wxrust_base/generated/
class_t.rs1use super::*;
2
3wxwidgets! {
5 #[doc(alias = "wxTimer")]
10 #[doc(alias = "Timer")]
11 class Timer
12 = TimerIsOwned<true>(wxTimer) impl
13 TimerMethods,
14 EvtHandlerMethods,
15 ObjectMethods
16}
17impl<const OWNED: bool> TimerIsOwned<OWNED> {
18 pub fn new() -> TimerIsOwned<OWNED> {
22 unsafe { TimerIsOwned(ffi::wxTimer_new()) }
23 }
24 pub fn new_with_evthandler<E: EvtHandlerMethods>(
28 owner: Option<&E>,
29 id: c_int,
30 ) -> TimerIsOwned<OWNED> {
31 unsafe {
32 let owner = match owner {
33 Some(r) => r.as_ptr(),
34 None => ptr::null_mut(),
35 };
36 TimerIsOwned(ffi::wxTimer_new1(owner, id))
37 }
38 }
39 pub fn none() -> Option<&'static Self> {
40 None
41 }
42}
43impl<const OWNED: bool> Clone for TimerIsOwned<OWNED> {
44 fn clone(&self) -> Self {
45 Self(self.0)
46 }
47}
48impl<const OWNED: bool> From<TimerIsOwned<OWNED>> for EvtHandlerIsOwned<OWNED> {
49 fn from(o: TimerIsOwned<OWNED>) -> Self {
50 unsafe { Self::from_ptr(o.as_ptr()) }
51 }
52}
53impl<const OWNED: bool> From<TimerIsOwned<OWNED>> for ObjectIsOwned<OWNED> {
54 fn from(o: TimerIsOwned<OWNED>) -> Self {
55 unsafe { Self::from_ptr(o.as_ptr()) }
56 }
57}
58impl<const OWNED: bool> DynamicCast for TimerIsOwned<OWNED> {
59 fn class_info() -> ClassInfoIsOwned<false> {
60 unsafe { ClassInfoIsOwned::from_ptr(ffi::wxTimer_CLASSINFO()) }
61 }
62}
63
64wxwidgets! {
66 #[doc(alias = "wxTimerEvent")]
71 #[doc(alias = "TimerEvent")]
72 class TimerEvent
73 = TimerEventIsOwned<true>(wxTimerEvent) impl
74 TimerEventMethods,
75 EventMethods,
76 ObjectMethods
77}
78impl<const OWNED: bool> TimerEventIsOwned<OWNED> {
79 pub fn new<T: TimerMethods>(timer: &T) -> TimerEventIsOwned<OWNED> {
82 unsafe {
83 let timer = timer.as_ptr();
84 TimerEventIsOwned(ffi::wxTimerEvent_new(timer))
85 }
86 }
87 pub fn none() -> Option<&'static Self> {
88 None
89 }
90}
91impl Clone for TimerEventIsOwned<false> {
92 fn clone(&self) -> Self {
93 Self(self.0)
94 }
95}
96impl<const OWNED: bool> From<TimerEventIsOwned<OWNED>> for EventIsOwned<OWNED> {
97 fn from(o: TimerEventIsOwned<OWNED>) -> Self {
98 unsafe { Self::from_ptr(o.as_ptr()) }
99 }
100}
101impl<const OWNED: bool> From<TimerEventIsOwned<OWNED>> for ObjectIsOwned<OWNED> {
102 fn from(o: TimerEventIsOwned<OWNED>) -> Self {
103 unsafe { Self::from_ptr(o.as_ptr()) }
104 }
105}
106impl<const OWNED: bool> DynamicCast for TimerEventIsOwned<OWNED> {
107 fn class_info() -> ClassInfoIsOwned<false> {
108 unsafe { ClassInfoIsOwned::from_ptr(ffi::wxTimerEvent_CLASSINFO()) }
109 }
110}
111impl<const OWNED: bool> Drop for TimerEventIsOwned<OWNED> {
112 fn drop(&mut self) {
113 if OWNED {
114 unsafe { ffi::wxObject_delete(self.0) }
115 }
116 }
117}