00001 /* 00002 * Copyright 2000 Murray Cumming 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this library; if not, write to the Free 00016 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef BAKERY_APP_H 00020 #define BAKERY_APP_H 00021 00022 #include <bakery/App/AppInstanceManager.h> 00023 #include <gtkmm/window.h> 00024 00025 #include <vector> 00026 #include <list> 00027 #include <map> 00028 00029 namespace Bakery 00030 { 00031 00032 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00033 class HelpInfo 00034 { 00035 public: 00036 typedef std::vector<Glib::ustring> type_vecStrings; 00037 Glib::ustring m_strVersion, m_strCopyright, m_strDescription, m_strTranslatorCredits; 00038 00039 type_vecStrings m_vecAuthors, m_vecDocumenters; 00040 }; 00041 #endif //DOXYGEN_SHOULD_SKIP_THIS 00042 00060 class App : virtual public Glib::ObjectBase 00061 { 00062 public: 00063 friend class AppInstanceManager; 00064 00066 App(const Glib::ustring& appname = Glib::ustring()); 00067 virtual ~App(); 00068 00069 virtual void init(); //Sets it up and shows it. 00070 00071 //'About Box' information: 00072 typedef std::vector<Glib::ustring> type_vecStrings; 00073 static void set_about_information(const Glib::ustring& strVersion, const type_vecStrings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription); 00074 virtual Glib::ustring get_version() const; 00075 00076 static void set_command_line_args(int argc, char** &argv); //Needed for session management. 00077 00078 typedef SigC::Signal0<void> type_signal_hide; 00079 type_signal_hide ui_signal_hide(); 00080 00081 protected: 00082 static void init_app_name(const Glib::ustring& appname); 00083 00084 virtual void init_menus() = 0; //Override this to add more menu or different menus. 00085 virtual void init_menus_file() = 0; //Call this from init_menus() to add the standard file menu. 00086 virtual void init_menus_edit() = 0; //Call this from init_menus() to add the standard edit menu 00087 virtual void init_menus_help() = 0; //Call this from init_menus() to add the standard help menu. 00088 virtual void init_toolbars() = 0; 00089 00090 virtual App* new_instance() = 0; //Must override in order to new() the derived document class. 00091 00092 // virtual void close_window() = 0; 00093 // virtual void bring_to_front() = 0; 00094 //Signal handlers: 00095 00096 public: 00097 //Menus: 00098 virtual void on_menu_file_new(); 00099 virtual void on_menu_file_close(); 00100 virtual void on_menu_file_exit(); 00101 00102 //Edit menu handlers overriden in App_WithDoc: 00103 virtual void on_menu_edit_cut(); 00104 virtual void on_menu_edit_copy(); 00105 virtual void on_menu_edit_paste(); 00106 virtual void on_menu_edit_clear(); 00107 00108 virtual void on_menu_help_about() = 0; 00109 00110 00111 virtual void on_about_close(); 00112 00113 00114 //GUI abstractions: 00115 virtual void ui_hide() = 0; 00116 virtual void ui_bring_to_front() = 0; 00117 00118 //operation_cancelled: 00119 //e.g. A File|Open tries to save existing data, 00120 //but this needs to be cancelled if the save failed. 00121 static void set_operation_cancelled(bool bVal = true); 00122 static bool get_operation_cancelled(); 00123 00124 //Member data: 00125 00126 bool m_bInitialized; //Whether init() has been called. 00127 //'About Box'/WM Class information: 00128 static Glib::ustring m_strAppName; 00129 00130 //'About Box' information: 00131 static HelpInfo m_HelpInfo; 00132 00133 //Instances 00134 static AppInstanceManager m_AppInstanceManager; 00135 00136 static bool m_bOperationCancelled; //see set/get_operation_cancelled(). 00137 00138 //All instances share 1 About box: 00139 static bool m_bAboutShown; 00140 00141 //Command line args: 00142 static Glib::ustring m_strCommandLine_0; 00143 00144 type_signal_hide m_signal_hide; 00145 00146 //typedef std::vector<poptOption> type_vecPoptOptions; 00147 //type_vecPoptOptions m_vecPoptOptions; 00148 }; 00149 00150 } //namespace 00151 00152 #endif //BAKERY_APP_H