4 * Copyright 1998 Marcel Baur <mbaur@g26.ethz.ch>
6 * Clock is partially based on
7 * - Program Manager by Ulrich Schmied
8 * - rolex.c by Jim Peterson
21 CLOCK_GLOBALS Globals
;
23 /***********************************************************************
27 * All handling of main menu events
30 int CLOCK_MenuCommand (WPARAM wParam
)
34 Globals
.bAnalog
= TRUE
;
35 LANGUAGE_UpdateMenuCheckmarks();
36 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
40 Globals
.bAnalog
= FALSE
;
41 LANGUAGE_UpdateMenuCheckmarks();
42 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
46 MAIN_FileChooseFont();
49 case CL_WITHOUT_TITLE
: {
50 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
51 LANGUAGE_UpdateWindowCaption();
52 LANGUAGE_UpdateMenuCheckmarks();
56 Globals
.bAlwaysOnTop
= !Globals
.bAlwaysOnTop
;
57 LANGUAGE_UpdateMenuCheckmarks();
61 Globals
.bSeconds
= !Globals
.bSeconds
;
62 LANGUAGE_UpdateMenuCheckmarks();
63 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
67 Globals
.bDate
= !Globals
.bDate
;
68 LANGUAGE_UpdateMenuCheckmarks();
69 LANGUAGE_UpdateWindowCaption();
72 case CL_INFO_LICENSE
: {
73 WineLicense(Globals
.hMainWnd
, Globals
.lpszLanguage
);
76 case CL_INFO_NO_WARRANTY
: {
77 WineWarranty(Globals
.hMainWnd
, Globals
.lpszLanguage
);
80 case CL_INFO_ABOUT_WINE
: {
81 ShellAbout(Globals
.hMainWnd
, "Clock", "Clock\n" WINE_RELEASE_INFO
, 0);
84 /* Handle languages */
86 LANGUAGE_DefaultHandle(wParam
);
91 VOID
MAIN_FileChooseFont(VOID
) {
95 font
.lStructSize
= sizeof(font
);
96 font
.hwndOwner
= Globals
.hMainWnd
;
104 font
.lpTemplateName
= 0;
105 font
.hInstance
= Globals
.hInstance
;
106 /* font.lpszStyle = LF_FACESIZE; */
111 if (ChooseFont(&font
)) {
117 /***********************************************************************
122 LRESULT
CLOCK_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
130 printf("WM_CREATE\n");
135 printf("WM_RBUTTONUP\n");
136 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
137 LANGUAGE_UpdateMenuCheckmarks();
138 LANGUAGE_UpdateWindowCaption();
139 UpdateWindow (Globals
.hMainWnd
);
144 printf("WM_PAINT\n");
145 context
= BeginPaint(hWnd
, &ps
);
146 if(Globals
.bAnalog
) {
160 Globals
.MaxX
= LOWORD(lParam
);
161 Globals
.MaxY
= HIWORD(lParam
);
162 OldHour
.DontRedraw
= TRUE
;
163 OldMinute
.DontRedraw
= TRUE
;
164 OldSecond
.DontRedraw
= TRUE
;
169 CLOCK_MenuCommand(wParam
);
174 printf("WM_DESTROY\n");
180 return DefWindowProc (hWnd
, msg
, wParam
, lParam
);
187 /***********************************************************************
192 int PASCAL
WinMain (HANDLE hInstance
, HANDLE prev
, LPSTR cmdline
, int show
)
197 char szClassName
[] = "CLClass"; /* To make sure className >= 0x10000 */
198 char szWinName
[] = "Clock";
201 Globals
.bAnalog
= TRUE
;
202 Globals
.bSeconds
= TRUE
;
203 Globals
.lpszIniFile
= "clock.ini";
204 Globals
.lpszIcoFile
= "clock.ico";
206 /* Select Language */
209 Globals
.hInstance
= hInstance
;
210 Globals
.hMainIcon
= ExtractIcon(Globals
.hInstance
,
211 Globals
.lpszIcoFile
, 0);
213 if (!Globals
.hMainIcon
) Globals
.hMainIcon
=
214 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON
));
217 class.style
= CS_HREDRAW
| CS_VREDRAW
;
218 class.lpfnWndProc
= CLOCK_WndProc
;
219 class.cbClsExtra
= 0;
220 class.cbWndExtra
= 0;
221 class.hInstance
= Globals
.hInstance
;
222 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
223 class.hCursor
= LoadCursor (0, IDC_ARROW
);
224 class.hbrBackground
= GetStockObject (GRAY_BRUSH
);
225 class.lpszMenuName
= 0;
226 class.lpszClassName
= szClassName
;
229 if (!RegisterClass (&class)) return FALSE
;
231 Globals
.hMainWnd
= CreateWindow (szClassName
, szWinName
, WS_OVERLAPPEDWINDOW
,
232 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, Globals
.MaxX
, Globals
.MaxY
,
233 LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
), Globals
.hInstance
, 0);
235 LANGUAGE_SelectByName(Globals
.lpszLanguage
);
236 SetMenu(Globals
.hMainWnd
, Globals
.hMainMenu
);
238 LANGUAGE_UpdateMenuCheckmarks();
240 ShowWindow (Globals
.hMainWnd
, show
);
241 UpdateWindow (Globals
.hMainWnd
);
245 if (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) {
246 if (msg
.message
== WM_QUIT
) return msg
.wParam
;
247 TranslateMessage(&msg
);
248 DispatchMessage(&msg
);
254 /* We will never reach the following statement ! */