Image Component Library (ICL)
ButtonGroupHandle.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/ButtonGroupHandle.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 <ICLQt/GUIHandle.h>
35 #include <vector>
36 #include <string>
37 
39 class QRadioButton;
42 namespace icl{
43  namespace qt{
44 
46  typedef std::vector<QRadioButton*> RadioButtonVec;
47 
49  class ButtonGroupHandle : public GUIHandle<RadioButtonVec> {
50  public:
53 
56 
58  ICLQt_API void select(int id);
59 
61  ICLQt_API int getSelected() const;
62 
64  ICLQt_API std::string getSelectedText() const;
65 
67  ICLQt_API std::string getText(int id) const;
68 
70  ICLQt_API void setText(int id, const std::string &text);
71 
73  ICLQt_API void disable();
74 
76  ICLQt_API void enable();
77 
79  ICLQt_API void disable(int index);
80 
82  ICLQt_API void enable(int index);
83 
84  private:
86  int n() const{ return (int)vec().size(); }
87 
89  bool valid(int id) const{ return id >= 0 && id < (int)vec().size(); }
90 
92  RadioButtonVec &vec() { return ***this; }
93 
95  const RadioButtonVec &vec() const { return const_cast<ButtonGroupHandle*>(this)->vec(); }
96  };
97 
98  } // namespace qt
99 }
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API int getSelected() const
get the selected index
ICLQt_API void enable()
enables all radio buttons
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
const RadioButtonVec & vec() const
utitliy function returns the underlying vector (const)
Definition: ButtonGroupHandle.h:95
RadioButtonVec & vec()
utitliy function returns the underlying vector
Definition: ButtonGroupHandle.h:92
ICLQt_API void setText(int id, const std::string &text)
sets the text of a button with index ot a given text
Abstract base class for Handle classes.
Definition: GUIHandle.h:40
ButtonGroupHandle()
Create an empty handle.
Definition: ButtonGroupHandle.h:52
ButtonGroupHandle(RadioButtonVec *buttons, GUIWidget *w)
Craete a valid handle.
Definition: ButtonGroupHandle.h:55
std::vector< QRadioButton * > RadioButtonVec
type definition for the ButtonGroup handle
Definition: ButtonGroupHandle.h:46
Abstract class for GUI components.
Definition: GUIWidget.h:52
#define ICLQt_API
Definition: CompatMacros.h:178
ICLQt_API void disable()
disables all radio buttons
bool valid(int id) const
utility function (check indices for being valid)
Definition: ButtonGroupHandle.h:89
ICLQt_API std::string getSelectedText() const
get the text of the currently selected button
ICLQt_API std::string getText(int id) const
returns the text of a button with given index
Class for handling button goups.
Definition: ButtonGroupHandle.h:49
ICLQt_API void select(int id)
select a button with given index
int n() const
utility function (number of elements)
Definition: ButtonGroupHandle.h:86