wxrust-base 0.0.1-alpha

Binding for the (part of) wxBase library of the wxWidgets toolkit.
Documentation
use super::*;

// wxTimer
/// This trait represents [C++ `wxTimer` class](https://docs.wxwidgets.org/3.2/classwx_timer.html)'s methods and inheritance.
///
/// See [`TimerIsOwned`] documentation for the class usage.
pub trait TimerMethods: EvtHandlerMethods {
    // DTOR: fn ~wxTimer()
    /// Returns the ID of the events generated by this timer.
    ///
    /// See [C++ `wxTimer::GetId()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a577a4e2f301e76394653def2d3314366).
    fn get_id(&self) -> c_int {
        unsafe { ffi::wxTimer_GetId(self.as_ptr()) }
    }
    /// Returns the current interval for the timer (in milliseconds).
    ///
    /// See [C++ `wxTimer::GetInterval()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#af846a40c141b009058900264422bec2f).
    fn get_interval(&self) -> c_int {
        unsafe { ffi::wxTimer_GetInterval(self.as_ptr()) }
    }
    /// Returns the current owner of the timer.
    ///
    /// See [C++ `wxTimer::GetOwner()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a088fdf940662602b8ac01289e1edd218).
    fn get_owner(&self) -> WeakRef<EvtHandler> {
        unsafe { WeakRef::<EvtHandler>::from(ffi::wxTimer_GetOwner(self.as_ptr())) }
    }
    /// Returns true if the timer is one shot, i.e. if it will stop after firing the first notification automatically.
    ///
    /// See [C++ `wxTimer::IsOneShot()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a48215d19459b9635c98ef0ac9c299fb5).
    fn is_one_shot(&self) -> bool {
        unsafe { ffi::wxTimer_IsOneShot(self.as_ptr()) }
    }
    /// Returns true if the timer is running, false if it is stopped.
    ///
    /// See [C++ `wxTimer::IsRunning()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a8aa59ba1d6646bb5c62f8a035f887df7).
    fn is_running(&self) -> bool {
        unsafe { ffi::wxTimer_IsRunning(self.as_ptr()) }
    }
    /// This member should be overridden by the user if the default constructor was used and SetOwner() wasn't called.
    ///
    /// See [C++ `wxTimer::Notify()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#abeaa78e9916e88fd5f544c3eab4e57b4).
    fn notify(&self) {
        unsafe { ffi::wxTimer_Notify(self.as_ptr()) }
    }
    /// Associates the timer with the given owner object.
    ///
    /// See [C++ `wxTimer::SetOwner()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#aa3966b37329a4fad69ad384733eab27e).
    fn set_owner<E: EvtHandlerMethods>(&self, owner: Option<&E>, id: c_int) {
        unsafe {
            let owner = match owner {
                Some(r) => r.as_ptr(),
                None => ptr::null_mut(),
            };
            ffi::wxTimer_SetOwner(self.as_ptr(), owner, id)
        }
    }
    /// (Re)starts the timer.
    ///
    /// See [C++ `wxTimer::Start()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a8df981f7075786811598828af1d294ac).
    fn start(&self, milliseconds: c_int, one_shot: bool) -> bool {
        unsafe { ffi::wxTimer_Start(self.as_ptr(), milliseconds, one_shot) }
    }
    /// Starts the timer for a once-only notification.
    ///
    /// See [C++ `wxTimer::StartOnce()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a0e7e025d014770a17d1274684a19bb53).
    fn start_once(&self, milliseconds: c_int) -> bool {
        unsafe { ffi::wxTimer_StartOnce(self.as_ptr(), milliseconds) }
    }
    /// Stops the timer.
    ///
    /// See [C++ `wxTimer::Stop()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer.html#a74c499ddd20b00376ff99f08fb96a3d0).
    fn stop(&self) {
        unsafe { ffi::wxTimer_Stop(self.as_ptr()) }
    }
}

// wxTimerEvent
/// This trait represents [C++ `wxTimerEvent` class](https://docs.wxwidgets.org/3.2/classwx_timer_event.html)'s methods and inheritance.
///
/// See [`TimerEventIsOwned`] documentation for the class usage.
pub trait TimerEventMethods: EventMethods {
    /// Returns the interval of the timer which generated this event.
    ///
    /// See [C++ `wxTimerEvent::GetInterval()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer_event.html#ad05c2329d91f5f3c755be05c176b1688).
    fn get_interval(&self) -> c_int {
        unsafe { ffi::wxTimerEvent_GetInterval(self.as_ptr()) }
    }
    /// Returns the timer object which generated this event.
    ///
    /// See [C++ `wxTimerEvent::GetTimer()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_timer_event.html#af2174f494ca4bb926691ac4657397578).
    fn get_timer(&self) -> TimerIsOwned<false> {
        unsafe { TimerIsOwned::from_ptr(ffi::wxTimerEvent_GetTimer(self.as_ptr())) }
    }
}