ScrollEvent.h
1/*
2 Copyright (C) 2015 Marc Boris Duerner
3 Copyright (C) 2015 Laurentiu-Gheorghe Crisan
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 As a special exception, you may use this file as part of a free
11 software library without restriction. Specifically, if other files
12 instantiate templates or use macros or inline functions from this
13 file, or you compile this file and link it with other files to
14 produce an executable, this file does not by itself cause the
15 resulting executable to be covered by the GNU General Public
16 License. This exception does not however invalidate any other
17 reasons why the executable file might be covered by the GNU Library
18 General Public License.
19
20 This library is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public
26 License along with this library; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 MA 02110-1301 USA
29*/
30
31#ifndef Pt_Forms_ScrollEvent_h
32#define Pt_Forms_ScrollEvent_h
33
34#include <Pt/Forms/Api.h>
35#include <Pt/Forms/Widget.h>
36#include <Pt/Types.h>
37#include <Pt/Event.h>
38
39namespace Pt {
40
41namespace Forms {
42
50class ScrollEvent : public Pt::BasicEvent<ScrollEvent>
51{
52 public:
55 enum Wheel
56 {
57 Vertical = 0,
58 Horizontal = 1,
59 Depth = 2
60 };
61
65 : _widgetId_(0)
66 , _widget(0)
67 , _wheel(Vertical)
68 , _delta(0)
69 { }
70
74 : _widgetId_( widget.id() )
75 , _widget(&widget)
76 , _wheel(Vertical)
77 , _delta(0)
78 { }
79
83 {
84 return _widgetId_;
85 }
86
89 Widget* widget() const
90 {
91 return _widget;
92 }
93
97 {
98 _widget = widget;
99 }
100
104 {
105 return _wheel;
106 }
107
110 double delta() const
111 {
112 return _delta;
113 }
114
117 void set(Pt::uint32_t wheel, double d)
118 {
119 _wheel = wheel;
120 _delta = d;
121 }
122
123 private:
124 Pt::uint64_t _widgetId_;
125 Widget* _widget;
126 Pt::uint32_t _wheel;
127 double _delta;
128};
129
130} // namespace
131
132} // namespace
133
134#endif
Event base that clones, destroys and identifies a derived type T.
Definition Event.h:144
double delta() const
Returns the signed scroll delta.
Definition ScrollEvent.h:110
void setWidget(Widget *widget)
Sets the target widget.
Definition ScrollEvent.h:96
Pt::uint32_t wheel() const
Returns the scroll axis.
Definition ScrollEvent.h:103
ScrollEvent(Widget &widget)
Creates an event targeted at widget.
Definition ScrollEvent.h:73
void set(Pt::uint32_t wheel, double d)
Sets the scroll wheel and delta d.
Definition ScrollEvent.h:117
ScrollEvent()
Creates an event without a target and with zero delta.
Definition ScrollEvent.h:64
Wheel
Defines a scroll axis.
Definition ScrollEvent.h:56
Widget * widget() const
Returns the target widget, or 0 when no target is set.
Definition ScrollEvent.h:89
Pt::uint64_t widgetId() const
Returns the target widget ID, or 0 when no target is set.
Definition ScrollEvent.h:82
Common type of every visual Forms object.
Definition Widget.h:105
uint_type uint32_t
Unsigned 32-bit integer type.
Definition Api-Types.h:52
uint_type uint64_t
Unsigned 64-bit integer type.
Definition Api-Types.h:66
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33