xoreos  0.0.5
listbox.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <algorithm>
26 #include <cassert>
27 
28 #include "src/common/util.h"
29 #include "src/common/error.h"
30 #include "src/common/ustring.h"
31 
32 #include "src/graphics/graphics.h"
33 #include "src/graphics/font.h"
34 
39 
43 
44 namespace Engines {
45 
46 namespace NWN {
47 
49  return *itemA < *itemB;
50 }
51 
52 WidgetListItem::WidgetListItem(::Engines::GUI &gui) : NWNWidget(gui, ""), _itemNumber(0xFFFFFFFF), _state(false) {
53 }
54 
56 }
57 
58 bool WidgetListItem::operator<(const WidgetListItem &item) const {
59  return getTag() < item.getTag();
60 }
61 
62 void WidgetListItem::mouseUp(uint8 state, float UNUSED(x), float UNUSED(y)) {
63  if (isDisabled())
64  return;
65 
66  if (state != SDL_BUTTON_LMASK)
67  return;
68 
69  activate();
70 }
71 
72 void WidgetListItem::mouseDblClick(uint8 state, float UNUSED(x), float UNUSED(y)) {
73  if (isDisabled())
74  return;
75 
76  if (state == SDL_BUTTON_LMASK) {
77  WidgetListBox *ownerList = dynamic_cast<WidgetListBox *>(_owner);
78  if (ownerList)
79  ownerList->itemDblClicked();
80  }
81 }
82 
83 void WidgetListItem::mouseWheel(uint8 state, int x, int y) {
84  if (isDisabled())
85  return;
86 
87  if (y != 0)
88  if (_owner)
89  _owner->mouseWheel(state, x, y);
90 
91  return;
92 }
93 
95  if (isDisabled())
96  return;
97 
98  activate();
99 }
100 
102  return _itemNumber;
103 }
104 
106  return _state;
107 }
108 
110  if (_state)
111  return false;
112 
113  WidgetListBox *ownerList = dynamic_cast<WidgetListBox *>(_owner);
114  if (!ownerList || (ownerList->getMode() != WidgetListBox::kModeSelectable))
115  return false;
116 
117  _state = true;
118 
119  setActive(true);
120 
121  return true;
122 }
123 
125  if (!_state)
126  return false;
127 
128  WidgetListBox *ownerList = dynamic_cast<WidgetListBox *>(_owner);
129  if (!ownerList || (ownerList->getMode() != WidgetListBox::kModeSelectable))
130  return false;
131 
132  _state = false;
133 
134  return true;
135 }
136 
139 
140  deactivate();
141 }
142 
143 
145  const Common::UString &font, const Common::UString &text, float spacing) :
146  WidgetListItem(gui),
147  _uR(1.0f), _uG(1.0f), _uB(1.0f), _uA(1.0f),
148  _sR(1.0f), _sG(1.0f), _sB(0.0f), _sA(1.0f), _spacing(spacing) {
149 
151 
152  _fontHeight = f.getFont().getHeight();
153 
154  _text.reset(new Graphics::Aurora::Text(f, text, _uR, _uG, _uB, _uA));
155 
156  _text->setClickable(true);
157 }
158 
160 }
161 
163  _text->show();
164 }
165 
167  _text->hide();
168 }
169 
170 void WidgetListItemTextLine::setPosition(float x, float y, float z) {
171  NWNWidget::setPosition(x, y, z);
172 
173  getPosition(x, y, z);
174  _text->setPosition(x, y, z);
175 }
176 
177 void WidgetListItemTextLine::setUnselectedColor(float r, float g, float b, float a) {
178  _uR = r;
179  _uG = g;
180  _uB = b;
181  _uA = a;
182 
183  if (!getState())
184  _text->setColor(_uR, _uG, _uB, _uA);
185 }
186 
187 void WidgetListItemTextLine::setSelectedColor(float r, float g, float b, float a) {
188  _sR = r;
189  _sG = g;
190  _sB = b;
191  _sA = a;
192 
193  if (getState())
194  _text->setColor(_sR, _sG, _sB, _sA);
195 }
196 
198  return _text->getWidth();
199 }
200 
202  if (_text->empty())
203  return _fontHeight + _spacing;
204 
205  return _text->getHeight() + _spacing;
206 }
207 
210 
211  _text->setTag(tag);
212 }
213 
216  return false;
217 
218  _text->setColor(_sR, _sG, _sB, _sA);
219 
220  return true;
221 }
222 
225  return false;
226 
227  _text->setColor(_uR, _uG, _uB, _uA);
228 
229  return true;
230 }
231 
233  const Common::UString &model) :
234  ModelWidget(gui, tag, model), _contentX(0.0f), _contentY(0.0f), _contentZ(0.0f),
235  _startItem(0), _selectedItem(0xFFFFFFFF), _up(0), _down(0), _scrollbar(0), _locked(false),
236  _mode(kModeStatic), _hasScrollbar(false), _dblClicked(false) {
237 
238  _model->setClickable(true);
239 
240  getProperties();
241 
242  createScrollbar();
243 }
244 
246 }
247 
249  // Do we have a scroll bar?
250  _hasScrollbar = _model->hasNode("scrollmin") && _model->hasNode("scrollmax");
251 
252  // Calculate content region
253 
254  Graphics::Aurora::ModelNode *node = 0;
255 
256  float topX = 8.0f, topY = getHeight() - 6.0f, topZ = 0.0f;
257  if ((node = _model->getNode("text0")))
258  node->getPosition(topX, topY, topZ);
259 
260  float bottomX = getWidth() - (_hasScrollbar ? 25.0f : 3.0f), bottomY = 3.0f, bottomZ = 0.0f;
261  if ((node = _model->getNode("text1")))
262  node->getPosition(bottomX, bottomY, bottomZ);
263 
264  _contentX = topX;
265  _contentY = topY;
266 
267  _contentWidth = bottomX - topX;
268  _contentHeight = topY - bottomY;
269 }
270 
272  if (!_hasScrollbar)
273  return;
274 
275  // Get top position
276  float minX, minY, minZ;
277  _model->getNode("scrollmin")->getPosition(minX, minY, minZ);
278 
279  // Create the "up" button
280  _up = new WidgetButton(*_gui, getTag() + "#Up", "pb_scrl_up", "gui_scroll");
281  _up->setPosition(minX, minY, -50.0f);
282  addSub(*_up);
283 
284  // Get bottom position
285  float maxX, maxY, maxZ;
286  _model->getNode("scrollmax")->getPosition(maxX, maxY, maxZ);
287 
288  // Create the "down" button
289  _down = new WidgetButton(*_gui, getTag() + "#Down", "pb_scrl_down", "gui_scroll");
290  _down->setPosition(maxX, maxY - 10, -50.0f);
291  addSub(*_down);
292 
293  // Scroll bar range (max length)
294  float scrollRange = minY - (maxY - 10) - _up->getHeight() - 1;
295 
296  // Create the scrollbar
297  _scrollbar =
298  new WidgetScrollbar(*_gui, getTag() + "#Bar", Scrollbar::kTypeVertical, scrollRange);
299 
300  // Center the bar within the scrollbar area
301  float scrollX = maxX + (_up->getWidth() - _scrollbar->getWidth()) / 2;
302  // Move it to the base position
303  float scrollY = maxY - 10 + _up->getHeight();
304 
305  _scrollbar->setPosition(scrollX, scrollY, -50.0f);
306  addSub(*_scrollbar);
307 }
308 
310  return _mode;
311 }
312 
314  _mode = mode;
315 }
316 
319 
320  // Show the scrollbar
321  if (_hasScrollbar) {
322  _up->show();
323  _down->show();
324  _scrollbar->show();
325  }
326 
327  // Show the visible items
328  for (std::vector<WidgetListItem *>::iterator v = _visibleItems.begin(); v != _visibleItems.end(); ++v)
329  (*v)->show();
330 }
331 
334 
335  // Hide the scrollbar
336  if (_hasScrollbar) {
337  _up->hide();
338  _down->hide();
339  _scrollbar->hide();
340  }
341 
342  // Hide the visible items
343  for (std::vector<WidgetListItem *>::iterator v = _visibleItems.begin(); v != _visibleItems.end(); ++v)
344  (*v)->hide();
345 }
346 
347 void WidgetListBox::setPosition(float x, float y, float z) {
348  float oX, oY, oZ;
349  getPosition(oX, oY, oZ);
350 
351  ModelWidget::setPosition(x, y, z);
352 
353  float nX, nY, nZ;
354  getPosition(nX, nY, nZ);
355 
356  getPosition(x, y, z);
357  for (std::list<Widget *>::iterator it = _subWidgets.begin(); it != _subWidgets.end(); ++it) {
358  float sX, sY, sZ;
359  (*it)->getPosition(sX, sY, sZ);
360 
361  sX -= oX;
362  sY -= oY;
363  sZ -= oZ;
364 
365  (*it)->setPosition(sX + nX, sY + nY, sZ + nZ);
366  }
367 
368  _contentX = _contentX - oX + nX;
369  _contentY = _contentY - oY + nY;
370  _contentZ = _contentZ - oZ + nZ;
371 }
372 
374  return _contentWidth;
375 }
376 
378  return _contentHeight;
379 }
380 
382  assert(!_locked);
383  _locked = true;
384 
385  GfxMan.lockFrame();
386 }
387 
389  assert(_locked);
390 
391  for (std::vector<WidgetListItem *>::iterator v = _visibleItems.begin(); v != _visibleItems.end(); ++v)
392  (*v)->hide();
393  _visibleItems.clear();
394 
395  for (std::vector<WidgetListItem *>::iterator i = _items.begin(); i != _items.end(); ++i)
396  (*i)->remove();
397  _items.clear();
398 
399  _startItem = 0;
400  _selectedItem = 0xFFFFFFFF;
401 
403 }
404 
405 void WidgetListBox::reserve(size_t n) {
406  assert(_locked);
407 
408  _items.reserve(n);
409 }
410 
411 void WidgetListBox::add(WidgetListItem *item, bool noTag) {
412  assert(_locked);
413 
414  if (!_items.empty())
415  if (round(item->getHeight()) != round(_items.front()->getHeight()))
416  throw Common::Exception("WidgetListBox item sizes mismatch");
417 
418  item->_itemNumber = _items.size();
419 
420  if (!noTag)
421  item->setTag(Common::UString::format("%s#Item%d", getTag().c_str(), (int)_items.size()));
422 
423  for (std::vector<WidgetListItem *>::iterator i = _items.begin(); i != _items.end(); ++i) {
424  (*i)->addGroupMember(*item);
425  item->addGroupMember(**i);
426  }
427 
428  _items.push_back(item);
429 
430  addSub(*item);
431 
432  if (isVisible()) {
435  }
436 }
437 
439  assert(_locked);
440 
441  for (size_t it = 0; it < _visibleItems.size(); ++it) {
442  if (_visibleItems[it] == item) {
443  _visibleItems.erase(_visibleItems.begin() + it);
444  break;
445  }
446  }
447 
448  std::vector<WidgetListItem *>::iterator itItem;
449  for (std::vector<WidgetListItem *>::iterator i = _items.begin(); i != _items.end(); ++i) {
450  (*i)->removeGroupMember(*item);
451  item->removeGroupMember(**i);
452  if (*i == item)
453  itItem = i;
454  }
455 
456  _items.erase(itItem);
457 
458  removeSub(*item);
459  item->_itemNumber = 0xFFFFFFFF;
460 
461  _selectedItem = 0xFFFFFFFF;
462 
463  ptrdiff_t max = _items.size() - _visibleItems.size();
464  if (max > 0 && _scrollbar->getState() == 1.f)
465  _startItem -= 1;
466 
467  if (item->isVisible())
468  item->hide();
469 }
470 
472  assert(_locked);
473  _locked = false;
474 
475  if (_items.empty()) {
476  GfxMan.unlockFrame();
477  return;
478  }
479 
480  size_t count = MIN<size_t>(_contentHeight / _items.front()->getHeight(), _items.size());
481  if ((count == 0) || (count == _visibleItems.size())) {
482  GfxMan.unlockFrame();
483  return;
484  }
485 
486  assert(_visibleItems.size() < count);
487 
488  _visibleItems.reserve(count);
489 
490  size_t start = _startItem + _visibleItems.size();
491 
492  float itemHeight = _items.front()->getHeight();
493  while (_visibleItems.size() < count) {
494  WidgetListItem *item = _items[start++];
495 
496  float itemY = _contentY - (_visibleItems.size() + 1) * itemHeight;
497  item->setPosition(_contentX, itemY, _contentZ - 5.0f);
498 
499  _visibleItems.push_back(item);
500  if (isVisible())
501  _visibleItems.back()->show();
502  }
503 
506 
507  GfxMan.unlockFrame();
508 
509  if (isVisible())
510  updateVisible();
511 }
512 
514  std::sort(_items.begin(), _items.end(), compPtrItem);
515  for (uint16 it = 0; it < _items.size(); ++it) {
516  _items[it]->_itemNumber = it;
517  }
518 
519  if (isVisible())
520  updateVisible();
521 }
522 
524  const Common::UString &text, float spacing) {
525 
526  lock();
527  clear();
528 
530  std::vector<Common::UString> lines;
531  f.getFont().split(text, lines, getContentWidth());
532 
533  for (std::vector<Common::UString>::iterator l = lines.begin(); l != lines.end(); ++l)
534  add(new WidgetListItemTextLine(*_gui, font, *l, spacing));
535 
536  unlock();
537 }
538 
540  if (!_scrollbar)
541  return;
542 
543  if (_visibleItems.empty())
544  _scrollbar->setLength(1.0f);
545  else
546  _scrollbar->setLength(((float) _visibleItems.size()) / _items.size());
547 }
548 
550  if (!_scrollbar)
551  return;
552 
553  ptrdiff_t max = _items.size() - _visibleItems.size();
554  if (max > 0)
555  _scrollbar->setState(((float) _startItem) / max);
556  else
557  _scrollbar->setState(0.0f);
558 }
559 
561  if (_visibleItems.empty())
562  return;
563 
564  GfxMan.lockFrame();
565 
566  for (size_t i = 0; i < _visibleItems.size(); i++)
567  _visibleItems[i]->hide();
568 
569  float itemHeight = _items.front()->getHeight();
570  float itemY = _contentY;
571  for (size_t i = 0; i < _visibleItems.size(); i++) {
572  WidgetListItem *item = _items[_startItem + i];
573 
574  itemY -= itemHeight;
575 
576  item->setPosition(_contentX, itemY, _contentZ - 5.0f);
577  _visibleItems[i] = item;
578 
579  if (isVisible())
580  _visibleItems[i]->show();
581  }
582 
583  GfxMan.unlockFrame();
584 }
585 
587  _dblClicked = true;
588 
589  setActive(true);
590 }
591 
592 void WidgetListBox::scrollUp(size_t n) {
593  if (_visibleItems.empty())
594  return;
595 
596  if (_startItem == 0)
597  return;
598 
599  _startItem -= MIN<size_t>(n, _startItem);
600 
601  updateVisible();
603 }
604 
606  if (_visibleItems.empty())
607  return;
608 
609  if (_startItem + _visibleItems.size() >= _items.size())
610  return;
611 
612  _startItem += MIN<size_t>(n, _items.size() - _visibleItems.size() - _startItem);
613 
614  updateVisible();
616 }
617 
618 void WidgetListBox::select(size_t item) {
619  if (item >= _items.size())
620  return;
621 
622  _items[item]->select();
623  _selectedItem = item;
624 }
625 
627  return _selectedItem;
628 }
629 
631  if (_selectedItem >= _items.size()) return 0;
632 
633  return _items[_selectedItem];
634 }
635 
637  if (_selectedItem >= _items.size()) return;
638 
639  _items[_selectedItem]->deactivate();
640  _selectedItem = 0xFFFFFFFF;
641 }
642 
643 void WidgetListBox::setStartItem(size_t firstItem) {
644  _startItem = MIN<size_t>(firstItem, _items.size() - _visibleItems.size());
645 
646  updateVisible();
648 }
649 
651  return _startItem;
652 }
653 
654 std::vector<WidgetListItem *>::iterator WidgetListBox::begin() {
655  return _items.begin();
656 }
657 
658 std::vector<WidgetListItem *>::iterator WidgetListBox::end() {
659  return _items.end();
660 }
661 
663  bool dblClicked = _dblClicked;
664 
665  _dblClicked = false;
666 
667  return dblClicked;
668 }
669 
671  if (widget.getTag().endsWith("#Up")) {
672  scrollUp(1);
673  return;
674  }
675 
676  if (widget.getTag().endsWith("#Down")) {
677  scrollDown(1);
678  return;
679  }
680 
681  if (widget.getTag().endsWith("#Bar")) {
682  ptrdiff_t max = _items.size() - _visibleItems.size();
683  if (max <= 0)
684  return;
685 
686  size_t startItem = _scrollbar->getState() * max;
687  if (startItem == _startItem)
688  return;
689 
690  _startItem = startItem;
691  updateVisible();
692  return;
693  }
694 
695  WidgetListItem *listItem = dynamic_cast<WidgetListItem *>(&widget);
696  if (listItem) {
697  if (_selectedItem != listItem->_itemNumber) {
698  _selectedItem = listItem->_itemNumber;
699  setActive(true);
700  }
701  }
702 
703 }
704 
705 void WidgetListBox::mouseDown(uint8 UNUSED(state), float x, float y) {
706  if (isDisabled())
707  return;
708 
709  float wX, wY, wZ;
710  getPosition(wX, wY, wZ);
711 
712  // Check if we clicked on the scrollbar area
713  if (_scrollbar) {
714  if (x > (wX + getWidth() - 20)) {
715  if (y > _scrollbar->getBarPosition())
716  scrollUp(_visibleItems.size());
717  else
718  scrollDown(_visibleItems.size());
719 
720  return;
721  }
722  }
723 }
724 
725 void WidgetListBox::mouseWheel(uint8 UNUSED(state), int UNUSED(x), int y) {
726  if (isDisabled())
727  return;
728 
729  if (y > 0)
730  scrollUp(1);
731  else if (y < 0)
732  scrollDown(1);
733 }
734 
735 
736 } // End of namespace NWN
737 
738 } // End of namespace Engines
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: button.cpp:72
WidgetButton * _up
Definition: listbox.h:192
float getHeight() const
Get the widget&#39;s height.
Definition: listbox.cpp:201
The global graphics manager.
A NWN button widget.
Widget * _owner
The widget&#39;s owner, if any.
Definition: widget.h:113
virtual void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: widget.cpp:49
A class holding an UTF-8 string.
Definition: ustring.h:48
A NWN scrollbar widget.
Definition: scrollbar.h:95
size_t getItemNumber() const
Definition: listbox.cpp:101
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
void subActive(Widget &widget)
A sub-widget was activated.
Definition: listbox.cpp:670
void add(WidgetListItem *item, bool noTag=false)
Definition: listbox.cpp:411
float getHeight() const
Get the widget&#39;s height.
Definition: modelwidget.cpp:82
uint8_t uint8
Definition: types.h:200
bool operator<(const WidgetListItem &item) const
Definition: listbox.cpp:58
A handle to a font.
Definition: fonthandle.h:52
void setActive(bool active)
The widget&#39;s active state.
Definition: widget.cpp:268
A text object.
virtual void addGroupMember(Widget &widget)
Add a fellow group member to the widget.
Definition: widget.cpp:222
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
float split(const Common::UString &line, std::vector< Common::UString > &lines, float maxWidth=0.0f, float maxHeight=0.0f, bool trim=true) const
Definition: font.cpp:69
bool endsWith(const UString &with) const
Definition: ustring.cpp:315
WidgetButton * _down
Definition: listbox.h:193
WidgetListItemTextLine(::Engines::GUI &gui, const Common::UString &font, const Common::UString &text, float spacing=0.0f)
Definition: listbox.cpp:144
Base class for all widgets in NWN.
Definition: nwnwidget.h:45
float getContentWidth() const
Definition: listbox.cpp:373
void remove()
Remove the widget from the GUI.
Definition: widget.cpp:258
bool isVisible() const
Is the widget visible?
Definition: widget.cpp:59
void setLength(float length)
Set the length of the scrollbar, as a fraction of the range.
Definition: scrollbar.cpp:281
std::vector< WidgetListItem * >::iterator begin()
Get begin iterator from all the items in WidgetListBox.
Definition: listbox.cpp:654
void getPosition(float &x, float &y, float &z) const
Get the position of the node.
Definition: modelnode.cpp:181
WidgetListItem * getSelectedItem() const
Definition: listbox.cpp:630
virtual void signalGroupMemberActive()
A fellow group member signaled that it is now active.
Definition: widget.cpp:264
WidgetListItem(::Engines::GUI &gui)
Definition: listbox.cpp:52
GUI * _gui
The GUI the widget belongs to.
Definition: widget.h:108
void hide()
Hide the widget.
Definition: listbox.cpp:332
void hide()
Hide the widget.
Definition: modelwidget.cpp:63
virtual float getHeight() const
Get the widget&#39;s height.
Definition: widget.cpp:150
void setState(float state)
Set the current state, as a fraction of the range.
Definition: scrollbar.cpp:301
The Aurora font manager.
An item widget within a NWN listbox widget.
Definition: listbox.h:51
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: listbox.cpp:170
A NWN listbox widget.
void hide()
Hide the widget.
Definition: scrollbar.cpp:267
virtual void updateVisible()
Definition: listbox.cpp:560
void hide()
Hide the widget.
Definition: nwnwidget.cpp:40
std::vector< WidgetListItem * > _items
Definition: listbox.h:187
void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: listbox.cpp:725
A NWN button widget.
Definition: button.h:39
A GUI.
Definition: gui.h:43
float getState() const
Get the current state, as a fraction of the range.
Definition: scrollbar.cpp:297
size_t getSelected() const
Definition: listbox.cpp:626
Basic exceptions to throw.
void setText(const Common::UString &font, const Common::UString &text, float spacing=0.0f)
Definition: listbox.cpp:523
A text object.
Definition: text.h:42
WidgetScrollbar * _scrollbar
Definition: listbox.h:194
void setClickable(bool clickable)
Set the object&#39;s clickable state.
Definition: renderable.cpp:94
virtual void updateScrollbarPosition()
Definition: listbox.cpp:549
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Definition: ustring.cpp:718
uint16_t uint16
Definition: types.h:202
#define UNUSED(x)
Definition: system.h:170
Utility templates and functions.
virtual void updateScrollbarLength()
Definition: listbox.cpp:539
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
void setMode(Mode mode)
Definition: listbox.cpp:313
void show()
Show the widget.
Definition: modelwidget.cpp:53
void show()
Show the widget.
Definition: scrollbar.cpp:257
void setUnselectedColor(float r, float g, float b, float a)
Definition: listbox.cpp:177
A node within a 3D model.
A 3D model of an object.
bool hasNode(const Common::UString &node) const
Does the specified node exist in the current state?
Definition: model.cpp:368
WidgetListBox(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &model)
Definition: listbox.cpp:232
std::vector< WidgetListItem * >::iterator end()
Get end iterator from all the items in WidgetListBox.
Definition: listbox.cpp:658
A NWN listbox widget.
Definition: listbox.h:116
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: listbox.cpp:347
void mouseDown(uint8 state, float x, float y)
A mouse button was pressed on the widget.
Definition: listbox.cpp:705
bool compPtrItem(WidgetListItem *itemA, WidgetListItem *itemB)
Definition: listbox.cpp:48
StackException Exception
Definition: error.h:59
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: nwnwidget.cpp:60
Graphics::Aurora::Model * _model
Definition: modelwidget.h:64
virtual bool deactivate()
Definition: listbox.cpp:124
void reserve(size_t n)
Definition: listbox.cpp:405
Common::ScopedPtr< Graphics::Aurora::Text > _text
Definition: listbox.h:106
Unicode string handling.
void mouseDblClick(uint8 state, float x, float y)
A mouse button was double-clicked on the widget.
Definition: listbox.cpp:72
virtual void scrollUp(size_t n)
Definition: listbox.cpp:592
virtual void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: widget.cpp:197
virtual void removeGroupMember(Widget &widget)
Remove fellow group member from the widget.
Definition: widget.cpp:249
virtual void removeSub(Widget &widget)
Remove a sub-widget from the widget.
Definition: widget.cpp:227
A widget in a GUI.
Definition: widget.h:40
void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: listbox.cpp:208
void show()
Show the widget.
Definition: listbox.cpp:162
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: modelwidget.cpp:71
A NWN model widget.
Definition: modelwidget.h:45
void select(size_t item)
Definition: listbox.cpp:618
A NWN scrollbar model and widget.
void setSelectedColor(float r, float g, float b, float a)
Definition: listbox.cpp:187
float getContentHeight() const
Definition: listbox.cpp:377
void signalGroupMemberActive()
A fellow group member signaled that it is now active.
Definition: listbox.cpp:137
bool isDisabled() const
Is the widget disabled?
Definition: widget.cpp:63
float getWidth() const
Get the widget&#39;s width.
Definition: listbox.cpp:197
float getWidth() const
Get the widget&#39;s width.
Definition: scrollbar.cpp:318
float getWidth() const
Get the widget&#39;s width.
Definition: modelwidget.cpp:78
void show()
Show the widget.
Definition: listbox.cpp:317
void mouseUp(uint8 state, float x, float y)
A mouse button was released on the widget.
Definition: listbox.cpp:62
size_t getStartItem() const
Get the first item shown in the list.
Definition: listbox.cpp:650
void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: listbox.cpp:83
ModelNode * getNode(const Common::UString &node)
Get the specified node, from the current state.
Definition: model.cpp:379
void hide()
Hide the widget.
Definition: listbox.cpp:166
virtual void addSub(Widget &widget)
Add a sub-widget to the widget.
Definition: widget.cpp:206
virtual float getHeight() const =0
Return the height of a character.
std::vector< WidgetListItem * > _visibleItems
Definition: listbox.h:188
std::list< Widget * > _subWidgets
The widget&#39;s sub-widgets.
Definition: widget.h:115
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: scrollbar.cpp:275
virtual void scrollDown(size_t n)
Definition: listbox.cpp:605
A font.
void setStartItem(size_t firstItem)
Set the first item to show in the list.
Definition: listbox.cpp:643
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
#define FontMan
Shortcut for accessing the font manager.
Definition: fontman.h:105
A text line widget within a NWN listbox widget.
Definition: listbox.h:82