gwenhywfar 5.12.0
qt5/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
15public:
18
19
20
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 QT5_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<QT5_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 GWEN_UNUSED int index,
69 const char *value,
70 GWEN_UNUSED 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 GWEN_UNUSED 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
GWEN_WIDGET * _widget
Definition cppwidget.hpp:66
CppDialog * getDialog()
QT5_DialogBox * getMainWindow()
Qt5_W_PushButton(GWEN_WIDGET *w)
int setCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)
const char * getCharProperty(GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
Qt5_W_Widget(GWEN_WIDGET *w)
#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_Title
Definition dialog.h:263
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWEN_UNUSED
#define GWEN_LOGDOMAIN
Definition logger.h:35
#define QT5_DIALOG_STRING_TITLE
#define QT5_DIALOG_WIDGET_REAL
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