/* * InventoryProc: Subclassed window procedure for inventory area. */ long CALLBACK InventoryProc(HWND hwnd, UINT message, UINT wParam, LONG lParam) { RECT r; HDC hdc; switch (message) { case WM_KEYDOWN: if (HANDLE_WM_KEYDOWN_BLAK(hwnd, wParam, lParam, InventoryKey) == True) return 0; break; case WM_ERASEBKGND: // Draw outside of inventory items // XXX hdc = (HDC) wParam; r.left = cols * INVENTORY_BOX_WIDTH; r.right = inventory_area.cx; r.top = 0; r.bottom = inventory_area.cy; if (has_scrollbar) r.right -= inventory_scrollbar_width; DrawWindowBackgroundColor(&inventory_bkgnd, hdc, &r, r.left + inventory_area.x, r.top + inventory_area.y, -1); r.left = 0; r.right = inventory_area.cx; if (has_scrollbar) r.right -= inventory_scrollbar_width; r.top = rows * INVENTORY_BOX_HEIGHT; r.bottom = inventory_area.cy; DrawWindowBackgroundColor(&inventory_bkgnd, hdc, &r, r.left + inventory_area.x, r.top + inventory_area.y, -1); return 1; HANDLE_MSG(hwnd, WM_LBUTTONDOWN, InventoryLButtonDown); HANDLE_MSG(hwnd, WM_RBUTTONDOWN, InventoryRButton); HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK, InventoryLButtonDown); HANDLE_MSG(hwnd, WM_LBUTTONUP, InventoryLButtonUp); case WM_SETFOCUS: StatsDrawBorder(); break; case WM_KILLFOCUS: StatsDrawBorder(); InventoryReleaseCapture(); break; } return CallWindowProc(lpfnDefProc, hwnd, message, wParam, lParam); }
/* * StatsListDrawItem: Message handler for stats list boxes. Return TRUE iff * message is handled. */ BOOL StatsListDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpdis) { AREA stats_area; if (hList == NULL) return TRUE; switch (lpdis->itemAction) { case ODA_SELECT: case ODA_DRAWENTIRE: /* If box is empty, do nothing */ if (lpdis->itemID == -1) return TRUE; /* Draw window background at correct offset */ StatsGetArea(&stats_area); DrawWindowBackgroundColor(pinventory_bkgnd(), lpdis->hDC, (RECT *) (&lpdis->rcItem), // was NULL stats_area.x + lpdis->rcItem.left, stats_area.y + lpdis->rcItem.top + StatsGetButtonBorder(), -1); /* Draw info on stat */ StatsListDrawStat(lpdis, (Bool) (lpdis->itemState & ODS_SELECTED), (Bool)( StatsGetCurrentGroup() == STATS_SPELLS ) ); break; case ODA_FOCUS: // DrawFocusRect(lpdis->hDC, &lpdis->rcItem); break; } return TRUE; }
/* * DisplayNumericStat: Display the given numeric type stat from the current group on the * main window. */ void DisplayNumericStat(Statistic *s) { RECT r; HDC hdc; HFONT hOldFont; char *name, *str; AREA stats_area; AREA a; // ajw - Avoid drawing if Inventory is selected as the "group". if( StatsGetCurrentGroup() == STATS_INVENTORY ) return; StatsGetArea(&stats_area); r.left = 0; r.right = stats_area.cx / 2; r.top = s->y; r.bottom = r.top + s->cy; /* If stat is out of stats area, abort */ if (r.bottom > stats_area.cy || s->num <= top_stat) return; hdc = GetDC(hStats); // DrawWindowBackground(hdc, &r, stats_area.x + r.left, stats_area.y + r.top); DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); hOldFont = (HFONT) SelectObject(hdc, GetFont(FONT_STATS)); SetBkMode(hdc, TRANSPARENT); name = LookupNameRsc(s->name_res); // Draw with drop shadow SetTextColor(hdc, GetColor(COLOR_STATSBGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); OffsetRect(&r, 1, 1); SetTextColor(hdc, GetColor(COLOR_STATSFGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); switch (s->numeric.tag) { case STAT_RES: r.left = stats_area.cx / 2; r.right = stats_area.cx; DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); str = LookupNameRsc(s->numeric.value); DrawText(hdc, str, strlen(str), &r, DT_RIGHT); break; case STAT_INT: // Draw background around stat bar a.x = stats_area.cx / 2; a.cx = stats_bar_width; a.y = s->y + (s->cy - STATS_BAR_HEIGHT) / 2; a.cy = STATS_BAR_HEIGHT; InterfaceDrawBarBorder( pinventory_bkgnd(), hdc, &a ); break; } SelectObject(hdc, hOldFont); ReleaseDC(hStats, hdc); InvalidateRect( s->hControl, NULL, FALSE ); }
/* * InventoryRedraw: Redraw entire inventory. */ void InventoryRedraw(void) { InvItem *item; int i, offset, row, col; list_type l; HDC hdc; RECT r; offset = top_row * cols; l = items; for (i=0; i < offset; i++) if (l != NULL) l = l->next; for (i = 0; i + offset < num_items; i++) { if (l == NULL) break; item = (InvItem *) (l->data); row = i / cols; col = i % cols; if (row >= rows) break; InventoryDrawSingleItem(item, i / cols, i % cols); l = l->next; } // Clear remaining empty part of inventory hdc = GetDC(hwndInv); for ( ; i < rows * cols; i++) { r.left = (i % cols) * INVENTORY_BOX_WIDTH; r.top = (i / cols) * INVENTORY_BOX_HEIGHT; r.right = r.left + INVENTORY_BOX_WIDTH; r.bottom = r.top + INVENTORY_BOX_WIDTH; DrawWindowBackgroundColor(&inventory_bkgnd, hdc, &r, r.left + inventory_area.x, r.top + inventory_area.y, -1); } r.left = cols * INVENTORY_BOX_WIDTH; r.right = inventory_area.cx; r.top = 0; r.bottom = inventory_area.cy; if (has_scrollbar) r.right -= inventory_scrollbar_width; DrawWindowBackgroundColor(&inventory_bkgnd, hdc, &r, r.left + inventory_area.x, r.top + inventory_area.y, -1); r.left = 0; r.right = inventory_area.cx; if (has_scrollbar) r.right -= inventory_scrollbar_width; r.top = rows * INVENTORY_BOX_HEIGHT; r.bottom = inventory_area.cy; DrawWindowBackgroundColor(&inventory_bkgnd, hdc, &r, r.left + inventory_area.x, r.top + inventory_area.y, -1); // Redraw the scrollbar in the correct position. if (has_scrollbar) { InventoryScrollRange(); SetScrollPos(hwndInvScroll, SB_CTL, top_row, TRUE); ShowWindow(hwndInvDialog, SW_SHOWNORMAL); ShowWindow(hwndInvScroll, has_scrollbar ? SW_SHOWNORMAL : SW_HIDE); } ReleaseDC(hwndInv, hdc); }