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 
39 namespace Pt {
40 
41 namespace Forms {
42 
43 class ScrollEvent : public Pt::BasicEvent<ScrollEvent>
44 {
45  public:
46  enum Wheel
47  {
48  Vertical = 0,
49  Horizontal = 1,
50  Depth = 2
51  };
52 
53  ScrollEvent()
54  : _widgetId_(0)
55  , _widget(0)
56  , _wheel(Vertical)
57  , _delta(0)
58  { }
59 
60  explicit ScrollEvent(Widget& widget)
61  : _widgetId_( widget.id() )
62  , _widget(&widget)
63  , _wheel(Vertical)
64  , _delta(0)
65  { }
66 
67  Pt::uint64_t widgetId() const
68  {
69  return _widgetId_;
70  }
71 
72  Widget* widget() const
73  {
74  return _widget;
75  }
76 
77  void setWidget(Widget* widget)
78  {
79  _widget = widget;
80  }
81 
82  Pt::uint32_t wheel() const
83  {
84  return _wheel;
85  }
86 
87  double delta() const
88  {
89  return _delta;
90  }
91 
92  void set(Pt::uint32_t wheel, double d)
93  {
94  _wheel = wheel;
95  _delta = d;
96  }
97 
98  private:
99  Pt::uint64_t _widgetId_;
100  Widget* _widget;
101  Pt::uint32_t _wheel;
102  double _delta;
103 };
104 
105 } // namespace
106 
107 } // namespace
108 
109 #endif
uint_type uint64_t
Unsigned 64-bit integer type.
Definition: Types.h:54
uint_type uint32_t
Unsigned 32-bit integer type.
Definition: Types.h:42