[Scummvm-cvs-logs] SF.net SVN: scummvm: [29403] scummvm/trunk/gui

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Nov 4 04:38:31 CET 2007


Revision: 29403
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29403&view=rev
Author:   lordhoto
Date:     2007-11-03 20:38:30 -0700 (Sat, 03 Nov 2007)

Log Message:
-----------

- made Widget::_flags private
- reworked state (enabled/disabled/highlighted) handling of widgets
- cleanup in ModernTheme.cpp

Modified Paths:
--------------
    scummvm/trunk/gui/EditTextWidget.cpp
    scummvm/trunk/gui/EditTextWidget.h
    scummvm/trunk/gui/ListWidget.cpp
    scummvm/trunk/gui/ListWidget.h
    scummvm/trunk/gui/PopUpWidget.cpp
    scummvm/trunk/gui/PopUpWidget.h
    scummvm/trunk/gui/ScrollBarWidget.cpp
    scummvm/trunk/gui/ScrollBarWidget.h
    scummvm/trunk/gui/TabWidget.cpp
    scummvm/trunk/gui/TabWidget.h
    scummvm/trunk/gui/ThemeClassic.cpp
    scummvm/trunk/gui/ThemeClassic.h
    scummvm/trunk/gui/ThemeModern.cpp
    scummvm/trunk/gui/ThemeModern.h
    scummvm/trunk/gui/about.cpp
    scummvm/trunk/gui/dialog.cpp
    scummvm/trunk/gui/theme.cpp
    scummvm/trunk/gui/theme.h
    scummvm/trunk/gui/widget.cpp
    scummvm/trunk/gui/widget.h

Modified: scummvm/trunk/gui/EditTextWidget.cpp
===================================================================
--- scummvm/trunk/gui/EditTextWidget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/EditTextWidget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -31,7 +31,7 @@
 
 EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
 	: EditableWidget(boss, x, y - 1, w, h + 2) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
 	_type = kEditTextWidget;
 
 	setEditString(text);
@@ -39,7 +39,7 @@
 
 EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text)
 	: EditableWidget(boss, name) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
 	_type = kEditTextWidget;
 	_hints |= THEME_HINT_USE_SHADOW;
 
@@ -81,12 +81,12 @@
 }
 
 
-void EditTextWidget::drawWidget(bool hilite) {
+void EditTextWidget::drawWidget() {
 	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _hints, Theme::kWidgetBackgroundEditText);
 
 	// Draw the text
 	adjustOffset();
-	g_gui.theme()->drawText(Common::Rect(_x+2+ _leftPadding,_y+2, _x+_leftPadding+getEditRect().width()+2, _y+_h-2), _editString, Theme::kStateEnabled, Theme::kTextAlignLeft, false, -_editScrollOffset, false, _font);
+	g_gui.theme()->drawText(Common::Rect(_x+2+ _leftPadding,_y+2, _x+_leftPadding+getEditRect().width()+2, _y+_h-2), _editString, _state, Theme::kTextAlignLeft, false, -_editScrollOffset, false, _font);
 }
 
 Common::Rect EditTextWidget::getEditRect() const {

Modified: scummvm/trunk/gui/EditTextWidget.h
===================================================================
--- scummvm/trunk/gui/EditTextWidget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/EditTextWidget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -53,7 +53,7 @@
 	virtual void reflowLayout();
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 	void receivedFocusWidget();
 	void lostFocusWidget();
 

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ListWidget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -44,7 +44,7 @@
 	_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
 	_scrollBar->setTarget(this);
 
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
 	setHints(THEME_HINT_SAVE_BACKGROUND | THEME_HINT_USE_SHADOW);
 	_type = kListWidget;
 	_editMode = false;
@@ -326,7 +326,7 @@
 	}
 }
 
-void ListWidget::drawWidget(bool hilite) {
+void ListWidget::drawWidget() {
 	int i, pos, len = _list.size();
 	Common::String buffer;
 
@@ -355,7 +355,7 @@
 			char temp[10];
 			sprintf(temp, "%2d. ", (pos + _numberingMode));
 			buffer = temp;
-			g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted, _leftPadding);
+			g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), buffer, _state, Theme::kTextAlignLeft, inverted, _leftPadding);
 			pad = 0;
 		}
 
@@ -365,7 +365,7 @@
 			buffer = _editString;
 			adjustOffset();
 			width = _w - r.left - _hlRightPadding - _leftPadding;
-			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight-2), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted, pad);
+			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight-2), buffer, _state, Theme::kTextAlignLeft, inverted, pad);
 		} else {
 			int maxWidth = _textWidth[i];
 			buffer = _list[pos];
@@ -377,7 +377,7 @@
 				width = _w - r.left - _hlRightPadding;
 			if (width > maxWidth)
 				maxWidth = width;
-			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight-2), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted, pad);
+			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight-2), buffer, _state, Theme::kTextAlignLeft, inverted, pad);
 		}
 
 		_textWidth[i] = width;

