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_ComboBox: public Qt4_W_Widget {
00015 public:
00016 Qt4_W_ComboBox(GWEN_WIDGET *w):Qt4_W_Widget(w) {
00017 }
00018
00019
00020
00021 ~Qt4_W_ComboBox() {
00022 }
00023
00024
00025
00026 virtual int setup() {
00027 QComboBox *qw;
00028 uint32_t flags;
00029 GWEN_WIDGET *wParent;
00030 QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
00031 QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
00032 QT4_GuiDialog *qtDialog;
00033
00034 flags=GWEN_Widget_GetFlags(_widget);
00035 wParent=GWEN_Widget_Tree_GetParent(_widget);
00036
00037 qw=new QComboBox();
00038
00039
00040 if (flags & GWEN_WIDGET_FLAGS_FILLX)
00041 hpolicy=QSizePolicy::Expanding;
00042 if (flags & GWEN_WIDGET_FLAGS_FILLY)
00043 vpolicy=QSizePolicy::Expanding;
00044 qw->setSizePolicy(hpolicy, vpolicy);
00045 qw->setEditable((flags & GWEN_WIDGET_FLAGS_READONLY)?false:true);
00046
00047 GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
00048
00049 qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
00050 assert(qtDialog);
00051
00052 qw->connect(qw, SIGNAL(activated(int)),
00053 qtDialog->getMainWindow(),
00054 SLOT(slotActivated()));
00055
00056
00057 if (wParent)
00058 GWEN_Widget_AddChildGuiWidget(wParent, _widget);
00059 return 0;
00060 }
00061
00062
00063
00064 int setIntProperty(GWEN_DIALOG_PROPERTY prop,
00065 int index,
00066 int value,
00067 int doSignal) {
00068 QComboBox *qw;
00069
00070 qw=(QComboBox*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00071 assert(qw);
00072
00073 switch(prop) {
00074 case GWEN_DialogProperty_Value:
00075 qw->setCurrentIndex(value);
00076 return 0;
00077
00078 case GWEN_DialogProperty_ClearValues:
00079 qw->clear();
00080 return 0;
00081
00082 default:
00083 return Qt4_W_Widget::setIntProperty(prop, index, value, doSignal);
00084 }
00085 };
00086
00087
00088
00089 int getIntProperty(GWEN_DIALOG_PROPERTY prop,
00090 int index,
00091 int defaultValue) {
00092 QComboBox *qw;
00093
00094 qw=(QComboBox*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00095 assert(qw);
00096
00097 switch(prop) {
00098 case GWEN_DialogProperty_Value:
00099 return qw->currentIndex();
00100
00101 case GWEN_DialogProperty_ValueCount:
00102 return qw->count();
00103
00104 default:
00105 return Qt4_W_Widget::getIntProperty(prop, index, defaultValue);
00106 }
00107 };
00108
00109
00110
00111 int setCharProperty(GWEN_DIALOG_PROPERTY prop,
00112 int index,
00113 const char *value,
00114 int doSignal) {
00115 QComboBox *qw;
00116 QString text;
00117
00118 qw=(QComboBox*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00119 assert(qw);
00120
00121 if (value)
00122 text=QString::fromUtf8(value);
00123
00124 switch(prop) {
00125 case GWEN_DialogProperty_Value:
00126
00127 break;
00128
00129 case GWEN_DialogProperty_AddValue:
00130 qw->addItem(text);
00131 return 0;
00132
00133 case GWEN_DialogProperty_ClearValues:
00134 qw->clear();
00135 return 0;
00136 default:
00137 break;
00138 }
00139
00140 DBG_WARN(GWEN_LOGDOMAIN,
00141 "Function is not appropriate for this type of widget (%s)",
00142 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00143 return GWEN_ERROR_INVALID;
00144 };
00145
00146
00147
00148 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop,
00149 int index,
00150 const char *defaultValue) {
00151 QComboBox *qw;
00152 QString str;
00153
00154 qw=(QComboBox*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL);
00155 assert(qw);
00156
00157 switch(prop) {
00158 case GWEN_DialogProperty_Value:
00159 str=qw->itemText(index);
00160 if (str.isEmpty())
00161 return defaultValue;
00162 else {
00163 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8());
00164 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE);
00165 }
00166 break;
00167
00168 default:
00169 break;
00170 }
00171
00172 DBG_WARN(GWEN_LOGDOMAIN,
00173 "Function is not appropriate for this type of widget (%s)",
00174 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget)));
00175 return defaultValue;
00176 };
00177
00178 };
00179
00180
00181
00182
00183
00184
00185