00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_Tab.h"
00025 #include "MyGUI_ControllerManager.h"
00026 #include "MyGUI_WidgetManager.h"
00027 #include "MyGUI_Button.h"
00028 #include "MyGUI_TabItem.h"
00029 #include "MyGUI_ResourceSkin.h"
00030
00031 namespace MyGUI
00032 {
00033
00034 const float TAB_SPEED_FADE_COEF = 5.0f;
00035
00036 Tab::Tab() :
00037 mOffsetTab(0),
00038 mButtonShow(false),
00039 mWidthBar(0),
00040 mWidgetBar(nullptr),
00041 mButtonLeft(nullptr),
00042 mButtonRight(nullptr),
00043 mButtonList(nullptr),
00044 mButtonDecor(nullptr),
00045 mEmptyBarWidget(nullptr),
00046 mItemTemplate(nullptr),
00047 mStartIndex(0),
00048 mIndexSelect(ITEM_NONE),
00049 mButtonDefaultWidth(1),
00050 mSmoothShow(true),
00051 mButtonAutoWidth(true),
00052 mShutdown(false)
00053 {
00054 }
00055
00056 void Tab::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
00057 {
00058 Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
00059
00060 initialiseWidgetSkin(_info);
00061 }
00062
00063 Tab::~Tab()
00064 {
00065 mShutdown = true;
00066 shutdownWidgetSkin();
00067 }
00068
00069 void Tab::baseChangeWidgetSkin(ResourceSkin* _info)
00070 {
00071 shutdownWidgetSkin();
00072 Base::baseChangeWidgetSkin(_info);
00073 initialiseWidgetSkin(_info);
00074 }
00075
00076 void Tab::initialiseWidgetSkin(ResourceSkin* _info)
00077 {
00078
00079 const MapString& properties = _info->getProperties();
00080 if (false == properties.empty())
00081 {
00082 MapString::const_iterator iter = properties.find("OffsetBar");
00083 if (iter != properties.end()) mOffsetTab = utility::parseInt(iter->second);
00084
00085 iter = properties.find("ButtonSkin");
00086 if (iter != properties.end()) mButtonSkinName = iter->second;
00087 iter = properties.find("EmptyBarSkin");
00088 if (iter != properties.end()) mEmptySkinName = iter->second;
00089 }
00090
00091 for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
00092 {
00093 if (*(*iter)->_getInternalData<std::string>() == "Bar")
00094 {
00095 MYGUI_DEBUG_ASSERT( ! mWidgetBar, "widget already assigned");
00096 mWidgetBar = (*iter);
00097 }
00098 else if (*(*iter)->_getInternalData<std::string>() == "Left")
00099 {
00100 MYGUI_DEBUG_ASSERT( ! mButtonLeft, "widget already assigned");
00101 mButtonLeft = (*iter)->castType<Button>();
00102 mButtonLeft->setVisible(false);
00103 mButtonLeft->eventMouseButtonClick = newDelegate(this, &Tab::notifyPressedButtonEvent);
00104 }
00105 else if (*(*iter)->_getInternalData<std::string>() == "Right")
00106 {
00107 MYGUI_DEBUG_ASSERT( ! mButtonRight, "widget already assigned");
00108 mButtonRight = (*iter)->castType<Button>();
00109 mButtonRight->setVisible(false);
00110 mButtonRight->eventMouseButtonClick = newDelegate(this, &Tab::notifyPressedButtonEvent);
00111 }
00112 else if (*(*iter)->_getInternalData<std::string>() == "List")
00113 {
00114 MYGUI_DEBUG_ASSERT( ! mButtonList, "widget already assigned");
00115 mButtonList = (*iter)->castType<Button>();
00116 mButtonList->setVisible(false);
00117 mButtonList->eventMouseButtonClick = newDelegate(this, &Tab::notifyPressedButtonEvent);
00118 }
00119 else if (*(*iter)->_getInternalData<std::string>() == "ButtonDecor")
00120 {
00121 MYGUI_DEBUG_ASSERT( ! mButtonDecor, "widget already assigned");
00122 mButtonDecor = *iter;
00123 mButtonDecor->setVisible(false);
00124 }
00125 else if (*(*iter)->_getInternalData<std::string>() == "ShowPatch")
00126 {
00127 mWidgetsPatch.push_back((*iter));
00128 (*iter)->setVisible(false);
00129 }
00130 else if ((*(*iter)->_getInternalData<std::string>() == "Sheet") || (*(*iter)->_getInternalData<std::string>() == "TabItem"))
00131 {
00132 MYGUI_DEBUG_ASSERT( ! mItemTemplate, "widget already assigned");
00133 mItemTemplate = (*iter);
00134 mItemTemplate->setVisible(false);
00135 }
00136 }
00137 MYGUI_ASSERT(nullptr != mWidgetBar, "Child Widget Bar not found in skin (Tab must have Bar)");
00138 MYGUI_ASSERT(nullptr != mItemTemplate, "Child Widget TabItem not found in skin (Tab must have TabItem (Sheet) )");
00139
00140
00141 mEmptyBarWidget = mWidgetBar->createWidget<Widget>(mEmptySkinName, IntCoord(), Align::Left | Align::Top);
00142
00143 updateBar();
00144 }
00145
00146 void Tab::shutdownWidgetSkin()
00147 {
00148 mWidgetsPatch.clear();
00149 mWidgetBar = nullptr;
00150 mButtonLeft = nullptr;
00151 mButtonRight = nullptr;
00152 mButtonList = nullptr;
00153 mButtonDecor = nullptr;
00154 mItemTemplate = nullptr;
00155 mEmptyBarWidget = nullptr;
00156 }
00157
00158
00159
00160 WidgetPtr Tab::baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name)
00161 {
00162 if ((TabItem::getClassTypeName() == _type) || ("Sheet" == _type))
00163 {
00164 TabItemPtr sheet = static_cast<TabItemPtr>(Base::baseCreateWidget(_style, TabItem::getClassTypeName(), "Default", mItemTemplate->getCoord(), mItemTemplate->getAlign(), "", _name));
00165 _insertItem(ITEM_NONE, _name, sheet, Any::Null);
00166
00167 return sheet;
00168 }
00169 return Base::baseCreateWidget(_style, _type, _skin, _coord, _align, _layer, _name);
00170 }
00171
00172 TabItemPtr Tab::insertItemAt(size_t _index, const UString& _name, Any _data)
00173 {
00174 MYGUI_ASSERT_RANGE_INSERT(_index, mItemsInfo.size(), "Tab::insertItem");
00175
00176 TabItemPtr sheet = static_cast<TabItemPtr>(Base::baseCreateWidget(WidgetStyle::Child, TabItem::getClassTypeName(), "Default", mItemTemplate->getCoord(), mItemTemplate->getAlign(), "", ""));
00177 _insertItem(_index, _name, sheet, _data);
00178
00179 return sheet;
00180 }
00181
00182 void Tab::setPosition(const IntPoint& _point)
00183 {
00184 Base::setPosition(_point);
00185
00186 updateBar();
00187 }
00188
00189 void Tab::setSize(const IntSize& _size)
00190 {
00191 Base::setSize(_size);
00192
00193 updateBar();
00194 }
00195
00196 void Tab::setCoord(const IntCoord& _coord)
00197 {
00198 Base::setCoord(_coord);
00199
00200 updateBar();
00201 }
00202
00203 void Tab::updateBar()
00204 {
00205
00206 if (mWidgetBar->getWidth() < 1) return;
00207
00208 if ((mWidgetBar->getWidth() < mWidthBar) && (1 < mItemsInfo.size()))
00209 {
00210 if (false == mButtonShow)
00211 {
00212 mButtonShow = true;
00213 if (nullptr != mButtonLeft) mButtonLeft->setVisible(true);
00214 if (nullptr != mButtonRight) mButtonRight->setVisible(true);
00215 if (nullptr != mButtonList) mButtonList->setVisible(true);
00216 if (nullptr != mButtonDecor) mButtonDecor->setVisible(true);
00217 for (VectorWidgetPtr::iterator iter=mWidgetsPatch.begin(); iter!=mWidgetsPatch.end(); ++iter) (*iter)->setVisible(true);
00218 mWidgetBar->setSize(mWidgetBar->getWidth() - mOffsetTab, mWidgetBar->getHeight());
00219 }
00220 }
00221 else
00222 {
00223 if (mButtonShow)
00224 {
00225 mButtonShow = false;
00226 if (nullptr != mButtonLeft) mButtonLeft->setVisible(false);
00227 if (nullptr != mButtonRight) mButtonRight->setVisible(false);
00228 if (nullptr != mButtonList) mButtonList->setVisible(false);
00229 if (nullptr != mButtonDecor) mButtonDecor->setVisible(false);
00230 for (VectorWidgetPtr::iterator iter=mWidgetsPatch.begin(); iter!=mWidgetsPatch.end(); ++iter) (*iter)->setVisible(false);
00231 mWidgetBar->setSize(mWidgetBar->getWidth() + mOffsetTab, mWidgetBar->getHeight());
00232 }
00233 }
00234
00235
00236 if (mStartIndex > 0)
00237 {
00238
00239 int width = 0;
00240 for (size_t pos=mStartIndex; pos<mItemsInfo.size(); pos++) width += mItemsInfo[pos].width;
00241
00242
00243 while ((mStartIndex > 0) && ((width + mItemsInfo[mStartIndex-1].width) <= mWidgetBar->getWidth()))
00244 {
00245 mStartIndex--;
00246 width += mItemsInfo[mStartIndex].width;
00247 }
00248 }
00249
00250
00251 int width = 0;
00252 size_t count = 0;
00253 size_t pos=mStartIndex;
00254 for (; pos<mItemsInfo.size(); pos++)
00255 {
00256
00257 if (width > mWidgetBar->getWidth()) break;
00258
00259
00260 TabItemInfo& info = mItemsInfo[pos];
00261 if ((width + info.width) > mWidgetBar->getWidth())
00262 {
00263 break;
00264 }
00265
00266
00267 if (count >= mItemButton.size()) _createItemButton();
00268
00269
00270 ButtonPtr button = mItemButton[count]->castType<Button>();
00271 button->setVisible(true);
00272
00273
00274 button->setButtonPressed(pos == mIndexSelect);
00275
00276 if (button->getCaption() != info.name)
00277 button->setCaption(info.name);
00278
00279 IntCoord coord(width, 0, info.width, mWidgetBar->getHeight());
00280 if (coord != button->getCoord())
00281 button->setCoord(coord);
00282
00283 width += info.width;
00284 count ++;
00285 }
00286
00287
00288 while (count < mItemButton.size())
00289 {
00290 mItemButton[count]->setVisible(false);
00291 count ++;
00292 }
00293
00294 bool right = true;
00295 if (pos == mItemsInfo.size()) right = false;
00296
00297
00298 if (width < mWidgetBar->getWidth())
00299 {
00300 mEmptyBarWidget->setVisible(true);
00301 mEmptyBarWidget->setCoord(width, 0, mWidgetBar->getWidth() - width, mWidgetBar->getHeight());
00302 }
00303 else
00304 {
00305 mEmptyBarWidget->setVisible(false);
00306 }
00307
00308
00309 if (mStartIndex == 0)
00310 {
00311 if (nullptr != mButtonLeft) mButtonLeft->setEnabled(false);
00312 }
00313 else
00314 {
00315 if (nullptr != mButtonLeft) mButtonLeft->setEnabled(true);
00316 }
00317
00318 if (right)
00319 {
00320 if (nullptr != mButtonRight) mButtonRight->setEnabled(true);
00321 }
00322 else
00323 {
00324 if (nullptr != mButtonRight) mButtonRight->setEnabled(false);
00325 }
00326
00327 }
00328
00329 void Tab::notifyPressedButtonEvent(MyGUI::WidgetPtr _sender)
00330 {
00331 if (_sender == mButtonLeft)
00332 {
00333 if (mStartIndex > 0)
00334 {
00335 mStartIndex --;
00336 updateBar();
00337 }
00338 }
00339 else if (_sender == mButtonRight)
00340 {
00341 if ((mStartIndex+1) < mItemsInfo.size())
00342 {
00343 mStartIndex ++;
00344
00345 updateBar();
00346 }
00347 }
00348 else if (_sender == mButtonList)
00349 {
00350 }
00351 }
00352
00353 void Tab::notifyPressedBarButtonEvent(MyGUI::WidgetPtr _sender)
00354 {
00355 size_t select = *_sender->_getInternalData<size_t>() + mStartIndex;
00356
00357 if (select == mIndexSelect)
00358 {
00359
00360 beginToItemSelected();
00361 return;
00362 }
00363 size_t old = mIndexSelect;
00364 mIndexSelect = select;
00365
00366 size_t count = 0;
00367 for (size_t pos=0; pos<mItemButton.size(); pos++)
00368 {
00369 ButtonPtr button = mItemButton[count]->castType<Button>();
00370 if (button->isVisible())
00371 {
00372
00373 button->setButtonPressed((pos + mStartIndex) == mIndexSelect);
00374 }
00375 count ++;
00376 }
00377
00378
00379 beginToItemSelected();
00380
00381
00382 _forcePeek(mItemsInfo[mIndexSelect].item);
00383
00384 _showItem(mItemsInfo[mIndexSelect].item, true, mSmoothShow);
00385 _showItem(mItemsInfo[old].item, false, mSmoothShow);
00386
00387 eventTabChangeSelect(this, mIndexSelect);
00388 }
00389
00390 void Tab::beginToItemAt(size_t _index)
00391 {
00392 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::beginToItemAt");
00393
00394
00395 if (mWidgetBar->getWidth() < 1) return;
00396
00397 if (_index == mStartIndex) return;
00398 else if (_index < mStartIndex)
00399 {
00400 mStartIndex = _index;
00401 updateBar();
00402 }
00403 else
00404 {
00405
00406 int width = 0;
00407 for (size_t pos=mStartIndex; pos<=_index; pos++)
00408 {
00409 width += mItemsInfo[pos].width;
00410 }
00411
00412
00413 bool change = false;
00414 while ((mStartIndex < _index) && (width > mWidgetBar->getWidth()))
00415 {
00416 width -= mItemsInfo[mStartIndex].width;
00417 mStartIndex ++;
00418 change = true;
00419 }
00420 if (change) updateBar();
00421
00422 }
00423 }
00424
00425 void Tab::setButtonDefaultWidth(int _width)
00426 {
00427 mButtonDefaultWidth = _width;
00428 if (mButtonDefaultWidth < 1) mButtonDefaultWidth = 1;
00429 setButtonAutoWidth(false);
00430 }
00431
00432 void Tab::setButtonAutoWidth(bool _auto)
00433 {
00434 mButtonAutoWidth = _auto;
00435
00436 for (size_t pos=0; pos<mItemsInfo.size(); pos++)
00437 {
00438 int width;
00439 if (mButtonAutoWidth) width = _getTextWidth(mItemsInfo[pos].name);
00440 else width = mButtonDefaultWidth;
00441
00442 mWidthBar += width - mItemsInfo[pos].width;
00443 mItemsInfo[pos].width = width;
00444 }
00445
00446 updateBar();
00447 }
00448
00449 void Tab::setButtonWidthAt(size_t _index, int _width)
00450 {
00451 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::setButtonWidthAt");
00452
00453 if (_width <= 0)
00454 {
00455 if (mButtonAutoWidth) _width = _getTextWidth(mItemsInfo[_index].name);
00456 else _width = mButtonDefaultWidth;
00457 }
00458
00459 mWidthBar += _width - mItemsInfo[_index].width;
00460 mItemsInfo[_index].width = _width;
00461
00462 updateBar();
00463 }
00464
00465 void Tab::setItemNameAt(size_t _index, const UString& _name)
00466 {
00467 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::setItemNameAt");
00468 mItemsInfo[_index].name = _name;
00469
00470 int width;
00471 if (mButtonAutoWidth) width = _getTextWidth(_name);
00472 else width = mButtonDefaultWidth;
00473
00474 mWidthBar += width - mItemsInfo[_index].width;
00475 mItemsInfo[_index].width = width;
00476
00477 updateBar();
00478 }
00479
00480 void Tab::setIndexSelected(size_t _index)
00481 {
00482 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::setIndexSelected");
00483 if (mIndexSelect == _index) return;
00484 size_t old = mIndexSelect;
00485 mIndexSelect = _index;
00486 updateBar();
00487
00488
00489 if (mSmoothShow) _forcePeek(mItemsInfo[mIndexSelect].item);
00490
00491 _showItem(mItemsInfo[mIndexSelect].item, true, mSmoothShow);
00492 _showItem(mItemsInfo[old].item, false, mSmoothShow);
00493
00494 beginToItemSelected();
00495 }
00496
00497 void Tab::actionWidgetHide(WidgetPtr _widget)
00498 {
00499 _widget->setVisible(false);
00500 _widget->setEnabled(true);
00501 }
00502
00503 void Tab::_showItem(TabItemPtr _item, bool _show, bool _smooth)
00504 {
00505 if (false == _smooth)
00506 {
00507 ControllerManager::getInstance().removeItem(_item);
00508 _item->setAlpha(ALPHA_MAX);
00509
00510 _item->setVisible(_show);
00511
00512 return;
00513 }
00514
00515 if (_show)
00516 {
00517 ControllerFadeAlpha* controller = createControllerFadeAlpha(ALPHA_MAX, TAB_SPEED_FADE_COEF, true);
00518 ControllerManager::getInstance().addItem(_item, controller);
00519 }
00520 else
00521 {
00522 ControllerFadeAlpha* controller = createControllerFadeAlpha(ALPHA_MIN, TAB_SPEED_FADE_COEF, false);
00523 controller->eventPostAction = newDelegate(this, &Tab::actionWidgetHide);
00524 ControllerManager::getInstance().addItem(_item, controller);
00525 }
00526 }
00527
00528 void Tab::_createItemButton()
00529 {
00530 ButtonPtr button = mWidgetBar->createWidget<Button>(mButtonSkinName, IntCoord(), Align::Left | Align::Top);
00531 button->eventMouseButtonClick = newDelegate(this, &Tab::notifyPressedBarButtonEvent);
00532 button->_setInternalData(mItemButton.size());
00533 mItemButton.push_back(button);
00534 }
00535
00536 int Tab::_getTextWidth(const UString& _text)
00537 {
00538 if (0 == mItemButton.size()) _createItemButton();
00539
00540 UString save = mItemButton[0]->getCaption();
00541 mItemButton[0]->setCaption(_text);
00542
00543 ISubWidgetText* text = mItemButton[0]->getSubWidgetText();
00544 const IntSize& size = text ? text->getTextSize() : IntSize();
00545 const IntCoord& coord = text ? text->getCoord() : IntCoord();
00546
00547 mItemButton[0]->setCaption(save);
00548
00549 return size.width + mItemButton[0]->getWidth() - coord.width;
00550 }
00551
00552 void Tab::_notifyDeleteItem(TabItemPtr _sheet)
00553 {
00554
00555 if (mShutdown) return;
00556
00557 size_t index = getItemIndex(_sheet);
00558
00559 mWidthBar -= mItemsInfo[index].width;
00560 mItemsInfo.erase(mItemsInfo.begin() + index);
00561
00562 if (0 == mItemsInfo.size()) mIndexSelect = ITEM_NONE;
00563 else
00564 {
00565 if (index < mIndexSelect) mIndexSelect --;
00566 else if (index == mIndexSelect)
00567 {
00568 if (mIndexSelect == mItemsInfo.size()) mIndexSelect --;
00569 mItemsInfo[mIndexSelect].item->setVisible(true);
00570 mItemsInfo[mIndexSelect].item->setAlpha(ALPHA_MAX);
00571 }
00572 }
00573
00574 updateBar();
00575 }
00576
00577 void Tab::_insertItem(size_t _index, const UString& _name, TabItemPtr _sheet, Any _data)
00578 {
00579 if (_index == ITEM_NONE) _index = mItemsInfo.size();
00580
00581
00582 int width = (mButtonAutoWidth ? _getTextWidth(_name) : mButtonDefaultWidth);
00583 mWidthBar += width;
00584
00585 mItemsInfo.insert(mItemsInfo.begin() + _index, TabItemInfo(width, _name, _sheet, _data));
00586
00587
00588 if (1 == mItemsInfo.size()) mIndexSelect = 0;
00589 else
00590 {
00591 _sheet->setVisible(false);
00592 if (_index <= mIndexSelect) mIndexSelect ++;
00593 }
00594
00595 updateBar();
00596 }
00597
00598 void Tab::setItemDataAt(size_t _index, Any _data)
00599 {
00600 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::setItemDataAt");
00601 mItemsInfo[_index].data = _data;
00602 }
00603
00604 int Tab::getButtonWidthAt(size_t _index)
00605 {
00606 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::getButtonWidthAt");
00607 return mItemsInfo[_index].width;
00608 }
00609
00610 const UString& Tab::getItemNameAt(size_t _index)
00611 {
00612 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::getItemNameAt");
00613 return mItemsInfo[_index].name;
00614 }
00615
00616 TabItemPtr Tab::getItemAt(size_t _index)
00617 {
00618 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::getItemAt");
00619 return mItemsInfo[_index].item;
00620 }
00621
00622 void Tab::removeItemAt(size_t _index)
00623 {
00624 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "Tab::removeItemAt");
00625 this->_destroyChildWidget(mItemsInfo[_index].item);
00626 }
00627
00628 void Tab::removeAllItems()
00629 {
00630 while (mItemsInfo.size() > 0)
00631 {
00632 this->_destroyChildWidget(mItemsInfo.back().item);
00633 }
00634 }
00635
00636 ControllerFadeAlpha* Tab::createControllerFadeAlpha(float _alpha, float _coef, bool _enable)
00637 {
00638 ControllerItem* item = ControllerManager::getInstance().createItem(ControllerFadeAlpha::getClassTypeName());
00639 ControllerFadeAlpha* controller = item->castType<ControllerFadeAlpha>();
00640
00641 controller->setAlpha(_alpha);
00642 controller->setCoef(_coef);
00643 controller->setEnabled(_enable);
00644
00645 return controller;
00646 }
00647
00648 size_t Tab::getItemIndex(TabItemPtr _item)
00649 {
00650 for (size_t pos=0; pos<mItemsInfo.size(); pos++)
00651 {
00652 if (mItemsInfo[pos].item == _item) return pos;
00653 }
00654 MYGUI_EXCEPT("item (" << _item << ") not found, source 'Tab::getItemIndex'");
00655 }
00656
00657 size_t Tab::findItemIndex(TabItemPtr _item)
00658 {
00659 for (size_t pos=0; pos<mItemsInfo.size(); pos++)
00660 {
00661 if (mItemsInfo[pos].item == _item) return pos;
00662 }
00663 return ITEM_NONE;
00664 }
00665
00666 size_t Tab::findItemIndexWith(const UString& _name)
00667 {
00668 for (size_t pos=0; pos<mItemsInfo.size(); pos++)
00669 {
00670 if (mItemsInfo[pos].name == _name) return pos;
00671 }
00672 return ITEM_NONE;
00673 }
00674
00675 TabItemPtr Tab::findItemWith(const UString& _name)
00676 {
00677 for (size_t pos=0; pos<mItemsInfo.size(); pos++)
00678 {
00679 if (mItemsInfo[pos].name == _name) return mItemsInfo[pos].item;
00680 }
00681 return nullptr;
00682 }
00683
00684 TabItemPtr Tab::getItemSelected()
00685 {
00686 return getIndexSelected() != ITEM_NONE ? getItemAt(getIndexSelected()) : nullptr;
00687 }
00688
00689 void Tab::setProperty(const std::string& _key, const std::string& _value)
00690 {
00691 if (_key == "Tab_ButtonWidth") setButtonDefaultWidth(utility::parseValue<int>(_value));
00692 else if (_key == "Tab_ButtonAutoWidth") setButtonAutoWidth(utility::parseValue<bool>(_value));
00693 else if (_key == "Tab_SmoothShow") setSmoothShow(utility::parseValue<bool>(_value));
00694 else if (_key == "Tab_AddItem") addItem(_value);
00695 else if (_key == "Tab_SelectItem") setIndexSelected(utility::parseValue<size_t>(_value));
00696
00697 #ifndef MYGUI_DONT_USE_OBSOLETE
00698 else if (_key == "Tab_AddSheet")
00699 {
00700 MYGUI_LOG(Warning, "Tab_AddSheet is obsolete, use Tab_AddItem");
00701 addItem(_value);
00702 }
00703 else if (_key == "Tab_SelectSheet")
00704 {
00705 MYGUI_LOG(Warning, "Tab_SelectSheet is obsolete, use Tab_SelectItem");
00706 setIndexSelected(utility::parseValue<size_t>(_value));
00707 }
00708 #endif // MYGUI_DONT_USE_OBSOLETE
00709
00710 else Base::setProperty(_key, _value);
00711 }
00712
00713 }