Modified: scummvm/trunk/gui/ListWidget.h
===================================================================
--- scummvm/trunk/gui/ListWidget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ListWidget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -106,7 +106,7 @@
 	void endEditMode();
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 
 	//! Finds the item at position (x,y). Returns -1 if there is no item there.
 	int findItem(int x, int y) const;

Modified: scummvm/trunk/gui/PopUpWidget.cpp
===================================================================
--- scummvm/trunk/gui/PopUpWidget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/PopUpWidget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -357,7 +357,7 @@
 
 PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
 	: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS);
 	setHints(THEME_HINT_SAVE_BACKGROUND);
 	_type = kPopUpWidget;
 
@@ -368,7 +368,6 @@
 }
 
 void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
-
 	if (isEnabled()) {
 		PopUpDialog popupDialog(this, x + getAbsX(), y + getAbsY());
 		int newSel = popupDialog.runModal();
@@ -420,19 +419,18 @@
 	}
 }
 
-void PopUpWidget::drawWidget(bool hilite) {
+void PopUpWidget::drawWidget() {
 	int x = _x + _labelWidth + _labelSpacing;
 	int w = _w - _labelWidth - _labelSpacing;
 
 	// Draw the label, if any
 	if (_labelWidth > 0)
-		g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label,
-								isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, Theme::kTextAlignRight);
+		g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label, _state, Theme::kTextAlignRight);
 
 	Common::String sel;
 	if (_selectedItem >= 0)
 		sel = _entries[_selectedItem].name;
-	g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled, g_gui.theme()->convertAligment(kTextAlignLeft));
+	g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, _state, g_gui.theme()->convertAligment(kTextAlignLeft));
 }
 
 } // End of namespace GUI

Modified: scummvm/trunk/gui/PopUpWidget.h
===================================================================
--- scummvm/trunk/gui/PopUpWidget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/PopUpWidget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -87,7 +87,7 @@
 
 	virtual void reflowLayout();
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 };
 
 } // End of namespace GUI

Modified: scummvm/trunk/gui/ScrollBarWidget.cpp
===================================================================
--- scummvm/trunk/gui/ScrollBarWidget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ScrollBarWidget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -32,7 +32,7 @@
 
 ScrollBarWidget::ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h)
 	: Widget (boss, x, y, w, h), CommandSender(boss) {
-	_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG | WIDGET_WANT_TICKLE;
+	setFlags(WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG | WIDGET_WANT_TICKLE);
 	_type = kScrollBarWidget;
 
 	_part = kNoPart;
@@ -183,7 +183,7 @@
 	}
 }
 
-void ScrollBarWidget::drawWidget(bool hilite) {
+void ScrollBarWidget::drawWidget() {
 	if (_draggingPart != kNoPart)
 		_part = _draggingPart;
 
@@ -198,8 +198,7 @@
 		state = Theme::kScrollbarStateSlider;
 	}
 
-	g_gui.theme()->drawScrollbar(Common::Rect(_x, _y, _x+_w, _y+_h), _sliderPos, _sliderHeight, state,
-								isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
+	g_gui.theme()->drawScrollbar(Common::Rect(_x, _y, _x+_w, _y+_h), _sliderPos, _sliderHeight, state, _state);
 }
 
 } // End of namespace GUI

Modified: scummvm/trunk/gui/ScrollBarWidget.h
===================================================================
--- scummvm/trunk/gui/ScrollBarWidget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ScrollBarWidget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -80,7 +80,7 @@
 	void recalc();
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 	void checkBounds(int old_pos);
 };
 

Modified: scummvm/trunk/gui/TabWidget.cpp
===================================================================
--- scummvm/trunk/gui/TabWidget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/TabWidget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -50,7 +50,7 @@
 	_tabSpacing = g_gui.theme()->getTabSpacing();
 	_tabPadding = g_gui.theme()->getTabPadding();
 
-	_flags = WIDGET_ENABLED;
+	setFlags(WIDGET_ENABLED);
  	_type = kTabWidget;
 	_activeTab = -1;
 	_firstVisibleTab = 0;
@@ -248,7 +248,7 @@
 	_tabPadding = g_gui.theme()->getTabPadding();
 }
 
-void TabWidget::drawWidget(bool hilite) {
+void TabWidget::drawWidget() {
 	Common::Array<Common::String> tabs;
 	for (int i = _firstVisibleTab; i < (int)_tabs.size(); ++i) {
 		tabs.push_back(_tabs[i].title);

Modified: scummvm/trunk/gui/TabWidget.h
===================================================================
--- scummvm/trunk/gui/TabWidget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/TabWidget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -99,7 +99,7 @@
 	// Essentially this compensates for the space taken up by the tab title header.
 	virtual int16	getChildY() const;
 
-	virtual void drawWidget(bool hilite);
+	virtual void drawWidget();
 
 	virtual Widget *findWidget(int x, int y);
 };

Modified: scummvm/trunk/gui/ThemeClassic.cpp
===================================================================
--- scummvm/trunk/gui/ThemeClassic.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ThemeClassic.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -170,7 +170,7 @@
 	return 3;
 }
 
-void ThemeClassic::drawDialogBackground(const Common::Rect &r, uint16 hints, State state) {
+void ThemeClassic::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	
@@ -187,7 +187,7 @@
 	addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0);
 }
 
