bakery  2.6
App.h
Go to the documentation of this file.
1 /*
2  * Copyright 2000 Murray Cumming
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef BAKERY_APP_H
20 #define BAKERY_APP_H
21 
23 #include <glibmm/object.h>
24 
25 #include <vector>
26 #include <list>
27 #include <map>
28 
29 namespace Bakery
30 {
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 class HelpInfo
34 {
35 public:
36  typedef std::vector<Glib::ustring> type_vecStrings;
37  Glib::ustring m_strVersion, m_strCopyright, m_strDescription, m_strTranslatorCredits;
38 
39  type_vecStrings m_vecAuthors, m_vecDocumenters;
40 };
41 #endif //DOXYGEN_SHOULD_SKIP_THIS
42 
60 class App : virtual public Glib::ObjectBase
61 {
62 public:
63  friend class AppInstanceManager;
64 
65  //The constructor has a default argument so that there is a default constructor,
66  //so that derived classes do not need to call a specific constructor. This is
67  //a virtual base class so they would otherwise need to do that.
68 
70  App(const Glib::ustring& appname = Glib::ustring());
71 
72  virtual ~App();
73 
74  virtual void init(); //Sets it up and shows it.
75 
76  //'About Box' information:
77  typedef std::vector<Glib::ustring> type_vecStrings;
78  static void set_about_information(const Glib::ustring& strVersion, const type_vecStrings& vecAuthors, const Glib::ustring& strCopyright, const Glib::ustring& strDescription);
79  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);
80  virtual Glib::ustring get_version() const;
81 
82  static void set_command_line_args(int argc, char** &argv); //Needed for session management.
83 
84  typedef sigc::signal<void> type_signal_hide;
85  type_signal_hide ui_signal_hide();
86 
87 protected:
88  static void init_app_name(const Glib::ustring& appname);
89 
93  virtual void init_ui_manager();
94 
97  virtual void init_menus();
98 
101  virtual void init_menus_file() = 0;
102 
105  virtual void init_menus_edit() = 0;
106 
109  virtual void init_menus_help() = 0;
110 
111  virtual void init_toolbars();
112 
113  virtual App* new_instance() = 0; //Must override in order to new() the derived document class.
114 
115 // virtual void close_window() = 0;
116 // virtual void bring_to_front() = 0;
117  //Signal handlers:
118 
119 public: // We can not take function pointers of these methods in a
120  // derived class, if they are protected - for instance, with sigc::mem_fun()
121  //Menus:
122  virtual void on_menu_file_new();
123  virtual void on_menu_file_close();
124  virtual void on_menu_file_exit();
125 
126  //Edit menu handlers overriden in App_WithDoc:
127  virtual void on_menu_edit_cut();
128  virtual void on_menu_edit_copy();
129  virtual void on_menu_edit_paste();
130  virtual void on_menu_edit_clear();
131 
132  virtual void on_menu_help_about() = 0;
133 
134 
135  virtual void on_about_close();
136 
137 protected:
138  //GUI abstractions:
139  virtual void ui_hide() = 0;
140  virtual void ui_bring_to_front() = 0;
141 
142  //operation_cancelled:
143  //e.g. A File|Open tries to save existing data,
144  //but this needs to be cancelled if the save failed.
145  static void set_operation_cancelled(bool bVal = true);
146  static bool get_operation_cancelled();
147 
148  //Member data:
149 
150  //'About Box'/WM Class information:
151  static Glib::ustring m_strAppName;
152 
153  //'About Box' information:
154  static HelpInfo m_HelpInfo;
155 
156  //Instances
158 
159  static bool m_bOperationCancelled; //see set/get_operation_cancelled().
160 
161  //All instances share 1 About box:
162  static bool m_bAboutShown;
163 
164  //Command line args:
165  static Glib::ustring m_strCommandLine_0;
166 
167  type_signal_hide m_signal_hide;
168 
169 
170 
171  //typedef std::vector<poptOption> type_vecPoptOptions;
172  //type_vecPoptOptions m_vecPoptOptions;
173 };
174 
175 } //namespace
176 
177 #endif //BAKERY_APP_H
std::vector< Glib::ustring > type_vecStrings
Definition: App.h:77
sigc::signal< void > type_signal_hide
Definition: App.h:84
void init()
Saves you the trouble of initializing gconfmm and libglademm yourself.
static bool m_bAboutShown
Definition: App.h:162
static HelpInfo m_HelpInfo
Definition: App.h:154
Definition: App.h:29
Bakery&#39;s Main Window.
Definition: App.h:60
static AppInstanceManager m_AppInstanceManager
Definition: App.h:157
static bool m_bOperationCancelled
Definition: App.h:159
static Glib::ustring m_strCommandLine_0
Definition: App.h:165
static Glib::ustring m_strAppName
Definition: App.h:151
Contains a list of App instances.
Definition: AppInstanceManager.h:36
type_signal_hide m_signal_hide
Definition: App.h:167