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)
48 Globals.bAnalog = TRUE;
49 LANGUAGE_UpdateMenuCheckmarks();
50 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
54 Globals.bAnalog = FALSE;
55 LANGUAGE_UpdateMenuCheckmarks();
56 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
60 MAIN_FileChooseFont();
63 case CL_WITHOUT_TITLE: {
64 Globals.bWithoutTitle = !Globals.bWithoutTitle;
65 LANGUAGE_UpdateWindowCaption();
66 LANGUAGE_UpdateMenuCheckmarks();
70 Globals.bAlwaysOnTop = !Globals.bAlwaysOnTop;
71 LANGUAGE_UpdateMenuCheckmarks();
75 Globals.bSeconds = !Globals.bSeconds;
76 LANGUAGE_UpdateMenuCheckmarks();
77 SendMessage(Globals.hMainWnd, WM_PAINT, 0, 0);
81 Globals.bDate = !Globals.bDate;
82 LANGUAGE_UpdateMenuCheckmarks();
83 LANGUAGE_UpdateWindowCaption();
86 case CL_INFO_LICENSE: {
87 WineLicense(Globals.hMainWnd);
90 case CL_INFO_NO_WARRANTY: {
91 WineWarranty(Globals.hMainWnd);
94 case CL_INFO_ABOUT_WINE: {
95 ShellAbout(Globals.hMainWnd, "Clock", "Clock\n" WINE_RELEASE_INFO, 0);
98 /* Handle languages */
100 LANGUAGE_DefaultHandle(wParam);
105 VOID MAIN_FileChooseFont(VOID) {
110 font.lStructSize = sizeof(font);
111 font.hwndOwner = Globals.hMainWnd;
113 font.lpLogFont = &lf;
119 font.lpTemplateName = 0;
120 font.hInstance = Globals.hInstance;
121 /* font.lpszStyle = LF_FACESIZE; */
126 if (ChooseFont(&font)) {
132 /***********************************************************************
137 LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
145 printf("WM_CREATE\n");
150 printf("WM_RBUTTONUP\n");
151 Globals.bWithoutTitle = !Globals.bWithoutTitle;
152 LANGUAGE_UpdateMenuCheckmarks();
153 LANGUAGE_UpdateWindowCaption();
154 UpdateWindow (Globals.hMainWnd);
159 printf("WM_PAINT\n");
160 context = BeginPaint(hWnd, &ps);
161 if(Globals.bAnalog) {
175 Globals.MaxX = LOWORD(lParam);
176 Globals.MaxY = HIWORD(lParam);
177 OldHour.DontRedraw = TRUE;
178 OldMinute.DontRedraw = TRUE;
179 OldSecond.DontRedraw = TRUE;
184 CLOCK_MenuCommand(wParam);
189 printf("WM_DESTROY\n");
195 return DefWindowProc (hWnd, msg, wParam, lParam);
202 /***********************************************************************
207 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
212 char szClassName[] = "CLClass"; /* To make sure className >= 0x10000 */
213 char szWinName[] = "Clock";
216 Globals.bAnalog = TRUE;
217 Globals.bSeconds = TRUE;
218 Globals.lpszIniFile = "clock.ini";
219 Globals.lpszIcoFile = "clock.ico";
221 Globals.hInstance = hInstance;
222 Globals.hMainIcon = ExtractIcon(Globals.hInstance,
223 Globals.lpszIcoFile, 0);
225 if (!Globals.hMainIcon) Globals.hMainIcon =
226 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
229 class.style = CS_HREDRAW | CS_VREDRAW;
230 class.lpfnWndProc = CLOCK_WndProc;
231 class.cbClsExtra = 0;
232 class.cbWndExtra = 0;
233 class.hInstance = Globals.hInstance;
234 class.hIcon = LoadIcon (0, IDI_APPLICATION);
235 class.hCursor = LoadCursor (0, IDC_ARROW);
236 class.hbrBackground = GetStockObject (GRAY_BRUSH);
237 class.lpszMenuName = 0;
238 class.lpszClassName = szClassName;
241 if (!RegisterClass (&class)) return FALSE;
243 Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW,
244 CW_USEDEFAULT, CW_USEDEFAULT, Globals.MaxX, Globals.MaxY, 0,
245 LoadMenu(Globals.hInstance, STRING_MENU_Xx), Globals.hInstance, 0);
247 LANGUAGE_SelectByName("En");
248 SetMenu(Globals.hMainWnd, Globals.hMainMenu);
250 LANGUAGE_UpdateMenuCheckmarks();
252 ShowWindow (Globals.hMainWnd, show);
253 UpdateWindow (Globals.hMainWnd);
257 if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
258 if (msg.message == WM_QUIT) return msg.wParam;
259 TranslateMessage(&msg);
260 DispatchMessage(&msg);
266 /* We will never reach the following statement ! */