gwenhywfar 5.12.0
qt4/w_combobox.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 QComboBox *qw;
28 uint32_t flags;
29 GWEN_WIDGET *wParent;
30 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
31 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
32 QT4_GuiDialog *qtDialog;
33
35 wParent=GWEN_Widget_Tree_GetParent(_widget);
36
37 qw=new QComboBox();
38
39 /* handle flags */
40 if (flags & GWEN_WIDGET_FLAGS_FILLX)
41 hpolicy=QSizePolicy::Expanding;
42 if (flags & GWEN_WIDGET_FLAGS_FILLY)
43 vpolicy=QSizePolicy::Expanding;
44 qw->setSizePolicy(hpolicy, vpolicy);
45 qw->setEditable((flags & GWEN_WIDGET_FLAGS_READONLY)?false:true);
46
48
49 qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
50 assert(qtDialog);
51
52 qw->connect(qw, SIGNAL(activated(int)),
53 qtDialog->getMainWindow(),
54 SLOT(slotActivated()));
55
56
57 if (wParent)
59 return 0;
60 }
61
62
63
65 int index,
66 int value,
67 int doSignal) {
68 QComboBox *qw;
69
71 assert(qw);
72
73 switch(prop) {
75 qw->setCurrentIndex(value);
76 return 0;
77
79 qw->clear();
80 return 0;
81
82 default:
83 return Qt4_W_Widget::setIntProperty(prop, index, value, doSignal);
84 }
85 };
86
87
88
90 int index,
91 int defaultValue) {
92 QComboBox *qw;
93
95 assert(qw);
96
97 switch(prop) {
99 return qw->currentIndex();
100
102 return qw->count();
103
104 default:
105 return Qt4_W_Widget::getIntProperty(prop, index, defaultValue);
106 }
107 };
108
109
110
112 int index,
113 const char *value,
114 int doSignal) {
115 QComboBox *qw;
116 QString text;
117
119 assert(qw);
120
121 if (value)
122 text=QString::fromUtf8(value);
123
124 switch(prop) {
126 // undefined
127 break;
128
130 qw->addItem(text);
131 return 0;
132
134 qw->clear();
135 return 0;
136 default:
137 break;
138 }
139
141 "Function is not appropriate for this type of widget (%s)",
143 return GWEN_ERROR_INVALID;
144 };
145
146
147
149 int index,
150 const char *defaultValue) {
151 QComboBox *qw;
152 QString str;
153
155 assert(qw);
156
157 switch(prop) {
159 str=qw->itemText(index);
160 if (str.isEmpty())
161 return defaultValue;
162 else {
165 }
166 break;
167
168 default:
169 break;
170 }
171
173 "Function is not appropriate for this type of widget (%s)",
175 return defaultValue;
176 };
177
178};
179
180
181
182
183
184
185
GWEN_WIDGET * _widget
Definition cppwidget.hpp:66
CppDialog * getDialog()
QT4_DialogBox * getMainWindow()
virtual int setup()
int setIntProperty(GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
Qt4_W_ComboBox(GWEN_WIDGET *w)
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_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
#define GWEN_WIDGET_FLAGS_READONLY
Definition dialog.h:63
GWEN_DIALOG_PROPERTY
Definition dialog.h:260
@ GWEN_DialogProperty_AddValue
Definition dialog.h:268
@ GWEN_DialogProperty_ValueCount
Definition dialog.h:270
@ GWEN_DialogProperty_ClearValues
Definition dialog.h:269
@ GWEN_DialogProperty_Value
Definition dialog.h:264
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWEN_LOGDOMAIN
Definition logger.h:35
#define QT4_DIALOG_WIDGET_REAL
#define QT4_DIALOG_STRING_TITLE
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition widget.c:828
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:452
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition widget.c:185
struct GWEN_WIDGET GWEN_WIDGET
Definition widget_be.h:34