-void ThemeClassic::drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
+void ThemeClassic::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
 	if (!_initOk)
 		return;
 
@@ -202,7 +202,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state) {
+void ThemeClassic::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	restoreBackground(r);
@@ -210,7 +210,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state) {
+void ThemeClassic::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
 	if (!_initOk || background == kWidgetBackgroundNo)
 		return;
 
@@ -238,7 +238,7 @@
 	addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0);
 }
 
-void ThemeClassic::drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints) {
+void ThemeClassic::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
 	if (!_initOk)
 		return;
 	restoreBackground(r);
@@ -251,7 +251,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans) {
+void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
 	if (!_initOk)
 		return;
 
@@ -278,7 +278,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawSlider(const Common::Rect &r, int width, State state) {
+void ThemeClassic::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	Common::Rect r2 = r;
@@ -299,7 +299,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align) {
+void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
 	if (!_initOk)
 		return;
 
@@ -329,7 +329,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state) {
+void ThemeClassic::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -373,7 +373,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state) {
+void ThemeClassic::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	restoreBackground(r);
@@ -399,7 +399,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scroll, State state) {
+void ThemeClassic::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scroll, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	restoreBackground(r);
@@ -462,7 +462,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawCaret(const Common::Rect &r, bool erase, State state) {
+void ThemeClassic::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -477,7 +477,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeClassic::drawLineSeparator(const Common::Rect &r, State state) {
+void ThemeClassic::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	_screen.hLine(r.left - 1, r.top + r.height() / 2, r.right, _shadowcolor);

Modified: scummvm/trunk/gui/ThemeClassic.h
===================================================================
--- scummvm/trunk/gui/ThemeClassic.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ThemeClassic.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -58,20 +58,20 @@
 	int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; }
 	int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; }
 
-	void drawDialogBackground(const Common::Rect &r, uint16 hints, State state);
-	void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
-	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state);
+	void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state);
+	void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
+	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state);
 
-	void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state);
-	void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints);
-	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans);
-	void drawSlider(const Common::Rect &r, int width, State state);
-	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state);
-	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state);
-	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state);
-	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align);
-	void drawCaret(const Common::Rect &r, bool erase, State state);
-	void drawLineSeparator(const Common::Rect &r, State state);
+	void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state);
+	void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints);
+	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans);
+	void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state);
+	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state);
+	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state);
+	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state);
+	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align);
+	void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state);
+	void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state);
 	void restoreBackground(Common::Rect r, bool special = false);
 	bool addDirtyRect(Common::Rect r, bool save = false, bool special = false);
 

Modified: scummvm/trunk/gui/ThemeModern.cpp
===================================================================
--- scummvm/trunk/gui/ThemeModern.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ThemeModern.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -50,8 +50,10 @@
 
 namespace GUI {
 
+// TODO: This should be moved to ThemeModern
 OverlayColor getColorAlpha(OverlayColor col1, OverlayColor col2, int alpha);
 OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor);
+void getStateColor(OverlayColor &s, OverlayColor &e, OverlayColor enabledS, OverlayColor enabledE, OverlayColor highlightS, OverlayColor highlightE, Theme::WidgetStateInfo state);
 
 #pragma mark -
 
@@ -251,7 +253,7 @@
 
 #define surface(x) (_images[x])
  
-void ThemeModern::drawDialogBackground(const Common::Rect &r, uint16 hints, State state) {
+void ThemeModern::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -285,7 +287,7 @@
 	addDirtyRect(r2, (hints & THEME_HINT_SAVE_BACKGROUND) != 0, true);
 }
 
-void ThemeModern::drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
+void ThemeModern::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
 	if (!_initOk)
 		return;
 
@@ -304,7 +306,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state) {
+void ThemeModern::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	restoreBackground(r);
@@ -312,7 +314,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state) {
+void ThemeModern::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -389,7 +391,7 @@
 	addDirtyRect((hints & THEME_HINT_USE_SHADOW) ? r2 : r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0);
 }
 
-void ThemeModern::drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints) {
+void ThemeModern::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
 	if (!_initOk)
 		return;
 	
@@ -401,16 +403,18 @@
 	// shadow
 	drawShadow(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd), kShadowButton);
 
