swisswatch-0.06.orig/ 40700 1755 1750 0 5326260030 12732 5ustar krsusersswisswatch-0.06.orig/Hand.h100600 1755 1750 267 5157477347 14070 0ustar krsusers#ifndef _Hand_h_ #define _Hand_h_ typedef struct _HandClassRec *HandWidgetClass; typedef struct _HandRec *HandWidget; extern WidgetClass handWidgetClass; #endif /* not _Hand_h_ */ swisswatch-0.06.orig/HandOrMark.h100600 1755 1750 1716 5157741657 15222 0ustar krsusers#ifndef _HandOrMark_h_ #define _HandOrMark_h_ #define XtNclass "class" #define XtNinner "inner" #define XtNouter "outer" #define XtNcycle "cycle" #define XtNstrokeWidth "strokeWidth" #define XtNstrokeWidthR "strokeWidthR" #define XtCClass "Class" #define XtCInner "Inner" #define XtCOuter "Outer" #define XtCCycle "Cycle" #define XtCStrokeWidth "StrokeWidth" #define XtCStrokeWidthR "StrokeWidthR" #define XtNcap "cap" #define XtNjoin "join" #define XtNshape "shape" #define XtNrender "render" #define XtNphase "phase" #define XtNcolor "color" #define XtNcenterX "centerX" #define XtNcenterY "centerY" #define XtCCap "Cap" #define XtCJoin "Join" #define XtCShape "Shape" #define XtCRender "Render" #define XtCPhase "Phase" #define XtCCenterX "CenterX" #define XtCCenterY "CenterY" typedef struct _HandOrMarkClassRec *HandOrMarkWidgetClass; typedef struct _HandOrMarkRec *HandOrMarkWidget; extern WidgetClass handOrMarkWidgetClass; #endif /* not _HandOrMark_h_ */ swisswatch-0.06.orig/HandP.h100600 1755 1750 1034 5157726466 14220 0ustar krsusers#ifndef _HandP_h_ #define _HandP_h_ #include "HandOrMarP.h" #include "Hand.h" typedef struct _HandClassPart { int dummy; } HandClassPart; typedef struct _HandClassRec { ObjectClassPart object_class; HandOrMarkClassPart hand_or_mark_class_part; HandClassPart hand_class_part; } HandClassRec; extern HandClassRec handClassRec; typedef struct _HandPart { int dummy; } HandPart; typedef struct _HandRec { ObjectPart object; HandOrMarkPart hand_or_mark; HandPart hand; } HandRec; #endif /* not _HandP_h_ */ swisswatch-0.06.orig/Mark.c100600 1755 1750 4664 5201730202 14074 0ustar krsusers/***************************************************************************** * File Name: Mark.c * Description: Mark widget class -- implementation * Author: Simon Leinen (simon@liasun5) * Date Created: 6-May-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include "MarkP.h" #include #if NeedFunctionPrototypes static void draw(Widget, Drawable, int, int); #else /* not NeedFunctionPrototypes */ static void draw(); #endif /* not NeedFunctionPrototypes */ MarkClassRec markClassRec = { { /* superclass */ (WidgetClass) & handOrMarkClassRec, /* class_name */ "Mark", /* widget_size */ sizeof(MarkRec), /* class_initialize */ NULL, /* class_part_initialize*/ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* pad */ NULL, /* pad */ NULL, /* pad */ 0, /* resources */ NULL, /* num_resources */ 0, /* xrm_class */ NULLQUARK, /* pad */ FALSE, /* pad */ FALSE, /* pad */ FALSE, /* pad */ FALSE, /* destroy */ NULL, /* pad */ NULL, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ NULL, /* pad */ NULL, /* get_values_hook */ NULL, /* pad */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* pad */ NULL, /* pad */ NULL, /* pad */ NULL, /* extension */ NULL, }, { /* draw */ draw, /* resize */ 0, /* realize */ 0, }, { /* dummy */ 0, }, }; WidgetClass markWidgetClass = (WidgetClass) &markClassRec; static void draw(w, d, width, height) Widget w; Drawable d; int width; int height; { #define mw ((MarkWidget) w) int cycle = mw->hand_or_mark.cycle; unsigned k; double sinus, cosinus; for (k = 0; k < cycle; ++k) { double ang = M_PI_2-((double)k/(double)cycle*2*M_PI); #if HAVE_SINCOS sincos(ang, &sinus, &cosinus); #else /* not HAVE_SINCOS */ sinus = sin(ang); cosinus = cos(ang); #endif /* not HAVE_SINCOS */ DrawShape((HandOrMarkWidget)mw, d, mw->hand_or_mark.fg_gc, sinus, cosinus); } #undef mw } swisswatch-0.06.orig/Mark.h100600 1755 1750 267 5157477354 14106 0ustar krsusers#ifndef _Mark_h_ #define _Mark_h_ typedef struct _MarkClassRec *MarkWidgetClass; typedef struct _MarkRec *MarkWidget; extern WidgetClass markWidgetClass; #endif /* not _Mark_h_ */ swisswatch-0.06.orig/MarkP.h100600 1755 1750 1034 5157726502 14227 0ustar krsusers#ifndef _MarkP_h_ #define _MarkP_h_ #include "HandOrMarP.h" #include "Mark.h" typedef struct _MarkClassPart { int dummy; } MarkClassPart; typedef struct _MarkClassRec { ObjectClassPart object_class; HandOrMarkClassPart hand_or_mark_class_part; MarkClassPart mark_class_part; } MarkClassRec; extern MarkClassRec markClassRec; typedef struct _MarkPart { int dummy; } MarkPart; typedef struct _MarkRec { ObjectPart object; HandOrMarkPart hand_or_mark; MarkPart mark; } MarkRec; #endif /* not _MarkP_h_ */ swisswatch-0.06.orig/SWatch.ad100600 1755 1750 13301 5326045131 14551 0ustar krsusers!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! File Name: SWatch.ad !!! Description: Application defaults for the SwissWatch application class !!! Author: Simon Leinen (simon@liasun6.epfl.ch) !!! Date Created: 12-Mar-92 !!! RCS $Header$ !!! RCS $Log$ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *SwissWatch.TickTime: 1 *SwissWatch.Background: black *SwissWatch.nChildren: 3 *SwissWatch.Hand.inner: 0 *SwissWatch.Hand.outer: .9 *SwissWatch.width: 100 *SwissWatch.height: 100 swisswatch*Background: black swisswatch*Foreground: white swisswatch*SwissWatch.nChildren: 7 swisswatch*SwissWatch.Hand.inner: -.05 swisswatch*SwissWatch.Hand.width: 0 swisswatch*SwissWatch.*.cap: round swisswatch*SwissWatch.Hand.shape: rectangle swisswatch*SwissWatch.child_0.class: Mark swisswatch*SwissWatch.child_0.cycle: 60 swisswatch*SwissWatch.child_0.strokeWidthR: 0.01 swisswatch*SwissWatch.child_0.inner: 0.79 swisswatch*SwissWatch.child_0.outer: 0.8 swisswatch*SwissWatch.child_1.class: Mark swisswatch*SwissWatch.child_1.cycle: 12 swisswatch*SwissWatch.child_1.strokeWidthR: 0.02 swisswatch*SwissWatch.child_1.inner: .71 swisswatch*SwissWatch.child_1.outer: .8 swisswatch*SwissWatch.child_2.class: Hand swisswatch*SwissWatch.child_2.cycle: 43200 swisswatch*SwissWatch.child_2.outer: .40 swisswatch*SwissWatch.child_2.render: outlined swisswatch*SwissWatch.child_2.strokeWidthR: 0.1 swisswatch*SwissWatch.child_3.class: Hand swisswatch*SwissWatch.child_3.cycle: 3600 swisswatch*SwissWatch.child_3.outer: .60 swisswatch*SwissWatch.child_3.render: outlined swisswatch*SwissWatch.child_3.strokeWidthR: 0.075 swisswatch*SwissWatch.child_4.class: Hand swisswatch*SwissWatch.child_4.cycle: 43200 swisswatch*SwissWatch.child_4.outer: .38 swisswatch*SwissWatch.child_4.inner: .30 swisswatch*SwissWatch.child_4.render: outlined swisswatch*SwissWatch.child_4.strokeWidthR: 0.05 swisswatch*SwissWatch.child_5.class: Hand swisswatch*SwissWatch.child_5.cycle: 3600 swisswatch*SwissWatch.child_5.outer: .58 swisswatch*SwissWatch.child_5.inner: .50 swisswatch*SwissWatch.child_5.render: outlined swisswatch*SwissWatch.child_5.strokeWidthR: 0.0375 swisswatch*SwissWatch.child_6.class: Hand swisswatch*SwissWatch.child_6.render: filled swisswatch*SwissWatch.child_6.shape: circle swisswatch*SwissWatch.child_6.cycle: 60 swisswatch*SwissWatch.child_6.outer: 0.575 swisswatch*SwissWatch.child_6.width: 0.15 swissclock*Background: snow1 swissclock*Foreground: black swissclock*SwissWatch.width: 300 swissclock*SwissWatch.height: 300 swissclock*SwissWatch.nChildren: 7 swissclock*SwissWatch.*.StrokeWidth: 0 swissclock*SwissWatch.*.render: outlined swissclock*SwissWatch.*.width: 0 swissclock*SwissWatch.Hand.inner: -.18 swissclock*SwissWatch.child_0.class: Mark swissclock*SwissWatch.child_0.Cycle: 60 swissclock*SwissWatch.child_0.Inner: .90 swissclock*SwissWatch.child_0.Outer: .95 swissclock*SwissWatch.child_0.StrokeWidthR: .03 swissclock*SwissWatch.child_1.class: Mark swissclock*SwissWatch.child_1.Cycle: 12 swissclock*SwissWatch.child_1.Inner: .82 swissclock*SwissWatch.child_1.Outer: .95 swissclock*SwissWatch.child_1.StrokeWidthR: .03 swissclock*SwissWatch.child_2.class: Mark swissclock*SwissWatch.child_2.shape: circle swissclock*SwissWatch.child_2.render: outline swissclock*SwissWatch.child_2.outer: 0 swissclock*SwissWatch.child_2.width: 1.99 swissclock*SwissWatch.child_2.strokeWidthR: .03 swissclock*SwissWatch.child_2.cycle: 1 swissclock*SwissWatch.child_3.class: Hand swissclock*SwissWatch.child_3.outer: .60 swissclock*SwissWatch.child_3.shape: arrow swissclock*SwissWatch.child_3.render: filled swissclock*SwissWatch.child_3.width: .10 swissclock*SwissWatch.child_3.cycle: 43200 swissclock*SwissWatch.child_4.class: Hand swissclock*SwissWatch.child_4.outer: .81 swissclock*SwissWatch.child_4.shape: arrow swissclock*SwissWatch.child_4.render: filled swissclock*SwissWatch.child_4.width: .08 swissclock*SwissWatch.child_4.cycle: 3600 swissclock*SwissWatch.child_5.class: Hand swissclock*SwissWatch.child_5.strokeWidthR: 0.03 swissclock*SwissWatch.child_5.inner: -.26 swissclock*SwissWatch.child_5.outer: .78 swissclock*SwissWatch.child_5.cycle: 60 swissclock*SwissWatch.child_6.class: Hand swissclock*SwissWatch.child_6.shape: circle swissclock*SwissWatch.child_6.render: filled swissclock*SwissWatch.child_6.outer: .78 swissclock*SwissWatch.child_6.width: .20 swissclock*SwissWatch.child_6.cycle: 60 swissclock*SwissWatch.*.shape: rectangle swissclock*SwissWatch.railroad: true swissclock*SwissWatch.circular: true oclock*SwissWatch.nChildren: 4 oclock*SwissWatch.TickTime: 60 oclock*SwissWatch.child_0.Class: Mark oclock*SwissWatch.child_0.Cycle: 1 oclock*SwissWatch.child_0.Shape: circle oclock*SwissWatch.child_0.Render: filled oclock*SwissWatch.child_0.Width: 0.075 oclock*SwissWatch.child_0.Inner: .825 oclock*SwissWatch.child_0.Outer: .825 oclock*SwissWatch.child_1.Class: Mark oclock*SwissWatch.child_1.Cycle: 1 oclock*SwissWatch.child_1.Inner: 0 oclock*SwissWatch.child_1.Outer: 0 oclock*SwissWatch.child_1.Width: 1.9 oclock*SwissWatch.child_1.Shape: circle oclock*SwissWatch.child_1.Render: outlined oclock*SwissWatch.child_1.Color: black oclock*SwissWatch.child_1.StrokeWidthR: 0.1 oclock*SwissWatch.Hand.Shape: arrow oclock*SwissWatch.Hand.Render: filled oclock*SwissWatch.Hand.Width: 0.09 oclock*SwissWatch.child_2.Class: Hand oclock*SwissWatch.child_2.Cycle: 43200 oclock*SwissWatch.child_2.Outer: 0.45 oclock*SwissWatch.child_3.Class: Hand oclock*SwissWatch.child_3.Outer: 0.72 oclock*SwissWatch.child_3.Cycle: 3600 swisswatch-0.06.orig/SwissWatcP.h100600 1755 1750 2347 5157742122 15270 0ustar krsusers#ifndef _SwissWatchP_h_ #define _SwissWatchP_h_ #include #include "SwissWatch.h" typedef struct _SwissWatchClassPart { int dummy; } SwissWatchClassPart; typedef struct _SwissWatchClassRec { CoreClassPart core_class; CompositeClassPart composite_class; SwissWatchClassPart swiss_watch_class; } SwissWatchClassRec; extern SwissWatchClassRec swissWatchClassRec; typedef struct _SwissWatchPart { unsigned n_children; float tick_time; double now; long now_local_sec; double frac_sec; double expected; XtIntervalId timeout; Boolean shape_window; Boolean circular; Boolean swiss_mode; #ifdef SHAPE GC shape_gc; Pixmap shape_mask; int shape_width; int shape_height; #endif /* SHAPE */ GC bg_gc; Pixmap mark_pic; Pixmap pic; int rad_x; int rad_y; int cx; int cy; } SwissWatchPart; typedef struct _SwissWatchRec { CorePart core; CompositePart composite; SwissWatchPart swiss_watch; } SwissWatchRec; #ifdef NeedFunctionPrototypes #define SwissWatchInheritResize (((void *)(Widget, int, int)) 0) #else /* not NeedFunctionPrototypes */ #define SwissWatchInheritResize (((void *)()) 0) #endif /* not NeedFunctionPrototypes */ #endif /* not _SwissWatchP_h_ */ swisswatch-0.06.orig/SwissWatch.c100600 1755 1750 34477 5326246345 15350 0ustar krsusers/***************************************************************************** * File Name: SwissWatch.c * Description: Swisswatch widget class -- implementation * Author: Simon Leinen (simon@liasun5) * Date Created: 6-May-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include #include #include #ifdef SHAPE #include #endif /* SHAPE */ #include "SwissWatcP.h" #include "HandOrMarP.h" #include "Hand.h" #include "Mark.h" #include #if NeedFunctionPrototypes static void Initialize(Widget,Widget,ArgList,Cardinal*); static void Realize(Widget,XtValueMask*,XSetWindowAttributes*); static void Redisplay(Widget,XEvent*,Region); static void Resize(Widget); static void Destroy(Widget); static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *); static void ClassInitialize(void); static void convert_string_to_widget_class(XrmValue*,Cardinal*,XrmValue*,XrmValue*); static void adapt_size(SwissWatchWidget); static void tock(SwissWatchWidget,int); static void tick(XtPointer,XtIntervalId *); static void drawhands(SwissWatchWidget); static void drawmarks(SwissWatchWidget); static void destroy_gcs(SwissWatchWidget); static void get_gcs(SwissWatchWidget); #else /* not NeedFunctionPrototypes */ static void Initialize(); static void Realize(); static void Redisplay(); static void Resize(); static void Destroy(); static Boolean SetValues(); static void ClassInitialize(); static void convert_string_to_widget_class(); static void adapt_size(); static void tick(); static void tock(); static void drawhands(); static void drawmarks(); static void destroy_gcs(); static void get_gcs(); #endif /* not NeedFunctionPrototypes */ #if !defined(__STDC__) extern int sprintf(); extern int gettimeofday(); #endif /* __STDC__ */ #define offset(slot) XtOffsetOf(SwissWatchRec,swiss_watch.slot) static XtResource resources[] = { {XtNnChildren, XtCNChildren, XtRInt,sizeof(Cardinal), offset(n_children), XtRImmediate, (XtPointer)0}, {XtNtickTime, XtCTickTime, XtRFloat,sizeof(float), offset(tick_time), XtRString, (XtPointer)"2.0"}, #ifdef SHAPE {XtNshapeWindow,XtCShapeWindow,XtRBoolean,sizeof(Boolean), offset(shape_window),XtRString,"true"}, #endif {XtNcircular,XtCCircular,XtRBoolean,sizeof(Boolean), offset(circular),XtRString,"false"}, {XtNrailroad,XtCRailroad,XtRBoolean,sizeof(Boolean), offset(swiss_mode),XtRString,"false"}, }; #undef offset static CompositeClassExtensionRec extension_rec = { /* next_extension */ NULL, /* record_type */ NULLQUARK, /* version */ XtCompositeExtensionVersion, /* record_size */ sizeof(CompositeClassExtensionRec), /* accepts_objects */ TRUE, }; #define superclass (&compositeClassRec) SwissWatchClassRec swissWatchClassRec = { { /******* CorePart *******/ /* superclass */ (WidgetClass) superclass, /* class_name */ "SwissWatch", /* widget_size */ sizeof(SwissWatchRec), /* class_initialize */ ClassInitialize, /* class_part_initialize*/ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ TRUE, /* compress_enterleave */ FALSE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ Resize, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* tm_table */ NULL, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /**** CompositePart *****/ /* geometry_handler */ XtInheritGeometryManager, /* change_managed */ XtInheritChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ (XtPointer) & extension_rec, }, { /* dummy */ 0, } }; #define WIDTH(widget) ((widget)->core.width) #define HEIGHT(widget) ((widget)->core.height) #define RAD_X(w) ((w)->swiss_watch.rad_x) #define RAD_Y(w) ((w)->swiss_watch.rad_y) #define CX(w) ((w)->swiss_watch.cx) #define CY(w) ((w)->swiss_watch.cy) WidgetClass swissWatchWidgetClass = (WidgetClass) &swissWatchClassRec; typedef struct _ChildResources { WidgetClass class; } ChildResources; static XtResource child_resources[] = { {XtNclass, XtCClass, XtRWidgetClass,sizeof(WidgetClass), XtOffsetOf(ChildResources,class), XtRString, (XtPointer)"mark"} }; static void Initialize(req, new, args, num_args) Widget req; Widget new; ArgList args; Cardinal * num_args; { #define w_new ((SwissWatchWidget) new) unsigned k; char child_name[12]; ChildResources resource_struct; for (k = 0; k < w_new->swiss_watch.n_children; ++k) { sprintf(child_name, "child_%d", k); XtGetSubresources(req, & resource_struct, child_name, "Child", child_resources, XtNumber(child_resources), NULL, 0); XtVaCreateManagedWidget(child_name, resource_struct.class, new, NULL); } #ifdef SHAPE { int shape_event_base, shape_error_base; if (w_new->swiss_watch.shape_window && !XShapeQueryExtension(XtDisplay(new), &shape_event_base, &shape_error_base)) w_new->swiss_watch.shape_window = False; w_new->swiss_watch.shape_mask = 0; w_new->swiss_watch.shape_gc = 0; w_new->swiss_watch.shape_width = 0; w_new->swiss_watch.shape_height = 0; } #endif /* SHAPE */ #undef w_new } static void ClassInitialize() { XtAddConverter(XtRString, XtRWidgetClass, convert_string_to_widget_class, NULL, 0); } #define ForAllChildren(w, child) \ for ( (child) = (Widget *) (w)->composite.children ; \ (child) < (Widget *) ( (w)->composite.children + \ (w)->composite.num_children ) ; \ (child)++ ) static void Redisplay(w, event, region) Widget w; XEvent * event; Region region; { #define ww ((SwissWatchWidget) w) #define ev ((XExposeEvent *) event) if (event==0) XCopyArea(XtDisplay(w),ww->swiss_watch.pic,XtWindow(w),ww->swiss_watch.bg_gc, 0,0,w->core.width,w->core.height,0,0); else XCopyArea(XtDisplay(w),ww->swiss_watch.pic,XtWindow(w),ww->swiss_watch.bg_gc, ev->x,ev->y,ev->width,ev->height,ev->x,ev->y); #undef ev #undef ww } static void convert_string_to_widget_class(args, num_args, from, to) XrmValue* args; Cardinal* num_args; XrmValue* from; XrmValue* to; { char lower_name[1000]; to->size = sizeof(WidgetClass); XmuCopyISOLatin1Lowered(lower_name, (char *) from->addr); if (!strcmp(lower_name, "hand")) { to->addr = (XtPointer) & handWidgetClass; return; } if (!strcmp(lower_name, "mark")) { to->addr = (XtPointer) & markWidgetClass; return; } to->size = 0; to->addr = NULL; } static void Realize(w, mask, attributes) Widget w; XtValueMask* mask; XSetWindowAttributes* attributes; { #define ww ((SwissWatchWidget) w) Widget * childp; (*superclass->core_class.realize) (w, mask, attributes); get_gcs(ww); tock(ww,TRUE); adapt_size(ww); ForAllChildren(ww, childp) { RealizeHandOrMark((HandOrMarkWidget) (* childp)); } #undef ww } static void tock(w, init_p) SwissWatchWidget w; int init_p; { double now; double next; double tick_time = w->swiss_watch.tick_time; struct tm * tm_now; struct timeval tvnow; gettimeofday(& tvnow, (struct timezone *) 0); tm_now = localtime(&tvnow.tv_sec); #if HAVE_GMTOFF w->swiss_watch.now_local_sec = tvnow.tv_sec+tm_now->tm_gmtoff; #else /* not HAVE_GMTOFF */ w->swiss_watch.now_local_sec = tm_now->tm_sec+tm_now->tm_min*60+tm_now->tm_hour*3600+tm_now->tm_mday*86400; w->swiss_watch.frac_sec = tvnow.tv_usec*1e-6; #endif /* not HAVE_GMTOFF */ now = tvnow.tv_sec+1e-6*tvnow.tv_usec; if (init_p) { int int_tick = (int) tick_time; if (int_tick==0) int_tick = 1; if (int_tick > 1) { int next_sec = ((tm_now->tm_sec + int_tick) / int_tick); next_sec *= int_tick; next = tvnow.tv_sec + next_sec - tm_now->tm_sec; } else next = (tvnow.tv_sec/int_tick+1)*int_tick; } else { next = w->swiss_watch.expected+tick_time; while(next < now) next += tick_time; } w->swiss_watch.expected = next; #ifdef DEBUG printf("%8f %8f %6d\n", tick_time, next-now, (int) ((next-now)*1000)); #endif /* 0 */ XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)w), (int) ((next-now)*1000), tick, (XtPointer)w); } static void tick(closure, interval) XtPointer closure; XtIntervalId * interval; { tock((SwissWatchWidget) closure, FALSE); drawhands((SwissWatchWidget) closure); Redisplay((Widget) closure, (XEvent*) 0, (Region) 0); } static void Resize(w) Widget w; { #define ww ((SwissWatchWidget) w) Display * display = XtDisplay(w); if (XtIsRealized (w)) { XFreePixmap(display,ww->swiss_watch.mark_pic); XFreePixmap(display,ww->swiss_watch.pic); adapt_size(ww); } #undef ww } static void adapt_size(w) SwissWatchWidget w; { Display * display = XtDisplay(w); int depth = DefaultDepthOfScreen(XtScreen(w)); Widget * childp; double scale; w->swiss_watch.mark_pic = XCreatePixmap(display,XtWindow(w),WIDTH(w),HEIGHT(w),depth); w->swiss_watch.pic = XCreatePixmap(display,XtWindow(w),WIDTH(w),HEIGHT(w),depth); w->swiss_watch.cx = WIDTH(w)/2; w->swiss_watch.cy = HEIGHT(w)/2; if (w->swiss_watch.circular) w->swiss_watch.rad_x = w->swiss_watch.rad_y = scale = (CX(w) < CY(w)) ? CX(w) : CY(w); else w->swiss_watch.rad_x = CX(w), w->swiss_watch.rad_y = CY(w), scale = sqrt((double) (CX(w)*CY(w))); #ifdef SHAPE if (w->swiss_watch.shape_window) { Pixmap shape_mask; XGCValues xgcv; int x; int y; Widget parent; shape_mask = XCreatePixmap (XtDisplay (w), XtWindow (w), WIDTH(w), HEIGHT(w), 1); if (!w->swiss_watch.shape_gc) w->swiss_watch.shape_gc = XCreateGC (XtDisplay((Widget) w), shape_mask, 0, &xgcv); /* erase the pixmap */ XSetForeground (XtDisplay (w), w->swiss_watch.shape_gc, 0); XFillRectangle (XtDisplay (w), shape_mask, w->swiss_watch.shape_gc, 0, 0, WIDTH(w), HEIGHT(w)); XSetForeground (XtDisplay (w), w->swiss_watch.shape_gc, 1); XFillArc (XtDisplay (w), shape_mask, w->swiss_watch.shape_gc, CX(w)-RAD_X(w),CY(w)-RAD_Y(w), 2*RAD_X(w),2*RAD_Y(w), 0,360*64); /* Find the highest enclosing widget and shape it */ x = 0; y = 0; for (parent = (Widget) w; XtParent (parent); parent = XtParent (parent)) { x = x + parent->core.x + parent->core.border_width; y = y + parent->core.y + parent->core.border_width; } XShapeCombineMask (XtDisplay (parent), XtWindow (parent), ShapeBounding, x, y, shape_mask, ShapeSet); /* erase the pixmap */ XSetForeground (XtDisplay (w), w->swiss_watch.shape_gc, 0); XFillRectangle (XtDisplay (w), shape_mask, w->swiss_watch.shape_gc, 0, 0, WIDTH(w), HEIGHT(w)); XSetForeground (XtDisplay (w), w->swiss_watch.shape_gc, 1); /* draw the clip shape */ XFillArc (XtDisplay (w),shape_mask,w->swiss_watch.shape_gc, CX(w)-RAD_X(w),CY(w)-RAD_Y(w), 2*RAD_X(w),2*RAD_Y(w), 0,360*64); XShapeCombineMask (XtDisplay (w), XtWindow (w), ShapeClip, 0, 0, shape_mask, ShapeSet); XFreePixmap (XtDisplay (w), shape_mask); } #endif /* SHAPE */ ForAllChildren(w, childp) { ResizeHandOrMark((HandOrMarkWidget) (* childp), RAD_X(w), RAD_Y(w)); } if (XtIsRealized((Widget) w)) { drawmarks(w); drawhands(w); } } static void Destroy(w) Widget w; { #define ww ((SwissWatchWidget) w) #ifdef SHAPE destroy_gcs(ww); XFreePixmap(XtDisplay(w), ww->swiss_watch.shape_mask); #endif /* SHAPE */ XtReleaseGC(w, ww->swiss_watch.bg_gc); XFreePixmap(XtDisplay(w), ww->swiss_watch.mark_pic); XFreePixmap(XtDisplay(w), ww->swiss_watch.pic); if (ww->swiss_watch.timeout) XtRemoveTimeOut(ww->swiss_watch.timeout); #undef ww } static void drawhands(ww) SwissWatchWidget ww; { Widget * childp; #define w ((Widget) ww) XCopyArea(XtDisplay(w), ww->swiss_watch.mark_pic,ww->swiss_watch.pic,ww->swiss_watch.bg_gc, 0,0,WIDTH(w),HEIGHT(w),0,0); ForAllChildren(ww, childp) { if (XtIsSubclass(*childp, handWidgetClass)) DrawHandOrMark((HandOrMarkWidget)*childp, ww->swiss_watch.pic); } #undef w } static void drawmarks(ww) SwissWatchWidget ww; { Widget * childp; #define w ((Widget) ww) XFillRectangle(XtDisplay(w),ww->swiss_watch.mark_pic,ww->swiss_watch.bg_gc, 0,0,ww->core.width,ww->core.height); ForAllChildren(ww, childp) { if (XtIsSubclass(*childp, markWidgetClass)) DrawHandOrMark((HandOrMarkWidget)*childp, ww->swiss_watch.mark_pic); } #undef w } static Boolean SetValues(current, request, new, args, num_args) Widget current; Widget request; Widget new; ArgList args; Cardinal * num_args; { #define w_cur ((SwissWatchWidget) current) #define w_new ((SwissWatchWidget) new) #define CHANGED(FIELD) (w_cur->FIELD != w_new->FIELD) Boolean needs_redisplay = FALSE; Boolean needs_reset = FALSE; Boolean needs_new_gcs = FALSE; if (CHANGED (core.background_pixel)) needs_redisplay = needs_reset = needs_new_gcs = TRUE; if (needs_new_gcs && XtIsRealized (current)) { destroy_gcs(w_cur); get_gcs(w_new); } if (needs_reset) SwissWatchReset(w_new); return needs_redisplay; #undef CHANGED #undef w_cur #undef w_new } static void destroy_gcs(w) SwissWatchWidget w; { XtReleaseGC((Widget) w, w->swiss_watch.shape_gc); } static void get_gcs(w) SwissWatchWidget w; { XGCValues values; values.foreground = w->core.background_pixel; w->swiss_watch.bg_gc = XtGetGC ((Widget) w, GCForeground, & values); } extern void SwissWatchReset(w) SwissWatchWidget w; { drawmarks(w); drawhands(w); } swisswatch-0.06.orig/SwissWatch.h100600 1755 1750 3715 5163147365 15325 0ustar krsusers/***************************************************************************** * File Name: SwissWatch.h * Description: SwissWatch widget -- public header file * Author: Simon Leinen (simon@liasun6) * Date Created: 12-Mar-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #ifndef _SwissWatch_h_ #define _SwissWatch_h_ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL height Height Dimension computed at create icon Icon Pixmap 0 label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True value Value String NULL width Width Dimension computed at create x Position Position 0 y Position Position 0 nChildren NChildren Cardinal 0 tickTime TickTime Float 1.0 railroad Railroad Boolean False circular Circular Boolean False shapeWindow ShapeWindow Boolean True (if the SHAPE extension is available) */ #define XtNnChildren "nChildren" #define XtNtickTime "tickTime" #define XtNrailroad "railroad" #define XtNcircular "circular" #define XtNtickTime "tickTime" #define XtNshapeWindow "shapeWindow" #define XtCNChildren "NChildren" #define XtCTickTime "TickTime" #define XtCRailroad "Railroad" #define XtCCircular "Circular" #define XtCTickTime "TickTime" #define XtCShapeWindow "ShapeWindow" typedef struct _SwissWatchClassRec *SwissWatchWidgetClass; typedef struct _SwissWatchRec *SwissWatchWidget; extern WidgetClass swissWatchWidgetClass; #if NeedFunctionPrototypes extern void SwissWatchReset(SwissWatchWidget); #else extern void SwissWatchReset(); #endif #endif /* not _SwissWatch_h_ */ swisswatch-0.06.orig/TableConvert.c100600 1755 1750 5541 5201730211 15565 0ustar krsusers/***************************************************************************** * File Name: TableConvert.c * Description: Generic XtRString to Enum Conversion Using Tables * Author: Simon Leinen (simon@liasun6) * Date Created: 5-Jul-91 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include #include "TableConvert.h" #if NeedFunctionPrototypes static Boolean table_convert(Display*,XrmValue*,Cardinal*,XrmValue*,XrmValue*,XtPointer*); #else /* not NeedFunctionPrototypes */ static Boolean table_convert(); #endif /* not NeedFunctionPrototypes */ typedef struct _InternalLookupTableEntryRec { XrmQuark quark; int value; } InternalLookupTableEntryRec, * InternalLookupTableEntry; typedef struct _InternalLookupTableRec { InternalLookupTableEntryRec * entries; Cardinal n_entries; } InternalLookupTableRec, * InternalLookupTable; extern void set_table_converter(to_type,entries,n_entries) String to_type; LOOKUP_TABLE_ENTRY * entries; Cardinal n_entries; { Cardinal k; InternalLookupTable internal_lookup_table; XtConvertArgList arglist = XtNew(XtConvertArgRec); internal_lookup_table = XtNew(InternalLookupTableRec); internal_lookup_table->n_entries = n_entries; internal_lookup_table->entries = (InternalLookupTableEntryRec *) XtCalloc(n_entries,sizeof(InternalLookupTableEntryRec)); for (k=0; kentries[k].quark = XrmStringToQuark(buffer); internal_lookup_table->entries[k].value = entries[k].value; } arglist[0].address_mode = XtImmediate; arglist[0].address_id = (XtPointer) internal_lookup_table; arglist[0].size = sizeof internal_lookup_table; XtSetTypeConverter(XtRString,to_type,table_convert, arglist,1, XtCacheNone,(XtDestructor)0); } static Boolean table_convert(display,args,n_args,from,to,converter_data) Display * display; XrmValue * args; Cardinal * n_args; XrmValue * from; XrmValue * to; XtPointer * converter_data; { unsigned k; char buffer[1000]; InternalLookupTable table = * (InternalLookupTable *) args[0].addr; XrmQuark quark; XmuCopyISOLatin1Lowered(buffer,(String) from->addr); quark = XrmStringToQuark(buffer); for (k = 0; k < table->n_entries; ++k) if (quark==table->entries[k].quark) { if (to->addr!=0) { if (to->size < sizeof(int)) { to->size = sizeof(int); return False; } *(int *) to->addr = table->entries[k].value; } else { to->addr = (XtPointer) & table->entries[k].value; to->size = sizeof(int); } return True; } XtDisplayStringConversionWarning (display,(char *)from->addr,"AnEnumerationType"); return False; } swisswatch-0.06.orig/TableConvert.h100600 1755 1750 1507 5201744052 15600 0ustar krsusers/***************************************************************************** * File Name: TableConvert.h * Description: Generic XtRString to Enum Conversion Using Tables * Author: Simon Leinen (simon@liasun6) * Date Created: 5-Jul-91 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #ifndef _TableConvert_h_ #define _TableConvert_h_ #include struct lookup_table_entry_ { char *name; int value; } ; typedef struct lookup_table_entry_ LOOKUP_TABLE_ENTRY; #if NeedFunctionPrototypes extern void set_table_converter(String,LOOKUP_TABLE_ENTRY *,Cardinal); #else /* not NeedFunctionPrototypes */ extern void set_table_converter(/*String,LOOKUP_TABLE_ENTRY *,Cardinal*/); #endif /* not NeedFunctionPrototypes */ #endif /* not _TableConvert_h_ */ swisswatch-0.06.orig/swisswatch.c100600 1755 1750 5603 5202475157 15413 0ustar krsusers/***************************************************************************** * File Name: swisswatch.c * Description: Swiss X Watch * Author: Simon Leinen (simon@liasun5) * Date Created: 10-Mar-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include #include "SwissWatch.h" #include #if NeedFunctionPrototypes static Widget initialize_user_interface(int*argcp,char**argv); static void quit(Widget,XEvent *,String *,Cardinal *); #else /* not NeedFunctionPrototypes */ static Widget initialize_user_interface(); static void quit(); #endif /* not NeedFunctionPrototypes */ extern int main(argc, argv) int argc; char *argv[]; { (void) initialize_user_interface(& argc, argv); XtMainLoop(); return 0; } static XrmOptionDescRec options[] = { {"-fg", "*Foreground", XrmoptionSepArg, NULL}, {"-bg", "*Background", XrmoptionSepArg, NULL}, {"-foreground", "*Foreground", XrmoptionSepArg, NULL}, {"-background", "*Background", XrmoptionSepArg, NULL}, {"-tick", "*swissWatch.tickTime", XrmoptionSepArg, NULL}, {"-railroad", "*swissWatch.railroad", XrmoptionNoArg, (XtPointer)"True"}, {"-sbb", "*swissWatch.railroad", XrmoptionNoArg, (XtPointer)"True"}, {"-cff", "*swissWatch.railroad", XrmoptionNoArg, (XtPointer)"True"}, {"-ffs", "*swissWatch.railroad", XrmoptionNoArg, (XtPointer)"True"}, {"-noshape", "*swissWatch.shapeWindow", XrmoptionNoArg, (XtPointer)"False"}, {"-circular", "*swissWatch.circular", XrmoptionNoArg, (XtPointer)"True"}, }; static XtActionsRec actions[] = { {"quit", quit}, }; static Atom wm_delete_window; static Widget initialize_user_interface(argcp, argv) int * argcp; char ** argv; { Widget top_level; XtAppContext app_c; top_level = XtInitialize(argv[0], "SwissWatch", options, XtNumber(options), argcp, argv); if (* argcp != 1) { fprintf (stderr, "usage: %s [toolkitoptions ...]\n", argv[0]); exit (42); } app_c = XtWidgetToApplicationContext(top_level); XtAppAddActions(app_c, actions, XtNumber(actions)); XtVaCreateManagedWidget("swissWatch", swissWatchWidgetClass, top_level, NULL); XtRealizeWidget(top_level); XtOverrideTranslations (top_level, XtParseTranslationTable ("WM_PROTOCOLS: quit()")); wm_delete_window = XInternAtom(XtDisplay(top_level), "WM_DELETE_WINDOW", False); (void) XSetWMProtocols (XtDisplay(top_level), XtWindow(top_level), &wm_delete_window, 1); return top_level; } static void quit(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { if (event->type == ClientMessage && event->xclient.data.l[0] != wm_delete_window) { XBell(XtDisplay(w), 0); } else { XCloseDisplay(XtDisplay(w)); exit(0); } } swisswatch-0.06.orig/HandOrMark.c100600 1755 1750 32575 5326255434 15233 0ustar krsusers/***************************************************************************** * File Name: HandOrMark.c * Description: HandOrMark widget class -- implementation * Author: Simon Leinen (simon@liasun5) * Date Created: 6-May-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include #include #include "HandOrMarP.h" #include "SwissWatcP.h" #include "TableConvert.h" #include #define offset(slot) XtOffsetOf(HandOrMarkRec,hand_or_mark.slot) static XtResource resources[] = { {XtNinner, XtCInner, XtRFloat,sizeof(float), offset(inner), XtRString, (XtPointer)"0.0"}, {XtNouter, XtCOuter, XtRFloat,sizeof(float), offset(outer), XtRString, (XtPointer)"0.0"}, {XtNforeground, XtCForeground, XtRPixel,sizeof(Pixel), offset(foreground), XtRString, XtDefaultForeground}, {XtNcycle, XtCCycle, XtRInt,sizeof(int), offset(cycle), XtRString, "4711"}, {XtNstrokeWidth,XtCStrokeWidth, XtRDimension,sizeof(Dimension),offset(stroke_width), XtRString,"0"}, {XtNstrokeWidthR,XtCStrokeWidthR, XtRFloat,sizeof(float),offset(stroke_width_r), XtRString,"0"}, {XtNcap,XtCCap, XtRCapStyle,sizeof(int),offset(cap_style),XtRImmediate, (XtPointer)CapButt}, {XtNjoin,XtCJoin, XtRJoinStyle,sizeof(int),offset(join_style),XtRImmediate, (XtPointer)JoinMiter}, {XtNshape,XtCShape, XtRTickShape,sizeof(int),offset(shape_style),XtRImmediate, (XtPointer)ShapeRectangle}, {XtNrender,XtCRender, XtRTickRenderType,sizeof(int),offset(render_type),XtRImmediate, (XtPointer)ShapeRectangle}, {XtNwidth, XtCWidth, XtRFloat, sizeof(float), offset(width), XtRString, "0.0"}, {XtNphase, XtCPhase, XtRFloat, sizeof(float), offset(phase), XtRString, "0"}, {XtNcenterX, XtCCenterX, XtRFloat, sizeof(float), offset(cx), XtRString, "0"}, {XtNcenterY, XtCCenterY, XtRFloat, sizeof(float), offset(cy), XtRString, "0"}, }; #define RAD_X(w) ((w)->swiss_watch.rad_x) #define RAD_Y(w) ((w)->swiss_watch.rad_y) #define CX(w) ((w)->swiss_watch.cx) #define CY(w) ((w)->swiss_watch.cy) #undef offset #if NeedFunctionPrototypes static void InitializeClass(void); static void Destroy(Widget); static void Realize(Widget); static void Resize(Widget, int, int); static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *); static void get_hand_or_mark_gcs(HandOrMarkWidget); static void destroy_gcs(HandOrMarkWidget); #else /* not NeedFunctionPrototypes */ static void InitializeClass(); static void Destroy(); static void Realize(); static void Resize(); static Boolean SetValues(); static void get_hand_or_mark_gcs(); static void destroy_gcs(); #endif /* not NeedFunctionPrototypes */ HandOrMarkClassRec handOrMarkClassRec = { { /* superclass */ (WidgetClass) &objectClassRec, /* class_name */ "HandOrMark", /* widget_size */ sizeof(HandOrMarkRec), /* class_initialize */ InitializeClass, /* class_part_initialize*/ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* rect1 */ NULL, /* rect2 */ NULL, /* rect3 */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* rect4 */ FALSE, /* rect5 */ FALSE, /* rect6 */ FALSE, /* rect7 */ FALSE, /* destroy */ Destroy, /* resize */ NULL, /* expose */ NULL, /* set_values */ SetValues, /* set_values_hook */ NULL, /* pad */ NULL, /* get_values_hook */ NULL, /* pad */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* pad */ NULL, /* pad */ NULL, /* pad */ NULL, /* extension */ NULL, }, { /* draw */ NULL, /* resize */ Resize, /* realize */ Realize, } }; WidgetClass handOrMarkWidgetClass = (WidgetClass) &handOrMarkClassRec; static void Realize(w) Widget w; { } static void get_hand_or_mark_gcs(w) HandOrMarkWidget w; { XGCValues values; XtGCMask mask; SwissWatchWidget parent = (SwissWatchWidget) XtParent((Widget) w); int radius = sqrt((double) RAD_X(parent)*RAD_Y(parent)); if (w->hand_or_mark.shape_style==ShapeCircle && w->hand_or_mark.render_type==ShapeFill && RAD_X(parent)==RAD_Y(parent)) { w->hand_or_mark.use_draw_line_to_draw_circle = True; if (w->hand_or_mark.stroke_width_r) w->hand_or_mark.stroke_width = (int) (w->hand_or_mark.stroke_width_r*radius); else if (w->hand_or_mark.width) w->hand_or_mark.stroke_width = (int) (w->hand_or_mark.width*radius); w->hand_or_mark.cap_style = CapRound; } else { w->hand_or_mark.use_draw_line_to_draw_circle = False; if (w->hand_or_mark.stroke_width_r) w->hand_or_mark.stroke_width = (int) (w->hand_or_mark.stroke_width_r*radius); } values.foreground = w->hand_or_mark.foreground; values.line_width = w->hand_or_mark.stroke_width; values.cap_style = w->hand_or_mark.cap_style; values.join_style = w->hand_or_mark.join_style; mask = GCForeground | GCLineWidth | GCCapStyle | GCJoinStyle; w->hand_or_mark.fg_gc = XtGetGC((Widget) parent, mask, &values); } static void Destroy(w) Widget w; { #define ww ((HandOrMarkWidget) w) destroy_gcs(ww); #undef ww } static LOOKUP_TABLE_ENTRY cap_table[] = { { "notlast", CapNotLast }, { "butt", CapButt }, { "round", CapRound }, { "projecting", CapProjecting }, { "capnotlast", CapNotLast }, { "capbutt", CapButt }, { "capround", CapRound }, { "capprojecting", CapProjecting } }; static LOOKUP_TABLE_ENTRY join_table[] = { { "miter", JoinMiter }, { "round", JoinRound }, { "bevel", JoinBevel }, { "joinmiter", JoinMiter }, { "joinround", JoinRound }, { "joinbevel", JoinBevel } }; static LOOKUP_TABLE_ENTRY tick_shape_table[] = { { "triangle", ShapeTriangle }, { "triangular", ShapeTriangle }, { "rectangle", ShapeRectangle }, { "rectangular", ShapeRectangle }, { "arrow", ShapeArrow }, { "arrowed", ShapeArrow }, { "circle", ShapeCircle }, { "circular", ShapeCircle } }; static LOOKUP_TABLE_ENTRY tick_render_table[] = { { "outline", ShapeOutline }, { "outlined", ShapeOutline }, { "fill", ShapeFill }, { "filled", ShapeFill } }; static void InitializeClass() { set_table_converter (XtRCapStyle,cap_table,XtNumber(cap_table)); set_table_converter (XtRJoinStyle,join_table,XtNumber(join_table)); set_table_converter (XtRTickShape,tick_shape_table,XtNumber(tick_shape_table)); set_table_converter (XtRTickRenderType,tick_render_table,XtNumber(tick_render_table)); } extern void ResizeHandOrMark(hand_or_mark, width, height) HandOrMarkWidget hand_or_mark; int width; int height; { HandOrMarkWidgetClass class = (HandOrMarkWidgetClass) hand_or_mark->object.widget_class; while (class->hand_or_mark_class.resize==0) class = (HandOrMarkWidgetClass) class->object_class.superclass; (* class->hand_or_mark_class.resize) ((Widget) hand_or_mark, width, height); } extern void RealizeHandOrMark(hand_or_mark) HandOrMarkWidget hand_or_mark; { HandOrMarkWidgetClass class = (HandOrMarkWidgetClass) hand_or_mark->object.widget_class; while (class->hand_or_mark_class.realize==0) class = (HandOrMarkWidgetClass) class->object_class.superclass; (* class->hand_or_mark_class.realize) ((Widget) hand_or_mark); } static void Resize(w, width, height) Widget w; int width; int height; { #define hw ((HandOrMarkWidget) w) if (XtIsRealized(XtParent(w))) { destroy_gcs(hw); get_hand_or_mark_gcs(hw); } #undef hw } extern void DrawShape(w,d,gc,s,c) HandOrMarkWidget w; Drawable d; GC gc; double s; double c; { SwissWatchWidget parent = (SwissWatchWidget) XtParent((Widget) w); #define TX(x) (CX(parent)+(int)((w->hand_or_mark.cx+(x))*RAD_X(parent))) #define TY(y) (CY(parent)-(int)((w->hand_or_mark.cy+(y))*RAD_Y(parent))) switch (w->hand_or_mark.shape_style) { case ShapeTriangle: if (w->hand_or_mark.width < 1e-3) { XDrawLine(XtDisplay((Widget) parent),d,gc, TX(c*w->hand_or_mark.inner),TY(s*w->hand_or_mark.inner), TX(c*w->hand_or_mark.outer),TY(s*w->hand_or_mark.outer)); } else { XPoint p[4]; p[0].x = TX(c*w->hand_or_mark.outer); p[0].y = TY(s*w->hand_or_mark.outer); p[1].x = TX(c*w->hand_or_mark.inner-s*w->hand_or_mark.width/2); p[1].y = TY(s*w->hand_or_mark.inner+c*w->hand_or_mark.width/2); p[2].x = TX(c*w->hand_or_mark.inner+s*w->hand_or_mark.width/2); p[2].y = TY(s*w->hand_or_mark.inner-c*w->hand_or_mark.width/2); switch (w->hand_or_mark.render_type) { case ShapeOutline: p[3] = p[0]; XDrawLines(XtDisplay((Widget) parent),d,gc,&p[0],4,CoordModeOrigin); break; case ShapeFill: XFillPolygon(XtDisplay((Widget) parent),d,gc,&p[0],3,Convex,CoordModeOrigin); break; } } break; case ShapeRectangle: case ShapeArrow: if (w->hand_or_mark.width < 1e-3) { XDrawLine(XtDisplay((Widget) parent),d,gc, TX(c*w->hand_or_mark.inner),TY(s*w->hand_or_mark.inner), TX(c*w->hand_or_mark.outer),TY(s*w->hand_or_mark.outer)); } else { XPoint p[6]; Cardinal k=0; #define ADDPOINT(X,Y) (p[k].x = TX(X),p[k].y = TY(Y),++k) ADDPOINT((c*w->hand_or_mark.inner)-(s*w->hand_or_mark.width/2), (s*w->hand_or_mark.inner)+(c*w->hand_or_mark.width/2)); ADDPOINT((c*w->hand_or_mark.inner)+(s*w->hand_or_mark.width/2), (s*w->hand_or_mark.inner)-(c*w->hand_or_mark.width/2)); ADDPOINT((c*w->hand_or_mark.outer)+(s*w->hand_or_mark.width/2), (s*w->hand_or_mark.outer)-(c*w->hand_or_mark.width/2)); if (w->hand_or_mark.shape_style==ShapeArrow) { ADDPOINT(c*(w->hand_or_mark.outer+w->hand_or_mark.width/2), s*(w->hand_or_mark.outer+w->hand_or_mark.width/2)); } ADDPOINT((c*w->hand_or_mark.outer)-(s*w->hand_or_mark.width/2), (s*w->hand_or_mark.outer)+(c*w->hand_or_mark.width/2)); switch (w->hand_or_mark.render_type) { case ShapeOutline: p[k] = p[0],++k; XDrawLines(XtDisplay((Widget) parent),d,gc,&p[0],k,CoordModeOrigin); break; case ShapeFill: XFillPolygon(XtDisplay((Widget) parent),d,gc,&p[0],k,Convex,CoordModeOrigin); break; } #undef ADDPOINT } break; case ShapeCircle: switch (w->hand_or_mark.render_type) { case ShapeOutline: XDrawArc(XtDisplay((Widget) parent),d,gc, TX(c*w->hand_or_mark.outer-w->hand_or_mark.width/2), TY(s*w->hand_or_mark.outer+w->hand_or_mark.width/2), (int) (RAD_X(parent)*w->hand_or_mark.width), (int) (RAD_Y(parent)*w->hand_or_mark.width), 0,360*64); break; case ShapeFill: if (w->hand_or_mark.use_draw_line_to_draw_circle) { int cx = TX(c*w->hand_or_mark.outer); int cy = TY(s*w->hand_or_mark.outer); XDrawLine(XtDisplay((Widget) parent),d,gc,cx,cy,cx,cy); } else XFillArc(XtDisplay((Widget) parent),d,gc, TX(c*w->hand_or_mark.outer-w->hand_or_mark.width/2), TY(s*w->hand_or_mark.outer+w->hand_or_mark.width/2), (int) (RAD_X(parent)*w->hand_or_mark.width), (int) (RAD_Y(parent)*w->hand_or_mark.width), 0,360*64); break; } break; } #undef TX #undef TY } extern void DrawHandOrMark(w, d) HandOrMarkWidget w; Drawable d; { Widget parent = XtParent((Widget) w); HandOrMarkWidgetClass class = (HandOrMarkWidgetClass) w->object.widget_class; while (class->hand_or_mark_class.draw==0) class = (HandOrMarkWidgetClass) class->object_class.superclass; (* class->hand_or_mark_class.draw) ((Widget) w, d, parent->core.width, parent->core.height); } static Boolean SetValues(current, request, new, args, num_args) Widget current; Widget request; Widget new; ArgList args; Cardinal * num_args; { #define h_cur ((HandOrMarkWidget) current) #define h_new ((HandOrMarkWidget) new) Boolean needs_parent_reset = FALSE; Boolean needs_redisplay = FALSE; Boolean needs_new_gcs = FALSE; #define CHANGED(FIELD) (h_cur->FIELD != h_new->FIELD) if (CHANGED (hand_or_mark.stroke_width) && !CHANGED (hand_or_mark.stroke_width_r)) h_new->hand_or_mark.stroke_width_r = 0.0; if (CHANGED (hand_or_mark.inner) || CHANGED (hand_or_mark.cx) || CHANGED (hand_or_mark.cy) || CHANGED (hand_or_mark.outer) || CHANGED (hand_or_mark.cycle) || CHANGED (hand_or_mark.width) || CHANGED (hand_or_mark.phase) || CHANGED (hand_or_mark.shape_style) || CHANGED (hand_or_mark.render_type)) needs_redisplay = needs_parent_reset = TRUE; if (CHANGED (hand_or_mark.foreground) || CHANGED (hand_or_mark.stroke_width) || CHANGED (hand_or_mark.stroke_width_r) || CHANGED (hand_or_mark.cap_style) || CHANGED (hand_or_mark.join_style)) needs_redisplay = needs_parent_reset = needs_new_gcs = TRUE; if (needs_new_gcs || XtIsRealized(XtParent(current))) { destroy_gcs(h_cur); get_hand_or_mark_gcs(h_new); } if (needs_parent_reset) { SwissWatchReset((SwissWatchWidget) XtParent(current)); } return needs_redisplay; #undef CHANGED #undef h_cur #undef h_new } static void destroy_gcs(w) HandOrMarkWidget w; { XtReleaseGC((Widget) w, w->hand_or_mark.fg_gc); } swisswatch-0.06.orig/HandOrMarP.h100600 1755 1750 4145 5242162634 15151 0ustar krsusers#ifndef _HandOrMarkP_h_ #define _HandOrMarkP_h_ #include #include "HandOrMark.h" #define XtRCapStyle "CapStyle" #define XtRJoinStyle "JoinStyle" #define XtRTickShape "TickShape" #define XtRTickRenderType "TickRenderType" #if NeedFunctionPrototypes typedef void (* XslDrawHandOrMarkProc) (Widget, Drawable, int, int); typedef void (* XslResizeHandOrMarkProc) (Widget, int, int); typedef void (* XslRealizeHandOrMarkProc) (Widget); #else /* not NeedFunctionPrototypes */ typedef void (* XslDrawHandOrMarkProc) (); typedef void (* XslResizeHandOrMarkProc) (); typedef void (* XslRealizeHandOrMarkProc) (); #endif /* not NeedFunctionPrototypes */ typedef struct _HandOrMarkClassPart { XslDrawHandOrMarkProc draw; XslResizeHandOrMarkProc resize; XslRealizeHandOrMarkProc realize; } HandOrMarkClassPart; typedef struct _HandOrMarkClassRec { ObjectClassPart object_class; HandOrMarkClassPart hand_or_mark_class; } HandOrMarkClassRec; extern HandOrMarkClassRec handOrMarkClassRec; typedef enum { ShapeTriangle, ShapeRectangle, ShapeArrow, ShapeCircle, } HandOrMarkShape; typedef enum { ShapeOutline, ShapeFill, } HandOrMarkOutline; typedef struct _HandOrMarkPart { float inner; float outer; long pad_0; Dimension stroke_width; float stroke_width_r; int cycle; Pixel foreground; GC fg_gc; float width; float phase; int shape_style; int cap_style; int join_style; int render_type; float cx; float cy; Boolean use_draw_line_to_draw_circle; } HandOrMarkPart; typedef struct _HandOrMarkRec { ObjectPart object; HandOrMarkPart hand_or_mark; } HandOrMarkRec; #if NeedFunctionPrototypes extern void DrawShape(HandOrMarkWidget, Drawable, GC, double, double); extern void DrawHandOrMark(HandOrMarkWidget, Drawable); extern void ResizeHandOrMark(HandOrMarkWidget, int, int); extern void RealizeHandOrMark(HandOrMarkWidget); #else /* not NeedFunctionPrototypes */ extern void DrawShape(); extern void DrawHandOrMark(); extern void ResizeHandOrMark(); extern void RealizeHandOrMark(); #endif /* not NeedFunctionPrototypes */ #endif /* not _HandOrMarkP_h_ */ swisswatch-0.06.orig/Imakefile100600 1755 1750 1141 5247361174 14654 0ustar krsusers#ifdef ContribRules ContribRules #endif DEFINES = ExtensionDefines SRCS = swisswatch.c SwissWatch.c Hand.c Mark.c HandOrMark.c TableConvert.c OBJS = swisswatch.o SwissWatch.o Hand.o Mark.o HandOrMark.o TableConvert.o DEPLIBS = $(DEPXTOOLLIB) $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB) LOCAL_LIBRARIES = $(XTOOLLIB) $(XMULIB) $(EXTENSIONLIB) $(XLIB) SYS_LIBRARIES = -lm ComplexProgramTarget(swisswatch) #ifdef InstallAppDefaultsLong InstallAppDefaultsLong(SWatch,SwissWatch) InstallAppDefaultsLong(SWatch-co,SwissWatch-color) #else /* hmm, we seem to run under pre-R5 */ InstallAppDefaults(SwissWatch) #endif swisswatch-0.06.orig/SWatch-co.ad100600 1755 1750 1016 5326050072 15130 0ustar krsusers#include "SwissWatch" swisswatch*SwissWatch.child_4.foreground: green swisswatch*SwissWatch.child_5.foreground: green swisswatch*SwissWatch.child_6.foreground: red swisswatch*SwissWatch.Mark.foreground: green swisswatch*SwissWatch.Hand.foreground: grey80 ! swissclock*SwissWatch.child_5.foreground: red swissclock*SwissWatch.child_6.foreground: red swissclock*SwissWatch.*.foreground: black ! oclock*Background: grey oclock*SwissWatch.*.foreground: yellow oclock*SwissWatch.child_1.foreground: light blue swisswatch-0.06.orig/swisswatch.man100600 1755 1750 22116 5326050655 15761 0ustar krsusers.TH SWISSWATCH 1 "Release 5" "X Version 11" .SH NAME swisswatch \- the mother of all X Toolkit clocks .SH SYNOPSIS .B swisswatch [-option ...] .SH DESCRIPTION .I Swisswatch is an analog clock for X that is highly customizable by means of resources. .SH SYNOPSIS Handles minute-hand display correctly when ticking more often than once a minute. Handles arbitrary number of hands and/or mark specifications. .SH OPTIONS .TP 8 .B \-fg \fIforeground color\fB choose a different color for the hands and marks. .TP 8 .B \-bg \fIbackground color\fB choose a different color for the background. .TP 8 .B \-tick \fItime\fB the interval between updates of the display. This should be a positive floating-point number. .B \-geometry \fIgeometry\fB define the initial window geometry; see \fIX(1)\fP. .TP 8 .B \-display \fIdisplay\fB specify the display to use; see \fIX(1)\fP. .TP 8 .B \-noshape causes the clock to not reshape itself and ancestors to exactly fit the outline of the clock. .TP 8 .B \-railroad .TP 8 .B \-sbb .TP 8 .B \-cff .TP 8 .B \-ffs causes the second and minute hands to behave differently at the turn of the minute. This mode tries to mimick the Look and Feel of the swiss federal railway clocks. .SH RESOURCES .TP 8 .B .tickTime / .TickTime Time between ticks, in seconds. The hands will move this often. (All hands have their positions recomputed and redrawn each time the clock ticks.) This is a floating-point value, though values less than the system's clock resolution will not work very well. Ticks occur precisely on the appropriate boundary, regardless of when the program was started; for example, if tickTime is 5, ticks occur precisely when gettimeofday().tv_sec%5 changes. .TP 8 .B .numMarks / .NumMarks Number of sets of marks around the clock face. .TP 8 .B .child_\fIn\fP.cycle / .Mark.Cycle / .Hand.Cycle For a mark, the number of marks in set \fIn\fP. For a hand, the number of ticks corresponding to one complete turn of the hand. .TP 8 .B .child_\fIn\fP.outsideEnd / .Mark.OutsideEnd Outside end of marks in set \fIn\fP, as a radial distance. .TP 8 .B .child_\fIn\fP.length / .Mark.Length Length of marks in set \fIn\fP; the marks extend from the outsideEnd position inward for this distance. .TP 8 .B .child_\fIn\fP.phase / .Mark.Phase Phase of mark set \fIn\fP. This specifies a rotation of the whole set of marks. The default is 0, which specifies that a mark appear at the straight-up ("12-o'clock") position, with the other number-1 marks (if any) spaced evenly around the face. If phase is nonzero, it specifies a rotation of the entire set of marks clockwise. The value is the rotation, as a fraction of the distance from one mark to the next. For example, any integer value will have no visible effect (any desired effect corresponds to some value in [0..1]). Experimentation is recommended. .TP 8 .B .child_\fIn\fP.centerX / .Mark.CenterX .TP 8 .B .child_\fIn\fP.centerY / .Mark.CenterY These specify where on the clock face the center of the circle formed by the marks is to be. The X and Y coordinates are scaled so that the bounding square of the clock face is [-1..1] x [-1..1]. This allows for placing circles of marks centered at points other than the center of the clock face; this is useful primarily in conjunction with the corresponding options for hands. .TP 8 .B .child_\fIn\fP.foreground / .Mark.Foreground Color used to draw a mark or hand. .TP 8 .B .nChildren / .NChildren Number of hands and marks on the clock. .TP 8 .B .child_\fIn\fP.class The class of the hand or mark, currently only "Hand" and "Mark" are supported. .TP 8 .B .child_\fIn\fP.width / .Hand.Width The width of the hand. For triangular hands, this is the width of the base; for rectangular hands, this is the width of the rectangle; and for circular hands, this is the diameter of the circle. If the width of a triangular or rectangular outline hand is zero, the hand is drawn as a single line instead of the full shape. .TP 8 .B .child_\fIn\fP.shape / .Hand.Shape The shape of the hand. Hands can be triangular, rectangular, or circular; the allowed values are "triangle", "rectangle", "circle", "triangular", "rectangular", and "circular". Illegal values produce a complaint and a default is used. .TP 8 .B .child_\fIn\fP.render / .Hand.Render The rendition of the hand. Hands can be drawn as outlines or as filled shapes; the allowed values are "outline", "fill", "outlined", and "filled". Illegal values produce a complaint and a default is used. .TP 8 .B .child_\fIn\fP.strokeWidth / .Hand.StrokeWidth The width of strokes used to draw the hand, when the hand is drawn in a way that uses strokes. A value of 0 uses so-called "thin" lines, which are often faster. .TP 8 .B .child_\fIn\fP.strokeWidthR / .Hand.StrokeWidthR If a non-zero floating point number is specified, the stroke width will always be the product of this number and the clock's outer radius (in x direction if it is an ellipsis). .TP 8 .B .child_\fIn\fP.cap / .Hand.Cap The line cap style used when drawing hands. This produces no visual effect except when drawing triangular or rectangular hands of width 0. Legal values are "notlast", "butt", "round", "projecting", "capnotlast", "capbutt", "capround", and "capprojecting". .TP 8 .B .child_\fIn\fP.join / .Hand.Join The line join style used when drawing hands. Legal values are "miter", "round", "bevel", "joinmiter", joinround", and "joinbevel". .TP 8 .B .child_\fIn\fP.cycle / .Hand.Cycle The number of seconds it takes for the hand to circle around the face once. For example, a normal second hand will give 60, a normal minute hand 3600. If this is small compared to the tickTime value, the hand will move by visually large amounts each tick; this may or may not be desirable. The value may be floating-point. .TP 8 .B .child_\fIn\fP.phase / .Hand.Phase An offset applied to the time of day before computing the hand position. To determine the position of a hand, the following is computed: .sp .B ((now - tz - phase) % cycle) / cycle .sp where `now' is the current time of day (obtained with time(3)), tz is a correction factor for the timezone as found in the tm_gmtoff field of the structure returned by localtime(3)), phase is the value of the phase resource for the hand, and cycle is the value of the cycle resource for the hand. The result is a number from 0 to 1, which is mapped into an angular position, with 0 being straight up, .25 being straight right, .5 being straight down, etc. .sp The simplest way to determine the desired phase value for a hand is to experiment. It is usually obvious that the value should be a multiple of something like 3600; try various multiples until you get the desired hand position. .TP 8 .B .child_\fIn\fP.color / .Hand.Foreground The color used for drawing the hand. Hands are drawn opaquely in increasing numerical order. .TP 8 .B .child_\fIn\fP.center.x / .Hand.Center.X .TP 8 .B .child_\fIn\fP.center.y / .Hand.Center.Y These specify where on the clock face the pivot point of the hand is to be. The X and Y coordinates are scaled so that the bounding square of the clock face is 1..1] x [-1..1]. This allows hands to rotate about points other than the center of the clock face, as with some watches. .TP 8 .B .geometry / .Geometry Geometry specification, when none is given on the command line. If no geometry spec can be found anywhere, the equivalent of 200x200+100+100 is used. .TP 8 .B .background / .Background Color used as a background for all drawing. .TP 8 .B .name / .Name A string, which is stored as the window manager name for the window. If none is given, "xwatch" is used. .TP 8 .B .iconName / .IconName A string, which is stored as the window manager icon name for the window. If none is given, "xwatch" is used. .TP 8 .B .railroad / .Railroad Enables or disables Swiss-railway-clock mode, as described under the -railroad command-line option. The value can be "true", "false", "yes", or "no". .TP 8 .B .circular / .Circular If set, the clock will remain circular even if one tries to resize it to a non-circular ellipse. This is the previous behavior. The possible values are the same as for \fB.swiss/.Swiss\fP. .SH EXAMPLE RESOURCES The distributed application defaults files define three different looks for swisswatch. Try them out by calling it as .sp 1 swisswatch .sp 1 swisswatch -name swissclock .sp 1 swisswatch -name oclock .sp 1 .SH COLORS If you would like your clock to be viewable in color, include the following in the #ifdef COLOR section you read with xrdb: .sp 1 *customization: -color .sp 1 .br This will cause swisswatch to pick up the colors in the app-defaults color customization file: /usr/lib/X11/app-defaults/SwissWatch-color. .SH "SEE ALSO" X(1), X Toolkit documentation .SH COPYRIGHT Copyright 1989, Massachusetts Institute of Technology. .br See \fIX(1)\fP for a full statement of rights and permissions. .SH AUTHOR Simon Leinen, Ecole Polytechnique Federale de Lausanne .SH CREDITS Der Mouse wrote the mclock program that already featured most of the functionality: smooth movement of the minute hand and excessive configurability. I basically reimplemented mclock as a Toolkit application. This manpage also contains slightly adapted text from mclock.doc. swisswatch-0.06.orig/Makefile.simple100600 1755 1750 2570 5326251235 15774 0ustar krsusers############################################################################## # File Name: Makefile.simple # Description: Makefile for the imake-deprived # Author: Logiciels X11 (x11@lia.di.epfl.ch) # Date Created: 17-Jan-93 # RCS $Header$ # RCS $Log$ ############################################################################## ## Edit and uncomment this line if you don't have the X11 include ## files under /usr/include/X11 # INCLUDES = -I/usr/X11R5/include ## Edit and uncomment this line if you don't have the X11 libraries ## installed in the linker's standard search path # XLIBDIR = -L/usr/X11R5/lib ## Desired optimization/debugging options for the compiler CDEBUGFLAGS = -O ## Uncomment this line if you have an Xlib version that doesn't ## support the SHAPE extension (X11R3 or earlier). If your libraries ## are really that old, the program probably won't compile anyway. DEFINES = -DSHAPE LOCAL_LIBRARIES = $(XLIBDIR) -lXt -lXmu -lXext -lX11 CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(DEFINES) SYS_LIBRARIES = -lm SRCS = swisswatch.c SwissWatch.c Hand.c Mark.c HandOrMark.c TableConvert.c OBJS = swisswatch.o SwissWatch.o Hand.o Mark.o HandOrMark.o TableConvert.o swisswatch: $(OBJS) $(CC) $(CFLAGS) -o swisswatch $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) clean:: rm -f swisswatch rm -f *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"* swisswatch-0.06.orig/SwissWatch.ad100600 1755 1750 14256 5326252300 15467 0ustar krsusers!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! File Name: SwissWatch.ad !!! Description: pre-X11R5 version of the app-defaults file !!! Author: Simon Leinen (simon@liasun6.epfl.ch) !!! Date Created: 12-Mar-92 !!! RCS $Header$ !!! RCS $Log$ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! swisswatch*SwissWatch.child_4.foreground: green swisswatch*SwissWatch.child_5.foreground: green swisswatch*SwissWatch.child_6.foreground: red swisswatch*SwissWatch.Mark.foreground: green swisswatch*SwissWatch.Hand.foreground: grey80 ! swissclock*SwissWatch.child_5.foreground: red swissclock*SwissWatch.child_6.foreground: red swissclock*SwissWatch.*.foreground: black ! oclock*Background: grey oclock*SwissWatch.*.foreground: yellow oclock*SwissWatch.child_1.foreground: light blue *SwissWatch.TickTime: 1 *SwissWatch.Background: black *SwissWatch.nChildren: 3 *SwissWatch.Hand.inner: 0 *SwissWatch.Hand.outer: .9 *SwissWatch.width: 100 *SwissWatch.height: 100 swisswatch*Background: black swisswatch*Foreground: white swisswatch*SwissWatch.nChildren: 7 swisswatch*SwissWatch.Hand.inner: -.05 swisswatch*SwissWatch.Hand.width: 0 swisswatch*SwissWatch.*.cap: round swisswatch*SwissWatch.Hand.shape: rectangle swisswatch*SwissWatch.child_0.class: Mark swisswatch*SwissWatch.child_0.cycle: 60 swisswatch*SwissWatch.child_0.strokeWidthR: 0.01 swisswatch*SwissWatch.child_0.inner: 0.79 swisswatch*SwissWatch.child_0.outer: 0.8 swisswatch*SwissWatch.child_1.class: Mark swisswatch*SwissWatch.child_1.cycle: 12 swisswatch*SwissWatch.child_1.strokeWidthR: 0.02 swisswatch*SwissWatch.child_1.inner: .71 swisswatch*SwissWatch.child_1.outer: .8 swisswatch*SwissWatch.child_2.class: Hand swisswatch*SwissWatch.child_2.cycle: 43200 swisswatch*SwissWatch.child_2.outer: .40 swisswatch*SwissWatch.child_2.render: outlined swisswatch*SwissWatch.child_2.strokeWidthR: 0.1 swisswatch*SwissWatch.child_3.class: Hand swisswatch*SwissWatch.child_3.cycle: 3600 swisswatch*SwissWatch.child_3.outer: .60 swisswatch*SwissWatch.child_3.render: outlined swisswatch*SwissWatch.child_3.strokeWidthR: 0.075 swisswatch*SwissWatch.child_4.class: Hand swisswatch*SwissWatch.child_4.cycle: 43200 swisswatch*SwissWatch.child_4.outer: .38 swisswatch*SwissWatch.child_4.inner: .30 swisswatch*SwissWatch.child_4.render: outlined swisswatch*SwissWatch.child_4.strokeWidthR: 0.05 swisswatch*SwissWatch.child_5.class: Hand swisswatch*SwissWatch.child_5.cycle: 3600 swisswatch*SwissWatch.child_5.outer: .58 swisswatch*SwissWatch.child_5.inner: .50 swisswatch*SwissWatch.child_5.render: outlined swisswatch*SwissWatch.child_5.strokeWidthR: 0.0375 swisswatch*SwissWatch.child_6.class: Hand swisswatch*SwissWatch.child_6.render: filled swisswatch*SwissWatch.child_6.shape: circle swisswatch*SwissWatch.child_6.cycle: 60 swisswatch*SwissWatch.child_6.outer: 0.575 swisswatch*SwissWatch.child_6.width: 0.15 swissclock*Background: snow1 swissclock*Foreground: black swissclock*SwissWatch.width: 300 swissclock*SwissWatch.height: 300 swissclock*SwissWatch.nChildren: 7 swissclock*SwissWatch.*.StrokeWidth: 0 swissclock*SwissWatch.*.render: outlined swissclock*SwissWatch.*.width: 0 swissclock*SwissWatch.Hand.inner: -.18 swissclock*SwissWatch.child_0.class: Mark swissclock*SwissWatch.child_0.Cycle: 60 swissclock*SwissWatch.child_0.Inner: .90 swissclock*SwissWatch.child_0.Outer: .95 swissclock*SwissWatch.child_0.StrokeWidthR: .03 swissclock*SwissWatch.child_1.class: Mark swissclock*SwissWatch.child_1.Cycle: 12 swissclock*SwissWatch.child_1.Inner: .82 swissclock*SwissWatch.child_1.Outer: .95 swissclock*SwissWatch.child_1.StrokeWidthR: .03 swissclock*SwissWatch.child_2.class: Mark swissclock*SwissWatch.child_2.shape: circle swissclock*SwissWatch.child_2.render: outline swissclock*SwissWatch.child_2.outer: 0 swissclock*SwissWatch.child_2.width: 1.99 swissclock*SwissWatch.child_2.strokeWidthR: .03 swissclock*SwissWatch.child_2.cycle: 1 swissclock*SwissWatch.child_3.class: Hand swissclock*SwissWatch.child_3.outer: .60 swissclock*SwissWatch.child_3.shape: arrow swissclock*SwissWatch.child_3.render: filled swissclock*SwissWatch.child_3.width: .10 swissclock*SwissWatch.child_3.cycle: 43200 swissclock*SwissWatch.child_4.class: Hand swissclock*SwissWatch.child_4.outer: .81 swissclock*SwissWatch.child_4.shape: arrow swissclock*SwissWatch.child_4.render: filled swissclock*SwissWatch.child_4.width: .08 swissclock*SwissWatch.child_4.cycle: 3600 swissclock*SwissWatch.child_5.class: Hand swissclock*SwissWatch.child_5.strokeWidthR: 0.03 swissclock*SwissWatch.child_5.inner: -.26 swissclock*SwissWatch.child_5.outer: .78 swissclock*SwissWatch.child_5.cycle: 60 swissclock*SwissWatch.child_6.class: Hand swissclock*SwissWatch.child_6.shape: circle swissclock*SwissWatch.child_6.render: filled swissclock*SwissWatch.child_6.outer: .78 swissclock*SwissWatch.child_6.width: .20 swissclock*SwissWatch.child_6.cycle: 60 swissclock*SwissWatch.*.shape: rectangle swissclock*SwissWatch.railroad: true swissclock*SwissWatch.circular: true oclock*SwissWatch.nChildren: 4 oclock*SwissWatch.TickTime: 60 oclock*SwissWatch.child_0.Class: Mark oclock*SwissWatch.child_0.Cycle: 1 oclock*SwissWatch.child_0.Shape: circle oclock*SwissWatch.child_0.Render: filled oclock*SwissWatch.child_0.Width: 0.075 oclock*SwissWatch.child_0.Inner: .825 oclock*SwissWatch.child_0.Outer: .825 oclock*SwissWatch.child_1.Class: Mark oclock*SwissWatch.child_1.Cycle: 1 oclock*SwissWatch.child_1.Inner: 0 oclock*SwissWatch.child_1.Outer: 0 oclock*SwissWatch.child_1.Width: 1.9 oclock*SwissWatch.child_1.Shape: circle oclock*SwissWatch.child_1.Render: outlined oclock*SwissWatch.child_1.Color: black oclock*SwissWatch.child_1.StrokeWidthR: 0.1 oclock*SwissWatch.Hand.Shape: arrow oclock*SwissWatch.Hand.Render: filled oclock*SwissWatch.Hand.Width: 0.09 oclock*SwissWatch.child_2.Class: Hand oclock*SwissWatch.child_2.Cycle: 43200 oclock*SwissWatch.child_2.Outer: 0.45 oclock*SwissWatch.child_3.Class: Hand oclock*SwissWatch.child_3.Outer: 0.72 oclock*SwissWatch.child_3.Cycle: 3600 swisswatch-0.06.orig/README100600 1755 1750 2704 5326253452 13726 0ustar krsusersREADME: Swisswatch -*- mode: text -*- Swisswatch is a reimplementation of der Mouse's mclock program using lightweight X Toolkit objects ("gadgets"). It relies heavily on resources for configuration, and can assume a wide range of looks. The application defaults files distributed with swisswatch currently support an oclock emulation, a Swiss railway clock emulation, and a fancy default appearance. You are encouraged to play with the resources and create your personalized version... and send the results back to me so that I can integrate them into the distribution. Under X11R5, you can use the resource editor to interactively change colors and shapes of the graphical elements of the clock. INSTALLATION If you are running X11R5 with a properly configured imake, this should work: % xmkmf -a % make install install.man Under X11R4 with imake, use: % xmkmf % make depend % make install install.man If you don't have imake (shame on you), edit `Makefile.simple' according to the comments in that file, and issue % make -f Makefile.simple install install.man If you want to test swisswatch before installing, you have to set the environment variable XENVIRONMENT so that the program find the uninstalled resources: % env XENVIRONMENT=SwissWatch.ad ./swisswatch Have fun, -- Simon Leinen. Laboratoire d'Intelligence Artificielle Ecole Polytechnique Federale de Lausanne MA-Ecublens CH-1015 Lausanne Tel.: +41-21-693-5277 swisswatch-0.06.orig/Hand.c100600 1755 1750 6612 5326257464 14075 0ustar krsusers/***************************************************************************** * File Name: Hand.c * Description: Hand widget class -- implementation * Author: Simon Leinen (simon@liasun5) * Date Created: 6-May-92 * RCS $Header$ * RCS $Log$ ****************************************************************************/ #include #include "HandP.h" #include "SwissWatcP.h" #include #if NeedFunctionPrototypes static void draw(Widget, Drawable, int, int); #else /* not NeedFunctionPrototypes */ static void draw(); #endif /* not NeedFunctionPrototypes */ #if defined(sun) || defined(__sun__) #define HAVE_SINCOS 1 #endif HandClassRec handClassRec = { { /* superclass */ (WidgetClass) & handOrMarkClassRec, /* class_name */ "Hand", /* widget_size */ sizeof(HandRec), /* class_initialize */ NULL, /* class_part_initialize*/ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* rect1 */ NULL, /* rect2 */ NULL, /* rect3 */ 0, /* resources */ NULL, /* num_resources */ 0, /* xrm_class */ NULLQUARK, /* rect4 */ FALSE, /* rect5 */ FALSE, /* rect6 */ FALSE, /* rect7 */ FALSE, /* destroy */ NULL, /* resize */ NULL, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* rect9 */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* rect10 */ NULL, /* query_geometry */ NULL, /* rect11 */ NULL, /* extension */ NULL, }, { /* draw */ draw, /* resize */ 0, /* realize */ 0, }, { /* dummy */ 0, } }; WidgetClass handWidgetClass = (WidgetClass) &handClassRec; static void draw(w, d, width, height) Widget w; Drawable d; int width; int height; { #define hw ((HandWidget) w) SwissWatchWidget parent = (SwissWatchWidget) XtParent(w); double dnow = parent->swiss_watch.now_local_sec+parent->swiss_watch.frac_sec; double cycle = hw->hand_or_mark.cycle; double ang; double sinus, cosinus; if (parent->swiss_watch.swiss_mode) { if (cycle < 464) { ang = fmod(dnow-hw->hand_or_mark.phase,60.0); if (ang < 57.5) { ang = (ang * 2 * M_PI * 62) / 3600; } #if 0 else if (ang > 58.9) { if (nexttick.tv_usec > 500000) nexttick.tv_sec ++; nexttick.tv_usec = 0; ang = 0; } #endif /* 0 */ else { ang = 0; } } else { ang = dnow - hw->hand_or_mark.phase; ang -= fmod(ang,60.0) - .0001; /* fudge factor - ensure desired rounding */ ang = (fmod(ang,cycle) * 2 * M_PI) / cycle; } } else { ang = (fmod(dnow-hw->hand_or_mark.phase,cycle) * 2 * M_PI) / cycle; } #if HAVE_SINCOS sincos((double) (M_PI_2-ang), &sinus, &cosinus); #else /* not HAVE_SINCOS */ sinus = sin((double) (M_PI_2-ang)); cosinus = cos((double) (M_PI_2-ang)); #endif /* not HAVE_SINCOS */ DrawShape((HandOrMarkWidget)hw, d, hw->hand_or_mark.fg_gc, sinus, cosinus); #ifdef DEBUG printf("draw %s %s %f %f\n", w->core.widget_class->core_class.class_name, XrmNameToString(w->core.xrm_name), ang, ang/M_PI*180.0); #endif /* DEBUG */ #undef hw } swisswatch-0.06.orig/ChangeLog100600 1755 1750 2031 5326260023 14601 0ustar krsusersSun Jan 17 13:15:46 1993 Logiciels X11 (x11 at liasun6) * Hand.c (draw): removed junk after #endif * README: added installation instructions * HandOrMark.c (get_hand_or_mark_gcs): when abusing XDrawLine to draw a filled cirular shape, set GCCapStyle to CapRound * Makefile.simple: new file * SwissWatch.c (tock): if tick_time is greater than 1, make sure that the ticks occur exactly on the given multiple of seconds. Sat Jan 16 19:09:09 1993 Logiciels X11 (x11 at liasun6) * Imakefile: don't link to -lXaw - we have our own widgets. * HandOrMark.c (get_hand_or_mark_gcs): use XDrawLine to draw circles Sat Jan 16 18:18:45 1993 Simon Leinen (simon at liasun6) * Swisswatch.ad, SWatch.ad, SWatch-co.ad: the second hands are now always last in the list of children. That way, it can be eliminated by decrementing the "nChildren" resource. When the "tickTime" is increased to 60, the user gets a less resource-intensive clock (proposed by Bill Sebok ). * swisswatch.man: added Amir Katz' fixes