gwenhywfar  4.8.0beta
w_checkbox.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 
15 public:
17  }
18 
19 
20 
22  }
23 
24 
25 
26  virtual int setup() {
27  QWidget *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 QCheckBox(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  QCheckBox *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  QCheckBox *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  QCheckBox *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  QCheckBox *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