[Scummvm-cvs-logs] CVS: scummvm/gui TabWidget.cpp,1.15,1.16 TabWidget.h,1.9,1.10 launcher.cpp,1.118,1.119 options.cpp,1.80,1.81

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon May 16 23:20:38 CEST 2005


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25999

Modified Files:
	TabWidget.cpp TabWidget.h launcher.cpp options.cpp 
Log Message:
Added "big" version of the Tab widget, and made use of it.


Index: TabWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/TabWidget.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- TabWidget.cpp	4 Apr 2005 17:57:40 -0000	1.15
+++ TabWidget.cpp	17 May 2005 06:19:42 -0000	1.16
@@ -28,20 +28,36 @@
 
 enum {
 	kTabHeight = 16,
+	kBigTabHeight = 21,
 
 	kTabLeftOffset = 4,
 	kTabSpacing = 2,
 	kTabPadding = 3
 };
 
-TabWidget::TabWidget(GuiObject *boss, int x, int y, int w, int h)
-	: Widget(boss, x, y, w, h) {
+TabWidget::TabWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws)
+	: Widget(boss, x, y, w, h), _ws(ws) {
 
 	_flags = WIDGET_ENABLED;
 	_type = kTabWidget;
 	_activeTab = -1;
 
 	_tabWidth = 40;
+
+	switch (_ws) {
+	case kNormalWidgetSize:
+		_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+		_tabHeight = kTabHeight;
+		break;
+	case kBigWidgetSize:
+		_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+		_tabHeight = kBigTabHeight;
+		break;
+	case kDefaultWidgetSize:
+		_font = &g_gui.getFont();
+		_tabHeight = kTabHeight;
+		break;
+	}
 }
 
 TabWidget::~TabWidget() {
@@ -53,21 +69,21 @@
 }
 
 int16 TabWidget::getChildY() const {
-	return getAbsY() + kTabHeight;
+	return getAbsY() + _tabHeight;
 }
 
 int TabWidget::addTab(const String &title) {
 	// Add a new tab page
 	Tab newTab;
-	 newTab.title = title;
-	 newTab.firstWidget = 0;
+	newTab.title = title;
+	newTab.firstWidget = 0;
 
 	_tabs.push_back(newTab);
 
 	int numTabs = _tabs.size();
 
 	// Determine the new tab width
-	int newWidth = g_gui.getStringWidth(title) + 2 * kTabPadding;
+	int newWidth = _font->getStringWidth(title) + 2 * kTabPadding;
 	if (_tabWidth < newWidth)
 		_tabWidth = newWidth;
 	int maxWidth = (_w - kTabLeftOffset) / numTabs - kTabLeftOffset;
@@ -96,7 +112,7 @@
 
 
 void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) {
-	assert(y < kTabHeight);
+	assert(y < _tabHeight);
 
 	// Determine which tab was clicked
 	int tabID = -1;
@@ -146,33 +162,33 @@
 	const int right2 = _x + _w - 2;
 	
 	// Draw horizontal line
-	gui->hLine(left1, _y + kTabHeight - 2, right1, gui->_shadowcolor);
-	gui->hLine(left2, _y + kTabHeight - 2, right2, gui->_shadowcolor);
+	gui->hLine(left1, _y + _tabHeight - 2, right1, gui->_shadowcolor);
+	gui->hLine(left2, _y + _tabHeight - 2, right2, gui->_shadowcolor);
 
 	// Iterate over all tabs and draw them
 	int i, x = _x + kTabLeftOffset;
 	for (i = 0; i < (int)_tabs.size(); ++i) {
 		OverlayColor color = (i == _activeTab) ? gui->_color : gui->_shadowcolor;
 		int yOffset = (i == _activeTab) ? 0 : 2; 
-		box(x, _y + yOffset, _tabWidth, kTabHeight - yOffset, color, color, (i == _activeTab));
-		gui->drawString(_tabs[i].title, x + kTabPadding, _y + yOffset / 2 + (kTabHeight - kLineHeight - 1), _tabWidth - 2 * kTabPadding, gui->_textcolor, kTextAlignCenter);
+		box(x, _y + yOffset, _tabWidth, _tabHeight - yOffset, color, color, (i == _activeTab));
+		gui->drawString(_font, _tabs[i].title, x + kTabPadding, _y + yOffset / 2 + (_tabHeight - _font->getFontHeight() - 3), _tabWidth - 2 * kTabPadding, gui->_textcolor, kTextAlignCenter);
 		x += _tabWidth + kTabSpacing;
 	}
 
 	// Draw more horizontal lines
-	gui->hLine(left1, _y + kTabHeight - 1, right1, gui->_color);
-	gui->hLine(left2, _y + kTabHeight - 1, right2, gui->_color);
+	gui->hLine(left1, _y + _tabHeight - 1, right1, gui->_color);
+	gui->hLine(left2, _y + _tabHeight - 1, right2, gui->_color);
 	gui->hLine(_x+1, _y + _h - 2, _x + _w - 2, gui->_shadowcolor);
 	gui->hLine(_x+1, _y + _h - 1, _x + _w - 2, gui->_color);
 }
 
 Widget *TabWidget::findWidget(int x, int y) {
-	if (y < kTabHeight) {
+	if (y < _tabHeight) {
 		// Click was in the tab area
 		return this;
 	} else {
 		// Iterate over all child widgets and find the one which was clicked
-		return Widget::findWidgetInChain(_firstWidget, x, y - kTabHeight);
+		return Widget::findWidgetInChain(_firstWidget, x, y - _tabHeight);
 	}
 }
 

Index: TabWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/TabWidget.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- TabWidget.h	4 Apr 2005 17:57:15 -0000	1.9
+++ TabWidget.h	17 May 2005 06:19:42 -0000	1.10
@@ -38,9 +38,12 @@
 	int _activeTab;
 	TabList _tabs;
 	int _tabWidth;
+	int _tabHeight;
+	const WidgetSize _ws;
+	const Graphics::Font *_font;
 
 public:
-	TabWidget(GuiObject *boss, int x, int y, int w, int h);
+	TabWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kDefaultWidgetSize);
 	~TabWidget();
 
 	virtual int16	getChildY() const;

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- launcher.cpp	16 May 2005 06:33:33 -0000	1.118
+++ launcher.cpp	17 May 2005 06:19:42 -0000	1.119
@@ -144,6 +144,14 @@
 	
 	_w = screenW - 2 * 10;
 	_h = screenH - 2 * 40;	// TODO/FIXME
