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 
43 class PT_FORMS_API Workspace : public Control
44 {
45  friend class WorkspaceManager;
46 
47  typedef Control Base;
48 
49  public:
50  Workspace();
51 
52  virtual ~Workspace();
53 
54  public:
55  void addWindow(Window& w);
56 
57  void removeWindow(Window& w);
58 
59  const std::vector<Window*>& windows() const;
60 
61  WindowManager& windowManager();
62 
63  public:
64  Control* content();
65 
66  const Control* content() const;
67 
68  void setContent(Control* control);
69 
70  //
71  // Widget
72  //
73  protected:
74  virtual void onConnect(Screen& screen);
75 
76  virtual void onDisconnect();
77 
78 
79  virtual Widget* onHitTest(const Gfx::PointF& p);
80 
81  virtual void onRequestResize(const Gfx::SizeF& s);
82 
83  //
84  // Control
85  //
86  protected:
87  virtual void onSetSurface(PaintSurface* surface, const Gfx::PointF& pos);
88 
89  virtual void onRemoveControl(Control& control);
90 
91  virtual Gfx::SizeF onMeasure(const SizePolicy& policy);
92 
93  virtual void onLayout(const Gfx::RectF& rect);
94 
95  virtual void onPaint(PaintSurface&, const Gfx::RectF&);
96 
97  protected:
98  virtual void onProcessLayoutEvent(const LayoutEvent& ev);
99 
100  virtual void onProcessRescaleEvent(const RescaleEvent& ev);
101 
102  virtual void onProcessResizeEvent(const ResizeEvent& ev);
103 
104  virtual void onProcessPaintEvent(const PaintEvent& ev);
105 
106  virtual void onProcessEnableEvent(const EnableEvent& ev);
107 
108  protected:
109  virtual void onProcessMouseEvent(const MouseEvent& ev);
110 
111  virtual void onProcessTouchEvent(const TouchEvent& ev);
112 
113  virtual void onProcessScrollEvent(const ScrollEvent& ev);
114 
115  virtual void onProcessEnterEvent(const EnterEvent& ev);
116 
117  virtual void onProcessLeaveEvent(const LeaveEvent& ev);
118 
119  virtual void onProcessKeyEvent(const KeyEvent& ev);
120 
121  //
122  // WindowManager
123  //
124  protected:
125  void onRelayoutRequest(WorkspaceManager& wm);
126 
127  virtual void onRepaint(WindowManager& wm, const Gfx::RectF& rect);
128 
129  virtual void onActivate(WindowManager& wm, bool active);
130 
131  private:
132  WorkspaceManager _wm;
133  Control* _content;
134  Widget* _pointer;
135  Gfx::SizeF _requestedSize;
136 };
137 
138 } // namespace
139 
140 } // namespace
141 
142 #endif // include guard