1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
/***************************************************************************
begin : Fri Jan 22 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cppwidget_p.hpp"
#include "cppdialog.hpp"
#include <assert.h>
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/gui_be.h>
#include <gwenhywfar/widget_be.h>
#include <gwenhywfar/i18n.h>
#include <gwenhywfar/text.h>
#include <gwenhywfar/mdigest.h>
#include <gwenhywfar/debug.h>
#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
GWEN_INHERIT(GWEN_WIDGET, CppWidget);
int CppWidgetLinker::SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw->setIntProperty(prop, index, value, doSignal);
}
int CppWidgetLinker::GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw->getIntProperty(prop, index, defaultValue);
}
int CppWidgetLinker::SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw->setCharProperty(prop, index, value, doSignal);
}
const char *CppWidgetLinker::GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw->getCharProperty(prop, index, defaultValue);
}
int CppWidgetLinker::AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw->addChildGuiWidget(wChild);
}
void CppWidgetLinker::freeData(void *bp, void *p) {
CppWidget *xw;
xw=(CppWidget*) p;
if (xw->_widget)
xw->_widget=NULL;
delete xw;
}
CppWidget::CppWidget()
:_widget(NULL)
{
}
CppWidget::CppWidget(GWEN_WIDGET *w)
:_widget(w)
{
GWEN_INHERIT_SETDATA(GWEN_WIDGET, CppWidget,
_widget, this,
CppWidgetLinker::freeData);
_setIntPropertyFn=GWEN_Widget_SetSetIntPropertyFn(_widget, CppWidgetLinker::SetIntProperty);
_getIntPropertyFn=GWEN_Widget_SetGetIntPropertyFn(_widget, CppWidgetLinker::GetIntProperty);
_setCharPropertyFn=GWEN_Widget_SetSetCharPropertyFn(_widget, CppWidgetLinker::SetCharProperty);
_getCharPropertyFn=GWEN_Widget_SetGetCharPropertyFn(_widget, CppWidgetLinker::GetCharProperty);
_addChildGuiWidgetFn=GWEN_Widget_SetAddChildGuiWidgetFn(_widget, CppWidgetLinker::AddChildGuiWidget);
}
CppWidget::~CppWidget() {
if (_widget) {
GWEN_INHERIT_UNLINK(GWEN_WIDGET, CppWidget, _widget)
}
}
GWEN_WIDGET *CppWidget::getCInterface() {
return _widget;
}
CppWidget *CppWidget::getWidget(GWEN_WIDGET *w) {
CppWidget *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, CppWidget, w);
assert(xw);
return xw;
}
CppDialog *CppWidget::getDialog() {
GWEN_DIALOG *dlg;
dlg=GWEN_Widget_GetDialog(_widget);
if (dlg)
return CppDialog::getDialog(dlg);
else
return NULL;
}
int CppWidget::setIntProperty(GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
if (_setIntPropertyFn)
return _setIntPropertyFn(_widget, prop, index, value, doSignal);
else
return GWEN_ERROR_NOT_SUPPORTED;
}
int CppWidget::getIntProperty(GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
if (_getIntPropertyFn)
return _getIntPropertyFn(_widget, prop, index, defaultValue);
else
return defaultValue;
}
int CppWidget::setCharProperty(GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
if (_setCharPropertyFn)
return _setCharPropertyFn(_widget, prop, index, value, doSignal);
else
return GWEN_ERROR_NOT_SUPPORTED;
}
const char *CppWidget::getCharProperty(GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
if (_getCharPropertyFn)
return _getCharPropertyFn(_widget, prop, index, defaultValue);
else
return defaultValue;
}
int CppWidget::addChildGuiWidget(GWEN_WIDGET *wChild) {
if (_addChildGuiWidgetFn)
return _addChildGuiWidgetFn(_widget, wChild);
else
return GWEN_ERROR_NOT_SUPPORTED;
}
const char *CppWidget::getName() {
return GWEN_Widget_GetName(_widget);
}
GWEN_WIDGET_TYPE CppWidget::getType() {
return GWEN_Widget_GetType(_widget);
}
int CppWidget::getColumns() {
return GWEN_Widget_GetColumns(_widget);
}
int CppWidget::getRows() {
return GWEN_Widget_GetRows(_widget);
}
uint32_t CppWidget::getFlags() {
return GWEN_Widget_GetFlags(_widget);
}
int CppWidget::getGroupId() {
return GWEN_Widget_GetGroupId(_widget);
}
int CppWidget::getWidth() {
return GWEN_Widget_GetWidth(_widget);
}
int CppWidget::getHeight() {
return GWEN_Widget_GetHeight(_widget);
}
const char *CppWidget::getText(int idx) {
return GWEN_Widget_GetText(_widget, idx);
}
const char *CppWidget::getIconFileName() {
return GWEN_Widget_GetIconFileName(_widget);
}
const char *CppWidget::getImageFileName() {
return GWEN_Widget_GetImageFileName(_widget);
}
|