diff --git a/01_git/Makefile.in b/01_git/Makefile.in index a4101cc3e2b55b081c1c016e642f44ec5e11af98..04451a2ae8297c717f1db3fa1e027a5ee3e4d8cb 100644 --- a/01_git/Makefile.in +++ b/01_git/Makefile.in @@ -1,5 +1,7 @@ # AfterStepApps standard Makefile and autoconf/ ; do not edit +CFLAGS+=-g + OBJS = astime.o astime_x.o safecopy.o x_color.o sunriset.o PROG = astime diff --git a/01_git/astime_x.c b/01_git/astime_x.c index 0dbdd67b0d563333e408033d6d0a4c59716b4623..3efedc394782e88d4ef52c7b4dd0a53bdefffc01 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -9,7 +9,6 @@ * This software is distributed under GPL. For details see LICENSE file. */ -#define DEBUG #include <stdio.h> #include <stdlib.h> @@ -99,6 +98,56 @@ struct tm *loc_time; /* requests for update */ int update_request = 0; +void draw_sunriset(Display *dpy, + Window win, + struct tm *local_time, + double lon, + double lat, + int color, + int type) +{ +#define CIV_SUNSIZE .70 +#define NAUT_SUNSIZE .70 +#define ASTRO_SUNSIZE .70 + int x, y; + unsigned int width, height; + int angle1, angle2; + double start, end, size; + GC gc; + + if (type == 0) { + size = CIV_SUNSIZE; + civil_twilight(local_time->tm_year, local_time->tm_mon, + local_time->tm_mday, lat, lon, &start, &end); + } else if (type == 1) { + size = NAUT_SUNSIZE; + nautical_twilight(local_time->tm_year, local_time->tm_mon, + local_time->tm_mday, lat, lon, &start, &end); + } else { + size = ASTRO_SUNSIZE; + astronomical_twilight(local_time->tm_year, local_time->tm_mon, + local_time->tm_mday, lat, lon, &start, &end); + } + /*color = WhitePixel(dpy, DefaultScreen(dpy));*/ + gc = XCreateGC(dpy, win, 0, NULL); + XSetForeground(dpy, gc, color); + x = center.x - (watch_size.x * size); + y = center.y - (watch_size.y * size); + width = watch_size.x * size * 2; + height = watch_size.y * size * 2; + if (loc_time->tm_isdst > 0) { + start += 0.0; + end += 0.0; + } + angle1 = (int) round(start * 15.0); + angle2 = (int) round(end * 15.0); + angle2 -= (angle1 + 360) % 360; +#ifdef DEBUG + printf("angle1 = %d, angle2 = %d, tm_isdst = %d, start = %lf, end = %lf\n", angle1, angle2, local_time->tm_isdst, start, end); +#endif + XFillArc(mainDisplay, win, gc, x, x, width, height, (360 - angle1 + 90) * 64, -angle2 * 64); +} + void draw_window(Window win) { int i; @@ -250,8 +299,17 @@ void draw_window(Window win) center.y - watch_size.y ); #endif - - + if (state.twentyfour) { +#define CIVIL_DAWN 0 +#define NAUT_DAWN 1 +#define ASTRO_DAWN 2 + draw_sunriset(mainDisplay, win, loc_time, + 49.6972222, 11.05, pix[4], ASTRO_DAWN); + draw_sunriset(mainDisplay, win, loc_time, + 49.6972222, 11.05, pix[6], NAUT_DAWN); + draw_sunriset(mainDisplay, win, loc_time, + 49.6972222, 11.05, pix[3], CIVIL_DAWN); + } /* draw filled polygonal hands */ for (i = 2; i >= 0; i--) { if ((i == 0) && (state.draw_seconds == 0)) @@ -266,7 +324,13 @@ void draw_window(Window win) &mainGCV ); - XFillPolygon(mainDisplay, win, mainGC, hand[i], 3, Convex, CoordModeOrigin); + XFillPolygon(mainDisplay, + win, + mainGC, + hand[i], + 3, + Convex, + CoordModeOrigin); } /* draw line-rendered hands */ if (state.hprop[i][HCLINE]) { @@ -276,8 +340,9 @@ void draw_window(Window win) mainGCV.line_width = 1; } else { /* scale line thickness by window size */ - mainGCV.line_width = rint((1 + (0.5 * i)) * (((watch_size.x + watch_size.y) / 2.0) * - (state.hthick / 100.0))); + mainGCV.line_width = rint((1 + (0.5 * i)) + * (((watch_size.x + watch_size.y) / 2.0) + * (state.hthick / 100.0))); } XChangeGC( @@ -299,8 +364,9 @@ void draw_window(Window win) /* draw outlines of hands */ if (state.hprop[i][HOLINE]) { mainGCV.foreground = pix[i + 3]; - mainGCV.line_width = rint((1 + (0.5 * i)) * (((watch_size.x + watch_size.y) / 2.0) * - (state.othick / 1000.0))); + mainGCV.line_width = rint((1 + (0.5 * i)) + * (((watch_size.x + watch_size.y) / 2.0) + * (state.othick / 1000.0))); XChangeGC( mainDisplay, mainGC,