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_De();
26 void LIBWINE_Register_En();
27 void LIBWINE_Register_Sw();
30 CLOCK_GLOBALS Globals
;
32 /***********************************************************************
36 * All handling of main menu events
39 int CLOCK_MenuCommand (WPARAM wParam
)
43 Globals
.bAnalog
= TRUE
;
44 LANGUAGE_UpdateMenuCheckmarks();
45 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
49 Globals
.bAnalog
= FALSE
;
50 LANGUAGE_UpdateMenuCheckmarks();
51 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
55 MAIN_FileChooseFont();
58 case CL_WITHOUT_TITLE
: {
59 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
60 LANGUAGE_UpdateWindowCaption();
61 LANGUAGE_UpdateMenuCheckmarks();
65 Globals
.bAlwaysOnTop
= !Globals
.bAlwaysOnTop
;
66 LANGUAGE_UpdateMenuCheckmarks();
70 Globals
.bSeconds
= !Globals
.bSeconds
;
71 LANGUAGE_UpdateMenuCheckmarks();
72 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
76 Globals
.bDate
= !Globals
.bDate
;
77 LANGUAGE_UpdateMenuCheckmarks();
78 LANGUAGE_UpdateWindowCaption();
81 case CL_INFO_LICENSE
: {
82 WineLicense(Globals
.hMainWnd
, Globals
.lpszLanguage
);
85 case CL_INFO_NO_WARRANTY
: {
86 WineWarranty(Globals
.hMainWnd
, Globals
.lpszLanguage
);
89 case CL_INFO_ABOUT_WINE
: {
90 ShellAbout(Globals
.hMainWnd
, "Clock", "Clock\n" WINE_RELEASE_INFO
, 0);
95 LANGUAGE_DefaultHandle(wParam
);
100 VOID
MAIN_FileChooseFont(VOID
) {
104 font
.lStructSize
= sizeof(font
);
105 font
.hwndOwner
= Globals
.hMainWnd
;
113 font
.lpTemplateName
= 0;
114 font
.hInstance
= Globals
.hInstance
;
115 font
.lpszStyle
= LF_FACESIZE
;
120 if (ChooseFont(&font
)) {
126 /***********************************************************************
131 LRESULT
CLOCK_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
139 printf("WM_CREATE\n");
144 printf("WM_RBUTTONUP\n");
145 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
146 LANGUAGE_UpdateMenuCheckmarks();
147 LANGUAGE_UpdateWindowCaption();
148 UpdateWindow (Globals
.hMainWnd
);
153 printf("WM_PAINT\n");
154 context
= BeginPaint(hWnd
, &ps
);
155 if(Globals
.bAnalog
) {
169 Globals
.MaxX
= LOWORD(lParam
);
170 Globals
.MaxY
= HIWORD(lParam
);
171 OldHour
.DontRedraw
= TRUE
;
172 OldMinute
.DontRedraw
= TRUE
;
173 OldSecond
.DontRedraw
= TRUE
;
178 CLOCK_MenuCommand(wParam
);
183 printf("WM_DESTROY\n");
189 return DefWindowProc (hWnd
, msg
, wParam
, lParam
);
196 /***********************************************************************
201 int PASCAL
WinMain (HANDLE hInstance
, HANDLE prev
, LPSTR cmdline
, int show
)
206 char className
[] = "CLClass"; /* To make sure className >= 0x10000 */
207 char winName
[] = "Clock";
209 #if defined(WINELIB) && !defined(HAVE_WINE_CONSTRUCTOR)
210 /* Register resources */
211 LIBWINE_Register_De();
212 LIBWINE_Register_En();
213 LIBWINE_Register_Sw();
216 printf("WinMain()\n");
219 Globals
.bAnalog
= TRUE
;
220 Globals
.bSeconds
= TRUE
;
221 Globals
.lpszIniFile
= "clock.ini";
222 Globals
.lpszIcoFile
= "clock.ico";
224 /* Select Language */
227 Globals
.hInstance
= hInstance
;
228 Globals
.hMainIcon
= ExtractIcon(Globals
.hInstance
,
229 Globals
.lpszIcoFile
, 0);
231 if (!Globals
.hMainIcon
) Globals
.hMainIcon
=
232 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON
));
235 class.style
= CS_HREDRAW
| CS_VREDRAW
;
236 class.lpfnWndProc
= CLOCK_WndProc
;
237 class.cbClsExtra
= 0;
238 class.cbWndExtra
= 0;
239 class.hInstance
= Globals
.hInstance
;
240 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
241 class.hCursor
= LoadCursor (0, IDC_ARROW
);
242 class.hbrBackground
= GetStockObject (GRAY_BRUSH
);
243 class.lpszMenuName
= 0;
244 class.lpszClassName
= className
;
247 if (!RegisterClass (&class)) return FALSE
;
249 Globals
.hMainWnd
= CreateWindow (className
, winName
, WS_OVERLAPPEDWINDOW
,
250 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, Globals
.MaxX
, Globals
.MaxY
,
251 LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
),
252 Globals
.hInstance
, 0);
254 LANGUAGE_SelectByName(Globals
.lpszLanguage
);
255 SetMenu(Globals
.hMainWnd
, Globals
.hMainMenu
);
257 Globals
.hSystemMenu
= GetSystemMenu(Globals
.hMainWnd
, TRUE
);
259 AppendMenu(Globals
.hSystemMenu
, MF_STRING
| MF_BYCOMMAND
, 1000, "item");
260 SetSystemMenu(Globals
.hMainWnd
, Globals
.hSystemMenu
);
262 EnableMenuItem(Globals
.hPropertiesMenu
, CL_FONT
, \
263 MF_BYCOMMAND
| MF_GRAYED
);
264 ShowWindow (Globals
.hMainWnd
, show
);
265 UpdateWindow (Globals
.hMainWnd
);
269 if (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) {
270 if (msg
.message
== WM_QUIT
) return msg
.wParam
;
271 TranslateMessage(&msg
);
272 DispatchMessage(&msg
);
278 // We will never reach the following statement !