gwenhywfar
4.3.3
|
00001 /*************************************************************************** 00002 begin : Mon Feb 15 2010 00003 copyright : (C) 2010 by Martin Preuss 00004 email : martin@libchipcard.de 00005 00006 *************************************************************************** 00007 * Please see toplevel file COPYING for license details * 00008 ***************************************************************************/ 00009 00010 00011 #include <gwen-gui-cpp/cppwidget.hpp> 00012 00013 00014 class Qt4_W_RadioButton: public Qt4_W_Widget { 00015 public: 00016 Qt4_W_RadioButton(GWEN_WIDGET *w):Qt4_W_Widget(w) { 00017 } 00018 00019 00020 00021 ~Qt4_W_RadioButton() { 00022 } 00023 00024 00025 00026 virtual int setup() { 00027 QRadioButton *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 QRadioButton(text); 00043 00044 /* handle flags */ 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(toggled(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 setIntProperty(GWEN_DIALOG_PROPERTY prop, 00068 int index, 00069 int value, 00070 int doSignal) { 00071 QRadioButton *qw; 00072 00073 qw=(QRadioButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); 00074 assert(qw); 00075 00076 switch(prop) { 00077 case GWEN_DialogProperty_Value: 00078 qw->setChecked((value==0)?false:true); 00079 return 0; 00080 00081 default: 00082 return Qt4_W_Widget::setIntProperty(prop, index, value, doSignal); 00083 } 00084 }; 00085 00086 00087 00088 int getIntProperty(GWEN_DIALOG_PROPERTY prop, 00089 int index, 00090 int defaultValue) { 00091 QRadioButton *qw; 00092 00093 qw=(QRadioButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); 00094 assert(qw); 00095 00096 switch(prop) { 00097 case GWEN_DialogProperty_Value: 00098 return (qw->isChecked())?1:0; 00099 00100 default: 00101 return Qt4_W_Widget::getIntProperty(prop, index, defaultValue); 00102 } 00103 }; 00104 00105 00106 00107 int setCharProperty(GWEN_DIALOG_PROPERTY prop, 00108 int index, 00109 const char *value, 00110 int doSignal) { 00111 QRadioButton *qw; 00112 QString text; 00113 00114 qw=(QRadioButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); 00115 assert(qw); 00116 00117 if (value) 00118 text=QString::fromUtf8(value); 00119 00120 switch(prop) { 00121 case GWEN_DialogProperty_Title: 00122 qw->setText(text); 00123 return 0; 00124 default: 00125 break; 00126 } 00127 00128 DBG_WARN(GWEN_LOGDOMAIN, 00129 "Function is not appropriate for this type of widget (%s)", 00130 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); 00131 return GWEN_ERROR_INVALID; 00132 }; 00133 00134 00135 00136 const char *getCharProperty(GWEN_DIALOG_PROPERTY prop, 00137 int index, 00138 const char *defaultValue) { 00139 QRadioButton *qw; 00140 QString str; 00141 00142 qw=(QRadioButton*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); 00143 assert(qw); 00144 00145 switch(prop) { 00146 case GWEN_DialogProperty_Title: 00147 str=qw->text(); 00148 if (str.isEmpty()) 00149 return defaultValue; 00150 else { 00151 GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8()); 00152 return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE); 00153 } 00154 break; 00155 00156 default: 00157 break; 00158 } 00159 00160 DBG_WARN(GWEN_LOGDOMAIN, 00161 "Function is not appropriate for this type of widget (%s)", 00162 GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); 00163 return defaultValue; 00164 }; 00165 00166 }; 00167 00168 00169 00170 00171 00172 00173