aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-25 16:37:50 +0000
committerFilippos Karapetis2009-03-25 16:37:50 +0000
commit4723f80fe26ba0d6f4b21a9583af35fbf24aff25 (patch)
treefc735ec22efa362b818cbd6ab48694eb3a2afc8c /engines/sci
parent0501542b79e630fa70f676319df91c74b30f8137 (diff)
downloadscummvm-rg350-4723f80fe26ba0d6f4b21a9583af35fbf24aff25.tar.gz
scummvm-rg350-4723f80fe26ba0d6f4b21a9583af35fbf24aff25.tar.bz2
scummvm-rg350-4723f80fe26ba0d6f4b21a9583af35fbf24aff25.zip
Merged sciw_select_item() and sciw_unselect_item()
svn-id: r39689
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kmenu.cpp4
-rw-r--r--engines/sci/gfx/gfx_gui.cpp31
-rw-r--r--engines/sci/gfx/gfx_gui.h18
3 files changed, 14 insertions, 39 deletions
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index e2f56f9434..7ea852fd69 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -300,8 +300,8 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
/* Remove the active menu item, if neccessary */
if (item_nr != old_item) {
- port = sciw_unselect_item(s, port, &(s->_menubar->_menus[menu_nr]), old_item);
- port = sciw_select_item(s, port, &(s->_menubar->_menus[menu_nr]), item_nr);
+ port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), old_item, false);
+ port = sciw_toggle_item(port, &(s->_menubar->_menus[menu_nr]), item_nr, true);
FULL_REDRAW;
}
diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp
index 5567602b68..7bdbb745fa 100644
--- a/engines/sci/gfx/gfx_gui.cpp
+++ b/engines/sci/gfx/gfx_gui.cpp
@@ -313,13 +313,13 @@ gfxw_list_t *sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, c
list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.width + 1, zone.height + 1),
port->color, port->color, GFX_BOX_SHADE_FLAT)));
- if (!inverse)
+ if (!inverse) {
list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height),
text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out);
- if (!inverse)
list->add(GFXWC(list),
GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL)));
+ }
if (inverse)
list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height),
@@ -582,7 +582,7 @@ gfxw_port_t *sciw_new_menu(EngineState *s, gfxw_port_t *status_bar, Menubar *men
retval->set_visual(GFXW(retval), s->visual);
for (i = 0; i < (int)menu->_items.size(); i++)
- sciw_unselect_item(s, retval, menu, i);
+ sciw_toggle_item(retval, menu, i, false);
return retval;
}
@@ -635,36 +635,21 @@ gfxw_widget_t *_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_col
return GFXW(list);
}
-gfxw_port_t *sciw_unselect_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection) {
+gfxw_port_t *sciw_toggle_item(gfxw_port_t *menu_port, Menu *menu, int selection, bool selected) {
if (selection < 0 || selection >= (int)menu->_items.size())
return menu_port;
- MenuItem *item = &menu->_items[selection];
-
- if (item->_type == MENU_TYPE_NORMAL)
- menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.width + 1,
- menu_port, menu_port->color, menu_port->bgcolor, selection + MAGIC_ID_OFFSET,
- item->_enabled)));
- else
- menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.width + 1,
- menu_port, menu_port->color, menu_port->bgcolor, selection + MAGIC_ID_OFFSET)));
-
- return menu_port;
-}
-
-gfxw_port_t *sciw_select_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection) {
- if (selection < 0 || selection >= (int)menu->_items.size())
- return menu_port;
+ gfx_color_t fgColor = !selected ? menu_port->color : menu_port->bgcolor;
+ gfx_color_t bgColor = !selected ? menu_port->bgcolor : menu_port->color;
MenuItem *item = &menu->_items[selection];
if (item->_type == MENU_TYPE_NORMAL)
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_entry(item, selection * 10, menu_port->zone.width + 1,
- menu_port, menu_port->bgcolor, menu_port->color, selection + MAGIC_ID_OFFSET,
- item->_enabled)));
+ menu_port, fgColor, bgColor, selection + MAGIC_ID_OFFSET, item->_enabled)));
else
menu_port->add(GFXWC(menu_port), GFXW(_make_menu_hbar(selection * 10, menu_port->zone.width + 1,
- menu_port, menu_port->bgcolor, menu_port->color, selection + MAGIC_ID_OFFSET)));
+ menu_port, fgColor, bgColor, selection + MAGIC_ID_OFFSET)));
return menu_port;
}
diff --git a/engines/sci/gfx/gfx_gui.h b/engines/sci/gfx/gfx_gui.h
index 7eff8b5bfb..29e0a8da11 100644
--- a/engines/sci/gfx/gfx_gui.h
+++ b/engines/sci/gfx/gfx_gui.h
@@ -172,22 +172,12 @@ gfxw_port_t *sciw_new_menu(EngineState *s, gfxw_port_t *status_bar, Menubar *men
** Returns : (gfxw_port_t *) The result port
*/
-gfxw_port_t *sciw_unselect_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection);
-/* Unselects a previously selected item from a menu port
-** Parameters: (EngineState *) s: The state to operate on
-** (gfxw_port_t *) menu_port: The port modify
+gfxw_port_t *sciw_toggle_item(gfxw_port_t *menu_port, Menu *menu, int selection, bool selected);
+/* Toggle the selection of a menu item from a menu port
+** Parameters: (gfxw_port_t *) menu_port: The port to modify
** (Menu *) menu: The menu the menu port corresponds to
** (int) selection: Number of the menu entry to unselect, or -1 to do a NOP
-** Returns : (gfxw_port_t *) The modified menu
-*/
-
-gfxw_port_t *
-sciw_select_item(EngineState *s, gfxw_port_t *menu_port, Menu *menu, int selection);
-/* Selects a menu item from a menu port
-** Parameters: (EngineState *) s: The state to operate on
-** (gfxw_port_t *) menu_port: The port modify
-** (Menu *) menu: The menu the menu port corresponds to
-** (int) selection: Number of the menu entry to select, or -1 to do a NOP
+** (bool) selected: Whether to set the item's state to selected or not
** Returns : (gfxw_port_t *) The modified menu
*/