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/Forms/Painter.h>
36#include <Pt/Gfx/Point.h>
37#include <Pt/Gfx/Size.h>
38#include <Pt/Gfx/Rect.h>
39
40#include <vector>
41#include <map>
42
43namespace Pt {
44
45namespace Forms {
46
47class WorkspaceFrame;
48
49class Workspace;
50
58{
59 typedef WindowManager Base;
60
61 friend class Workspace;
62 friend class WorkspaceFrame;
63
64 public:
68
72
75 void setParent(Workspace* workspace);
76
77 //Gfx::PaintSurface& surface();
78
79 //const Gfx::PaintSurface& surface() const;
80
81 //void setSurface(Gfx::PaintSurface* surface, const Gfx::PointF& pos);
82
88
94
95 public:
98 Window* activeWindow();
99
102 const std::vector<Window*>& windows() const;
103
106 double borderWidth() const
107 {
108 return _borderWidth;
109 }
110
113 double titleHeight() const
114 {
115 return _titleHeight;
116 }
117
121 {
122 return _inactiveColor;
123 }
124
127 const Gfx::Color& activeColor() const
128 {
129 return _activeColor;
130 }
131
134 const Gfx::Color& textColor() const
135 {
136 return _textColor;
137 }
138
142 {
143 return _inactiveTextColor;
144 }
145
146 //
147 // layouting
148 //
149 protected:
150 virtual void onProcessLayoutEvent(const LayoutEvent& ev);
151
152 virtual void onLayoutEvent(const LayoutEvent& ev);
153
154 virtual void onLayout(const Gfx::RectF& rect);
155
156 //
157 // WindowManager
158 //
159 protected:
160 virtual void onRequestRelayout();
161
162 protected:
163 virtual WindowFrame* onAttach(Window& w);
164
165 virtual void onDetach(WindowFrame& w);
166
167 virtual void onInit(WindowFrame& w);
168
169 virtual void onRelease(WindowFrame& w);
170
171 protected:
172 Gfx::PointF toFrame(const WorkspaceFrame& w,
173 const Gfx::PointF& pos) const;
174
175 Gfx::PointF fromFrame(const WorkspaceFrame& w,
176 const Gfx::PointF& pos) const;
177
178 virtual void onSetAbove(WorkspaceFrame& w, bool above);
179
180 virtual void onSetSizeLimits(WorkspaceFrame& w,
181 const Gfx::SizeF& minSize,
182 const Gfx::SizeF& maxSize);
183
184 virtual void onAutoCenter(WindowFrame& w, const Gfx::SizeF* size);
185
186 virtual void onShow(WorkspaceFrame& w, bool visible);
187
188 virtual void onActivate(WorkspaceFrame& w, bool active);
189
190 virtual void onEnable(WorkspaceFrame& w, bool enable);
191
192 virtual void onMove(WorkspaceFrame& w, const Gfx::PointF& to);
193
194 virtual void onResize(WorkspaceFrame& w, const Gfx::SizeF& to);
195
196 virtual void onClose(WorkspaceFrame& w);
197
198 //
199 // Widget
200 //
201 protected:
202 virtual void onConnect(Screen& screen);
203
204 virtual void onDisconnect();
205
206
207 virtual Gfx::PointF onToParent(const Gfx::PointF& pos) const;
208
209 virtual Gfx::PointF onFromParent(const Gfx::PointF& pos) const;
210
211 virtual Widget* onHitTest(const Gfx::PointF& p);
212
213
214 virtual void onRequestRepaint(const Gfx::RectF& rect);
215
216 virtual void onRequestActivate(bool active);
217
218 virtual void onRequestCapture(bool capture);
219
220 protected:
221 virtual void onProcessEvent(const Pt::Event& ev);
222
223 virtual void onProcessRescaleEvent(const RescaleEvent& ev);
224
225 virtual void onProcessPaintEvent(const PaintEvent& ev);
226
227 virtual void onProcessEnableEvent(const EnableEvent& ev);
228
229 virtual void onProcessResizeEvent(const ResizeEvent& ev);
230
231 virtual void onResizeEvent(const ResizeEvent& ev);
232
233 virtual void onProcessMouseEvent(const MouseEvent& ev);
234
235 virtual void onProcessTouchEvent(const TouchEvent& ev);
236
237 virtual void onProcessScrollEvent(const ScrollEvent& ev);
238
239 virtual void onProcessEnterEvent(const EnterEvent& ev);
240
241 virtual void onProcessLeaveEvent(const LeaveEvent& ev);
242
243 virtual void onProcessKeyEvent(const KeyEvent& ev);
244
245 private:
246 Workspace* _parent;
247
248 std::vector<Window*> _windows;
249 std::vector<Window*> _windowStack;
250
251 Window* _activeWindow;
252 Window* _topMostWindow;
253 std::map<Window*, Gfx::RectF> _autoCenter;
254
255 Forms::Painter _painter;
256
257 double _borderWidth;
258 double _titleHeight;
259 Gfx::Color _activeColor;
260 Gfx::Color _inactiveColor;
261 Gfx::Color _textColor;
262 Gfx::Color _inactiveTextColor;
263};
264
265} // namespace
266
267} // namespace
268
269#endif // include guard
Base class for typed events.
Definition Event.h:66
Pointer entered a widget.
Definition EnterEvent.h:49
Key press or release.
Definition KeyEvent.h:50
Pointer left a widget.
Definition LeaveEvent.h:49
Pointer movement or button change.
Definition MouseEvent.h:134
Reports a dirty rectangle that a widget must paint.
Definition PaintEvent.h:48
Draws on a Forms paint surface or paint context.
Definition Painter.h:53
Reports that a widget was resized.
Definition ResizeEvent.h:50
Display root for top-level windows.
Definition Screen.h:83
Scroll or wheel movement.
Definition ScrollEvent.h:51
Touch press, move, or release.
Definition TouchEvent.h:51
Common type of every visual Forms object.
Definition Widget.h:105
virtual void enable(bool isEnable=true)
Requests that the widget be enabled or disabled.
const Gfx::SizeF & size() const
Returns the size in local logical coordinates.
Screen * screen()
Returns the connected screen, or 0 when disconnected.
WindowManager()
Creates a disconnected host for window frames.
virtual void onProcessLeaveEvent(const LeaveEvent &ev)
Delivers a leave event through the responder chain.
virtual void onDetach(WindowFrame &w)
Unregisters frame from this host.
virtual ~WorkspaceManager()
Destroys the workspace window manager.
bool processTouchEvent(const TouchEvent &ev)
Processes ev for the hosted windows.
virtual void onProcessRescaleEvent(const RescaleEvent &ev)
Dispatches a rescale event.
const Gfx::Color & textColor() const
Returns the title text color of the active workspace window.
Definition WorkspaceManager.h:134
virtual void onDisconnect()
Disconnects this host from its screen.
const std::vector< Window * > & windows() const
Returns the windows attached to this workspace.
void setParent(Workspace *workspace)
Sets the workspace that contains this manager.
double borderWidth() const
Returns the width of each workspace window border.
Definition WorkspaceManager.h:106
virtual Widget * onHitTest(const Gfx::PointF &p)
Returns the descendant hit at local position pos.
virtual void onRequestRelayout()
Handles a request to relayout hosted windows.
virtual void onResizeEvent(const ResizeEvent &ev)
Updates the local size and bounds from a resize event.
virtual void onProcessResizeEvent(const ResizeEvent &ev)
Dispatches a resize event.
virtual void onConnect(Screen &screen)
Connects this host to screen.
virtual void onProcessEvent(const Pt::Event &ev)
Sends ev to the widget event dispatcher.
virtual Gfx::PointF onFromParent(const Gfx::PointF &pos) const
Converts parent position pos to local coordinates.
const Gfx::Color & inactiveTextColor() const
Returns the title text color of an inactive workspace window.
Definition WorkspaceManager.h:141
const Gfx::Color & activeColor() const
Returns the border color of the active workspace window.
Definition WorkspaceManager.h:127
virtual void onProcessMouseEvent(const MouseEvent &ev)
Updates pointer tracking and delivers a mouse event.
virtual void onProcessEnterEvent(const EnterEvent &ev)
Delivers an enter event through the responder chain.
WorkspaceManager()
Creates a detached workspace window manager.
virtual void onRelease(WindowFrame &w)
Releases frame before it is detached and deleted.
bool processMouseEvent(const MouseEvent &ev)
Processes ev for the hosted windows.
const Gfx::Color & inactiveColor() const
Returns the border color of an inactive workspace window.
Definition WorkspaceManager.h:120
virtual void onProcessScrollEvent(const ScrollEvent &ev)
Delivers a scroll event through the responder chain.
virtual void onRequestActivate(bool active)
Forwards a request to activate or deactivate the widget.
virtual void onInit(WindowFrame &w)
Initializes frame after the frame initializes its window.
double titleHeight() const
Returns the height of each workspace window title area.
Definition WorkspaceManager.h:113
virtual void onRequestCapture(bool capture)
Requests application-managed pointer capture or release.
virtual void onRequestRepaint(const Gfx::RectF &rect)
Forwards a repaint request for local rectangle rect.
Window * activeWindow()
Returns the active hosted window, or null.
virtual void onProcessPaintEvent(const PaintEvent &ev)
Processes a paint event through the Widget event path.
virtual void onProcessEnableEvent(const EnableEvent &ev)
Dispatches an enable event.
virtual void onProcessKeyEvent(const KeyEvent &ev)
Delivers a key event through the responder chain.
virtual void onProcessTouchEvent(const TouchEvent &ev)
Updates pointer tracking and delivers a touch event.
virtual WindowFrame * onAttach(Window &w)
Creates and registers a frame for window.
virtual Gfx::PointF onToParent(const Gfx::PointF &pos) const
Converts local position pos to parent coordinates.
Control that presents windows in its own bounds.
Definition Workspace.h:55
8-bit ARGB color.
Definition Color.h:65
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33