00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAVE_CONFIG_H
00011 # include <config.h>
00012 #endif
00013
00014 #include "cppdialog_p.hpp"
00015 #include <assert.h>
00016
00017 #include <gwenhywfar/inherit.h>
00018 #include <gwenhywfar/debug.h>
00019 #include <gwenhywfar/gui_be.h>
00020 #include <gwenhywfar/i18n.h>
00021
00022 #include <gwenhywfar/text.h>
00023 #include <gwenhywfar/mdigest.h>
00024 #include <gwenhywfar/debug.h>
00025
00026
00027 #define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
00028
00029
00030
00031 GWEN_INHERIT(GWEN_DIALOG, CppDialog);
00032
00033
00034
00035
00036 int CppDialogLinker::SetIntProperty(GWEN_DIALOG *dlg,
00037 GWEN_WIDGET *w,
00038 GWEN_DIALOG_PROPERTY prop,
00039 int index,
00040 int value,
00041 int doSignal) {
00042 CppDialog *xdlg;
00043
00044 assert(dlg);
00045 xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
00046 assert(xdlg);
00047
00048 return xdlg->setIntProperty(w, prop, index, value, doSignal);
00049 }
00050
00051
00052
00053
00054 int CppDialogLinker::GetIntProperty(GWEN_DIALOG *dlg,
00055 GWEN_WIDGET *w,
00056 GWEN_DIALOG_PROPERTY prop,
00057 int index,
00058 int defaultValue) {
00059 CppDialog *xdlg;
00060
00061 assert(dlg);
00062 xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
00063 assert(xdlg);
00064
00065 return xdlg->getIntProperty(w, prop, index, defaultValue);
00066 }
00067
00068
00069
00070 int CppDialogLinker::SetCharProperty(GWEN_DIALOG *dlg,
00071 GWEN_WIDGET *w,
00072 GWEN_DIALOG_PROPERTY prop,
00073 int index,
00074 const char *value,
00075 int doSignal) {
00076 CppDialog *xdlg;
00077
00078 assert(dlg);
00079 xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
00080 assert(xdlg);
00081
00082 return xdlg->setCharProperty(w, prop, index, value, doSignal);
00083 }
00084
00085
00086
00087 const char *CppDialogLinker::GetCharProperty(GWEN_DIALOG *dlg,
00088 GWEN_WIDGET *w,
00089 GWEN_DIALOG_PROPERTY prop,
00090 int index,
00091 const char *defaultValue) {
00092 CppDialog *xdlg;
00093
00094 assert(dlg);
00095 xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
00096 assert(xdlg);
00097
00098 return xdlg->getCharProperty(w, prop, index, defaultValue);
00099 }
00100
00101
00102
00103 void CppDialogLinker::freeData(void *bp, void *p) {
00104 CppDialog *xdlg;
00105
00106 xdlg=(CppDialog*) p;
00107 if (xdlg->_dialog)
00108 xdlg->_dialog=NULL;
00109 delete xdlg;
00110 }
00111
00112
00113
00114
00115
00116 CppDialog::CppDialog()
00117 :_dialog(NULL)
00118 {
00119 }
00120
00121
00122
00123 CppDialog::CppDialog(GWEN_DIALOG *dlg)
00124 :_dialog(NULL)
00125 {
00126 _dialog=dlg;
00127
00128 GWEN_INHERIT_SETDATA(GWEN_DIALOG, CppDialog,
00129 _dialog, this,
00130 CppDialogLinker::freeData);
00131
00132 _setIntPropertyFn=GWEN_Dialog_SetSetIntPropertyFn(_dialog, CppDialogLinker::SetIntProperty);
00133 _getIntPropertyFn=GWEN_Dialog_SetGetIntPropertyFn(_dialog, CppDialogLinker::GetIntProperty);
00134 _setCharPropertyFn=GWEN_Dialog_SetSetCharPropertyFn(_dialog, CppDialogLinker::SetCharProperty);
00135 _getCharPropertyFn=GWEN_Dialog_SetGetCharPropertyFn(_dialog, CppDialogLinker::GetCharProperty);
00136 }
00137
00138
00139
00140 CppDialog::~CppDialog() {
00141 if (_dialog) {
00142 GWEN_INHERIT_UNLINK(GWEN_DIALOG, CppDialog, _dialog)
00143 }
00144 }
00145
00146
00147
00148 CppDialog *CppDialog::getDialog(GWEN_DIALOG *dlg) {
00149 CppDialog *xdlg;
00150 GWEN_DIALOG *pdlg;
00151
00152 while( (pdlg=GWEN_Dialog_GetParentDialog(dlg)) )
00153 dlg=pdlg;
00154
00155 assert(dlg);
00156 xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
00157 assert(xdlg);
00158
00159 return xdlg;
00160 }
00161
00162
00163
00164 GWEN_DIALOG *CppDialog::getCInterface() {
00165 return _dialog;
00166 }
00167
00168
00169
00170 int CppDialog::setIntProperty(GWEN_WIDGET *w,
00171 GWEN_DIALOG_PROPERTY prop,
00172 int index,
00173 int value,
00174 int doSignal) {
00175 if (_setIntPropertyFn)
00176 return _setIntPropertyFn(_dialog, w, prop, index, value, doSignal);
00177 else
00178 return GWEN_ERROR_NOT_SUPPORTED;
00179 }
00180
00181
00182
00183 int CppDialog::getIntProperty(GWEN_WIDGET *w,
00184 GWEN_DIALOG_PROPERTY prop,
00185 int index,
00186 int defaultValue) {
00187 if (_getIntPropertyFn)
00188 return _getIntPropertyFn(_dialog, w, prop, index, defaultValue);
00189 else
00190 return defaultValue;
00191 }
00192
00193
00194
00195 int CppDialog::setCharProperty(GWEN_WIDGET *w,
00196 GWEN_DIALOG_PROPERTY prop,
00197 int index,
00198 const char *value,
00199 int doSignal) {
00200 if (_setCharPropertyFn)
00201 return _setCharPropertyFn(_dialog, w, prop, index, value, doSignal);
00202 else
00203 return GWEN_ERROR_NOT_SUPPORTED;
00204 }
00205
00206
00207
00208 const char *CppDialog::getCharProperty(GWEN_WIDGET *w,
00209 GWEN_DIALOG_PROPERTY prop,
00210 int index,
00211 const char *defaultValue) {
00212 if (_getCharPropertyFn)
00213 return _getCharPropertyFn(_dialog, w, prop, index, defaultValue);
00214 else
00215 return defaultValue;
00216 }
00217
00218
00219
00220 int CppDialog::emitSignal(GWEN_DIALOG_EVENTTYPE t, const char *sender) {
00221 assert(_dialog);
00222 return GWEN_Dialog_EmitSignal(_dialog, t, sender);
00223 }
00224
00225
00226
00227 GWEN_WIDGET_TREE *CppDialog::getWidgets() const {
00228 assert(_dialog);
00229 return GWEN_Dialog_GetWidgets(_dialog);
00230 }
00231
00232
00233
00234 GWEN_WIDGET *CppDialog::findWidgetByName(const char *name) {
00235 assert(_dialog);
00236 return GWEN_Dialog_FindWidgetByName(_dialog, name);
00237 }
00238
00239
00240
00241 GWEN_WIDGET *CppDialog::findWidgetByImplData(int index, void *ptr) {
00242 assert(_dialog);
00243 return GWEN_Dialog_FindWidgetByImplData(_dialog, index, ptr);
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256