gwenhywfar  4.7.0beta
w_pushbutton.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 QPushButton(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(clicked(bool)),
57  qtDialog->getMainWindow(),
58  SLOT(slotActivated()));
59 
60  if (wParent)
62  return 0;
63  }
64 
65 
66 
68  int index,
69  const char *value,
70  int doSignal) {
71  QPushButton *qw;
72  QString text;
73 
75  assert(qw);
76 
77  if (value)
78  text=QString::fromUtf8(value);
79 
80  switch(prop) {
82  qw->setText(text);
83  return 0;
84  default:
85  break;
86  }
87 
89  "Function is not appropriate for this type of widget (%s)",
91  return GWEN_ERROR_INVALID;
92  };
93 
94 
95 
97  int index,
98  const char *defaultValue) {
99  QPushButton *qw;
100  QString str;
101 
103  assert(qw);
104 
105  switch(prop) {
107  str=qw->text();
108  if (str.isEmpty())
109  return defaultValue;
110  else {
113  }
114  break;
115 
116  default:
117  break;
118  }
119 
121  "Function is not appropriate for this type of widget (%s)",
123  return defaultValue;
124  };
125 
126 };
127 
128 
129 
130 
131 
132 
133