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_Widget: public CppWidget {
00015 public:
00016 Qt4_W_Widget(GWEN_WIDGET *w):CppWidget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_Widget() {
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
00033 flags=GWEN_Widget_GetFlags(_widget);
00034 wParent=GWEN_Widget_Tree_GetParent(_widget);
00035
00036 qw=new QWidget();
00037
00038
00039 if (flags & GWEN_WIDGET_FLAGS_FILLX)
00040 hpolicy=QSizePolicy::Expanding;
00041 if (flags & GWEN_WIDGET_FLAGS_FILLY)
00042 vpolicy=QSizePolicy::Expanding;
00043 qw->setSizePolicy(hpolicy, vpolicy);
00044
00045 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00046 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_CONTENT, (void*) qw);
00047
00048 if (wParent)
00049 GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00050 return 0;
00051 }
00052
00053
00054
00055 static QWidget *getQWidget(GWEN_WIDGET *w) {
00056 QWidget *qw;
00057
00058 qw=(QWidget*) GWEN_Widget_GetImplData(w, QT4_DIALOG_WIDGET_REAL);
00059 assert(qw);
00060
00061 return qw;
00062 }
00063
00064
00065 int setIntProperty(GWEN_DIALOG_PROPERTY prop,
00066 int index,
00067 int value,
00068 int doSignal) {
00069 QWidget *qw;
00070
00071 qw=(QWidget*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00072 assert(qw);
00073
00074 switch(prop) {
00075 case GWEN_DialogProperty_Width:
00076 qw->resize(value, qw->height());
00077 return 0;
00078
00079 case GWEN_DialogProperty_Height:
00080 qw->resize(qw->width(), value);
00081 return 0;
00082
00083 case GWEN_DialogProperty_Enabled:
00084 qw->setEnabled((value==0)?false:true);
00085 return 0;
00086
00087 case GWEN_DialogProperty_Focus:
00088 qw->setFocus();
00089 return 0;
00090
00091 case GWEN_DialogProperty_Visibility:
00092 if (value==0)
00093 qw->hide();
00094 else
00095 qw->show();
00096 return 0;
00097
00098 default:
00099 break;
00100 }
00101
00102 DBG_WARN(GWEN_LOGDOMAIN,
00103 "Function is not appropriate for this type of widget (%s)",
00104 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00105 return GWEN_ERROR_INVALID;
00106 };
00107
00108
00109
00110 int getIntProperty(GWEN_DIALOG_PROPERTY prop,
00111 int index,
00112 int defaultValue) {
00113 QWidget *qw;
00114
00115 qw=(QWidget*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00116 assert(qw);
00117
00118 switch(prop) {
00119 case GWEN_DialogProperty_Width:
00120 return qw->width();
00121
00122 case GWEN_DialogProperty_Height:
00123 return qw->height();
00124
00125 case GWEN_DialogProperty_Enabled:
00126 return (qw->isEnabled())?1:0;
00127
00128 case GWEN_DialogProperty_Focus:
00129 return (qw->hasFocus())?1:0;
00130
00131 default:
00132 break;
00133 }
00134
00135 DBG_WARN(GWEN_LOGDOMAIN,
00136 "Function is not appropriate for this type of widget (%s)",
00137 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00138 return defaultValue;
00139 };
00140
00141
00142
00143 int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00144 int index,
00145 const char *value,
00146 int doSignal) {
00147 DBG_WARN(GWEN_LOGDOMAIN,
00148 "Function is not appropriate for this type of widget (%s)",
00149 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00150 return GWEN_ERROR_INVALID;
00151 };
00152
00153
00154
00155 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00156 int index,
00157 const char *defaultValue) {
00158 DBG_WARN(GWEN_LOGDOMAIN,
00159 "Function is not appropriate for this type of widget (%s)",
00160 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00161 return defaultValue;
00162 };
00163
00164 };
00165
00166
00167
00168
00169
00170
00171