wxrust_base/generated/
methods_t.rs

1use super::*;
2
3// wxTimer
4/// This trait represents [C++ `wxTimer` class](https://docs.wxwidgets.org/3.2/classwx_timer.html)'s methods and inheritance.
5///
6/// See [`TimerIsOwned`] documentation for the class usage.
7pub trait TimerMethods: EvtHandlerMethods {
8    // DTOR: fn ~wxTimer()
9    /// Returns the ID of the events generated by this timer.
10    ///
11    /// See [C++ `wxTimer::GetId()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a577a4e2f301e76394653def2d3314366).
12    fn get_id(&self) -> c_int {
13        unsafe { ffi::wxTimer_GetId(self.as_ptr()) }
14    }
15    /// Returns the current interval for the timer (in milliseconds).
16    ///
17    /// See [C++ `wxTimer::GetInterval()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#af846a40c141b009058900264422bec2f).
18    fn get_interval(&self) -> c_int {
19        unsafe { ffi::wxTimer_GetInterval(self.as_ptr()) }
20    }
21    /// Returns the current owner of the timer.
22    ///
23    /// See [C++ `wxTimer::GetOwner()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a088fdf940662602b8ac01289e1edd218).
24    fn get_owner(&self) -> WeakRef<EvtHandler> {
25        unsafe { WeakRef::<EvtHandler>::from(ffi::wxTimer_GetOwner(self.as_ptr())) }
26    }
27    /// Returns true if the timer is one shot, i.e. if it will stop after firing the first notification automatically.
28    ///
29    /// See [C++ `wxTimer::IsOneShot()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a48215d19459b9635c98ef0ac9c299fb5).
30    fn is_one_shot(&self) -> bool {
31        unsafe { ffi::wxTimer_IsOneShot(self.as_ptr()) }
32    }
33    /// Returns true if the timer is running, false if it is stopped.
34    ///
35    /// See [C++ `wxTimer::IsRunning()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a8aa59ba1d6646bb5c62f8a035f887df7).
36    fn is_running(&self) -> bool {
37        unsafe { ffi::wxTimer_IsRunning(self.as_ptr()) }
38    }
39    /// This member should be overridden by the user if the default constructor was used and SetOwner() wasn't called.
40    ///
41    /// See [C++ `wxTimer::Notify()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#abeaa78e9916e88fd5f544c3eab4e57b4).
42    fn notify(&self) {
43        unsafe { ffi::wxTimer_Notify(self.as_ptr()) }
44    }
45    /// Associates the timer with the given owner object.
46    ///
47    /// See [C++ `wxTimer::SetOwner()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#aa3966b37329a4fad69ad384733eab27e).
48    fn set_owner<E: EvtHandlerMethods>(&self, owner: Option<&E>, id: c_int) {
49        unsafe {
50            let owner = match owner {
51                Some(r) => r.as_ptr(),
52                None => ptr::null_mut(),
53            };
54            ffi::wxTimer_SetOwner(self.as_ptr(), owner, id)
55        }
56    }
57    /// (Re)starts the timer.
58    ///
59    /// See [C++ `wxTimer::Start()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a8df981f7075786811598828af1d294ac).
60    fn start(&self, milliseconds: c_int, one_shot: bool) -> bool {
61        unsafe { ffi::wxTimer_Start(self.as_ptr(), milliseconds, one_shot) }
62    }
63    /// Starts the timer for a once-only notification.
64    ///
65    /// See [C++ `wxTimer::StartOnce()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a0e7e025d014770a17d1274684a19bb53).
66    fn start_once(&self, milliseconds: c_int) -> bool {
67        unsafe { ffi::wxTimer_StartOnce(self.as_ptr(), milliseconds) }
68    }
69    /// Stops the timer.
70    ///
71    /// See [C++ `wxTimer::Stop()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a74c499ddd20b00376ff99f08fb96a3d0).
72    fn stop(&self) {
73        unsafe { ffi::wxTimer_Stop(self.as_ptr()) }
74    }
75}
76
77// wxTimerEvent
78/// This trait represents [C++ `wxTimerEvent` class](https://docs.wxwidgets.org/3.2/classwx_timer_event.html)'s methods and inheritance.
79///
80/// See [`TimerEventIsOwned`] documentation for the class usage.
81pub trait TimerEventMethods: EventMethods {
82    /// Returns the interval of the timer which generated this event.
83    ///
84    /// See [C++ `wxTimerEvent::GetInterval()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer_event.html#ad05c2329d91f5f3c755be05c176b1688).
85    fn get_interval(&self) -> c_int {
86        unsafe { ffi::wxTimerEvent_GetInterval(self.as_ptr()) }
87    }
88    /// Returns the timer object which generated this event.
89    ///
90    /// See [C++ `wxTimerEvent::GetTimer()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer_event.html#af2174f494ca4bb926691ac4657397578).
91    fn get_timer(&self) -> TimerIsOwned<false> {
92        unsafe { TimerIsOwned::from_ptr(ffi::wxTimerEvent_GetTimer(self.as_ptr())) }
93    }
94}