void DrawLabelAsWindow(WIDGET_LABEL *label) { COLOR oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; int i, win_w, win_h; /* Compute the dimensions of the label */ win_h = label->height ((WIDGET *)label) + 16; win_w = 0; for (i = 0; i < label->line_count; i++) { int len = utf8StringCount (label->lines[i]); if (len > win_w) { win_w = len; } } win_w = (win_w * 6) + 16; BatchGraphics (); r.corner.x = (SCREEN_WIDTH - win_w) >> 1; r.corner.y = (SCREEN_HEIGHT - win_h) >> 1; r.extent.width = win_w; r.extent.height = win_h; DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + 16; for (i = 0; i < label->line_count; i++) { t.pStr = label->lines[i]; t.align = ALIGN_CENTER; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += 8; } UnbatchGraphics (); SetContextFontEffect (oldFontEffect); SetContextFont (oldfont); SetContextForeGroundColor (oldfg); }
static void DrawConfirmationWindow (BOOLEAN answer) { Color oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; BatchGraphics (); r.corner.x = (SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1; r.corner.y = (SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1; r.extent.width = CONFIRM_WIN_WIDTH; r.extent.height = CONFIRM_WIN_HEIGHT; DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + (8 << RESOLUTION_FACTOR); // JMS_GFX t.pStr = GAME_STRING (QUITMENU_STRING_BASE); // "Really Quit?" t.align = ALIGN_CENTER; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += (10 << RESOLUTION_FACTOR); // JMS_GFX t.baseline.x = r.corner.x + (r.extent.width >> 2); t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 1); // "Yes" SetContextForeGroundColor (answer ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR); font_DrawText (&t); t.baseline.x += (r.extent.width >> 1); t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 2); // "No" SetContextForeGroundColor (answer ? MENU_TEXT_COLOR : MENU_HIGHLIGHT_COLOR); font_DrawText (&t); UnbatchGraphics (); SetContextFontEffect (oldFontEffect); SetContextFont (oldfont); SetContextForeGroundColor (oldfg); }
// windowRect, if not NULL, will be filled with the dimensions of the // window drawn. void DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect) { Color oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; int i, win_w, win_h; if (cur_font) oldfont = SetContextFont (cur_font); /* Compute the dimensions of the label */ win_h = label->height ((WIDGET *)label) + (16 << RESOLUTION_FACTOR); // JMS_GFX win_w = 0; for (i = 0; i < label->line_count; i++) { int len = utf8StringCount (label->lines[i]); if (len > win_w) { win_w = len; } } win_w = (win_w * (6 << RESOLUTION_FACTOR)) + (16 << RESOLUTION_FACTOR); // JMS_GFX BatchGraphics (); r.corner.x = (ScreenWidth - win_w) >> 1; r.corner.y = (ScreenHeight - win_h) >> 1; r.extent.width = win_w; r.extent.height = win_h; DrawShadowedBox (&r, win_bg_clr, win_dark_clr, win_medium_clr); t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + (16 << RESOLUTION_FACTOR); // JMS_GFX for (i = 0; i < label->line_count; i++) { t.pStr = label->lines[i]; t.align = ALIGN_CENTER; t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += (8 << RESOLUTION_FACTOR); // JMS_GFX } UnbatchGraphics (); SetContextFontEffect (oldFontEffect); if (oldfont) SetContextFont (oldfont); SetContextForeGroundColor (oldfg); if (windowRect != NULL) { // Add the outer border added by DrawShadowedBox. // XXX: It may be nicer to add a border size parameter to // DrawShadowedBox, instead of assuming 2 here. windowRect->corner.x = r.corner.x - 2 * (1 + RESOLUTION_FACTOR); windowRect->corner.y = r.corner.y - 2 * (1 + RESOLUTION_FACTOR); windowRect->extent.width = r.extent.width + 4 * (1 + RESOLUTION_FACTOR); windowRect->extent.height = r.extent.height + 4 * (1 + RESOLUTION_FACTOR); } }