32 mButtonDefaultWidth(1),
34 mButtonAutoWidth(true),
44 Base::initialiseOverride();
51 mOffsetTab = utility::parseValue<int>(
getUserString(
"OffsetBar"));
59 if (mWidgetBar !=
nullptr)
66 if (mButtonLeft !=
nullptr)
73 if (mButtonRight !=
nullptr)
80 if (mButtonDecor !=
nullptr)
87 if (mItemTemplate !=
nullptr)
92 #ifndef MYGUI_DONT_USE_OBSOLETE 93 if (mItemTemplate ==
nullptr)
96 if (mItemTemplate !=
nullptr)
101 #endif // MYGUI_DONT_USE_OBSOLETE 104 Widget* showPatch =
nullptr;
106 if (showPatch !=
nullptr)
108 mWidgetsPatch.push_back(showPatch);
121 if (mEmpty ==
nullptr)
136 mWidgetsPatch.clear();
137 mWidgetBar =
nullptr;
138 mButtonLeft =
nullptr;
139 mButtonRight =
nullptr;
140 mButtonDecor =
nullptr;
141 mItemTemplate =
nullptr;
142 mEmptyBarWidget =
nullptr;
144 mHeaderPlace =
nullptr;
151 Base::shutdownOverride();
156 Base::onWidgetCreated(_widget);
159 if (child !=
nullptr)
174 size_t lastIndex = mItemsInfo.size() - 1;
180 return widget->castType<
TabItem>();
188 if (_index1 != _index2)
190 std::swap(mItemsInfo[_index1], mItemsInfo[_index2]);
197 Base::setPosition(_point);
204 Base::setSize(_size);
211 Base::setCoord(_coord);
218 if (_sender == mButtonLeft)
226 else if (_sender == mButtonRight)
228 if ((mStartIndex + 1) < mItemsInfo.size())
241 if (select == mIndexSelect)
247 size_t old = mIndexSelect;
248 mIndexSelect = select;
251 for (
size_t pos = 0; pos < mItemButton.size(); pos++)
253 Button* button = mItemButton[count]->castType<
Button>();
268 _showItem(mItemsInfo[mIndexSelect].item,
true, mSmoothShow);
269 _showItem(mItemsInfo[old].item,
false, mSmoothShow);
279 if (_getWidgetBar()->
getWidth() < 1)
282 if (_index == mStartIndex)
284 else if (_index < mStartIndex)
286 mStartIndex = _index;
293 for (
size_t pos = mStartIndex; pos <= _index; pos++)
295 width += mItemsInfo[pos].width;
300 while ((mStartIndex < _index) && (width > _getWidgetBar()->
getWidth()))
302 width -= mItemsInfo[mStartIndex].width;
313 mButtonDefaultWidth = _width;
314 if (mButtonDefaultWidth < 1)
315 mButtonDefaultWidth = 1;
321 mButtonAutoWidth = _auto;
323 for (
size_t pos = 0; pos < mItemsInfo.size(); pos++)
326 if (mButtonAutoWidth)
329 width = mButtonDefaultWidth;
331 mWidthBar += width - mItemsInfo[pos].width;
332 mItemsInfo[pos].width = width;
344 if (mButtonAutoWidth)
347 _width = mButtonDefaultWidth;
350 mWidthBar += _width - mItemsInfo[_index].width;
351 mItemsInfo[_index].width = _width;
359 mItemsInfo[_index].name = _name;
362 if (mButtonAutoWidth)
365 width = mButtonDefaultWidth;
367 mWidthBar += width - mItemsInfo[_index].width;
368 mItemsInfo[_index].width = width;
376 if (mIndexSelect == _index)
378 size_t old = mIndexSelect;
379 mIndexSelect = _index;
386 _showItem(mItemsInfo[mIndexSelect].item,
true, mSmoothShow);
387 _showItem(mItemsInfo[old].item,
false, mSmoothShow);
423 Button* TabControl::createButton()
426 if (mWidgetBar !=
nullptr)
428 else if (mHeaderPlace !=
nullptr)
429 parent = mHeaderPlace;
436 Button* button = createButton();
439 mItemButton.push_back(button);
444 if (mItemButton.empty())
447 UString save = mItemButton[0]->getCaption();
448 mItemButton[0]->setCaption(_text);
454 mItemButton[0]->setCaption(save);
456 return size.
width + mItemButton[0]->getWidth() - coord.
width;
467 mWidthBar -= mItemsInfo[index].width;
468 mItemsInfo.erase(mItemsInfo.begin() + index);
470 if (mItemsInfo.empty())
474 if (index < mIndexSelect)
476 else if (index == mIndexSelect)
478 if (mIndexSelect == mItemsInfo.size())
480 mItemsInfo[mIndexSelect].item->setVisible(
true);
481 mItemsInfo[mIndexSelect].item->setAlpha(
ALPHA_MAX);
491 _index = mItemsInfo.size();
494 int width = (mButtonAutoWidth ?
_getTextWidth(_name) : mButtonDefaultWidth);
497 mItemsInfo.insert(mItemsInfo.begin() + _index,
TabItemInfo(width, _name, _sheet, _data));
500 if (1 == mItemsInfo.size())
505 if (_index <= mIndexSelect)
515 mItemsInfo[_index].data = _data;
521 return mItemsInfo[_index].width;
527 return mItemsInfo[_index].name;
533 return mItemsInfo[_index].item;
544 while (!mItemsInfo.empty())
550 ControllerFadeAlpha* TabControl::createControllerFadeAlpha(
float _alpha,
float _coef,
bool _enable)
564 for (
size_t pos = 0; pos < mItemsInfo.size(); pos++)
566 if (mItemsInfo[pos].item == _item)
569 MYGUI_EXCEPT(
"item (" << _item <<
") not found, source 'TabControl::getItemIndex'");
574 for (
size_t pos = 0; pos < mItemsInfo.size(); pos++)
576 if (mItemsInfo[pos].item == _item)
584 for (
size_t pos = 0; pos < mItemsInfo.size(); pos++)
586 if (mItemsInfo[pos].name == _name)
594 for (
size_t pos = 0; pos < mItemsInfo.size(); pos++)
596 if (mItemsInfo[pos].name == _name)
597 return mItemsInfo[pos].item;
607 Widget* TabControl::_getWidgetTemplate()
609 return mItemTemplate ==
nullptr ? this : mItemTemplate;
612 Widget* TabControl::_getWidgetBar()
614 return mWidgetBar ==
nullptr ? this : mWidgetBar;
620 if (_key ==
"ButtonWidth")
624 else if (_key ==
"ButtonAutoWidth")
628 else if (_key ==
"SmoothShow")
632 else if (_key ==
"SelectItem")
637 Base::setPropertyOverride(_key, _value);
661 return mItemsInfo.size();
749 return mButtonDefaultWidth;
754 return mButtonAutoWidth;
759 mSmoothShow = _value;
799 if (mHeaderPlace !=
nullptr)
805 void TabControl::updateBarOld()
808 if (_getWidgetBar()->
getWidth() < 1)
811 if ((_getWidgetBar()->
getWidth() < mWidthBar) && (1 < mItemsInfo.size()))
817 if (
nullptr != mButtonLeft)
819 if (
nullptr != mButtonRight)
821 if (
nullptr != mButtonDecor)
823 for (VectorWidgetPtr::iterator iter = mWidgetsPatch.begin(); iter != mWidgetsPatch.end(); ++iter)
824 (*iter)->setVisible(
true);
825 if (mWidgetBar !=
nullptr)
834 if (
nullptr != mButtonLeft)
836 if (
nullptr != mButtonRight)
838 if (
nullptr != mButtonDecor)
840 for (VectorWidgetPtr::iterator iter = mWidgetsPatch.begin(); iter != mWidgetsPatch.end(); ++iter)
841 (*iter)->setVisible(
false);
842 if (mWidgetBar !=
nullptr)
852 for (
size_t pos = mStartIndex; pos < mItemsInfo.size(); pos++)
853 width += mItemsInfo[pos].width;
856 while ((mStartIndex > 0) && ((width + mItemsInfo[mStartIndex - 1].width) <= _getWidgetBar()->
getWidth()))
859 width += mItemsInfo[mStartIndex].width;
866 size_t pos = mStartIndex;
867 for (; pos < mItemsInfo.size(); pos++)
870 if (width > _getWidgetBar()->
getWidth())
881 if (count >= mItemButton.size())
885 Button* button = mItemButton[count]->castType<
Button>();
903 while (count < mItemButton.size())
905 mItemButton[count]->setVisible(
false);
910 if (pos == mItemsInfo.size())
914 if (mEmptyBarWidget !=
nullptr)
917 if (width < _getWidgetBar()->
getWidth())
929 if (mStartIndex == 0)
931 if (
nullptr != mButtonLeft)
936 if (
nullptr != mButtonLeft)
942 if (
nullptr != mButtonRight)
947 if (
nullptr != mButtonRight)
952 void TabControl::updateBarNew()
954 if (mHeaderPlace ==
nullptr)
961 int widthControls = 0;
962 if (mControls !=
nullptr)
963 widthControls = mControls->
getWidth();
965 if ((mHeaderPlace->
getWidth() < mWidthBar) && (1 < mItemsInfo.size()) && (mHeaderPlace->
getWidth() >= widthControls))
971 if (
nullptr != mControls)
975 if (mControls !=
nullptr)
984 if (
nullptr != mControls)
996 for (
size_t pos = mStartIndex; pos < mItemsInfo.size(); pos++)
997 width += mItemsInfo[pos].width;
1000 while ((mStartIndex > 0) && ((width + mItemsInfo[mStartIndex - 1].width) <= (mHeaderPlace->
getWidth() - widthControls)))
1003 width += mItemsInfo[mStartIndex].width;
1010 size_t pos = mStartIndex;
1011 for (; pos < mItemsInfo.size(); pos++)
1014 if (width > (mHeaderPlace->
getWidth() - widthControls))
1019 if ((width + info.
width) > (mHeaderPlace->
getWidth() - widthControls))
1025 if (count >= mItemButton.size())
1029 Button* button = mItemButton[count];
1042 width += info.
width;
1047 while (count < mItemButton.size())
1049 mItemButton[count]->setVisible(
false);
1054 if (pos == mItemsInfo.size())
1057 if (mEmpty !=
nullptr)
1064 if (mStartIndex == 0)
1066 if (
nullptr != mButtonLeft)
1071 if (
nullptr != mButtonLeft)
1077 if (
nullptr != mButtonRight)
1082 if (
nullptr != mButtonRight)
void addItem(Widget *_widget, ControllerItem *_item)
virtual void onWidgetCreated(Widget *_widget)
void removeItemAt(size_t _index)
Remove item at a specified position.
virtual void _addItem(const MyGUI::UString &_name)
TabItem properties. TabItem_skin_childs Skin childs. TabItem widget description should be here...
TabItem * findItemWith(const UString &_name)
Search item, returns the item of the first occurrence in array or nullptr if item not found...
int _getTextWidth(const UString &_text)
types::TSize< int > IntSize
void _notifyDeleteItem(TabItem *_item)
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
delegates::IDelegate0 * newDelegate(void(*_func)())
virtual size_t _getItemCount()
static ControllerManager & getInstance()
void setButtonDefaultWidth(int _value)
void _insertItem(size_t _index, const UString &_name, TabItem *_sheet, Any _data)
void setButtonWidth(TabItem *_item, int _width=DEFAULT)
Set button width.
void setItemNameAt(size_t _index, const UString &_name)
Replace an item name at a specified position.
size_t findItemIndex(TabItem *_item)
Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found...
void beginToItemAt(size_t _index)
Move all elements so specified becomes visible.
bool getSmoothShow() const
const std::string & getUserString(const std::string &_key) const
TabItem * insertItemAt(size_t _index, const UString &_name, Any _data=Any::Null)
Insert an item into a array at a specified position.
virtual void setCaption(const UString &_value)
int getAbsoluteTop() const
void swapItems(size_t _index1, size_t _index2)
void setSmoothShow(bool _value)
void setItemDataAt(size_t _index, Any _data)
Replace an item data at a specified position.
void beginToItemLast()
Move all elements so last becomes visible.
int getButtonWidth(TabItem *_item)
Get button width.
virtual void setCoord(const IntCoord &_value)
virtual void setPosition(const IntPoint &_value)
void removeItem(TabItem *_item)
Remove item.
types::TCoord< int > IntCoord
static const std::string & getClassTypeName()
const UString & getItemNameAt(size_t _index)
Get item name from specified position.
virtual const UString & getCaption()
void removeAllItems()
Remove all items.
EventPairAddParameter< EventHandle_WidgetPtr, EventHandle_WidgetPtrControllerItemPtr > eventPostAction
TabItem * insertItem(TabItem *_to, const UString &_name, Any _data=Any::Null)
Insert an item into a array.
void setButtonWidthAt(size_t _index, int _width=DEFAULT)
Set button width at a specified position.
#define MYGUI_EXCEPT(dest)
void setButtonAutoWidth(bool _value)
void setItemData(TabItem *_item, Any _data)
Replace an item data.
static const std::string & getClassTypeName()
void setItemName(TabItem *_item, const UString &_name)
Replace an item name.
void notifyPressedButtonEvent(MyGUI::Widget *_sender)
int getAbsoluteLeft() const
void setAlpha(float _value)
void _setInternalData(Any _data)
void setCoef(float _value)
TabItem * getItemAt(size_t _index)
Get item from specified position.
const UString & getItemName(TabItem *_item)
Get item name.
virtual Widget * _getItemAt(size_t _index)
bool isUserString(const std::string &_key) const
void beginToItemFirst()
Move all elements so first becomes visible.
void _showItem(TabItem *_sheet, bool _show, bool _smooth)
TabItem * getItemSelected()
Get selected item (nullptr if none selected)
void setEnabled(bool _value)
virtual void _removeItemAt(size_t _index)
int getButtonWidthAt(size_t _index)
Get button width at a specified position.
Type * castType(bool _throw=true)
TabItem * addItem(const UString &_name, Any _data=Any::Null)
Add an item to the end of a array.
size_t getItemIndex(TabItem *_item)
Get item index.
virtual void _setItemNameAt(size_t _index, const UString &_name)
void removeItem(Widget *_widget)
void notifyPressedBarButtonEvent(MyGUI::Widget *_sender)
virtual void setSize(const IntSize &_value)
#define MYGUI_ASSERT_RANGE(index, size, owner)
size_t findItemIndexWith(const UString &_name)
Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found...
size_t getIndexSelected() const
Get index of selected item (ITEM_NONE if none selected)
virtual void initialiseOverride()
EventPair< EventHandle_WidgetSizeT, EventHandle_TabPtrSizeT > eventTabChangeSelect
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
void setItemSelected(TabItem *_item)
Select item.
const float TAB_SPEED_FADE_COEF
int getButtonDefaultWidth() const
size_t getItemCount() const
Get number of items.
virtual IntSize getTextSize()
virtual void shutdownOverride()
void clearItemDataAt(size_t _index)
Clear an item data at a specified position.
bool getButtonAutoWidth() const
virtual const UString & _getItemNameAt(size_t _index)
ValueType * _getInternalData(bool _throw=true) const
void setIndexSelected(size_t _index)
Select specified _index.
void beginToItem(TabItem *_item)
Move all elements so specified becomes visible.
#define MYGUI_ASSERT_RANGE_INSERT(index, size, owner)
void beginToItemSelected()
Move all elements so selected becomes visible.
void clearItemData(TabItem *_item)
Clear an item data.
const IntCoord & getCoord() const
ControllerItem * createItem(const std::string &_type)
types::TPoint< int > IntPoint