MyGUI  3.4.0
MyGUI_ListBox.cpp
Go to the documentation of this file.
1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #include "MyGUI_Precompiled.h"
8 #include "MyGUI_ListBox.h"
9 #include "MyGUI_Button.h"
10 #include "MyGUI_ScrollBar.h"
11 #include "MyGUI_ResourceSkin.h"
12 #include "MyGUI_InputManager.h"
13 #include "MyGUI_WidgetManager.h"
14 
15 namespace MyGUI
16 {
17 
19  mWidgetScroll(nullptr),
20  mActivateOnClick(false),
21  mHeightLine(1),
22  mTopIndex(0),
23  mOffsetTop(0),
24  mRangeIndex(-1),
25  mLastRedrawLine(0),
26  mIndexSelect(ITEM_NONE),
27  mLineActive(ITEM_NONE),
28  mNeedVisibleScroll(true)
29  {
30  }
31 
33  {
34  Base::initialiseOverride();
35 
36  // FIXME нам нужен фокус клавы
37  setNeedKeyFocus(true);
38 
39  // парсим свойства
40  if (isUserString("SkinLine"))
41  mSkinLine = getUserString("SkinLine");
42 
43  if (isUserString("HeightLine"))
44  mHeightLine = utility::parseInt(getUserString("HeightLine"));
45 
46  if (mHeightLine < 1)
47  mHeightLine = 1;
48 
49  if (getClientWidget() != nullptr)
50  {
55  }
56 
58  assignWidget(mWidgetScroll, "VScroll");
59  if (mWidgetScroll != nullptr)
60  {
62  mWidgetScroll->setScrollPage((size_t)mHeightLine);
63  }
64 
65  updateScroll();
66  updateLine();
67  }
68 
70  {
71  mWidgetScroll = nullptr;
72 
73  Base::shutdownOverride();
74  }
75 
76  void ListBox::onMouseWheel(int _rel)
77  {
78  notifyMouseWheel(nullptr, _rel);
79 
80  Base::onMouseWheel(_rel);
81  }
82 
84  {
85  if (getItemCount() == 0)
86  {
87  Base::onKeyButtonPressed(_key, _char);
89  return;
90  }
91 
92  // очень секретный метод, запатентованный механизм движения курсора
93  size_t sel = mIndexSelect;
94 
95  if (_key == KeyCode::ArrowUp)
96  {
97  if (sel != 0)
98  {
99  if (sel == ITEM_NONE)
100  sel = 0;
101  else
102  sel --;
103  }
104  }
105  else if (_key == KeyCode::ArrowDown)
106  {
107  if (sel == ITEM_NONE)
108  sel = 0;
109  else
110  sel ++;
111 
112  if (sel >= getItemCount())
113  {
114  // старое значение
115  sel = mIndexSelect;
116  }
117  }
118  else if (_key == KeyCode::Home)
119  {
120  if (sel != 0)
121  sel = 0;
122  }
123  else if (_key == KeyCode::End)
124  {
125  if (sel != (getItemCount() - 1))
126  {
127  sel = getItemCount() - 1;
128  }
129  }
130  else if (_key == KeyCode::PageUp)
131  {
132  if (sel != 0)
133  {
134  if (sel == ITEM_NONE)
135  {
136  sel = 0;
137  }
138  else
139  {
140  size_t page = _getClientWidget()->getHeight() / mHeightLine;
141  if (sel <= page)
142  sel = 0;
143  else
144  sel -= page;
145  }
146  }
147  }
148  else if (_key == KeyCode::PageDown)
149  {
150  if (sel != (getItemCount() - 1))
151  {
152  if (sel == ITEM_NONE)
153  {
154  sel = 0;
155  }
156  else
157  {
158  sel += _getClientWidget()->getHeight() / mHeightLine;
159  if (sel >= getItemCount())
160  sel = getItemCount() - 1;
161  }
162  }
163  }
164  else if ((_key == KeyCode::Return) || (_key == KeyCode::NumpadEnter))
165  {
166  if (sel != ITEM_NONE)
167  {
168  //FIXME нас могут удалить
169  eventListSelectAccept(this, sel);
170 
171  Base::onKeyButtonPressed(_key, _char);
172 
174  // выходим, так как изменили колличество строк
175  return;
176  }
177  }
178 
179  if (sel != mIndexSelect)
180  {
181  _resetContainer(true);
182 
183  if (!isItemVisibleAt(sel))
184  {
185  beginToItemAt(sel);
186  if (mWidgetScroll != nullptr)
187  _sendEventChangeScroll(mWidgetScroll->getScrollPosition());
188  }
189  setIndexSelected(sel);
190 
191  // изменилась позиция
192  // FIXME нас могут удалить
193  eventListChangePosition(this, mIndexSelect);
194  }
195 
196  Base::onKeyButtonPressed(_key, _char);
198  }
199 
200  void ListBox::notifyMouseWheel(Widget* _sender, int _rel)
201  {
202  if (mRangeIndex <= 0)
203  return;
204 
205  if (mWidgetScroll == nullptr)
206  return;
207 
208  int offset = (int)mWidgetScroll->getScrollPosition();
209  if (_rel < 0)
210  offset += mHeightLine;
211  else
212  offset -= mHeightLine;
213 
214  if (offset >= mRangeIndex)
215  offset = mRangeIndex;
216  else if (offset < 0)
217  offset = 0;
218 
219  if ((int)mWidgetScroll->getScrollPosition() == offset)
220  return;
221 
222  mWidgetScroll->setScrollPosition(offset);
223  _setScrollView(offset);
224  _sendEventChangeScroll(offset);
225 
226  _resetContainer(true);
227  }
228 
229  void ListBox::notifyScrollChangePosition(ScrollBar* _sender, size_t _position)
230  {
231  _setScrollView(_position);
232  _sendEventChangeScroll(_position);
233  }
234 
235  void ListBox::notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id)
236  {
237  if (MouseButton::Left == _id && !mActivateOnClick)
238  _activateItem(_sender);
239 
240  eventNotifyItem(this, IBNotifyItemData(getIndexByWidget(_sender), IBNotifyItemData::MousePressed, _left, _top, _id));
241  }
242 
244  {
245  if (mActivateOnClick)
246  _activateItem(_sender);
247  }
248 
250  {
251  if (mIndexSelect != ITEM_NONE)
252  eventListSelectAccept(this, mIndexSelect);
253  }
254 
255  void ListBox::setPosition(const IntPoint& _point)
256  {
257  Base::setPosition(_point);
258  }
259 
260  void ListBox::setSize(const IntSize& _size)
261  {
262  Base::setSize(_size);
263 
264  updateScroll();
265  updateLine();
266  }
267 
268  void ListBox::setCoord(const IntCoord& _coord)
269  {
270  Base::setCoord(_coord);
271 
272  updateScroll();
273  updateLine();
274  }
275 
277  {
278  mRangeIndex = (mHeightLine * (int)mItemsInfo.size()) - _getClientWidget()->getHeight();
279 
280  if (mWidgetScroll == nullptr)
281  return;
282 
283  if ((!mNeedVisibleScroll) || (mRangeIndex < 1) || (mWidgetScroll->getLeft() <= _getClientWidget()->getLeft()))
284  {
285  if (mWidgetScroll->getVisible())
286  {
287  mWidgetScroll->setVisible(false);
288  // увеличиваем клиентскую зону на ширину скрола
289  if (getClientWidget() != nullptr)
291  }
292  }
293  else if (!mWidgetScroll->getVisible())
294  {
295  if (getClientWidget() != nullptr)
297  mWidgetScroll->setVisible(true);
298  }
299 
300  mWidgetScroll->setScrollRange(mRangeIndex + 1);
301  mWidgetScroll->setScrollViewPage(_getClientWidget()->getHeight());
302  if (!mItemsInfo.empty())
303  mWidgetScroll->setTrackSize(mWidgetScroll->getLineSize() * _getClientWidget()->getHeight() / mHeightLine / (int)mItemsInfo.size());
304  }
305 
306  void ListBox::updateLine(bool _reset)
307  {
308  // сбрасываем
309  if (_reset)
310  {
311  mOldSize.clear();
312  mLastRedrawLine = 0;
313  _resetContainer(false);
314  }
315 
316  // позиция скролла
317  int position = mTopIndex * mHeightLine + mOffsetTop;
318 
319  // если высота увеличивалась то добавляем виджеты
320  if (mOldSize.height < mCoord.height)
321  {
322  int height = (int)mWidgetLines.size() * mHeightLine - mOffsetTop;
323 
324  // до тех пор, пока не достигнем максимального колличества, и всегда на одну больше
325  while ( (height <= (_getClientWidget()->getHeight() + mHeightLine)) && (mWidgetLines.size() < mItemsInfo.size()) )
326  {
327  // создаем линию
328  Widget* widget = _getClientWidget()->createWidgetT("Button", mSkinLine, 0, height, _getClientWidget()->getWidth(), mHeightLine, Align::Top | Align::HStretch);
329  Button* line = widget->castType<Button>();
330  // подписываемся на всякие там события
340  line->_setContainer(this);
341  // присваиваем порядковый номер, для простоты просчета
342  line->_setInternalData((size_t)mWidgetLines.size());
343  // и сохраняем
344  mWidgetLines.push_back(line);
345  height += mHeightLine;
346  }
347 
348  // проверяем на возможность не менять положение списка
349  if (position >= mRangeIndex)
350  {
351  // размер всех помещается в клиент
352  if (mRangeIndex <= 0)
353  {
354  // обнуляем, если надо
355  if (position || mOffsetTop || mTopIndex)
356  {
357  position = 0;
358  mTopIndex = 0;
359  mOffsetTop = 0;
360  mLastRedrawLine = 0; // чтобы все перерисовалось
361 
362  // выравниваем
363  int offset = 0;
364  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
365  {
366  mWidgetLines[pos]->setPosition(0, offset);
367  offset += mHeightLine;
368  }
369  }
370  }
371  else
372  {
373  // прижимаем список к нижней границе
374  int count = _getClientWidget()->getHeight() / mHeightLine;
375  mOffsetTop = mHeightLine - (_getClientWidget()->getHeight() % mHeightLine);
376 
377  if (mOffsetTop == mHeightLine)
378  {
379  mOffsetTop = 0;
380  count --;
381  }
382 
383  int top = (int)mItemsInfo.size() - count - 1;
384 
385  // выравниваем
386  int offset = 0 - mOffsetTop;
387  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
388  {
389  mWidgetLines[pos]->setPosition(0, offset);
390  offset += mHeightLine;
391  }
392 
393  // высчитываем положение, должно быть максимальным
394  position = top * mHeightLine + mOffsetTop;
395 
396  // если индех изменился, то перерисовываем линии
397  if (top != mTopIndex)
398  {
399  mTopIndex = top;
401  }
402  }
403  }
404 
405  // увеличился размер, но прокрутки вниз небыло, обновляем линии снизу
406  _redrawItemRange(mLastRedrawLine);
407 
408  } // if (old_cy < mCoord.height)
409 
410  // просчитываем положение скролла
411  if (mWidgetScroll != nullptr)
412  mWidgetScroll->setScrollPosition(position);
413 
414  mOldSize.width = mCoord.width;
415  mOldSize.height = mCoord.height;
416 
417 #if MYGUI_DEBUG_MODE == 1
418  _checkMapping("ListBox::updateLine");
419 #endif
420  }
421 
422  void ListBox::_redrawItemRange(size_t _start)
423  {
424  // перерисовываем линии, только те, что видны
425  size_t pos = _start;
426  for (; pos < mWidgetLines.size(); pos++)
427  {
428  // индекс в нашем массиве
429  size_t index = pos + (size_t)mTopIndex;
430 
431  // не будем заходить слишком далеко
432  if (index >= mItemsInfo.size())
433  {
434  // запоминаем последнюю перерисованную линию
435  mLastRedrawLine = pos;
436  break;
437  }
438  if (mWidgetLines[pos]->getTop() > _getClientWidget()->getHeight())
439  {
440  // запоминаем последнюю перерисованную линию
441  mLastRedrawLine = pos;
442  break;
443  }
444 
445  // если был скрыт, то покажем
446  mWidgetLines[pos]->setVisible(true);
447  // обновляем текст
448  mWidgetLines[pos]->setCaption(mItemsInfo[index].first);
449 
450  // если нужно выделить ,то выделим
451  static_cast<Button*>(mWidgetLines[pos])->setStateSelected(index == mIndexSelect);
452  }
453 
454  // если цикл весь прошли, то ставим максимальную линию
455  if (pos >= mWidgetLines.size())
456  {
457  mLastRedrawLine = pos;
458  }
459  else
460  {
461  //Widget* focus = InputManager::getInstance().getMouseFocusWidget();
462  for (; pos < mWidgetLines.size(); pos++)
463  {
464  static_cast<Button*>(mWidgetLines[pos])->setStateSelected(false);
465  static_cast<Button*>(mWidgetLines[pos])->setVisible(false);
466  //if (focus == mWidgetLines[pos]) InputManager::getInstance()._unlinkWidget(focus);
467  }
468  }
469 
470 #if MYGUI_DEBUG_MODE == 1
471  _checkMapping("ListBox::_redrawItemRange");
472 #endif
473  }
474 
475  // перерисовывает индекс
476  void ListBox::_redrawItem(size_t _index)
477  {
478  // невидно
479  if (_index < (size_t)mTopIndex)
480  return;
481  _index -= (size_t)mTopIndex;
482  // тоже невидно
483  if (_index >= mLastRedrawLine)
484  return;
485 
486  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::_redrawItem");
487  // перерисовываем
488  mWidgetLines[_index]->setCaption(mItemsInfo[_index + mTopIndex].first);
489 
490 #if MYGUI_DEBUG_MODE == 1
491  _checkMapping("ListBox::_redrawItem");
492 #endif
493  }
494 
495  void ListBox::insertItemAt(size_t _index, const UString& _name, Any _data)
496  {
497  MYGUI_ASSERT_RANGE_INSERT(_index, mItemsInfo.size(), "ListBox::insertItemAt");
498  if (_index == ITEM_NONE)
499  _index = mItemsInfo.size();
500 
501  // вставляем физически
502  mItemsInfo.insert(mItemsInfo.begin() + _index, PairItem(_name, _data));
503 
504  // если надо, то меняем выделенный элемент
505  if ((mIndexSelect != ITEM_NONE) && (_index <= mIndexSelect))
506  mIndexSelect++;
507 
508  // строка, до первого видимого элемента
509  if ((_index <= (size_t)mTopIndex) && (mRangeIndex > 0))
510  {
511  mTopIndex ++;
512  // просчитываем положение скролла
513  if (mWidgetScroll != nullptr)
514  {
515  mWidgetScroll->setScrollRange(mWidgetScroll->getScrollRange() + mHeightLine);
516  if (!mItemsInfo.empty())
517  mWidgetScroll->setTrackSize( mWidgetScroll->getLineSize() * _getClientWidget()->getHeight() / mHeightLine / (int)mItemsInfo.size() );
518  mWidgetScroll->setScrollPosition(mTopIndex * mHeightLine + mOffsetTop);
519  }
520  mRangeIndex += mHeightLine;
521  }
522  else
523  {
524  // высчитывам положение строки
525  int offset = ((int)_index - mTopIndex) * mHeightLine - mOffsetTop;
526 
527  // строка, после последнего видимого элемента, плюс одна строка (потому что для прокрутки нужно на одну строчку больше)
528  if (_getClientWidget()->getHeight() < (offset - mHeightLine))
529  {
530  // просчитываем положение скролла
531  if (mWidgetScroll != nullptr)
532  {
533  mWidgetScroll->setScrollRange(mWidgetScroll->getScrollRange() + mHeightLine);
534  if (!mItemsInfo.empty())
535  mWidgetScroll->setTrackSize( mWidgetScroll->getLineSize() * _getClientWidget()->getHeight() / mHeightLine / (int)mItemsInfo.size() );
536  mWidgetScroll->setScrollPosition(mTopIndex * mHeightLine + mOffsetTop);
537  }
538  mRangeIndex += mHeightLine;
539 
540  // строка в видимой области
541  }
542  else
543  {
544  // обновляем все
545  updateScroll();
546  updateLine(true);
547 
548  // позже сюда еще оптимизацию по колличеству перерисовок
549  }
550  }
551 
552 #if MYGUI_DEBUG_MODE == 1
553  _checkMapping("ListBox::insertItemAt");
554 #endif
555  }
556 
557  void ListBox::removeItemAt(size_t _index)
558  {
559  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::removeItemAt");
560 
561  // удяляем физически строку
562  mItemsInfo.erase(mItemsInfo.begin() + _index);
563 
564  // если надо, то меняем выделенный элемент
565  if (mItemsInfo.empty()) mIndexSelect = ITEM_NONE;
566  else if (mIndexSelect != ITEM_NONE)
567  {
568  if (_index < mIndexSelect)
569  mIndexSelect--;
570  else if ((_index == mIndexSelect) && (mIndexSelect == (mItemsInfo.size())))
571  mIndexSelect--;
572  }
573 
574  // если виджетов стало больше , то скрываем крайний
575  if (mWidgetLines.size() > mItemsInfo.size())
576  {
577  mWidgetLines[mItemsInfo.size()]->setVisible(false);
578  }
579 
580  // строка, до первого видимого элемента
581  if (_index < (size_t)mTopIndex)
582  {
583  mTopIndex --;
584  // просчитываем положение скролла
585  if (mWidgetScroll != nullptr)
586  {
587  mWidgetScroll->setScrollRange(mWidgetScroll->getScrollRange() - mHeightLine);
588  if (!mItemsInfo.empty())
589  mWidgetScroll->setTrackSize( mWidgetScroll->getLineSize() * _getClientWidget()->getHeight() / mHeightLine / (int)mItemsInfo.size() );
590  mWidgetScroll->setScrollPosition(mTopIndex * mHeightLine + mOffsetTop);
591  }
592  mRangeIndex -= mHeightLine;
593  }
594  else
595  {
596  // высчитывам положение удаляемой строки
597  int offset = ((int)_index - mTopIndex) * mHeightLine - mOffsetTop;
598 
599  // строка, после последнего видимого элемента
600  if (_getClientWidget()->getHeight() < offset)
601  {
602  // просчитываем положение скролла
603  if (mWidgetScroll != nullptr)
604  {
605  mWidgetScroll->setScrollRange(mWidgetScroll->getScrollRange() - mHeightLine);
606  if (!mItemsInfo.empty())
607  mWidgetScroll->setTrackSize( mWidgetScroll->getLineSize() * _getClientWidget()->getHeight() / mHeightLine / (int)mItemsInfo.size() );
608  mWidgetScroll->setScrollPosition(mTopIndex * mHeightLine + mOffsetTop);
609  }
610  mRangeIndex -= mHeightLine;
611 
612  // строка в видимой области
613  }
614  else
615  {
616  // обновляем все
617  updateScroll();
618  updateLine(true);
619 
620  // позже сюда еще оптимизацию по колличеству перерисовок
621  }
622  }
623 
624 #if MYGUI_DEBUG_MODE == 1
625  _checkMapping("ListBox::removeItemAt");
626 #endif
627  }
628 
629  void ListBox::setIndexSelected(size_t _index)
630  {
631  MYGUI_ASSERT_RANGE_AND_NONE(_index, mItemsInfo.size(), "ListBox::setIndexSelected");
632  if (mIndexSelect != _index)
633  {
634  _selectIndex(mIndexSelect, false);
635  _selectIndex(_index, true);
636  mIndexSelect = _index;
637  }
638  }
639 
640  void ListBox::_selectIndex(size_t _index, bool _select)
641  {
642  if (_index == ITEM_NONE)
643  return;
644  // не видно строки
645  if (_index < (size_t)mTopIndex)
646  return;
647  // высчитывам положение строки
648  int offset = ((int)_index - mTopIndex) * mHeightLine - mOffsetTop;
649  // строка, после последнего видимого элемента
650  if (_getClientWidget()->getHeight() < offset)
651  return;
652 
653  size_t index = _index - mTopIndex;
654  if (index < mWidgetLines.size())
655  static_cast<Button*>(mWidgetLines[index])->setStateSelected(_select);
656 
657 #if MYGUI_DEBUG_MODE == 1
658  _checkMapping("ListBox::_selectIndex");
659 #endif
660  }
661 
662  void ListBox::beginToItemAt(size_t _index)
663  {
664  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::beginToItemAt");
665  if (mRangeIndex <= 0)
666  return;
667 
668  int offset = (int)_index * mHeightLine;
669  if (offset >= mRangeIndex) offset = mRangeIndex;
670 
671  if (mWidgetScroll != nullptr)
672  {
673  if ((int)mWidgetScroll->getScrollPosition() == offset)
674  return;
675  mWidgetScroll->setScrollPosition(offset);
676  }
677  notifyScrollChangePosition(nullptr, offset);
678 
679 #if MYGUI_DEBUG_MODE == 1
680  _checkMapping("ListBox::beginToItemAt");
681 #endif
682  }
683 
684  // видим ли мы элемент, полностью или нет
685  bool ListBox::isItemVisibleAt(size_t _index, bool _fill)
686  {
687  // если элемента нет, то мы его не видим (в том числе когда их вообще нет)
688  if (_index >= mItemsInfo.size())
689  return false;
690  // если скрола нет, то мы палюбак видим
691  if (mRangeIndex <= 0)
692  return true;
693 
694  // строка, до первого видимого элемента
695  if (_index < (size_t)mTopIndex)
696  return false;
697 
698  // строка это верхний выделенный
699  if (_index == (size_t)mTopIndex)
700  {
701  if ((mOffsetTop != 0) && (_fill))
702  return false; // нам нужна полностью видимость
703  return true;
704  }
705 
706  // высчитывам положение строки
707  int offset = ((int)_index - mTopIndex) * mHeightLine - mOffsetTop;
708 
709  // строка, после последнего видимого элемента
710  if (_getClientWidget()->getHeight() < offset)
711  return false;
712 
713  // если мы внизу и нам нужен целый
714  if (_getClientWidget()->getHeight() < (offset + mHeightLine) && _fill)
715  return false;
716 
717  return true;
718  }
719 
721  {
722  mTopIndex = 0;
723  mIndexSelect = ITEM_NONE;
724  mOffsetTop = 0;
725 
726  mItemsInfo.clear();
727 
728  int offset = 0;
729  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
730  {
731  mWidgetLines[pos]->setVisible(false);
732  mWidgetLines[pos]->setPosition(0, offset);
733  offset += mHeightLine;
734  }
735 
736  // обновляем все
737  updateScroll();
738  updateLine(true);
739 
740 #if MYGUI_DEBUG_MODE == 1
741  _checkMapping("ListBox::removeAllItems");
742 #endif
743  }
744 
745  void ListBox::setItemNameAt(size_t _index, const UString& _name)
746  {
747  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::setItemNameAt");
748  mItemsInfo[_index].first = _name;
749  _redrawItem(_index);
750  }
751 
752  void ListBox::setItemDataAt(size_t _index, Any _data)
753  {
754  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::setItemDataAt");
755  mItemsInfo[_index].second = _data;
756  _redrawItem(_index);
757  }
758 
759  const UString& ListBox::getItemNameAt(size_t _index)
760  {
761  MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "ListBox::getItemNameAt");
762  return mItemsInfo[_index].first;
763  }
764 
766  {
767 
768 #if MYGUI_DEBUG_MODE == 1
769  MYGUI_ASSERT_RANGE(*_sender->_getInternalData<size_t>(), mWidgetLines.size(), "ListBox::notifyMouseSetFocus");
770 #endif
771 
772  mLineActive = *_sender->_getInternalData<size_t>();
773  eventListMouseItemFocus(this, mLineActive);
774  }
775 
777  {
778  if ((nullptr == _new) || (_new->getParent() != _getClientWidget()))
779  {
780  mLineActive = ITEM_NONE;
782  }
783  }
784 
785  void ListBox::_setItemFocus(size_t _index, bool _focus)
786  {
787  MYGUI_ASSERT_RANGE(_index, mWidgetLines.size(), "ListBox::_setItemFocus");
788  static_cast<Button*>(mWidgetLines[_index])->_setMouseFocus(_focus);
789  }
790 
791  void ListBox::setScrollVisible(bool _visible)
792  {
793  if (mNeedVisibleScroll == _visible)
794  return;
795  mNeedVisibleScroll = _visible;
796  updateScroll();
797  }
798 
799  void ListBox::setScrollPosition(size_t _position)
800  {
801  if (mWidgetScroll != nullptr)
802  {
803  if (mWidgetScroll->getScrollRange() > _position)
804  {
805  mWidgetScroll->setScrollPosition(_position);
806  _setScrollView(_position);
807  }
808  }
809  }
810 
811  void ListBox::_setScrollView(size_t _position)
812  {
813  mOffsetTop = ((int)_position % mHeightLine);
814 
815  // смещение с отрицательной стороны
816  int offset = 0 - mOffsetTop;
817 
818  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
819  {
820  mWidgetLines[pos]->setPosition(IntPoint(0, offset));
821  offset += mHeightLine;
822  }
823 
824  // если индех изменился, то перерисовываем линии
825  int top = ((int)_position / mHeightLine);
826  if (top != mTopIndex)
827  {
828  mTopIndex = top;
830  }
831 
832  // прорисовываем все нижние строки, если они появились
833  _redrawItemRange(mLastRedrawLine);
834  }
835 
836  void ListBox::_sendEventChangeScroll(size_t _position)
837  {
838  eventListChangeScroll(this, _position);
839  if (ITEM_NONE != mLineActive)
840  eventListMouseItemFocus(this, mLineActive);
841  }
842 
843  void ListBox::swapItemsAt(size_t _index1, size_t _index2)
844  {
845  MYGUI_ASSERT_RANGE(_index1, mItemsInfo.size(), "ListBox::swapItemsAt");
846  MYGUI_ASSERT_RANGE(_index2, mItemsInfo.size(), "ListBox::swapItemsAt");
847 
848  if (_index1 == _index2)
849  return;
850 
851  std::swap(mItemsInfo[_index1], mItemsInfo[_index2]);
852 
853  _redrawItem(_index1);
854  _redrawItem(_index2);
855  }
856 
857  void ListBox::_checkMapping(const std::string& _owner)
858  {
859  size_t count_pressed = 0;
860  size_t count_show = 0;
861 
862  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
863  {
864  MYGUI_ASSERT(pos == *mWidgetLines[pos]->_getInternalData<size_t>(), _owner);
865  if (static_cast<Button*>(mWidgetLines[pos])->getStateSelected())
866  count_pressed ++;
867  if (static_cast<Button*>(mWidgetLines[pos])->getVisible())
868  count_show ++;
869  }
870  //MYGUI_ASSERT(count_pressed < 2, _owner);
871  //MYGUI_ASSERT((count_show + mOffsetTop) <= mItemsInfo.size(), _owner);
872  }
873 
875  {
876  // максимальная высота всех строк
877  int max_height = mItemsInfo.size() * mHeightLine;
878  // видимая высота
879  int visible_height = _getClientWidget()->getHeight();
880 
881  // все строки помещаются
882  if (visible_height >= max_height)
883  {
884  MYGUI_ASSERT(mTopIndex == 0, "mTopIndex == 0");
885  MYGUI_ASSERT(mOffsetTop == 0, "mOffsetTop == 0");
886  int height = 0;
887  for (size_t pos = 0; pos < mWidgetLines.size(); pos++)
888  {
889  if (pos >= mItemsInfo.size())
890  break;
891  MYGUI_ASSERT(mWidgetLines[pos]->getTop() == height, "mWidgetLines[pos]->getTop() == height");
892  height += mWidgetLines[pos]->getHeight();
893  }
894  }
895  }
896 
897  size_t ListBox::findItemIndexWith(const UString& _name)
898  {
899  for (size_t pos = 0; pos < mItemsInfo.size(); pos++)
900  {
901  if (mItemsInfo[pos].first == _name)
902  return pos;
903  }
904  return ITEM_NONE;
905  }
906 
908  {
909  return (int)((mCoord.height - _getClientWidget()->getHeight()) + (mItemsInfo.size() * mHeightLine));
910  }
911 
912  size_t ListBox::getItemCount() const
913  {
914  return mItemsInfo.size();
915  }
916 
917  void ListBox::addItem(const UString& _name, Any _data)
918  {
919  insertItemAt(ITEM_NONE, _name, _data);
920  }
921 
923  {
924  return mIndexSelect;
925  }
926 
928  {
930  }
931 
932  void ListBox::clearItemDataAt(size_t _index)
933  {
934  setItemDataAt(_index, Any::Null);
935  }
936 
938  {
939  if (getItemCount())
940  beginToItemAt(0);
941  }
942 
944  {
945  if (getItemCount())
947  }
948 
950  {
951  if (getIndexSelected() != ITEM_NONE)
953  }
954 
956  {
957  return isItemVisibleAt(mIndexSelect, _fill);
958  }
959 
961  {
962  for (VectorButton::iterator iter = mWidgetLines.begin(); iter != mWidgetLines.end(); ++iter)
963  {
964  if ((*iter) == _item)
965  return *(*iter)->_getInternalData<size_t>() + mTopIndex;
966  }
967  return ITEM_NONE;
968  }
969 
970  void ListBox::_resetContainer(bool _update)
971  {
972  // обязательно у базового
973  Base::_resetContainer(_update);
974 
975  if (!_update)
976  {
978  for (VectorButton::iterator iter = mWidgetLines.begin(); iter != mWidgetLines.end(); ++iter)
979  instance.unlinkFromUnlinkers(*iter);
980  }
981  }
982 
983  void ListBox::setPropertyOverride(const std::string& _key, const std::string& _value)
984  {
985  // не коментировать
986  if (_key == "AddItem")
987  addItem(_value);
988  else if (_key == "ActivateOnClick")
989  mActivateOnClick = utility::parseBool(_value);
990  else
991  {
992  Base::setPropertyOverride(_key, _value);
993  return;
994  }
995 
996  eventChangeProperty(this, _key, _value);
997  }
998 
1000  {
1001  // если выделен клиент, то сбрасываем
1002  if (_sender == _getClientWidget())
1003  {
1004  if (mIndexSelect != ITEM_NONE)
1005  {
1006  _selectIndex(mIndexSelect, false);
1007  mIndexSelect = ITEM_NONE;
1008  eventListChangePosition(this, mIndexSelect);
1009  }
1010  eventListMouseItemActivate(this, mIndexSelect);
1011 
1012  // если не клиент, то просчитывам
1013  }
1014  // ячейка может быть скрыта
1015  else if (_sender->getVisible())
1016  {
1017 
1018 #if MYGUI_DEBUG_MODE == 1
1019  _checkMapping("ListBox::notifyMousePressed");
1020  MYGUI_ASSERT_RANGE(*_sender->_getInternalData<size_t>(), mWidgetLines.size(), "ListBox::notifyMousePressed");
1021  MYGUI_ASSERT_RANGE(*_sender->_getInternalData<size_t>() + mTopIndex, mItemsInfo.size(), "ListBox::notifyMousePressed");
1022 #endif
1023 
1024  size_t index = *_sender->_getInternalData<size_t>() + mTopIndex;
1025 
1026  if (mIndexSelect != index)
1027  {
1028  _selectIndex(mIndexSelect, false);
1029  _selectIndex(index, true);
1030  mIndexSelect = index;
1031  eventListChangePosition(this, mIndexSelect);
1032  }
1033  eventListMouseItemActivate(this, mIndexSelect);
1034  }
1035 
1036  _resetContainer(true);
1037  }
1038 
1040  {
1041  return getItemCount();
1042  }
1043 
1045  {
1046  addItem(_name);
1047  }
1048 
1049  void ListBox::_removeItemAt(size_t _index)
1050  {
1051  removeItemAt(_index);
1052  }
1053 
1054  void ListBox::_setItemNameAt(size_t _index, const UString& _name)
1055  {
1056  setItemNameAt(_index, _name);
1057  }
1058 
1059  const UString& ListBox::_getItemNameAt(size_t _index)
1060  {
1061  return getItemNameAt(_index);
1062  }
1063 
1064  size_t ListBox::getIndexByWidget(Widget* _widget)
1065  {
1066  if (_widget == getClientWidget())
1067  return ITEM_NONE;
1068  return *_widget->_getInternalData<size_t>() + mTopIndex;
1069  }
1070 
1072  {
1073  eventNotifyItem(this, IBNotifyItemData(getIndexByWidget(_sender), IBNotifyItemData::KeyPressed, _key, _char));
1074  }
1075 
1077  {
1078  eventNotifyItem(this, IBNotifyItemData(getIndexByWidget(_sender), IBNotifyItemData::KeyReleased, _key));
1079  }
1080 
1081  void ListBox::notifyMouseButtonReleased(Widget* _sender, int _left, int _top, MouseButton _id)
1082  {
1083  eventNotifyItem(this, IBNotifyItemData(getIndexByWidget(_sender), IBNotifyItemData::MouseReleased, _left, _top, _id));
1084  }
1085 
1087  {
1088  Base::onKeyButtonReleased(_key);
1089 
1091  }
1092 
1093  void ListBox::setActivateOnClick(bool activateOnClick)
1094  {
1095  mActivateOnClick = activateOnClick;
1096  }
1097 
1099  {
1100  if (_index == MyGUI::ITEM_NONE)
1101  return nullptr;
1102 
1103  // индекс в нашем массиве
1104  size_t index = _index + (size_t)mTopIndex;
1105 
1106  if (index < mWidgetLines.size())
1107  return mWidgetLines[index];
1108  return nullptr;
1109  }
1110 
1111 } // namespace MyGUI
MyGUI::WidgetInput::setNeedKeyFocus
void setNeedKeyFocus(bool _value)
Definition: MyGUI_WidgetInput.cpp:152
MyGUI::Char
unsigned int Char
Definition: MyGUI_Types.h:48
MyGUI::Singleton< WidgetManager >::getInstance
static WidgetManager & getInstance()
Definition: MyGUI_Singleton.h:44
MyGUI::ListBox::eventNotifyItem
EventHandle_ListBoxPtrCIBNotifyCellDataRef eventNotifyItem
Definition: MyGUI_ListBox.h:231
MyGUI::Widget::getParent
Widget * getParent() const
Definition: MyGUI_Widget.cpp:1274
MyGUI::ListBox::getWidgetByIndex
Widget * getWidgetByIndex(size_t _index)
Definition: MyGUI_ListBox.cpp:1098
MyGUI::WidgetInput::eventMouseButtonReleased
EventHandle_WidgetIntIntButton eventMouseButtonReleased
Definition: MyGUI_WidgetInput.h:163
MyGUI::KeyCode::End
@ End
Definition: MyGUI_KeyCode.h:144
MyGUI::ListBox::_sendEventChangeScroll
void _sendEventChangeScroll(size_t _position)
Definition: MyGUI_ListBox.cpp:836
MyGUI::ScrollBar::setScrollViewPage
void setScrollViewPage(size_t _value)
Definition: MyGUI_ScrollBar.cpp:623
MyGUI::ListBox::notifyMouseDoubleClick
void notifyMouseDoubleClick(Widget *_sender)
Definition: MyGUI_ListBox.cpp:249
MyGUI::WidgetInput::eventMouseButtonPressed
EventHandle_WidgetIntIntButton eventMouseButtonPressed
Definition: MyGUI_WidgetInput.h:154
MyGUI::ListBox::notifyMouseSetFocus
void notifyMouseSetFocus(Widget *_sender, Widget *_old)
Definition: MyGUI_ListBox.cpp:765
MyGUI::types::TSize::height
T height
Definition: MyGUI_TSize.h:21
MyGUI::ListBox::getOptimalHeight
int getOptimalHeight()
Return optimal height to fit all items in ListBox.
Definition: MyGUI_ListBox.cpp:907
MyGUI::utility::parseBool
bool parseBool(const std::string &_value)
Definition: MyGUI_StringUtility.h:189
MyGUI::ScrollBar::setTrackSize
void setTrackSize(int _value)
Definition: MyGUI_ScrollBar.cpp:381
MyGUI::WidgetManager
Definition: MyGUI_WidgetManager.h:23
MyGUI::ScrollBar::eventScrollChangePosition
EventHandle_ScrollBarPtrSizeT eventScrollChangePosition
Definition: MyGUI_ScrollBar.h:127
MyGUI::ListBox::_redrawItemRange
void _redrawItemRange(size_t _start=0)
Definition: MyGUI_ListBox.cpp:422
MyGUI::ScrollBar
ScrollBar properties. Skin childs. ScrollBar widget description should be here.
Definition: MyGUI_ScrollBar.h:26
MyGUI::ListBox::_getItemNameAt
const UString & _getItemNameAt(size_t _index) override
Definition: MyGUI_ListBox.cpp:1059
MyGUI::WidgetInput::eventKeyButtonReleased
EventHandle_WidgetKeyCode eventKeyButtonReleased
Definition: MyGUI_WidgetInput.h:204
MyGUI::WidgetInput::eventKeyButtonPressed
EventHandle_WidgetKeyCodeChar eventKeyButtonPressed
Definition: MyGUI_WidgetInput.h:197
MyGUI::ListBox::isItemSelectedVisible
bool isItemSelectedVisible(bool _fill=true)
Same as ListBox::isItemVisibleAt for selected item.
Definition: MyGUI_ListBox.cpp:955
MyGUI::ListBox::insertItemAt
void insertItemAt(size_t _index, const UString &_name, Any _data=Any::Null)
Insert an item into a array at a specified position.
Definition: MyGUI_ListBox.cpp:495
MyGUI::ListBox::notifyMouseButtonReleased
void notifyMouseButtonReleased(Widget *_sender, int _left, int _top, MouseButton _id)
Definition: MyGUI_ListBox.cpp:1081
MyGUI_ListBox.h
MYGUI_ASSERT_RANGE
#define MYGUI_ASSERT_RANGE(index, size, owner)
Definition: MyGUI_Diagnostic.h:45
MyGUI::IBNotifyItemData::MouseReleased
@ MouseReleased
Definition: MyGUI_IBItemInfo.h:66
MyGUI::ListBox::notifyKeyButtonReleased
void notifyKeyButtonReleased(Widget *_sender, KeyCode _key)
Definition: MyGUI_ListBox.cpp:1076
MyGUI::Widget::eventChangeProperty
EventHandle_WidgetStringString eventChangeProperty
Definition: MyGUI_Widget.h:267
MyGUI::KeyCode::ArrowDown
@ ArrowDown
Definition: MyGUI_KeyCode.h:145
MyGUI::Align::HStretch
@ HStretch
Definition: MyGUI_Align.h:29
MYGUI_ASSERT_RANGE_AND_NONE
#define MYGUI_ASSERT_RANGE_AND_NONE(index, size, owner)
Definition: MyGUI_Diagnostic.h:46
MyGUI::KeyCode::Home
@ Home
Definition: MyGUI_KeyCode.h:139
MyGUI::ListBox::beginToItemAt
void beginToItemAt(size_t _index)
Move all elements so specified becomes visible.
Definition: MyGUI_ListBox.cpp:662
MyGUI::Widget::createWidgetT
Widget * createWidgetT(const std::string &_type, const std::string &_skin, const IntCoord &_coord, Align _align, const std::string &_name="")
Definition: MyGUI_Widget.cpp:907
MyGUI::Widget
Widget properties. Skin childs. Widget widget description should be here.
Definition: MyGUI_Widget.h:37
MyGUI::ScrollBar::getLineSize
int getLineSize() const
Definition: MyGUI_ScrollBar.cpp:435
MyGUI::ListBox::removeAllItems
void removeAllItems()
Remove all items.
Definition: MyGUI_ListBox.cpp:720
MyGUI::ListBox::initialiseOverride
void initialiseOverride() override
Definition: MyGUI_ListBox.cpp:32
MyGUI::ITEM_NONE
const size_t ITEM_NONE
Definition: MyGUI_Macros.h:17
MyGUI::ListBox::_removeItemAt
void _removeItemAt(size_t _index) override
Definition: MyGUI_ListBox.cpp:1049
MyGUI::WidgetInput::eventMouseLostFocus
EventHandle_WidgetWidget eventMouseLostFocus
Definition: MyGUI_WidgetInput.h:115
MyGUI::ListBox::setScrollPosition
void setScrollPosition(size_t _position)
Set scroll position.
Definition: MyGUI_ListBox.cpp:799
MyGUI::types::TPoint< int >
MyGUI::ListBox::setSize
void setSize(const IntSize &_value) override
Definition: MyGUI_Widget.cpp:647
MyGUI::ListBox::notifyMouseWheel
void notifyMouseWheel(Widget *_sender, int _rel)
Definition: MyGUI_ListBox.cpp:200
MyGUI::Button::setStateSelected
void setStateSelected(bool _value)
Set button selected state.
Definition: MyGUI_Button.cpp:126
MyGUI::Any
Definition: MyGUI_Any.h:64
MyGUI::Button
Button properties. Skin childs. Button widget description should be here.
Definition: MyGUI_Button.h:22
MyGUI::types::TSize::width
T width
Definition: MyGUI_TSize.h:20
MyGUI::ListBox::removeItemAt
void removeItemAt(size_t _index)
Remove item at a specified position.
Definition: MyGUI_ListBox.cpp:557
MyGUI::ListBox::_checkAlign
void _checkAlign()
Definition: MyGUI_ListBox.cpp:874
MyGUI::ListBox::beginToItemLast
void beginToItemLast()
Move all elements so last becomes visible.
Definition: MyGUI_ListBox.cpp:943
MyGUI::ListBox::setItemDataAt
void setItemDataAt(size_t _index, Any _data)
Replace an item data at a specified position.
Definition: MyGUI_ListBox.cpp:752
MyGUI::ListBox::clearItemDataAt
void clearItemDataAt(size_t _index)
Clear an item data at a specified position.
Definition: MyGUI_ListBox.cpp:932
MyGUI::ListBox::beginToItemFirst
void beginToItemFirst()
Move all elements so first becomes visible.
Definition: MyGUI_ListBox.cpp:937
MyGUI::ListBox::onKeyButtonReleased
void onKeyButtonReleased(KeyCode _key) override
Definition: MyGUI_ListBox.cpp:1086
MyGUI::UserData::getUserString
const std::string & getUserString(const std::string &_key) const
Definition: MyGUI_WidgetUserData.cpp:20
MyGUI::Align::Top
@ Top
Definition: MyGUI_Align.h:31
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:168
MyGUI::newDelegate
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
Definition: MyGUI_Delegate.h:99
MyGUI_Precompiled.h
MyGUI::ListBox::notifyMousePressed
void notifyMousePressed(Widget *_sender, int _left, int _top, MouseButton _id)
Definition: MyGUI_ListBox.cpp:235
MyGUI::ListBox::setPropertyOverride
void setPropertyOverride(const std::string &_key, const std::string &_value) override
Definition: MyGUI_ListBox.cpp:983
MyGUI::MouseButton
Definition: MyGUI_MouseButton.h:16
MyGUI::ListBox::eventListSelectAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_ListPtrSizeT > eventListSelectAccept
Definition: MyGUI_ListBox.h:196
MyGUI::ListBox::eventListChangeScroll
EventPair< EventHandle_WidgetSizeT, EventHandle_ListPtrSizeT > eventListChangeScroll
Definition: MyGUI_ListBox.h:224
MyGUI::ICroppedRectangle::mCoord
IntCoord mCoord
Definition: MyGUI_ICroppedRectangle.h:245
MyGUI::ListBox::notifyKeyButtonPressed
void notifyKeyButtonPressed(Widget *_sender, KeyCode _key, Char _char)
Definition: MyGUI_ListBox.cpp:1071
MyGUI::KeyCode::PageUp
@ PageUp
Definition: MyGUI_KeyCode.h:141
MyGUI::IBNotifyItemData::MousePressed
@ MousePressed
Definition: MyGUI_IBItemInfo.h:65
MyGUI::ListBox::setPosition
void setPosition(const IntPoint &_value) override
Definition: MyGUI_Widget.cpp:630
MyGUI::ScrollBar::getScrollRange
size_t getScrollRange() const
Definition: MyGUI_ScrollBar.cpp:603
MyGUI_InputManager.h
MyGUI::ListBox::clearIndexSelected
void clearIndexSelected()
Definition: MyGUI_ListBox.cpp:927
MyGUI::ListBox::_setItemNameAt
void _setItemNameAt(size_t _index, const UString &_name) override
Definition: MyGUI_ListBox.cpp:1054
MyGUI::Widget::setVisible
virtual void setVisible(bool _value)
Definition: MyGUI_Widget.cpp:957
MyGUI::ListBox::beginToItemSelected
void beginToItemSelected()
Move all elements so selected becomes visible.
Definition: MyGUI_ListBox.cpp:949
MyGUI::ListBox::setCoord
void setCoord(const IntCoord &_value) override
Definition: MyGUI_Widget.cpp:684
MyGUI::ListBox::_redrawItem
void _redrawItem(size_t _index)
Definition: MyGUI_ListBox.cpp:476
MyGUI::ListBox::_getItemIndex
size_t _getItemIndex(Widget *_item) override
Definition: MyGUI_ListBox.cpp:960
MyGUI_Button.h
MyGUI::types::TSize::clear
void clear()
Definition: MyGUI_TSize.h:90
MyGUI::Widget::setSize
void setSize(const IntSize &_value) override
Definition: MyGUI_Widget.cpp:647
MyGUI::ListBox::setIndexSelected
void setIndexSelected(size_t _index)
Definition: MyGUI_ListBox.cpp:629
MYGUI_ASSERT
#define MYGUI_ASSERT(exp, dest)
Definition: MyGUI_Diagnostic.h:34
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:18
MyGUI_WidgetManager.h
MyGUI::UserData::_setInternalData
void _setInternalData(Any _data)
Definition: MyGUI_WidgetUserData.cpp:59
MyGUI::ListBox::_activateItem
void _activateItem(Widget *_sender)
Definition: MyGUI_ListBox.cpp:999
MyGUI::ListBox::_setScrollView
void _setScrollView(size_t _position)
Definition: MyGUI_ListBox.cpp:811
MyGUI::KeyCode::NumpadEnter
@ NumpadEnter
Definition: MyGUI_KeyCode.h:125
MyGUI::ListBox::getIndexSelected
size_t getIndexSelected() const
Definition: MyGUI_ListBox.cpp:922
MyGUI_ScrollBar.h
MyGUI::ScrollBar::setScrollPosition
void setScrollPosition(size_t _value)
Definition: MyGUI_ScrollBar.cpp:350
MyGUI::UserData::isUserString
bool isUserString(const std::string &_key) const
Definition: MyGUI_WidgetUserData.cpp:44
MyGUI::ListBox::addItem
void addItem(const UString &_name, Any _data=Any::Null)
Add an item to the end of a array.
Definition: MyGUI_ListBox.cpp:917
MyGUI::KeyCode::ArrowUp
@ ArrowUp
Definition: MyGUI_KeyCode.h:140
MyGUI::ListBox::swapItemsAt
void swapItemsAt(size_t _index1, size_t _index2)
Swap items at a specified positions.
Definition: MyGUI_ListBox.cpp:843
MyGUI::Widget::_getClientWidget
Widget * _getClientWidget()
If there is client widget return it, otherwise return this.
Definition: MyGUI_Widget.cpp:1133
MyGUI::types::TSize< int >
MyGUI::ListBox::notifyScrollChangePosition
void notifyScrollChangePosition(ScrollBar *_sender, size_t _rel)
Definition: MyGUI_ListBox.cpp:229
MyGUI::KeyCode::Return
@ Return
Definition: MyGUI_KeyCode.h:47
MyGUI::utility::parseInt
int parseInt(const std::string &_value)
Definition: MyGUI_StringUtility.h:164
MyGUI::ListBox::eventListChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ListPtrSizeT > eventListChangePosition
Definition: MyGUI_ListBox.h:203
MyGUI::IBNotifyItemData::KeyPressed
@ KeyPressed
Definition: MyGUI_IBItemInfo.h:67
MyGUI::Widget::assignWidget
void assignWidget(T *&_widget, const std::string &_name)
Definition: MyGUI_Widget.h:329
MyGUI::ListBox::_selectIndex
void _selectIndex(size_t _index, bool _select)
Definition: MyGUI_ListBox.cpp:640
MyGUI::ListBox::updateScroll
void updateScroll()
Definition: MyGUI_ListBox.cpp:276
MyGUI::KeyCode::PageDown
@ PageDown
Definition: MyGUI_KeyCode.h:146
MyGUI::ListBox::updateLine
void updateLine(bool _reset=false)
Definition: MyGUI_ListBox.cpp:306
MyGUI::types::TCoord::width
T width
Definition: MyGUI_TCoord.h:24
MyGUI::Widget::getClientWidget
Widget * getClientWidget()
Definition: MyGUI_Widget.cpp:1289
MyGUI::ListBox::notifyMouseClick
void notifyMouseClick(Widget *_sender)
Definition: MyGUI_ListBox.cpp:243
MyGUI::WidgetInput::eventMouseSetFocus
EventHandle_WidgetWidget eventMouseSetFocus
Definition: MyGUI_WidgetInput.h:122
MyGUI::ICroppedRectangle::getTop
int getTop() const
Definition: MyGUI_ICroppedRectangle.h:104
MyGUI::ICroppedRectangle::getHeight
int getHeight() const
Definition: MyGUI_ICroppedRectangle.h:119
MyGUI::ListBox::_getItemCount
size_t _getItemCount() override
Definition: MyGUI_ListBox.cpp:1039
MyGUI::ScrollBar::setScrollRange
void setScrollRange(size_t _value)
Definition: MyGUI_ScrollBar.cpp:340
MyGUI::Widget::getVisible
bool getVisible() const
Definition: MyGUI_Widget.cpp:1249
MyGUI::ScrollBar::setScrollPage
void setScrollPage(size_t _value)
Definition: MyGUI_ScrollBar.cpp:613
MyGUI::ListBox::shutdownOverride
void shutdownOverride() override
Definition: MyGUI_ListBox.cpp:69
MyGUI::ListBox::notifyMouseLostFocus
void notifyMouseLostFocus(Widget *_sender, Widget *_new)
Definition: MyGUI_ListBox.cpp:776
MyGUI::WidgetInput::eventMouseButtonDoubleClick
EventHandle_WidgetVoid eventMouseButtonDoubleClick
Definition: MyGUI_WidgetInput.h:175
MyGUI::ListBox::eventListMouseItemActivate
EventPair< EventHandle_WidgetSizeT, EventHandle_ListPtrSizeT > eventListMouseItemActivate
Definition: MyGUI_ListBox.h:210
MyGUI::ListBox::getItemNameAt
const UString & getItemNameAt(size_t _index)
Get item name from specified position.
Definition: MyGUI_ListBox.cpp:759
MyGUI::MouseButton::Left
@ Left
Definition: MyGUI_MouseButton.h:21
MyGUI::ListBox::setActivateOnClick
void setActivateOnClick(bool activateOnClick)
Definition: MyGUI_ListBox.cpp:1093
MyGUI::IntPoint
types::TPoint< int > IntPoint
Definition: MyGUI_Types.h:26
MyGUI::IBNotifyItemData
Definition: MyGUI_IBItemInfo.h:62
MyGUI::ListBox::_resetContainer
void _resetContainer(bool _update) override
Definition: MyGUI_ListBox.cpp:970
MYGUI_ASSERT_RANGE_INSERT
#define MYGUI_ASSERT_RANGE_INSERT(index, size, owner)
Definition: MyGUI_Diagnostic.h:47
MyGUI::types::TCoord< int >
MyGUI::IBNotifyItemData::KeyReleased
@ KeyReleased
Definition: MyGUI_IBItemInfo.h:68
MyGUI::WidgetManager::unlinkFromUnlinkers
void unlinkFromUnlinkers(Widget *_widget)
Definition: MyGUI_WidgetManager.cpp:146
MyGUI::UserData::_getInternalData
ValueType * _getInternalData(bool _throw=true) const
Definition: MyGUI_WidgetUserData.h:54
MyGUI::Widget::_setContainer
void _setContainer(Widget *_value)
Definition: MyGUI_Widget.cpp:1309
MyGUI::ICroppedRectangle::getWidth
int getWidth() const
Definition: MyGUI_ICroppedRectangle.h:114
MyGUI::ListBox::setScrollVisible
void setScrollVisible(bool _visible)
Set scroll visible when it needed.
Definition: MyGUI_ListBox.cpp:791
MyGUI::WidgetInput::eventMouseWheel
EventHandle_WidgetInt eventMouseWheel
Definition: MyGUI_WidgetInput.h:145
MyGUI::ICroppedRectangle::getLeft
int getLeft() const
Definition: MyGUI_ICroppedRectangle.h:94
MyGUI::ListBox::setItemNameAt
void setItemNameAt(size_t _index, const UString &_name)
Replace an item name at a specified position.
Definition: MyGUI_ListBox.cpp:745
MyGUI::Any::Null
static AnyEmpty Null
Definition: MyGUI_Any.h:67
MyGUI::ListBox::isItemVisibleAt
bool isItemVisibleAt(size_t _index, bool _fill=true)
Definition: MyGUI_ListBox.cpp:685
MyGUI::ListBox::_addItem
void _addItem(const MyGUI::UString &_name) override
Definition: MyGUI_ListBox.cpp:1044
MyGUI::ListBox::getItemCount
size_t getItemCount() const
Get number of items.
Definition: MyGUI_ListBox.cpp:912
MyGUI::types::TCoord::height
T height
Definition: MyGUI_TCoord.h:25
MyGUI
Definition: MyGUI_ActionController.h:15
MyGUI::ListBox::onKeyButtonPressed
void onKeyButtonPressed(KeyCode _key, Char _char) override
Definition: MyGUI_ListBox.cpp:83
MyGUI::ListBox::_setItemFocus
void _setItemFocus(size_t _position, bool _focus)
Definition: MyGUI_ListBox.cpp:785
MyGUI::ListBox::onMouseWheel
void onMouseWheel(int _rel) override
Definition: MyGUI_ListBox.cpp:76
MyGUI::ScrollBar::getScrollPosition
size_t getScrollPosition() const
Definition: MyGUI_ScrollBar.cpp:608
MyGUI::ListBox::findItemIndexWith
size_t findItemIndexWith(const UString &_name)
Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found.
Definition: MyGUI_ListBox.cpp:897
MyGUI::ListBox::ListBox
ListBox()
Definition: MyGUI_ListBox.cpp:18
MyGUI_ResourceSkin.h
MyGUI::ListBox::eventListMouseItemFocus
EventPair< EventHandle_WidgetSizeT, EventHandle_ListPtrSizeT > eventListMouseItemFocus
Definition: MyGUI_ListBox.h:217
MyGUI::KeyCode
Definition: MyGUI_KeyCode.h:16
MyGUI::WidgetInput::eventMouseButtonClick
EventHandle_WidgetVoid eventMouseButtonClick
Definition: MyGUI_WidgetInput.h:169