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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2894 - (hide annotations) (download) (as text)
Sat Apr 30 14:42:14 2016 UTC (7 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3242 byte(s)
* Enabled auto save & restore of window size & position of all
  remaining windows.
* Bumped version (1.0.0.svn7).

1 schoenebeck 2893 /*
2     Copyright (c) 2016 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 <glibmm/object.h>
12     #include <gtkmm/window.h>
13 schoenebeck 2894 #include <gtkmm/dialog.h>
14 schoenebeck 2893 #include <glibmm/main.h>
15     #include "Settings.h"
16    
17     /** @brief Base class intended to be used for all gigedit Windows.
18     *
19     * This class aims to provide common functionalities for all Windows of the
20     * gigedit application. So usually all gigedit Windows should derive from this
21     * class.
22     *
23     * Currently this class only automatically saves and restores the user's
24     * preference for the respective Windows position on the screen and size of the
25     * window. It saves the position and dimensions automatically as soon as the
26     * user moves or resizes the window. And it automatically restores the window's
27     * position and size when it is created.
28     */
29     class ManagedWindow : public Gtk::Window {
30     public:
31     ManagedWindow();
32    
33     // following methods must be implemented by deriving class
34     virtual Settings::Property<int>* windowSettingX() = 0;
35     virtual Settings::Property<int>* windowSettingY() = 0;
36     virtual Settings::Property<int>* windowSettingWidth() = 0;
37     virtual Settings::Property<int>* windowSettingHeight() = 0;
38    
39     protected:
40     bool on_configure_event(GdkEventConfigure* e);
41     void enableListeningConfigureEvents() { m_listenOnConfigureEvents = true; }
42     bool saveWindowDimensions(int x, int y, int w, int h);
43     void restoreWindowDimensions();
44     private:
45     Gtk::Window* m_window;
46     bool m_listenOnConfigureEvents;
47     Glib::RefPtr<Glib::TimeoutSource> m_eventThrottleTimer;
48     };
49    
50 schoenebeck 2894 /** @brief Base class intended to be used for all gigedit dialogs.
51     *
52     * This class aims to provide common functionalities for all dialogs of the
53     * gigedit application. So usually all gigedit dialogs should derive from this
54     * class.
55     *
56     * This class essentially is a copy of ManagedWindow. Due to inheritance
57     * issues there is unfortunately not much that could be avoided regarding code
58     * duplication by using a common both class for both. That's why all code is
59     * simply copied for now.
60     */
61     class ManagedDialog : public Gtk::Dialog {
62     public:
63     ManagedDialog();
64     ManagedDialog(const Glib::ustring& title, bool modal = false);
65     explicit ManagedDialog(const Glib::ustring& title, Gtk::Window& parent, bool modal = false);
66     //ManagedDialog(const Glib::ustring& title, Gtk::DialogFlags flags);
67    
68     // following methods must be implemented by deriving class
69     virtual Settings::Property<int>* windowSettingX() = 0;
70     virtual Settings::Property<int>* windowSettingY() = 0;
71     virtual Settings::Property<int>* windowSettingWidth() = 0;
72     virtual Settings::Property<int>* windowSettingHeight() = 0;
73    
74     protected:
75     bool on_configure_event(GdkEventConfigure* e);
76     void enableListeningConfigureEvents() { m_listenOnConfigureEvents = true; }
77     bool saveWindowDimensions(int x, int y, int w, int h);
78     void restoreWindowDimensions();
79     void initManagedDialog();
80     private:
81     Gtk::Window* m_window;
82     bool m_listenOnConfigureEvents;
83     Glib::RefPtr<Glib::TimeoutSource> m_eventThrottleTimer;
84     };
85    
86 schoenebeck 2893 #endif // MANAGED_WINDOW_H

  ViewVC Help
Powered by ViewVC