mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 08:56:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			64 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef OENGINE_MYGUI_LAYOUT_H
 | 
						|
#define OENGINE_MYGUI_LAYOUT_H
 | 
						|
 | 
						|
#include <string>
 | 
						|
#include <MyGUI_WidgetDefines.h>
 | 
						|
#include <MyGUI_Widget.h>
 | 
						|
 | 
						|
namespace OEngine {
 | 
						|
namespace GUI
 | 
						|
{
 | 
						|
  /** The Layout class is an utility class used to load MyGUI layouts
 | 
						|
      from xml files, and to manipulate member widgets.
 | 
						|
   */
 | 
						|
  class Layout
 | 
						|
  {
 | 
						|
  public:
 | 
						|
    Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr)
 | 
						|
      : mMainWidget(nullptr)
 | 
						|
    { initialise(_layout, _parent); }
 | 
						|
    virtual ~Layout() { shutdown();  }
 | 
						|
 | 
						|
    MyGUI::Widget* getWidget(const std::string& _name);
 | 
						|
 | 
						|
    template <typename T>
 | 
						|
    void getWidget(T * & _widget, const std::string & _name)
 | 
						|
    {
 | 
						|
        MyGUI::Widget* w = getWidget(_name);
 | 
						|
        T* cast = w->castType<T>(false);
 | 
						|
        if (!cast)
 | 
						|
        {
 | 
						|
            MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
 | 
						|
                         << "' source name = '" << w->getName()
 | 
						|
                         << "' source type = '" << w->getTypeName() << "' in layout '" << mLayoutName << "'");
 | 
						|
        }
 | 
						|
        else
 | 
						|
            _widget = cast;
 | 
						|
    }
 | 
						|
 | 
						|
  private:
 | 
						|
    void initialise(const std::string & _layout,
 | 
						|
                    MyGUI::Widget* _parent = nullptr);
 | 
						|
 | 
						|
    void shutdown();
 | 
						|
 | 
						|
  public:
 | 
						|
    void setCoord(int x, int y, int w, int h);
 | 
						|
 | 
						|
    virtual void setVisible(bool b);
 | 
						|
 | 
						|
    void setText(const std::string& name, const std::string& caption);
 | 
						|
 | 
						|
    // NOTE: this assume that mMainWidget is of type Window.
 | 
						|
    void setTitle(const std::string& title);
 | 
						|
 | 
						|
    MyGUI::Widget* mMainWidget;
 | 
						|
 | 
						|
  protected:
 | 
						|
 | 
						|
    std::string mPrefix;
 | 
						|
    std::string mLayoutName;
 | 
						|
    MyGUI::VectorWidgetPtr mListWindowRoot;
 | 
						|
  };
 | 
						|
}}
 | 
						|
#endif
 |