gwenhywfar  5.14.1
qt5/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 
12 public:
14  }
15 
16 
17 
19  }
20 
21 
22 
23  virtual int setup() {
24  QWidget *qw;
25  uint32_t flags;
26  GWEN_WIDGET *wParent;
27  QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
28  QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
29  const char *s;
30  QString text;
31  QT5_GuiDialog *qtDialog;
32 
34  wParent=GWEN_Widget_Tree_GetParent(_widget);
36  if (s)
37  text=QString::fromUtf8(s);
38 
39  qw=new QCheckBox(text);
40 
41  /* handle flags */
42  if (flags & GWEN_WIDGET_FLAGS_FILLX)
43  hpolicy=QSizePolicy::Expanding;
44  if (flags & GWEN_WIDGET_FLAGS_FILLY)
45  vpolicy=QSizePolicy::Expanding;
46  qw->setSizePolicy(hpolicy, vpolicy);
47 
49 
50  qtDialog=dynamic_cast<QT5_GuiDialog*>(getDialog());
51  assert(qtDialog);
52 
53  qw->connect(qw, SIGNAL(toggled(bool)),
54  qtDialog->getMainWindow(),
55  SLOT(slotActivated()));
56 
57  if (wParent)
59  return 0;
60  }
61 
62 
63 
65  int index,
66  int value,
67  int doSignal) {
68  QCheckBox *qw;
69 
71  assert(qw);
72 
73  switch(prop) {
75  qw->setChecked((value==0)?false:true);
76  return 0;
77 
78  default:
79  return Qt5_W_Widget::setIntProperty(prop, index, value, doSignal);
80  }
81  };
82 
83 
84 
86  int index,
87  int defaultValue) {
88  QCheckBox *qw;
89 
91  assert(qw);
92 
93  switch(prop) {
95  return (qw->isChecked())?1:0;
96 
97  default:
98  return Qt5_W_Widget::getIntProperty(prop, index, defaultValue);
99  }
100  };
101 
102 
103 
105  GWEN_UNUSED int index,
106  const char *value,
107  GWEN_UNUSED int doSignal) {
108  QCheckBox *qw;
109  QString text;
110 
112  assert(qw);
113 
114  if (value)
115  text=QString::fromUtf8(value);
116 
117  switch(prop) {
119  qw->setText(text);
120  return 0;
121  default:
122  break;
123  }
124 
126  "Function is not appropriate for this type of widget (%s)",
128  return GWEN_ERROR_INVALID;
129  };
130 
131 
132 
134  GWEN_UNUSED int index,
135  const char *defaultValue) {
136  QCheckBox *qw;
137  QString str;
138 
140  assert(qw);
141 
142  switch(prop) {
144  str=qw->text();
145  if (str.isEmpty())
146  return defaultValue;
147  else {
150  }
151  break;
152 
153  default:
154  break;
155  }
156 
158  "Function is not appropriate for this type of widget (%s)",
160  return defaultValue;
161  };
162 
163 };
164 
165 
166 
167 
168 
169 
170 
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:185
void GWEN_Widget_SetText(GWEN_WIDGET *w, int idx, const char *s)
Definition: widget.c:304
#define GWEN_ERROR_INVALID
Definition: error.h:67
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
#define GWEN_LOGDOMAIN
Definition: logger.h:32
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
#define DBG_WARN(dbg_logger, format,...)
Definition: debug.h:125
int getIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:836
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
QT5_DialogBox * getMainWindow()
Qt5_W_CheckBox(GWEN_WIDGET *w)
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
#define QT5_DIALOG_STRING_TITLE
int setIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:456
virtual int setup()
int setCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)
CppDialog * getDialog()
Definition: cppwidget.cpp:174
GWEN_WIDGET * _widget
Definition: cppwidget.hpp:66
int getIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int defaultValue)
#define QT5_DIALOG_WIDGET_REAL
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
#define GWEN_UNUSED