Image Component Library (ICL)
ButtonHandle.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLQt/src/ICLQt/ButtonHandle.h **
10 ** Module : ICLQt **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/SmartPtr.h>
35 #include <ICLQt/GUIHandle.h>
36 #include <string>
37 #include <vector>
38 #include <QPushButton>
39 
40 //#include <QPushButton>
41 
43 class QPushButton;
47 namespace icl{
48  namespace qt{
49 
51  class ButtonHandle : public GUIHandle<QPushButton>{
52  public:
53 
54  friend class ButtonGUIWidget;
55  friend class ToggleButtonGUIWidget;
56 
59 
61  ICLQt_API ButtonHandle(QPushButton *b, GUIWidget *w);
62 
64 
67  ICLQt_API bool wasTriggered(bool reset = true);
68 
70  void trigger(bool execCallbacks = true){
71  *m_triggered = true;
72  if(execCallbacks){
73  cb();
74  }
75  }
76 
77  ICLQt_API void setButtonText(std::string const &text) {
78  (**this)->setText(text.c_str());
79  }
80 
82  ICLQt_API void reset();
83 
85  ICLQt_API const std::string &getID() const;
86 
87  private:
88 
90  std::string m_sID;
91  };
92  } // namespace qt
93 }
94 
utils::SmartPtr< bool > m_triggered
internal boolean variable
Definition: ButtonHandle.h:89
undocument this line if you encounter any issues!
Definition: Any.h:37
void trigger(bool execCallbacks=true)
trigger this event (sets the internal boolean variable to true)
Definition: ButtonHandle.h:70
Special Utiltiy class for handling Button clicks in the ICL GUI API.
Definition: ButtonHandle.h:51
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
ICLQt_API const std::string & getID() const
returns this buttons id (uncommon)
Abstract base class for Handle classes.
Definition: GUIHandle.h:40
ICLQt_API ButtonHandle()
creates a n empty button handle
ICLQt_API bool wasTriggered(bool reset=true)
check if this event/button was triggered
ICLQt_API void reset()
sets the internal boolean variable to false
Abstract class for GUI components.
Definition: GUIWidget.h:52
friend class ButtonGUIWidget
Definition: ButtonHandle.h:54
#define ICLQt_API
Definition: CompatMacros.h:178
std::string m_sID
corresponding id
Definition: ButtonHandle.h:90
friend class ToggleButtonGUIWidget
Definition: ButtonHandle.h:55
virtual void cb()
envokes all registered callbacks
Definition: GUIHandleBase.h:102
ICLQt_API void setButtonText(std::string const &text)
Definition: ButtonHandle.h:77