IntSize MenuItem::_getContentSize() { ISubWidgetText* text = getSubWidgetText(); if (text == nullptr) return mMinSize; return text->getTextSize() + (getSize() - text->getSize()); }
void MenuControl::_notifyUpdateName(MenuItem* _item) { size_t index = getItemIndex(_item); mItemsInfo[index].name = _item->getCaption(); ISubWidgetText* text = _item->getSubWidgetText(); mItemsInfo[index].width = text ? (text->getTextSize().width + _item->getSize().width - text->getWidth()) : 0; update(); }
int TabControl::_getTextWidth(const UString& _text) { if (mItemButton.empty()) _createItemButton(); UString save = mItemButton[0]->getCaption(); mItemButton[0]->setCaption(_text); ISubWidgetText* text = mItemButton[0]->getSubWidgetText(); const IntSize& size = text ? text->getTextSize() : IntSize(); const IntCoord& coord = text ? text->getCoord() : IntCoord(); mItemButton[0]->setCaption(save); return size.width + mItemButton[0]->getWidth() - coord.width; }
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) { ISubWidgetText* t = history->getClient()->getSubWidgetText(); if(t == nullptr) return; const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left); size_t cursorPosition = t->getCursorPosition(lastPressed); MyGUI::UString color = history->getColorAtPos(cursorPosition); if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key)); } }
void Message::updateSize() { ISubWidgetText* text = nullptr; if (mWidgetText != nullptr) text = mWidgetText->getSubWidgetText(); IntSize size = text == nullptr ? IntSize() : text->getTextSize(); // минимум высота иконки if ((nullptr != mIcon) && (mIcon->getImageIndex() != ITEM_NONE)) { if (size.height < mIcon->getHeight()) size.height = mIcon->getHeight(); size.width += mIcon->getSize().width; } size += mOffsetText; size.width += 3; int width = ((int)mVectorButton.size() * mButtonSize.width) + (((int)mVectorButton.size()+1) * mButtonOffset.width); if (size.width < width) size.width = width; int offset = (size.width - width)/2; offset += mButtonOffset.width; const IntSize& view = Gui::getInstance().getViewSize(); setCoord((view.width-size.width)/2, (view.height-size.height)/2, size.width, size.height); if (nullptr != mIcon) { if (mWidgetText != nullptr) { if (mIcon->getImageIndex() != ITEM_NONE) mWidgetText->setCoord(mLeftOffset2, mWidgetText->getTop(), mWidgetText->getWidth(), mWidgetText->getHeight()); else mWidgetText->setCoord(mLeftOffset1, mWidgetText->getTop(), mWidgetText->getWidth(), mWidgetText->getHeight()); } } for (VectorWidgetPtr::iterator iter=mVectorButton.begin(); iter!=mVectorButton.end(); ++iter) { (*iter)->setCoord(offset, mCoord.height - mButtonOffset.height, mButtonSize.width, mButtonSize.height); offset += mButtonOffset.width + mButtonSize.width; } }