-	if (state == kStateHighlight) {
-		drawRectMasked(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd),
-						256, _colors[kButtonBackgroundHighlightStart], _colors[kButtonBackgroundHighlightEnd],
-						_gradientFactors[kButtonFactor]);
-	} else {
-		drawRectMasked(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd),
-						(state == kStateDisabled) ? -30 : 256, _colors[kButtonBackgroundStart], _colors[kButtonBackgroundEnd],
-						_gradientFactors[kButtonFactor]);
-	}
+	OverlayColor start, end;
+	int alpha = 256;
 
+	getStateColor(start, end, _colors[kButtonBackgroundStart], _colors[kButtonBackgroundEnd],
+				_colors[kButtonBackgroundHighlightStart], _colors[kButtonBackgroundHighlightEnd], state);
+
+	if (state != kStateHighlight)
+		alpha = (state == kStateDisabled) ? -30 : 256;
+
+	drawRectMasked(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd),
+					alpha, start, end, _gradientFactors[kButtonFactor]);
+
 	const int off = (r.height() - getFontHeight()) / 2;
 
 	OverlayColor col = 0;
@@ -433,7 +437,7 @@
 	addDirtyRect(r2);
 }
 
-void ThemeModern::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans) {
+void ThemeModern::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
 	if (!_initOk)
 		return;
 
@@ -476,7 +480,7 @@
 	addDirtyRect(rect);
 }
 
-void ThemeModern::drawSlider(const Common::Rect &rr, int width, State state) {
+void ThemeModern::drawSlider(const Common::Rect &rr, int width, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -497,18 +501,22 @@
 	}
 	
 	drawShadow(r2, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd), kShadowButton);
-	if (state == kStateHighlight) {
-		drawRectMasked(r2, surface(kSliderCorner), surface(kSliderTop), surface(kSliderLeft), surface(kSliderBkgd),
-					256, _colors[kSliderHighStart], _colors[kSliderHighEnd], _gradientFactors[kSliderFactor]);
-	} else {
-		drawRectMasked(r2, surface(kSliderCorner), surface(kSliderTop), surface(kSliderLeft), surface(kSliderBkgd),
-					(state == kStateDisabled) ? -30 : 256, _colors[kSliderStart], _colors[kSliderEnd], _gradientFactors[kSliderFactor]);
-	}
 
+	OverlayColor start, end;
+	int alpha = 256;
+
+	getStateColor(start, end, _colors[kSliderStart], _colors[kSliderEnd], _colors[kSliderHighStart], _colors[kSliderHighEnd], state);
+
+	if (state != kStateHighlight)
+		alpha = (state == kStateDisabled) ? -30 : 256;
+
+	drawRectMasked(r2, surface(kSliderCorner), surface(kSliderTop), surface(kSliderLeft), surface(kSliderBkgd),
+				alpha, start, end, _gradientFactors[kSliderFactor]);
+
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align) {
+void ThemeModern::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
 	if (!_initOk)
 		return;
 
@@ -550,7 +558,7 @@
 	addDirtyRect(r2);
 }
 
-void ThemeModern::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state) {
+void ThemeModern::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	Common::Rect r2 = r;
@@ -568,7 +576,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state) {
+void ThemeModern::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -632,7 +640,7 @@
 	addDirtyRect(Common::Rect(r.left, r.top-2, r.right, r.bottom));
 }
 
-void ThemeModern::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, State state) {
+void ThemeModern::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	const int UP_DOWN_BOX_HEIGHT = r.width() + 1;
@@ -643,16 +651,11 @@
 					_colors[kScrollbarBackgroundStart], _colors[kScrollbarBackgroundEnd], _gradientFactors[kScrollbarBkgdFactor]);
 
 	// draws the 'up' button
-	OverlayColor buttonStart = 0;
-	OverlayColor buttonEnd = 0;
+	OverlayColor buttonStart = _colors[kScrollbarButtonStart];
+	OverlayColor buttonEnd = _colors[kScrollbarButtonEnd];
 	
