/[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 2893 - (hide annotations) (download) (as text)
Fri Apr 29 14:19:53 2016 UTC (8 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 1697 byte(s)
* Automatically save & restore window size and position
  (yet limited to main window and script editor window).
* Bumped version (1.0.0.svn6).

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     #include <glibmm/main.h>
14     #include "Settings.h"
15    
16     /** @brief Base class intended to be used for all gigedit Windows.
17     *
18     * This class aims to provide common functionalities for all Windows of the
19     * gigedit application. So usually all gigedit Windows should derive from this
20     * class.
21     *
22     * Currently this class only automatically saves and restores the user's
23     * preference for the respective Windows position on the screen and size of the
24     * window. It saves the position and dimensions automatically as soon as the
25     * user moves or resizes the window. And it automatically restores the window's
26     * position and size when it is created.
27     */
28     class ManagedWindow : public Gtk::Window {
29     public:
30     ManagedWindow();
31    
32     // following methods must be implemented by deriving class
33     virtual Settings::Property<int>* windowSettingX() = 0;
34     virtual Settings::Property<int>* windowSettingY() = 0;
35     virtual Settings::Property<int>* windowSettingWidth() = 0;
36     virtual Settings::Property<int>* windowSettingHeight() = 0;
37    
38     protected:
39     bool on_configure_event(GdkEventConfigure* e);
40     void enableListeningConfigureEvents() { m_listenOnConfigureEvents = true; }
41     bool saveWindowDimensions(int x, int y, int w, int h);
42     void restoreWindowDimensions();
43     private:
44     Gtk::Window* m_window;
45     bool m_listenOnConfigureEvents;
46     Glib::RefPtr<Glib::TimeoutSource> m_eventThrottleTimer;
47     };
48    
49     #endif // MANAGED_WINDOW_H

  ViewVC Help
Powered by ViewVC