mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Implement tick marks in the Type menu on Windows. Now all my front
ends have got them. [originally from svn r7982]
This commit is contained in:
36
windows.c
36
windows.c
@ -195,6 +195,7 @@ struct frontend {
|
|||||||
HBRUSH *brushes;
|
HBRUSH *brushes;
|
||||||
HPEN *pens;
|
HPEN *pens;
|
||||||
HRGN clip;
|
HRGN clip;
|
||||||
|
HMENU typemenu;
|
||||||
UINT timer;
|
UINT timer;
|
||||||
DWORD timer_last_tickcount;
|
DWORD timer_last_tickcount;
|
||||||
int npresets;
|
int npresets;
|
||||||
@ -220,6 +221,8 @@ struct frontend {
|
|||||||
int xmin, ymin;
|
int xmin, ymin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void update_type_menu_tick(frontend *fe);
|
||||||
|
|
||||||
void fatal(char *fmt, ...)
|
void fatal(char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
@ -584,10 +587,11 @@ static void win_draw_text(void *handle, int x, int y, int fonttype,
|
|||||||
xy.y -= tm.tmAscent;
|
xy.y -= tm.tmAscent;
|
||||||
}
|
}
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size)) {
|
if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size))
|
||||||
#else
|
#else
|
||||||
if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size)) {
|
if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size))
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
if (align & ALIGN_HCENTRE)
|
if (align & ALIGN_HCENTRE)
|
||||||
xy.x -= size.cx / 2;
|
xy.x -= size.cx / 2;
|
||||||
else if (align & ALIGN_HRIGHT)
|
else if (align & ALIGN_HRIGHT)
|
||||||
@ -1613,7 +1617,10 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
|||||||
if (thegame.can_configure) {
|
if (thegame.can_configure) {
|
||||||
AppendMenu(sub, MF_ENABLED, IDM_CONFIG, TEXT("&Custom..."));
|
AppendMenu(sub, MF_ENABLED, IDM_CONFIG, TEXT("&Custom..."));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
fe->typemenu = sub;
|
||||||
|
} else
|
||||||
|
fe->typemenu = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
AppendMenu(menu, MF_SEPARATOR, 0, 0);
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
@ -1672,6 +1679,8 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error)
|
|||||||
ShowWindow(fe->hwnd, SW_SHOWNORMAL);
|
ShowWindow(fe->hwnd, SW_SHOWNORMAL);
|
||||||
SetForegroundWindow(fe->hwnd);
|
SetForegroundWindow(fe->hwnd);
|
||||||
|
|
||||||
|
update_type_menu_tick(fe);
|
||||||
|
|
||||||
midend_redraw(fe->me);
|
midend_redraw(fe->me);
|
||||||
|
|
||||||
return fe;
|
return fe;
|
||||||
@ -2628,10 +2637,31 @@ static void adjust_game_size(frontend *fe, RECT *proposed, int isedge,
|
|||||||
*wx_r = wx; *wy_r = wy;
|
*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)
|
static void new_game_type(frontend *fe)
|
||||||
{
|
{
|
||||||
midend_new_game(fe->me);
|
midend_new_game(fe->me);
|
||||||
new_game_size(fe);
|
new_game_size(fe);
|
||||||
|
update_type_menu_tick(fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_alt_pressed(void)
|
static int is_alt_pressed(void)
|
||||||
|
Reference in New Issue
Block a user