-	if (scrollState == kScrollbarStateUp) {
-		buttonStart = _colors[kScrollbarButtonHighlightStart];
-		buttonEnd = _colors[kScrollbarButtonHighlightEnd];
-	} else {
-		buttonStart = _colors[kScrollbarButtonStart];
-		buttonEnd = _colors[kScrollbarButtonEnd];
-	}
+	if (scrollState == kScrollbarStateUp)
+		getStateColor(buttonStart, buttonEnd, buttonStart, buttonEnd, _colors[kScrollbarButtonHighlightStart], _colors[kScrollbarButtonHighlightEnd], state);
 	
 	r2.bottom = r2.top + UP_DOWN_BOX_HEIGHT;
 	drawRectMasked(r2, surface(kScrollbarBkgdCorner), surface(kScrollbarBkgdTop), surface(kScrollbarBkgdLeft), surface(kScrollbarBkgd), 256,
@@ -666,16 +669,11 @@
 	drawSurface(r2, arrow, false, false, 256);
 
 	// draws the slider
-	OverlayColor sliderStart = 0;
-	OverlayColor sliderEnd = 0;
+	OverlayColor sliderStart = _colors[kScrollbarSliderStart];
+	OverlayColor sliderEnd = _colors[kScrollbarSliderEnd];
 	
-	if (scrollState == kScrollbarStateSlider) {
-		sliderStart = _colors[kScrollbarSliderHighlightStart];
-		sliderEnd = _colors[kScrollbarSliderHighlightEnd];
-	} else {
-		sliderStart = _colors[kScrollbarSliderStart];
-		sliderEnd = _colors[kScrollbarSliderEnd];
-	}
+	if (scrollState == kScrollbarStateSlider)
+		getStateColor(sliderStart, sliderEnd, sliderStart, sliderEnd, _colors[kScrollbarSliderHighlightStart], _colors[kScrollbarSliderHighlightEnd], state);
 	
 	r2 = r;
 	r2.left += 1;
@@ -697,14 +695,11 @@
 					sliderEnd, sliderStart, _gradientFactors[kScrollbarFactor]);
 
 	// draws the 'down' button
+	buttonStart = _colors[kScrollbarButtonStart];
+	buttonEnd = _colors[kScrollbarButtonEnd];
 	
-	if (scrollState == kScrollbarStateDown) {
-		buttonStart = _colors[kScrollbarButtonHighlightStart];
-		buttonEnd = _colors[kScrollbarButtonHighlightEnd];
-	} else {
-		buttonStart = _colors[kScrollbarButtonStart];
-		buttonEnd = _colors[kScrollbarButtonEnd];
-	}
+	if (scrollState == kScrollbarStateDown)
+		getStateColor(buttonStart, buttonEnd, buttonStart, buttonEnd, _colors[kScrollbarButtonHighlightStart], _colors[kScrollbarButtonHighlightEnd], state);
 	
 	r2 = r;
 	r2.top = r2.bottom - UP_DOWN_BOX_HEIGHT;
@@ -720,7 +715,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawCaret(const Common::Rect &r, bool erase, State state) {
+void ThemeModern::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 
@@ -749,7 +744,7 @@
 	addDirtyRect(r);
 }
 
-void ThemeModern::drawLineSeparator(const Common::Rect &r, State state) {
+void ThemeModern::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
 	if (!_initOk)
 		return;
 	_screen.hLine(r.left - 1, r.top + r.height() / 2, r.right, _system->RGBToColor(0, 0, 0));
@@ -1572,6 +1567,20 @@
 		return calcGradient<ColorMasks<555> >(start, end, pos);
 	}
 }
+
+void getStateColor(OverlayColor &s, OverlayColor &e,
+					OverlayColor enabledS, OverlayColor enabledE,
+					OverlayColor highlightS, OverlayColor highlightE,
+					Theme::WidgetStateInfo state) {
+	if (state == Theme::kStateHighlight) {
+		s = highlightS;
+		e = highlightE;
+	} else {
+		s = enabledS;
+		e = enabledE;
+	}
+}
+
 } // end of namespace GUI
 
 #endif

Modified: scummvm/trunk/gui/ThemeModern.h
===================================================================
--- scummvm/trunk/gui/ThemeModern.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/ThemeModern.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -60,20 +60,20 @@
 	int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; }
 	int getCharWidth(byte c, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getCharWidth(c); return 0; }
 
-	void drawDialogBackground(const Common::Rect &r, uint16 hints, State state);
-	void drawText(const Common::Rect &r, const Common::String &str, State state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
-	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state);
+	void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state);
+	void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
+	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state);
 
-	void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, State state);
-	void drawButton(const Common::Rect &r, const Common::String &str, State state, uint16 hints);
-	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state, int alpha, bool themeTrans);
-	void drawSlider(const Common::Rect &r, int width, State state);
-	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state);
-	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state);
-	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state);
-	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state, TextAlign align);
-	void drawCaret(const Common::Rect &r, bool erase, State state);
-	void drawLineSeparator(const Common::Rect &r, State state);
+	void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state);
+	void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints);
+	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans);
+	void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state);
+	void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state);
+	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state);
+	void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state);
+	void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align);
+	void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state);
+	void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state);
 
 	void restoreBackground(Common::Rect r, bool special = false);
 	bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false);

