gwenhywfar 4.0.3
|
00001 /*************************************************************************** 00002 begin : Fri Jan 22 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 #ifdef HAVE_CONFIG_H 00011 # include <config.h> 00012 #endif 00013 00014 #include "cppwidget_p.hpp" 00015 #include "cppdialog.hpp" 00016 00017 #include <assert.h> 00018 00019 #include <gwenhywfar/inherit.h> 00020 #include <gwenhywfar/debug.h> 00021 #include <gwenhywfar/gui_be.h> 00022 #include <gwenhywfar/widget_be.h> 00023 #include <gwenhywfar/i18n.h> 00024 00025 #include <gwenhywfar/text.h> 00026 #include <gwenhywfar/mdigest.h> 00027 #include <gwenhywfar/debug.h> 00028 00029 00030 #define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) 00031 00032 00033 00034 GWEN_INHERIT(GWEN_WIDGET, CppWidget); 00035 00036 00037 00038 00039 int CppWidgetLinker::SetIntProperty(GWEN_WIDGET *w, 00040 GWEN_DIALOG_PROPERTY prop, 00041 int index, 00042 int value, 00043 int doSignal) { 00044 CppWidget *xw; 00045 00046 assert(w); 00047 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00048 assert(xw); 00049 00050 return xw->setIntProperty(prop, index, value, doSignal); 00051 } 00052 00053 00054 00055 00056 int CppWidgetLinker::GetIntProperty(GWEN_WIDGET *w, 00057 GWEN_DIALOG_PROPERTY prop, 00058 int index, 00059 int defaultValue) { 00060 CppWidget *xw; 00061 00062 assert(w); 00063 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00064 assert(xw); 00065 00066 return xw->getIntProperty(prop, index, defaultValue); 00067 } 00068 00069 00070 00071 int CppWidgetLinker::SetCharProperty(GWEN_WIDGET *w, 00072 GWEN_DIALOG_PROPERTY prop, 00073 int index, 00074 const char *value, 00075 int doSignal) { 00076 CppWidget *xw; 00077 00078 assert(w); 00079 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00080 assert(xw); 00081 00082 return xw->setCharProperty(prop, index, value, doSignal); 00083 } 00084 00085 00086 00087 const char *CppWidgetLinker::GetCharProperty(GWEN_WIDGET *w, 00088 GWEN_DIALOG_PROPERTY prop, 00089 int index, 00090 const char *defaultValue) { 00091 CppWidget *xw; 00092 00093 assert(w); 00094 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00095 assert(xw); 00096 00097 return xw->getCharProperty(prop, index, defaultValue); 00098 } 00099 00100 00101 00102 int CppWidgetLinker::AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) { 00103 CppWidget *xw; 00104 00105 assert(w); 00106 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00107 assert(xw); 00108 00109 return xw->addChildGuiWidget(wChild); 00110 } 00111 00112 00113 00114 void CppWidgetLinker::freeData(void *bp, void *p) { 00115 CppWidget *xw; 00116 00117 xw=(CppWidget*) p; 00118 if (xw->_widget) 00119 xw->_widget=NULL; 00120 delete xw; 00121 } 00122 00123 00124 00125 00126 00127 CppWidget::CppWidget() 00128 :_widget(NULL) 00129 { 00130 } 00131 00132 00133 00134 CppWidget::CppWidget(GWEN_WIDGET *w) 00135 :_widget(w) 00136 { 00137 GWEN_INHERIT_SETDATA(GWEN_WIDGET, CppWidget, 00138 _widget, this, 00139 CppWidgetLinker::freeData); 00140 00141 _setIntPropertyFn=GWEN_Widget_SetSetIntPropertyFn(_widget, CppWidgetLinker::SetIntProperty); 00142 _getIntPropertyFn=GWEN_Widget_SetGetIntPropertyFn(_widget, CppWidgetLinker::GetIntProperty); 00143 _setCharPropertyFn=GWEN_Widget_SetSetCharPropertyFn(_widget, CppWidgetLinker::SetCharProperty); 00144 _getCharPropertyFn=GWEN_Widget_SetGetCharPropertyFn(_widget, CppWidgetLinker::GetCharProperty); 00145 _addChildGuiWidgetFn=GWEN_Widget_SetAddChildGuiWidgetFn(_widget, CppWidgetLinker::AddChildGuiWidget); 00146 } 00147 00148 00149 00150 CppWidget::~CppWidget() { 00151 if (_widget) { 00152 GWEN_INHERIT_UNLINK(GWEN_WIDGET, CppWidget, _widget) 00153 } 00154 } 00155 00156 00157 00158 GWEN_WIDGET *CppWidget::getCInterface() { 00159 return _widget; 00160 } 00161 00162 00163 00164 CppWidget *CppWidget::getWidget(GWEN_WIDGET *w) { 00165 CppWidget *xw; 00166 00167 assert(w); 00168 xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w); 00169 assert(xw); 00170 00171 return xw; 00172 } 00173 00174 00175 00176 CppDialog *CppWidget::getDialog() { 00177 GWEN_DIALOG *dlg; 00178 00179 dlg=GWEN_Widget_GetDialog(_widget); 00180 if (dlg) 00181 return CppDialog::getDialog(dlg); 00182 else 00183 return NULL; 00184 } 00185 00186 00187 00188 int CppWidget::setIntProperty(GWEN_DIALOG_PROPERTY prop, 00189 int index, 00190 int value, 00191 int doSignal) { 00192 if (_setIntPropertyFn) 00193 return _setIntPropertyFn(_widget, prop, index, value, doSignal); 00194 else 00195 return GWEN_ERROR_NOT_SUPPORTED; 00196 } 00197 00198 00199 00200 int CppWidget::getIntProperty(GWEN_DIALOG_PROPERTY prop, 00201 int index, 00202 int defaultValue) { 00203 if (_getIntPropertyFn) 00204 return _getIntPropertyFn(_widget, prop, index, defaultValue); 00205 else 00206 return defaultValue; 00207 } 00208 00209 00210 00211 int CppWidget::setCharProperty(GWEN_DIALOG_PROPERTY prop, 00212 int index, 00213 const char *value, 00214 int doSignal) { 00215 if (_setCharPropertyFn) 00216 return _setCharPropertyFn(_widget, prop, index, value, doSignal); 00217 else 00218 return GWEN_ERROR_NOT_SUPPORTED; 00219 } 00220 00221 00222 00223 const char *CppWidget::getCharProperty(GWEN_DIALOG_PROPERTY prop, 00224 int index, 00225 const char *defaultValue) { 00226 if (_getCharPropertyFn) 00227 return _getCharPropertyFn(_widget, prop, index, defaultValue); 00228 else 00229 return defaultValue; 00230 } 00231 00232 00233 00234 int CppWidget::addChildGuiWidget(GWEN_WIDGET *wChild) { 00235 if (_addChildGuiWidgetFn) 00236 return _addChildGuiWidgetFn(_widget, wChild); 00237 else 00238 return GWEN_ERROR_NOT_SUPPORTED; 00239 } 00240 00241 00242 00243 const char *CppWidget::getName() { 00244 return GWEN_Widget_GetName(_widget); 00245 } 00246 00247 00248 00249 GWEN_WIDGET_TYPE CppWidget::getType() { 00250 return GWEN_Widget_GetType(_widget); 00251 } 00252 00253 00254 00255 int CppWidget::getColumns() { 00256 return GWEN_Widget_GetColumns(_widget); 00257 } 00258 00259 00260 00261 int CppWidget::getRows() { 00262 return GWEN_Widget_GetRows(_widget); 00263 } 00264 00265 00266 00267 uint32_t CppWidget::getFlags() { 00268 return GWEN_Widget_GetFlags(_widget); 00269 } 00270 00271 00272 00273 int CppWidget::getGroupId() { 00274 return GWEN_Widget_GetGroupId(_widget); 00275 } 00276 00277 00278 00279 int CppWidget::getWidth() { 00280 return GWEN_Widget_GetWidth(_widget); 00281 } 00282 00283 00284 00285 int CppWidget::getHeight() { 00286 return GWEN_Widget_GetHeight(_widget); 00287 } 00288 00289 00290 00291 const char *CppWidget::getText(int idx) { 00292 return GWEN_Widget_GetText(_widget, idx); 00293 } 00294 00295 00296 00297 const char *CppWidget::getIconFileName() { 00298 return GWEN_Widget_GetIconFileName(_widget); 00299 } 00300 00301 00302 00303 const char *CppWidget::getImageFileName() { 00304 return GWEN_Widget_GetImageFileName(_widget); 00305 } 00306 00307 00308 00309 00310 00311 00312 00313