[Scummvm-cvs-logs] SF.net SVN: scummvm: [23705] scummvm/trunk/gui/ListWidget.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sat Aug 12 19:24:53 CEST 2006


Revision: 23705
Author:   eriktorbjorn
Date:     2006-08-12 10:24:49 -0700 (Sat, 12 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23705&view=rev

Log Message:
-----------
The ListWidget constructor already did most of what reflowLayout() does, except
calling Widget::reflowLayout(). I've simplified that by calling reflowLayout()
directly instead. This may be a bit of a hack, but it was the best way I could
think of to ensure that _entriesPerPage was properly initialised. It wasn't
before, because _h had not been initialised, causing Valgrind to complain.

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp
Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2006-08-12 16:42:19 UTC (rev 23704)
+++ scummvm/trunk/gui/ListWidget.cpp	2006-08-12 17:24:49 UTC (rev 23705)
@@ -32,19 +32,12 @@
 ListWidget::ListWidget(GuiObject *boss, const String &name)
 	: EditableWidget(boss, name), CommandSender(boss) {
 
-	_leftPadding = g_gui.evaluator()->getVar("ListWidget.leftPadding", 0);
-	_rightPadding = g_gui.evaluator()->getVar("ListWidget.rightPadding", 0);
-	_topPadding = g_gui.evaluator()->getVar("ListWidget.topPadding", 0);
-	_bottomPadding = g_gui.evaluator()->getVar("ListWidget.bottomPadding", 0);
-	_hlLeftPadding = g_gui.evaluator()->getVar("ListWidget.hlLeftPadding", 0);
-	_hlRightPadding = g_gui.evaluator()->getVar("ListWidget.hlRightPadding", 0);
+	_scrollBar = NULL;
+	_textWidth = NULL;
 
-	if (g_gui.getWidgetSize() == kBigWidgetSize) {
-		_scrollBarWidth =  kBigScrollBarWidth;
-	} else {
-		_scrollBarWidth = kNormalScrollBarWidth;
-	}
-	
+	// This ensures that _entriesPerPage is properly initialised.
+	reflowLayout();
+
 	_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
 	_scrollBar->setTarget(this);
 
@@ -53,7 +46,6 @@
 	_type = kListWidget;
 	_editMode = false;
 	_numberingMode = kListNumberingOne;
-	_entriesPerPage = (_h - _topPadding - _bottomPadding) / kLineHeight;
 	_currentPos = 0;
 	_selectedItem = -1;
 	_currentKeyDown = 0;
@@ -65,11 +57,6 @@
 
 	// FIXME: This flag should come from widget definition
 	_editable = true;
-
-	_textWidth = new int[_entriesPerPage];
-
-	for (int i = 0; i < _entriesPerPage; i++)
-		_textWidth[i] = 0;
 }
 
 ListWidget::~ListWidget() {
@@ -470,9 +457,11 @@
 	for (int i = 0; i < _entriesPerPage; i++)
 		_textWidth[i] = 0;
 
-	_scrollBar->resize(_w - _scrollBarWidth, 0, _scrollBarWidth, _h);
-	scrollBarRecalc();
-	scrollToCurrent();
+	if (_scrollBar) {
+		_scrollBar->resize(_w - _scrollBarWidth, 0, _scrollBarWidth, _h);
+		scrollBarRecalc();
+		scrollToCurrent();
+	}
 }
 
 } // 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