libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GtkCRNApp.h
Go to the documentation of this file.
1 /* Copyright 2010-2014 CoReNum
2  *
3  * This file is part of libgtkcrnmm.
4  *
5  * libgtkcrnmm is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libgtkcrnmm is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libgtkcrnmm. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: GtkCRNApp.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef GtkCRNApp_HEADER
23 #define GtkCRNApp_HEADER
24 
25 #include <libgtkcrnmm_config.h>
26 #include <gtkmm.h>
27 #include <CRNException.h>
28 #include <vector>
29 
30 namespace GtkCRN
31 {
35  class App:
36 #ifdef CRN_USING_GTKMM3
37  public Gtk::ApplicationWindow
38 #else
39  public Gtk::Window
40 #endif
41  {
42  public:
52  App();
54  virtual ~App() {}
55 
57  static Gtk::Window* get_main_window() { return internal_main_window(); }
59  static void set_main_window(Gtk::Window *win) { internal_main_window() = win; }
60 
62  static void show_message(const Glib::ustring &message, Gtk::MessageType mtype);
64  static void show_exception(crn::Exception &ex, bool kill_app = true);
66  static void show_exception(std::exception &ex, bool kill_app = true);
68  static void show_exception(bool kill_app = true);
69 
70  protected:
72  virtual bool ask_for_quit(GdkEventAny* event);
74  virtual void help() {}
76  virtual void about() {}
78  Glib::ustring ask_for_string(const Glib::ustring &msg, const Glib::ustring &defval = "");
79 
80 #ifdef CRN_USING_GTKMM3
81  Glib::RefPtr<Gio::SimpleActionGroup> actions;
82 #else
83  Glib::RefPtr<Gtk::UIManager> ui_manager;
84  Glib::RefPtr<Gtk::ActionGroup> actions;
85 #endif
86 
87  static Gtk::Window*& internal_main_window();
88  };
89 };
90 
91 #endif
92 
93 
Glib::RefPtr< Gtk::ActionGroup > actions
Definition: GtkCRNApp.h:84
Glib::RefPtr< Gtk::UIManager > ui_manager
Definition: GtkCRNApp.h:83
Base class to create an application.
Definition: GtkCRNApp.h:35
virtual ~App()
Destructor.
Definition: GtkCRNApp.h:54
static void set_main_window(Gtk::Window *win)
Sets the main window of the application to be used as parent for dialogs and messages.
Definition: GtkCRNApp.h:59
static Gtk::Window *& internal_main_window()
Definition: GtkCRNApp.cpp:36
Glib::ustring ask_for_string(const Glib::ustring &msg, const Glib::ustring &defval="")
Shows a dialog asking for a single string.
Definition: GtkCRNApp.cpp:96
static Gtk::Window * get_main_window()
Gets a pointer to the main window.
Definition: GtkCRNApp.h:57
virtual void help()
Displays help (overloadable)
Definition: GtkCRNApp.h:74
static void show_message(const Glib::ustring &message, Gtk::MessageType mtype)
Displays a message.
Definition: GtkCRNApp.cpp:149
virtual void about()
Displays credits (overloadable)
Definition: GtkCRNApp.h:76
static void show_exception(crn::Exception &ex, bool kill_app=true)
Displays an exception.
Definition: GtkCRNApp.cpp:207
App()
Constructor. Creates Actions and adds them to UI manager.
Definition: GtkCRNApp.cpp:55
Base class for exceptions.
Definition: CRNException.h:39
virtual bool ask_for_quit(GdkEventAny *event)
Callback for application quit event (overloadable)
Definition: GtkCRNApp.cpp:76