Reduce MyGUI includes

openmw-35
scrawl 10 years ago
parent 4b704f665f
commit eecea4131f

@ -101,7 +101,7 @@ set(OENGINE_OGRE
set(OENGINE_GUI
${LIBS_DIR}/openengine/gui/loglistener.cpp
${LIBS_DIR}/openengine/gui/manager.cpp
${LIBS_DIR}/openengine/gui/layout.hpp
${LIBS_DIR}/openengine/gui/layout.cpp
)
set(OENGINE_BULLET

@ -2,6 +2,8 @@
#include <boost/algorithm/string.hpp>
#include <MyGUI_Gui.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -1,5 +1,9 @@
#include "birth.hpp"
#include <MyGUI_ListBox.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h>
#include <boost/lexical_cast.hpp>
#include <components/esm/records.hpp>

@ -1,5 +1,7 @@
#include "bookwindow.hpp"
#include <MyGUI_TextBox.h>
#include <boost/lexical_cast.hpp>
#include <components/esm/loadbook.hpp>

@ -1,5 +1,9 @@
#include "class.hpp"
#include <MyGUI_ImageBox.h>
#include <MyGUI_ListBox.h>
#include <MyGUI_Gui.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_InputManager.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/dialoguemanager.hpp"

@ -1,5 +1,8 @@
#include "confirmationdialog.hpp"
#include <MyGUI_Button.h>
#include <MyGUI_EditBox.h>
namespace MWGui
{
ConfirmationDialog::ConfirmationDialog() :

@ -1,5 +1,7 @@
#include "console.hpp"
#include <MyGUI_EditBox.h>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>

@ -2,6 +2,9 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_InputManager.h>
#include <MyGUI_Button.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -1,6 +1,7 @@
#include "controllers.hpp"
#include <MyGUI_InputManager.h>
#include <MyGUI_Widget.h>
namespace MWGui
{

@ -1,9 +1,13 @@
#ifndef MWGUI_CONTROLLERS_H
#define MWGUI_CONTROLLERS_H
#include <MyGUI_Widget.h>
#include <string>
#include <MyGUI_ControllerItem.h>
namespace MyGUI
{
class Widget;
}
namespace MWGui
{

@ -1,6 +1,8 @@
#include "countdialog.hpp"
#include <boost/lexical_cast.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_ScrollBar.h>
#include <MyGUI_RenderManager.h>
#include <components/widgets/numericeditbox.hpp>

@ -1,5 +1,9 @@
#include "debugwindow.hpp"
#include <MyGUI_TabControl.h>
#include <MyGUI_TabItem.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_EditBox.h>
#include <LinearMath/btQuickprof.h>

@ -3,6 +3,10 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <MyGUI_LanguageManager.h>
#include <MyGUI_Window.h>
#include <MyGUI_ProgressBar.h>
#include <components/widgets/list.hpp>
#include "../mwbase/environment.hpp"

@ -171,7 +171,7 @@ namespace MWGui
BookPage* mHistory;
Gui::MWList* mTopicsList;
MyGUI::ScrollBar* mScrollBar;
MyGUI::Progress* mDispositionBar;
MyGUI::ProgressBar* mDispositionBar;
MyGUI::EditBox* mDispositionText;
PersuasionDialog mPersuasionDialog;

@ -1,5 +1,8 @@
#include "draganddrop.hpp"
#include <MyGUI_Gui.h>
#include <MyGUI_ControllerManager.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
@ -10,6 +13,7 @@
#include "inventorywindow.hpp"
#include "itemwidget.hpp"
#include "itemview.hpp"
#include "controllers.hpp"
namespace MWGui
{

@ -1,19 +1,23 @@
#include "formatting.hpp"
#include <components/interpreter/defines.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/stringops.hpp>
#include <OgreUTFString.h>
#include <OgreResourceGroupManager.h>
#include "../mwscript/interpretercontext.hpp"
#include <MyGUI_EditText.h>
#include <MyGUI_Gui.h>
#include <MyGUI_EditBox.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_FontManager.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/lexical_cast.hpp>
#include <OgreUTFString.h>
#include <OgreResourceGroupManager.h>
#include <components/interpreter/defines.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/stringops.hpp>
#include <MyGUI_EditText.h>
#include "../mwscript/interpretercontext.hpp"
namespace MWGui
{

@ -1,7 +1,7 @@
#ifndef MWGUI_FORMATTING_H
#define MWGUI_FORMATTING_H
#include <MyGUI.h>
#include <MyGUI_Colour.h>
#include <map>
namespace MWGui

@ -2,6 +2,15 @@
#include <boost/lexical_cast.hpp>
#include <OgreMath.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_ProgressBar.h>
#include <MyGUI_Button.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_ScrollView.h>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp"

@ -2,6 +2,12 @@
#include <stdexcept>
#include <MyGUI_Window.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_Button.h>
#include <boost/lexical_cast.hpp>
#include "../mwbase/world.hpp"
@ -15,6 +21,7 @@
#include "../mwworld/action.hpp"
#include "../mwscript/interpretercontext.hpp"
#include "../mwbase/scriptmanager.hpp"
#include "../mwrender/characterpreview.hpp"
#include "bookwindow.hpp"
#include "scrollwindow.hpp"
@ -26,6 +33,7 @@
#include "countdialog.hpp"
#include "tradewindow.hpp"
#include "draganddrop.hpp"
#include "widgets.hpp"
namespace
{
@ -667,4 +675,9 @@ namespace MWGui
useItem(model.getItem(cycled).mBase);
}
void InventoryWindow::rebuildAvatar()
{
mPreview->rebuild();
}
}

@ -1,14 +1,23 @@
#ifndef MGUI_Inventory_H
#define MGUI_Inventory_H
#include "../mwrender/characterpreview.hpp"
#include "windowpinnablebase.hpp"
#include "widgets.hpp"
#include "mode.hpp"
#include "../mwworld/ptr.hpp"
namespace MWRender
{
class InventoryPreview;
}
namespace MWGui
{
namespace Widgets
{
class MWDynamicStat;
}
class ItemView;
class SortFilterItemModel;
class TradeItemModel;
@ -33,9 +42,7 @@ namespace MWGui
MWWorld::Ptr getAvatarSelectedItem(int x, int y);
void rebuildAvatar() {
mPreview->rebuild();
}
void rebuildAvatar();
SortFilterItemModel* getSortFilterModel();
TradeItemModel* getTradeModel();

@ -1,5 +1,8 @@
#include "itemselection.hpp"
#include <MyGUI_TextBox.h>
#include <MyGUI_Button.h>
#include "itemview.hpp"
#include "inventoryitemmodel.hpp"
#include "sortfilteritemmodel.hpp"

@ -1,22 +1,25 @@
#include "journalwindow.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/journal.hpp"
#include <sstream>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <MyGUI_TextBox.h>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "boost/lexical_cast.hpp"
#include <boost/lexical_cast.hpp>
#include <components/widgets/imagebutton.hpp>
#include <components/widgets/list.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/journal.hpp"
#include "bookpage.hpp"
#include "windowbase.hpp"
#include "journalviewmodel.hpp"

@ -1,6 +1,8 @@
#include "levelupdialog.hpp"
#include <boost/lexical_cast.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_EditBox.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
@ -34,17 +36,17 @@ namespace MWGui
for (int i=1; i<9; ++i)
{
MyGUI::TextBox* t;
getWidget(t, "AttribVal" + boost::lexical_cast<std::string>(i));
getWidget(t, "AttribVal" + MyGUI::utility::toString(i));
MyGUI::Button* b;
getWidget(b, "Attrib" + boost::lexical_cast<std::string>(i));
getWidget(b, "Attrib" + MyGUI::utility::toString(i));
b->setUserData (i-1);
b->eventMouseButtonClick += MyGUI::newDelegate(this, &LevelupDialog::onAttributeClicked);
mAttributes.push_back(b);
mAttributeValues.push_back(t);
getWidget(t, "AttribMultiplier" + boost::lexical_cast<std::string>(i));
getWidget(t, "AttribMultiplier" + MyGUI::utility::toString(i));
mAttributeMultipliers.push_back(t);
}
@ -76,7 +78,7 @@ namespace MWGui
if (val >= 100)
val = 100;
mAttributeValues[i]->setCaption(boost::lexical_cast<std::string>(val));
mAttributeValues[i]->setCaption(MyGUI::utility::toString(val));
}
}
@ -154,13 +156,13 @@ namespace MWGui
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
int level = creatureStats.getLevel ()+1;
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + boost::lexical_cast<std::string>(level));
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level));
std::string levelupdescription;
if(level > 20)
levelupdescription=world->getFallback()->getFallbackString("Level_Up_Default");
else
levelupdescription=world->getFallback()->getFallbackString("Level_Up_Level"+boost::lexical_cast<std::string>(level));
levelupdescription=world->getFallback()->getFallbackString("Level_Up_Level"+MyGUI::utility::toString(level));
mLevelDescription->setCaption (levelupdescription);
@ -174,7 +176,7 @@ namespace MWGui
availableAttributes++;
int mult = pcStats.getLevelupAttributeMultiplier (i);
text->setCaption(mult <= 1 ? "" : "x" + boost::lexical_cast<std::string>(mult));
text->setCaption(mult <= 1 ? "" : "x" + MyGUI::utility::toString(mult));
}
else
{

@ -9,6 +9,11 @@
#include <OgreViewport.h>
#include <OgreHardwarePixelBuffer.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_ScrollBar.h>
#include <MyGUI_Gui.h>
#include <MyGUI_TextBox.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/statemanager.hpp"

@ -2,6 +2,10 @@
#include <OgreResourceGroupManager.h>
#include <MyGUI_TextBox.h>
#include <MyGUI_Gui.h>
#include <MyGUI_RenderManager.h>
#include <components/version/version.hpp>
#include <components/widgets/imagebutton.hpp>

@ -5,6 +5,15 @@
#include <OgreSceneNode.h>
#include <OgreVector2.h>
#include <MyGUI_ScrollView.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_Gui.h>
#include <MyGUI_LanguageManager.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_RotatingSkin.h>
#include <MyGUI_FactoryManager.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
@ -15,7 +24,7 @@
#include "../mwrender/globalmap.hpp"
#include "../components/esm/globalmap.hpp"
#include <components/esm/globalmap.hpp>
#include "widgets.hpp"
#include "confirmationdialog.hpp"

@ -4,6 +4,10 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h>
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"

@ -1,6 +1,12 @@
#include "messagebox.hpp"
#include <MyGUI_LanguageManager.h>
#include <MyGUI_EditBox.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_Button.h>
#include <components/misc/stringops.hpp>
#include "messagebox.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/inputmanager.hpp"

@ -2,6 +2,10 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_EditBox.h>
#include <MyGUI_Button.h>
#include <MyGUI_Gui.h>
#include <components/esm/quickkeys.hpp>
#include <components/misc/resourcehelpers.hpp>

@ -1,5 +1,10 @@
#include "race.hpp"
#include <MyGUI_ListBox.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_Gui.h>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>

@ -3,6 +3,9 @@
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h>
#include <components/esm/records.hpp>
#include "../mwbase/world.hpp"

@ -4,6 +4,9 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h>
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"

@ -1,5 +1,9 @@
#include "review.hpp"
#include <MyGUI_ScrollView.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h>
#include <boost/lexical_cast.hpp>
#include "../mwbase/environment.hpp"
@ -12,6 +16,16 @@
#undef min
#undef max
namespace
{
void adjustButtonSize(MyGUI::Button *button)
{
// adjust size of button to fit its text
MyGUI::IntSize size = button->getTextSize();
button->setSize(size.width + 24, button->getSize().height);
}
}
namespace MWGui
{

@ -4,6 +4,11 @@
#include <OgreImage.h>
#include <OgreTextureManager.h>
#include <MyGUI_ComboBox.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_ListBox.h>
#include <MyGUI_InputManager.h>
#include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp>

@ -1,5 +1,7 @@
#include "screenfader.hpp"
#include <MyGUI_RenderManager.h>
namespace MWGui
{

@ -1,5 +1,7 @@
#include "scrollwindow.hpp"
#include <MyGUI_ScrollView.h>
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"

@ -1,7 +1,13 @@
#include "settingswindow.hpp"
#include <OgreRoot.h>
#include <OgrePlugin.h>
#include <MyGUI_ScrollBar.h>
#include <MyGUI_Window.h>
#include <MyGUI_ComboBox.h>
#include <MyGUI_ListBox.h>
#include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>

@ -2,6 +2,10 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_Gui.h>
#include <MyGUI_Button.h>
#include <MyGUI_ScrollView.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -2,6 +2,9 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h>
#include <components/misc/resourcehelpers.hpp>
#include <components/esm/records.hpp>

@ -1,10 +1,12 @@
#include "spellicons.hpp"
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <iomanip>
#include <boost/lexical_cast.hpp>
#include <MyGUI_ImageBox.h>
#include <components/esm/loadmgef.hpp>
#include <components/misc/resourcehelpers.hpp>

@ -2,6 +2,8 @@
#include <boost/format.hpp>
#include <MyGUI_InputManager.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"

@ -1,5 +1,11 @@
#include "statswindow.hpp"
#include <MyGUI_Window.h>
#include <MyGUI_ScrollView.h>
#include <MyGUI_ProgressBar.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_Gui.h>
#include <boost/lexical_cast.hpp>
#include "../mwbase/environment.hpp"

@ -3,6 +3,9 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
#include <MyGUI_EditBox.h>
#include <MyGUI_Button.h>
namespace MWGui
{
@ -64,4 +67,15 @@ namespace MWGui
onOkClicked(_sender);
}
std::string TextInputDialog::getTextInput() const
{
return mTextEdit->getCaption();
}
void TextInputDialog::setTextInput(const std::string &text)
{
mTextEdit->setCaption(text);
}
}

@ -15,8 +15,8 @@ namespace MWGui
public:
TextInputDialog();
std::string getTextInput() const { return mTextEdit->getCaption(); }
void setTextInput(const std::string &text) { mTextEdit->setCaption(text); }
std::string getTextInput() const;
void setTextInput(const std::string &text);
void setNextButtonShow(bool shown);
void setTextLabel(const std::string &label);

@ -2,6 +2,11 @@
#include <iomanip>
#include <MyGUI_Gui.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_ImageBox.h>
#include <boost/lexical_cast.hpp>
#include <components/misc/resourcehelpers.hpp>

@ -1,6 +1,8 @@
#include "tradewindow.hpp"
#include <boost/lexical_cast.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_ControllerManager.h>
#include <components/widgets/numericeditbox.hpp>
@ -484,7 +486,7 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + boost::lexical_cast<std::string>(playerGold));
mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + MyGUI::utility::toString(playerGold));
if (mCurrentBalance > 0)
{
@ -497,7 +499,7 @@ namespace MWGui
mTotalBalance->setValue(std::abs(mCurrentBalance));
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(getMerchantGold()));
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + MyGUI::utility::toString(getMerchantGold()));
}
void TradeWindow::updateOffer()

