WindowManager.h
1 /* Copyright (C) 2015 Marc Boris Duerner
2 
3  This library is free software; you can redistribute it and/or
4  modify it under the terms of the GNU Lesser General Public
5  License as published by the Free Software Foundation; either
6  version 2.1 of the License, or (at your option) any later version.
7 
8  As a special exception, you may use this file as part of a free
9  software library without restriction. Specifically, if other files
10  instantiate templates or use macros or inline functions from this
11  file, or you compile this file and link it with other files to
12  produce an executable, this file does not by itself cause the
13  resulting executable to be covered by the GNU General Public
14  License. This exception does not however invalidate any other
15  reasons why the executable file might be covered by the GNU Library
16  General Public License.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with this library; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301 USA
27 */
28 
29 #ifndef PT_FORMS_WINDOWMANAGER_H
30 #define PT_FORMS_WINDOWMANAGER_H
31 
32 #include <Pt/Forms/Widget.h>
33 #include <Pt/Forms/Window.h>
34 #include <Pt/Gfx/Size.h>
35 
36 namespace Pt {
37 
38 namespace Forms {
39 
40 class Window;
41 class WindowFrame;
42 
67 class WindowManager : public Widget
68 {
69  friend class Window;
70 
71  public:
74  typedef Widget Base;
75 
76  public:
80 
83  virtual ~WindowManager();
84 
90  void relayout();
91 
99  {
100  return _surfaceChanged;
101  }
102 
103  // TODO:
104 
105  //void addWindow(Window& w)
106  //{
107  // w.setParent(*this);
108  //}
109 
110  //void removeWindow(Window& w)
111  //{
112  // if(w.windowManager() == this)
113  // w.unparent();
114  //}
115 
116  //std::vector<Pt::Forms::Window*>& windows()
117  //{
118  // return _windows;
119  //}
120 
121  //Pt::Signal<Window&>& windowAdded()
122  //{
123  // return _windowAdded;
124  //}
125 
126  //Pt::Signal<Window&>& windowRemoved()
127  //{
128  // return _windowRemoved;
129  //}
130 
131  protected:
137  virtual void onConnect(Screen& screen);
138 
144  virtual void onDisconnect();
145 
151  virtual void onRequestRelayout();
152 
153  protected:
159  virtual void onProcessPaintEvent(const PaintEvent& ev);
160 
165  virtual void onPaintEvent(const PaintEvent& ev);
166 
167  protected:
175  virtual WindowFrame* onAttach(Window& window) = 0;
176 
182  virtual void onDetach(WindowFrame& frame) = 0;
183 
190  virtual void onInit(WindowFrame& frame) = 0;
191 
197  virtual void onRelease(WindowFrame& frame) = 0;
198 
199  //virtual void onAutoCenter(WindowFrame& w, bool enable) = 0;
200 
201  private:
202  Pt::Signal<Window&> _surfaceChanged;
203 
204  //std::vector<Pt::Forms::Window*> _windows;
205  //Pt::Signal<Window&> _windowAdded;
206  //Pt::Signal<Window&> _windowRemoved;
207 };
208 
209 } // namespace
210 
211 } // namespace
212 
213 #endif
Core module.
Definition: Allocator.h:33
void relayout()
Requests a relayout of hosted windows.
Multicast Signal to call multiple slots.
Definition: Signal.h:190
virtual WindowFrame * onAttach(Window &window)=0
Creates and registers a frame for window.
Reports a dirty rectangle that a widget must paint.
Definition: PaintEvent.h:48
Form presented by a window manager.
Definition: Window.h:99
virtual ~WindowManager()
Destroys the window host.
virtual void onProcessPaintEvent(const PaintEvent &ev)
Processes a paint event through the Widget event path.
Common type of every visual Forms object.
Definition: Widget.h:105
Pt::Signal< Window & > & surfaceChanged()
Returns the signal sent after a window backing pixmap is synchronized.
Definition: WindowManager.h:98
virtual void onRequestRelayout()
Handles a request to relayout hosted windows.
Screen * screen()
Returns the connected screen, or 0 when disconnected.
Display root for top-level windows.
Definition: Screen.h:83
virtual void onConnect(Screen &screen)
Connects this host to screen.
virtual void onDisconnect()
Disconnects this host from its screen.
Host that attaches windows to a screen or workspace.
Definition: WindowManager.h:68
virtual void onInit(WindowFrame &frame)=0
Initializes frame after the frame initializes its window.
WindowManager()
Creates a disconnected host for window frames.
virtual void onRelease(WindowFrame &frame)=0
Releases frame before it is detached and deleted.
virtual void onDetach(WindowFrame &frame)=0
Unregisters frame from this host.
Widget Base
Defines the base widget type.
Definition: WindowManager.h:74
virtual void onPaintEvent(const PaintEvent &ev)
Handles a paint event after standard processing.