app.h

Go to the documentation of this file.
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_APP_H
00024 #define OMGUI_APP_H
00025 
00026 #include <omgui/dllimpexp.h>
00027 #include <omgui/types.h>
00028 #include <omgui/event.h>
00029 
00030 #include <list>
00031 #include <vector>
00032 #include <memory>
00033 
00034 #include <omgui/eventloop.h>
00035 
00036 namespace omgui {
00037 
00038 class TopLevel;
00039 typedef std::list< Pointer<TopLevel> > TopLevelList;
00040 
00041 class OMGUI_API App
00042 {
00043 public:
00047     typedef std::vector<string> cmd_line;
00048 
00049     virtual bool init() = 0;
00050 
00054     void run();
00055 
00063     void quit();
00064 
00068     void close_toplevel_windows();
00069 
00075     static const TopLevelList &get_top_level_widgets();
00076 
00080     omgui::EventLoop *get_event_loop();
00081 
00085     const cmd_line &get_cmd_line();
00086     void set_cmd_line(const cmd_line &cmd);
00087 
00091     static void add_top_level(TopLevel *t);
00092 
00096     static void remove_top_level(TopLevel *t);
00097 
00098     virtual ~App();
00099 
00100 protected:
00101     App();
00102 
00103 private:
00104     cmd_line m_cmd;
00105 
00107     std::auto_ptr<omgui::EventLoop> m_event_loop;
00108 
00115     void gui_init();
00116 
00125     void _quit();
00126 };
00127 
00128 // this comment is not a doxygen comment to keep doxygen from confusing this function
00129 // with its template overload declared below.
00130 /*
00131     \return A reference to the omgui::App object that is running this application
00132 
00133     \note This is implemented in src/omgui/main.cpp.
00134 */
00135 OMGUI_API App &get_app();
00136 
00143 template<typename T> T &get_app()
00144 {
00145     return dynamic_cast<T&>(omgui::get_app());
00146 }
00147 
00148 } // omgui
00149 
00150 #endif // OMGUI_APP_H

doxygen SourceForge.net Logo