Article View: comp.windows.x
Article #23867Clock widget for different timezones
From: David S. Herron
Date: Wed, 19 Jun 1991 19:42
Date: Wed, 19 Jun 1991 19:42
67 lines
2045 bytes
2045 bytes
A customer wants to have a row of clocks showing different timezones.
Unfortunately the clock widget doesn't handle that case very well.
But a little simple hackery should suffice. Changes follow. This
is relative to R4/lib/Xaw/Clock{.c,P.h,.h} distributed from MIT and
patched to patchlevel 18.
--------------> Clock.c <-------------
static XtResource resources[] = {
...
{XtNhourOffset, XtCInterval, XtRInt, sizeof(int),
offset(hourOffset), XtRImmediate, (caddr_t) 0 },
};
...
/* ARGSUSED */
static void Initialize (request, new)
Widget request, new;
{
...
while (w->clock.hourOffset > 12) /* Normalize the offset */
w->clock.hourOffset -= 12;
while (w->clock.hourOffset < -12)
w->clock.hourOffset += 12;
...
}
...
/* ARGSUSED */
static void clock_tic(client_data, id)
caddr_t client_data;
XtIntervalId *id;
{
...
(void) time(&time_value);
time_value += (w->clock.hourOffset * 60 * 60);
tm = *localtime(&time_value);
...
}
--------------> Clock.h <-------------
/* Parameters:
...
hourOffset Interval int 0 (hours)
...
*/
...
/* Int: Value to add to the hours, half-assed way to display different timezones */
#define XtNhourOffset "hourOffset"
--------------> ClockP.h <-------------
/* New fields for the clock widget instance record */
typedef struct {
...
int hourOffset; /* How much to offset the hours ... */
...
} ClockPart;
David
--
<- David Herron, an MMDF & WIN/MHS guy, <david@twg.com>
<-
<-
<- "MS-DOS? Where we're going we don't need MS-DOS." --Back To The Future
Technical Details
Message-ID:
<9129@gollum.twg.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!twg.com!davidShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!twg.com!david From: david@twg.com (David S. Herron) Newsgroups: comp.windows.x Subject: Clock widget for different timezones Message-ID: <9129@gollum.twg.com> Date: 19 Jun 91 19:42:08 GMT Organization: The Wollongong Group, Palo Alto, CA Lines: 67