Permalink
Browse files

Addd ComboBox, and include the ItemContainer Interface

  • Loading branch information...
1 parent 8f7eb51 commit 318295793e2ff2bcee038de4cb2546245e9523ad @Hanmac committed Mar 20, 2013
Showing with 91 additions and 1 deletion.
  1. +2 −1 ext/rwx.cpp
  2. +64 −0 ext/wxComboBox.cpp
  3. +22 −0 ext/wxComboBox.hpp
  4. +3 −0 ext/wxItemContainer.cpp
View
@@ -94,6 +94,7 @@
#include "wxItemContainer.hpp"
#include "wxChoice.hpp"
+#include "wxComboBox.hpp"
#include "wxSlider.hpp"
@@ -279,7 +280,7 @@ extern "C" void Init_rwx()
Init_WXStaticText(rb_mWX);
Init_WXStaticBox(rb_mWX);
-
+ Init_WXComboBox(rb_mWX);
Init_WXChoice(rb_mWX);
Init_WXAnyButton(rb_mWX);
View
@@ -0,0 +1,64 @@
+/*
+ * wxComboBox.cpp
+ *
+ * Created on: 03.05.2012
+ * Author: hanmac
+ */
+
+
+
+#include "wxEvtHandler.hpp"
+#include "wxItemContainer.hpp"
+
+VALUE rb_cWXComboBox;
+
+#if wxUSE_COMBOBOX
+#define _self unwrap<wxComboBox*>(self)
+
+namespace RubyWX {
+namespace ComboBox {
+
+APP_PROTECT(wxComboBox)
+
+VALUE _initialize(int argc,VALUE *argv,VALUE self)
+{
+ VALUE parent,hash;
+ rb_scan_args(argc, argv, "11",&parent,&hash);
+
+ if(!rb_obj_is_kind_of(hash,rb_cString)) {
+ _self->Create(unwrap<wxWindow*>(parent),wxID_ANY);
+ _created = true;
+ }
+
+ rb_call_super(argc,argv);
+
+ if(rb_obj_is_kind_of(hash,rb_cHash)) {
+ VALUE temp;
+ if(!NIL_P(temp=rb_hash_aref(hash,ID2SYM(rb_intern("items")))))
+ _self->Set(unwrap<wxArrayString>(temp));
+ if(!NIL_P(temp=rb_hash_aref(hash,ID2SYM(rb_intern("select")))))
+ _self->SetSelection(NUM2INT(temp));
+ }
+
+ return self;
+}
+
+}
+}
+#endif
+void Init_WXComboBox(VALUE rb_mWX)
+{
+#if wxUSE_COMBOBOX
+ using namespace RubyWX::ComboBox;
+ rb_cWXComboBox = rb_define_class_under(rb_mWX,"ComboBox",rb_cWXControl);
+ rb_define_alloc_func(rb_cWXComboBox,_alloc);
+
+ rb_define_method(rb_cWXComboBox,"initialize",RUBY_METHOD_FUNC(_initialize),-1);
+
+ rb_include_module(rb_cWXComboBox,rb_mWXItemContainer);
+
+ registerInfo<wxComboBox>(rb_cWXComboBox);
+#endif
+
+}
+
View
@@ -0,0 +1,22 @@
+/*
+ * wxComboBox.hpp
+ *
+ * Created on: 03.05.2012
+ * Author: hanmac
+ */
+
+#ifndef WXCOMBOBOX_HPP_
+#define WXCOMBOBOX_HPP_
+
+#include "main.hpp"
+
+extern VALUE rb_cWXComboBox;
+
+void Init_WXComboBox(VALUE rb_mWX);
+
+#if wxUSE_COMBOBOX
+#include <wx/combobox.h>
+#endif
+
+
+#endif /* WXCOMBOBOX_HPP_ */
View
@@ -10,6 +10,7 @@
#include "wxListBox.hpp"
#include "wxChoice.hpp"
+#include "wxComboBox.hpp"
VALUE rb_mWXItemContainer;
#if wxUSE_CONTROLS
@@ -22,6 +23,8 @@ wxItemContainer* unwrap< wxItemContainer* >(const VALUE &obj)
return unwrap<wxListBox*>(obj);
if(rb_obj_is_kind_of(obj,rb_cWXChoice))
return unwrap<wxChoice*>(obj);
+ if(rb_obj_is_kind_of(obj,rb_cWXComboBox))
+ return unwrap<wxComboBox*>(obj);
return unwrapPtr<wxItemContainer>(obj,rb_mWXItemContainer);
return NULL;

0 comments on commit 3182957

Please sign in to comment.