Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <gwen-gui-cpp/cppwidget.hpp>
00012
00013
00014 class Qt4_W_PushButton: public Qt4_W_Widget {
00015 public:
00016 Qt4_W_PushButton(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_PushButton() {
00022 }
00023
00024
00025
00026 virtual int setup() {
00027 QWidget *qw;
00028 uint32_t flags;
00029 GWEN_WIDGET *wParent;
00030 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
00031 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
00032 const char *s;
00033 QString text;
00034 QT4_GuiDialog *qtDialog;
00035
00036 flags=GWEN_Widget_GetFlags(_widget);
00037 wParent=GWEN_Widget_Tree_GetParent(_widget);
00038 s=GWEN_Widget_GetText(_widget, 0);
00039 if (s)
00040 text=QString::fromUtf8(s);
00041
00042 qw=new QPushButton(text);
00043
00044
00045 if (flags & GWEN_WIDGET_FLAGS_FILLX)
00046 hpolicy=QSizePolicy::Expanding;
00047 if (flags & GWEN_WIDGET_FLAGS_FILLY)
00048 vpolicy=QSizePolicy::Expanding;
00049 qw->setSizePolicy(hpolicy, vpolicy);
00050
00051 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00052
00053 qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
00054 assert(qtDialog);
00055
00056 qw->connect(qw, SIGNAL(clicked(bool)),
00057 qtDialog->getMainWindow(),
00058 SLOT(slotActivated()));
00059
00060 if (wParent)
00061 GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00062 return 0;
00063 }
00064
00065
00066
00067 int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00068 int index,
00069 const char *value,
00070 int doSignal) {
00071 QPushButton *qw;
00072 QString text;
00073
00074 qw=(QPushButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00075 assert(qw);
00076
00077 if (value)
00078 text=QString::fromUtf8(value);
00079
00080 switch(prop) {
00081 case GWEN_DialogProperty_Title:
00082 qw->setText(text);
00083 return 0;
00084 default:
00085 break;
00086 }
00087
00088 DBG_WARN(GWEN_LOGDOMAIN,
00089 "Function is not appropriate for this type of widget (%s)",
00090 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00091 return GWEN_ERROR_INVALID;
00092 };
00093
00094
00095
00096 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00097 int index,
00098 const char *defaultValue) {
00099 QPushButton *qw;
00100 QString str;
00101
00102 qw=(QPushButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00103 assert(qw);
00104
00105 switch(prop) {
00106 case GWEN_DialogProperty_Title:
00107 str=qw->text();
00108 if (str.isEmpty())
00109 return defaultValue;
00110 else {
00111 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
00112 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
00113 }
00114 break;
00115
00116 default:
00117 break;
00118 }
00119
00120 DBG_WARN(GWEN_LOGDOMAIN,
00121 "Function is not appropriate for this type of widget (%s)",
00122 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00123 return defaultValue;
00124 };
00125
00126 };
00127
00128
00129
00130
00131
00132
00133