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. svn-id: r23705
This commit is contained in:
parent
e9b9aa65a6
commit
b4311d15ca
1 changed files with 10 additions and 21 deletions
|
@ -32,19 +32,12 @@ namespace GUI {
|
||||||
ListWidget::ListWidget(GuiObject *boss, const String &name)
|
ListWidget::ListWidget(GuiObject *boss, const String &name)
|
||||||
: EditableWidget(boss, name), CommandSender(boss) {
|
: EditableWidget(boss, name), CommandSender(boss) {
|
||||||
|
|
||||||
_leftPadding = g_gui.evaluator()->getVar("ListWidget.leftPadding", 0);
|
_scrollBar = NULL;
|
||||||
_rightPadding = g_gui.evaluator()->getVar("ListWidget.rightPadding", 0);
|
_textWidth = NULL;
|
||||||
_topPadding = g_gui.evaluator()->getVar("ListWidget.topPadding", 0);
|
|
||||||
_bottomPadding = g_gui.evaluator()->getVar("ListWidget.bottomPadding", 0);
|
// This ensures that _entriesPerPage is properly initialised.
|
||||||
_hlLeftPadding = g_gui.evaluator()->getVar("ListWidget.hlLeftPadding", 0);
|
reflowLayout();
|
||||||
_hlRightPadding = g_gui.evaluator()->getVar("ListWidget.hlRightPadding", 0);
|
|
||||||
|
|
||||||
if (g_gui.getWidgetSize() == kBigWidgetSize) {
|
|
||||||
_scrollBarWidth = kBigScrollBarWidth;
|
|
||||||
} else {
|
|
||||||
_scrollBarWidth = kNormalScrollBarWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
|
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
|
||||||
_scrollBar->setTarget(this);
|
_scrollBar->setTarget(this);
|
||||||
|
|
||||||
|
@ -53,7 +46,6 @@ ListWidget::ListWidget(GuiObject *boss, const String &name)
|
||||||
_type = kListWidget;
|
_type = kListWidget;
|
||||||
_editMode = false;
|
_editMode = false;
|
||||||
_numberingMode = kListNumberingOne;
|
_numberingMode = kListNumberingOne;
|
||||||
_entriesPerPage = (_h - _topPadding - _bottomPadding) / kLineHeight;
|
|
||||||
_currentPos = 0;
|
_currentPos = 0;
|
||||||
_selectedItem = -1;
|
_selectedItem = -1;
|
||||||
_currentKeyDown = 0;
|
_currentKeyDown = 0;
|
||||||
|
@ -65,11 +57,6 @@ ListWidget::ListWidget(GuiObject *boss, const String &name)
|
||||||
|
|
||||||
// FIXME: This flag should come from widget definition
|
// FIXME: This flag should come from widget definition
|
||||||
_editable = true;
|
_editable = true;
|
||||||
|
|
||||||
_textWidth = new int[_entriesPerPage];
|
|
||||||
|
|
||||||
for (int i = 0; i < _entriesPerPage; i++)
|
|
||||||
_textWidth[i] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListWidget::~ListWidget() {
|
ListWidget::~ListWidget() {
|
||||||
|
@ -470,9 +457,11 @@ void ListWidget::reflowLayout() {
|
||||||
for (int i = 0; i < _entriesPerPage; i++)
|
for (int i = 0; i < _entriesPerPage; i++)
|
||||||
_textWidth[i] = 0;
|
_textWidth[i] = 0;
|
||||||
|
|
||||||
_scrollBar->resize(_w - _scrollBarWidth, 0, _scrollBarWidth, _h);
|
if (_scrollBar) {
|
||||||
scrollBarRecalc();
|
_scrollBar->resize(_w - _scrollBarWidth, 0, _scrollBarWidth, _h);
|
||||||
scrollToCurrent();
|
scrollBarRecalc();
|
||||||
|
scrollToCurrent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace GUI
|
} // End of namespace GUI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue