gwenhywfar 5.14.1
qt5/w_widget.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
14class Qt5_W_Widget: public CppWidget {
15public:
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
34 wParent=GWEN_Widget_Tree_GetParent(_widget);
35
36 qw=new QWidget();
37
38 /* handle flags */
39 if (flags & GWEN_WIDGET_FLAGS_FILLX)
40 hpolicy=QSizePolicy::Expanding;
41 if (flags & GWEN_WIDGET_FLAGS_FILLY)
42 vpolicy=QSizePolicy::Expanding;
43 qw->setSizePolicy(hpolicy, vpolicy);
44
47
48 if (wParent)
50 return 0;
51 }
52
53
54
55 static QWidget *getQWidget(GWEN_WIDGET *w) {
56 QWidget *qw;
57
59 assert(qw);
60
61 return qw;
62 }
63
64
66 GWEN_UNUSED int index,
67 int value,
68 GWEN_UNUSED int doSignal) {
69 QWidget *qw;
70
72 assert(qw);
73
74 switch(prop) {
76 qw->resize(value, qw->height());
77 return 0;
78
80 qw->resize(qw->width(), value);
81 return 0;
82
84 qw->setEnabled((value==0)?false:true);
85 return 0;
86
88 qw->setFocus();
89 return 0;
90
92 if (value==0)
93 qw->hide();
94 else
95 qw->show();
96 return 0;
97
98 default:
99 break;
100 }
101
103 "Function is not appropriate for this type of widget (%s)",
105 return GWEN_ERROR_INVALID;
106 };
107
108
109
111 GWEN_UNUSED int index,
112 int defaultValue) {
113 QWidget *qw;
114
116 assert(qw);
117
118 switch(prop) {
120 return qw->width();
121
123 return qw->height();
124
126 return (qw->isEnabled())?1:0;
127
129 return (qw->hasFocus())?1:0;
130
131 default:
132 break;
133 }
134
136 "Function is not appropriate for this type of widget (%s)",
138 return defaultValue;
139 };
140
141
142
144 GWEN_UNUSED int index,
145 GWEN_UNUSED const char *value,
146 GWEN_UNUSED int doSignal) {
148 "Function is not appropriate for this type of widget (%s)",
150 return GWEN_ERROR_INVALID;
151 };
152
153
154
156 GWEN_UNUSED int index,
157 const char *defaultValue) {
159 "Function is not appropriate for this type of widget (%s)",
161 return defaultValue;
162 };
163
164};
165
166
167
168
169
170
171
CppWidget(GWEN_WIDGET *w)
GWEN_WIDGET * _widget
Definition cppwidget.hpp:66
virtual int setup()
static QWidget * getQWidget(GWEN_WIDGET *w)
Qt5_W_Widget(GWEN_WIDGET *w)
int setCharProperty(GWEN_UNUSED GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, GWEN_UNUSED const char *value, GWEN_UNUSED int doSignal)
int setIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
const char * getCharProperty(GWEN_UNUSED GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
int getIntProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED 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_Visibility
Definition dialog.h:280
@ GWEN_DialogProperty_Height
Definition dialog.h:273
@ GWEN_DialogProperty_Enabled
Definition dialog.h:267
@ GWEN_DialogProperty_Focus
Definition dialog.h:276
@ GWEN_DialogProperty_Width
Definition dialog.h:272
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWEN_UNUSED
#define GWEN_LOGDOMAIN
Definition logger.h:32
#define QT5_DIALOG_WIDGET_REAL
#define QT5_DIALOG_WIDGET_CONTENT
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
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