wxruby3 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,777 @@
1
+ // Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ //
3
+ // This software is released under the MIT license.
4
+
5
+ /*
6
+ * WxRuby3 WxRubyComboPopup class
7
+ */
8
+
9
+ #ifndef _WXRUBY_COMBO_POPUP_H
10
+ #define _WXRUBY_COMBO_POPUP_H
11
+
12
+ #include <wx/combo.h>
13
+ #include <map>
14
+
15
+ class WxRubyComboPopup : public wxComboPopup
16
+ {
17
+ private:
18
+ static WxRuby_ID init_ID;
19
+ static WxRuby_ID lazy_create_ID;
20
+ static WxRuby_ID create_ID;
21
+ static WxRuby_ID destroy_popup_ID;
22
+ static WxRuby_ID find_item_ID;
23
+ static WxRuby_ID get_adjusted_size_ID;
24
+ static WxRuby_ID get_control_ID;
25
+ static WxRuby_ID set_string_value_ID;
26
+ static WxRuby_ID get_string_value_ID;
27
+ static WxRuby_ID on_combo_double_click_ID;
28
+ static WxRuby_ID on_combo_key_event_ID;
29
+ static WxRuby_ID on_combo_char_event_ID;
30
+ static WxRuby_ID on_dismiss_ID;
31
+ static WxRuby_ID on_popup_ID;
32
+ static WxRuby_ID paint_combo_control_ID;
33
+
34
+ static std::map<WxRubyComboPopup*, VALUE> combo_popup_map;
35
+
36
+ VALUE rb_combo_popup_;
37
+
38
+ class Exception : public Swig::DirectorException
39
+ {
40
+ public:
41
+ Exception(VALUE error, const char *hdr, const char *msg ="")
42
+ : Swig::DirectorException(error, hdr, msg)
43
+ {}
44
+ };
45
+
46
+ public:
47
+ static void GC_mark_combo_popups()
48
+ {
49
+ for (auto pair : combo_popup_map)
50
+ {
51
+ rb_gc_mark(pair.second);
52
+ }
53
+ }
54
+
55
+ WxRubyComboPopup(VALUE rb_cp)
56
+ : wxComboPopup()
57
+ , rb_combo_popup_(rb_cp)
58
+ {
59
+ combo_popup_map[this] = rb_cp; // register
60
+ }
61
+
62
+ virtual ~WxRubyComboPopup()
63
+ {
64
+ if (!NIL_P(rb_combo_popup_))
65
+ {
66
+ combo_popup_map.erase(this); //deregister
67
+ // unlink
68
+ rb_iv_set(rb_combo_popup_, "@_wx_combo_popup_proxy", Qnil);
69
+ rb_combo_popup_ = Qnil;
70
+ }
71
+ }
72
+
73
+ VALUE GetRubyComboPopup() const
74
+ {
75
+ return rb_combo_popup_;
76
+ }
77
+
78
+ virtual void Init() override
79
+ {
80
+ wxRuby_Funcall(rb_combo_popup_, init_ID(), 0);
81
+ }
82
+
83
+ virtual bool LazyCreate() override
84
+ {
85
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, lazy_create_ID(), 0);
86
+ return rc == Qtrue ? true : false;
87
+ }
88
+
89
+ virtual bool Create(wxWindow* parent) override
90
+ {
91
+ VALUE rb_parent = wxRuby_WrapWxObjectInRuby(parent);
92
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, create_ID(), 1, rb_parent);
93
+ return rc == Qtrue ? true : false;
94
+ }
95
+
96
+ virtual void DestroyPopup() override
97
+ {
98
+ wxRuby_Funcall(rb_combo_popup_, destroy_popup_ID(), 0);
99
+ delete this;
100
+ }
101
+
102
+ virtual bool FindItem(const wxString& item, wxString* trueItem=nullptr) override
103
+ {
104
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, find_item_ID(), 2, WXSTR_TO_RSTR(item), trueItem ? Qtrue : Qfalse);
105
+ if (TYPE(rc) == T_STRING && trueItem)
106
+ {
107
+ *trueItem = RSTR_TO_WXSTR(rc);
108
+ return true;
109
+ }
110
+ return (rc == Qfalse || NIL_P(rc)) ? false : true;
111
+ }
112
+
113
+ virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight) override
114
+ {
115
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, get_adjusted_size_ID(),
116
+ 3, INT2NUM(minWidth), INT2NUM(prefHeight), INT2NUM(maxHeight));
117
+ if (TYPE(rc) == T_DATA)
118
+ {
119
+ void* ptr;
120
+ SWIG_ConvertPtr(rc, &ptr, SWIGTYPE_p_wxSize, 0);
121
+ return *reinterpret_cast<wxSize * >(ptr);
122
+ }
123
+ else if (TYPE(rc) == T_ARRAY && RARRAY_LEN(rc) == 2)
124
+ {
125
+ return wxSize(NUM2INT(rb_ary_entry(rc, 0)), NUM2INT(rb_ary_entry(rc, 1)));
126
+ }
127
+ else
128
+ {
129
+ throw Exception(rb_eTypeError, "Return type error: ",
130
+ "expected Wx::Size or Array(Integer,Integer) from #get_adjusted_size");
131
+ }
132
+ }
133
+
134
+ virtual wxWindow *GetControl() override
135
+ {
136
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, get_control_ID(), 0);
137
+ void *ptr;
138
+ int res = SWIG_ConvertPtr(rc, &ptr, SWIGTYPE_p_wxWindow, 0);
139
+ if (!SWIG_IsOK(res))
140
+ {
141
+ throw Exception(rb_eTypeError, "Return type error: ",
142
+ "expected Wx::Window from #get_control");
143
+ }
144
+ return reinterpret_cast<wxWindow*>(ptr);
145
+ }
146
+
147
+ virtual void SetStringValue(const wxString& value) override
148
+ {
149
+ wxRuby_Funcall(rb_combo_popup_, set_string_value_ID(), 1, WXSTR_TO_RSTR(value));
150
+ }
151
+
152
+ virtual wxString GetStringValue() const override
153
+ {
154
+ VALUE rc = wxRuby_Funcall(rb_combo_popup_, get_string_value_ID(), 0);
155
+ return RSTR_TO_WXSTR(rc);
156
+ }
157
+
158
+ virtual void OnComboKeyEvent(wxKeyEvent& event) override
159
+ {
160
+ #if __WXRB_DEBUG__
161
+ wxRuby_Funcall(rb_combo_popup_, on_combo_key_event_ID(), 1, wxRuby_WrapWxEventInRuby(nullptr, &event));
162
+ #else
163
+ wxRuby_Funcall(rb_combo_popup_, on_combo_key_event_ID(), 1, wxRuby_WrapWxEventInRuby(&event));
164
+ #endif
165
+ }
166
+
167
+ virtual void OnComboCharEvent(wxKeyEvent& event) override
168
+ {
169
+ #if __WXRB_DEBUG__
170
+ wxRuby_Funcall(rb_combo_popup_, on_combo_char_event_ID(), 1, wxRuby_WrapWxEventInRuby(nullptr, &event));
171
+ #else
172
+ wxRuby_Funcall(rb_combo_popup_, on_combo_char_event_ID(), 1, wxRuby_WrapWxEventInRuby(&event));
173
+ #endif
174
+ }
175
+
176
+ virtual void OnComboDoubleClick() override
177
+ {
178
+ wxRuby_Funcall(rb_combo_popup_, on_combo_double_click_ID(), 0);
179
+ }
180
+
181
+ virtual void OnPopup() override
182
+ {
183
+ wxRuby_Funcall(rb_combo_popup_, on_popup_ID(), 0);
184
+ }
185
+
186
+ virtual void OnDismiss() override
187
+ {
188
+ wxRuby_Funcall(rb_combo_popup_, on_dismiss_ID(), 0);
189
+ }
190
+
191
+ virtual void PaintComboControl(wxDC& dc, const wxRect& rect) override
192
+ {
193
+ wxRuby_Funcall(rb_combo_popup_, paint_combo_control_ID(), 2,
194
+ SWIG_NewPointerObj(SWIG_as_voidptr(&dc), SWIGTYPE_p_wxDC, 0),
195
+ SWIG_NewPointerObj(new wxRect(rect), SWIGTYPE_p_wxRect, SWIG_POINTER_OWN));
196
+ }
197
+
198
+ };
199
+
200
+ WxRuby_ID WxRubyComboPopup::init_ID("init");
201
+ WxRuby_ID WxRubyComboPopup::lazy_create_ID("lazy_create");
202
+ WxRuby_ID WxRubyComboPopup::create_ID("create");
203
+ WxRuby_ID WxRubyComboPopup::destroy_popup_ID("destroy_popup");
204
+ WxRuby_ID WxRubyComboPopup::find_item_ID("find_item");
205
+ WxRuby_ID WxRubyComboPopup::get_adjusted_size_ID("get_adjusted_size");
206
+ WxRuby_ID WxRubyComboPopup::get_control_ID("get_control");
207
+ WxRuby_ID WxRubyComboPopup::set_string_value_ID("set_string_value");
208
+ WxRuby_ID WxRubyComboPopup::get_string_value_ID("get_string_value");
209
+ WxRuby_ID WxRubyComboPopup::on_combo_double_click_ID("on_combo_double_click");
210
+ WxRuby_ID WxRubyComboPopup::on_combo_key_event_ID("on_combo_key_event");
211
+ WxRuby_ID WxRubyComboPopup::on_combo_char_event_ID("on_combo_char_event");
212
+ WxRuby_ID WxRubyComboPopup::on_dismiss_ID("on_dismiss");
213
+ WxRuby_ID WxRubyComboPopup::on_popup_ID("on_popup");
214
+ WxRuby_ID WxRubyComboPopup::paint_combo_control_ID("paint_combo_control");
215
+
216
+ std::map<WxRubyComboPopup*, VALUE> WxRubyComboPopup::combo_popup_map;
217
+
218
+ // Wrapper methods for module Wx::ComboPopup
219
+
220
+ static VALUE wx_combo_popup_get_combo_ctrl(int argc, VALUE *argv, VALUE self)
221
+ {
222
+ if (argc < 0 || argc > 0)
223
+ {
224
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
225
+ }
226
+
227
+ VALUE rb_cp_proxy = rb_iv_get(self, "@_wx_combo_popup_proxy");
228
+ if (!NIL_P(rb_cp_proxy))
229
+ {
230
+ wxComboPopup* cpp = nullptr;
231
+ Data_Get_Struct(rb_cp_proxy, wxComboPopup, cpp);
232
+ if (cpp)
233
+ {
234
+ try {
235
+ wxComboCtrl* combo = cpp->GetComboCtrl();
236
+ return wxRuby_WrapWxObjectInRuby(combo);
237
+ }
238
+ catch (const Swig::DirectorException& swigex) {
239
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
240
+ {
241
+ rb_exc_raise(swigex.getError());
242
+ }
243
+ else
244
+ {
245
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
246
+ }
247
+ }
248
+ catch (const std::exception& ex) {
249
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
250
+ }
251
+ catch (...) {
252
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
253
+ }
254
+ }
255
+ }
256
+ return Qnil;
257
+ }
258
+
259
+ // Wrapper methods for class Wx::ComboPopupWx
260
+
261
+ static VALUE combo_popup_wx_get_combo_ctrl(int argc, VALUE *argv, VALUE self)
262
+ {
263
+ wxComboPopup *cpp;
264
+ Data_Get_Struct(self, wxComboPopup, cpp);
265
+
266
+ if (argc < 0 || argc > 0)
267
+ {
268
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
269
+ }
270
+
271
+ try {
272
+ wxComboCtrl* combo = cpp->GetComboCtrl();
273
+ return wxRuby_WrapWxObjectInRuby(combo);
274
+ }
275
+ catch (const Swig::DirectorException& swigex) {
276
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
277
+ {
278
+ rb_exc_raise(swigex.getError());
279
+ }
280
+ else
281
+ {
282
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
283
+ }
284
+ }
285
+ catch (const std::exception& ex) {
286
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
287
+ }
288
+ catch (...) {
289
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
290
+ }
291
+ }
292
+
293
+ static VALUE combo_popup_wx_lazy_create(int argc, VALUE *argv, VALUE self)
294
+ {
295
+ wxComboPopup *cpp;
296
+ Data_Get_Struct(self, wxComboPopup, cpp);
297
+
298
+ if (argc < 0 || argc > 0)
299
+ {
300
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
301
+ }
302
+
303
+ try {
304
+ return cpp->LazyCreate() ? Qtrue : Qfalse;
305
+ }
306
+ catch (const Swig::DirectorException& swigex) {
307
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
308
+ {
309
+ rb_exc_raise(swigex.getError());
310
+ }
311
+ else
312
+ {
313
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
314
+ }
315
+ }
316
+ catch (const std::exception& ex) {
317
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
318
+ }
319
+ catch (...) {
320
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
321
+ }
322
+ }
323
+
324
+ static VALUE combo_popup_wx_create(int argc, VALUE *argv, VALUE self)
325
+ {
326
+ wxComboPopup *cpp;
327
+ Data_Get_Struct(self, wxComboPopup, cpp);
328
+
329
+ if (argc < 1 || argc > 1)
330
+ {
331
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
332
+ }
333
+
334
+ void *ptr;
335
+ int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_wxWindow, 0);
336
+ if (!SWIG_IsOK(res)) {
337
+ rb_raise(rb_eArgError, "Expected Wx::Window for 1");
338
+ return Qnil;
339
+ }
340
+ wxWindow *parent = reinterpret_cast< wxWindow * >(ptr);
341
+ if (!parent)
342
+ {
343
+ rb_raise(rb_eArgError,
344
+ "Window parent argument must not be nil");
345
+ }
346
+
347
+ try {
348
+ return cpp->Create(parent) ? Qtrue : Qfalse;
349
+ }
350
+ catch (const Swig::DirectorException& swigex) {
351
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
352
+ {
353
+ rb_exc_raise(swigex.getError());
354
+ }
355
+ else
356
+ {
357
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
358
+ }
359
+ }
360
+ catch (const std::exception& ex) {
361
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
362
+ }
363
+ catch (...) {
364
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
365
+ }
366
+ }
367
+
368
+ static VALUE combo_popup_wx_find_item(int argc, VALUE *argv, VALUE self)
369
+ {
370
+ wxComboPopup *cpp;
371
+ Data_Get_Struct(self, wxComboPopup, cpp);
372
+
373
+ if (argc < 1 || argc > 2)
374
+ {
375
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 2)", argc);
376
+ }
377
+
378
+ wxString item = RSTR_TO_WXSTR(argv[0]);
379
+ bool f_trueItem = (argc<2 || (argv[1] == Qfalse || argv[1] == Qnil)) ? false : true;
380
+ wxString trueItem;
381
+ try {
382
+ bool rc = cpp->FindItem(item, f_trueItem ? &trueItem : nullptr);
383
+ return rc ? (f_trueItem ? WXSTR_TO_RSTR(trueItem) : Qtrue) : Qfalse;
384
+ }
385
+ catch (const Swig::DirectorException& swigex) {
386
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
387
+ {
388
+ rb_exc_raise(swigex.getError());
389
+ }
390
+ else
391
+ {
392
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
393
+ }
394
+ }
395
+ catch (const std::exception& ex) {
396
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
397
+ }
398
+ catch (...) {
399
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
400
+ }
401
+ }
402
+
403
+ static VALUE combo_popup_wx_get_adjusted_size(int argc, VALUE *argv, VALUE self)
404
+ {
405
+ wxComboPopup *cpp;
406
+ Data_Get_Struct(self, wxComboPopup, cpp);
407
+
408
+ if (argc < 3 || argc > 3)
409
+ {
410
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 3)", argc);
411
+ }
412
+
413
+ try {
414
+ wxSize sz = cpp->GetAdjustedSize(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]));
415
+ return SWIG_NewPointerObj(new wxSize(sz), SWIGTYPE_p_wxSize, SWIG_POINTER_OWN);
416
+ }
417
+ catch (const Swig::DirectorException& swigex) {
418
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
419
+ {
420
+ rb_exc_raise(swigex.getError());
421
+ }
422
+ else
423
+ {
424
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
425
+ }
426
+ }
427
+ catch (const std::exception& ex) {
428
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
429
+ }
430
+ catch (...) {
431
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
432
+ }
433
+ }
434
+
435
+ static VALUE combo_popup_wx_get_control(int argc, VALUE *argv, VALUE self)
436
+ {
437
+ wxComboPopup *cpp;
438
+ Data_Get_Struct(self, wxComboPopup, cpp);
439
+
440
+ if (argc < 0 || argc > 0)
441
+ {
442
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
443
+ }
444
+
445
+ try {
446
+ wxWindow* control = cpp->GetControl();
447
+ return wxRuby_WrapWxObjectInRuby(control);
448
+ }
449
+ catch (const Swig::DirectorException& swigex) {
450
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
451
+ {
452
+ rb_exc_raise(swigex.getError());
453
+ }
454
+ else
455
+ {
456
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
457
+ }
458
+ }
459
+ catch (const std::exception& ex) {
460
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
461
+ }
462
+ catch (...) {
463
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
464
+ }
465
+ }
466
+
467
+ static VALUE combo_popup_wx_set_string_value(int argc, VALUE *argv, VALUE self)
468
+ {
469
+ wxComboPopup *cpp;
470
+ Data_Get_Struct(self, wxComboPopup, cpp);
471
+
472
+ if (argc < 1 || argc > 1)
473
+ {
474
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
475
+ }
476
+
477
+ try {
478
+ wxString val = RSTR_TO_WXSTR(argv[0]);
479
+ cpp->SetStringValue(val);
480
+ return Qnil;
481
+ }
482
+ catch (const Swig::DirectorException& swigex) {
483
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
484
+ {
485
+ rb_exc_raise(swigex.getError());
486
+ }
487
+ else
488
+ {
489
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
490
+ }
491
+ }
492
+ catch (const std::exception& ex) {
493
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
494
+ }
495
+ catch (...) {
496
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
497
+ }
498
+ }
499
+
500
+ static VALUE combo_popup_wx_get_string_value(int argc, VALUE *argv, VALUE self)
501
+ {
502
+ wxComboPopup *cpp;
503
+ Data_Get_Struct(self, wxComboPopup, cpp);
504
+
505
+ if (argc < 0 || argc > 0)
506
+ {
507
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
508
+ }
509
+
510
+ try {
511
+ wxString val = cpp->GetStringValue();
512
+ return WXSTR_TO_RSTR(val);
513
+ }
514
+ catch (const Swig::DirectorException& swigex) {
515
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
516
+ {
517
+ rb_exc_raise(swigex.getError());
518
+ }
519
+ else
520
+ {
521
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
522
+ }
523
+ }
524
+ catch (const std::exception& ex) {
525
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
526
+ }
527
+ catch (...) {
528
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
529
+ }
530
+ }
531
+
532
+ static VALUE combo_popup_wx_on_combo_double_click(int argc, VALUE *argv, VALUE self)
533
+ {
534
+ wxComboPopup *cpp;
535
+ Data_Get_Struct(self, wxComboPopup, cpp);
536
+
537
+ if (argc < 0 || argc > 0)
538
+ {
539
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
540
+ }
541
+
542
+ try {
543
+ cpp->OnComboDoubleClick();
544
+ }
545
+ catch (const Swig::DirectorException& swigex) {
546
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
547
+ {
548
+ rb_exc_raise(swigex.getError());
549
+ }
550
+ else
551
+ {
552
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
553
+ }
554
+ }
555
+ catch (const std::exception& ex) {
556
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
557
+ }
558
+ catch (...) {
559
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
560
+ }
561
+ return Qnil;
562
+ }
563
+
564
+ static VALUE get_key_event_class()
565
+ {
566
+ static VALUE key_event_klass = Qnil;
567
+ if (NIL_P(key_event_klass))
568
+ {
569
+ key_event_klass = rb_eval_string("Wx::KeyEvent");
570
+ }
571
+ return key_event_klass;
572
+ }
573
+
574
+ static VALUE combo_popup_wx_on_combo_key_event(int argc, VALUE *argv, VALUE self)
575
+ {
576
+ wxComboPopup *cpp;
577
+ Data_Get_Struct(self, wxComboPopup, cpp);
578
+
579
+ if (argc < 1 || argc > 1)
580
+ {
581
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
582
+ }
583
+
584
+ if (!rb_obj_is_kind_of(argv[0], get_key_event_class()))
585
+ {
586
+ rb_raise(rb_eTypeError, "Expected Wx::KeyEvent for 1");
587
+ }
588
+
589
+ wxEvent* evt = reinterpret_cast<wxEvent*> (DATA_PTR(argv[0]));
590
+ if (evt == nullptr)
591
+ {
592
+ rb_raise(rb_eTypeError, "Invalid null reference for Wx::KeyEvent");
593
+ }
594
+
595
+ try {
596
+ cpp->OnComboKeyEvent(*dynamic_cast<wxKeyEvent*> (evt));
597
+ }
598
+ catch (const Swig::DirectorException& swigex) {
599
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
600
+ {
601
+ rb_exc_raise(swigex.getError());
602
+ }
603
+ else
604
+ {
605
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
606
+ }
607
+ }
608
+ catch (const std::exception& ex) {
609
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
610
+ }
611
+ catch (...) {
612
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
613
+ }
614
+ return Qnil;
615
+ }
616
+
617
+ static VALUE combo_popup_wx_on_combo_char_event(int argc, VALUE *argv, VALUE self)
618
+ {
619
+ wxComboPopup *cpp;
620
+ Data_Get_Struct(self, wxComboPopup, cpp);
621
+
622
+ if (argc < 1 || argc > 1)
623
+ {
624
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
625
+ }
626
+
627
+ if (!rb_obj_is_kind_of(argv[0], get_key_event_class()))
628
+ {
629
+ rb_raise(rb_eTypeError, "Expected Wx::KeyEvent for 1");
630
+ }
631
+
632
+ wxEvent* evt = reinterpret_cast<wxEvent*> (DATA_PTR(argv[0]));
633
+ if (evt == nullptr)
634
+ {
635
+ rb_raise(rb_eTypeError, "Invalid null reference for Wx::KeyEvent");
636
+ }
637
+
638
+ try {
639
+ cpp->OnComboCharEvent(*dynamic_cast<wxKeyEvent*> (evt));
640
+ }
641
+ catch (const Swig::DirectorException& swigex) {
642
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
643
+ {
644
+ rb_exc_raise(swigex.getError());
645
+ }
646
+ else
647
+ {
648
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
649
+ }
650
+ }
651
+ catch (const std::exception& ex) {
652
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
653
+ }
654
+ catch (...) {
655
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
656
+ }
657
+ return Qnil;
658
+ }
659
+
660
+ static VALUE combo_popup_wx_on_dismiss(int argc, VALUE *argv, VALUE self)
661
+ {
662
+ wxComboPopup *cpp;
663
+ Data_Get_Struct(self, wxComboPopup, cpp);
664
+
665
+ if (argc < 0 || argc > 0)
666
+ {
667
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
668
+ }
669
+
670
+ try {
671
+ cpp->OnDismiss();
672
+ }
673
+ catch (const Swig::DirectorException& swigex) {
674
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
675
+ {
676
+ rb_exc_raise(swigex.getError());
677
+ }
678
+ else
679
+ {
680
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
681
+ }
682
+ }
683
+ catch (const std::exception& ex) {
684
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
685
+ }
686
+ catch (...) {
687
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
688
+ }
689
+ return Qnil;
690
+ }
691
+
692
+ static VALUE combo_popup_wx_on_popup(int argc, VALUE *argv, VALUE self)
693
+ {
694
+ wxComboPopup *cpp;
695
+ Data_Get_Struct(self, wxComboPopup, cpp);
696
+
697
+ if (argc < 0 || argc > 0)
698
+ {
699
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
700
+ }
701
+
702
+ try {
703
+ cpp->OnPopup();
704
+ }
705
+ catch (const Swig::DirectorException& swigex) {
706
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
707
+ {
708
+ rb_exc_raise(swigex.getError());
709
+ }
710
+ else
711
+ {
712
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
713
+ }
714
+ }
715
+ catch (const std::exception& ex) {
716
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
717
+ }
718
+ catch (...) {
719
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
720
+ }
721
+ return Qnil;
722
+ }
723
+
724
+ static VALUE combo_popup_wx_paint_combo_control(int argc, VALUE *argv, VALUE self)
725
+ {
726
+ wxComboPopup *cpp;
727
+ Data_Get_Struct(self, wxComboPopup, cpp);
728
+
729
+ if (argc < 2 || argc > 2)
730
+ {
731
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 2)", argc);
732
+ }
733
+
734
+ void *ptr;
735
+ int res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_wxDC, 0);
736
+ if (!SWIG_IsOK(res)) {
737
+ rb_raise(rb_eArgError, "Expected Wx::DC for 1");
738
+ return Qnil;
739
+ }
740
+ if (!ptr) {
741
+ rb_raise(rb_eArgError, "Invalid null reference for Wx::DC");
742
+ return Qnil;
743
+ }
744
+ wxDC *dc = reinterpret_cast< wxDC * >(ptr);
745
+ res = SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_wxRect, 0);
746
+ if (!SWIG_IsOK(res)) {
747
+ rb_raise(rb_eArgError, "Expected Wx::Rect for 2");
748
+ return Qnil;
749
+ }
750
+ if (!ptr) {
751
+ rb_raise(rb_eArgError, "Invalid null reference for Wx::Rect");
752
+ return Qnil;
753
+ }
754
+ wxRect* rect = reinterpret_cast< wxRect * >(ptr);
755
+ try {
756
+ cpp->PaintComboControl(*dc, *rect);
757
+ }
758
+ catch (const Swig::DirectorException& swigex) {
759
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
760
+ {
761
+ rb_exc_raise(swigex.getError());
762
+ }
763
+ else
764
+ {
765
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
766
+ }
767
+ }
768
+ catch (const std::exception& ex) {
769
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
770
+ }
771
+ catch (...) {
772
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
773
+ }
774
+ return Qnil;
775
+ }
776
+
777
+ #endif /* _WXRUBY_COMBO_POPUP_H */