gwenhywfar 5.14.1
qt4/w_radiobutton.cpp
Go to the documentation of this file.
1/***************************************************************************
2 begin : Mon Feb 15 2010
3 copyright : (C) 2010 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * Please see toplevel file COPYING for license details *
8 ***************************************************************************/
9
10
11#include <gwen-gui-cpp/cppwidget.hpp>
12
13
15public:
18
19
20
23
24
25
26 virtual int setup() {
27 QRadioButton *qw;
28 uint32_t flags;
29 GWEN_WIDGET *wParent;
30 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
31 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
32 const char *s;
33 QString text;
34 QT4_GuiDialog *qtDialog;
35
37 wParent=GWEN_Widget_Tree_GetParent(_widget);
39 if (s)
40 text=QString::fromUtf8(s);
41
42 qw=new QRadioButton(text);
43
44 /* handle flags */
45 if (flags & GWEN_WIDGET_FLAGS_FILLX)
46 hpolicy=QSizePolicy::Expanding;
47 if (flags & GWEN_WIDGET_FLAGS_FILLY)
48 vpolicy=QSizePolicy::Expanding;
49 qw->setSizePolicy(hpolicy, vpolicy);
50
52
53 qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
54 assert(qtDialog);
55
56 qw->connect(qw, SIGNAL(toggled(bool)),
57 qtDialog->getMainWindow(),
58 SLOT(slotActivated()));
59
60 if (wParent)
62 return 0;
63 }
64
65
66
68 int index,
69 int value,
70 int doSignal) {
71 QRadioButton *qw;
72
74 assert(qw);
75
76 switch(prop) {
78 qw->setChecked((value==0)?false:true);
79 return 0;
80
81 default:
82 return Qt4_W_Widget::setIntProperty(prop, index, value, doSignal);
83 }
84 };
85
86
87
89 int index,
90 int defaultValue) {
91 QRadioButton *qw;
92
94 assert(qw);
95
96 switch(prop) {
98 return (qw->isChecked())?1:0;
99
100 default:
101 return Qt4_W_Widget::getIntProperty(prop, index, defaultValue);
102 }
103 };
104
105
106
108 int index,
109 const char *value,
110 int doSignal) {
111 QRadioButton *qw;
112 QString text;
113
115 assert(qw);
116
117 if (value)
118 text=QString::fromUtf8(value);
119
120 switch(prop) {
122 qw->setText(text);
123 return 0;
124 default:
125 break;
126 }
127
129 "Function is not appropriate for this type of widget (%s)",
131 return GWEN_ERROR_INVALID;
132 };
133
134
135
137 int index,
138 const char *defaultValue) {
139 QRadioButton *qw;
140 QString str;
141
143 assert(qw);
144
145 switch(prop) {
147 str=qw->text();
148 if (str.isEmpty())
149 return defaultValue;
150 else {
153 }
154 break;
155
156 default:
157 break;
158 }
159
161 "Function is not appropriate for this type of widget (%s)",
163 return defaultValue;
164 };
165
166};
167
168
169
170
171
172
173
GWEN_WIDGET * _widget
Definition cppwidget.hpp:66
CppDialog * getDialog()
QT4_DialogBox * getMainWindow()
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
int getIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
int setCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
Qt4_W_RadioButton(GWEN_WIDGET *w)
Qt4_W_Widget(GWEN_WIDGET *w)
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
int getIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
#define DBG_WARN(dbg_logger, format,...)
Definition debug.h:125
#define GWEN_WIDGET_FLAGS_FILLY
Definition dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition dialog.h:61
GWEN_DIALOG_PROPERTY
Definition dialog.h:260
@ GWEN_DialogProperty_Title
Definition dialog.h:263
@ GWEN_DialogProperty_Value
Definition dialog.h:264
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWEN_LOGDOMAIN
Definition logger.h:32
#define QT4_DIALOG_WIDGET_REAL
#define QT4_DIALOG_STRING_TITLE
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition widget.c:836
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition widget.c:136
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition widget.c:122
void GWEN_Widget_SetText(GWEN_WIDGET *w, int idx, const char *s)
Definition widget.c:304
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition widget.c:293
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition widget.c:149
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition widget.c:456
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition widget.c:185
struct GWEN_WIDGET GWEN_WIDGET
Definition widget_be.h:34