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
30 #include "wine/version.h"
35 CLOCK_GLOBALS Globals;
37 /***********************************************************************
41 * All handling of main menu events
44 int CLOCK_MenuCommand (WPARAM wParam)
46 CHAR szApp[MAX_STRING_LEN];
47 CHAR szAppRelease[MAX_STRING_LEN];
49 /* switch to analog */
51 Globals.bAnalog = TRUE;
52 LANGUAGE_UpdateMenuCheckmarks();
53 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
56 /* switch to digital */
58 Globals.bAnalog = FALSE;
59 LANGUAGE_UpdateMenuCheckmarks();
60 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
65 MAIN_FileChooseFont();
70 Globals.bWithoutTitle = !Globals.bWithoutTitle;
71 LANGUAGE_UpdateWindowCaption();
72 LANGUAGE_UpdateMenuCheckmarks();
77 Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
78 LANGUAGE_UpdateMenuCheckmarks();
81 /* show or hide seconds */
83 Globals.bSeconds = !Globals.bSeconds;
84 LANGUAGE_UpdateMenuCheckmarks();
85 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
88 /* show or hide date */
90 Globals.bDate = !Globals.bDate;
91 LANGUAGE_UpdateMenuCheckmarks();
92 LANGUAGE_UpdateWindowCaption();
97 WineLicense(Globals.hMainWnd);
100 /* show warranties */
102 WineWarranty(Globals.hMainWnd);
105 /* show "about" box */
107 LoadString(Globals.hInstance, 0x10C, szApp, sizeof(szApp));
108 lstrcpy(szAppRelease,szApp);
109 lstrcat(szAppRelease,"\n" WINE_RELEASE_INFO);
110 ShellAbout(Globals.hMainWnd, szApp, szAppRelease, 0);
113 /* Handle languages */
115 LANGUAGE_DefaultHandle(wParam);
121 VOID MAIN_FileChooseFont(VOID) {
126 font.lStructSize = sizeof(font);
127 font.hwndOwner = Globals.hMainWnd;
129 font.lpLogFont = &lf;
135 font.lpTemplateName = 0;
136 font.hInstance = Globals.hInstance;
137 /* font.lpszStyle = LF_FACESIZE; */
142 if (ChooseFont(&font)) {
148 /***********************************************************************
153 LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
161 printf("WM_CREATE\n");
166 printf("WM_RBUTTONUP\n");
167 Globals.bWithoutTitle = !Globals.bWithoutTitle;
168 LANGUAGE_UpdateMenuCheckmarks();
169 LANGUAGE_UpdateWindowCaption();
170 UpdateWindow (Globals.hMainWnd);
175 printf("WM_PAINT\n");
176 context = BeginPaint(hWnd, &ps);
177 if(Globals.bAnalog) {
191 Globals.MaxX = LOWORD(lParam);
192 Globals.MaxY = HIWORD(lParam);
193 OldHour.DontRedraw = TRUE;
194 OldMinute.DontRedraw = TRUE;
195 OldSecond.DontRedraw = TRUE;
200 CLOCK_MenuCommand(wParam);
205 printf("WM_DESTROY\n");
211 return DefWindowProc (hWnd, msg, wParam, lParam);
218 /***********************************************************************
223 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
228 char szClassName[] = "CLClass"; /* To make sure className >= 0x10000 */
229 char szWinName[] = "Clock";
232 Globals.bAnalog = TRUE;
233 Globals.bSeconds = TRUE;
234 Globals.lpszIniFile = "clock.ini";
235 Globals.lpszIcoFile = "clock.ico";
237 Globals.hInstance = hInstance;
238 Globals.hMainIcon = ExtractIcon(Globals.hInstance,
239 Globals.lpszIcoFile, 0);
241 if (!Globals.hMainIcon) Globals.hMainIcon =
242 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
245 class.style = CS_HREDRAW | CS_VREDRAW;
246 class.lpfnWndProc = CLOCK_WndProc;
247 class.cbClsExtra = 0;
248 class.cbWndExtra = 0;
249 class.hInstance = Globals.hInstance;
250 class.hIcon = LoadIcon (0, IDI_APPLICATION);
251 class.hCursor = LoadCursor (0, IDC_ARROW);
252 class.hbrBackground = GetStockObject (GRAY_BRUSH);
253 class.lpszMenuName = 0;
254 class.lpszClassName = szClassName;
257 if (!RegisterClass (&class)) return FALSE;
259 Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
260 CW_USEDEFAULT, CW_USEDEFAULT, Globals.MaxX, Globals.MaxY, 0,
261 LoadMenu(Globals.hInstance, STRING_MENU_Xx), Globals.hInstance, 0);
263 LANGUAGE_LoadMenus();
264 SetMenu(Globals.hMainWnd, Globals.hMainMenu);
266 LANGUAGE_UpdateMenuCheckmarks();
268 ShowWindow (Globals.hMainWnd, show);
269 UpdateWindow (Globals.hMainWnd);
273 if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
274 if (msg.message == WM_QUIT) return msg.wParam;
275 TranslateMessage(&msg);
276 DispatchMessage(&msg);
282 /* We will never reach the following statement ! */