File: cppdialog.cpp

package info (click to toggle)
libgwenhywfar 4.12.0beta-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,004 kB
  • ctags: 7,553
  • sloc: ansic: 98,857; sh: 11,641; cpp: 8,598; objc: 2,525; makefile: 1,710; xml: 876
file content (256 lines) | stat: -rw-r--r-- 5,205 bytes parent folder | download | duplicates (5)
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
/***************************************************************************
    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 "cppdialog_p.hpp"
#include <assert.h>

#include <gwenhywfar/inherit.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/gui_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_DIALOG, CppDialog);




int CppDialogLinker::SetIntProperty(GWEN_DIALOG *dlg,
				    GWEN_WIDGET *w,
				    GWEN_DIALOG_PROPERTY prop,
				    int index,
				    int value,
				    int doSignal) {
  CppDialog *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
  assert(xdlg);

  return xdlg->setIntProperty(w, prop, index, value, doSignal);
}




int CppDialogLinker::GetIntProperty(GWEN_DIALOG *dlg,
				    GWEN_WIDGET *w,
				    GWEN_DIALOG_PROPERTY prop,
				    int index,
				    int defaultValue) {
  CppDialog *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
  assert(xdlg);

  return xdlg->getIntProperty(w, prop, index, defaultValue);
}



int CppDialogLinker::SetCharProperty(GWEN_DIALOG *dlg,
				     GWEN_WIDGET *w,
				     GWEN_DIALOG_PROPERTY prop,
				     int index,
				     const char *value,
				     int doSignal) {
  CppDialog *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
  assert(xdlg);

  return xdlg->setCharProperty(w, prop, index, value, doSignal);
}



const char *CppDialogLinker::GetCharProperty(GWEN_DIALOG *dlg,
					     GWEN_WIDGET *w,
					     GWEN_DIALOG_PROPERTY prop,
					     int index,
					     const char *defaultValue) {
  CppDialog *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
  assert(xdlg);

  return xdlg->getCharProperty(w, prop, index, defaultValue);
}



void CppDialogLinker::freeData(void *bp, void *p) {
  CppDialog *xdlg;

  xdlg=(CppDialog*) p;
  if (xdlg->_dialog)
    xdlg->_dialog=NULL;
  delete xdlg;
}





CppDialog::CppDialog()
:_dialog(NULL)
{
}



CppDialog::CppDialog(GWEN_DIALOG *dlg)
:_dialog(NULL)
{
  _dialog=dlg;

  GWEN_INHERIT_SETDATA(GWEN_DIALOG, CppDialog,
		       _dialog, this,
		       CppDialogLinker::freeData);

  _setIntPropertyFn=GWEN_Dialog_SetSetIntPropertyFn(_dialog, CppDialogLinker::SetIntProperty);
  _getIntPropertyFn=GWEN_Dialog_SetGetIntPropertyFn(_dialog, CppDialogLinker::GetIntProperty);
  _setCharPropertyFn=GWEN_Dialog_SetSetCharPropertyFn(_dialog, CppDialogLinker::SetCharProperty);
  _getCharPropertyFn=GWEN_Dialog_SetGetCharPropertyFn(_dialog, CppDialogLinker::GetCharProperty);
}



CppDialog::~CppDialog() {
  if (_dialog) {
    GWEN_INHERIT_UNLINK(GWEN_DIALOG, CppDialog, _dialog)
  }
}



CppDialog *CppDialog::getDialog(GWEN_DIALOG *dlg) {
  CppDialog *xdlg;
  GWEN_DIALOG *pdlg;

  while( (pdlg=GWEN_Dialog_GetParentDialog(dlg)) )
    dlg=pdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, CppDialog, dlg);
  assert(xdlg);

  return xdlg;
}



GWEN_DIALOG *CppDialog::getCInterface() {
  return _dialog;
}



int CppDialog::setIntProperty(GWEN_WIDGET *w,
			      GWEN_DIALOG_PROPERTY prop,
			      int index,
			      int value,
			      int doSignal) {
  if (_setIntPropertyFn)
    return _setIntPropertyFn(_dialog, w, prop, index, value, doSignal);
  else
    return GWEN_ERROR_NOT_SUPPORTED;
}



int CppDialog::getIntProperty(GWEN_WIDGET *w,
			      GWEN_DIALOG_PROPERTY prop,
			      int index,
			      int defaultValue) {
  if (_getIntPropertyFn)
    return _getIntPropertyFn(_dialog, w, prop, index, defaultValue);
  else
    return defaultValue;
}



int CppDialog::setCharProperty(GWEN_WIDGET *w,
			       GWEN_DIALOG_PROPERTY prop,
			       int index,
			       const char *value,
			       int doSignal) {
  if (_setCharPropertyFn)
    return _setCharPropertyFn(_dialog, w, prop, index, value, doSignal);
  else
    return GWEN_ERROR_NOT_SUPPORTED;
}



const char *CppDialog::getCharProperty(GWEN_WIDGET *w,
				       GWEN_DIALOG_PROPERTY prop,
				       int index,
				       const char *defaultValue) {
  if (_getCharPropertyFn)
    return _getCharPropertyFn(_dialog, w, prop, index, defaultValue);
  else
    return defaultValue;
}



int CppDialog::emitSignal(GWEN_DIALOG_EVENTTYPE t, const char *sender) {
  assert(_dialog);
  return GWEN_Dialog_EmitSignal(_dialog, t, sender);
}



GWEN_WIDGET_TREE *CppDialog::getWidgets() const {
  assert(_dialog);
  return GWEN_Dialog_GetWidgets(_dialog);
}



GWEN_WIDGET *CppDialog::findWidgetByName(const char *name) {
  assert(_dialog);
  return GWEN_Dialog_FindWidgetByName(_dialog, name);
}



GWEN_WIDGET *CppDialog::findWidgetByImplData(int index, void *ptr) {
  assert(_dialog);
  return GWEN_Dialog_FindWidgetByImplData(_dialog, index, ptr);
}