Modified: scummvm/trunk/gui/about.cpp
===================================================================
--- scummvm/trunk/gui/about.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/about.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -218,7 +218,7 @@
 	for (int line = firstLine; line < lastLine; line++) {
 		const char *str = _lines[line].c_str();
 		Theme::TextAlign align = Theme::kTextAlignCenter;
-		Theme::State state = Theme::kStateEnabled;
+		Theme::WidgetStateInfo state = Theme::kStateEnabled;
 		while (str[0] == '\\') {
 			switch (str[1]) {
 			case 'C':

Modified: scummvm/trunk/gui/dialog.cpp
===================================================================
--- scummvm/trunk/gui/dialog.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/dialog.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -296,9 +296,8 @@
 
 void Dialog::handleTickle() {
 	// Focused widget receives tickle notifications
-	if (_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE) {
+	if (_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE)
 		_focusedWidget->handleTickle();
-	}
 }
 
 void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {

Modified: scummvm/trunk/gui/theme.cpp
===================================================================
--- scummvm/trunk/gui/theme.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/theme.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -258,3 +258,4 @@
 }
 
 } // End of namespace GUI
+

Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/theme.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -105,11 +105,13 @@
 
 	//! State of the widget to be drawn
 	enum State {
-		kStateDisabled,	//! Indicates that the widget is disabled, that does NOT include that it is invisible
-		kStateEnabled,	//! Indicates that the widget is enabled
-		kStateHighlight	//! Indicates that the widget is highlighted by the user
+		kStateDisabled,		//! Indicates that the widget is disabled, that does NOT include that it is invisible
+		kStateEnabled,		//! Indicates that the widget is enabled
+		kStateHighlight		//! Indicates that the widget is highlighted by the user
 	};
 
+	typedef State WidgetStateInfo;
+
 	enum ScrollbarState {
 		kScrollbarStateNo,
 		kScrollbarStateUp,
@@ -277,21 +279,21 @@
 	virtual int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const = 0;
 	virtual int getCharWidth(byte c, FontStyle font = kFontStyleBold) const = 0;
 
-	virtual void drawDialogBackground(const Common::Rect &r, uint16 hints, State state = kStateEnabled) = 0;
-	virtual void drawText(const Common::Rect &r, const Common::String &str, State state = kStateEnabled, TextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold) = 0;
+	virtual void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold) = 0;
 	// this should ONLY be used by the debugger until we get a nicer solution
-	virtual void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, State state = kStateEnabled) = 0;
+	virtual void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled) = 0;
 
-	virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, State state = kStateEnabled) = 0;
-	virtual void drawButton(const Common::Rect &r, const Common::String &str, State state = kStateEnabled, uint16 hints = 0) = 0;
-	virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, State state = kStateEnabled, int alpha = 256, bool themeTrans = false) = 0;
-	virtual void drawSlider(const Common::Rect &r, int width, State state = kStateEnabled) = 0;
-	virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, State state = kStateEnabled) = 0;
-	virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, State state = kStateEnabled) = 0;
-	virtual void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, State state = kStateEnabled) = 0;
-	virtual void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, State state = kStateEnabled, TextAlign align = kTextAlignLeft) = 0;
-	virtual void drawCaret(const Common::Rect &r, bool erase, State state = kStateEnabled) = 0;
-	virtual void drawLineSeparator(const Common::Rect &r, State state = kStateEnabled) = 0;
+	virtual void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0) = 0;
+	virtual void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false) = 0;
+	virtual void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft) = 0;
+	virtual void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) = 0;
+	virtual void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled) = 0;
 
 	virtual void restoreBackground(Common::Rect r, bool special = false) = 0;
 	virtual bool addDirtyRect(Common::Rect r, bool save = false, bool special = false) = 0;

Modified: scummvm/trunk/gui/widget.cpp
===================================================================
--- scummvm/trunk/gui/widget.cpp	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/widget.cpp	2007-11-04 03:38:30 UTC (rev 29403)
@@ -33,13 +33,15 @@
 
 Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
 	: GuiObject(x, y, w, h), _type(0), _boss(boss),
-	  _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), _hasFocus(false) {
+	  _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW),
+	  _hasFocus(false), _state(Theme::kStateEnabled) {
 	init();
 }
 
 Widget::Widget(GuiObject *boss, const Common::String &name)
 	: GuiObject(name), _type(0), _boss(boss),
-	  _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), _hasFocus(false) {
+	  _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW),
+	  _hasFocus(false), _state(Theme::kStateDisabled) {
 	init();
 }
 
@@ -51,6 +53,11 @@
 	_hints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
 }
 
+Widget::~Widget() {
+	delete _next;
+	_next = 0;
+}
+
 void Widget::resize(int x, int y, int w, int h) {
 	_x = x;
 	_y = y;
@@ -58,11 +65,26 @@
 	_h = h;
 }
 