@ -9,12 +9,11 @@ namespace Gui
class NumericEditBox;
}
namespace MWGui
namespace MyGUI
{
class WindowManager;
class ControllerItem;
}
namespace MWGui
{
class ItemView;

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_Gui.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"

@ -2,6 +2,10 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_Button.h>
#include <MyGUI_ScrollView.h>
#include <MyGUI_Gui.h>
#include <OgreVector3.h>
#include "../mwbase/environment.hpp"

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <MyGUI_ProgressBar.h>
#include <components/widgets/box.hpp>
#include "../mwbase/windowmanager.hpp"

@ -1,21 +1,24 @@
#include "widgets.hpp"
#include "../mwworld/esmstore.hpp"
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <iomanip>
#include <components/misc/resourcehelpers.hpp>
#include <boost/lexical_cast.hpp>
#include <MyGUI_ProgressBar.h>
#include <MyGUI_ImageBox.h>
#include <MyGUI_ControllerManager.h>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "controllers.hpp"
#undef min
#undef max

@ -2,7 +2,6 @@
#define MWGUI_WIDGETS_H
#include "../mwmechanics/stat.hpp"
#include "controllers.hpp"
#include <components/esm/effectlist.hpp>
#include <components/esm/loadskil.hpp>
@ -14,6 +13,7 @@
namespace MyGUI
{
class ImageBox;
class ControllerItem;
}
namespace MWBase

@ -1,5 +1,7 @@
#include "windowbase.hpp"
#include <MyGUI_InputManager.h>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"

@ -6,10 +6,17 @@
#include <OgreTextureManager.h>
#include <OgreRenderWindow.h>
#include "MyGUI_UString.h"
#include "MyGUI_IPointer.h"
#include "MyGUI_ResourceImageSetPointer.h"
#include "MyGUI_TextureUtility.h"
#include <MyGUI_UString.h>
#include <MyGUI_IPointer.h>
#include <MyGUI_ResourceImageSetPointer.h>
#include <MyGUI_TextureUtility.h>
#include <MyGUI_FactoryManager.h>
#include <MyGUI_LanguageManager.h>
#include <MyGUI_PointerManager.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_Gui.h>
#include <MyGUI_ClipboardManager.h>
#include <MyGUI_RenderManager.h>
#include <openengine/ogre/renderer.hpp>
#include <openengine/gui/manager.hpp>
@ -76,6 +83,7 @@
#include "spellview.hpp"
#include "draganddrop.hpp"
#include "container.hpp"
#include "controllers.hpp"
namespace MWGui
{

@ -1,5 +1,7 @@
#include "windowpinnablebase.hpp"
#include <MyGUI_Button.h>
#include "exposedwindow.hpp"
namespace MWGui

@ -0,0 +1,103 @@
#include "layout.hpp"
#include <MyGUI_LayoutManager.h>
#include <MyGUI_Widget.h>
#include <MyGUI_Gui.h>
#include <MyGUI_TextBox.h>
#include <MyGUI_Window.h>
namespace OEngine
{
namespace GUI
{
void Layout::initialise(const std::string& _layout, MyGUI::Widget* _parent)
{
const std::string MAIN_WINDOW = "_Main";
mLayoutName = _layout;
if (mLayoutName.empty())
mMainWidget = _parent;
else
{
mPrefix = MyGUI::utility::toString(this, "_");
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
const std::string main_name = mPrefix + MAIN_WINDOW;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter)
{
if ((*iter)->getName() == main_name)
{
mMainWidget = (*iter);
break;
}
}
MYGUI_ASSERT(mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found.");
}
}
void Layout::shutdown()
{
MyGUI::Gui::getInstance().destroyWidget(mMainWidget);
mListWindowRoot.clear();
}
void Layout::setCoord(int x, int y, int w, int h)
{
mMainWidget->setCoord(x,y,w,h);
}
void Layout::adjustWindowCaption()
{
MyGUI::TextBox* box = mMainWidget->castType<MyGUI::Window>(mMainWidget)->getCaptionWidget();
box->setSize(box->getTextSize().width + 24, box->getSize().height);
// in order to trigger alignment updates, we need to update the parent
// mygui doesn't provide a proper way of doing this, so we are just changing size
box->getParent()->setCoord(MyGUI::IntCoord(
box->getParent()->getCoord().left,
box->getParent()->getCoord().top,
box->getParent()->getCoord().width,
box->getParent()->getCoord().height+1
));
box->getParent()->setCoord(MyGUI::IntCoord(
box->getParent()->getCoord().left,
box->getParent()->getCoord().top,
box->getParent()->getCoord().width,
box->getParent()->getCoord().height-1
));
}
void Layout::setVisible(bool b)
{
mMainWidget->setVisible(b);
}
void Layout::setText(const std::string &name, const std::string &caption)
{
MyGUI::Widget* pt;
getWidget(pt, name);
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
}
void Layout::setTitle(const std::string& title)
{
static_cast<MyGUI::Window*>(mMainWidget)->setCaptionWithReplacing(title);
adjustWindowCaption();
}
MyGUI::Widget* Layout::getWidget(const std::string &_name)
{
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin();
iter!=mListWindowRoot.end(); ++iter)
{
MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name);
if (nullptr != find)
{
return find;
}
}
MYGUI_EXCEPT("widget name '" << _name << "' in layout '" << mLayoutName << "' not found.");
}
}
}

