00001 00007 /* 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef OMGUI_INITIALIZER_WINDOW_H 00024 #define OMGUI_INITIALIZER_WINDOW_H 00025 00026 #include <omgui/initializer/widget.h> 00027 00028 namespace omgui { 00029 class MenuBar; 00030 namespace initializer { 00031 00035 struct OMGUI_API WindowData : public WidgetData 00036 { 00037 protected: 00039 string m_title; 00040 00042 omgui::Size m_content_size; 00043 00045 omgui::Point m_position; 00046 00052 bool m_default_position; 00053 00055 Pointer<omgui::Panel> m_content_panel; 00056 00058 MenuBar *m_menu_bar; 00059 00060 public: 00061 WindowData(); 00062 00063 void set_title(const string &str); 00064 string get_title() const; 00065 void set_position(const omgui::Point &p); 00066 omgui::Point get_position() const; 00067 void set_content_size(const omgui::Size &s); 00068 omgui::Size get_content_size() const; 00069 void set_content_panel(const Pointer<omgui::Panel> &p); 00070 Pointer<omgui::Panel> get_content_panel() const; 00071 void set_menu_bar(omgui::MenuBar *menubar); 00072 omgui::MenuBar *get_menu_bar() const; 00073 00074 bool default_position() const; 00075 }; 00076 00080 template <typename T> class Window : public Widget<T> 00081 { 00082 public: 00083 typedef WindowData data_type; 00084 00085 protected: 00086 data_type *m_data; 00087 00088 Window(data_type *data) 00089 : Widget<T>(data), 00090 m_data(data) 00091 { } 00092 00093 public: 00094 T &title(const string &s) 00095 { 00096 m_data->set_title(s); 00097 return static_cast<T&>(*this); 00098 } 00099 00100 T &position(const omgui::Point &p) 00101 { 00102 m_data->set_position(p); 00103 return static_cast<T&>(*this); 00104 } 00105 00106 T &content_size(const omgui::Size &s) 00107 { 00108 m_data->set_content_size(s); 00109 return static_cast<T&>(*this); 00110 } 00111 00112 T &content_panel(const Pointer<omgui::Panel> &p) 00113 { 00114 m_data->set_content_panel(p); 00115 return static_cast<T&>(*this); 00116 } 00117 00118 T &menu_bar(MenuBar *menubar) 00119 { 00120 m_data->set_menu_bar(menubar); 00121 return static_cast<T&>(*this); 00122 } 00123 00124 string get_title() const { return m_data->get_title(); } 00125 omgui::Point get_position() const { return m_data->get_position(); } 00126 omgui::Size get_content_size() const { return m_data->get_content_size(); } 00127 Pointer<omgui::Panel> get_content_panel() const { return m_data->get_content_panel(); } 00128 MenuBar *get_menu_bar() const { return m_data->get_menu_bar(); } 00129 }; 00130 00131 } // initializer 00132 00133 class Window; 00137 class OMGUI_API WindowInitializer : public omgui::initializer::Window<WindowInitializer> 00138 { 00139 friend class omgui::Window; 00140 00141 public: 00142 WindowInitializer(); 00143 00144 private: 00145 data_type get_data() const; 00146 }; 00147 00148 } // omgui 00149 00150 #endif // OMGUI_INITIALIZER_WINDOW_H