-Widget::~Widget() {
-	delete _next;
-	_next = 0;
+void Widget::setFlags(int flags) {
+	updateState(_flags, _flags | flags);
+	_flags |= flags;
 }
 
+void Widget::clearFlags(int flags) {
+	updateState(_flags, _flags & ~flags);
+	_flags &= ~flags;
+}
+
+void Widget::updateState(int oldFlags, int newFlags) {
+	if (newFlags & WIDGET_ENABLED) {
+		_state = Theme::kStateEnabled;
+		if (newFlags & WIDGET_HILITED)
+			_state = Theme::kStateHighlight;
+	} else {
+		_state = Theme::kStateDisabled;
+	}
+}
+
 void Widget::draw() {
 	NewGui *gui = &g_gui;
 
@@ -75,10 +97,6 @@
 	_x = getAbsX();
 	_y = getAbsY();
 
-	// Clear background (unless alpha blending is enabled)
-	//if (_flags & WIDGET_CLEARBG)
-	//	gui->fillRect(_x, _y, _w, _h, gui->_bgcolor);
-
 	// Draw border
 	if (_flags & WIDGET_BORDER) {
 		gui->theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _hints, Theme::kWidgetBackgroundBorder);
@@ -89,7 +107,7 @@
 	}
 
 	// Now perform the actual widget draw
-	drawWidget((_flags & WIDGET_HILITED) ? true : false);
+	drawWidget();
 
 	// Restore x/y
 	if (_flags & WIDGET_BORDER) {
@@ -133,6 +151,7 @@
 	}
 	return 0;
 }
+
 bool Widget::isEnabled() const {
 	if (g_gui.evaluator()->getVar(_name + ".enabled") == 0) {
 		return false;
@@ -147,19 +166,18 @@
 	return !(_flags & WIDGET_INVISIBLE);
 }
 
-
 #pragma mark -
 
 StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, TextAlignment align)
 	: Widget(boss, x, y, w, h), _align(align) {
-	_flags = WIDGET_ENABLED;
+	setFlags(WIDGET_ENABLED);
 	_type = kStaticTextWidget;
 	_label = text;
 }
 
 StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text)
 	: Widget(boss, name) {
-	_flags = WIDGET_ENABLED;
+	setFlags(WIDGET_ENABLED);
 	_type = kStaticTextWidget;
 	_label = text;
 
@@ -191,10 +209,8 @@
 }
 
 
-void StaticTextWidget::drawWidget(bool hilite) {
-	g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label,
-							isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled,
-							g_gui.theme()->convertAligment(_align));
+void StaticTextWidget::drawWidget() {
+	g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, g_gui.theme()->convertAligment(_align));
 }
 
 #pragma mark -
@@ -202,14 +218,14 @@
 ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd, uint8 hotkey)
 	: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss),
 	  _cmd(cmd), _hotkey(hotkey) {
-	_flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
 	_type = kButtonWidget;
 }
 
 ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd, uint8 hotkey)
 	: StaticTextWidget(boss, name, label), CommandSender(boss),
 	  _cmd(cmd), _hotkey(hotkey) {
-	_flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
 	_hints = THEME_HINT_USE_SHADOW;
 	_type = kButtonWidget;
 }
@@ -219,21 +235,21 @@
 		sendCommand(_cmd, 0);
 }
 
-void ButtonWidget::drawWidget(bool hilite) {
-	g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled, _hints);
+void ButtonWidget::drawWidget() {
+	g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, _hints);
 }
 
 #pragma mark -
 
 CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &label, uint32 cmd, uint8 hotkey)
 	: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) {
-	_flags = WIDGET_ENABLED;
+	setFlags(WIDGET_ENABLED);
 	_type = kCheckboxWidget;
 }
 
 CheckboxWidget::CheckboxWidget(GuiObject *boss, const Common::String &name, const Common::String &label, uint32 cmd, uint8 hotkey)
 	: ButtonWidget(boss, name, label, cmd, hotkey), _state(false) {
-	_flags = WIDGET_ENABLED;
+	setFlags(WIDGET_ENABLED);
 	_type = kCheckboxWidget;
 }
 
@@ -246,15 +262,14 @@
 void CheckboxWidget::setState(bool state) {
 	if (_state != state) {
 		_state = state;
-		_flags ^= WIDGET_INV_BORDER;
+		//_flags ^= WIDGET_INV_BORDER;
 		draw();
 	}
 	sendCommand(_cmd, _state);
 }
 
-void CheckboxWidget::drawWidget(bool hilite) {
-	g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state,
-								isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
+void CheckboxWidget::drawWidget() {
+	g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, Widget::_state);
 }
 
 #pragma mark -
@@ -262,14 +277,14 @@
 SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd)
 	: Widget(boss, x, y, w, h), CommandSender(boss),
 	  _cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) {
-	_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG);
 	_type = kSliderWidget;
 }
 
 SliderWidget::SliderWidget(GuiObject *boss, const Common::String &name, uint32 cmd)
 	: Widget(boss, name), CommandSender(boss),
 	  _cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) {
-	_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG);
 	_type = kSliderWidget;
 }
 
@@ -303,9 +318,8 @@
 	_isDragging = false;
 }
 
