win32gui (from <Someone>)
trunk and branch: Do not limit role selection list by race/gender/alignment. The default.nh selection will still be honored but the list itself will include every possible role. Some interface tweaks for main trunk: - improved calculation of the size of the menu window - made auto-arrange windows on/off option (it was reset automatically which was unintuitive and in some cases annoying, IMO)
This commit is contained in:
@@ -38,6 +38,8 @@ Platform- and/or Interface-Specific Fixes
|
|||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
win32tty: fix visible CRLF characters during lockfile error message
|
win32tty: fix visible CRLF characters during lockfile error message
|
||||||
win32gui: you couldn't specify an alignment in defaults.nh and have it stick
|
win32gui: you couldn't specify an alignment in defaults.nh and have it stick
|
||||||
|
win32gui: allow race/gender/alignment selections beyond those specified in
|
||||||
|
defaults.nh, while still honoring defaults.nh choices
|
||||||
unix: don't define errno if NHSTDC
|
unix: don't define errno if NHSTDC
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ win32gui: better handling of "more" prompt for messages that would have scrolled
|
|||||||
win32gui: set correct checkmark on "Lock Windows" menu item on startup
|
win32gui: set correct checkmark on "Lock Windows" menu item on startup
|
||||||
win32gui: redraw message window on resizing (it does not update properly otherwise)
|
win32gui: redraw message window on resizing (it does not update properly otherwise)
|
||||||
win32gui: fixed copy/paste error in read registry settings function
|
win32gui: fixed copy/paste error in read registry settings function
|
||||||
|
win32gui: improved calculation of the size of the menu window
|
||||||
|
win32gui: made auto-arrange windows on/off option (it was reset automatically
|
||||||
|
which was unintuitive and in some cases annoying
|
||||||
platforms that support hangup: SAFERHANGUP to avoid losing objects in transit
|
platforms that support hangup: SAFERHANGUP to avoid losing objects in transit
|
||||||
between lists when hangup occurs, and also avoid cheats due to
|
between lists when hangup occurs, and also avoid cheats due to
|
||||||
well-timed hangups to stop a long melee
|
well-timed hangups to stop a long melee
|
||||||
|
|||||||
+8
-10
@@ -559,17 +559,15 @@ void plselAdjustLists(HWND hWnd, int changed_sel)
|
|||||||
/* reset content and populate the list */
|
/* reset content and populate the list */
|
||||||
SendMessage(control_role, CB_RESETCONTENT, 0, 0);
|
SendMessage(control_role, CB_RESETCONTENT, 0, 0);
|
||||||
for (i = 0; roles[i].name.m; i++) {
|
for (i = 0; roles[i].name.m; i++) {
|
||||||
if (ok_role(i, initrace, initgend, initalign)) {
|
if (initgend>=0 && flags.female && roles[i].name.f)
|
||||||
if (initgend>=0 && flags.female && roles[i].name.f)
|
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.f, wbuf, sizeof(wbuf)) );
|
||||||
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.f, wbuf, sizeof(wbuf)) );
|
else
|
||||||
else
|
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.m, wbuf, sizeof(wbuf)) );
|
||||||
ind = SendMessage(control_role, CB_ADDSTRING, (WPARAM)0, (LPARAM)NH_A2W(roles[i].name.m, wbuf, sizeof(wbuf)) );
|
|
||||||
|
|
||||||
SendMessage(control_role, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
SendMessage(control_role, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i );
|
||||||
if( i==initrole ) {
|
if( i==initrole ) {
|
||||||
SendMessage(control_role, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
SendMessage(control_role, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 );
|
||||||
valid_opt = 1;
|
valid_opt = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-8
@@ -196,6 +196,12 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
|||||||
(GetNHApp()->bWindowsLocked? MF_CHECKED : MF_UNCHECKED)
|
(GetNHApp()->bWindowsLocked? MF_CHECKED : MF_UNCHECKED)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CheckMenuItem(
|
||||||
|
GetMenu(hWnd),
|
||||||
|
IDM_SETTING_AUTOLAYOUT,
|
||||||
|
GetNHApp()->bAutoLayout? MF_CHECKED : MF_UNCHECKED
|
||||||
|
);
|
||||||
|
|
||||||
/* store handle to the mane menu in the application record */
|
/* store handle to the mane menu in the application record */
|
||||||
GetNHApp()->hMainWnd = hWnd;
|
GetNHApp()->hMainWnd = hWnd;
|
||||||
break;
|
break;
|
||||||
@@ -530,7 +536,6 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
mswin_select_map_mode(iflags.wc_map_mode);
|
mswin_select_map_mode(iflags.wc_map_mode);
|
||||||
|
|
||||||
child = GetNHApp()->windowlist[msg_param->wid].win;
|
child = GetNHApp()->windowlist[msg_param->wid].win;
|
||||||
if( child ) mswin_layout_main_window(child);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -559,6 +564,7 @@ void mswin_layout_main_window(HWND changed_child)
|
|||||||
SIZE msg_size;
|
SIZE msg_size;
|
||||||
POINT map_org;
|
POINT map_org;
|
||||||
SIZE map_size;
|
SIZE map_size;
|
||||||
|
SIZE menu_size;
|
||||||
HWND wnd_status, wnd_msg;
|
HWND wnd_status, wnd_msg;
|
||||||
PNHMainWindow data;
|
PNHMainWindow data;
|
||||||
|
|
||||||
@@ -581,6 +587,19 @@ void mswin_layout_main_window(HWND changed_child)
|
|||||||
msg_size.cx = msg_size.cy = 0;
|
msg_size.cx = msg_size.cy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* find all menu windows and calculate the size */
|
||||||
|
menu_size.cx = menu_size.cy = 0;
|
||||||
|
for( i=0; i<MAXWINDOWS; i++ ) {
|
||||||
|
SIZE tmp_size;
|
||||||
|
if( GetNHApp()->windowlist[i].win
|
||||||
|
&& !GetNHApp()->windowlist[i].dead
|
||||||
|
&& GetNHApp()->windowlist[i].type == NHW_MENU ) {
|
||||||
|
mswin_menu_window_size(GetNHApp()->windowlist[i].win , &tmp_size);
|
||||||
|
menu_size.cx = max(menu_size.cx, tmp_size.cx);
|
||||||
|
menu_size.cy = max(menu_size.cy, tmp_size.cy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set window positions */
|
/* set window positions */
|
||||||
SetRect(&wnd_rect, client_rt.left, client_rt.top, client_rt.right, client_rt.bottom);
|
SetRect(&wnd_rect, client_rt.left, client_rt.top, client_rt.right, client_rt.bottom);
|
||||||
switch(iflags.wc_align_status) {
|
switch(iflags.wc_align_status) {
|
||||||
@@ -676,10 +695,11 @@ void mswin_layout_main_window(HWND changed_child)
|
|||||||
GetNHApp()->rtMsgWindow.right = msg_org.x + msg_size.cx;
|
GetNHApp()->rtMsgWindow.right = msg_org.x + msg_size.cx;
|
||||||
GetNHApp()->rtMsgWindow.bottom = msg_org.y + msg_size.cy;
|
GetNHApp()->rtMsgWindow.bottom = msg_org.y + msg_size.cy;
|
||||||
|
|
||||||
GetNHApp()->rtMenuWindow.left = map_org.x + map_size.cx*2/3;
|
/* map_width/4 < menu_width < map_width*2/3 */
|
||||||
GetNHApp()->rtMenuWindow.top = map_org.y;
|
GetNHApp()->rtMenuWindow.left = GetNHApp()->rtMapWindow.right - min(map_size.cx*2/3, max(map_size.cx/4, menu_size.cx));
|
||||||
GetNHApp()->rtMenuWindow.right = map_org.x + map_size.cx;
|
GetNHApp()->rtMenuWindow.top = GetNHApp()->rtMapWindow.top;
|
||||||
GetNHApp()->rtMenuWindow.bottom = map_org.y + map_size.cy;
|
GetNHApp()->rtMenuWindow.right = GetNHApp()->rtMapWindow.right;
|
||||||
|
GetNHApp()->rtMenuWindow.bottom = GetNHApp()->rtMapWindow.bottom;
|
||||||
|
|
||||||
GetNHApp()->rtInvenWindow.left = GetNHApp()->rtMenuWindow.left;
|
GetNHApp()->rtInvenWindow.left = GetNHApp()->rtMenuWindow.left;
|
||||||
GetNHApp()->rtInvenWindow.top = GetNHApp()->rtMenuWindow.top;
|
GetNHApp()->rtInvenWindow.top = GetNHApp()->rtMenuWindow.top;
|
||||||
@@ -711,6 +731,8 @@ void mswin_layout_main_window(HWND changed_child)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( IsWindow(changed_child) )
|
||||||
|
SetForegroundWindow(changed_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
@@ -784,9 +806,15 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case IDM_SETTING_AUTOLAYOUT:
|
case IDM_SETTING_AUTOLAYOUT:
|
||||||
GetNHApp()->bAutoLayout = TRUE;
|
GetNHApp()->bAutoLayout = !GetNHApp()->bAutoLayout;
|
||||||
mswin_layout_main_window(NULL);
|
mswin_layout_main_window(NULL);
|
||||||
GetNHApp()->bAutoLayout = FALSE;
|
|
||||||
|
/* Update menu item check-mark */
|
||||||
|
CheckMenuItem(
|
||||||
|
GetMenu(GetNHApp()->hMainWnd),
|
||||||
|
IDM_SETTING_AUTOLAYOUT,
|
||||||
|
GetNHApp()->bAutoLayout? MF_CHECKED : MF_UNCHECKED
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_SETTING_LOCKWINDOWS:
|
case IDM_SETTING_LOCKWINDOWS:
|
||||||
@@ -901,7 +929,6 @@ void mswin_menu_check_intf_mode()
|
|||||||
CheckMenuItem(hMenu, IDM_NHMODE, MF_CHECKED);
|
CheckMenuItem(hMenu, IDM_NHMODE, MF_CHECKED);
|
||||||
else
|
else
|
||||||
CheckMenuItem(hMenu, IDM_NHMODE, MF_UNCHECKED);
|
CheckMenuItem(hMenu, IDM_NHMODE, MF_UNCHECKED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mswin_select_map_mode(int mode)
|
void mswin_select_map_mode(int mode)
|
||||||
|
|||||||
+64
-67
@@ -47,10 +47,12 @@ typedef struct mswin_nethack_menu_window {
|
|||||||
BOOL counting; /* counting flag */
|
BOOL counting; /* counting flag */
|
||||||
char prompt[QBUFSZ]; /* menu prompt */
|
char prompt[QBUFSZ]; /* menu prompt */
|
||||||
int tab_stop_size[NUMTABS];/* tabstops to align option values */
|
int tab_stop_size[NUMTABS];/* tabstops to align option values */
|
||||||
|
int menu_cx; /* menu width */
|
||||||
} menu;
|
} menu;
|
||||||
|
|
||||||
struct menu_text {
|
struct menu_text {
|
||||||
TCHAR* text;
|
TCHAR* text;
|
||||||
|
SIZE text_box_size;
|
||||||
} text;
|
} text;
|
||||||
};
|
};
|
||||||
int result;
|
int result;
|
||||||
@@ -500,9 +502,12 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
case MSNH_MSG_PUTSTR:
|
case MSNH_MSG_PUTSTR:
|
||||||
{
|
{
|
||||||
PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
|
PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
|
||||||
HWND text_view;
|
HWND text_view;
|
||||||
TCHAR wbuf[BUFSZ];
|
TCHAR wbuf[BUFSZ];
|
||||||
size_t text_size;
|
size_t text_size;
|
||||||
|
RECT text_rt;
|
||||||
|
HGDIOBJ saveFont;
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
if( data->type!=MENU_TYPE_TEXT )
|
if( data->type!=MENU_TYPE_TEXT )
|
||||||
SetMenuType(hWnd, MENU_TYPE_TEXT);
|
SetMenuType(hWnd, MENU_TYPE_TEXT);
|
||||||
@@ -523,6 +528,16 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
text_view = GetDlgItem(hWnd, IDC_MENU_TEXT);
|
text_view = GetDlgItem(hWnd, IDC_MENU_TEXT);
|
||||||
if( !text_view ) panic("cannot get text view window");
|
if( !text_view ) panic("cannot get text view window");
|
||||||
SetWindowText(text_view, data->text.text);
|
SetWindowText(text_view, data->text.text);
|
||||||
|
|
||||||
|
/* calculate dimensions of the added line of text */
|
||||||
|
hdc = GetDC(text_view);
|
||||||
|
saveFont = SelectObject(hdc, mswin_get_font(NHW_MENU, ATR_NONE, hdc, FALSE));
|
||||||
|
SetRect(&text_rt, 0, 0, 0, 0);
|
||||||
|
DrawText(hdc, msg_data->text, strlen(msg_data->text), &text_rt, DT_CALCRECT | DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE);
|
||||||
|
data->text.text_box_size.cx = max(text_rt.right - text_rt.left, data->text.text_box_size.cx);
|
||||||
|
data->text.text_box_size.cy += text_rt.bottom - text_rt.top;
|
||||||
|
SelectObject(hdc, saveFont);
|
||||||
|
ReleaseDC(text_view, hdc);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MSNH_MSG_STARTMENU:
|
case MSNH_MSG_STARTMENU:
|
||||||
@@ -550,6 +565,8 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
HDC hDC;
|
HDC hDC;
|
||||||
int column;
|
int column;
|
||||||
HFONT saveFont;
|
HFONT saveFont;
|
||||||
|
LONG menuitemwidth = 0;
|
||||||
|
TEXTMETRIC tm;
|
||||||
|
|
||||||
if( data->type!=MENU_TYPE_MENU ) break;
|
if( data->type!=MENU_TYPE_MENU ) break;
|
||||||
if( strlen(msg_data->str)==0 ) break;
|
if( strlen(msg_data->str)==0 ) break;
|
||||||
@@ -572,6 +589,7 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
/* calculate tabstop size */
|
/* calculate tabstop size */
|
||||||
hDC = GetDC(hWnd);
|
hDC = GetDC(hWnd);
|
||||||
saveFont = SelectObject(hDC, mswin_get_font(NHW_MENU, msg_data->attr, hDC, FALSE));
|
saveFont = SelectObject(hDC, mswin_get_font(NHW_MENU, msg_data->attr, hDC, FALSE));
|
||||||
|
GetTextMetrics(hDC, &tm);
|
||||||
p1 = data->menu.items[new_item].str;
|
p1 = data->menu.items[new_item].str;
|
||||||
p = strchr(data->menu.items[new_item].str, '\t');
|
p = strchr(data->menu.items[new_item].str, '\t');
|
||||||
column = 0;
|
column = 0;
|
||||||
@@ -588,9 +606,16 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
);
|
);
|
||||||
data->menu.tab_stop_size[column] =
|
data->menu.tab_stop_size[column] =
|
||||||
max( data->menu.tab_stop_size[column], drawRect.right - drawRect.left );
|
max( data->menu.tab_stop_size[column], drawRect.right - drawRect.left );
|
||||||
|
|
||||||
|
menuitemwidth += data->menu.tab_stop_size[column];
|
||||||
|
|
||||||
if (p != NULL) *p = '\t';
|
if (p != NULL) *p = '\t';
|
||||||
else /* last string so, */ break;
|
else /* last string so, */ break;
|
||||||
|
|
||||||
|
/* add the separation only when not the last item */
|
||||||
|
/* in the last item, we break out of the loop, in the statement just above */
|
||||||
|
menuitemwidth += TAB_SEPARATION;
|
||||||
|
|
||||||
++column;
|
++column;
|
||||||
p1 = p + 1;
|
p1 = p + 1;
|
||||||
p = strchr(p1, '\t');
|
p = strchr(p1, '\t');
|
||||||
@@ -598,6 +623,12 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
SelectObject(hDC, saveFont);
|
SelectObject(hDC, saveFont);
|
||||||
ReleaseDC(hWnd, hDC);
|
ReleaseDC(hWnd, hDC);
|
||||||
|
|
||||||
|
/* calculate new menu width */
|
||||||
|
data->menu.menu_cx = max(
|
||||||
|
data->menu.menu_cx,
|
||||||
|
2*TILE_X + menuitemwidth + (tm.tmAveCharWidth+tm.tmOverhang)*12
|
||||||
|
);
|
||||||
|
|
||||||
/* increment size */
|
/* increment size */
|
||||||
data->menu.size++;
|
data->menu.size++;
|
||||||
} break;
|
} break;
|
||||||
@@ -631,7 +662,6 @@ void LayoutMenu(HWND hWnd)
|
|||||||
/* get window coordinates */
|
/* get window coordinates */
|
||||||
GetClientRect(hWnd, &clrt );
|
GetClientRect(hWnd, &clrt );
|
||||||
|
|
||||||
|
|
||||||
// OK button
|
// OK button
|
||||||
if( data->is_active ) {
|
if( data->is_active ) {
|
||||||
GetWindowRect(menu_ok, &rt);
|
GetWindowRect(menu_ok, &rt);
|
||||||
@@ -678,6 +708,15 @@ void LayoutMenu(HWND hWnd)
|
|||||||
} else {
|
} else {
|
||||||
sz_elem.cy = (clrt.bottom - clrt.top) - 2*MENU_MARGIN;
|
sz_elem.cy = (clrt.bottom - clrt.top) - 2*MENU_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( data->type == MENU_TYPE_MENU ) {
|
||||||
|
ListView_SetColumnWidth(
|
||||||
|
GetMenuControl(hWnd),
|
||||||
|
0,
|
||||||
|
max(clrt.right - clrt.left - GetSystemMetrics(SM_CXVSCROLL), data->menu.menu_cx )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
MoveWindow(GetMenuControl(hWnd), pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
MoveWindow(GetMenuControl(hWnd), pt_elem.x, pt_elem.y, sz_elem.cx, sz_elem.cy, TRUE );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
@@ -1002,7 +1041,11 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
RECT client_rt;
|
RECT client_rt;
|
||||||
|
|
||||||
GetClientRect(lpdis->hwndItem, &client_rt);
|
GetClientRect(lpdis->hwndItem, &client_rt);
|
||||||
SetRect( &drawRect, client_rt.left, lpdis->rcItem.top, client_rt.right, lpdis->rcItem.bottom );
|
SetRect( &drawRect,
|
||||||
|
client_rt.left,
|
||||||
|
lpdis->rcItem.top,
|
||||||
|
client_rt.left + ListView_GetColumnWidth(lpdis->hwndItem, 0),
|
||||||
|
lpdis->rcItem.bottom );
|
||||||
DrawFocusRect(lpdis->hDC, &drawRect);
|
DrawFocusRect(lpdis->hDC, &drawRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1332,82 +1375,36 @@ BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch)
|
|||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
void mswin_menu_window_size (HWND hWnd, LPSIZE sz)
|
void mswin_menu_window_size (HWND hWnd, LPSIZE sz)
|
||||||
{
|
{
|
||||||
TEXTMETRIC tm;
|
|
||||||
HWND control;
|
HWND control;
|
||||||
HGDIOBJ saveFont;
|
|
||||||
HDC hdc;
|
|
||||||
PNHMenuWindow data;
|
PNHMenuWindow data;
|
||||||
int i;
|
|
||||||
RECT rt, wrt;
|
RECT rt, wrt;
|
||||||
int extra_cx;
|
int extra_cx;
|
||||||
|
|
||||||
GetClientRect(hWnd, &rt);
|
|
||||||
sz->cx = rt.right - rt.left;
|
|
||||||
sz->cy = rt.bottom - rt.top;
|
|
||||||
|
|
||||||
GetWindowRect(hWnd, &wrt);
|
|
||||||
extra_cx = (wrt.right-wrt.left) - sz->cx;
|
|
||||||
|
|
||||||
data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
|
||||||
if(data) {
|
if(data) {
|
||||||
control = GetMenuControl(hWnd);
|
control = GetMenuControl(hWnd);
|
||||||
hdc = GetDC(control);
|
|
||||||
|
/* get the control size */
|
||||||
|
GetClientRect(control, &rt);
|
||||||
|
sz->cx = rt.right - rt.left;
|
||||||
|
sz->cy = rt.bottom - rt.top;
|
||||||
|
|
||||||
|
/* calculate "extra" space around the control */
|
||||||
|
GetWindowRect(hWnd, &wrt);
|
||||||
|
extra_cx = (wrt.right-wrt.left) - sz->cx;
|
||||||
|
|
||||||
if( data->type==MENU_TYPE_MENU ) {
|
if( data->type==MENU_TYPE_MENU ) {
|
||||||
/* Calculate the width of the list box. */
|
sz->cx = max(sz->cx, data->menu.menu_cx + GetSystemMetrics(SM_CXVSCROLL) );
|
||||||
saveFont = SelectObject(hdc, mswin_get_font(NHW_MENU, ATR_NONE, hdc, FALSE));
|
|
||||||
GetTextMetrics(hdc, &tm);
|
|
||||||
for(i=0; i<data->menu.size; i++ ) {
|
|
||||||
LONG menuitemwidth = 0;
|
|
||||||
int column;
|
|
||||||
char *p, *p1;
|
|
||||||
|
|
||||||
p1 = data->menu.items[i].str;
|
|
||||||
p = strchr(data->menu.items[i].str, '\t');
|
|
||||||
column = 0;
|
|
||||||
for (;;) {
|
|
||||||
TCHAR wbuf[BUFSZ];
|
|
||||||
RECT tabRect;
|
|
||||||
SetRect ( &tabRect, 0, 0, 1, 1 );
|
|
||||||
if (p != NULL) *p = '\0'; /* for time being, view tab field as zstring */
|
|
||||||
DrawText(hdc,
|
|
||||||
NH_A2W(p1, wbuf, BUFSZ),
|
|
||||||
strlen(p1),
|
|
||||||
&tabRect,
|
|
||||||
DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE
|
|
||||||
);
|
|
||||||
/* it probably isn't necessary to recompute the tab width now, but do so
|
|
||||||
* just in case, honoring the previously computed value
|
|
||||||
*/
|
|
||||||
menuitemwidth += max(data->menu.tab_stop_size[column],
|
|
||||||
tabRect.right - tabRect.left);
|
|
||||||
if (p != NULL) *p = '\t';
|
|
||||||
else /* last string so, */ break;
|
|
||||||
/* add the separation only when not the last item */
|
|
||||||
/* in the last item, we break out of the loop, in the statement just above */
|
|
||||||
menuitemwidth += TAB_SEPARATION;
|
|
||||||
++column;
|
|
||||||
p1 = p + 1;
|
|
||||||
p = strchr(p1, '\t');
|
|
||||||
}
|
|
||||||
|
|
||||||
sz->cx = max(sz->cx,
|
|
||||||
(LONG)(2*TILE_X + menuitemwidth + tm.tmAveCharWidth*12 + tm.tmOverhang));
|
|
||||||
}
|
|
||||||
SelectObject(hdc, saveFont);
|
|
||||||
} else {
|
} else {
|
||||||
/* Calculate the width of the text box. */
|
/* Use the width of the text box */
|
||||||
RECT text_rt;
|
sz->cx = max( sz->cx, data->text.text_box_size.cx + 2*GetSystemMetrics(SM_CXVSCROLL));
|
||||||
saveFont = SelectObject(hdc, mswin_get_font(NHW_MENU, ATR_NONE, hdc, FALSE));
|
|
||||||
GetTextMetrics(hdc, &tm);
|
|
||||||
SetRect(&text_rt, 0, 0, sz->cx, sz->cy);
|
|
||||||
DrawText(hdc, data->text.text, _tcslen(data->text.text), &text_rt, DT_CALCRECT | DT_TOP | DT_LEFT | DT_NOPREFIX);
|
|
||||||
sz->cx = max(sz->cx, text_rt.right - text_rt.left + 5*tm.tmAveCharWidth + tm.tmOverhang);
|
|
||||||
SelectObject(hdc, saveFont);
|
|
||||||
}
|
}
|
||||||
sz->cx += extra_cx;
|
sz->cx += extra_cx;
|
||||||
|
} else {
|
||||||
ReleaseDC(control, hdc);
|
/* uninitilized window */
|
||||||
|
GetClientRect(hWnd, &rt);
|
||||||
|
sz->cx = rt.right - rt.left;
|
||||||
|
sz->cy = rt.bottom - rt.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|||||||
+1
-5
@@ -817,6 +817,7 @@ void mswin_display_nhwindow(winid wid, BOOLEAN_P block)
|
|||||||
if (GetNHApp()->windowlist[wid].win != NULL)
|
if (GetNHApp()->windowlist[wid].win != NULL)
|
||||||
{
|
{
|
||||||
ShowWindow(GetNHApp()->windowlist[wid].win, SW_SHOW);
|
ShowWindow(GetNHApp()->windowlist[wid].win, SW_SHOW);
|
||||||
|
mswin_layout_main_window(GetNHApp()->windowlist[wid].win);
|
||||||
if (GetNHApp()->windowlist[wid].type == NHW_MENU) {
|
if (GetNHApp()->windowlist[wid].type == NHW_MENU) {
|
||||||
MENU_ITEM_P* p;
|
MENU_ITEM_P* p;
|
||||||
mswin_menu_window_select_menu(GetNHApp()->windowlist[wid].win, PICK_NONE, &p, TRUE);
|
mswin_menu_window_select_menu(GetNHApp()->windowlist[wid].win, PICK_NONE, &p, TRUE);
|
||||||
@@ -2521,11 +2522,6 @@ void mswin_update_window_placement(int type, LPRECT rt)
|
|||||||
!EqualRect(rt_conf, rt) )
|
!EqualRect(rt_conf, rt) )
|
||||||
{
|
{
|
||||||
*rt_conf = *rt;
|
*rt_conf = *rt;
|
||||||
|
|
||||||
/* if window changed size while the game is in progess -
|
|
||||||
it was most likely resized by the user */
|
|
||||||
if( program_state.something_worth_saving )
|
|
||||||
GetNHApp()->bAutoLayout = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user