Screen.h
1 /* Copyright (C) 2015 Marc Boris Duerner
2  Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  As a special exception, you may use this file as part of a free
10  software library without restriction. Specifically, if other files
11  instantiate templates or use macros or inline functions from this
12  file, or you compile this file and link it with other files to
13  produce an executable, this file does not by itself cause the
14  resulting executable to be covered by the GNU General Public
15  License. This exception does not however invalidate any other
16  reasons why the executable file might be covered by the GNU Library
17  General Public License.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library; if not, write to the Free Software
26  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27  MA 02110-1301 USA
28 */
29 
30 #ifndef Pt_Forms_Screen_H
31 #define Pt_Forms_Screen_H
32 
33 #include <Pt/Forms/Api.h>
34 #include <Pt/Forms/Widget.h>
35 #include <Pt/Gfx/Size.h>
36 #include <Pt/System/Clock.h>
37 #include <Pt/Signal.h>
38 
39 #include <vector>
40 
41 namespace Pt {
42 
43 namespace Forms {
44 
45 class ScreenImpl;
46 class ApplicationImpl;
47 
48 class Window;
49 class WindowManager;
50 class RescaleEvent;
51 
54 class PT_FORMS_API Screen : public Widget
55 {
56  friend class ScreenImpl;
57 
58  typedef Widget Base;
59 
60  public:
61  Screen(ApplicationImpl& app);
62 
63  virtual ~Screen();
64 
65 
66  void addWindow(Window& w);
67 
68  void removeWindow(Window& w);
69 
70  const std::vector<Window*>& windows() const;
71 
72  WindowManager& windowManager();
73 
74 
75  Widget* underPointer();
76 
77  void setPointer(Widget* widget);
78 
79  void setPointer(Widget& widget, bool isPointer);
80 
81  public:
82  ScreenImpl* impl();
83 
84  protected:
85  virtual void onInit(ScreenImpl& s);
86 
87  virtual void onRelease(ScreenImpl& s);
88 
89  virtual void onResize(ScreenImpl& s, const Gfx::SizeF& size);
90 
91  virtual void onShow(ScreenImpl& s, bool isShow);
92 
93  // TODO: name clash with Widget base class
94  using Base::onShow;
95 
96  //
97  // Widget
98  //
99  protected:
100  virtual Widget* onHitTest(const Gfx::PointF& pos);
101 
102  virtual Gfx::PointF onToParent(const Gfx::PointF& pos) const;
103 
104  virtual Gfx::PointF onFromParent(const Gfx::PointF& pos) const;
105 
106  virtual Gfx::PointF onToGlobal(const Gfx::PointF& pos) const;
107 
108  virtual Gfx::PointF onFromGlobal(const Gfx::PointF& pos) const;
109 
110  virtual void onProcessEvent( const Event& ev );
111 
112  virtual void onRequestRepaint(const Gfx::RectF& rect);
113 
114  protected:
115  virtual void onProcessRescaleEvent(const RescaleEvent& ev);
116 
117  virtual void onRescaleEvent(const RescaleEvent& ev);
118 
119  virtual void onRescale(double scaling);
120 
121  protected:
122  virtual void onProcessPaintEvent(const PaintEvent& ev);
123 
124  virtual void onPaintEvent(const PaintEvent& ev);
125 
126  virtual void onPaint(const Gfx::RectF& rect);
127 
128  protected:
129  virtual void onProcessResizeEvent(const ResizeEvent& ev);
130 
131  virtual void onResizeEvent(const ResizeEvent& ev);
132 
133  protected:
134  virtual void onProcessMouseEvent(const MouseEvent& ev);
135 
136  virtual void onProcessTouchEvent(const TouchEvent& ev);
137 
138  virtual void onProcessScrollEvent(const ScrollEvent& ev);
139 
140  virtual void onProcessKeyEvent(const KeyEvent& ev);
141 
142  //
143  // Responder
144  //
145  protected:
146  virtual bool onMouseEvent(const MouseEvent& ev);
147 
148  virtual bool onTouchEvent(const TouchEvent& ev);
149 
150  virtual bool onScrollEvent(const ScrollEvent& ev);
151 
152  virtual bool onKeyEvent(const KeyEvent& ev);
153 
154  private:
155  ScreenImpl* _impl;
156  Gfx::RectF _updateRect;
157  int _updates;
158  Widget* _pointer;
159  Pt::System::Clock _clock;
160 };
161 
162 } // namespace
163 
164 } // namespace
165 
166 #endif
Measures time intervals.
Definition: Clock.h:46
Window base class.
Definition: Window.h:65
Rect with floating-point coordinates.
Definition: Rect.h:44
Base class for all event types.
Definition: Event.h:49
Screen of a display.
Definition: Screen.h:54
Size with floating-point width and height.
Definition: Size.h:44
Point with floating-point X and Y coordinates.
Definition: Point.h:44