/* * InterfaceDrawElements: Draw spiffy interface elements. */ void InterfaceDrawElements(HDC hdc) { int i, x, y; InterfaceElement *e; Bool vertical; for (i=0; i < NUM_AUTO_ELEMENTS; i++) { // Temp. disable xxx /* if( i >= ELEMENT_ULTOP && i <= ELEMENT_LRRIGHT ) continue; if( i >= ELEMENT_IULTOP && i <= ELEMENT_ILRRIGHT ) continue; if( i == ELEMENT_BLLBOTTOM || i == ELEMENT_BLRBOTTOM ) continue;*/ OffscreenWindowBackground(NULL, elements[i].x, elements[i].y, elements[i].width, elements[i].height); OffscreenBitBlt(hdc, elements[i].x, elements[i].y, elements[i].width, elements[i].height, elements[i].bits, 0, 0, DIBWIDTH(elements[i].width), OBB_COPY | OBB_FLIP | OBB_TRANSPARENT); GdiFlush(); } for (i=0; i < NUM_AUTO_REPEATERS; i++) { // Temp. disable xxx if( i >= ELEMENT_ITOP && i <= ELEMENT_IRIGHT ) continue; // disable xxx if( i >= ELEMENT_TOP && i <= ELEMENT_RIGHT ) continue; if( i == ELEMENT_BBOTTOM ) continue; e = &repeaters[i].element; x = e->x; y = e->y; vertical = repeaters[i].vertical; while (1) { if ((vertical && y > repeaters[i].end) || (!vertical && x > repeaters[i].end)) break; OffscreenWindowBackground(NULL, x, y, e->width, e->height); OffscreenBitBlt(hdc, x, y, e->width, e->height, e->bits, 0, 0, DIBWIDTH(e->width), OBB_COPY | OBB_FLIP | OBB_TRANSPARENT); if (vertical) y += e->height; else x += e->width; GdiFlush(); } } }
/* * ToolbarDrawButton: Handle WM_DRAWITEM messages for toolbar buttons. * Return True iff message handled. */ Bool ToolbarDrawButton(HWND hwnd, const DRAWITEMSTRUCT *lpdis) { Button *b; int x; switch (lpdis->itemAction) { case ODA_SELECT: case ODA_DRAWENTIRE: // Draw bitmap, if button has one b = ToolbarFindButtonByHandle(lpdis->hwndItem); if (b == NULL || b->bits == NULL) { FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH) GetStockObject(LTGRAY_BRUSH)); } else { // Pick image to draw, depending on whether button is pressed if (lpdis->itemState & ODS_SELECTED || b->pressed) x = TOOLBAR_BUTTON_WIDTH; else x = 0; SelectPalette(lpdis->hDC, hPal, FALSE); OffscreenWindowBackground(NULL, b->x, TOOLBAR_Y, TOOLBAR_BUTTON_WIDTH, TOOLBAR_BUTTON_HEIGHT); OffscreenBitBlt(lpdis->hDC, 0, 0, TOOLBAR_BUTTON_WIDTH, TOOLBAR_BUTTON_HEIGHT, b->bits, x, 0, 2 * TOOLBAR_BUTTON_WIDTH, OBB_FLIP | OBB_COPY | OBB_TRANSPARENT); } return True; } return False; }
/* * InterfaceDrawBarBorder: Draw border around a graph bar; the bar occupies * the area "a" on hdc. */ void InterfaceDrawBarBorder( RawBitmap* prawbmpBackground, HDC hdc, AREA *a ) { int i, x, y; InterfaceElement *e; Bool vertical; elements[ELEMENT_BARRIGHT].x = a->cx; for (i = ELEMENT_BARLEFT; i <= ELEMENT_BARRIGHT; i++) { OffscreenWindowBackground(prawbmpBackground, a->x + elements[i].x, a->y + elements[i].y, elements[i].width, elements[i].height); OffscreenBitBlt(hdc, a->x + elements[i].x, a->y + elements[i].y, elements[i].width, elements[i].height, elements[i].bits, 0, 0, DIBWIDTH(elements[i].width), OBB_COPY | OBB_FLIP | OBB_TRANSPARENT); GdiFlush(); } repeaters[ELEMENT_BARBOTTOM].element.y = a->cy; for (i = ELEMENT_BARTOP; i <= ELEMENT_BARBOTTOM; i++) { e = &repeaters[i].element; x = e->x + a->x; y = e->y + a->y; vertical = repeaters[i].vertical; while (1) { if ((vertical && y >= a->y + a->cy) || (!vertical && x >= a->x + a->cx)) break; OffscreenWindowBackground(prawbmpBackground, x, y, e->width, e->height); OffscreenBitBlt(hdc, x, y, e->width, e->height, e->bits, 0, 0, DIBWIDTH(e->width), OBB_COPY | OBB_FLIP | OBB_TRANSPARENT); if (vertical) y += e->height; else x += e->width; GdiFlush(); } } }
/* * StatsMainRedraw: Called when the main window needs to be redrawn. */ void StatsMainRedraw(void) { list_type l; HDC hdc; AREA a, b; object_node *obj; // Fake object node for DrawObject hdc = GetDC(cinfo->hMain); obj = ObjectGetBlank(); a.x = stat_x; a.cx = STAT_ICON_HEIGHT; for (l = main_stats; l != NULL; l = l->next) { Statistic *s = (Statistic *) (l->data); a.y = s->y; a.cy = s->cy; obj->icon_res = s->name_res; OffscreenWindowBackground(NULL, a.x, a.y, a.cx, a.cy); DrawStretchedObjectDefault(hdc, obj, &a, NULL); GdiFlush(); b.x = stat_bar_x; b.cx = stat_width; b.y = a.y + STATS_MAIN_SPACING; b.cy = s->cy - 4 * STATS_MAIN_SPACING; InterfaceDrawBarBorder(NULL, hdc, &b); } ObjectDestroyAndFree(obj); ReleaseDC(cinfo->hMain, hdc); }
/* * InventoryDrawSingleItem: Draw given inventory item, at given row and col * in relative coordinates. */ void InventoryDrawSingleItem(InvItem *item, int row, int col) { HDC hdc; AREA area, obj_area; char temp[MAXAMOUNT + 1]; Bool draw_cursor; area.x = col * INVENTORY_BOX_WIDTH; area.y = row * INVENTORY_BOX_HEIGHT; area.cx = INVENTORY_BOX_WIDTH; area.cy = INVENTORY_BOX_HEIGHT; obj_area.x = area.x + INVENTORY_OBJECT_BORDER; obj_area.y = area.y + INVENTORY_OBJECT_BORDER; obj_area.cx = INVENTORY_OBJECT_WIDTH - 1; obj_area.cy = INVENTORY_OBJECT_HEIGHT - 1; hdc = GetDC(hwndInv); // See if we should draw cursor here draw_cursor = (GetFocus() == hwndInv && row == cursor_row - top_row && col == cursor_col); if (draw_cursor) OffscreenBitBlt(hdc, 0, 0, INVENTORY_BOX_WIDTH, INVENTORY_BOX_HEIGHT, cursor_bits, 0, 0, INVENTORY_BOX_WIDTH, OBB_FLIP); else OffscreenWindowBackground(&inventory_bkgnd, inventory_area.x + area.x, inventory_area.y + area.y, INVENTORY_BOX_WIDTH, INVENTORY_BOX_HEIGHT); if (item->is_using) OffscreenBitBlt(hdc, INVENTORY_OBJECT_BORDER, INVENTORY_OBJECT_BORDER, INVENTORY_OBJECT_WIDTH, INVENTORY_OBJECT_HEIGHT, inuse_bits, 0, 0, INVENTORY_OBJECT_WIDTH, OBB_FLIP | OBB_TRANSPARENT); DrawObject(hdc, item->obj, item->obj->animate->group, True, &obj_area, NULL, INVENTORY_OBJECT_BORDER, INVENTORY_OBJECT_BORDER, 0, False); OffscreenCopy(hdc, area.x, area.y, INVENTORY_BOX_WIDTH, INVENTORY_BOX_HEIGHT, 0, 0); // Draw numbers for number items if (IsNumberObj(item->obj->id) && cinfo->config->inventory_num) { sprintf(temp, "%d", item->obj->amount); SetBkMode(hdc, TRANSPARENT); SelectObject(hdc, GetFont(FONT_STATNUM)); SetTextColor(hdc, GetColor(COLOR_INVNUMBGD)); TextOut(hdc, obj_area.x + 1, obj_area.y + 1, temp, strlen(temp)); SetTextColor(hdc, GetColor(COLOR_INVNUMFGD)); TextOut(hdc, obj_area.x, obj_area.y, temp, strlen(temp)); } // Draw border around area to clear previous cursor (if any) if (!draw_cursor) { DrawWindowBackgroundBorder(&inventory_bkgnd, hdc, &obj_area, INVENTORY_OBJECT_BORDER, inventory_area.x + obj_area.x, inventory_area.y + obj_area.y, -1, NULL); } ReleaseDC(hwndInv, hdc); }