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
41namespace Pt {
42
43namespace Forms {
44
45class ScreenImpl;
46class ApplicationImpl;
47
48class Window;
49class WindowManager;
50class RescaleEvent;
51
82class PT_FORMS_API Screen : public Widget
83{
84 friend class ScreenImpl;
85
86 typedef Widget Base;
87
88 public:
91 Screen(ApplicationImpl& app);
92
95 virtual ~Screen();
96
97
101
105
108 const std::vector<Window*>& windows() const;
109
113
114
118
125 void setPointer(Widget* widget);
126
133 void setPointer(Widget& widget, bool isPointer);
134
135 public:
141 ScreenImpl* impl();
142
143 protected:
146 virtual void onInit(ScreenImpl& s);
147
150 virtual void onRelease(ScreenImpl& s);
151
154 virtual void onResize(ScreenImpl& s, const Gfx::SizeF& size);
155
158 virtual void onShow(ScreenImpl& s, bool isShow);
159
160 // TODO: name clash with Widget base class
161 using Base::onShow;
162
163 //
164 // Widget
165 //
166 protected:
169 virtual Widget* onHitTest(const Gfx::PointF& pos);
170
173 virtual Gfx::PointF onToParent(const Gfx::PointF& pos) const;
174
177 virtual Gfx::PointF onFromParent(const Gfx::PointF& pos) const;
178
181 virtual Gfx::PointF onToGlobal(const Gfx::PointF& pos) const;
182
185 virtual Gfx::PointF onFromGlobal(const Gfx::PointF& pos) const;
186
189 virtual void onProcessEvent( const Event& ev );
190
198 virtual void onRequestRepaint(const Gfx::RectF& rect);
199
200 protected:
203 virtual void onProcessRescaleEvent(const RescaleEvent& ev);
204
207 virtual void onRescaleEvent(const RescaleEvent& ev);
208
211 virtual void onRescale(double scaling);
212
213 protected:
220 virtual void onProcessPaintEvent(const PaintEvent& ev);
221
224 virtual void onPaintEvent(const PaintEvent& ev);
225
228 virtual void onPaint(const Gfx::RectF& rect);
229
230 protected:
233 virtual void onProcessResizeEvent(const ResizeEvent& ev);
234
237 virtual void onResizeEvent(const ResizeEvent& ev);
238
239 protected:
242 virtual void onProcessMouseEvent(const MouseEvent& ev);
243
246 virtual void onProcessTouchEvent(const TouchEvent& ev);
247
253 virtual void onProcessScrollEvent(const ScrollEvent& ev);
254
257 virtual void onProcessKeyEvent(const KeyEvent& ev);
258
259 //
260 // Responder
261 //
262 protected:
265 virtual bool onMouseEvent(const MouseEvent& ev);
266
269 virtual bool onTouchEvent(const TouchEvent& ev);
270
273 virtual bool onScrollEvent(const ScrollEvent& ev);
274
277 virtual bool onKeyEvent(const KeyEvent& ev);
278
279 private:
280 ScreenImpl* _impl;
281 Gfx::RectF _updateRect;
282 int _updates;
283 Widget* _pointer;
284 Pt::System::Clock _clock;
285};
286
287} // namespace
288
289} // namespace
290
291#endif
Base class for typed events.
Definition Event.h:66
Key press or release.
Definition KeyEvent.h:50
Pointer movement or button change.
Definition MouseEvent.h:134
Reports a dirty rectangle that a widget must paint.
Definition PaintEvent.h:48
Reports that a widget was resized.
Definition ResizeEvent.h:50
virtual bool onMouseEvent(const MouseEvent &ev)
Forwards ev to the base Widget responder chain.
Widget * underPointer()
Returns the widget currently under the pointer, or null.
virtual void onProcessRescaleEvent(const RescaleEvent &ev)
Forwards ev to the base Widget, then to the platform implementation.
virtual void onRescaleEvent(const RescaleEvent &ev)
Forwards ev to the base Widget event handling.
Screen(ApplicationImpl &app)
Creates the screen and connects it to app.
virtual bool onTouchEvent(const TouchEvent &ev)
Forwards ev to the base Widget responder chain.
const std::vector< Window * > & windows() const
Returns the windows currently attached to this screen.
virtual void onShow(ScreenImpl &s, bool isShow)
Dispatches a ShowEvent for a platform visibility change of s.
virtual void onResizeEvent(const ResizeEvent &ev)
Forwards ev to the base Widget event handling.
WindowManager & windowManager()
Returns the window manager that presents this screen's windows.
virtual void onResize(ScreenImpl &s, const Gfx::SizeF &size)
Dispatches a ResizeEvent for a platform resize of s to size.
virtual void onProcessResizeEvent(const ResizeEvent &ev)
Forwards ev to the base Widget, then to the platform implementation.
virtual void onRelease(ScreenImpl &s)
Called before the platform implementation s disconnects.
virtual Gfx::PointF onFromParent(const Gfx::PointF &pos) const
Returns pos unchanged; the screen has no parent.
virtual void onProcessMouseEvent(const MouseEvent &ev)
Forwards ev to the platform implementation for hit-test routing.
void setPointer(Widget &widget, bool isPointer)
Sets or clears widget as the widget under the pointer.
ScreenImpl * impl()
Returns the platform implementation backing this screen.
void addWindow(Window &w)
Attaches w to this screen's window manager.
virtual void onProcessScrollEvent(const ScrollEvent &ev)
Routes ev to the widget under the pointer, or to the platform implementation.
virtual bool onKeyEvent(const KeyEvent &ev)
Forwards ev to the base Widget responder chain.
virtual void onInit(ScreenImpl &s)
Called after the platform implementation s has connected.
virtual void onPaint(const Gfx::RectF &rect)
Extension point for painting rect; does nothing by default.
virtual void onRequestRepaint(const Gfx::RectF &rect)
Unifies rect into the pending update and schedules one paint pass.
void setPointer(Widget *widget)
Makes widget the widget under the pointer.
virtual bool onScrollEvent(const ScrollEvent &ev)
Forwards ev to the base Widget responder chain.
virtual void onPaintEvent(const PaintEvent &ev)
Forwards ev to the base Widget, then calls onPaint().
virtual void onProcessEvent(const Event &ev)
Forwards ev to the base Widget event processing.
virtual void onProcessPaintEvent(const PaintEvent &ev)
Forwards the last coalesced update in ev to the platform implementation.
virtual Gfx::PointF onToGlobal(const Gfx::PointF &pos) const
Returns pos unchanged; screen coordinates are global.
virtual Gfx::PointF onFromGlobal(const Gfx::PointF &pos) const
Returns pos unchanged; screen coordinates are global.
virtual void onRescale(double scaling)
Forwards scaling to the base Widget event handling.
virtual Widget * onHitTest(const Gfx::PointF &pos)
Finds the deepest widget at pos, or this screen if none.
virtual void onProcessKeyEvent(const KeyEvent &ev)
Forwards ev to the platform implementation for routing to the focused widget.
virtual void onProcessTouchEvent(const TouchEvent &ev)
Forwards ev to the platform implementation for hit-test routing.
virtual ~Screen()
Destructor.
virtual Gfx::PointF onToParent(const Gfx::PointF &pos) const
Returns pos unchanged; the screen has no parent.
void removeWindow(Window &w)
Detaches w from this screen's window manager.
Scroll or wheel movement.
Definition ScrollEvent.h:51
Touch press, move, or release.
Definition TouchEvent.h:51
Widget()
Creates and registers a widget with the Forms application.
const Gfx::Scaling & scaling() const
Returns the current logical-to-device scaling.
const Gfx::SizeF & size() const
Returns the size in local logical coordinates.
virtual void onShow(bool visible)
Updates the local visibility state to visible.
Host that attaches windows to a screen or workspace.
Definition WindowManager.h:68
Form presented by a window manager.
Definition Window.h:99
Stopwatch, system time and monotonic ticks.
Definition Clock.h:59
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33