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
25 void LIBWINE_Register_Da();
26 void LIBWINE_Register_De();
27 void LIBWINE_Register_En();
28 void LIBWINE_Register_Es();
29 void LIBWINE_Register_Fr();
30 void LIBWINE_Register_Sw();
33 CLOCK_GLOBALS Globals;
35 /***********************************************************************
39 * All handling of main menu events
42 int CLOCK_MenuCommand (WPARAM wParam)
46 Globals.bAnalog = TRUE;
47 LANGUAGE_UpdateMenuCheckmarks();
48 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
52 Globals.bAnalog = FALSE;
53 LANGUAGE_UpdateMenuCheckmarks();
54 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
58 MAIN_FileChooseFont();
61 case CL_WITHOUT_TITLE: {
62 Globals.bWithoutTitle = !Globals.bWithoutTitle;
63 LANGUAGE_UpdateWindowCaption();
64 LANGUAGE_UpdateMenuCheckmarks();
68 Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
69 LANGUAGE_UpdateMenuCheckmarks();
73 Globals.bSeconds = !Globals.bSeconds;
74 LANGUAGE_UpdateMenuCheckmarks();
75 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
79 Globals.bDate = !Globals.bDate;
80 LANGUAGE_UpdateMenuCheckmarks();
81 LANGUAGE_UpdateWindowCaption();
84 case CL_INFO_LICENSE: {
85 WineLicense(Globals.hMainWnd, Globals.lpszLanguage);
88 case CL_INFO_NO_WARRANTY: {
89 WineWarranty(Globals.hMainWnd, Globals.lpszLanguage);
92 case CL_INFO_ABOUT_WINE: {
93 ShellAbout(Globals.hMainWnd, "Clock", "Clock\n" WINE_RELEASE_INFO, 0);
96 /* Handle languages */
98 LANGUAGE_DefaultHandle(wParam);
103 VOID MAIN_FileChooseFont(VOID) {
107 font.lStructSize = sizeof(font);
108 font.hwndOwner = Globals.hMainWnd;
116 font.lpTemplateName = 0;
117 font.hInstance = Globals.hInstance;
118 /* font.lpszStyle = LF_FACESIZE; */
123 if (ChooseFont(&font)) {
129 /***********************************************************************
134 LRESULT CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
142 printf("WM_CREATE\n");
147 printf("WM_RBUTTONUP\n");
148 Globals.bWithoutTitle = !Globals.bWithoutTitle;
149 LANGUAGE_UpdateMenuCheckmarks();
150 LANGUAGE_UpdateWindowCaption();
151 UpdateWindow (Globals.hMainWnd);
156 printf("WM_PAINT\n");
157 context = BeginPaint(hWnd, &ps);
158 if(Globals.bAnalog) {
172 Globals.MaxX = LOWORD(lParam);
173 Globals.MaxY = HIWORD(lParam);
174 OldHour.DontRedraw = TRUE;
175 OldMinute.DontRedraw = TRUE;
176 OldSecond.DontRedraw = TRUE;
181 CLOCK_MenuCommand(wParam);
186 printf("WM_DESTROY\n");
192 return DefWindowProc (hWnd, msg, wParam, lParam);
199 /***********************************************************************
204 int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show)
209 char szClassName[] = "CLClass"; /* To make sure className >= 0x10000 */
210 char szWinName[] = "Clock";
212 #if defined(WINELIB) && !defined(HAVE_WINE_CONSTRUCTOR)
213 /* Register resources */
214 LIBWINE_Register_Da();
215 LIBWINE_Register_De();
216 LIBWINE_Register_En();
217 LIBWINE_Register_Es();
218 LIBWINE_Register_Fr();
219 LIBWINE_Register_Sw();
223 Globals.bAnalog = TRUE;
224 Globals.bSeconds = TRUE;
225 Globals.lpszIniFile = "clock.ini";
226 Globals.lpszIcoFile = "clock.ico";
228 /* Select Language */
231 Globals.hInstance = hInstance;
232 Globals.hMainIcon = ExtractIcon(Globals.hInstance,
233 Globals.lpszIcoFile, 0);
235 if (!Globals.hMainIcon) Globals.hMainIcon =
236 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
239 class.style = CS_HREDRAW | CS_VREDRAW;
240 class.lpfnWndProc = CLOCK_WndProc;
241 class.cbClsExtra = 0;
242 class.cbWndExtra = 0;
243 class.hInstance = Globals.hInstance;
244 class.hIcon = LoadIcon (0, IDI_APPLICATION);
245 class.hCursor = LoadCursor (0, IDC_ARROW);
246 class.hbrBackground = GetStockObject (GRAY_BRUSH);
247 class.lpszMenuName = 0;
248 class.lpszClassName = szClassName;
251 if (!RegisterClass (&class)) return FALSE;
253 Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
254 CW_USEDEFAULT, 0, CW_USEDEFAULT, Globals.MaxX, Globals.MaxY,
255 LoadMenu(Globals.hInstance, STRING_MENU_Xx), Globals.hInstance, 0);
257 LANGUAGE_SelectByName(Globals.lpszLanguage);
258 SetMenu(Globals.hMainWnd, Globals.hMainMenu);
260 LANGUAGE_UpdateMenuCheckmarks();
262 ShowWindow (Globals.hMainWnd, show);
263 UpdateWindow (Globals.hMainWnd);
267 if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
268 if (msg.message == WM_QUIT) return msg.wParam;
269 TranslateMessage(&msg);
270 DispatchMessage(&msg);
276 /* We will never reach the following statement ! */