forked from alexfru/dflat20
-
Notifications
You must be signed in to change notification settings - Fork 2
/
watch.c
65 lines (62 loc) · 1.86 KB
/
watch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ----------- watch.c ----------- */
#include "dflat.h"
int WatchIconProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
{
int rtn, i;
static int tick = 0;
static char *hands[] = {
" À ", " Ú ", " ¿ ", " Ù "
};
switch (msg) {
case CREATE_WINDOW:
tick = 0;
rtn = DefaultWndProc(wnd, msg, p1, p2);
SendMessage(wnd, CAPTURE_MOUSE, 0, 0);
SendMessage(wnd, HIDE_MOUSE, 0, 0);
SendMessage(wnd, CAPTURE_KEYBOARD, 0, 0);
SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
return rtn;
case CLOCKTICK:
++tick;
tick &= 3;
SendMessage(wnd->PrevClock, msg, p1, p2);
/* (fall through and paint) */
case PAINT:
SetStandardColor(wnd);
writeline(wnd, hands[tick], 1, 1, FALSE);
return TRUE;
case BORDER:
rtn = DefaultWndProc(wnd, msg, p1, p2);
writeline(wnd, "Í", 2, 0, FALSE);
return rtn;
case MOUSE_MOVED:
SendMessage(wnd, HIDE_WINDOW, 0, 0);
SendMessage(wnd, MOVE, p1, p2);
SendMessage(wnd, SHOW_WINDOW, 0, 0);
return TRUE;
case CLOSE_WINDOW:
SendMessage(wnd, RELEASE_CLOCK, 0, 0);
SendMessage(wnd, RELEASE_MOUSE, 0, 0);
SendMessage(wnd, RELEASE_KEYBOARD, 0, 0);
SendMessage(wnd, SHOW_MOUSE, 0, 0);
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
WINDOW WatchIcon(void)
{
int mx, my;
WINDOW wnd;
SendMessage(NULL, CURRENT_MOUSE_CURSOR,
(PARAM) &mx, (PARAM) &my);
wnd = CreateWindow(
BOX,
NULL,
mx, my, 3, 5,
NULL,NULL,
WatchIconProc,
VISIBLE | HASBORDER | SHADOW | SAVESELF);
return wnd;
}