/[svn]/gigedit/trunk/src/gigedit/ManagedWindow.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/ManagedWindow.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3364 - (show annotations) (download) (as text)
Tue Nov 14 18:07:25 2017 UTC (6 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3881 byte(s)
* Added experimental support for upcoming GTK(MM)4
  (for now up to GTKMM 3.91.2 while still preserving backward compatibility
  down to GTKMM 2).
* Re-merged r2845 to compile now with and without Gtk "Stock ID" API
  (see also r3158).

1 /*
2 Copyright (c) 2016 - 2017 Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #ifndef MANAGED_WINDOW_H
9 #define MANAGED_WINDOW_H
10
11 #include "compat.h"
12 #include <glibmm/object.h>
13 #include <gtkmm/window.h>
14 #if USE_GTKMM_BUILDER
15 # include <gtkmm/applicationwindow.h>
16 #endif
17 #include <gtkmm/dialog.h>
18 #include <glibmm/main.h>
19 #include "Settings.h"
20
21 /** @brief Base class intended to be used for all gigedit Windows.
22 *
23 * This class aims to provide common functionalities for all Windows of the
24 * gigedit application. So usually all gigedit Windows should derive from this
25 * class.
26 *
27 * Currently this class only automatically saves and restores the user's
28 * preference for the respective Windows position on the screen and size of the
29 * window. It saves the position and dimensions automatically as soon as the
30 * user moves or resizes the window. And it automatically restores the window's
31 * position and size when it is created.
32 */
33 class ManagedWindow :
34 #if USE_GTKMM_BUILDER
35 public Gtk::ApplicationWindow
36 #else
37 public Gtk::Window
38 #endif
39 {
40 public:
41 ManagedWindow();
42
43 // following methods must be implemented by deriving class
44 virtual Settings::Property<int>* windowSettingX() = 0;
45 virtual Settings::Property<int>* windowSettingY() = 0;
46 virtual Settings::Property<int>* windowSettingWidth() = 0;
47 virtual Settings::Property<int>* windowSettingHeight() = 0;
48
49 protected:
50 #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
51 bool on_configure_event(Gdk::EventConfigure& event);
52 #else
53 bool on_configure_event(GdkEventConfigure* e);
54 #endif
55 void enableListeningConfigureEvents() { m_listenOnConfigureEvents = true; }
56 bool saveWindowDimensions(int x, int y, int w, int h);
57 void restoreWindowDimensions();
58 private:
59 Gtk::Window* m_window;
60 bool m_listenOnConfigureEvents;
61 Glib::RefPtr<Glib::TimeoutSource> m_eventThrottleTimer;
62 };
63
64 /** @brief Base class intended to be used for all gigedit dialogs.
65 *
66 * This class aims to provide common functionalities for all dialogs of the
67 * gigedit application. So usually all gigedit dialogs should derive from this
68 * class.
69 *
70 * This class essentially is a copy of ManagedWindow. Due to inheritance
71 * issues there is unfortunately not much that could be avoided regarding code
72 * duplication by using a common both class for both. That's why all code is
73 * simply copied for now.
74 */
75 class ManagedDialog : public Gtk::Dialog {
76 public:
77 ManagedDialog();
78 ManagedDialog(const Glib::ustring& title, bool modal = false);
79 explicit ManagedDialog(const Glib::ustring& title, Gtk::Window& parent, bool modal = false);
80 //ManagedDialog(const Glib::ustring& title, Gtk::DialogFlags flags);
81
82 // following methods must be implemented by deriving class
83 virtual Settings::Property<int>* windowSettingX() = 0;
84 virtual Settings::Property<int>* windowSettingY() = 0;
85 virtual Settings::Property<int>* windowSettingWidth() = 0;
86 virtual Settings::Property<int>* windowSettingHeight() = 0;
87
88 protected:
89 #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
90 bool on_configure_event(Gdk::EventConfigure& event);
91 #else
92 bool on_configure_event(GdkEventConfigure* e);
93 #endif
94 void enableListeningConfigureEvents() { m_listenOnConfigureEvents = true; }
95 bool saveWindowDimensions(int x, int y, int w, int h);
96 void restoreWindowDimensions();
97 void initManagedDialog();
98 private:
99 Gtk::Window* m_window;
100 bool m_listenOnConfigureEvents;
101 Glib::RefPtr<Glib::TimeoutSource> m_eventThrottleTimer;
102 };
103
104 #endif // MANAGED_WINDOW_H

  ViewVC Help
Powered by ViewVC