MCPcopy Create free account
hub / github.com/NetHack/NetHack / onMeasureItem

Function onMeasureItem

win/win32/mhmenu.c:965–1011  ·  view source on GitHub ↗

-----------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

963}
964/*-----------------------------------------------------------------------------*/
965BOOL
966onMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
967{
968 LPMEASUREITEMSTRUCT lpmis;
969 TEXTMETRIC tm;
970 HGDIOBJ saveFont;
971 HDC hdc;
972 PNHMenuWindow data;
973 RECT list_rect;
974 int i;
975
976 UNREFERENCED_PARAMETER(wParam);
977
978 lpmis = (LPMEASUREITEMSTRUCT) lParam;
979 data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
980 GetClientRect(GetMenuControl(hWnd), &list_rect);
981
982 hdc = GetDC(GetMenuControl(hWnd));
983 cached_font * font = mswin_get_font(NHW_MENU, ATR_INVERSE, hdc, FALSE);
984 saveFont = SelectObject(hdc, font->hFont);
985 GetTextMetrics(hdc, &tm);
986
987 /* Set the height of the list box items to max height of the individual
988 * items */
989 for (i = 0; i < data->menui.menu.size; i++) {
990/* int map_y = GetNHApp()->mapTile_Y; */
991 int map_y = 16; /* leave it at the default size, unless
992 * we are actually showing the larger
993 * icons in the menu */
994 if (NHMENU_HAS_GLYPH(data->menui.menu.items[i])
995 && !IS_MAP_ASCII(iflags.wc_map_mode)) {
996 lpmis->itemHeight =
997 max(lpmis->itemHeight,
998 (UINT) max(tm.tmHeight, map_y) + 2);
999 } else {
1000 lpmis->itemHeight =
1001 max(lpmis->itemHeight, (UINT) max(tm.tmHeight, map_y) + 2);
1002 }
1003 }
1004
1005 /* set width to the window width */
1006 lpmis->itemWidth = list_rect.right - list_rect.left;
1007
1008 SelectObject(hdc, saveFont);
1009 ReleaseDC(GetMenuControl(hWnd), hdc);
1010 return TRUE;
1011}
1012/*-----------------------------------------------------------------------------*/
1013BOOL
1014onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)

Callers 1

MenuWndProcFunction · 0.70

Calls 2

GetMenuControlFunction · 0.70
mswin_get_fontFunction · 0.70

Tested by

no test coverage detected