@ -1,7 +1,9 @@
#ifndef OENGINE_MYGUI_LAYOUT_H
#define OENGINE_MYGUI_LAYOUT_H
#include <MyGUI.h>
#include <string>
#include <MyGUI_WidgetDefines.h>
#include <MyGUI_Widget.h>
namespace OEngine {
namespace GUI
@ -17,118 +19,43 @@ namespace GUI
{ initialise(_layout, _parent); }
virtual ~Layout() { shutdown(); }
MyGUI::Widget* getWidget(const std::string& _name);
template <typename T>
void getWidget(T * & _widget, const std::string & _name, bool _throw = true)
void getWidget(T * & _widget, const std::string & _name)
{
_widget = nullptr;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin();
iter!=mListWindowRoot.end(); ++iter)
MyGUI::Widget* w = getWidget(_name);
T* cast = w->castType<T>(false);
if (!cast)
{
MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name);
if (nullptr != find)
{
T * cast = find->castType<T>(false);
if (nullptr != cast)
_widget = cast;
else if (_throw)
{
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
<< "' source name = '" << find->getName()
<< "' source type = '" << find->getTypeName() << "' in layout '" << mLayoutName << "'");
}
return;
}
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
<< "' source name = '" << w->getName()
<< "' source type = '" << w->getTypeName() << "' in layout '" << mLayoutName << "'");
}
MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' in layout '" << mLayoutName << "' not found.");
else
_widget = cast;
}
private:
void initialise(const std::string & _layout,
MyGUI::Widget* _parent = nullptr)
{
const std::string MAIN_WINDOW = "_Main";
mLayoutName = _layout;
if (mLayoutName.empty())
mMainWidget = _parent;
else
{
mPrefix = MyGUI::utility::toString(this, "_");
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
MyGUI::Widget* _parent = nullptr);
const std::string main_name = mPrefix + MAIN_WINDOW;
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter)
{
if ((*iter)->getName() == main_name)
{
mMainWidget = (*iter);
break;
}
}
MYGUI_ASSERT(mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found.");
}
}
void shutdown()
{
MyGUI::Gui::getInstance().destroyWidget(mMainWidget);
mListWindowRoot.clear();
}
void shutdown();
public:
void setCoord(int x, int y, int w, int h)
{
mMainWidget->setCoord(x,y,w,h);
}
void setCoord(int x, int y, int w, int h);
void adjustWindowCaption()
{
// adjust the size of the window caption so that all text is visible
// NOTE: this assumes that mMainWidget is of type Window.
MyGUI::TextBox* box = static_cast<MyGUI::Window*>(mMainWidget)->getCaptionWidget();
box->setSize(box->getTextSize().width + 24, box->getSize().height);
// adjust the size of the window caption so that all text is visible
// NOTE: this assumes that mMainWidget is of type Window.
void adjustWindowCaption();
// in order to trigger alignment updates, we need to update the parent
// mygui doesn't provide a proper way of doing this, so we are just changing size
box->getParent()->setCoord(MyGUI::IntCoord(
box->getParent()->getCoord().left,
box->getParent()->getCoord().top,
box->getParent()->getCoord().width,
box->getParent()->getCoord().height+1
));
box->getParent()->setCoord(MyGUI::IntCoord(
box->getParent()->getCoord().left,
box->getParent()->getCoord().top,
box->getParent()->getCoord().width,
box->getParent()->getCoord().height-1
));
}
virtual void setVisible(bool b);
virtual void setVisible(bool b)
{
mMainWidget->setVisible(b);
}
void setText(const std::string& name, const std::string& caption);
void setText(const std::string& name, const std::string& caption)
{
MyGUI::Widget* pt;
getWidget(pt, name);
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
}
// NOTE: this assume that mMainWidget is of type Window.
void setTitle(const std::string& title);
void setTitle(const std::string& title)
{
// NOTE: this assume that mMainWidget is of type Window.
static_cast<MyGUI::Window*>(mMainWidget)->setCaptionWithReplacing(title);
adjustWindowCaption();
}
void adjustButtonSize(MyGUI::Button* button)
{
// adjust size of button to fit its text
MyGUI::IntSize size = button->getTextSize();
button->setSize(size.width + 24, button->getSize().height);
}
MyGUI::Widget* mMainWidget;
protected:

Loading…
Cancel
Save