+
+	GUI::WidgetSize ws;
+
+	if (screenW >= 400 && screenH >= 300) {
+		ws = GUI::kBigWidgetSize;
+	} else {
+		ws = GUI::kNormalWidgetSize;
+	}
 	
 	const int x = 5;
 	const int w = _w - 15;
@@ -163,7 +171,7 @@
 	}
 
 	// GUI:  Add tab widget
-	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2*vBorder);
+	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2 * vBorder, ws);
 
 	//
 	// 1) The game tab

Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- options.cpp	16 May 2005 06:33:33 -0000	1.80
+++ options.cpp	17 May 2005 06:19:42 -0000	1.81
@@ -435,19 +435,32 @@
 
 
 GlobalOptionsDialog::GlobalOptionsDialog()
-	: OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 20, 320 - 2 * 10, 200 - 1 * 20) {
+	: OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 40, 320 - 2 * 10, 140) {
 
 	const int screenW = g_system->getOverlayWidth();
 	const int screenH = g_system->getOverlayHeight();
+
+	GUI::WidgetSize ws;
 	
-	_w = screenW - 2 * 10;
-	_h = screenH - 1 * 20;
+	if (screenW >= 400 && screenH >= 300) {
+		ws = GUI::kBigWidgetSize;
+		_w = screenW - 2 * 10;
+		_h = screenH - 2 * 40;
+		_x = 10;
+		_y = 40;
+	} else {
+		ws = GUI::kNormalWidgetSize;
+		_w = screenW - 2 * 10;
+		_h = screenH - 1 * 20;
+		_x = 10;
+		_y = 20;
+	}
 
-	const int vBorder = 4;
+	const int vBorder = 5;	// Tab border
 	int yoffset;
 
 	// The tab widget
-	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2 * vBorder);
+	TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2 * vBorder, ws);
 
 	//
 	// 1) The graphics tab





More information about the Scummvm-git-logs mailing list