__myevic__ void DTMenuIDraw( int it, int line, int sel ) { int colors = sel ? 0x1F & ~(1<<(dt_sel<<1)) : 0x1F; switch ( it ) { case 0: DrawTimeSmall( 12, line+2, &rtd, colors ); break; case 1: DrawDate( 4, line+2, &rtd, colors ); break; default: break; } }
void wmtime_routine(int argc, char **argv) { rckeys wmtime_keys[] = { { "left", &left_action }, { "right", &right_action }, { "middle", &middle_action }, { NULL, NULL } }; int i; XEvent Event; int but_stat = -1; struct tm *time_struct; long starttime; long curtime; char *conffile = NULL; /* Scan through ~/.wmtimerc for the mouse button actions. */ if (default_left_action) left_action = strdup(default_left_action); if (default_middle_action) middle_action = strdup(default_middle_action); if (default_right_action) right_action = strdup(default_right_action); /* Scan through the .rc files */ if (asprintf(&conffile, "/etc/wmtimerc") >= 0) { parse_rcfile(conffile, wmtime_keys); free(conffile); } if (asprintf(&conffile, "%s/.wmtimerc", getenv("HOME")) >= 0) { parse_rcfile(conffile, wmtime_keys); free(conffile); } if (asprintf(&conffile, "/etc/wmtimerc.fixed") >= 0) { parse_rcfile(conffile, wmtime_keys); free(conffile); } /* set user-defined colors */ if (color[0] != 0) { Window Root; XColor col; XWindowAttributes attributes; int screen; Pixel pixel; #define NUMSYMBOLS 10 XpmColorSymbol user_color[NUMSYMBOLS] = { {NULL, "#2081B2CAAEBA", 0}, /* O */ {NULL, "#000049244103", 0}, /* + */ {NULL, "#00007DF771C6", 0}, /* @ */ {NULL, "#18618A288617", 0}, /* # */ {NULL, "#18619A699658", 0}, /* ; */ {NULL, "#0820861779E7", 0}, /* : */ {NULL, "#000071C66185", 0}, /* > */ {NULL, "#000061855144", 0}, /* , */ {NULL, "#00004D344103", 0}, /* < */ {NULL, "#10407DF779E7", 0} /* 1 */ }; /* code based on GetColor() from wmgeneral.c */ /* we need a temporary display to parse the color */ display = XOpenDisplay(NULL); screen = DefaultScreen(display); Root = RootWindow(display, screen); XGetWindowAttributes(display, Root, &attributes); col.pixel = 0; if (!XParseColor(display, attributes.colormap, color, &col)) { fprintf(stderr, "wmtime: can't parse %s.\n", color); goto draw_window; } else if (!XAllocColor(display, attributes.colormap, &col)) { fprintf(stderr, "wmtime: can't allocate %s.\n", color); goto draw_window; } pixel = col.pixel; /* replace colors from wmtime-master.xpm */ user_color[0].pixel = pixel; user_color[1].pixel = scale_pixel(pixel, .4); user_color[2].pixel = scale_pixel(pixel, .7); user_color[3].pixel = scale_pixel(pixel, .8); user_color[4].pixel = scale_pixel(pixel, .9); user_color[5].pixel = scale_pixel(pixel, .8); user_color[6].pixel = scale_pixel(pixel, .6); user_color[7].pixel = scale_pixel(pixel, .5); user_color[8].pixel = scale_pixel(pixel, .4); user_color[9].pixel = scale_pixel(pixel, .7); wmgen.attributes.valuemask |= XpmColorSymbols; wmgen.attributes.numsymbols = NUMSYMBOLS; wmgen.attributes.colorsymbols = user_color; XCloseDisplay(display); } draw_window: openXwindow(argc, argv, wmtime_master_xpm, (char*)wmtime_mask_bits, 128, 64); /* Mask out the right parts of the clock */ copyXPMArea(0, 0, 128, 64, 0, 98); /* Draw the borders */ copyXPMArea(0, 0, 64, 64, 64, 0); /* Draw the clock face */ copyXPMArea(64, 98, 64, 64, 0, 0); /* Draw the LCD background */ setMaskXY(0, 0); /* add mouse region */ AddMouseRegion(0, 5, 48, 58, 60); AddMouseRegion(1, 5, 5, 58, 46); starttime = time(0); curtime = time(0); time_struct = localtime(&curtime); while (1) { curtime = time(0); waitpid(0, NULL, WNOHANG); time_struct = localtime(&curtime); if (curtime >= starttime) { if (!digital) { /* Now to update the seconds */ DrawWijzer(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec); DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon); } else { DrawTime(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec); DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon); } RedrawWindow(); } while (XPending(display)) { XNextEvent(display, &Event); switch (Event.type) { case Expose: RedrawWindow(); break; case DestroyNotify: XCloseDisplay(display); exit(0); break; case ButtonPress: but_stat = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); break; case ButtonRelease: i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y); if (but_stat == i && but_stat >= 0) { switch (but_stat) { case 0: digital = 1-digital; if (digital) { copyXPMArea(64, 98, 64, 64, 0, 0); DrawTime(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec); DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon); } else { copyXPMArea(0, 98, 64, 64, 0, 0); DrawWijzer(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec); DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon); } RedrawWindow(); break; case 1: switch (Event.xbutton.button) { case 1: if (left_action) execCommand(left_action); break; case 2: if (middle_action) execCommand(middle_action); break; case 3: if (right_action) execCommand(right_action); break; } } } break; } } /* Sleep 0.3 seconds */ usleep(300000L); } }