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();
31 void LIBWINE_Register_Fi();
34 CLOCK_GLOBALS Globals
;
36 /***********************************************************************
40 * All handling of main menu events
43 int CLOCK_MenuCommand (WPARAM wParam
)
47 Globals
.bAnalog
= TRUE
;
48 LANGUAGE_UpdateMenuCheckmarks();
49 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
53 Globals
.bAnalog
= FALSE
;
54 LANGUAGE_UpdateMenuCheckmarks();
55 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
59 MAIN_FileChooseFont();
62 case CL_WITHOUT_TITLE
: {
63 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
64 LANGUAGE_UpdateWindowCaption();
65 LANGUAGE_UpdateMenuCheckmarks();
69 Globals
.bAlwaysOnTop
= !Globals
.bAlwaysOnTop
;
70 LANGUAGE_UpdateMenuCheckmarks();
74 Globals
.bSeconds
= !Globals
.bSeconds
;
75 LANGUAGE_UpdateMenuCheckmarks();
76 SendMessage(Globals
.hMainWnd
, WM_PAINT
, 0, 0);
80 Globals
.bDate
= !Globals
.bDate
;
81 LANGUAGE_UpdateMenuCheckmarks();
82 LANGUAGE_UpdateWindowCaption();
85 case CL_INFO_LICENSE
: {
86 WineLicense(Globals
.hMainWnd
, Globals
.lpszLanguage
);
89 case CL_INFO_NO_WARRANTY
: {
90 WineWarranty(Globals
.hMainWnd
, Globals
.lpszLanguage
);
93 case CL_INFO_ABOUT_WINE
: {
94 ShellAbout(Globals
.hMainWnd
, "Clock", "Clock\n" WINE_RELEASE_INFO
, 0);
97 /* Handle languages */
99 LANGUAGE_DefaultHandle(wParam
);
104 VOID
MAIN_FileChooseFont(VOID
) {
108 font
.lStructSize
= sizeof(font
);
109 font
.hwndOwner
= Globals
.hMainWnd
;
117 font
.lpTemplateName
= 0;
118 font
.hInstance
= Globals
.hInstance
;
119 /* font.lpszStyle = LF_FACESIZE; */
124 if (ChooseFont(&font
)) {
130 /***********************************************************************
135 LRESULT
CLOCK_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
143 printf("WM_CREATE\n");
148 printf("WM_RBUTTONUP\n");
149 Globals
.bWithoutTitle
= !Globals
.bWithoutTitle
;
150 LANGUAGE_UpdateMenuCheckmarks();
151 LANGUAGE_UpdateWindowCaption();
152 UpdateWindow (Globals
.hMainWnd
);
157 printf("WM_PAINT\n");
158 context
= BeginPaint(hWnd
, &ps
);
159 if(Globals
.bAnalog
) {
173 Globals
.MaxX
= LOWORD(lParam
);
174 Globals
.MaxY
= HIWORD(lParam
);
175 OldHour
.DontRedraw
= TRUE
;
176 OldMinute
.DontRedraw
= TRUE
;
177 OldSecond
.DontRedraw
= TRUE
;
182 CLOCK_MenuCommand(wParam
);
187 printf("WM_DESTROY\n");
193 return DefWindowProc (hWnd
, msg
, wParam
, lParam
);
200 /***********************************************************************
205 int PASCAL
WinMain (HANDLE hInstance
, HANDLE prev
, LPSTR cmdline
, int show
)
210 char szClassName
[] = "CLClass"; /* To make sure className >= 0x10000 */
211 char szWinName
[] = "Clock";
213 #if defined(WINELIB) && !defined(HAVE_WINE_CONSTRUCTOR)
214 /* Register resources */
215 LIBWINE_Register_Da();
216 LIBWINE_Register_De();
217 LIBWINE_Register_En();
218 LIBWINE_Register_Es();
219 LIBWINE_Register_Fr();
220 LIBWINE_Register_Sw();
221 LIBWINE_Register_Fi();
225 Globals
.bAnalog
= TRUE
;
226 Globals
.bSeconds
= TRUE
;
227 Globals
.lpszIniFile
= "clock.ini";
228 Globals
.lpszIcoFile
= "clock.ico";
230 /* Select Language */
233 Globals
.hInstance
= hInstance
;
234 Globals
.hMainIcon
= ExtractIcon(Globals
.hInstance
,
235 Globals
.lpszIcoFile
, 0);
237 if (!Globals
.hMainIcon
) Globals
.hMainIcon
=
238 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON
));
241 class.style
= CS_HREDRAW
| CS_VREDRAW
;
242 class.lpfnWndProc
= CLOCK_WndProc
;
243 class.cbClsExtra
= 0;
244 class.cbWndExtra
= 0;
245 class.hInstance
= Globals
.hInstance
;
246 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
247 class.hCursor
= LoadCursor (0, IDC_ARROW
);
248 class.hbrBackground
= GetStockObject (GRAY_BRUSH
);
249 class.lpszMenuName
= 0;
250 class.lpszClassName
= szClassName
;
253 if (!RegisterClass (&class)) return FALSE
;
255 Globals
.hMainWnd
= CreateWindow (szClassName
, szWinName
, WS_OVERLAPPEDWINDOW
,
256 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, Globals
.MaxX
, Globals
.MaxY
,
257 LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
), Globals
.hInstance
, 0);
259 LANGUAGE_SelectByName(Globals
.lpszLanguage
);
260 SetMenu(Globals
.hMainWnd
, Globals
.hMainMenu
);
262 LANGUAGE_UpdateMenuCheckmarks();
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 ! */