ruby-iup 0.0.1-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/doc/README +10 -0
  2. data/doc/build_install.txt +77 -0
  3. data/examples/README +16 -0
  4. data/examples/ctrl/cbox.rb +221 -0
  5. data/examples/ctrl/checkboard.rb +33 -0
  6. data/examples/ctrl/degrade.rb +73 -0
  7. data/examples/ctrl/example1.rb +53 -0
  8. data/examples/ctrl/example2.rb +39 -0
  9. data/examples/ctrl/iupcolorbar.rb +95 -0
  10. data/examples/ctrl/iupcolorbrowser.rb +45 -0
  11. data/examples/ctrl/iupdial.rb +117 -0
  12. data/examples/ctrl/iupgauge.rb +242 -0
  13. data/examples/ctrl/iupgetcolor.rb +8 -0
  14. data/examples/ctrl/iupgetparam.rb +62 -0
  15. data/examples/ctrl/iupglcanvas.rb +172 -0
  16. data/examples/ctrl/iupmask.rb +15 -0
  17. data/examples/ctrl/iupmatrix.rb +39 -0
  18. data/examples/ctrl/iupplot2.rb +603 -0
  19. data/examples/ctrl/iuptabs.rb +22 -0
  20. data/examples/ctrl/iuptree.rb +190 -0
  21. data/examples/ctrl/iupval.rb +71 -0
  22. data/examples/ctrl/numbering.rb +46 -0
  23. data/examples/ctrl/sample.rb +166 -0
  24. data/examples/dlg/iupalarm.rb +14 -0
  25. data/examples/dlg/iupfiledlg.rb +19 -0
  26. data/examples/dlg/iupgetfile.rb +19 -0
  27. data/examples/dlg/iuplistdialog.rb +26 -0
  28. data/examples/dlg/iupmessage.rb +5 -0
  29. data/examples/dlg/iupscanf.rb +17 -0
  30. data/examples/elem/iupbutton.rb +197 -0
  31. data/examples/elem/iupcanvas.rb +27 -0
  32. data/examples/elem/iupcanvas2.rb +113 -0
  33. data/examples/elem/iupcanvas3.rb +62 -0
  34. data/examples/elem/iupdialog.rb +71 -0
  35. data/examples/elem/iupdialog2.rb +25 -0
  36. data/examples/elem/iupfill.rb +51 -0
  37. data/examples/elem/iupframe.rb +25 -0
  38. data/examples/elem/iuphbox.rb +68 -0
  39. data/examples/elem/iupimage.rb +113 -0
  40. data/examples/elem/iupitem.rb +60 -0
  41. data/examples/elem/iuplabel.rb +57 -0
  42. data/examples/elem/iuplist.rb +41 -0
  43. data/examples/elem/iuplist2.rb +125 -0
  44. data/examples/elem/iupmenu.rb +32 -0
  45. data/examples/elem/iupmultiline.rb +24 -0
  46. data/examples/elem/iupmultiline2.rb +156 -0
  47. data/examples/elem/iupradio.rb +32 -0
  48. data/examples/elem/iupseparator.rb +81 -0
  49. data/examples/elem/iupsubmenu.rb +85 -0
  50. data/examples/elem/iuptext.rb +61 -0
  51. data/examples/elem/iuptimer.rb +36 -0
  52. data/examples/elem/iuptoggle.rb +110 -0
  53. data/examples/elem/iupvbox.rb +87 -0
  54. data/examples/elem/iupzbox.rb +60 -0
  55. data/examples/elem/mdisample.rb +376 -0
  56. data/examples/elem/progressbar.rb +294 -0
  57. data/examples/elem/scrollbar.rb +66 -0
  58. data/examples/elem/tray.rb +90 -0
  59. data/examples/func/iupgetattribute.rb +32 -0
  60. data/examples/func/iupidle.rb +48 -0
  61. data/ext/extconf.rb +27 -0
  62. data/ext/iup-win32/cd.dll +0 -0
  63. data/ext/iup-win32/cd.lib +0 -0
  64. data/ext/iup-win32/cdcontextplus.dll +0 -0
  65. data/ext/iup-win32/cdcontextplus.lib +0 -0
  66. data/ext/iup-win32/cdlua51.lib +0 -0
  67. data/ext/iup-win32/cdluacontextplus51.lib +0 -0
  68. data/ext/iup-win32/cdluaim51.lib +0 -0
  69. data/ext/iup-win32/cdluapdf51.lib +0 -0
  70. data/ext/iup-win32/cdpdf.dll +0 -0
  71. data/ext/iup-win32/cdpdf.lib +0 -0
  72. data/ext/iup-win32/freetype6.dll +0 -0
  73. data/ext/iup-win32/freetype6.lib +0 -0
  74. data/ext/iup-win32/im.dll +0 -0
  75. data/ext/iup-win32/im_avi.dll +0 -0
  76. data/ext/iup-win32/im_capture.dll +0 -0
  77. data/ext/iup-win32/im_ecw.dll +0 -0
  78. data/ext/iup-win32/im_fftw.dll +0 -0
  79. data/ext/iup-win32/im_jp2.dll +0 -0
  80. data/ext/iup-win32/im_process.dll +0 -0
  81. data/ext/iup-win32/im_wmv.dll +0 -0
  82. data/ext/iup-win32/iup.dll +0 -0
  83. data/ext/iup-win32/iup.lib +0 -0
  84. data/ext/iup-win32/iup_pplot.dll +0 -0
  85. data/ext/iup-win32/iup_pplot.lib +0 -0
  86. data/ext/iup-win32/iupcd.dll +0 -0
  87. data/ext/iup-win32/iupcd.lib +0 -0
  88. data/ext/iup-win32/iupcontrols.dll +0 -0
  89. data/ext/iup-win32/iupcontrols.lib +0 -0
  90. data/ext/iup-win32/iupgl.dll +0 -0
  91. data/ext/iup-win32/iupgl.lib +0 -0
  92. data/ext/iup-win32/iupim.dll +0 -0
  93. data/ext/iup-win32/iupim.lib +0 -0
  94. data/ext/iup-win32/iupimglib.dll +0 -0
  95. data/ext/iup-win32/iupimglib.lib +0 -0
  96. data/ext/iup-win32/iuplua51.lib +0 -0
  97. data/ext/iup-win32/iuplua_pplot51.lib +0 -0
  98. data/ext/iup-win32/iupluacd51.lib +0 -0
  99. data/ext/iup-win32/iupluacontrols51.lib +0 -0
  100. data/ext/iup-win32/iupluagl51.lib +0 -0
  101. data/ext/iup-win32/iupluaim51.lib +0 -0
  102. data/ext/iup-win32/iupluaimglib51.lib +0 -0
  103. data/ext/iup-win32/iupluaole51.lib +0 -0
  104. data/ext/iup-win32/iupole.dll +0 -0
  105. data/ext/iup-win32/iupole.lib +0 -0
  106. data/ext/iup-win32/iupstub.lib +0 -0
  107. data/ext/iup-win32/pdflib.dll +0 -0
  108. data/ext/iup-win32/pdflib.lib +0 -0
  109. data/ext/iup.c +1261 -0
  110. data/ext/mkrf_conf.rb +72 -0
  111. data/ext/rb_cd.h +1525 -0
  112. data/ext/rb_iup.h +2446 -0
  113. data/ext/rb_iup_pplot.h +129 -0
  114. data/ext/rb_iupcb.h +13 -0
  115. data/ext/rb_iupcbox.h +40 -0
  116. data/ext/rb_iupcells.h +15 -0
  117. data/ext/rb_iupcolorbar.h +17 -0
  118. data/ext/rb_iupcompat.h +237 -0
  119. data/ext/rb_iupcontrols.h +28 -0
  120. data/ext/rb_iupdef.h +3 -0
  121. data/ext/rb_iupdial.h +24 -0
  122. data/ext/rb_iupgauge.h +15 -0
  123. data/ext/rb_iupgc.h +18 -0
  124. data/ext/rb_iupgetparam.h +72 -0
  125. data/ext/rb_iupgl.h +58 -0
  126. data/ext/rb_iupim.h +25 -0
  127. data/ext/rb_iupmask.h +189 -0
  128. data/ext/rb_iupmatrix.h +80 -0
  129. data/ext/rb_iupole.h +24 -0
  130. data/ext/rb_iupsbox.h +23 -0
  131. data/ext/rb_iupspeech.h +25 -0
  132. data/ext/rb_iupspin.h +29 -0
  133. data/ext/rb_iuptabs.h +29 -0
  134. data/ext/rb_iuptree.h +94 -0
  135. data/ext/rb_iupval.h +24 -0
  136. data/lib/README +1 -0
  137. data/lib/iup.so +0 -0
  138. metadata +187 -0
