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