Use MyGUI's castType for widget casts

deque
scrawl 10 years ago
parent 9d05718515
commit cfc57d0fe0

@ -266,7 +266,7 @@ namespace MWGui
BookPage::ClickCallback callback = boost::bind (&DialogueWindow::notifyLinkClicked, this, _1);
mHistory->adviseLinkClicked(callback);
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
}
void DialogueWindow::exit()

@ -42,7 +42,7 @@ namespace MWGui
, mSelectedItem(-1)
, mGuiMode(GM_Inventory)
{
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
getWidget(mAvatar, "Avatar");
getWidget(mAvatarImage, "AvatarImage");
@ -368,7 +368,7 @@ namespace MWGui
mItemView->update();
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
_sender->castType<MyGUI::Button>()->setStateSelected(true);
}
void InventoryWindow::onPinToggled()

@ -154,7 +154,7 @@ namespace MWGui
void MWList::onItemSelected(MyGUI::Widget* _sender)
{
std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption();
std::string name = _sender->castType<MyGUI::Button>()->getCaption();
int id = *_sender->getUserData<int>();
eventItemSelected(name, id);
eventWidgetSelected(_sender);

@ -370,10 +370,10 @@ namespace MWGui
void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender)
{
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
std::string val = _sender->castType<MyGUI::Button>()->getCaption();
val = hlslGlsl();
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
_sender->castType<MyGUI::Button>()->setCaption(val);
Settings::Manager::setString("shader mode", "General", val);
@ -483,7 +483,7 @@ namespace MWGui
{
int actionId = *_sender->getUserData<int>();
static_cast<MyGUI::Button*>(_sender)->setCaptionWithReplacing("#{sNone}");
_sender->castType<MyGUI::Button>()->setCaptionWithReplacing("#{sNone}");
MWBase::Environment::get().getWindowManager ()->staticMessageBox ("#{sControlsMenu3}");
MWBase::Environment::get().getWindowManager ()->disallowMouse();

@ -66,7 +66,7 @@ namespace MWGui
mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, (MyGUI::TextBox*)NULL));
}
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
MyGUI::Window* t = mMainWidget->castType<MyGUI::Window>();
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
}
@ -90,7 +90,7 @@ namespace MWGui
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
{
MyGUI::ProgressPtr pt;
MyGUI::ProgressBar* pt;
getWidget(pt, name);
pt->setProgressRange(max);
pt->setProgressPosition(val);
@ -102,7 +102,7 @@ namespace MWGui
void StatsWindow::setPlayerName(const std::string& playerName)
{
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(playerName);
mMainWidget->castType<MyGUI::Window>()->setCaption(playerName);
adjustWindowCaption();
}

@ -37,7 +37,7 @@ namespace MWGui
void setBounty (int bounty) { if (bounty != mBounty) mChanged = true; this->mBounty = bounty; }
void updateSkillArea();
virtual void open() { onWindowResize(static_cast<MyGUI::Window*>(mMainWidget)); }
virtual void open() { onWindowResize(mMainWidget->castType<MyGUI::Window>()); }
private:
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);

@ -138,7 +138,7 @@ namespace MWGui
mFilterMagic->setStateSelected(false);
mFilterMisc->setStateSelected(false);
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
_sender->castType<MyGUI::Button>()->setStateSelected(true);
mItemView->update();
}

@ -192,7 +192,10 @@ namespace MWGui
mSleeping = canRest;
dynamic_cast<Gui::Box*>(mMainWidget)->notifyChildrenSizeChanged();
Gui::Box* box = dynamic_cast<Gui::Box*>(mMainWidget);
if (box == NULL)
throw std::runtime_error("main widget must be a box");
box->notifyChildrenSizeChanged();
center();
}

