summaryrefslogtreecommitdiff
path: root/widget.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-10-24 14:15:17 +0000
committerDarkvater <Darkvater@openttd.org>2006-10-24 14:15:17 +0000
commitc7c65ce6d56e527f153d3d471f2c4dd8ebf2dd00 (patch)
tree51fafb2220dd4dc447ee00655e96ff8b9666708b /widget.c
parent13df23c58656e84afc2e060647ac8b10788b53d8 (diff)
downloadopenttd-c7c65ce6d56e527f153d3d471f2c4dd8ebf2dd00.tar.xz
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
WWT_IMGBTN must contain an image for drawing. Renamed WWT_PANEL_2 to WWT_IMGBTN_2 because that is what it is. Added WWT_PUSHBTN that is either just a pushable button, or a textbutton, which text's drawn dynamically independent of widget.
Diffstat (limited to 'widget.c')
-rw-r--r--widget.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/widget.c b/widget.c
index cb7847c9b..1bf567308 100644
--- a/widget.c
+++ b/widget.c
@@ -203,18 +203,21 @@ void DrawWindowWidgets(const Window *w)
}
switch (wi->type & WWT_MASK) {
- case WWT_PANEL: /* WWT_IMGBTN */
- case WWT_PANEL_2: {
+ case WWT_IMGBTN:
+ case WWT_IMGBTN_2: {
int img = wi->data;
-
+ assert(img != 0);
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
- if (img != 0) { // has an image
- // show diff image when clicked
- if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++;
+ /* show different image when clicked for WWT_IMGBTN_2 */
+ if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++;
+ DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked);
+ goto draw_default;
+ }
- DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked);
- }
+ case WWT_PANEL: {
+ assert(wi->data == 0);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
goto draw_default;
}
@@ -471,7 +474,7 @@ draw_default:;
}
static const Widget _dropdown_menu_widgets[] = {
-{ WWT_IMGBTN, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
{ WIDGETS_END},
};