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

Function onDrawItem

outdated/sys/wince/mhmenu.c:874–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872}
873
874LRESULT
875onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
876{
877 LPDRAWITEMSTRUCT lpdis;
878 PNHMenuItem item;
879 PNHMenuWindow data;
880 TEXTMETRIC tm;
881 HGDIOBJ saveFont;
882 HDC tileDC;
883 short ntile;
884 int t_x, t_y;
885 int x, y;
886 TCHAR wbuf[BUFSZ];
887 RECT drawRect;
888 COLORREF OldBg, OldFg, NewBg;
889 char *p, *p1;
890 int column;
891
892 lpdis = (LPDRAWITEMSTRUCT) lParam;
893
894 /* If there are no list box items, skip this message. */
895 if (lpdis->itemID == -1)
896 return FALSE;
897
898 data = (PNHMenuWindow) GetWindowLong(hWnd, GWL_USERDATA);
899
900 item = &data->menu.items[lpdis->itemID];
901
902 tileDC = CreateCompatibleDC(lpdis->hDC);
903 saveFont = SelectObject(
904 lpdis->hDC, mswin_get_font(NHW_MENU, item->attr, lpdis->hDC, FALSE));
905 NewBg = mswin_get_color(NHW_MENU, MSWIN_COLOR_BG);
906 OldBg = SetBkColor(lpdis->hDC, NewBg);
907 OldFg =
908 SetTextColor(lpdis->hDC, mswin_get_color(NHW_MENU, MSWIN_COLOR_FG));
909
910 GetTextMetrics(lpdis->hDC, &tm);
911
912 x = lpdis->rcItem.left + 1;
913
914 /* print check mark if it is a "selectable" menu */
915 if (data->how != PICK_NONE) {
916 if (NHMENU_IS_SELECTABLE(*item)) {
917 HGDIOBJ saveBrush;
918 HBRUSH hbrCheckMark;
919 char buf[2];
920
921 switch (item->count) {
922 case -1:
923 hbrCheckMark = CreatePatternBrush(data->bmpChecked);
924 break;
925 case 0:
926 hbrCheckMark = CreatePatternBrush(data->bmpNotChecked);
927 break;
928 default:
929 hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount);
930 break;
931 }

Callers 1

MenuWndProcFunction · 0.70

Calls 4

mswin_get_colorFunction · 0.85
mswin_get_fontFunction · 0.70
GetNHAppFunction · 0.70

Tested by

no test coverage detected