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
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 CLOCK_GLOBALS Globals;
38 /***********************************************************************
42 * All handling of main menu events
45 int CLOCK_MenuCommand (WPARAM wParam)
47 CHAR szApp[MAX_STRING_LEN];
48 CHAR szAppRelease[MAX_STRING_LEN];
50 /* switch to analog */
52 Globals.bAnalog = TRUE;
53 LANGUAGE_UpdateMenuCheckmarks();
54 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
57 /* switch to digital */
59 Globals.bAnalog = FALSE;
60 LANGUAGE_UpdateMenuCheckmarks();
61 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
66 MAIN_FileChooseFont();
71 Globals.bWithoutTitle = !Globals.bWithoutTitle;
72 LANGUAGE_UpdateWindowCaption();
73 LANGUAGE_UpdateMenuCheckmarks();
78 Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
79 LANGUAGE_UpdateMenuCheckmarks();
82 /* show or hide seconds */
84 Globals.bSeconds = !Globals.bSeconds;
85 LANGUAGE_UpdateMenuCheckmarks();
86 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
89 /* show or hide date */
91 Globals.bDate = !Globals.bDate;
92 LANGUAGE_UpdateMenuCheckmarks();
93 LANGUAGE_UpdateWindowCaption();
98 WineLicense(Globals.hMainWnd);
101 /* show warranties */
103 WineWarranty(Globals.hMainWnd);
106 /* show "about" box */
108 LoadString(Globals.hInstance, 0x10C, szApp, sizeof(szApp));
109 lstrcpy(szAppRelease,szApp);
110 lstrcat(szAppRelease,"\n" PACKAGE_STRING);
111 ShellAbout(Globals.hMainWnd, szApp, szAppRelease, 0);
114 /* Handle languages */
116 LANGUAGE_DefaultHandle(wParam);
122 VOID MAIN_FileChooseFont(VOID) {
127 font.lStructSize = sizeof(font);
128 font.hwndOwner = Globals.hMainWnd;
130 font.lpLogFont = &lf;
136 font.lpTemplateName = 0;
137 font.hInstance = Globals.hInstance;
138 /* font.lpszStyle = LF_FACESIZE; */
143 if (ChooseFont(&font)) {
149 /***********************************************************************
154 LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
162 printf("WM_CREATE\n");
167 printf("WM_RBUTTONUP\n");
168 Globals.bWithoutTitle = !Globals.bWithoutTitle;
169 LANGUAGE_UpdateMenuCheckmarks();
170 LANGUAGE_UpdateWindowCaption();
171 UpdateWindow (Globals.hMainWnd);
176 printf("WM_PAINT\n");
177 context = BeginPaint(hWnd, &ps);
178 if(Globals.bAnalog) {
192 Globals.MaxX = LOWORD(lParam);
193 Globals.MaxY = HIWORD(lParam);
194 OldHour.DontRedraw = TRUE;
195 OldMinute.DontRedraw = TRUE;
196 OldSecond.DontRedraw = TRUE;
201 CLOCK_MenuCommand(wParam);
206 printf("WM_DESTROY\n");
212 return DefWindowProc (hWnd, msg, wParam, lParam);
219 /***********************************************************************
224 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
229 char szClassName[] = "CLClass"; /* To make sure className >= 0x10000 */
230 char szWinName[] = "Clock";
233 Globals.bAnalog = TRUE;
234 Globals.bSeconds = TRUE;
235 Globals.lpszIniFile = "clock.ini";
236 Globals.lpszIcoFile = "clock.ico";
238 Globals.hInstance = hInstance;
239 Globals.hMainIcon = ExtractIcon(Globals.hInstance,
240 Globals.lpszIcoFile, 0);
242 if (!Globals.hMainIcon) Globals.hMainIcon =
243 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
246 class.style = CS_HREDRAW | CS_VREDRAW;
247 class.lpfnWndProc = CLOCK_WndProc;
248 class.cbClsExtra = 0;
249 class.cbWndExtra = 0;
250 class.hInstance = Globals.hInstance;
251 class.hIcon = LoadIcon (0, IDI_APPLICATION);
252 class.hCursor = LoadCursor (0, IDC_ARROW);
253 class.hbrBackground = GetStockObject (GRAY_BRUSH);
254 class.lpszMenuName = 0;
255 class.lpszClassName = szClassName;
258 if (!RegisterClass (&class)) return FALSE;
260 Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
261 CW_USEDEFAULT, CW_USEDEFAULT, Globals.MaxX, Globals.MaxY, 0,
262 LoadMenu(Globals.hInstance, STRING_MENU_Xx), Globals.hInstance, 0);
264 LANGUAGE_LoadMenus();
265 SetMenu(Globals.hMainWnd, Globals.hMainMenu);
267 LANGUAGE_UpdateMenuCheckmarks();
269 ShowWindow (Globals.hMainWnd, show);
270 UpdateWindow (Globals.hMainWnd);
274 if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
275 if (msg.message == WM_QUIT) return msg.wParam;
276 TranslateMessage(&msg);
277 DispatchMessage(&msg);
283 /* We will never reach the following statement ! */