aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/frame-demo.rs84
-rw-r--r--examples/hello-world.rs3
2 files changed, 86 insertions, 1 deletions
diff --git a/examples/frame-demo.rs b/examples/frame-demo.rs
new file mode 100644
index 0000000..2b69eb7
--- /dev/null
+++ b/examples/frame-demo.rs
@@ -0,0 +1,84 @@
+use std::ffi::CString;
+use std::marker::PhantomData;
+use std::mem::{transmute, zeroed};
+use std::ptr::{null, null_mut};
+
+use shit_wx_sys::*;
+
+fn main() {
+ unsafe {
+ let app = wxApp::new();
+
+ let title = "shit-wx-sys Example";
+ let c_string_title = CString::new(title).unwrap();
+ let title = wxString::FromAscii(c_string_title.as_ptr(), title.len().try_into().unwrap());
+ let default_position = wxPoint { x: -1, y: -1 };
+ let default_size = wxSize { x: -1, y: -1 };
+ let mut frame = wxFrame {
+ _base: wxFrameBase::new(),
+ m_hMenu: null_mut(),
+ m_menuDepth: 0,
+ m_hwndToolTip: null_mut(),
+ m_wasMinimized: false,
+ m_taskBarButton: null_mut(),
+ };
+ frame.Create(
+ null_mut(),
+ -1,
+ &title as *const wxString,
+ &default_position,
+ &default_size,
+ wxDEFAULT_FRAME_STYLE as i32,
+ &title as *const wxString,
+ );
+
+ let mut panel = wxPanel {
+ _base: wxPanelBase {
+ _base: wxNavigationEnabled {
+ vtable_: null(),
+ _base: wxWindow {
+ _base: wxWindowBase::new(),
+ m_hWnd: null_mut(),
+ m_oldWndProc: None,
+ _bitfield_align_1: [],
+ _bitfield_1: wxWindow::new_bitfield_1(false, false),
+ m_xThumbSize: 0,
+ m_yThumbSize: 0,
+ m_hDWP: null_mut(),
+ m_pendingPosition: wxPoint { x: 0, y: 0 },
+ m_pendingSize: wxSize { x: 0, y: 0 },
+ },
+ m_container: wxControlContainer::new(),
+ _phantom_0: PhantomData,
+ },
+ },
+ };
+ // hold my beer
+ panel._base._base.vtable_ =
+ transmute::<*const wxPanel, *const wxNavigationEnabled__bindgen_vtable>(&panel);
+ panel._base.Create(
+ transmute::<*mut wxFrame, *mut wxWindow>(&mut frame as *mut wxFrame),
+ wxStandardID_wxID_ANY,
+ &default_position,
+ &default_size,
+ wxTAB_TRAVERSAL as i32,
+ &title as *const wxString,
+ );
+
+ let label = "Hello World!";
+ let c_string_label = CString::new(label).unwrap();
+ let label = wxString::FromAscii(c_string_label.as_ptr(), label.len().try_into().unwrap());
+ let mut static_text: &mut wxStaticText = transmute(wxStaticText::wxCreateObject());
+ static_text.Create(
+ transmute::<*mut wxPanel, *mut wxWindow>(&mut panel),
+ wxStandardID_wxID_ANY,
+ &label,
+ &default_position,
+ &default_size,
+ 0,
+ &label,
+ );
+
+ // no way to call wxFrame::show bc bindgen doesn't handle virtual methods
+ }
+}
diff --git a/examples/hello-world.rs b/examples/hello-world.rs
index fb15d85..9fe521c 100644
--- a/examples/hello-world.rs
+++ b/examples/hello-world.rs
@@ -1,4 +1,5 @@
use std::ffi::CString;
+use std::ptr::null_mut;
use shit_wx_sys::*;
@@ -12,7 +13,7 @@ fn main() {
(&message) as *const wxString,
(&message) as *const wxString,
(wxOK as i32) | wxGeometryCentre_wxCENTER,
- NULL as *mut wxWindow,
+ null_mut(),
wxDefaultCoord,
wxDefaultCoord,
);