1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
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() {
#[cfg(unix)]
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
}
}
|