Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
berryGuiTkIControlListener.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef BERRYGUITKICONTROLLISTENER_H_
14 #define BERRYGUITKICONTROLLISTENER_H_
15 
16 #include <berryMacros.h>
17 #include <berryMessage.h>
18 
20 #include "berryGuiTkControlEvent.h"
21 
22 namespace berry
23 {
24 
25 namespace GuiTk
26 {
27 
44 struct BERRY_UI_QT IControlListener: public virtual Object
45 {
46 
48 
50 
51  enum Type {
52  NONE = 0x00000000,
53  MOVED = 0x00000001,
54  RESIZED = 0x00000002,
55  ACTIVATED = 0x00000004,
56  DESTROYED = 0x00000008,
57 
58  ALL = 0xffffffff
59  };
60 
61  Q_DECLARE_FLAGS(Types, Type)
62 
64 
65  EventType movedEvent;
66  EventType resizedEvent;
67  EventType activatedEvent;
68  EventType destroyedEvent;
69 
70  void AddListener(IControlListener::Pointer listener);
71  void RemoveListener(IControlListener::Pointer listener);
72 
73  private:
75  };
76 
77  ~IControlListener() override;
78 
79  virtual Events::Types GetEventTypes() const = 0;
80 
85  virtual void ControlMoved(ControlEvent::Pointer)
86  {
87  }
88 
93  {
94  }
95 
97  {
98  }
99 
101  {
102  }
103 
104 };
105 
106 template<typename R>
108 {
109  typedef R Listener;
110  typedef void
111  (R::*Callback)(ControlEvent::Pointer);
112 
113  ControlMovedAdapter(R* l, Callback c) :
114  listener(l), callback(c)
115  {
116  poco_assert(listener);
117  poco_assert(callback);
118  }
119 
120  Events::Types GetEventTypes() const override
121  {
122  return Events::MOVED;
123  }
124 
126  {
127  (listener->*callback)(e);
128  }
129 
130 private:
131 
132  Listener* listener;
133  Callback callback;
134 };
135 
136 template<typename R>
138 {
139  typedef R Listener;
140  typedef void
141  (R::*Callback)(ControlEvent::Pointer);
142 
143  ControlResizedAdapter(R* l, Callback c) :
144  listener(l), callback(c)
145  {
146  poco_assert(listener);
147  poco_assert(callback);
148  }
149 
150  Events::Types GetEventTypes() const override
151  {
152  return Events::RESIZED;
153  }
154 
156  {
157  (listener->*callback)(e);
158  }
159 
160 private:
161 
162  Listener* listener;
163  Callback callback;
164 };
165 
166 template<typename R>
168 {
169  typedef R Listener;
170  typedef void
171  (R::*Callback)(ControlEvent::Pointer);
172 
173  ControlActivatedAdapter(R* l, Callback c) :
174  listener(l), callback(c)
175  {
176  poco_assert(listener);
177  poco_assert(callback);
178  }
179 
180  Events::Types GetEventTypes() const override
181  {
182  return Events::ACTIVATED;
183  }
184 
186  {
187  (listener->*callback)(e);
188  }
189 
190 private:
191 
192  Listener* listener;
193  Callback callback;
194 };
195 
196 template<typename R>
198 {
199  typedef R Listener;
200  typedef void
201  (R::*Callback)(ControlEvent::Pointer);
202 
203  ControlDestroyedAdapter(R* l, Callback c) :
204  listener(l), callback(c)
205  {
206  poco_assert(listener);
207  poco_assert(callback);
208  }
209 
210  Events::Types GetEventTypes() const override
211  {
212  return Events::DESTROYED;
213  }
214 
216  {
217  (listener->*callback)(e);
218  }
219 
220 private:
221 
222  Listener* listener;
223  Callback callback;
224 };
225 
226 }
227 
228 }
229 
230 Q_DECLARE_OPERATORS_FOR_FLAGS(berry::GuiTk::IControlListener::Events::Types)
231 
232 #endif /* BERRYGUITKICONTROLLISTENER_H_ */
org_blueberry_ui_qt_Export.h
berry::GuiTk::ControlResizedAdapter
Definition: berryGuiTkIControlListener.h:137
berry::GuiTk::ControlResizedAdapter::Listener
R Listener
Definition: berryGuiTkIControlListener.h:139
berryMacros.h
berry::GuiTk::IControlListener::ControlResized
virtual void ControlResized(ControlEvent::Pointer)
Definition: berryGuiTkIControlListener.h:92
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berry::GuiTk::ControlActivatedAdapter::ControlActivatedAdapter
ControlActivatedAdapter(R *l, Callback c)
Definition: berryGuiTkIControlListener.h:173
berry::GuiTk::ControlMovedAdapter::Listener
R Listener
Definition: berryGuiTkIControlListener.h:109
berryMessage.h
berry::Message1
Definition: berryMessage.h:787
berry::Object
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
berry::GuiTk::ControlResizedAdapter::ControlResized
void ControlResized(ControlEvent::Pointer e) override
Definition: berryGuiTkIControlListener.h:155
berry::GuiTk::ControlMovedAdapter::ControlMoved
void ControlMoved(ControlEvent::Pointer e) override
Definition: berryGuiTkIControlListener.h:125
berry::GuiTk::ControlDestroyedAdapter
Definition: berryGuiTkIControlListener.h:197
berry::GuiTk::IControlListener::Events
Definition: berryGuiTkIControlListener.h:49
berryGuiTkControlEvent.h
berry::MessageDelegate1
Definition: berryMessage.h:170
berry::GuiTk::ControlActivatedAdapter::ControlActivated
void ControlActivated(ControlEvent::Pointer e) override
Definition: berryGuiTkIControlListener.h:185
berry::GuiTk::ControlDestroyedAdapter::ControlDestroyedAdapter
ControlDestroyedAdapter(R *l, Callback c)
Definition: berryGuiTkIControlListener.h:203
berry::GuiTk::IControlListener::Events::Type
Type
Definition: berryGuiTkIControlListener.h:51
BERRY_UI_QT
#define BERRY_UI_QT
Definition: org_blueberry_ui_qt_Export.h:26
berry::GuiTk::ControlMovedAdapter::GetEventTypes
Events::Types GetEventTypes() const override
Definition: berryGuiTkIControlListener.h:120
berry::GuiTk::ControlResizedAdapter::GetEventTypes
Events::Types GetEventTypes() const override
Definition: berryGuiTkIControlListener.h:150
berry::GuiTk::ControlDestroyedAdapter::Listener
R Listener
Definition: berryGuiTkIControlListener.h:199
berry::GuiTk::IControlListener::ControlActivated
virtual void ControlActivated(ControlEvent::Pointer)
Definition: berryGuiTkIControlListener.h:96
berry::GuiTk::ControlResizedAdapter::ControlResizedAdapter
ControlResizedAdapter(R *l, Callback c)
Definition: berryGuiTkIControlListener.h:143
berry::GuiTk::ControlMovedAdapter
Definition: berryGuiTkIControlListener.h:107
berry::GuiTk::IControlListener
Definition: berryGuiTkIControlListener.h:44
berry::GuiTk::ControlActivatedAdapter::GetEventTypes
Events::Types GetEventTypes() const override
Definition: berryGuiTkIControlListener.h:180
berry::GuiTk::ControlDestroyedAdapter::ControlDestroyed
void ControlDestroyed(ControlEvent::Pointer e) override
Definition: berryGuiTkIControlListener.h:215
berry::GuiTk::ControlEvent
Definition: berryGuiTkControlEvent.h:31
berry::Object::Pointer
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:82
berryObjectMacro
#define berryObjectMacro(...)
Definition: berryMacros.h:31
berry::GuiTk::ControlMovedAdapter::ControlMovedAdapter
ControlMovedAdapter(R *l, Callback c)
Definition: berryGuiTkIControlListener.h:113
berry::GuiTk::ControlActivatedAdapter::Listener
R Listener
Definition: berryGuiTkIControlListener.h:169
berry::GuiTk::IControlListener::ControlDestroyed
virtual void ControlDestroyed(ControlEvent::Pointer)
Definition: berryGuiTkIControlListener.h:100
berry
Definition: QmitkPropertyItemModel.h:24
berry::GuiTk::ControlActivatedAdapter
Definition: berryGuiTkIControlListener.h:167
berry::GuiTk::ControlDestroyedAdapter::GetEventTypes
Events::Types GetEventTypes() const override
Definition: berryGuiTkIControlListener.h:210