wxrust_base/generated/
class_e.rs

1use super::*;
2
3// wxEvent
4wxwidgets! {
5    /// An event is a structure holding information about an event passed to a callback or member function.
6    /// - [`Event`] represents a C++ `wxEvent` class instance which your code has ownership, [`EventIsOwned`]`<false>` represents one which don't own.
7    /// - Use [`Event`]'s `new()` to create an instance of this class.
8    /// - See [C++ `wxEvent` class's documentation](https://docs.wxwidgets.org/3.2/classwx_event.html) for more details.
9    #[doc(alias = "wxEvent")]
10    #[doc(alias = "Event")]
11    class Event
12        = EventIsOwned<true>(wxEvent) impl
13        EventMethods,
14        ObjectMethods
15}
16impl<const OWNED: bool> EventIsOwned<OWNED> {
17    // NOT_SUPPORTED: fn wxEvent()
18    pub fn none() -> Option<&'static Self> {
19        None
20    }
21}
22impl Clone for EventIsOwned<false> {
23    fn clone(&self) -> Self {
24        Self(self.0)
25    }
26}
27impl<const OWNED: bool> From<EventIsOwned<OWNED>> for ObjectIsOwned<OWNED> {
28    fn from(o: EventIsOwned<OWNED>) -> Self {
29        unsafe { Self::from_ptr(o.as_ptr()) }
30    }
31}
32impl<const OWNED: bool> DynamicCast for EventIsOwned<OWNED> {
33    fn class_info() -> ClassInfoIsOwned<false> {
34        unsafe { ClassInfoIsOwned::from_ptr(ffi::wxEvent_CLASSINFO()) }
35    }
36}
37impl<const OWNED: bool> Drop for EventIsOwned<OWNED> {
38    fn drop(&mut self) {
39        if OWNED {
40            unsafe { ffi::wxObject_delete(self.0) }
41        }
42    }
43}
44
45// wxEvtHandler
46wxwidgets! {
47    /// A class that can handle events from the windowing system.
48    /// - [`EvtHandler`] represents a C++ `wxEvtHandler` class instance which your code has ownership, [`EvtHandlerIsOwned`]`<false>` represents one which don't own.
49    /// - Use [`EvtHandler`]'s `new()` to create an instance of this class.
50    /// - See [C++ `wxEvtHandler` class's documentation](https://docs.wxwidgets.org/3.2/classwx_evt_handler.html) for more details.
51    #[doc(alias = "wxEvtHandler")]
52    #[doc(alias = "EvtHandler")]
53    class EvtHandler
54        = EvtHandlerIsOwned<true>(wxEvtHandler) impl
55        EvtHandlerMethods,
56        ObjectMethods
57}
58impl<const OWNED: bool> EvtHandlerIsOwned<OWNED> {
59    /// Constructor.
60    ///
61    /// See [C++ `wxEvtHandler::wxEvtHandler()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_evt_handler.html#a3f0166c4154227d05575b01eb2c8d4be).
62    pub fn new() -> EvtHandlerIsOwned<OWNED> {
63        unsafe { EvtHandlerIsOwned(ffi::wxEvtHandler_new()) }
64    }
65    pub fn none() -> Option<&'static Self> {
66        None
67    }
68}
69impl<const OWNED: bool> Clone for EvtHandlerIsOwned<OWNED> {
70    fn clone(&self) -> Self {
71        Self(self.0)
72    }
73}
74impl<const OWNED: bool> From<EvtHandlerIsOwned<OWNED>> for ObjectIsOwned<OWNED> {
75    fn from(o: EvtHandlerIsOwned<OWNED>) -> Self {
76        unsafe { Self::from_ptr(o.as_ptr()) }
77    }
78}
79impl<const OWNED: bool> DynamicCast for EvtHandlerIsOwned<OWNED> {
80    fn class_info() -> ClassInfoIsOwned<false> {
81        unsafe { ClassInfoIsOwned::from_ptr(ffi::wxEvtHandler_CLASSINFO()) }
82    }
83}