LayoutEvent.h
1 /* Copyright (C) 2017 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_LayoutEvent_h
30 #define Pt_Forms_LayoutEvent_h
31 
32 #include <Pt/Forms/Api.h>
33 #include <Pt/Forms/Widget.h>
34 #include <Pt/Forms/SizePolicy.h>
35 #include <Pt/Gfx/Rect.h>
36 #include <Pt/Types.h>
37 #include <Pt/Event.h>
38 
39 namespace Pt {
40 
41 namespace Forms {
42 
43 class PT_FORMS_API RescaleEvent : public Pt::BasicEvent<RescaleEvent>
44 {
45  public:
46  explicit RescaleEvent(Widget& widget,
47  double scaleFactor = 1.0)
48  : _widgetId_( widget.id() )
49  , _widget(&widget)
50  , _scaleFactor(scaleFactor)
51  {
52  }
53 
54  virtual ~RescaleEvent()
55  {
56  }
57 
58  Pt::uint64_t widgetId() const
59  {
60  return _widgetId_;
61  }
62 
63  Widget* widget() const
64  {
65  return _widget;
66  }
67 
68  double scaleFactor() const
69  {
70  return _scaleFactor;
71  }
72 
73  private:
74  Pt::uint64_t _widgetId_;
75  Widget* _widget;
76  double _scaleFactor;
77 };
78 
79 
80 class PT_FORMS_API MeasureEvent : public Pt::BasicEvent<MeasureEvent>
81 {
82  public:
83  MeasureEvent(Pt::uint64_t widgetId)
84  : _widgetId(widgetId)
85  {
86  }
87 
88  MeasureEvent(Pt::uint64_t widgetId, const SizePolicy& policy)
89  : _widgetId(widgetId)
90  , _sizePolicy(policy)
91  {
92  }
93 
94  virtual ~MeasureEvent()
95  {
96  }
97 
98  Pt::uint64_t widgetId() const
99  {
100  return _widgetId;
101  }
102 
103  const SizePolicy& sizePolicy() const
104  {
105  return _sizePolicy;
106  }
107 
108  void setSizePolicy(const SizePolicy& policy)
109  {
110  _sizePolicy = policy;
111  }
112 
113  private:
114  Pt::uint64_t _widgetId;
115  SizePolicy _sizePolicy;
116 };
117 
118 
119 class PT_FORMS_API LayoutEvent : public Pt::BasicEvent<LayoutEvent>
120 {
121  public:
122  LayoutEvent(Widget& widget)
123  : _widgetId_( widget.id() )
124  , _widget(&widget)
125  {
126  }
127 
128  LayoutEvent(Widget& widget, const Gfx::RectF& rect)
129  : _widgetId_( widget.id() )
130  , _widget(&widget)
131  , _rect(rect)
132  {
133  }
134 
135  virtual ~LayoutEvent()
136  {
137  }
138 
139  Pt::uint64_t widgetId() const
140  {
141  return _widgetId_;
142  }
143 
144  Widget* widget() const
145  {
146  return _widget;
147  }
148 
149  const Gfx::RectF& rect() const
150  {
151  return _rect;
152  }
153 
154  void setRect(const Gfx::RectF& r)
155  {
156  _rect = r;
157  }
158 
159  private:
160  Pt::uint64_t _widgetId_;
161  Widget* _widget;
162  Gfx::RectF _rect;
163 };
164 
165 } // namespace
166 
167 } // namespace
168 
169 #endif
uint_type uint64_t
Unsigned 64-bit integer type.
Definition: Types.h:54