Workspace.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_H
30 #define PT_FORMS_WORKSPACE_H
31 
32 #include <Pt/Forms/Api.h>
33 #include <Pt/Forms/Control.h>
34 #include <Pt/Forms/WorkspaceManager.h>
35 #include <Pt/Gfx/Point.h>
36 #include <Pt/Gfx/Size.h>
37 #include <Pt/Gfx/Rect.h>
38 
39 namespace Pt {
40 
41 namespace Forms {
42 
54 class PT_FORMS_API Workspace : public Control
55 {
56  friend class WorkspaceManager;
57 
58  typedef Control Base;
59 
60  public:
64 
67  virtual ~Workspace();
68 
69  public:
74  void addWindow(Window& w);
75 
78  void removeWindow(Window& w);
79 
82  const std::vector<Window*>& windows() const;
83 
90 
91  public:
95 
98  const Control* content() const;
99 
105  void setContent(Control* control);
106 
107  //
108  // Widget
109  //
110  protected:
111  virtual void onConnect(Screen& screen);
112 
113  virtual void onDisconnect();
114 
115 
116  virtual Widget* onHitTest(const Gfx::PointF& p);
117 
118  virtual void onRequestResize(const Gfx::SizeF& s);
119 
120  //
121  // Control
122  //
123  protected:
124  virtual void onSetSurface(PaintSurface* surface, const Gfx::PointF& pos);
125 
126  virtual void onRemoveControl(Control& control);
127 
128  virtual Gfx::SizeF onMeasure(const SizePolicy& policy);
129 
130  virtual void onLayout(const Gfx::RectF& rect);
131 
132  virtual void onPaint(PaintContext&, const Gfx::RectF&);
133 
134  protected:
135  virtual void onProcessLayoutEvent(const LayoutEvent& ev);
136 
137  virtual void onProcessRescaleEvent(const RescaleEvent& ev);
138 
139  virtual void onProcessResizeEvent(const ResizeEvent& ev);
140 
141  virtual void onProcessPaintEvent(const PaintEvent& ev);
142 
143  virtual void onProcessEnableEvent(const EnableEvent& ev);
144 
145  protected:
146  virtual void onProcessMouseEvent(const MouseEvent& ev);
147 
148  virtual void onProcessTouchEvent(const TouchEvent& ev);
149 
150  virtual void onProcessScrollEvent(const ScrollEvent& ev);
151 
152  virtual void onProcessEnterEvent(const EnterEvent& ev);
153 
154  virtual void onProcessLeaveEvent(const LeaveEvent& ev);
155 
156  virtual void onProcessKeyEvent(const KeyEvent& ev);
157 
158  //
159  // WindowManager
160  //
161  protected:
162  void onRelayoutRequest(WorkspaceManager& wm);
163 
164  virtual void onRepaint(WindowManager& wm, const Gfx::RectF& rect);
165 
166  virtual void onActivate(WindowManager& wm, bool active);
167 
168  private:
169  WorkspaceManager _wm;
170  Control* _content;
171  Widget* _pointer;
172  Gfx::SizeF _requestedSize;
173 };
174 
175 } // namespace
176 
177 } // namespace
178 
179 #endif // include guard
virtual void onProcessScrollEvent(const ScrollEvent &ev)
Delivers scroll input only while this control accepts input.
Core module.
Definition: Allocator.h:33
Key press or release.
Definition: KeyEvent.h:50
virtual void onProcessPaintEvent(const PaintEvent &ev)
Processes a paint event and paints visible child controls.
Touch press, move, or release.
Definition: TouchEvent.h:51
Pointer entered a widget.
Definition: EnterEvent.h:49
Scroll or wheel movement.
Definition: ScrollEvent.h:51
virtual void onPaint(PaintContext &, const Gfx::RectF &)
Paints custom content in local coordinates.
Reports that a widget was resized.
Definition: ResizeEvent.h:50
virtual void onProcessLeaveEvent(const LeaveEvent &ev)
Dispatches a pointer-leave event.
Forms render target for painting.
Definition: PaintSurface.h:50
Reports a dirty rectangle that a widget must paint.
Definition: PaintEvent.h:48
const Control * content() const
Returns the background content control, or 0.
virtual void onProcessKeyEvent(const KeyEvent &ev)
Delivers key input only while this control accepts input.
virtual ~Workspace()
Detaches managed windows and content.
Form presented by a window manager.
Definition: Window.h:99
virtual void onProcessTouchEvent(const TouchEvent &ev)
Routes touch input to the frontmost eligible child or this control.
Active painting session on a Forms paint surface.
Definition: PaintContext.h:51
Size with floating-point width and height.
Definition: Size.h:47
Common type of every visual Forms object.
Definition: Widget.h:105
virtual void onLayout(const Gfx::RectF &rect)
Assigns geometry to direct children within rect.
Point with floating-point X and Y coordinates.
Definition: Point.h:47
Control * content()
Returns the background content control, or 0.
Reusable view used as application content.
Definition: Control.h:107
virtual void onProcessEnableEvent(const EnableEvent &ev)
Dispatches effective enabled state to this control and its children.
virtual void onProcessResizeEvent(const ResizeEvent &ev)
Dispatches a resize event.
virtual void onProcessRescaleEvent(const RescaleEvent &ev)
Dispatches a scale change to this control and all children.
virtual void onDisconnect()
Disconnects this control and all direct descendants from the screen.
Display root for top-level windows.
Definition: Screen.h:83
Host that attaches windows to a screen or workspace.
Definition: WindowManager.h:68
Widget that hosts controls on a paint surface.
Definition: View.h:86
virtual void onConnect(Screen &screen)
Connects this control and all direct descendants to screen.
WindowManager & windowManager()
Returns the workspace's internal window manager.
virtual Widget * onHitTest(const Gfx::PointF &p)
Returns the frontmost descendant hit at local position p.
virtual void onProcessMouseEvent(const MouseEvent &ev)
Routes mouse input to the frontmost eligible child or this control.
Pointer left a widget.
Definition: LeaveEvent.h:49
Constraint used when measuring a control.
Definition: SizePolicy.h:48
Workspace()
Creates a workspace without content or windows.
virtual void onProcessLayoutEvent(const LayoutEvent &ev)
Processes a pending layout event.
void setContent(Control *control)
Replaces the background content with control.
Internal window manager used by a workspace.
Definition: WorkspaceManager.h:58
virtual void onRequestResize(const Gfx::SizeF &s)
Records and forwards a resize request to the parent view.
virtual void onRemoveControl(Control &control)
Notifies after control stops being a direct child.
Rect with floating-point coordinates.
Definition: Rect.h:47
virtual Gfx::SizeF onMeasure(const SizePolicy &policy)
Measures intrinsic content for effective policy policy.
void removeWindow(Window &w)
Detaches w without destroying it.
const std::vector< Window * > & windows() const
Returns the windows currently attached to this workspace.
Control that presents windows in its own bounds.
Definition: Workspace.h:55
virtual void onSetSurface(PaintSurface *surface, const Gfx::PointF &pos)
Propagates a surface assignment to direct children.
void addWindow(Window &w)
Attaches w to this workspace's window manager.
Pointer movement or button change.
Definition: MouseEvent.h:134
virtual void onProcessEnterEvent(const EnterEvent &ev)
Dispatches a pointer-entry event.