@ -59,18 +59,18 @@ namespace MWGui
{
if (mSkillId == ESM::Skill::Length)
{
static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption("");
mSkillNameWidget->setCaption("");
}
else
{
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], "");
static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption(name);
mSkillNameWidget->setCaption(name);
}
}
if (mSkillValueWidget)
{
SkillValue::Type modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(mSkillValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
mSkillValueWidget->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base)
mSkillValueWidget->_setWidgetState("increased");
else if (modified < base)
@ -145,7 +145,7 @@ namespace MWGui
{
if (mId < 0 || mId >= 8)
{
static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption("");
mAttributeNameWidget->setCaption("");
}
else
{
@ -160,13 +160,13 @@ namespace MWGui
"sAttributeLuck"
};
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(attributes[mId], "");
static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption(name);
mAttributeNameWidget->setCaption(name);
}
}
if (mAttributeValueWidget)
{
int modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(mAttributeValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
mAttributeValueWidget->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base)
mAttributeValueWidget->_setWidgetState("increased");
else if (modified < base)
@ -256,9 +256,9 @@ namespace MWGui
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
if (spell)
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName);
mSpellNameWidget->setCaption(spell->mName);
else
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption("");
mSpellNameWidget->setCaption("");
}
}
@ -310,7 +310,7 @@ namespace MWGui
// ... then adjust the size for all widgets
for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it)
{
effect = static_cast<MWSpellEffectPtr>(*it);
effect = (*it)->castType<MWSpellEffect>();
bool needcenter = center && (maxwidth > effect->getRequestedWidth());
int diff = maxwidth - effect->getRequestedWidth();
if (needcenter)
@ -470,7 +470,7 @@ namespace MWGui
}
}
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaptionWithReplacing(spellLine);
mTextWidget->setCaptionWithReplacing(spellLine);
mRequestedWidth = mTextWidget->getTextSize().width + 24;
mImageWidget->setImageTexture(Misc::ResourceHelpers::correctIconPath(magicEffect->mIcon));
@ -515,13 +515,13 @@ namespace MWGui
{
std::stringstream out;
out << mValue << "/" << mMax;
static_cast<MyGUI::TextBox*>(mBarTextWidget)->setCaption(out.str().c_str());
mBarTextWidget->setCaption(out.str().c_str());
}
}
void MWDynamicStat::setTitle(const std::string& text)
{
if (mTextWidget)
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(text);
mTextWidget->setCaption(text);
}
MWDynamicStat::~MWDynamicStat()

@ -122,8 +122,8 @@ namespace MWGui
ESM::Skill::SkillEnum mSkillId;
SkillValue mValue;
MyGUI::Widget* mSkillNameWidget;
MyGUI::Widget* mSkillValueWidget;
MyGUI::TextBox* mSkillNameWidget;
MyGUI::TextBox* mSkillValueWidget;
};
typedef MWSkill* MWSkillPtr;
@ -162,8 +162,8 @@ namespace MWGui
int mId;
AttributeValue mValue;
MyGUI::Widget* mAttributeNameWidget;
MyGUI::Widget* mAttributeValueWidget;
MyGUI::TextBox* mAttributeNameWidget;
MyGUI::TextBox* mAttributeValueWidget;
};
typedef MWAttribute* MWAttributePtr;
@ -293,7 +293,7 @@ namespace MWGui
int mValue, mMax;
MyGUI::TextBox* mTextWidget;
MyGUI::ProgressPtr mBarWidget;
MyGUI::ProgressBar* mBarWidget;
MyGUI::TextBox* mBarTextWidget;
};
typedef MWDynamicStat* MWDynamicStatPtr;

@ -7,7 +7,7 @@ namespace MWGui
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout)
: WindowBase(parLayout), mPinned(false)
{
ExposedWindow* window = static_cast<ExposedWindow*>(mMainWidget);
ExposedWindow* window = mMainWidget->castType<ExposedWindow>();
mPinButton = window->getSkinWidget ("Button");
mPinButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WindowPinnableBase::onPinButtonClicked);

Loading…
Cancel
Save