summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:57 +0000
commit71633e81c3dd2135c7c4c67c954dc0b7f162f7dc (patch)
treebd808426b18c9bad3411e0f1065f52fcb89462b1
parentc4bc1693ae8bbc4bff3891b1d06b110025c23579 (diff)
-rw-r--r--Clock.c40
-rw-r--r--Clock.h2
-rw-r--r--ClockP.h10
-rw-r--r--oclock.c18
-rw-r--r--oclock.man13
-rw-r--r--transform.c19
-rw-r--r--transform.h12
7 files changed, 78 insertions, 36 deletions
diff --git a/Clock.c b/Clock.c
index 5791faa..bf992ba 100644
--- a/Clock.c
+++ b/Clock.c
@@ -23,6 +23,7 @@ Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/Clock.c,v 1.7 2001/12/14 20:01:00 dawes Exp $ */
/*
* Clock.c
@@ -36,17 +37,12 @@ in this Software without prior written authorization from The Open Group.
#include "ClockP.h"
#include <X11/Xos.h>
#include <stdio.h>
+#include <stdlib.h>
#include <math.h>
#include <X11/extensions/shape.h>
-#ifdef X_NOT_STDC_ENV
-extern struct tm *localtime();
-#define Time_t long
-extern Time_t time();
-#else
#include <time.h>
#define Time_t time_t
-#endif
#define offset(field) XtOffsetOf(ClockRec, clock.field)
#define goffset(field) XtOffsetOf(WidgetRec, core.field)
@@ -77,9 +73,16 @@ static XtResource resources[] = {
#undef offset
#undef goffset
-static void new_time();
-
-static void Initialize(), Realize(), Destroy(), Redisplay(), Resize();
+static void ClassInitialize ( void );
+static void Initialize ( Widget greq, Widget gnew, ArgList args,
+ Cardinal *num_args );
+static void Resize ( Widget widget );
+static void Realize ( Widget gw, XtValueMask *valueMask,
+ XSetWindowAttributes *attrs );
+static void Destroy ( Widget gw );
+static void Redisplay ( Widget gw, XEvent *event, Region region );
+static double clock_to_angle ( double clock );
+static void new_time ( XtPointer client_data, XtIntervalId *id );
# define BORDER_SIZE(w) ((w)->clock.border_size)
# define WINDOW_WIDTH(w) (2.0 - BORDER_SIZE(w)*2)
@@ -92,8 +95,6 @@ static void Initialize(), Realize(), Destroy(), Redisplay(), Resize();
# define JEWEL_X(w) (0.0)
# define JEWEL_Y(w) (1.0 - (BORDER_SIZE(w) + JEWEL_SIZE(w)))
-static void ClassInitialize();
-
ClockClassRec clockClassRec = {
{ /* core fields */
/* superclass */ &widgetClassRec,
@@ -364,7 +365,7 @@ static void Realize (gw, valueMask, attrs)
XtCreateWindow( gw, (unsigned)InputOutput, (Visual *)CopyFromParent,
*valueMask, attrs );
if (!w->clock.transparent)
- Resize (w);
+ Resize (gw);
new_time ((XtPointer) gw, 0);
}
@@ -456,11 +457,12 @@ static void new_time (client_data, id)
(60 - tm->tm_sec) * 1000, new_time, client_data);
compute_hands (w);
if (w->clock.transparent)
- Resize (w);
+ Resize ((Widget)w);
else
paint_hands (w, XtWindow (w), w->clock.minuteGC, w->clock.hourGC);
} /* new_time */
+void
paint_jewel (w, d, gc)
ClockWidget w;
Drawable d;
@@ -480,7 +482,7 @@ GC gc;
/*
* check to see if the polygon intersects the circular jewel
*/
-
+int
check_jewel_poly (w, poly)
ClockWidget w;
TPoint poly[POLY_SIZE];
@@ -504,8 +506,8 @@ TPoint poly[POLY_SIZE];
b2 = sqr (poly[i+1].x - x) + sqr (poly[i+1].y - y);
c2 = sqr (poly[i].x - poly[i+1].x) + sqr (poly[i].y - poly[i+1].y);
d2 = a2 + b2 - c2;
- if (d2 <= sqr (size) &&
- a2 <= 2 * c2 && b2 <= 2 * c2 ||
+ if ((d2 <= sqr (size) &&
+ a2 <= 2 * c2 && b2 <= 2 * c2) ||
a2 <= sqr (size) ||
b2 <= sqr (size))
return 1;
@@ -514,6 +516,7 @@ TPoint poly[POLY_SIZE];
return 0;
}
+void
check_jewel (w, d, gc)
ClockWidget w;
Drawable d;
@@ -534,7 +537,7 @@ GC gc;
* A hand is a rectangle with a triangular cap at the far end.
* This is represented with a five sided polygon.
*/
-
+void
compute_hand (w, a, l, width, poly)
ClockWidget w;
double a, l, width;
@@ -558,6 +561,7 @@ TPoint poly[POLY_SIZE];
poly[5].y = poly[0].y;
}
+void
compute_hands (w)
ClockWidget w;
{
@@ -568,6 +572,7 @@ ClockWidget w;
w->clock.polys_valid = 1;
}
+void
paint_hand (w, d, gc, poly)
ClockWidget w;
Drawable d;
@@ -578,6 +583,7 @@ TPoint poly[POLY_SIZE];
Convex, CoordModeOrigin);
}
+void
paint_hands (w, d, minute_gc, hour_gc)
ClockWidget w;
Drawable d;
diff --git a/Clock.h b/Clock.h
index 6015931..06fd935 100644
--- a/Clock.h
+++ b/Clock.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/Clock.h,v 1.5 2001/12/14 20:01:00 dawes Exp $ */
#ifndef _XtClock_h
#define _XtClock_h
@@ -71,5 +72,6 @@ typedef struct _ClockClassRec *ClockWidgetClass; /* completely defined in Clo
extern WidgetClass clockWidgetClass;
+
#endif /* _XtClock_h */
/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/ClockP.h b/ClockP.h
index 408dc4d..b7e5b8a 100644
--- a/ClockP.h
+++ b/ClockP.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/ClockP.h,v 1.5 2001/12/14 20:01:00 dawes Exp $ */
#ifndef _ClockP_h
@@ -84,4 +85,13 @@ typedef struct _ClockClassRec {
/* Class pointer. */
extern ClockClassRec clockClassRec;
+extern void paint_jewel ( ClockWidget w, Drawable d, GC gc );
+extern int check_jewel_poly ( ClockWidget w, TPoint poly[6] );
+extern void check_jewel ( ClockWidget w, Drawable d, GC gc );
+extern void compute_hand ( ClockWidget w, double a, double l, double width,
+ TPoint poly[6] );
+extern void compute_hands ( ClockWidget w );
+extern void paint_hand ( ClockWidget w, Drawable d, GC gc, TPoint poly[6] );
+extern void paint_hands ( ClockWidget w, Drawable d, GC minute_gc, GC hour_gc );
+
#endif /* _ClockP_h */
diff --git a/oclock.c b/oclock.c
index 32bc912..1eb86e6 100644
--- a/oclock.c
+++ b/oclock.c
@@ -23,6 +23,7 @@ Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/oclock.c,v 1.7 2001/12/14 20:01:00 dawes Exp $ */
#include <X11/Intrinsic.h>
#include <X11/Xatom.h>
@@ -31,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xmu/Editres.h>
#include "Clock.h"
#include <stdio.h>
+#include <stdlib.h>
#ifdef XKB
#include <X11/extensions/XKBbells.h>
@@ -39,8 +41,12 @@ in this Software without prior written authorization from The Open Group.
#include "oclock.bit"
#include "oclmask.bit"
-extern void exit();
-static void quit();
+static void die ( Widget w, XtPointer client_data, XtPointer call_data );
+static void save ( Widget w, XtPointer client_data, XtPointer call_data );
+static void usage ( void );
+static void quit ( Widget w, XEvent *event, String *params,
+ Cardinal *num_params );
+
static XtActionsRec actions[] = {
{"quit", quit}
@@ -65,7 +71,7 @@ static void save(w, client_data, call_data)
/* Exit with message describing command line format */
-void usage()
+static void usage()
{
fprintf(stderr,
"usage: oclock\n");
@@ -97,9 +103,8 @@ static XrmOptionDescRec options[] = {
{"-transparent","*clock.transparent", XrmoptionNoArg, "TRUE"},
};
-void main(argc, argv)
- int argc;
- char **argv;
+int
+main(int argc, char *argv[])
{
XtAppContext xtcontext;
Widget toplevel;
@@ -146,6 +151,7 @@ void main(argc, argv)
_XEditResCheckMessages, NULL);
XtAppMainLoop(xtcontext);
+ exit(0);
}
static void quit(w, event, params, num_params)
diff --git a/oclock.man b/oclock.man
index 41128e1..3431033 100644
--- a/oclock.man
+++ b/oclock.man
@@ -22,7 +22,10 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
-.TH OCLOCK 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/oclock/oclock.man,v 1.9 2002/10/12 16:06:45 herrb Exp $
+.\"
+.TH OCLOCK 1 __xorgversion__
.SH NAME
oclock \- round X clock
.SH SYNOPSIS
@@ -52,10 +55,10 @@ choose a different color for the hour hand of the clock.
selects an appropriate level of backing store.
.TP 8
.B \-geometry \fIgeometry\fB
-define the initial window geometry; see \fIX(1)\fP.
+define the initial window geometry; see \fIX(__miscmansuffix__)\fP.
.TP 8
.B \-display \fIdisplay\fB
-specify the display to use; see \fIX(1)\fP.
+specify the display to use; see \fIX(__miscmansuffix__)\fP.
.TP 8
.B \-bd \fIcolor\fB
choose a different color for the window border.
@@ -83,7 +86,7 @@ in the #ifdef COLOR section you read with xrdb:
.br
This will cause oclock to pick up the colors in the app-defaults color
customization file:
-<XRoot>/lib/X11/app-defaults/Clock-color.
+__projectroot__/lib/X11/app-defaults/Clock-color.
Below are the default colors:
.sp 1
Clock*Background: grey
@@ -96,6 +99,6 @@ Clock*jewel: yellow
.br
Clock*minute: yellow
.SH "SEE ALSO"
-X(1), X Toolkit documentation
+X(__miscmansuffix__), X Toolkit documentation
.SH AUTHOR
Keith Packard, MIT X Consortium
diff --git a/transform.c b/transform.c
index 60a717a..7f78da1 100644
--- a/transform.c
+++ b/transform.c
@@ -26,21 +26,20 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/transform.c,v 3.5 2001/12/14 20:01:00 dawes Exp $ */
/*
* transformed coordinate system objects for X
*/
-# include <X11/Xlib.h>
-# include "transform.h"
+#include <X11/Xlib.h>
+#include "transform.h"
+#include <stdlib.h>
-static XPoint *
-TranslatePoints (points, n_points, t, mode)
-TPoint *points;
-int n_points;
-Transform *t;
-int mode;
+static XPoint *
+TranslatePoints(TPoint *points, int n_points,
+ Transform *t, int mode)
{
XPoint *xpoints;
int i;
@@ -60,6 +59,7 @@ int mode;
return xpoints;
}
+void
TFillPolygon (dpy, d, gc, t, points, n_points, shape, mode)
register Display *dpy;
Drawable d;
@@ -80,6 +80,7 @@ int mode;
}
}
+void
TDrawArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
register Display *dpy;
Drawable d;
@@ -105,6 +106,7 @@ TDrawArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
XDrawArc (dpy, d, gc, xx, xy, xw, xh, angle1, angle2);
}
+void
TFillArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
register Display *dpy;
Drawable d;
@@ -130,6 +132,7 @@ TFillArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
XFillArc (dpy, d, gc, xx, xy, xw, xh, angle1, angle2);
}
+void
SetTransform (t, xx1, xx2, xy1, xy2, tx1, tx2, ty1, ty2)
Transform *t;
int xx1, xx2, xy1, xy2;
diff --git a/transform.h b/transform.h
index 6377979..47ec2ed 100644
--- a/transform.h
+++ b/transform.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/oclock/transform.h,v 1.5 2001/12/14 20:01:00 dawes Exp $ */
/*
@@ -54,3 +55,14 @@ typedef struct _TRectangle {
# define Ty(x,y,t) ((((double) (y)) - (t)->by) / (t)->my)
# define Twidth(w,h,t) (((double) (w)) / (t)->mx)
# define Theight(w,h,t) (((double) (h)) / (t)->my)
+
+extern void TFillPolygon ( Display *dpy, Drawable d, GC gc, Transform *t,
+ TPoint *points, int n_points, int shape, int mode );
+extern void TDrawArc ( Display *dpy, Drawable d, GC gc, Transform *t,
+ double x, double y, double width, double height,
+ int angle1, int angle2 );
+extern void TFillArc ( Display *dpy, Drawable d, GC gc, Transform *t,
+ double x, double y, double width, double height,
+ int angle1, int angle2 );
+extern void SetTransform ( Transform *t, int xx1, int xx2, int xy1, int xy2,
+ double tx1, double tx2, double ty1, double ty2 );