WorkspaceManager.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,
26  MA 02110-1301 USA
27 */
28 
29 #ifndef PT_FORMS_WORKSPACE_MANAGER_H
30 #define PT_FORMS_WORKSPACE_MANAGER_H
31 
32 #include <Pt/Forms/Api.h>
33 #include <Pt/Forms/WindowManager.h>
34 #include <Pt/Forms/Widget.h>
35 #include <Pt/Gfx/Point.h>
36 #include <Pt/Gfx/Size.h>
37 #include <Pt/Gfx/Rect.h>
38 
39 #include <vector>
40 #include <map>
41 
42 namespace Pt {
43 
44 namespace Forms {
45 
46 class WorkspaceFrame;
47 
48 class Workspace;
49 
50 class WorkspaceManager : public WindowManager
51 {
52  typedef WindowManager Base;
53 
54  friend class Workspace;
55  friend class WorkspaceFrame;
56 
57  public:
58  WorkspaceManager();
59 
60  virtual ~WorkspaceManager();
61 
62  void setParent(Workspace* workspace);
63 
64  //Gfx::PaintSurface& surface();
65 
66  //const Gfx::PaintSurface& surface() const;
67 
68  //void setSurface(Gfx::PaintSurface* surface, const Gfx::PointF& pos);
69 
70  bool processMouseEvent(const MouseEvent& ev);
71 
72  bool processTouchEvent(const TouchEvent& ev);
73 
74  public:
75  Window* activeWindow();
76 
77  const std::vector<Window*>& windows() const;
78 
79  double borderWidth() const
80  {
81  return _borderWidth;
82  }
83 
84  double titleHeight() const
85  {
86  return _titleHeight;
87  }
88 
89  const Gfx::Color& inactiveColor() const
90  {
91  return _inactiveColor;
92  }
93 
94  const Gfx::Color& activeColor() const
95  {
96  return _activeColor;
97  }
98 
99  const Gfx::Color& textColor() const
100  {
101  return _textColor;
102  }
103 
104  const Gfx::Color& inactiveTextColor() const
105  {
106  return _inactiveTextColor;
107  }
108 
109  //
110  // layouting
111  //
112  protected:
113  virtual void onProcessLayoutEvent(const LayoutEvent& ev);
114 
115  virtual void onLayoutEvent(const LayoutEvent& ev);
116 
117  virtual void onLayout(const Gfx::RectF& rect);
118 
119  //
120  // WindowManager
121  //
122  protected:
123  virtual void onRequestRelayout();
124 
125  protected:
126  virtual WindowFrame* onAttach(Window& w);
127 
128  virtual void onDetach(WindowFrame& w);
129 
130  virtual void onInit(WindowFrame& w);
131 
132  virtual void onRelease(WindowFrame& w);
133 
134  protected:
135  Gfx::PointF toFrame(const WorkspaceFrame& w,
136  const Gfx::PointF& pos) const;
137 
138  Gfx::PointF fromFrame(const WorkspaceFrame& w,
139  const Gfx::PointF& pos) const;
140 
141  virtual void onSetAbove(WorkspaceFrame& w, bool above);
142 
143  virtual void onSetSizeLimits(WorkspaceFrame& w,
144  const Gfx::SizeF& minSize,
145  const Gfx::SizeF& maxSize);
146 
147  virtual void onAutoCenter(WindowFrame& w, const Gfx::SizeF* size);
148 
149  virtual void onShow(WorkspaceFrame& w, bool visible);
150 
151  virtual void onActivate(WorkspaceFrame& w, bool active);
152 
153  virtual void onEnable(WorkspaceFrame& w, bool enable);
154 
155  virtual void onMove(WorkspaceFrame& w, const Gfx::PointF& to);
156 
157  virtual void onResize(WorkspaceFrame& w, const Gfx::SizeF& to);
158 
159  virtual void onClose(WorkspaceFrame& w);
160 
161  //
162  // Widget
163  //
164  protected:
165  virtual void onConnect(Screen& screen);
166 
167  virtual void onDisconnect();
168 
169 
170  virtual Gfx::PointF onToParent(const Gfx::PointF& pos) const;
171 
172  virtual Gfx::PointF onFromParent(const Gfx::PointF& pos) const;
173 
174  virtual Widget* onHitTest(const Gfx::PointF& p);
175 
176 
177  virtual void onRequestRepaint(const Gfx::RectF& rect);
178 
179  virtual void onRequestActivate(bool active);
180 
181  virtual void onRequestCapture(bool capture);
182 
183  protected:
184  virtual void onProcessEvent(const Pt::Event& ev);
185 
186  virtual void onProcessRescaleEvent(const RescaleEvent& ev);
187 
188  virtual void onProcessPaintEvent(const PaintEvent& ev);
189 
190  virtual void onProcessEnableEvent(const EnableEvent& ev);
191 
192  virtual void onProcessResizeEvent(const ResizeEvent& ev);
193 
194  virtual void onResizeEvent(const ResizeEvent& ev);
195 
196  virtual void onProcessMouseEvent(const MouseEvent& ev);
197 
198  virtual void onProcessTouchEvent(const TouchEvent& ev);
199 
200  virtual void onProcessScrollEvent(const ScrollEvent& ev);
201 
202  virtual void onProcessEnterEvent(const EnterEvent& ev);
203 
204  virtual void onProcessLeaveEvent(const LeaveEvent& ev);
205 
206  virtual void onProcessKeyEvent(const KeyEvent& ev);
207 
208  private:
209  Workspace* _parent;
210 
211  std::vector<Window*> _windows;
212  std::vector<Window*> _windowStack;
213 
214  Window* _activeWindow;
215  Window* _topMostWindow;
216  std::map<Window*, Gfx::RectF> _autoCenter;
217 
218  double _borderWidth;
219  double _titleHeight;
220  Gfx::Color _activeColor;
221  Gfx::Color _inactiveColor;
222  Gfx::Color _textColor;
223  Gfx::Color _inactiveTextColor;
224 };
225 
226 } // namespace
227 
228 } // namespace
229 
230 #endif // include guard
Base class for all event types.
Definition: Event.h:49