data/ext/rb_iup.h ADDED
@@ -0,0 +1,2446 @@
1
+ #include <ruby.h>
2
+ #include "iup.h"
3
+ #include "iupcontrols.h"
4
+
5
+ extern VALUE rb_eIupError;
6
+ static char IdleAction[100];
7
+ static VALUE IdleProc = Qnil;
8
+
9
+ VALUE rb_mIup;
10
+ VALUE rb_mCd;
11
+ VALUE rb_eIupError;
12
+ VALUE rb_cIupImage;
13
+ VALUE rb_cIupButton;
14
+ VALUE rb_cIupCanvas;
15
+ VALUE rb_cIupDialog;
16
+ VALUE rb_cIupFill;
17
+ VALUE rb_cIupFrame;
18
+ VALUE rb_cIupHbox;
19
+ VALUE rb_cIupItem;
20
+ VALUE rb_cIupSeparator;
21
+ VALUE rb_cIupSubmenu;
22
+ VALUE rb_cIupLabel;
23
+ VALUE rb_cIupList;
24
+ VALUE rb_cIupMenu;
25
+ VALUE rb_cIupRadio;
26
+ VALUE rb_cIupText;
27
+ VALUE rb_cIupToggle;
28
+ VALUE rb_cIupToggle;
29
+ VALUE rb_cIupVbox;
30
+ VALUE rb_cIupZbox;
31
+ VALUE rb_cIupMultiLine;
32
+ VALUE rb_cIupUser;
33
+ VALUE rb_cIupControl;
34
+ VALUE rb_cIupTimer;
35
+ VALUE rb_cIupFileDlg;
36
+ VALUE rb_cIupTree;
37
+ VALUE rb_cIupNode;
38
+ VALUE rb_cIupTabs;
39
+ VALUE rb_cIupGLCanvas;
40
+ VALUE rb_cIupSpin;
41
+ VALUE rb_cIupSpinbox;
42
+ VALUE rb_cIupSbox;
43
+ VALUE rb_cIupCbox;
44
+ VALUE rb_cIupMatrix;
45
+ VALUE rb_cIupGauge;
46
+ VALUE rb_cIupDial;
47
+ VALUE rb_cIupColorbar;
48
+ VALUE rb_cIupColorBrowser;
49
+ VALUE rb_cIupCells;
50
+ VALUE rb_cIupPPlot;
51
+ VALUE rb_cIupVal;
52
+ VALUE rb_cCdCanvas;
53
+
54
+ extern VALUE rb_IupSetCallback(VALUE node,VALUE v_name,VALUE v_func);
55
+
56
+ void exit_handler(void)
57
+ {
58
+ IupControlsClose();
59
+ IupClose();
60
+ }
61
+
62
+ char* rb_str_upper(char* s)
63
+ {
64
+ char* temp=s;
65
+ if(isupper(*temp)) return s;
66
+ for(;*temp;temp++)
67
+ *temp=toupper(*temp);
68
+ return s;
69
+ }
70
+
71
+ VALUE rb_method_missing(int argc,VALUE *argv, VALUE self)
72
+ {
73
+ static char mname[100];
74
+ static char pname[100];
75
+ int n;
76
+ char *value = NULL;
77
+ ID id = rb_to_id(argv[0]);
78
+ VALUE v_ih = rb_iv_get(self,"@ihandle");
79
+ strcpy(mname,rb_id2name(id));
80
+ rb_str_upper(mname);
81
+ if(!*mname) {
82
+ rb_raise(rb_eRuntimeError, "fail: unknown method or property");
83
+ }
84
+ n = strlen(mname);
85
+ if(mname[n-1] == '=')
86
+ mname[n-1] = 0;
87
+ if(argc==2) {
88
+ if(TYPE(argv[1])==T_OBJECT) {
89
+ VALUE v_ih_named = rb_iv_get(argv[1],"@ihandle");
90
+ IupSetAttributeHandle((Ihandle*)NUM2UINT(v_ih),mname,(Ihandle*)NUM2UINT(v_ih_named));
91
+ }
92
+ else if(TYPE(argv[1])==T_DATA) {
93
+ rb_IupSetCallback(self,rb_str_new2(mname),rb_str_new2("Proc"));
94
+ sprintf(pname,"RB_PROC_%s",mname);
95
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),pname,(char*)argv[1]);
96
+ } else {
97
+ if(strcmp(mname,"ATTR")==0) {
98
+ VALUE v_arr;
99
+ int j;
100
+ v_arr = rb_funcall(argv[1],rb_intern("split"),1,rb_reg_new("[,=]",4,0));
101
+ for(j=0;j<RARRAY(v_arr)->len;j+=2) {
102
+ rb_funcall(RARRAY(v_arr)->ptr[j],rb_intern("strip!"),0,0);
103
+ rb_funcall(RARRAY(v_arr)->ptr[j+1],rb_intern("strip!"),0,0);
104
+ strcpy(mname,RSTRING(RARRAY(v_arr)->ptr[j])->ptr);
105
+ rb_str_upper(mname);
106
+ value = RSTRING(RARRAY(v_arr)->ptr[j+1])->ptr;
107
+ if(value[0]=='"') {
108
+ value[strlen(value)-1]=0;
109
+ strcpy(pname,&value[1]);
110
+ value = pname;
111
+ }
112
+ IupStoreAttribute((Ihandle*)NUM2UINT(v_ih),mname,value);
113
+ }
114
+ }
115
+ else {
116
+ if(argv[1]!=Qnil && TYPE(argv[1])!=T_STRING) {
117
+ VALUE v_value = rb_funcall(argv[1],rb_intern("to_s"),0);
118
+ value = RSTRING(v_value)->ptr;
119
+ } else if(argv[1]!=Qnil)
120
+ value = RSTRING(argv[1])->ptr;
121
+ IupStoreAttribute((Ihandle*)NUM2UINT(v_ih),mname,value);
122
+ }
123
+ }
124
+ return Qnil;
125
+ }
126
+ else {
127
+ Ihandle *ih = IupGetAttributeHandle((Ihandle*)NUM2UINT(v_ih),mname);
128
+ if(ih) {
129
+ return (VALUE)IupGetAttribute(ih,"RB_CLASS");
130
+ }
131
+ else {
132
+ value = IupGetAttribute((Ihandle*)NUM2UINT(v_ih),mname);
133
+ if(value==NULL) return Qnil;
134
+ return rb_str_new2(value);
135
+ }
136
+ }
137
+ }
138
+
139
+ void rb_set_attribute(Ihandle *v,VALUE arg)
140
+ {
141
+ static char key[100];
142
+ static char pkey[100];
143
+ char *value;
144
+ int i;
145
+ VALUE v_value;
146
+ VALUE klass;
147
+ VALUE v_keys = rb_funcall(arg,rb_intern("keys"),0);
148
+ for(i=0;i<RARRAY(v_keys)->len;i++) {
149
+ if(TYPE(RARRAY(v_keys)->ptr[i])==T_SYMBOL) {
150
+ strcpy(key,rb_id2name(SYM2ID(RARRAY(v_keys)->ptr[i])));
151
+ rb_str_upper(key);
152
+ } else if(TYPE(RARRAY(v_keys)->ptr[i])==T_STRING) {
153
+ strcpy(key,RSTRING(RARRAY(v_keys)->ptr[i])->ptr);
154
+ rb_str_upper(key);
155
+ }
156
+ v_value = rb_hash_aref(arg,RARRAY(v_keys)->ptr[i]);
157
+ if(TYPE(v_value)==T_OBJECT) {
158
+ VALUE v_ih_named = rb_iv_get(v_value,"@ihandle");
159
+ IupSetAttributeHandle(v,key,(Ihandle*)NUM2UINT(v_ih_named));
160
+ }
161
+ else if(TYPE(v_value)==T_DATA) {
162
+ klass = (VALUE)IupGetAttribute(v,"RB_CLASS");
163
+ if(klass) {
164
+ IupSetAttribute(v,key,(char*)v_value);
165
+ rb_IupSetCallback(klass,rb_str_new2(key),rb_str_new2("Proc"));
166
+ }
167
+ } else {
168
+ if(TYPE(v_value)!=T_STRING)
169
+ v_value = rb_funcall(v_value,rb_intern("to_s"),0);
170
+ value = RSTRING(v_value)->ptr;
171
+ if(strcmp(key,"ATTR")==0) {
172
+ VALUE v_arr;
173
+ int j;
174
+ v_arr = rb_funcall(v_value,rb_intern("split"),1,rb_reg_new("[,=\\s]+",7,0));
175
+ for(j=0;j<RARRAY(v_arr)->len;j+=2) {
176
+ rb_funcall(RARRAY(v_arr)->ptr[j],rb_intern("strip!"),0,0);
177
+ rb_funcall(RARRAY(v_arr)->ptr[j+1],rb_intern("strip!"),0,0);
178
+ strcpy(key,RSTRING(RARRAY(v_arr)->ptr[j])->ptr);
179
+ rb_str_upper(key);
180
+ value = RSTRING(RARRAY(v_arr)->ptr[j+1])->ptr;
181
+ if(value[0]=='"') {
182
+ value[strlen(value)-1]=0;
183
+ strcpy(pkey,&value[1]);
184
+ value = pkey;
185
+ }
186
+ IupStoreAttribute(v,key,value);
187
+ }
188
+ }
189
+ else
190
+ IupStoreAttribute(v,key,value);
191
+ }
192
+ }
193
+ }
194
+
195
+ VALUE rb_isxkey(VALUE self,VALUE s)
196
+ {
197
+ return isxkey(NUM2INT(s))?Qtrue:Qfalse;
198
+ }
199
+
200
+ VALUE rb_isshift(VALUE self,VALUE s)
201
+ {
202
+ return isshift(RSTRING(s)->ptr)?Qtrue:Qfalse;
203
+ }
204
+
205
+ VALUE rb_iscontrol(VALUE self,VALUE s)
206
+ {
207
+ return iscontrol(RSTRING(s)->ptr)?Qtrue:Qfalse;
208
+ }
209
+
210
+ VALUE rb_isbutton1(VALUE self,VALUE s)
211
+ {
212
+ return isbutton1(RSTRING(s)->ptr)?Qtrue:Qfalse;
213
+ }
214
+
215
+ VALUE rb_isbutton2(VALUE self,VALUE s)
216
+ {
217
+ return isbutton2(RSTRING(s)->ptr)?Qtrue:Qfalse;
218
+ }
219
+
220
+ VALUE rb_isbutton3(VALUE self,VALUE s)
221
+ {
222
+ return isbutton3(RSTRING(s)->ptr)?Qtrue:Qfalse;
223
+ }
224
+
225
+ VALUE rb_isdouble(VALUE self,VALUE s)
226
+ {
227
+ return isdouble(RSTRING(s)->ptr)?Qtrue:Qfalse;
228
+ }
229
+
230
+ VALUE rb_isalt(VALUE self,VALUE s)
231
+ {
232
+ return isalt(RSTRING(s)->ptr)?Qtrue:Qfalse;
233
+ }
234
+
235
+ VALUE rb_issys(VALUE self,VALUE s)
236
+ {
237
+ return issys(RSTRING(s)->ptr)?Qtrue:Qfalse;
238
+ }
239
+
240
+ VALUE rb_isbutton4(VALUE self,VALUE s)
241
+ {
242
+ return isbutton4(RSTRING(s)->ptr)?Qtrue:Qfalse;
243
+ }
244
+
245
+ VALUE rb_isbutton5(VALUE self,VALUE s)
246
+ {
247
+ return isbutton5(RSTRING(s)->ptr)?Qtrue:Qfalse;
248
+ }
249
+
250
+ VALUE rb_IupFileDlg(int argc,VALUE *argv,VALUE self)
251
+ {
252
+ Ihandle* v;
253
+ v = IupFileDlg();
254
+ if(argc==1 && TYPE(argv[0])==T_HASH)
255
+ rb_set_attribute(v,argv[0]);
256
+ if(v)
257
+ return rb_funcall(rb_cIupFileDlg,rb_intern("new"),1,UINT2NUM((unsigned)v));
258
+ return Qnil;
259
+ }
260
+
261
+ VALUE rb_IupGetFile(VALUE self,VALUE v_arq)
262
+ {
263
+ char *arq = RSTRING(v_arq)->ptr;
264
+ char filename[256];
265
+ int v;
266
+ VALUE v_r;
267
+ strcpy(filename,arq);
268
+ v = IupGetFile(filename);
269
+ v_r = rb_ary_new3(2,rb_str_new2(filename),UINT2NUM((unsigned)v));
270
+ return v_r;
271
+ }
272
+
273
+ VALUE rb_IupNode_initialize(int argc,VALUE *argv,VALUE self)
274
+ {
275
+ VALUE v_ih,v_action;
276
+ rb_scan_args(argc,argv,"11",&v_ih,&v_action);
277
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),"RB_CLASS",(char*)self);
278
+ rb_iv_set(self,"@ihandle",v_ih);
279
+ if(TYPE(v_action)==T_DATA) {
280
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),"RB_PROC_ACTION",(char*)v_action);
281
+ rb_IupSetCallback(self,rb_str_new2("ACTION"),rb_str_new2("Proc"));
282
+ }
283
+ return self;
284
+ }
285
+
286
+ VALUE rb_IupMessage(VALUE self,VALUE v_title,VALUE v_msg)
287
+ {
288
+ const char *title = RSTRING(v_title)->ptr;
289
+ const char *msg = RSTRING(v_msg)->ptr;
290
+ IupMessage(title,msg);
291
+ return Qnil;
292
+ }
293
+
294
+ VALUE rb_IupMessagef(int argc,VALUE *argv,VALUE self)
295
+ {
296
+ VALUE v;
297
+ const char *title = RSTRING(argv[0])->ptr;
298
+ const char *msg = RSTRING(argv[1])->ptr;
299
+ if(argc==2) {
300
+ IupMessage(title,msg);
301
+ return Qnil;
302
+ }
303
+ v = rb_f_sprintf(argc-1,argv+1);
304
+ msg = RSTRING(v)->ptr;
305
+ IupMessage(title,msg);
306
+ return Qnil;
307
+ }
308
+
309
+ VALUE rb_IupAlarm(VALUE self,VALUE v_title,VALUE v_msg,VALUE v_b1,VALUE v_b2,VALUE v_b3)
310
+ {
311
+ const char *title = RSTRING(v_title)->ptr;
312
+ const char *msg = RSTRING(v_msg)->ptr;
313
+ const char *b1 = RSTRING(v_b1)->ptr;
314
+ const char *b2 = RSTRING(v_b2)->ptr;
315
+ const char *b3 = RSTRING(v_b3)->ptr;
316
+ int v;
317
+ v = IupAlarm(title,msg,b1,b2,b3);
318
+ return UINT2NUM((unsigned)v);
319
+ }
320
+
321
+ VALUE rb_IupScanf(int argc,VALUE *argv,VALUE self)
322
+ {
323
+ VALUE v_format = argv[0];
324
+ char args[5][256];
325
+ const char *format = RSTRING(v_format)->ptr;
326
+ int v;
327
+ int i;
328
+ int t_n;
329
+ float t_f;
330
+ char *t_s;
331
+ VALUE v_r = Qnil;
332
+ for(i=1;i<argc && i<=5;i++) {
333
+ switch(TYPE(argv[i])) {
334
+ case T_FIXNUM:
335
+ t_n = NUM2INT(argv[i]);
336
+ memcpy(args[i-1],&t_n,sizeof(t_n));
337
+ break;
338
+ case T_STRING:
339
+ t_s = RSTRING(argv[i])->ptr;
340
+ memcpy(args[i-1],t_s,RSTRING(argv[i])->len+1);
341
+ break;
342
+ case T_FLOAT:
343
+ t_f = RFLOAT(argv[i])->value;
344
+ memcpy(args[i-1],&t_f,sizeof(t_f));
345
+ break;
346
+ default:
347
+ rb_raise(rb_eIupError,"Invalid Type");
348
+ }
349
+ }
350
+ switch(argc) {
351
+ case 2:
352
+ v = IupScanf(format,args[0]);
353
+ break;
354
+ case 3:
355
+ v = IupScanf(format,args[0],args[1]);
356
+ break;
357
+ case 4:
358
+ v = IupScanf(format,args[0],args[1],args[2]);
359
+ break;
360
+ case 5:
361
+ v = IupScanf(format,args[0],args[1],args[2],args[3]);
362
+ break;
363
+ case 6:
364
+ v = IupScanf(format,args[0],args[1],args[2],args[3],args[4]);
365
+ break;
366
+ default:
367
+ rb_raise(rb_eIupError,"Too many arguments");
368
+ }
369
+ v_r = rb_ary_new();
370
+ for(i=1;i<argc && i<=v;i++) {
371
+ switch(TYPE(argv[i])) {
372
+ case T_FIXNUM:
373
+ case T_BIGNUM:
374
+ memcpy(&t_n,args[i-1],sizeof(t_n));
375
+ rb_ary_push(v_r,INT2NUM(t_n));
376
+ break;
377
+ case T_STRING:
378
+ rb_ary_push(v_r,rb_str_new2(args[i-1]));
379
+ break;
380
+ case T_FLOAT:
381
+ memcpy(&t_f,args[i-1],sizeof(t_f));
382
+ sprintf(args[i-1],"%g",t_f);
383
+ rb_ary_push(v_r,rb_float_new(atof(args[i-1])));
384
+ break;
385
+ default:
386
+ rb_raise(rb_eIupError,"Invalid Type");
387
+ }
388
+ }
389
+ return v_r;
390
+ }
391
+
392
+ VALUE rb_IupListDialog (VALUE self,VALUE v_type, VALUE v_title, VALUE v_size, VALUE v_lst,
393
+ VALUE v_op, VALUE v_col, VALUE v_line, VALUE v_marks)
394
+ {
395
+ int type = NUM2INT(v_type);
396
+ const char* title = RSTRING(v_title)->ptr;
397
+ int size = NUM2INT(v_size);
398
+ char *lst[256];
399
+ int op = NUM2INT(v_op);
400
+ int col = NUM2INT(v_col);
401
+ int line = NUM2INT(v_line);
402
+ int marks[256];
403
+ int v;
404
+ int i;
405
+ VALUE v_r;
406
+ for(i=0;i<size;i++) {
407
+ lst[i] = RSTRING(RARRAY(v_lst)->ptr[i])->ptr;
408
+ marks[i] = NUM2INT(RARRAY(v_marks)->ptr[i]);
409
+ }
410
+ v = IupListDialog(type,title,size,(const char**)lst,op,col,line,marks);
411
+ v_marks = rb_ary_new();
412
+ if(type==2) {
413
+ for(i=0;i<size;i++) {
414
+ rb_ary_push(v_marks,INT2FIX(marks[i]));
415
+ }
416
+ } else {
417
+ for(i=0;i<size;i++) {
418
+ if(v==i)
419
+ rb_ary_push(v_marks,INT2FIX(1));
420
+ else
421
+ rb_ary_push(v_marks,INT2FIX(0));
422
+ }
423
+ }
424
+ v_r = rb_ary_new3(2,v_marks,INT2FIX(v));
425
+ return v_r;
426
+ }
427
+
428
+ VALUE rb_IupGetText(VALUE self,VALUE v_title,VALUE v_text)
429
+ {
430
+ const char* title = RSTRING(v_title)->ptr;
431
+ char* text = RSTRING(v_text)->ptr;
432
+ int v;
433
+ v = IupGetText(title,text);
434
+ return UINT2NUM((unsigned)v);
435
+ }
436
+
437
+ VALUE rb_IupOpen(VALUE self)
438
+ {
439
+ int argc = 1;
440
+ char *name = "iupruby";
441
+ char **argv = &name;
442
+ int v;
443
+ v = IupOpen(&argc,&argv);
444
+
445
+ if(v==IUP_ERROR)
446
+ rb_raise(rb_eIupError, "Error Opening IUP.");
447
+ IupControlsOpen();
448
+ return UINT2NUM((unsigned)v);
449
+ }
450
+
451
+ VALUE rb_IupClose(VALUE self)
452
+ {
453
+ IupClose();
454
+ return Qnil;
455
+ }
456
+
457
+ VALUE rb_IupMainLoop(VALUE self)
458
+ {
459
+ int v;
460
+ v = IupMainLoop();
461
+ return UINT2NUM((unsigned)v);
462
+ }
463
+
464
+ VALUE rb_IupLoopStep(VALUE self)
465
+ {
466
+ int v;
467
+ v = IupLoopStep();
468
+ return UINT2NUM((unsigned)v);
469
+ }
470
+
471
+ VALUE rb_IupFlush(VALUE self)
472
+ {
473
+ IupFlush();
474
+ return Qnil;
475
+ }
476
+
477
+ VALUE rb_IupExitLoop(VALUE self)
478
+ {
479
+ IupExitLoop();
480
+ return Qnil;
481
+ }
482
+
483
+ VALUE rb_IupUpdate(VALUE self,VALUE node)
484
+ {
485
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
486
+ IupUpdate((Ihandle*)NUM2UINT(v_ih));
487
+ return Qnil;
488
+ }
489
+
490
+ VALUE rb_IupRefresh(VALUE self,VALUE node)
491
+ {
492
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
493
+ IupRefresh((Ihandle*)NUM2UINT(v_ih));
494
+ return Qnil;
495
+ }
496
+
497
+ VALUE rb_IupMapFont(VALUE self,VALUE v_iupfont)
498
+ {
499
+ const char *iupfont = RSTRING(v_iupfont)->ptr;
500
+ char* v;
501
+ v = IupMapFont(iupfont);
502
+ return rb_str_new2(v);
503
+ }
504
+
505
+ VALUE rb_IupUnMapFont(VALUE self,VALUE v_driverfont)
506
+ {
507
+ const char *driverfont = RSTRING(v_driverfont)->ptr;
508
+ char* v;
509
+ v = IupUnMapFont(driverfont);
510
+ return rb_str_new2(v);
511
+ }
512
+
513
+ VALUE rb_IupHelp(VALUE self,VALUE v_url)
514
+ {
515
+ const char* url = RSTRING(v_url)->ptr;
516
+ int v;
517
+ v = IupHelp(url);
518
+ return UINT2NUM((unsigned)v);
519
+ }
520
+
521
+ VALUE rb_IupVersion(VALUE self)
522
+ {
523
+ char* v;
524
+ v = IupVersion();
525
+ return rb_str_new2(v);
526
+ }
527
+
528
+ VALUE rb_IupVersionDate(VALUE self)
529
+ {
530
+ char* v;
531
+ v = IupVersionDate();
532
+ return rb_str_new2(v);
533
+ }
534
+
535
+ VALUE rb_IupVersionNumber(VALUE self)
536
+ {
537
+ int v;
538
+ v = IupVersionNumber();
539
+ return UINT2NUM((unsigned)v);
540
+ }
541
+
542
+ VALUE rb_IupSetLanguage(VALUE self,VALUE v_lng)
543
+ {
544
+ const char *lng = RSTRING(v_lng)->ptr;
545
+ IupSetLanguage(lng);
546
+ return Qnil;
547
+ }
548
+
549
+ VALUE rb_IupGetLanguage(VALUE self)
550
+ {
551
+ char* v;
552
+ v = IupGetLanguage();
553
+ return rb_str_new2(v);
554
+ }
555
+
556
+ VALUE rb_IupDestroy(VALUE node)
557
+ {
558
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
559
+ IupDestroy((Ihandle*)NUM2UINT(v_ih));
560
+ return Qnil;
561
+ }
562
+
563
+ VALUE rb_IupDetach(VALUE self,VALUE vchild)
564
+ {
565
+ VALUE v_child = rb_iv_get(vchild,"@ihandle");
566
+ IupDetach((Ihandle*)NUM2UINT(v_child));
567
+ return Qnil;
568
+ }
569
+
570
+ VALUE rb_IupAppend(VALUE self,VALUE node,VALUE vchild)
571
+ {
572
+ Ihandle* v;
573
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
574
+ VALUE v_child = rb_iv_get(vchild,"@ihandle");
575
+ v = IupAppend((Ihandle*)NUM2UINT(v_ih),(Ihandle*)NUM2UINT(v_child));
576
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
577
+ }
578
+
579
+ VALUE rb_IupGetNextChild(VALUE self,VALUE node,VALUE vchild)
580
+ {
581
+ Ihandle* child = NULL;
582
+ Ihandle* v;
583
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
584
+ VALUE v_child = rb_iv_get(vchild,"@ihandle");
585
+ if(v_child!=Qnil) child = (Ihandle*)NUM2UINT(v_child);
586
+ v = IupGetNextChild((Ihandle*)NUM2UINT(v_ih),child);
587
+ if(v==NULL) return Qnil;
588
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
589
+ }
590
+
591
+ VALUE rb_IupGetBrother(VALUE self,VALUE node)
592
+ {
593
+ Ihandle* v;
594
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
595
+ v = IupGetBrother((Ihandle*)NUM2UINT(v_ih));
596
+ if(v==NULL) return Qnil;
597
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
598
+ }
599
+
600
+ VALUE rb_IupGetParent(VALUE self,VALUE node)
601
+ {
602
+ Ihandle* v;
603
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
604
+ v = IupGetParent((Ihandle*)NUM2UINT(v_ih));
605
+ if(v==NULL) return Qnil;
606
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
607
+ }
608
+
609
+ VALUE rb_IupGetDialog(VALUE self,VALUE node)
610
+ {
611
+ Ihandle* v;
612
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
613
+ v = IupGetDialog((Ihandle*)NUM2UINT(v_ih));
614
+ if(v==NULL) return Qnil;
615
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
616
+ }
617
+
618
+ VALUE rb_IupPopup(VALUE node,VALUE v_x,VALUE v_y)
619
+ {
620
+ int x = NUM2INT(v_x);
621
+ int y = NUM2INT(v_y);
622
+ int v;
623
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
624
+ v = IupPopup((Ihandle*)NUM2UINT(v_ih),x,y);
625
+ return UINT2NUM((unsigned)v);
626
+ }
627
+
628
+ VALUE rb_IupShow(VALUE node)
629
+ {
630
+ int v;
631
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
632
+ v = IupShow((Ihandle*)NUM2UINT(v_ih));
633
+ return UINT2NUM((unsigned)v);
634
+ }
635
+
636
+ VALUE rb_IupShowXY(VALUE node,VALUE v_x,VALUE v_y)
637
+ {
638
+ int x = NUM2INT(v_x);
639
+ int y = NUM2INT(v_y);
640
+ int v;
641
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
642
+ v = IupShowXY((Ihandle*)NUM2UINT(v_ih),x,y);
643
+ return UINT2NUM((unsigned)v);
644
+ }
645
+
646
+ VALUE rb_IupHide(VALUE node)
647
+ {
648
+ int v;
649
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
650
+ v = IupHide((Ihandle*)NUM2UINT(v_ih));
651
+ return UINT2NUM((unsigned)v);
652
+ }
653
+
654
+ VALUE rb_IupMap(VALUE node)
655
+ {
656
+ int v;
657
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
658
+ v = IupMap((Ihandle*)NUM2UINT(v_ih));
659
+ return UINT2NUM((unsigned)v);
660
+ }
661
+
662
+ VALUE rb_IupSetAttribute(VALUE node,VALUE v_name,VALUE v_value)
663
+ {
664
+ static char name[100];
665
+ static char pname[100];
666
+ const char* value = NULL;
667
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
668
+ strcpy(name,RSTRING(v_name)->ptr);
669
+ rb_str_upper(name);
670
+ if(v_value!=Qnil) {
671
+ if(TYPE(v_value)==T_OBJECT) {
672
+ VALUE v_ih_named = rb_iv_get(v_value,"@ihandle");
673
+ IupSetAttributeHandle((Ihandle*)NUM2UINT(v_ih),name,(Ihandle*)NUM2UINT(v_ih_named));
674
+ }
675
+ else if(TYPE(v_value)==T_DATA) {
676
+ rb_IupSetCallback(node,rb_str_new2(name),rb_str_new2("Proc"));
677
+ sprintf(pname,"RB_PROC_%s",name);
678
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),pname,(char*)v_value);
679
+ return Qnil;
680
+ } else {
681
+ if(TYPE(v_value)!=T_STRING)
682
+ v_value = rb_funcall(v_value,rb_intern("to_s"),0);
683
+ value = RSTRING(v_value)->ptr;
684
+ }
685
+ }
686
+ IupStoreAttribute((Ihandle*)NUM2UINT(v_ih),name,value);
687
+ return Qnil;
688
+ }
689
+
690
+ VALUE rb_IupSetAttributePtr(VALUE node,VALUE v_name,VALUE v_value)
691
+ {
692
+ extern VALUE rb_IupSetCallback(VALUE node,VALUE v_name,VALUE v_func);
693
+ char name[100];
694
+ const char* value = NULL;
695
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
696
+ strcpy(name,RSTRING(v_name)->ptr);
697
+ rb_str_upper(name);
698
+ if(v_value!=Qnil) {
699
+ if(TYPE(v_value)==T_DATA) {
700
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),name,(char*)v_value);
701
+ rb_IupSetCallback(node,rb_str_new2(name),rb_str_new2("Proc"));
702
+ return Qnil;
703
+ } else {
704
+ if(TYPE(v_value)==T_FIXNUM)
705
+ value = (char*)NUM2INT(v_value);
706
+ }
707
+ }
708
+ IupSetAttribute((Ihandle*)NUM2UINT(v_ih),name,value);
709
+ return Qnil;
710
+ }
711
+
712
+ VALUE rb_IupStoreAttribute(VALUE node,VALUE v_name,VALUE v_value)
713
+ {
714
+ const char* name = RSTRING(v_name)->ptr;
715
+ const char* value = NULL;
716
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
717
+ if(v_value!=Qnil)
718
+ value = RSTRING(v_value)->ptr;
719
+ IupStoreAttribute((Ihandle*)NUM2UINT(v_ih),name,value);
720
+ return Qnil;
721
+ }
722
+
723
+ VALUE rb_IupSetAttributes(VALUE node,VALUE v_str)
724
+ {
725
+ const char *str = RSTRING(v_str)->ptr;
726
+ Ihandle* v;
727
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
728
+ v = IupSetAttributes((Ihandle*)NUM2UINT(v_ih),str);
729
+ if(v==NULL) return Qnil;
730
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
731
+ }
732
+
733
+ VALUE rb_IupGetAttribute(VALUE node,VALUE v_name)
734
+ {
735
+ char name[100];
736
+ char* v;
737
+ Ihandle *ih;
738
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
739
+ strcpy(name,RSTRING(v_name)->ptr);
740
+ rb_str_upper(name);
741
+ ih = IupGetAttributeHandle((Ihandle*)NUM2UINT(v_ih),name);
742
+ if(ih) {
743
+ return (VALUE)IupGetAttribute(ih,"RB_CLASS");
744
+ }
745
+ v = IupGetAttribute((Ihandle*)NUM2UINT(v_ih),name);
746
+ if(v==NULL)
747
+ return Qnil;
748
+ else
749
+ return rb_str_new2(v);
750
+ }
751
+
752
+ VALUE rb_IupGetAttributePtr(VALUE node,VALUE v_name)
753
+ {
754
+ char name[100];
755
+ char* v;
756
+ VALUE klass;
757
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
758
+ strcpy(name,RSTRING(v_name)->ptr);
759
+ rb_str_upper(name);
760
+ v = IupGetAttribute((Ihandle*)NUM2UINT(v_ih),name);
761
+ klass = rb_funcall(rb_cIupNode,rb_intern("new"),1,UINT2NUM((unsigned)v));
762
+ if(v==NULL)
763
+ return Qnil;
764
+ else
765
+ return klass;
766
+ }
767
+
768
+ VALUE rb_IupGetAttributes(VALUE node)
769
+ {
770
+ char* v;
771
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
772
+ v = IupGetAttributes((Ihandle*)NUM2UINT(v_ih));
773
+ return rb_str_new2(v);
774
+ }
775
+
776
+ VALUE rb_IupGetInt(VALUE node,VALUE v_name)
777
+ {
778
+ const char* name = RSTRING(v_name)->ptr;
779
+ int v;
780
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
781
+ v = IupGetInt((Ihandle*)NUM2UINT(v_ih),name);
782
+ return UINT2NUM((unsigned)v);
783
+ }
784
+
785
+ VALUE rb_IupGetFloat(VALUE node,VALUE v_name)
786
+ {
787
+ const char* name = RSTRING(v_name)->ptr;
788
+ float v;
789
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
790
+ v = IupGetFloat((Ihandle*)NUM2UINT(v_ih),name);
791
+ return rb_float_new(v);
792
+ }
793
+
794
+ VALUE rb_IupSetGlobal(VALUE self,VALUE v_name,VALUE v_value)
795
+ {
796
+ const char* name = RSTRING(v_name)->ptr;
797
+ const char* value = RSTRING(v_value)->ptr;
798
+ IupSetGlobal(name,value);
799
+ return Qnil;
800
+ }
801
+
802
+ VALUE rb_IupStoreGlobal(VALUE self,VALUE v_name,VALUE v_value)
803
+ {
804
+ const char* name = RSTRING(v_name)->ptr;
805
+ const char* value = RSTRING(v_value)->ptr;
806
+ IupStoreGlobal(name,value);
807
+ return Qnil;
808
+ }
809
+
810
+ VALUE rb_IupGetGlobal(VALUE self,VALUE v_name)
811
+ {
812
+ const char* name = RSTRING(v_name)->ptr;
813
+ char* v;
814
+ v = IupGetGlobal(name);
815
+ return rb_str_new2(v);
816
+ }
817
+
818
+ VALUE rb_IupSetFocus(VALUE self,VALUE node)
819
+ {
820
+ Ihandle* v;
821
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
822
+ v = IupSetFocus((Ihandle*)NUM2UINT(v_ih));
823
+ return UINT2NUM((unsigned)v);
824
+ }
825
+
826
+ VALUE rb_IupGetFocus(VALUE self)
827
+ {
828
+ Ihandle* v;
829
+ v = IupGetFocus();
830
+ if(v==NULL) return Qnil;
831
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
832
+ }
833
+
834
+ VALUE rb_IupPreviousField(VALUE self,VALUE node)
835
+ {
836
+ Ihandle* v;
837
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
838
+ v = IupPreviousField((Ihandle*)NUM2UINT(v_ih));
839
+ if(v==NULL) return Qnil;
840
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
841
+ }
842
+
843
+ VALUE rb_IupNextField(VALUE self,VALUE node)
844
+ {
845
+ Ihandle* v;
846
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
847
+ v = IupNextField((Ihandle*)NUM2UINT(v_ih));
848
+ if(v==NULL) return Qnil;
849
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
850
+ }
851
+
852
+ static int _canvas_action(Ihandle* ih, float posx, float posy)
853
+ {
854
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
855
+ VALUE v;
856
+ if(func) {
857
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
858
+ if(strcmp(func,"Proc")==0) {
859
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_ACTION");
860
+ v = rb_funcall(proc,rb_intern("call"),3,node,rb_float_new(posx),rb_float_new(posy));
861
+ } else {
862
+ v = rb_funcall(Qnil,rb_intern(func),3,node,rb_float_new(posx),rb_float_new(posy));
863
+ }
864
+ return NUM2INT(v);
865
+ }
866
+ return IUP_DEFAULT;
867
+ }
868
+
869
+ static int _toggle_action(Ihandle* ih, int state)
870
+ {
871
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
872
+ VALUE v;
873
+ if(func) {
874
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
875
+ if(strcmp(func,"Proc")==0) {
876
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_ACTION");
877
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(state));
878
+ } else {
879
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(state));
880
+ }
881
+ return NUM2INT(v);
882
+ }
883
+ return IUP_DEFAULT;
884
+ }
885
+
886
+ static int _button_action(Ihandle* ih)
887
+ {
888
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
889
+ VALUE v;
890
+ if(func) {
891
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
892
+ if(strcmp(func,"Proc")==0) {
893
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_ACTION");
894
+ v = rb_funcall(proc,rb_intern("call"),1,node);
895
+ } else {
896
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
897
+ }
898
+ return NUM2INT(v);
899
+ }
900
+ return IUP_DEFAULT;
901
+ }
902
+
903
+ static int _list_action(Ihandle* ih, char *text, int pos, int state)
904
+ {
905
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
906
+ VALUE v;
907
+ if(func) {
908
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
909
+ if(strcmp(func,"Proc")==0) {
910
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_ACTION");
911
+ v = rb_funcall(proc,rb_intern("call"),4,node,rb_str_new2(text),INT2FIX(pos),INT2FIX(state));
912
+ } else {
913
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,rb_str_new2(text),INT2FIX(pos),INT2FIX(state));
914
+ }
915
+ return NUM2INT(v);
916
+ }
917
+ return IUP_DEFAULT;
918
+ }
919
+
920
+ static int _idle_cb()
921
+ {
922
+ VALUE v;
923
+ if(IdleProc!=Qnil) {
924
+ v = rb_funcall(IdleProc,rb_intern("call"),0);
925
+ return NUM2INT(v);
926
+ }
927
+ else if(*IdleAction) {
928
+ v = rb_funcall(rb_cObject,rb_intern(IdleAction),0);
929
+ return NUM2INT(v);
930
+ }
931
+ return IUP_DEFAULT;
932
+ }
933
+
934
+ static int _postdraw_cb(Ihandle* ih, void* cnv)
935
+ {
936
+ char* func = (char*)IupGetAttribute(ih,"RB_POSTDRAW_CB");
937
+ VALUE v;
938
+ if(func) {
939
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
940
+ if(strcmp(func,"Proc")==0) {
941
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_POSTDRAW_CB");
942
+ v = rb_funcall(proc,rb_intern("call"),2,node,rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
943
+ } else {
944
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
945
+ }
946
+ return NUM2INT(v);
947
+ }
948
+ return IUP_DEFAULT;
949
+ }
950
+
951
+ static int _predraw_cb(Ihandle* ih, void* cnv)
952
+ {
953
+ char* func = (char*)IupGetAttribute(ih,"RB_PREDRAW_CB");
954
+ VALUE v;
955
+ if(func) {
956
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
957
+ if(strcmp(func,"Proc")==0) {
958
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_PREDRAW_CB");
959
+ v = rb_funcall(proc,rb_intern("call"),2,node,rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
960
+ } else {
961
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
962
+ }
963
+ return NUM2INT(v);
964
+ }
965
+ return IUP_DEFAULT;
966
+ }
967
+
968
+ static int _change_cb(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b)
969
+ {
970
+ char* func = (char*)IupGetAttribute(ih,"RB_CHANGE_CB");
971
+ VALUE v;
972
+ if(func) {
973
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
974
+ if(strcmp(func,"Proc")==0) {
975
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_CHANGE_CB");
976
+ v = rb_funcall(proc,rb_intern("call"),4,node,INT2FIX(r),INT2FIX(g),INT2FIX(b));
977
+ } else {
978
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,INT2FIX(r),INT2FIX(g),INT2FIX(b));
979
+ }
980
+ return NUM2INT(v);
981
+ }
982
+ return IUP_DEFAULT;
983
+ }
984
+
985
+ static int _drag_cb(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b)
986
+ {
987
+ char* func = (char*)IupGetAttribute(ih,"RB_DRAG_CB");
988
+ VALUE v;
989
+ if(func) {
990
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
991
+ if(strcmp(func,"Proc")==0) {
992
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_DRAG_CB");
993
+ v = rb_funcall(proc,rb_intern("call"),4,node,INT2FIX(r),INT2FIX(g),INT2FIX(b));
994
+ } else {
995
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,INT2FIX(r),INT2FIX(g),INT2FIX(b));
996
+ }
997
+ return NUM2INT(v);
998
+ }
999
+ return IUP_DEFAULT;
1000
+ }
1001
+
1002
+ static int _tabchange_cb(Ihandle* ih, Ihandle* newtab, Ihandle* oldtab)
1003
+ {
1004
+ char* func = (char*)IupGetAttribute(ih,"RB_TABCHANGE_CB");
1005
+ VALUE v;
1006
+ if(func) {
1007
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1008
+ VALUE node_old = (VALUE)IupGetAttribute(oldtab,"RB_CLASS");
1009
+ VALUE node_new = (VALUE)IupGetAttribute(newtab,"RB_CLASS");
1010
+ if(strcmp(func,"Proc")==0) {
1011
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_TABCHANGE_CB");
1012
+ v = rb_funcall(proc,rb_intern("call"),3,node,node_new,node_old);
1013
+ } else {
1014
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,node_new,node_old);
1015
+ }
1016
+ return NUM2INT(v);
1017
+ }
1018
+ return IUP_DEFAULT;
1019
+ }
1020
+
1021
+ static int _button_press_cb(Ihandle* ih, double angle)
1022
+ {
1023
+ char* func = (char*)IupGetAttribute(ih,"RB_BUTTON_PRESS_CB");
1024
+ VALUE v;
1025
+ if(func) {
1026
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1027
+ if(strcmp(func,"Proc")==0) {
1028
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_BUTTON_PRESS_CB");
1029
+ v = rb_funcall(proc,rb_intern("call"),2,node,rb_float_new(angle));
1030
+ } else {
1031
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,rb_float_new(angle));
1032
+ }
1033
+ return NUM2INT(v);
1034
+ }
1035
+ return IUP_DEFAULT;
1036
+ }
1037
+
1038
+ static int _button_release_cb(Ihandle* ih, double angle)
1039
+ {
1040
+ char* func = (char*)IupGetAttribute(ih,"RB_BUTTON_RELEASE_CB");
1041
+ VALUE v;
1042
+ if(func) {
1043
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1044
+ if(strcmp(func,"Proc")==0) {
1045
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_BUTTON_RELEASE_CB");
1046
+ v = rb_funcall(proc,rb_intern("call"),2,node,rb_float_new(angle));
1047
+ } else {
1048
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,rb_float_new(angle));
1049
+ }
1050
+ return NUM2INT(v);
1051
+ }
1052
+ return IUP_DEFAULT;
1053
+ }
1054
+
1055
+ static int _mousemove_cb(Ihandle* ih, double angle)
1056
+ {
1057
+ char* func = (char*)IupGetAttribute(ih,"RB_MOUSEMOVE_CB");
1058
+ VALUE v;
1059
+ if(func) {
1060
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1061
+ if(strcmp(func,"Proc")==0) {
1062
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_MOUSEMOVE_CB");
1063
+ v = rb_funcall(proc,rb_intern("call"),2,node,rb_float_new(angle));
1064
+ } else {
1065
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,rb_float_new(angle));
1066
+ }
1067
+ return NUM2INT(v);
1068
+ }
1069
+ return IUP_DEFAULT;
1070
+ }
1071
+
1072
+ static int _draw_cb(Ihandle* ih, void* cnv)
1073
+ {
1074
+ char* func = (char*)IupGetAttribute(ih,"RB_DRAW_CB");
1075
+ VALUE v;
1076
+ if(func) {
1077
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1078
+ if(strcmp(func,"Proc")==0) {
1079
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_DRAW_CB");
1080
+ v = rb_funcall(proc,rb_intern("call"),2,node,
1081
+ rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
1082
+ } else {
1083
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,
1084
+ rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
1085
+ }
1086
+ return NUM2INT(v);
1087
+ }
1088
+ return IUP_DEFAULT;
1089
+ }
1090
+
1091
+ static char* _cell_cb(Ihandle* ih, int cell)
1092
+ {
1093
+ char* func = (char*)IupGetAttribute(ih,"RB_CELL_CB");
1094
+ VALUE v;
1095
+ if(func) {
1096
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1097
+ if(strcmp(func,"Proc")==0) {
1098
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_CELL_CB");
1099
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(cell));
1100
+ } else {
1101
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(cell));
1102
+ }
1103
+ if(v==Qnil)
1104
+ return NULL;
1105
+ else
1106
+ return RSTRING(v)->ptr;
1107
+ }
1108
+ return NULL;
1109
+ }
1110
+
1111
+ static int _extended_cb(Ihandle* ih, int cell)
1112
+ {
1113
+ char* func = (char*)IupGetAttribute(ih,"RB_EXTENDED_CB");
1114
+ VALUE v;
1115
+ if(func) {
1116
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1117
+ if(strcmp(func,"Proc")==0) {
1118
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_EXTENDED_CB");
1119
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(cell));
1120
+ } else {
1121
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(cell));
1122
+ }
1123
+ return NUM2INT(v);
1124
+ }
1125
+ return IUP_DEFAULT;
1126
+ }
1127
+
1128
+ static int _colorbar_select_cb(Ihandle* ih, int cell,int type)
1129
+ {
1130
+ char* func = (char*)IupGetAttribute(ih,"RB_SELECT_CB");
1131
+ VALUE v;
1132
+ if(func) {
1133
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1134
+ if(strcmp(func,"Proc")==0) {
1135
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_SELECT_CB");
1136
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(cell),INT2FIX(type));
1137
+ } else {
1138
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(cell),INT2FIX(type));
1139
+ }
1140
+ return NUM2INT(v);
1141
+ }
1142
+ return IUP_DEFAULT;
1143
+ }
1144
+
1145
+ static int _switch_cb(Ihandle* ih, int prim_cell,int sec_cell)
1146
+ {
1147
+ char* func = (char*)IupGetAttribute(ih,"RB_SWITCH_CB");
1148
+ VALUE v;
1149
+ if(func) {
1150
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1151
+ if(strcmp(func,"Proc")==0) {
1152
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_SWITCH_CB");
1153
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(prim_cell),INT2FIX(sec_cell));
1154
+ } else {
1155
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(prim_cell),INT2FIX(sec_cell));
1156
+ }
1157
+ return NUM2INT(v);
1158
+ }
1159
+ return IUP_DEFAULT;
1160
+ }
1161
+
1162
+ static int _height_cb(Ihandle* ih, int line)
1163
+ {
1164
+ char* func = (char*)IupGetAttribute(ih,"RB_HEIGHT_CB");
1165
+ VALUE v;
1166
+ if(func) {
1167
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1168
+ if(strcmp(func,"Proc")==0) {
1169
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_HEIGHT_CB");
1170
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(line));
1171
+ } else {
1172
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(line));
1173
+ }
1174
+ return NUM2INT(v);
1175
+ }
1176
+ return IUP_DEFAULT;
1177
+ }
1178
+
1179
+ static int _width_cb(Ihandle* ih, int column)
1180
+ {
1181
+ char* func = (char*)IupGetAttribute(ih,"RB_WIDTH_CB");
1182
+ VALUE v;
1183
+ if(func) {
1184
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1185
+ if(strcmp(func,"Proc")==0) {
1186
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_WIDTH_CB");
1187
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(column));
1188
+ } else {
1189
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(column));
1190
+ }
1191
+ return NUM2INT(v);
1192
+ }
1193
+ return IUP_DEFAULT;
1194
+ }
1195
+
1196
+ static int _hspan_cb(Ihandle* ih, int line, int column)
1197
+ {
1198
+ char* func = (char*)IupGetAttribute(ih,"RB_HSPAN_CB");
1199
+ VALUE v;
1200
+ if(func) {
1201
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1202
+ if(strcmp(func,"Proc")==0) {
1203
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_HSPAN_CB");
1204
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(line),INT2FIX(column));
1205
+ } else {
1206
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(line),INT2FIX(column));
1207
+ }
1208
+ return NUM2INT(v);
1209
+ }
1210
+ return IUP_DEFAULT;
1211
+ }
1212
+
1213
+ static int _scrolling_cb(Ihandle* ih, int line, int column)
1214
+ {
1215
+ char* func = (char*)IupGetAttribute(ih,"RB_SCROLLING_CB");
1216
+ VALUE v;
1217
+ if(func) {
1218
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1219
+ if(strcmp(func,"Proc")==0) {
1220
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_SCROLLING_CB");
1221
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(line),INT2FIX(column));
1222
+ } else {
1223
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(line),INT2FIX(column));
1224
+ }
1225
+ return NUM2INT(v);
1226
+ }
1227
+ return IUP_DEFAULT;
1228
+ }
1229
+
1230
+ static int _vspan_cb(Ihandle* ih, int line, int column)
1231
+ {
1232
+ char* func = (char*)IupGetAttribute(ih,"RB_VSPAN_CB");
1233
+ VALUE v;
1234
+ if(func) {
1235
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1236
+ if(strcmp(func,"Proc")==0) {
1237
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_VSPAN_CB");
1238
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(line),INT2FIX(column));
1239
+ } else {
1240
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(line),INT2FIX(column));
1241
+ }
1242
+ return NUM2INT(v);
1243
+ }
1244
+ return IUP_DEFAULT;
1245
+ }
1246
+
1247
+ static int _ncols_cb(Ihandle* ih)
1248
+ {
1249
+ char* func = (char*)IupGetAttribute(ih,"RB_NCOLS_CB");
1250
+ VALUE v;
1251
+ if(func) {
1252
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1253
+ if(strcmp(func,"Proc")==0) {
1254
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_NCOLS_CB");
1255
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1256
+ } else {
1257
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1258
+ }
1259
+ return NUM2INT(v);
1260
+ }
1261
+ return IUP_DEFAULT;
1262
+ }
1263
+
1264
+ static int _nlines_cb(Ihandle* ih)
1265
+ {
1266
+ char* func = (char*)IupGetAttribute(ih,"RB_NLINES_CB");
1267
+ VALUE v;
1268
+ if(func) {
1269
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1270
+ if(strcmp(func,"Proc")==0) {
1271
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_NLINES_CB");
1272
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1273
+ } else {
1274
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1275
+ }
1276
+ return NUM2INT(v);
1277
+ }
1278
+ return IUP_DEFAULT;
1279
+ }
1280
+
1281
+ static int _mouseclick_cb(Ihandle* ih,int button, int pressed, int line, int column, int x, int y, char* status)
1282
+ {
1283
+ char* func = (char*)IupGetAttribute(ih,"RB_MOUSECLICK_CB");
1284
+ VALUE v;
1285
+ if(func) {
1286
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1287
+ if(strcmp(func,"Proc")==0) {
1288
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_MOUSECLICK_CB");
1289
+ v = rb_funcall(proc,rb_intern("call"),8,node,INT2FIX(button),INT2FIX(pressed),
1290
+ INT2FIX(line),INT2FIX(column),INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1291
+ } else {
1292
+ v = rb_funcall(rb_cObject,rb_intern(func),8,node,INT2FIX(button),INT2FIX(pressed),
1293
+ INT2FIX(line),INT2FIX(column),INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1294
+ }
1295
+ return NUM2INT(v);
1296
+ }
1297
+ return IUP_DEFAULT;
1298
+ }
1299
+
1300
+ static int _mousemotion_cb(Ihandle* ih,int line, int column, int x, int y, char* r)
1301
+ {
1302
+ char* func = (char*)IupGetAttribute(ih,"RB_MOUSEMOTION_CB");
1303
+ VALUE v;
1304
+ if(func) {
1305
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1306
+ if(strcmp(func,"Proc")==0) {
1307
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_MOUSEMOTION_CB");
1308
+ v = rb_funcall(proc,rb_intern("call"),8,node,
1309
+ INT2FIX(line),INT2FIX(column),INT2FIX(x),INT2FIX(y),rb_str_new2(r));
1310
+ } else {
1311
+ v = rb_funcall(rb_cObject,rb_intern(func),8,node,
1312
+ INT2FIX(line),INT2FIX(column),INT2FIX(x),INT2FIX(y),rb_str_new2(r));
1313
+ }
1314
+ return NUM2INT(v);
1315
+ }
1316
+ return IUP_DEFAULT;
1317
+ }
1318
+
1319
+ static int _motion_cb(Ihandle* ih,int x, int y, char* status)
1320
+ {
1321
+ char* func = (char*)IupGetAttribute(ih,"RB_MOTION_CB");
1322
+ VALUE v;
1323
+ if(func) {
1324
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1325
+ if(strcmp(func,"Proc")==0) {
1326
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_MOTION_CB");
1327
+ v = rb_funcall(proc,rb_intern("call"),4,node,
1328
+ INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1329
+ } else {
1330
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,
1331
+ INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1332
+ }
1333
+ return NUM2INT(v);
1334
+ }
1335
+ return IUP_DEFAULT;
1336
+ }
1337
+
1338
+ static int _cell_draw_cb(Ihandle* ih,int line, int column, int xmin, int xmax, int ymin, int ymax, void* cnv)
1339
+ {
1340
+ char* func = (char*)IupGetAttribute(ih,"RB_DRAW_CB");
1341
+ VALUE v;
1342
+ if(func) {
1343
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1344
+ if(strcmp(func,"Proc")==0) {
1345
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_DRAW_CB");
1346
+ v = rb_funcall(proc,rb_intern("call"),8,node,
1347
+ INT2FIX(line),INT2FIX(column),INT2FIX(xmin),INT2FIX(xmax),INT2FIX(ymin),INT2FIX(ymax),
1348
+ rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
1349
+ } else {
1350
+ v = rb_funcall(rb_cObject,rb_intern(func),8,node,
1351
+ INT2FIX(line),INT2FIX(column),INT2FIX(xmin),INT2FIX(xmax),INT2FIX(ymin),INT2FIX(ymax),rb_funcall(rb_cCdCanvas,rb_intern("new"),1,INT2FIX(cnv)));
1352
+ }
1353
+ return NUM2INT(v);
1354
+ }
1355
+ return IUP_DEFAULT;
1356
+ }
1357
+
1358
+ static int _delete_cb(Ihandle* ih, int index, int sample_index, float x, float y)
1359
+ {
1360
+ char* func = (char*)IupGetAttribute(ih,"RB_DELETE_CB");
1361
+ VALUE v;
1362
+ if(func) {
1363
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1364
+ if(strcmp(func,"Proc")==0) {
1365
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_DELETE_CB");
1366
+ v = rb_funcall(proc,rb_intern("call"),5,node,INT2FIX(index),
1367
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y));
1368
+ } else {
1369
+ v = rb_funcall(rb_cObject,rb_intern(func),5,node,INT2FIX(index),
1370
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y));
1371
+ }
1372
+ return NUM2INT(v);
1373
+ }
1374
+ return IUP_DEFAULT;
1375
+ }
1376
+
1377
+ static int _select_cb(Ihandle* ih, int index, int sample_index, float x, float y, int select)
1378
+ {
1379
+ char* func = (char*)IupGetAttribute(ih,"RB_SELECT_CB");
1380
+ VALUE v;
1381
+ if(func) {
1382
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1383
+ if(strcmp(func,"Proc")==0) {
1384
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_SELECT_CB");
1385
+ v = rb_funcall(proc,rb_intern("call"),6,node,INT2FIX(index),
1386
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y),INT2FIX(select));
1387
+ } else {
1388
+ v = rb_funcall(rb_cObject,rb_intern(func),6,node,INT2FIX(index),
1389
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y),INT2FIX(select));
1390
+ }
1391
+ return NUM2INT(v);
1392
+ }
1393
+ return IUP_DEFAULT;
1394
+ }
1395
+
1396
+ static int _edit_cb(Ihandle* ih, int index, int sample_index, float x, float y, float* new_x, float* new_y)
1397
+ {
1398
+ char* func = (char*)IupGetAttribute(ih,"RB_EDIT_CB");
1399
+ VALUE v;
1400
+ if(func) {
1401
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1402
+ if(strcmp(func,"Proc")==0) {
1403
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_EDIT_CB");
1404
+ v = rb_funcall(proc,rb_intern("call"),7,node,INT2FIX(index),
1405
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y),rb_float_new(*new_x),rb_float_new(*new_y));
1406
+ } else {
1407
+ v = rb_funcall(rb_cObject,rb_intern(func),7,node,INT2FIX(index),
1408
+ INT2FIX(sample_index),rb_float_new(x),rb_float_new(y),rb_float_new(*new_x),rb_float_new(*new_y));
1409
+ }
1410
+ return NUM2INT(v);
1411
+ }
1412
+ return IUP_DEFAULT;
1413
+ }
1414
+
1415
+ static int _list_edit_cb(Ihandle *ih, int c, char *new_value)
1416
+ {
1417
+ char* func = (char*)IupGetAttribute(ih,"RB_EDIT_CB");
1418
+ VALUE v;
1419
+ if(func) {
1420
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1421
+ if(strcmp(func,"Proc")==0) {
1422
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_EDIT_CB");
1423
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(c),rb_str_new2(new_value));
1424
+ } else {
1425
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(c),rb_str_new2(new_value));
1426
+ }
1427
+ return NUM2INT(v);
1428
+ }
1429
+ return IUP_DEFAULT;
1430
+ }
1431
+
1432
+ static int _text_action(Ihandle *ih, int c, char *new_value)
1433
+ {
1434
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
1435
+ VALUE v;
1436
+ if(func) {
1437
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1438
+ if(strcmp(func,"Proc")==0) {
1439
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_ACTION");
1440
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(c),rb_str_new2(new_value));
1441
+ } else {
1442
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(c),rb_str_new2(new_value));
1443
+ }
1444
+ return NUM2INT(v);
1445
+ }
1446
+ return IUP_DEFAULT;
1447
+ }
1448
+
1449
+ static int _button_cb(Ihandle* ih, int button, int pressed, int x, int y, char* status)
1450
+ {
1451
+ char* func = (char*)IupGetAttribute(ih,"RB_BUTTON_CB");
1452
+ VALUE v;
1453
+ if(func) {
1454
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1455
+ if(strcmp(func,"Proc")==0) {
1456
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_BUTTON_CB");
1457
+ v = rb_funcall(proc,rb_intern("call"),6,node,INT2FIX(button),INT2FIX(pressed),
1458
+ INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1459
+ } else {
1460
+ v = rb_funcall(rb_cObject,rb_intern(func),6,node,INT2FIX(button),INT2FIX(pressed),
1461
+ INT2FIX(x),INT2FIX(y),rb_str_new2(status));
1462
+ }
1463
+ return NUM2INT(v);
1464
+ }
1465
+ return IUP_DEFAULT;
1466
+ }
1467
+
1468
+ static int _executeleaf_cb(Ihandle* ih, int id)
1469
+ {
1470
+ char* func = (char*)IupGetAttribute(ih,"RB_EXECUTELEAF_CB");
1471
+ VALUE v;
1472
+ if(func) {
1473
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1474
+ if(strcmp(func,"Proc")==0) {
1475
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_EXECUTELEAF_CB");
1476
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(id));
1477
+ } else {
1478
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(id));
1479
+ }
1480
+ return NUM2INT(v);
1481
+ }
1482
+ return IUP_DEFAULT;
1483
+ }
1484
+
1485
+ static int _branchopen_cb(Ihandle* ih, int id)
1486
+ {
1487
+ char* func = (char*)IupGetAttribute(ih,"RB_BRANCHOPEN_CB");
1488
+ VALUE v;
1489
+ if(func) {
1490
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1491
+ if(strcmp(func,"Proc")==0) {
1492
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_BRANCHOPEN_CB");
1493
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(id));
1494
+ } else {
1495
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(id));
1496
+ }
1497
+ return NUM2INT(v);
1498
+ }
1499
+ return IUP_DEFAULT;
1500
+ }
1501
+
1502
+ static int _branchclose_cb(Ihandle* ih, int id)
1503
+ {
1504
+ char* func = (char*)IupGetAttribute(ih,"RB_BRANCHCLOSE_CB");
1505
+ VALUE v;
1506
+ if(func) {
1507
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1508
+ if(strcmp(func,"Proc")==0) {
1509
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_BRANCHCLOSE_CB");
1510
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(id));
1511
+ } else {
1512
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(id));
1513
+ }
1514
+ return NUM2INT(v);
1515
+ }
1516
+ return IUP_DEFAULT;
1517
+ }
1518
+
1519
+ static int _rightclick_cb(Ihandle* ih, int id)
1520
+ {
1521
+ char* func = (char*)IupGetAttribute(ih,"RB_RIGHTCLICK_CB");
1522
+ VALUE v;
1523
+ if(func) {
1524
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1525
+ if(strcmp(func,"Proc")==0) {
1526
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_RIGHTCLICK_CB");
1527
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(id));
1528
+ } else {
1529
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(id));
1530
+ }
1531
+ return NUM2INT(v);
1532
+ }
1533
+ return IUP_DEFAULT;
1534
+ }
1535
+
1536
+ static int _k_any_cb(Ihandle* ih, int c)
1537
+ {
1538
+ extern char *iupKeyEncode(int c);
1539
+ char* func = NULL;
1540
+ VALUE v;
1541
+ static char key[100];
1542
+ static char pkey[100];
1543
+ sprintf(key,"RB_%s",(char*)iupKeyEncode(c));
1544
+ func = (char*)IupGetAttribute(ih,key);
1545
+ if(func==NULL) {
1546
+ func = (char*)IupGetAttribute(ih,"RB_K_ANY");
1547
+ strcpy(key,"RB_K_ANY");
1548
+ }
1549
+ if(func) {
1550
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1551
+ if(strcmp(func,"Proc")==0) {
1552
+ VALUE proc;
1553
+ sprintf(pkey,"RB_PROC_%s",&key[3]);
1554
+ proc = (VALUE)IupGetAttribute(ih,pkey);
1555
+ v = rb_funcall(proc,rb_intern("call"),2,node,INT2FIX(c));
1556
+ } else {
1557
+ v = rb_funcall(rb_cObject,rb_intern(func),2,node,INT2FIX(c));
1558
+ }
1559
+ return NUM2INT(v);
1560
+ }
1561
+ return IUP_DEFAULT;
1562
+ }
1563
+
1564
+ static int _renamenode_cb(Ihandle* ih, int id, char *name)
1565
+ {
1566
+ char* func = (char*)IupGetAttribute(ih,"RB_RENAMENODE_CB");
1567
+ VALUE v;
1568
+ if(func) {
1569
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1570
+ if(strcmp(func,"Proc")==0) {
1571
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_RENAMENODE_CB");
1572
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(id),rb_str_new2(name));
1573
+ } else {
1574
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(id),rb_str_new2(name));
1575
+ }
1576
+ return NUM2INT(v);
1577
+ }
1578
+ return IUP_DEFAULT;
1579
+ }
1580
+
1581
+ static int _rename_cb(Ihandle* ih, int id, char *name)
1582
+ {
1583
+ char* func = (char*)IupGetAttribute(ih,"RB_RENAME_CB");
1584
+ VALUE v;
1585
+ if(func) {
1586
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1587
+ if(strcmp(func,"Proc")==0) {
1588
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_RENAME_CB");
1589
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(id),rb_str_new2(name));
1590
+ } else {
1591
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(id),rb_str_new2(name));
1592
+ }
1593
+ return NUM2INT(v);
1594
+ }
1595
+ return IUP_DEFAULT;
1596
+ }
1597
+
1598
+ static int _dragdrop_cb(Ihandle *ih, int drag_id, int drop_id, int isshift, int iscontrol)
1599
+ {
1600
+ char* func = (char*)IupGetAttribute(ih,"RB_DRAGDROP_CB");
1601
+ VALUE v;
1602
+ if(func) {
1603
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1604
+ if(strcmp(func,"Proc")==0) {
1605
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_DRAGDROP_CB");
1606
+ v = rb_funcall(proc,rb_intern("call"),5,node,
1607
+ INT2FIX(drag_id),INT2FIX(drop_id),INT2FIX(isshift),INT2FIX(iscontrol));
1608
+ } else {
1609
+ v = rb_funcall(rb_cObject,rb_intern(func),5,node,
1610
+ INT2FIX(drag_id),INT2FIX(drop_id),INT2FIX(isshift),INT2FIX(iscontrol));
1611
+ }
1612
+ return NUM2INT(v);
1613
+ }
1614
+ return IUP_DEFAULT;
1615
+ }
1616
+
1617
+ static int _action_cb(Ihandle* ih)
1618
+ {
1619
+ char *key = "RB_PROC_ACTION";
1620
+ char* func = (char*)IupGetAttribute(ih,"RB_ACTION");
1621
+ VALUE v;
1622
+ if(func==NULL) {
1623
+ func = (char*)IupGetAttribute(ih,"RB_ACTION_CB");
1624
+ key = "RB_PROC_ACTION_CB";
1625
+ }
1626
+ if(func) {
1627
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1628
+ if(strcmp(func,"Proc")==0) {
1629
+ VALUE proc = (VALUE)IupGetAttribute(ih,key);
1630
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1631
+ } else {
1632
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1633
+ }
1634
+ return NUM2INT(v);
1635
+ }
1636
+ return IUP_DEFAULT;
1637
+ }
1638
+
1639
+ static int _mdiactivate_cb(Ihandle* ih)
1640
+ {
1641
+ char* func = (char*)IupGetAttribute(ih,"RB_MDIACTIVATE_CB");
1642
+ VALUE v;
1643
+ if(func) {
1644
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1645
+ if(strcmp(func,"Proc")==0) {
1646
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_MDIACTIVATE_CB");
1647
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1648
+ } else {
1649
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1650
+ }
1651
+ return NUM2INT(v);
1652
+ }
1653
+ return IUP_DEFAULT;
1654
+ }
1655
+
1656
+ static int _getfocus_cb(Ihandle* ih)
1657
+ {
1658
+ char* func = (char*)IupGetAttribute(ih,"RB_GETFOCUS_CB");
1659
+ VALUE v;
1660
+ if(func) {
1661
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1662
+ if(strcmp(func,"Proc")==0) {
1663
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_GETFOCUS_CB");
1664
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1665
+ } else {
1666
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1667
+ }
1668
+ return NUM2INT(v);
1669
+ }
1670
+ return IUP_DEFAULT;
1671
+ }
1672
+
1673
+ static int _killfocus_cb(Ihandle* ih)
1674
+ {
1675
+ char* func = (char*)IupGetAttribute(ih,"RB_KILLFOCUS_CB");
1676
+ VALUE v;
1677
+ if(func) {
1678
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1679
+ if(strcmp(func,"Proc")==0) {
1680
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_KILLFOCUS_CB");
1681
+ v = rb_funcall(proc,rb_intern("call"),1,node);
1682
+ } else {
1683
+ v = rb_funcall(rb_cObject,rb_intern(func),1,node);
1684
+ }
1685
+ return NUM2INT(v);
1686
+ }
1687
+ return IUP_DEFAULT;
1688
+ }
1689
+
1690
+ static int _trayclick_cb(Ihandle* ih, int b, int press, int dclick)
1691
+ {
1692
+ char* func = (char*)IupGetAttribute(ih,"RB_TRAYCLICK_CB");
1693
+ VALUE v;
1694
+ if(func) {
1695
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1696
+ if(strcmp(func,"Proc")==0) {
1697
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_TRAYCLICK_CB");
1698
+ v = rb_funcall(proc,rb_intern("call"),4,node,INT2FIX(b),rb_float_new(press),rb_float_new(dclick));
1699
+ } else {
1700
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,INT2FIX(b),rb_float_new(press),rb_float_new(dclick));
1701
+ }
1702
+ return NUM2INT(v);
1703
+ }
1704
+ return IUP_DEFAULT;
1705
+ }
1706
+
1707
+ static int _scroll_cb(Ihandle* ih, int op, float posx, float posy)
1708
+ {
1709
+ char* func = (char*)IupGetAttribute(ih,"RB_SCROLL_CB");
1710
+ VALUE v;
1711
+ if(func) {
1712
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1713
+ if(strcmp(func,"Proc")==0) {
1714
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_SCROLL_CB");
1715
+ v = rb_funcall(proc,rb_intern("call"),4,node,INT2FIX(op),rb_float_new(posx),rb_float_new(posy));
1716
+ } else {
1717
+ v = rb_funcall(rb_cObject,rb_intern(func),4,node,INT2FIX(op),rb_float_new(posx),rb_float_new(posy));
1718
+ }
1719
+ return NUM2INT(v);
1720
+ }
1721
+ return IUP_DEFAULT;
1722
+ }
1723
+
1724
+ static int _resize_cb(Ihandle* ih, int width, int height)
1725
+ {
1726
+ char* func = (char*)IupGetAttribute(ih,"RB_RESIZE_CB");
1727
+ VALUE v;
1728
+ if(func) {
1729
+ VALUE node = (VALUE)IupGetAttribute(ih,"RB_CLASS");
1730
+ if(strcmp(func,"Proc")==0) {
1731
+ VALUE proc = (VALUE)IupGetAttribute(ih,"RB_PROC_RESIZE_CB");
1732
+ v = rb_funcall(proc,rb_intern("call"),3,node,INT2FIX(width),INT2FIX(height));
1733
+ } else {
1734
+ v = rb_funcall(rb_cObject,rb_intern(func),3,node,INT2FIX(width),INT2FIX(height));
1735
+ }
1736
+ return NUM2INT(v);
1737
+ }
1738
+ return IUP_DEFAULT;
1739
+ }
1740
+
1741
+ VALUE rb_IupGetCallback(VALUE node,VALUE v_name)
1742
+ {
1743
+ const char *name = RSTRING(v_name)->ptr;
1744
+ Icallback v;
1745
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
1746
+ v = IupGetCallback((Ihandle*)NUM2UINT(v_ih),name);
1747
+ return UINT2NUM((unsigned)v);
1748
+ }
1749
+
1750
+ VALUE rb_IupSetCallback(VALUE node,VALUE v_name,VALUE v_func)
1751
+ {
1752
+ const char *name = RSTRING(v_name)->ptr;
1753
+ const char *func = NULL;
1754
+ char cb_name[100] = "RB_";
1755
+ VALUE klass = Qnil;
1756
+ Icallback v = (Icallback)NULL;
1757
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
1758
+ if(v_func!=Qnil) func = RSTRING(v_func)->ptr;
1759
+ strcat(cb_name,name);
1760
+ IupStoreAttribute((Ihandle*)NUM2UINT(v_ih),cb_name,func);
1761
+ klass = rb_funcall(node,rb_intern("class"),0,0);
1762
+ if(strcmp(name,"DRAW_CB")==0)
1763
+ if(klass==rb_cIupCells)
1764
+ v = (Icallback)_cell_draw_cb;
1765
+ else
1766
+ v = (Icallback)_draw_cb;
1767
+ else if(strcmp(name,"HEIGHT_CB")==0)
1768
+ v = (Icallback)_height_cb;
1769
+ else if(strcmp(name,"HSPAN_CB")==0)
1770
+ v = (Icallback)_hspan_cb;
1771
+ else if(strcmp(name,"MOUSECLICK_CB")==0)
1772
+ v = (Icallback)_mouseclick_cb;
1773
+ else if(strcmp(name,"MOUSEMOTION_CB")==0)
1774
+ v = (Icallback)_mousemotion_cb;
1775
+ else if(strcmp(name,"MOTION_CB")==0)
1776
+ v = (Icallback)_motion_cb;
1777
+ else if(strcmp(name,"NCOLS_CB")==0)
1778
+ v = (Icallback)_ncols_cb;
1779
+ else if(strcmp(name,"NLINES_CB")==0)
1780
+ v = (Icallback)_nlines_cb;
1781
+ else if(strcmp(name,"SCROLLING_CB")==0)
1782
+ v = (Icallback)_scrolling_cb;
1783
+ else if(strcmp(name,"VSPAN_CB")==0)
1784
+ v = (Icallback)_vspan_cb;
1785
+ else if(strcmp(name,"WIDTH_CB")==0)
1786
+ v = (Icallback)_width_cb;
1787
+ else if(strcmp(name,"DELETE_CB")==0)
1788
+ v = (Icallback)_delete_cb;
1789
+ else if(strcmp(name,"SELECT_CB")==0) {
1790
+ if(klass==rb_cIupColorbar)
1791
+ v = (Icallback)_colorbar_select_cb;
1792
+ else
1793
+ v = (Icallback)_select_cb;
1794
+ }
1795
+ else if(strcmp(name,"EDIT_CB")==0) {
1796
+ if(klass==rb_cIupList)
1797
+ v = (Icallback)_list_edit_cb;
1798
+ else
1799
+ v = (Icallback)_edit_cb;
1800
+ }
1801
+ else if(strcmp(name,"BUTTON_CB")==0)
1802
+ v = (Icallback)_button_cb;
1803
+ else if(strcmp(name,"BUTTON_PRESS_CB")==0)
1804
+ v = (Icallback)_button_press_cb;
1805
+ else if(strcmp(name,"BUTTON_RELEASE_CB")==0)
1806
+ v = (Icallback)_button_release_cb;
1807
+ else if(strcmp(name,"MOUSEMOVE_CB")==0)
1808
+ v = (Icallback)_mousemove_cb;
1809
+ else if(strcmp(name,"SCROLL_CB")==0)
1810
+ v = (Icallback)_scroll_cb;
1811
+ else if(strcmp(name,"RESIZE_CB")==0)
1812
+ v = (Icallback)_resize_cb;
1813
+ else if(strcmp(name,"ACTION")==0) {
1814
+ if(rb_class_inherited_p(klass,rb_cIupCanvas)==Qtrue)
1815
+ v = (Icallback)_canvas_action;
1816
+ else if(klass==rb_cIupToggle)
1817
+ v = (Icallback)_toggle_action;
1818
+ else if(klass==rb_cIupButton)
1819
+ v = (Icallback)_button_action;
1820
+ else if(klass==rb_cIupText||klass==rb_cIupMultiLine)
1821
+ v = (Icallback)_text_action;
1822
+ else if(klass==rb_cIupList)
1823
+ v = (Icallback)_list_action;
1824
+ else
1825
+ v = (Icallback)_action_cb;
1826
+ }
1827
+ else if(strcmp(name,"ACTION_CB")==0)
1828
+ v = (Icallback)_action_cb;
1829
+ else if(strcmp(name,"MDIACTIVATE_CB")==0)
1830
+ v = (Icallback)_mdiactivate_cb;
1831
+ else if(strcmp(name,"GETFOCUS_CB")==0)
1832
+ v = (Icallback)_getfocus_cb;
1833
+ else if(strcmp(name,"KILLFOCUS_CB")==0)
1834
+ v = (Icallback)_killfocus_cb;
1835
+ else if(strcmp(name,"TRAYCLICK_CB")==0)
1836
+ v = (Icallback)_trayclick_cb;
1837
+ else if(strcmp(name,"DRAG_CB")==0)
1838
+ v = (Icallback)_drag_cb;
1839
+ else if(strcmp(name,"CHANGE_CB")==0)
1840
+ v = (Icallback)_change_cb;
1841
+ else if(strcmp(name,"TABCHANGE_CB")==0)
1842
+ v = (Icallback)_tabchange_cb;
1843
+ else if(strcmp(name,"POSTDRAW_CB")==0)
1844
+ v = (Icallback)_postdraw_cb;
1845
+ else if(strcmp(name,"PREDRAW_CB")==0)
1846
+ v = (Icallback)_predraw_cb;
1847
+ else if(strcmp(name,"CELL_CB")==0)
1848
+ v = (Icallback)_cell_cb;
1849
+ else if(strcmp(name,"EXTENDED_CB")==0)
1850
+ v = (Icallback)_extended_cb;
1851
+ else if(strcmp(name,"SWITCH_CB")==0)
1852
+ v = (Icallback)_switch_cb;
1853
+ else if(strcmp(name,"EXECUTELEAF_CB")==0)
1854
+ v = (Icallback)_executeleaf_cb;
1855
+ else if(strcmp(name,"RENAMENODE_CB")==0)
1856
+ v = (Icallback)_renamenode_cb;
1857
+ else if(strcmp(name,"RENAME_CB")==0)
1858
+ v = (Icallback)_rename_cb;
1859
+ else if(strcmp(name,"BRANCHCLOSE_CB")==0)
1860
+ v = (Icallback)_branchclose_cb;
1861
+ else if(strcmp(name,"BRANCHOPEN_CB")==0)
1862
+ v = (Icallback)_branchopen_cb;
1863
+ else if(strcmp(name,"DRAGDROP_CB")==0)
1864
+ v = (Icallback)_dragdrop_cb;
1865
+ else if(strcmp(name,"RIGHTCLICK_CB")==0)
1866
+ v = (Icallback)_rightclick_cb;
1867
+ else if(strcmp(name,"K_ANY")==0)
1868
+ v = (Icallback)_k_any_cb;
1869
+ else if(strncmp(name,"K_",2)==0)
1870
+ v = (Icallback)_k_any_cb;
1871
+ v = IupSetCallback((Ihandle*)NUM2UINT(v_ih),name,v);
1872
+ return UINT2NUM((unsigned)v);
1873
+ }
1874
+
1875
+ VALUE rb_IupGetIdle(VALUE self)
1876
+ {
1877
+ Icallback v;
1878
+ v = IupGetFunction("IDLE_ACTION");
1879
+ if(v)
1880
+ return UINT2NUM((unsigned)v);
1881
+ return Qnil;
1882
+ }
1883
+
1884
+ VALUE rb_IupGetFunction(VALUE self,VALUE v_name)
1885
+ {
1886
+ const char *name = RSTRING(v_name)->ptr;
1887
+ Icallback v;
1888
+ v = IupGetFunction(name);
1889
+ return UINT2NUM((unsigned)v);
1890
+ }
1891
+
1892
+ VALUE rb_IupSetIdle(VALUE self,VALUE v_func)
1893
+ {
1894
+ Icallback func = NULL;
1895
+ Icallback v;
1896
+ if(v_func==Qnil) {
1897
+ *IdleAction=0;
1898
+ IdleProc = Qnil;
1899
+ }
1900
+ else if(TYPE(v_func)==T_DATA) {
1901
+ IdleProc = v_func;
1902
+ func = (Icallback)_idle_cb;
1903
+ }
1904
+ else if(TYPE(v_func)==T_STRING) {
1905
+ strcpy(IdleAction,RSTRING(v_func)->ptr);
1906
+ func = (Icallback)_idle_cb;
1907
+ }
1908
+ v = IupSetFunction("IDLE_ACTION",func);
1909
+ return UINT2NUM((unsigned)v);
1910
+ }
1911
+
1912
+ VALUE rb_IupSetFunction(VALUE self,VALUE v_name,VALUE v_func)
1913
+ {
1914
+ const char *name = RSTRING(v_name)->ptr;
1915
+ Icallback func = NULL;
1916
+ Icallback v;
1917
+ if(strcmp(name,"IDLE_ACTION")==0) {
1918
+ if(v_func==Qnil) {
1919
+ *IdleAction=0;
1920
+ IdleProc = Qnil;
1921
+ }
1922
+ else if(TYPE(v_func)==T_DATA) {
1923
+ IdleProc = v_func;
1924
+ func = (Icallback)_idle_cb;
1925
+ }
1926
+ else if(TYPE(v_func)==T_STRING) {
1927
+ strcpy(IdleAction,RSTRING(v_func)->ptr);
1928
+ func = (Icallback)_idle_cb;
1929
+ }
1930
+ } else {
1931
+ func = (Icallback)_action_cb;
1932
+ }
1933
+ v = IupSetFunction(name,func);
1934
+ return UINT2NUM((unsigned)v);
1935
+ }
1936
+
1937
+ VALUE rb_IupGetActionName(VALUE self)
1938
+ {
1939
+ const char* v;
1940
+ v = IupGetActionName();
1941
+ return rb_str_new2(v);
1942
+ }
1943
+
1944
+ VALUE rb_IupGetHandle(VALUE self,VALUE v_name)
1945
+ {
1946
+ const char *name = RSTRING(v_name)->ptr;
1947
+ Ihandle* v;
1948
+ v = IupGetHandle(name);
1949
+ if(v==NULL) return Qnil;
1950
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
1951
+ }
1952
+
1953
+ VALUE rb_IupSetHandle(VALUE self,VALUE v_name,VALUE node)
1954
+ {
1955
+ const char *name = RSTRING(v_name)->ptr;
1956
+ Ihandle* v;
1957
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
1958
+ v = IupSetHandle(name,(Ihandle*)NUM2UINT(v_ih));
1959
+ if(v==NULL) return Qnil;
1960
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
1961
+ }
1962
+
1963
+ VALUE rb_IupGetAllNames(VALUE self,VALUE v_n)
1964
+ {
1965
+ int n = NUM2INT(v_n);
1966
+ int i;
1967
+ VALUE v_r;
1968
+ int v;
1969
+ char **names = xmalloc(n*(sizeof(char*)));
1970
+ v_r = rb_ary_new();
1971
+ v = IupGetAllNames(names,n);
1972
+ for(i=0;i<n && i<v;i++)
1973
+ rb_ary_push(v_r,rb_str_new2(names[i]));
1974
+ free(names);
1975
+ return v_r;
1976
+ }
1977
+
1978
+ VALUE rb_IupGetAllDialogs(VALUE self,VALUE v_n)
1979
+ {
1980
+ int n = NUM2INT(v_n);
1981
+ int i;
1982
+ VALUE v_r;
1983
+ int v;
1984
+ char **names = xmalloc(n*(sizeof(char*)));
1985
+ v_r = rb_ary_new();
1986
+ v = IupGetAllDialogs(names,n);
1987
+ for(i=0;i<n && i<v;i++)
1988
+ rb_ary_push(v_r,rb_str_new2(names[i]));
1989
+ free(names);
1990
+ return v_r;
1991
+ }
1992
+
1993
+ VALUE rb_IupGetName(VALUE self,VALUE node)
1994
+ {
1995
+ char* v;
1996
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
1997
+ v = IupGetName((Ihandle*)NUM2UINT(v_ih));
1998
+ return rb_str_new2(v);
1999
+ }
2000
+
2001
+ VALUE rb_IupSetAttributeHandle(VALUE node,VALUE v_name,VALUE v_node_named)
2002
+ {
2003
+ const char* name = RSTRING(v_name)->ptr;
2004
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
2005
+ VALUE v_ih_named = rb_iv_get(v_node_named,"@ihandle");
2006
+ IupSetAttributeHandle((Ihandle*)NUM2UINT(v_ih),name,(Ihandle*)NUM2UINT(v_ih_named));
2007
+ return Qnil;
2008
+ }
2009
+
2010
+ VALUE rb_IupGetAttributeHandle(VALUE node,VALUE v_name)
2011
+ {
2012
+ const char* name = RSTRING(v_name)->ptr;
2013
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
2014
+ Ihandle* v;
2015
+ v = IupGetAttributeHandle((Ihandle*)NUM2UINT(v_ih),name);
2016
+ if(v==NULL) return Qnil;
2017
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
2018
+ }
2019
+
2020
+ VALUE rb_IupGetClassName(VALUE node)
2021
+ {
2022
+ char* v;
2023
+ VALUE v_ih = rb_iv_get(node,"@ihandle");
2024
+ v = IupGetClassName((Ihandle*)NUM2UINT(v_ih));
2025
+ return rb_str_new2(v);
2026
+ }
2027
+ /*
2028
+ VALUE rb_IupCreate(VALUE self,VALUE v_name)
2029
+ {
2030
+ const char *name = RSTRING(v_name)->ptr;
2031
+ Ihandle* v;
2032
+ v = IupCreate(name);
2033
+ if(v==NULL) return Qnil;
2034
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
2035
+ }
2036
+
2037
+ VALUE rb_IupCreatev(int argc,VALUE *argv,VALUE self)
2038
+ {
2039
+ const char *name = RSTRING(argv[0])->ptr;
2040
+ Ihandle* v;
2041
+ int i;
2042
+ void **params = (void**)xmalloc(sizeof(void*)*(argc));
2043
+ for(i=0;i<argc-1;i++)
2044
+ params[i] = (void*)NUM2INT(argv[i+1]);
2045
+ params[i] = NULL;
2046
+ v = IupCreatev(name,params);
2047
+ free(params);
2048
+ if(v==NULL) return Qnil;
2049
+ return (VALUE)IupGetAttribute(v,"RB_CLASS");
2050
+ }
2051
+ */
2052
+ VALUE rb_IupFill(int argc,VALUE *argv,VALUE self)
2053
+ {
2054
+ Ihandle* v;
2055
+ v = IupFill();
2056
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2057
+ rb_set_attribute(v,argv[0]);
2058
+ if(v)
2059
+ return rb_funcall(rb_cIupFill,rb_intern("new"),1,UINT2NUM((unsigned)v));
2060
+ return Qnil;
2061
+ }
2062
+
2063
+ VALUE rb_IupRadio(int argc,VALUE *argv,VALUE self)
2064
+ {
2065
+ Ihandle* v;
2066
+ VALUE child_node,v_hash;
2067
+ VALUE v_child;
2068
+ rb_scan_args(argc,argv,"11",&child_node,&v_hash);
2069
+ v_child = rb_iv_get(child_node,"@ihandle");
2070
+ v = IupRadio((Ihandle*)NUM2UINT(v_child));
2071
+ if(TYPE(v_hash)==T_HASH)
2072
+ rb_set_attribute(v,v_hash);
2073
+ if(v)
2074
+ return rb_funcall(rb_cIupRadio,rb_intern("new"),1,UINT2NUM((unsigned)v));
2075
+ return Qnil;
2076
+ }
2077
+
2078
+ VALUE rb_IupVboxv(int argc,VALUE *argv,VALUE self)
2079
+ {
2080
+ Ihandle* v;
2081
+ int i;
2082
+ Ihandle *children[100];
2083
+ VALUE node;
2084
+ VALUE v_children,v_hash;
2085
+ rb_scan_args(argc,argv,"11",&v_children,&v_hash);
2086
+ for(i=0;i<RARRAY(v_children)->len;i++) {
2087
+ node = RARRAY(v_children)->ptr[i];
2088
+ children[i] = (Ihandle*)NUM2UINT(rb_iv_get(node,"@ihandle"));
2089
+ }
2090
+ children[i] = NULL;
2091
+
2092
+ v = IupVboxv(children);
2093
+ if(TYPE(v_hash)==T_HASH)
2094
+ rb_set_attribute(v,v_hash);
2095
+ if(v)
2096
+ return rb_funcall(rb_cIupVbox,rb_intern("new"),1,UINT2NUM((unsigned)v));
2097
+ return Qnil;
2098
+ }
2099
+
2100
+ VALUE rb_IupZboxv(int argc,VALUE *argv,VALUE self)
2101
+ {
2102
+ Ihandle* v;
2103
+ int i;
2104
+ Ihandle *children[100];
2105
+ VALUE node;
2106
+ VALUE v_children,v_hash;
2107
+ rb_scan_args(argc,argv,"11",&v_children,&v_hash);
2108
+ for(i=0;i<RARRAY(v_children)->len;i++) {
2109
+ node = RARRAY(v_children)->ptr[i];
2110
+ children[i] = (Ihandle*)NUM2UINT(rb_iv_get(node,"@ihandle"));
2111
+ }
2112
+ children[i] = NULL;
2113
+ v = IupZboxv(children);
2114
+ if(TYPE(v_hash)==T_HASH)
2115
+ rb_set_attribute(v,v_hash);
2116
+ if(v)
2117
+ return rb_funcall(rb_cIupZbox,rb_intern("new"),1,UINT2NUM((unsigned)v));
2118
+ return Qnil;
2119
+ }
2120
+
2121
+ VALUE rb_IupHboxv(int argc,VALUE *argv,VALUE self)
2122
+ {
2123
+ Ihandle* v;
2124
+ int i;
2125
+ Ihandle *children[100];
2126
+ VALUE node;
2127
+ VALUE v_children,v_hash;
2128
+ rb_scan_args(argc,argv,"11",&v_children,&v_hash);
2129
+ for(i=0;i<RARRAY(v_children)->len;i++) {
2130
+ node = RARRAY(v_children)->ptr[i];
2131
+ children[i] = (Ihandle*)NUM2UINT(rb_iv_get(node,"@ihandle"));
2132
+ }
2133
+ children[i] = NULL;
2134
+ v = IupHboxv(children);
2135
+ if(TYPE(v_hash)==T_HASH)
2136
+ rb_set_attribute(v,v_hash);
2137
+ if(v)
2138
+ return rb_funcall(rb_cIupHbox,rb_intern("new"),1,UINT2NUM((unsigned)v));
2139
+ return Qnil;
2140
+ }
2141
+
2142
+ VALUE rb_IupFrame(int argc,VALUE *argv,VALUE self)
2143
+ {
2144
+ Ihandle* v;
2145
+ VALUE child_node,v_hash,v_child;
2146
+ rb_scan_args(argc,argv,"11",&child_node,&v_hash);
2147
+ v_child = rb_iv_get(child_node,"@ihandle");
2148
+ v = IupFrame((Ihandle*)NUM2UINT(v_child));
2149
+ if(TYPE(v_hash)==T_HASH)
2150
+ rb_set_attribute(v,v_hash);
2151
+ if(v)
2152
+ return rb_funcall(rb_cIupFrame,rb_intern("new"),1,UINT2NUM((unsigned)v));
2153
+ return Qnil;
2154
+ }
2155
+
2156
+ VALUE rb_IupImage(int argc,VALUE *argv,VALUE self)
2157
+ {
2158
+ int width;
2159
+ int height;
2160
+ int i;
2161
+ Ihandle* v;
2162
+ VALUE v_width;
2163
+ VALUE v_height;
2164
+ VALUE v_pixmap;
2165
+ unsigned char *pixmap = NULL;
2166
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2167
+ v_width = rb_hash_delete(argv[0],ID2SYM(rb_intern("width")));
2168
+ v_height = rb_hash_delete(argv[0],ID2SYM(rb_intern("height")));
2169
+ v_pixmap = rb_hash_delete(argv[0],ID2SYM(rb_intern("pixmap")));
2170
+ } else {
2171
+ rb_scan_args(argc,argv,"30",&v_width,&v_height,&v_pixmap);
2172
+ }
2173
+ if(v_width==Qnil||v_height==Qnil||v_pixmap==Qnil) {
2174
+ rb_raise(rb_eIupError,"Invalid Argument");
2175
+ }
2176
+ width = NUM2INT(v_width);
2177
+ height = NUM2INT(v_height);
2178
+ pixmap = xmalloc(RARRAY(v_pixmap)->len);
2179
+ for(i=0;i<RARRAY(v_pixmap)->len;i++)
2180
+ pixmap[i] = NUM2INT(RARRAY(v_pixmap)->ptr[i]);
2181
+ v = IupImage(width,height,pixmap);
2182
+ free(pixmap);
2183
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2184
+ rb_set_attribute(v,argv[0]);
2185
+ if(v)
2186
+ return rb_funcall(rb_cIupImage,rb_intern("new"),1,UINT2NUM((unsigned)v));
2187
+ return Qnil;
2188
+ }
2189
+
2190
+ VALUE rb_IupButton(int argc,VALUE *argv,VALUE self)
2191
+ {
2192
+ const char* title = NULL;
2193
+ const char* action = NULL;
2194
+ Ihandle* v;
2195
+ VALUE v_title,v_action;
2196
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2197
+ v_title = rb_hash_delete(argv[0],ID2SYM(rb_intern("title")));
2198
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2199
+ } else {
2200
+ rb_scan_args(argc,argv,"11",&v_title,&v_action);
2201
+ }
2202
+ if(v_title!=Qnil)
2203
+ title = RSTRING(v_title)->ptr;
2204
+ if(v_action!=Qnil)
2205
+ action = RSTRING(v_action)->ptr;
2206
+ v = IupButton(title,action);
2207
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2208
+ rb_set_attribute(v,argv[0]);
2209
+ if(v)
2210
+ return rb_funcall(rb_cIupButton,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2211
+ return Qnil;
2212
+ }
2213
+
2214
+ VALUE rb_IupCanvas(int argc,VALUE *argv,VALUE self)
2215
+ {
2216
+ const char* action = NULL;
2217
+ Ihandle* v;
2218
+ VALUE v_action;
2219
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2220
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2221
+ } else {
2222
+ rb_scan_args(argc,argv,"01",&v_action);
2223
+ }
2224
+ if(v_action!=Qnil)
2225
+ action = RSTRING(v_action)->ptr;
2226
+ v = IupCanvas(action);
2227
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2228
+ rb_set_attribute(v,argv[0]);
2229
+ if(v)
2230
+ return rb_funcall(rb_cIupCanvas,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2231
+ return Qnil;
2232
+ }
2233
+
2234
+ VALUE rb_IupDialog(int argc,VALUE *argv,VALUE self)
2235
+ {
2236
+ Ihandle* v;
2237
+ VALUE child_node,v_hash;
2238
+ VALUE v_child;
2239
+ rb_scan_args(argc,argv,"11",&child_node,&v_hash);
2240
+ v_child = rb_iv_get(child_node,"@ihandle");
2241
+ v = IupDialog((Ihandle*)NUM2UINT(v_child));
2242
+ if(TYPE(v_hash)==T_HASH)
2243
+ rb_set_attribute(v,v_hash);
2244
+ if(v)
2245
+ return rb_funcall(rb_cIupDialog,rb_intern("new"),1,UINT2NUM((unsigned)v));
2246
+ return Qnil;
2247
+ }
2248
+
2249
+ VALUE rb_IupUser(VALUE self)
2250
+ {
2251
+ Ihandle* v;
2252
+ v = IupUser();
2253
+ if(v)
2254
+ return rb_funcall(rb_cIupUser,rb_intern("new"),1,UINT2NUM((unsigned)v));
2255
+ return Qnil;
2256
+ }
2257
+
2258
+ VALUE rb_IupItem(int argc,VALUE *argv,VALUE self)
2259
+ {
2260
+ const char* title = NULL;
2261
+ const char* action = NULL;
2262
+ Ihandle* v;
2263
+ VALUE v_title,v_action;
2264
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2265
+ v_title = rb_hash_delete(argv[0],ID2SYM(rb_intern("title")));
2266
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2267
+ } else {
2268
+ rb_scan_args(argc,argv,"11",&v_title,&v_action);
2269
+ }
2270
+ if(v_title!=Qnil)
2271
+ title = RSTRING(v_title)->ptr;
2272
+ if(v_action!=Qnil)
2273
+ action = RSTRING(v_action)->ptr;
2274
+ v = IupItem(title,action);
2275
+ if(action)
2276
+ IupStoreAttribute(v,"RB_ACTION",action);
2277
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2278
+ rb_set_attribute(v,argv[0]);
2279
+ if(v)
2280
+ return rb_funcall(rb_cIupItem,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2281
+ return Qnil;
2282
+ }
2283
+
2284
+ VALUE rb_IupSubmenu(int argc,VALUE *argv,VALUE self)
2285
+ {
2286
+ const char* title = NULL;
2287
+ Ihandle* v;
2288
+ VALUE v_title,child_node;
2289
+ VALUE v_child;
2290
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2291
+ v_title = rb_hash_delete(argv[0],ID2SYM(rb_intern("title")));
2292
+ child_node = rb_hash_delete(argv[0],ID2SYM(rb_intern("menu")));
2293
+ } else {
2294
+ rb_scan_args(argc,argv,"20",&v_title,&child_node);
2295
+ }
2296
+ if(v_title!=Qnil)
2297
+ title = RSTRING(v_title)->ptr;
2298
+ v_child = rb_iv_get(child_node,"@ihandle");
2299
+ v = IupSubmenu(title,(Ihandle*)NUM2UINT(v_child));
2300
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2301
+ rb_set_attribute(v,argv[0]);
2302
+ if(v)
2303
+ return rb_funcall(rb_cIupSubmenu,rb_intern("new"),1,UINT2NUM((unsigned)v));
2304
+ return Qnil;
2305
+ }
2306
+
2307
+ VALUE rb_IupSeparator(VALUE self)
2308
+ {
2309
+ Ihandle* v;
2310
+ v = IupSeparator();
2311
+ if(v)
2312
+ return rb_funcall(rb_cIupSeparator,rb_intern("new"),1,UINT2NUM((unsigned)v));
2313
+ return Qnil;
2314
+ }
2315
+
2316
+ VALUE rb_IupLabel(int argc,VALUE *argv,VALUE self)
2317
+ {
2318
+ const char* title = NULL;
2319
+ Ihandle* v;
2320
+ VALUE v_title;
2321
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2322
+ v_title = rb_hash_delete(argv[0],ID2SYM(rb_intern("title")));
2323
+ } else {
2324
+ rb_scan_args(argc,argv,"10",&v_title);
2325
+ }
2326
+ title = RSTRING(v_title)->ptr;
2327
+ v = IupLabel(title);
2328
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2329
+ rb_set_attribute(v,argv[0]);
2330
+ if(v)
2331
+ return rb_funcall(rb_cIupLabel,rb_intern("new"),1,UINT2NUM((unsigned)v));
2332
+ return Qnil;
2333
+ }
2334
+
2335
+ VALUE rb_IupList(int argc,VALUE *argv,VALUE self)
2336
+ {
2337
+ const char* action = NULL;
2338
+ Ihandle* v;
2339
+ VALUE v_action;
2340
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2341
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2342
+ } else {
2343
+ rb_scan_args(argc,argv,"01",&v_action);
2344
+ }
2345
+ if(v_action!=Qnil)
2346
+ action = RSTRING(v_action)->ptr;
2347
+ v = IupList(action);
2348
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2349
+ rb_set_attribute(v,argv[0]);
2350
+ if(v)
2351
+ return rb_funcall(rb_cIupList,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2352
+ return Qnil;
2353
+ }
2354
+
2355
+ VALUE rb_IupMenuv(VALUE self,VALUE v_children)
2356
+ {
2357
+ Ihandle* v;
2358
+ int i;
2359
+ Ihandle *children[100];
2360
+ VALUE node;
2361
+ for(i=0;i<RARRAY(v_children)->len;i++) {
2362
+ node = RARRAY(v_children)->ptr[i];
2363
+ children[i] = (Ihandle*)NUM2UINT(rb_iv_get(node,"@ihandle"));
2364
+ }
2365
+ children[i] = NULL;
2366
+ v = IupMenuv(children);
2367
+ if(v)
2368
+ return rb_funcall(rb_cIupMenu,rb_intern("new"),1,UINT2NUM((unsigned)v));
2369
+ return Qnil;
2370
+ }
2371
+
2372
+ VALUE rb_IupText(int argc,VALUE *argv,VALUE self)
2373
+ {
2374
+ const char* action = NULL;
2375
+ Ihandle* v;
2376
+ VALUE v_action;
2377
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2378
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2379
+ } else {
2380
+ rb_scan_args(argc,argv,"01",&v_action);
2381
+ }
2382
+ if(v_action!=Qnil)
2383
+ action = RSTRING(v_action)->ptr;
2384
+ v = IupText(action);
2385
+ if(action)
2386
+ IupStoreAttribute(v,"RB_ACTION",action);
2387
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2388
+ rb_set_attribute(v,argv[0]);
2389
+ if(v)
2390
+ return rb_funcall(rb_cIupText,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2391
+ return Qnil;
2392
+ }
2393
+
2394
+ VALUE rb_IupMultiLine(int argc,VALUE *argv,VALUE self)
2395
+ {
2396
+ const char* action = NULL;
2397
+ Ihandle* v;
2398
+ VALUE v_action;
2399
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2400
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2401
+ } else {
2402
+ rb_scan_args(argc,argv,"01",&v_action);
2403
+ }
2404
+ if(v_action!=Qnil)
2405
+ action = RSTRING(v_action)->ptr;
2406
+ v = IupMultiLine(action);
2407
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2408
+ rb_set_attribute(v,argv[0]);
2409
+ if(v)
2410
+ return rb_funcall(rb_cIupMultiLine,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2411
+ return Qnil;
2412
+ }
2413
+
2414
+ VALUE rb_IupToggle(int argc,VALUE *argv,VALUE self)
2415
+ {
2416
+ const char* title = NULL;
2417
+ const char* action = NULL;
2418
+ Ihandle* v;
2419
+ VALUE v_title,v_action;
2420
+ if(argc==1 && TYPE(argv[0])==T_HASH) {
2421
+ v_title = rb_hash_delete(argv[0],ID2SYM(rb_intern("title")));
2422
+ v_action = rb_hash_delete(argv[0],ID2SYM(rb_intern("action")));
2423
+ } else {
2424
+ rb_scan_args(argc,argv,"02",&v_title,&v_action);
2425
+ }
2426
+ if(v_title!=Qnil)
2427
+ title = RSTRING(v_title)->ptr;
2428
+ if(v_action!=Qnil)
2429
+ action = RSTRING(v_action)->ptr;
2430
+ v = IupToggle(title,action);
2431
+ if(argc==1 && TYPE(argv[0])==T_HASH)
2432
+ rb_set_attribute(v,argv[0]);
2433
+ if(v)
2434
+ return rb_funcall(rb_cIupToggle,rb_intern("new"),2,UINT2NUM((unsigned)v),v_action);
2435
+ return Qnil;
2436
+ }
2437
+
2438
+ VALUE rb_IupTimer(VALUE self)
2439
+ {
2440
+ Ihandle* v;
2441
+ v = IupTimer();
2442
+ if(v)
2443
+ return rb_funcall(rb_cIupTimer,rb_intern("new"),1,UINT2NUM((unsigned)v));
2444
+ return Qnil;
2445
+ }
2446
+