Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

App.h

Go to the documentation of this file.
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 <glibmm/object.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 
00065   //The constructor has a default argument so that there is a default constructor,
00066   //so that derived classes do not need to call a specific constructor. This is
00067   //a virtual base class so they would otherwise need to do that.
00068   
00070   App(const Glib::ustring& appname = Glib::ustring()); 
00071   
00072   virtual ~App();
00073 
00074   virtual void init(); //Sets it up and shows it.
00075 
00076   //'About Box' information:
00077   typedef std::vector<Glib::ustring> type_vecStrings;   
00078   static void set_about_information(const Glib::ustring& strVersion, const type_vecStrings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription);
00079   static void set_about_information(const Glib::ustring& strVersion, const type_vecStrings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription, const type_vecStrings& vecDocumenters, const Glib::ustring& strTranslatorCredits);
00080   virtual Glib::ustring get_version() const;
00081 
00082   static void set_command_line_args(int argc, char** &argv); //Needed for session management.
00083 
00084   typedef sigc::signal<void> type_signal_hide;
00085   type_signal_hide ui_signal_hide();
00086   
00087 protected:
00088   static void init_app_name(const Glib::ustring& appname);
00089 
00093   virtual void init_ui_manager();
00094 
00097   virtual void init_menus();
00098 
00101   virtual void init_menus_file() = 0;
00102 
00105   virtual void init_menus_edit() = 0;
00106 
00109   virtual void init_menus_help() = 0;
00110 
00111   virtual void init_toolbars();
00112   
00113   virtual App* new_instance() = 0; //Must override in order to new() the derived document class.
00114 
00115 //  virtual void close_window() = 0;
00116 //  virtual void bring_to_front() = 0;
00117   //Signal handlers:
00118 
00119 public: // We can not take function pointers of these methods in a 
00120         // derived class, if they are protected - for instance, with sigc::mem_fun() 
00121   //Menus:
00122   virtual void on_menu_file_new();
00123   virtual void on_menu_file_close();
00124   virtual void on_menu_file_exit();
00125 
00126   //Edit menu handlers overriden in App_WithDoc:
00127   virtual void on_menu_edit_cut();
00128   virtual void on_menu_edit_copy();
00129   virtual void on_menu_edit_paste();
00130   virtual void on_menu_edit_clear();
00131   
00132   virtual void on_menu_help_about() = 0;
00133 
00134 
00135   virtual void on_about_close();
00136 
00137 protected:
00138   //GUI abstractions:
00139   virtual void ui_hide() = 0;
00140   virtual void ui_bring_to_front() = 0;
00141 
00142   //operation_cancelled:
00143   //e.g. A File|Open tries to save existing data,
00144   //but this needs to be cancelled if the save failed. 
00145   static void set_operation_cancelled(bool bVal = true);
00146   static bool get_operation_cancelled();
00147 
00148   //Member data:
00149   
00150   //'About Box'/WM Class information:
00151   static Glib::ustring m_strAppName;
00152 
00153   //'About Box' information:
00154   static HelpInfo m_HelpInfo;
00155 
00156   //Instances
00157   static AppInstanceManager m_AppInstanceManager;
00158 
00159   static bool m_bOperationCancelled; //see set/get_operation_cancelled().
00160 
00161   //All instances share 1 About box:
00162   static bool m_bAboutShown;
00163 
00164   //Command line args:
00165   static Glib::ustring m_strCommandLine_0;
00166 
00167   type_signal_hide m_signal_hide;
00168 
00169 
00170   
00171   //typedef std::vector<poptOption> type_vecPoptOptions;
00172   //type_vecPoptOptions m_vecPoptOptions;
00173 };
00174 
00175 } //namespace
00176 
00177 #endif //BAKERY_APP_H

Generated on Tue Jan 4 19:00:07 2005 for bakery by  doxygen 1.3.9.1