-void SliderWidget::drawWidget(bool hilite) {
-	g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x+_w, _y+_h), valueToPos(_value),
-							isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
+void SliderWidget::drawWidget() {
+	g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x+_w, _y+_h), valueToPos(_value), _state);
 }
 
 int SliderWidget::valueToPos(int value) {
@@ -320,7 +334,7 @@
 
 GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
 	: Widget(boss, x, y, w, h), _gfx(), _alpha(256), _transparency(false) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
 	_type = kGraphicsWidget;
 	// HACK: Don't save the background. We want to be sure that redrawing
 	//       the widget updates the screen, even when there isn't any image
@@ -330,7 +344,7 @@
 
 GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name)
 	: Widget(boss, name), _gfx(), _alpha(256), _transparency(false) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
 	_type = kGraphicsWidget;
 	// HACK: Don't save the background. We want to be sure that redrawing
 	//       the widget updates the screen, even when there isn't any image
@@ -372,25 +386,24 @@
 	}
 }
 
-void GraphicsWidget::drawWidget(bool hilite) {
-	if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
-		g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled, _alpha, _transparency);
-	}
+void GraphicsWidget::drawWidget() {
+	if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels)
+		g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, _state, _alpha, _transparency);
 }
 
 #pragma mark -
 
 ContainerWidget::ContainerWidget(GuiObject *boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
 	_type = kContainerWidget;
 }
 
 ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : Widget(boss, name) {
-	_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
+	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
 	_type = kContainerWidget;
 }
 
-void ContainerWidget::drawWidget(bool hilite) {
+void ContainerWidget::drawWidget() {
 	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _hints, Theme::kWidgetBackgroundBorder);
 }
 

Modified: scummvm/trunk/gui/widget.h
===================================================================
--- scummvm/trunk/gui/widget.h	2007-11-04 03:16:56 UTC (rev 29402)
+++ scummvm/trunk/gui/widget.h	2007-11-04 03:38:30 UTC (rev 29403)
@@ -31,6 +31,7 @@
 #include "graphics/font.h"
 #include "graphics/surface.h"
 #include "gui/object.h"
+#include "gui/theme.h"
 
 namespace Graphics {
 	class Font;
@@ -45,7 +46,7 @@
 	WIDGET_INVISIBLE	= 1 << 1,
 	WIDGET_HILITED		= 1 << 2,
 	WIDGET_BORDER		= 1 << 3,
-	WIDGET_INV_BORDER	= 1 << 4,
+	//WIDGET_INV_BORDER	= 1 << 4,
 	WIDGET_CLEARBG		= 1 << 5,
 	WIDGET_WANT_TICKLE	= 1 << 7,
 	WIDGET_TRACK_MOUSE	= 1 << 8,
@@ -97,10 +98,13 @@
 	GuiObject	*_boss;
 	Widget		*_next;
 	uint16		_id;
-	uint16		_flags;
 	uint16		_hints;
 	bool		_hasFocus;
+	Theme::WidgetStateInfo _state;
 
+private:
+	uint16		_flags;
+
 public:
 	static Widget *findWidgetInChain(Widget *start, int x, int y);
 	static Widget *findWidgetInChain(Widget *start, const char *name);
@@ -139,8 +143,8 @@
 	void lostFocus() { _hasFocus = false; lostFocusWidget(); }
 	virtual bool wantsFocus() { return false; }
 
-	void setFlags(int flags)	{ _flags |= flags; }
-	void clearFlags(int flags)	{ _flags &= ~flags; }
+	void setFlags(int flags);
+	void clearFlags(int flags);
 	int getFlags() const		{ return _flags; }
 
 	void setHints(int hints)	{ _hints |= hints; }
@@ -152,8 +156,10 @@
 	bool isVisible() const;
 
 protected:
-	virtual void drawWidget(bool hilite) {}
+	void updateState(int oldFlags, int newFlags);
 
+	virtual void drawWidget() = 0;
+
 	virtual void receivedFocusWidget() {}
 	virtual void lostFocusWidget() {}
 
@@ -182,7 +188,7 @@
 	TextAlignment getAlign() const		{ return _align; }
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 };
 
 /* ButtonWidget */
@@ -203,7 +209,7 @@
 	void handleMouseLeft(int button)	{ clearFlags(WIDGET_HILITED); draw(); }
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 };
 
 /* CheckboxWidget */
@@ -223,7 +229,7 @@
 	bool getState() const		{ return _state; }
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 };
 
 /* SliderWidget */
@@ -256,7 +262,7 @@
 	void handleMouseLeft(int button)	{ clearFlags(WIDGET_HILITED); draw(); }
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 
 	int valueToPos(int value);
 	int posToValue(int pos);
@@ -276,7 +282,7 @@
 	void useThemeTransparency(bool enable) { _transparency = enable; }
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 
 	Graphics::Surface _gfx;
 	int _alpha;
@@ -290,7 +296,7 @@
 	ContainerWidget(GuiObject *boss, const Common::String &name);
 
 protected:
-	void drawWidget(bool hilite);
+	void drawWidget();
 };
 
 } // End of namespace GUI


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