4 * Copyright 1998 Marcel Baur <mbaur@g26.ethz.ch>
5 * Copyright 1998 Karl Backström <karl_b@geocities.com>
17 CHAR STRING_MENU_Xx[] = "MENU_Xx";
19 VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
21 if(Globals.bAnalog == TRUE) {
25 CheckMenuItem(Globals.hPropertiesMenu, CL_ANALOG, \
26 MF_BYCOMMAND | MF_CHECKED);
27 CheckMenuItem(Globals.hPropertiesMenu, CL_DIGITAL, \
28 MF_BYCOMMAND | MF_UNCHECKED);
29 EnableMenuItem(Globals.hPropertiesMenu, CL_FONT, \
30 MF_BYCOMMAND | MF_GRAYED);
37 CheckMenuItem(Globals.hPropertiesMenu, CL_ANALOG, \
38 MF_BYCOMMAND | MF_UNCHECKED);
39 CheckMenuItem(Globals.hPropertiesMenu, CL_DIGITAL, \
40 MF_BYCOMMAND | MF_CHECKED);
41 EnableMenuItem(Globals.hPropertiesMenu, CL_FONT, \
46 CheckMenuItem(Globals.hPropertiesMenu, CL_WITHOUT_TITLE, MF_BYCOMMAND | \
47 (Globals.bWithoutTitle ? MF_CHECKED : MF_UNCHECKED));
48 CheckMenuItem(Globals.hSystemMenu, CL_ON_TOP, MF_BYCOMMAND | \
49 (Globals.bAlwaysOnTop ? MF_CHECKED : MF_UNCHECKED));
50 CheckMenuItem(Globals.hPropertiesMenu, CL_SECONDS, MF_BYCOMMAND | \
51 (Globals.bSeconds ? MF_CHECKED : MF_UNCHECKED));
52 CheckMenuItem(Globals.hPropertiesMenu, CL_DATE, MF_BYCOMMAND | \
53 (Globals.bDate ? MF_CHECKED : MF_UNCHECKED));
56 VOID LANGUAGE_UpdateWindowCaption(VOID) {
58 CHAR szCaption[MAX_STRING_LEN];
59 CHAR szDate[MAX_STRING_LEN];
64 LPSYSTEMTIME lpst = &st;
67 GetDateFormat(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, lpst, NULL, date,
70 /* Set frame caption */
71 LoadString(Globals.hInstance, IDS_CLOCK, szCaption, sizeof(szCaption));
73 lstrcat(szCaption, " - ");
74 lstrcat(szCaption, szDate);
76 SetWindowText(Globals.hMainWnd, szCaption);
82 static BOOL LANGUAGE_LoadStringOther(UINT num, UINT ids, LPSTR str, UINT len)
84 ids -= Globals.wStringTableOffset;
86 return(LoadString(Globals.hInstance, ids, str, len));
89 VOID LANGUAGE_SelectByName(LPCSTR lang)
94 for (i = 0; i <= MAX_LANGUAGE_NUMBER; i++)
95 if (LANGUAGE_LoadStringOther(i, IDS_LANGUAGE_ID, szNewLang,
96 sizeof(szNewLang)) && !lstrcmp(lang, szNewLang))
98 LANGUAGE_SelectByNumber(i);
103 for (i = 0; i <= MAX_LANGUAGE_NUMBER; i++)
104 if (LANGUAGE_LoadStringOther(i, IDS_LANGUAGE_ID, szNewLang, sizeof(szNewLang)))
106 LANGUAGE_SelectByNumber(i);
110 MessageBox(Globals.hMainWnd, "No language found", "FATAL ERROR", MB_OK);
114 VOID LANGUAGE_SelectByNumber(UINT num)
119 CHAR szItem[MAX_STRING_LEN];
122 /* Select string table */
123 Globals.wStringTableOffset = num * 0x100;
125 /* Get Language id */
126 LoadString(Globals.hInstance, IDS_LANGUAGE_ID, szLanguage, sizeof(szLanguage));
127 Globals.lpszLanguage = szLanguage;
129 /* Change Resource names */
130 lstrcpyn(STRING_MENU_Xx + sizeof(STRING_MENU_Xx) - 3, szLanguage, 3);
133 hMainMenu = LoadMenu(Globals.hInstance, STRING_MENU_Xx);
134 Globals.hPropertiesMenu = GetSubMenu(hMainMenu, 0);
135 Globals.hLanguageMenu = GetSubMenu(hMainMenu, 1);
136 Globals.hInfoMenu = GetSubMenu(hMainMenu, 2);
138 /* Remove dummy item */
139 RemoveMenu(Globals.hLanguageMenu, 0, MF_BYPOSITION);
140 /* Add language items */
141 for (i = 0; i <= MAX_LANGUAGE_NUMBER; i++)
142 if (LANGUAGE_LoadStringOther(i, IDS_LANGUAGE_MENU_ITEM, szItem, sizeof(szItem)))
143 AppendMenu(Globals.hLanguageMenu, MF_STRING | MF_BYCOMMAND,
144 CL_FIRST_LANGUAGE + i, szItem);
145 EnableMenuItem(Globals.hLanguageMenu, CL_FIRST_LANGUAGE + num, MF_BYCOMMAND | MF_CHECKED);
147 SetMenu(Globals.hMainWnd, hMainMenu);
149 /* Destroy old menu */
150 if (Globals.hMainMenu) DestroyMenu(Globals.hMainMenu);
151 Globals.hMainMenu = hMainMenu;
154 /* Update system menus */
155 for (i = 0; Languages[i].name && lstrcmp(szLanguage, Languages[i].name);) i++;
156 if (Languages[i].name) Options.language = i;
159 /* specific for Clock: */
161 LANGUAGE_UpdateMenuCheckmarks();
162 LANGUAGE_UpdateWindowCaption();
164 Globals.hSystemMenu = GetSystemMenu(Globals.hMainWnd, TRUE);
166 /* FIXME: Append a SEPARATOR to Globals.hSystemMenu here */
168 LoadString(Globals.hInstance, IDS_MENU_ON_TOP, szItem, sizeof(szItem));
169 AppendMenu(Globals.hSystemMenu, MF_STRING | MF_BYCOMMAND, 1000, szItem);
172 VOID LANGUAGE_DefaultHandle(WPARAM wParam)
174 if ((wParam >=CL_FIRST_LANGUAGE) && (wParam<=CL_LAST_LANGUAGE))
175 LANGUAGE_SelectByNumber(wParam - CL_FIRST_LANGUAGE);
176 else printf("Unimplemented menu command %i\n", wParam);
179 VOID LANGUAGE_Init(VOID)
181 CHAR szBuffer[MAX_PATHNAME_LEN];
184 Globals.lpszLanguage = Languages[Options.language].name;
187 if (Globals.lpszLanguage == "En") {
188 PROFILE_GetWineIniString("programs", "language", "En", szBuffer,
190 Globals.lpszLanguage = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(szBuffer)));
192 /* hmemcpy(Globals.lpszLanguage, szBuffer, 1+lstrlen(szBuffer)); */
193 lstrcpyn(Globals.lpszLanguage, szBuffer, strlen(szBuffer)+1);
197 /* Local Variables: */
198 /* c-file-style: "GNU" */