[Scummvm-cvs-logs] SF.net SVN: scummvm:[39689] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Mar 25 17:37:50 CET 2009
Revision: 39689
http://scummvm.svn.sourceforge.net/scummvm/?rev=39689&view=rev
Author: thebluegr
Date: 2009-03-25 16:37:50 +0000 (Wed, 25 Mar 2009)
Log Message:
-----------
Merged sciw_select_item() and sciw_unselect_item()
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kmenu.cpp
scummvm/trunk/engines/sci/gfx/gfx_gui.cpp
scummvm/trunk/engines/sci/gfx/gfx_gui.h
Modified: scummvm/trunk/engines/sci/engine/kmenu.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmenu.cpp 2009-03-25 12:58:22 UTC (rev 39688)
+++ scummvm/trunk/engines/sci/engine/kmenu.cpp 2009-03-25 16:37:50 UTC (rev 39689)
@@ -300,8 +300,8 @@
/* 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;
}
Modified: scummvm/trunk/engines/sci/gfx/gfx_gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_gui.cpp 2009-03-25 12:58:22 UTC (rev 39688)
+++ scummvm/trunk/engines/sci/gfx/gfx_gui.cpp 2009-03-25 16:37:50 UTC (rev 39689)
@@ -313,13 +313,13 @@
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 @@
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 @@
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];
+ gfx_color_t fgColor = !selected ? menu_port->color : menu_port->bgcolor;
+ gfx_color_t bgColor = !selected ? menu_port->bgcolor : menu_port->color;
- 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;
-
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;
}
Modified: scummvm/trunk/engines/sci/gfx/gfx_gui.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_gui.h 2009-03-25 12:58:22 UTC (rev 39688)
+++ scummvm/trunk/engines/sci/gfx/gfx_gui.h 2009-03-25 16:37:50 UTC (rev 39689)
@@ -172,25 +172,15 @@
** 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
+** (bool) selected: Whether to set the item's state to selected or not
** 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
-** Returns : (gfxw_port_t *) The modified menu
-*/
-
} // End of namespace Sci
#endif // SCI_INCLUDE_SCI_WIDGETS_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list