Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryGuiTkIControlListener.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef BERRYGUITKICONTROLLISTENER_H_
18 #define BERRYGUITKICONTROLLISTENER_H_
19 
20 #include <berryMacros.h>
21 #include <berryMessage.h>
22 
24 #include "berryGuiTkControlEvent.h"
25 
26 namespace berry
27 {
28 
29 namespace GuiTk
30 {
31 
48 struct BERRY_UI_QT IControlListener: public virtual Object
49 {
50 
52 
53  struct BERRY_UI_QT Events {
54 
55  enum Type {
56  NONE = 0x00000000,
57  MOVED = 0x00000001,
58  RESIZED = 0x00000002,
59  ACTIVATED = 0x00000004,
60  DESTROYED = 0x00000008,
61 
62  ALL = 0xffffffff
63  };
64 
65  Q_DECLARE_FLAGS(Types, Type)
66 
67  typedef Message1<ControlEvent::Pointer> EventType;
68 
69  EventType movedEvent;
70  EventType resizedEvent;
71  EventType activatedEvent;
72  EventType destroyedEvent;
73 
74  void AddListener(IControlListener::Pointer listener);
75  void RemoveListener(IControlListener::Pointer listener);
76 
77  private:
79  };
80 
81  virtual ~IControlListener();
82 
83  virtual Events::Types GetEventTypes() const = 0;
84 
91  virtual void ControlMoved(ControlEvent::Pointer /*e*/)
92  {
93  }
94 
101  {
102  }
103 
105  {
106  }
107 
109  {
110  }
111 
112 };
113 
114 template<typename R>
116 {
117  typedef R Listener;
118  typedef void
120 
121  ControlMovedAdapter(R* l, Callback c) :
122  listener(l), callback(c)
123  {
124  poco_assert(listener);
125  poco_assert(callback);
126  }
127 
128  Events::Types GetEventTypes() const override
129  {
130  return Events::MOVED;
131  }
132 
134  {
135  (listener->*callback)(e);
136  }
137 
138 private:
139 
140  Listener* listener;
141  Callback callback;
142 };
143 
144 template<typename R>
146 {
147  typedef R Listener;
148  typedef void
150 
151  ControlResizedAdapter(R* l, Callback c) :
152  listener(l), callback(c)
153  {
154  poco_assert(listener);
155  poco_assert(callback);
156  }
157 
158  Events::Types GetEventTypes() const override
159  {
160  return Events::RESIZED;
161  }
162 
164  {
165  (listener->*callback)(e);
166  }
167 
168 private:
169 
170  Listener* listener;
171  Callback callback;
172 };
173 
174 template<typename R>
176 {
177  typedef R Listener;
178  typedef void
180 
181  ControlActivatedAdapter(R* l, Callback c) :
182  listener(l), callback(c)
183  {
184  poco_assert(listener);
185  poco_assert(callback);
186  }
187 
188  Events::Types GetEventTypes() const override
189  {
190  return Events::ACTIVATED;
191  }
192 
194  {
195  (listener->*callback)(e);
196  }
197 
198 private:
199 
200  Listener* listener;
201  Callback callback;
202 };
203 
204 template<typename R>
206 {
207  typedef R Listener;
208  typedef void
210 
211  ControlDestroyedAdapter(R* l, Callback c) :
212  listener(l), callback(c)
213  {
214  poco_assert(listener);
215  poco_assert(callback);
216  }
217 
218  Events::Types GetEventTypes() const override
219  {
220  return Events::DESTROYED;
221  }
222 
224  {
225  (listener->*callback)(e);
226  }
227 
228 private:
229 
230  Listener* listener;
231  Callback callback;
232 };
233 
234 }
235 
236 }
237 
238 Q_DECLARE_OPERATORS_FOR_FLAGS(berry::GuiTk::IControlListener::Events::Types)
239 
240 #endif /* BERRYGUITKICONTROLLISTENER_H_ */
Events::Types GetEventTypes() const override
virtual void ControlDestroyed(ControlEvent::Pointer)
Events::Types GetEventTypes() const override
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
virtual void ControlMoved(ControlEvent::Pointer)
void(R::* Callback)(ControlEvent::Pointer)
virtual void ControlActivated(ControlEvent::Pointer)
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
virtual void ControlResized(ControlEvent::Pointer)
Events::Types GetEventTypes() const override
void(R::* Callback)(ControlEvent::Pointer)
Events::Types GetEventTypes() const override
void ControlMoved(ControlEvent::Pointer e) override
void(R::* Callback)(ControlEvent::Pointer)
void ControlDestroyed(ControlEvent::Pointer e) override
berryObjectMacro(berry::GuiTk::IControlListener) struct BERRY_UI_QT Events
void ControlResized(ControlEvent::Pointer e) override
void(R::* Callback)(ControlEvent::Pointer)
void ControlActivated(ControlEvent::Pointer e) override
#define BERRY_UI_QT