ref: 19172c4a30a15e69ad2e8aa74524d0c512e321c1
parent: 810814823f35c158fa667896c6176950470b66a4
author: Simon Tatham <[email protected]>
date: Wed Apr 9 10:57:20 EDT 2008
Implement tick marks in the Type menu on Windows. Now all my front ends have got them. [originally from svn r7982]
--- a/windows.c
+++ b/windows.c
@@ -195,6 +195,7 @@
HBRUSH *brushes;
HPEN *pens;
HRGN clip;
+ HMENU typemenu;
UINT timer;
DWORD timer_last_tickcount;
int npresets;
@@ -220,6 +221,8 @@
int xmin, ymin;
};
+static void update_type_menu_tick(frontend *fe);
+
void fatal(char *fmt, ...)
{
char buf[2048];
@@ -584,10 +587,11 @@
xy.y -= tm.tmAscent;
}
#ifndef _WIN32_WCE
- if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size)) {
+ if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size))
#else
- if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size)) {
+ if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size))
#endif
+ {
if (align & ALIGN_HCENTRE)
xy.x -= size.cx / 2;
else if (align & ALIGN_HRIGHT)
@@ -1613,8 +1617,11 @@
if (thegame.can_configure) {
AppendMenu(sub, MF_ENABLED, IDM_CONFIG, TEXT("&Custom..."));
}
- }
+ fe->typemenu = sub;
+ } else
+ fe->typemenu = INVALID_HANDLE_VALUE;
+
AppendMenu(menu, MF_SEPARATOR, 0, 0);
#ifndef _WIN32_WCE
AppendMenu(menu, MF_ENABLED, IDM_LOAD, TEXT("&Load..."));
@@ -1672,6 +1679,8 @@
ShowWindow(fe->hwnd, SW_SHOWNORMAL);
SetForegroundWindow(fe->hwnd);
+ update_type_menu_tick(fe);
+
midend_redraw(fe->me);
return fe;
@@ -2628,10 +2637,31 @@
*wx_r = wx; *wy_r = wy;
}
+static void update_type_menu_tick(frontend *fe)
+{
+ int total, n, i;
+
+ if (fe->typemenu == INVALID_HANDLE_VALUE)
+ return;
+
+ total = GetMenuItemCount(fe->typemenu);
+ n = midend_which_preset(fe->me);
+ if (n < 0)
+ n = total - 1; /* "Custom" item */
+
+ for (i = 0; i < total; i++) {
+ int flag = (i == n ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(fe->typemenu, i, MF_BYPOSITION | flag);
+ }
+
+ DrawMenuBar(fe->hwnd);
+}
+
static void new_game_type(frontend *fe)
{
midend_new_game(fe->me);
new_game_size(fe);
+ update_type_menu_tick(fe);
}
static int is_alt_pressed(void)