wxrust_base/generated/
class_o.rs

1use super::*;
2
3// wxObject
4wxwidgets! {
5    /// This is the root class of many of the wxWidgets classes.
6    /// - [`Object`] represents a C++ `wxObject` class instance which your code has ownership, [`ObjectIsOwned`]`<false>` represents one which don't own.
7    /// - Use [`Object`]'s `new()` to create an instance of this class.
8    /// - See [C++ `wxObject` class's documentation](https://docs.wxwidgets.org/3.2/classwx_object.html) for more details.
9    #[doc(alias = "wxObject")]
10    #[doc(alias = "Object")]
11    class Object
12        = ObjectIsOwned<true>(wxObject) impl
13        ObjectMethods
14}
15impl<const OWNED: bool> ObjectIsOwned<OWNED> {
16    /// Default ctor; initializes to NULL the internal reference data.
17    ///
18    /// See [C++ `wxObject::wxObject()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_object.html#acaa378363a28af421ab56ad7b46eadf0).
19    pub fn new() -> ObjectIsOwned<OWNED> {
20        unsafe { ObjectIsOwned(ffi::wxObject_new()) }
21    }
22    /// Copy ctor.
23    ///
24    /// See [C++ `wxObject::wxObject()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_object.html#a4721b4dc9b7aff0f30904ba2ea3954cf).
25    pub fn new_with_object<O: ObjectMethods>(other: &O) -> ObjectIsOwned<OWNED> {
26        unsafe {
27            let other = other.as_ptr();
28            ObjectIsOwned(ffi::wxObject_new1(other))
29        }
30    }
31    pub fn none() -> Option<&'static Self> {
32        None
33    }
34}
35impl Clone for ObjectIsOwned<false> {
36    fn clone(&self) -> Self {
37        Self(self.0)
38    }
39}
40impl<const OWNED: bool> DynamicCast for ObjectIsOwned<OWNED> {
41    fn class_info() -> ClassInfoIsOwned<false> {
42        unsafe { ClassInfoIsOwned::from_ptr(ffi::wxObject_CLASSINFO()) }
43    }
44}
45impl<const OWNED: bool> Drop for ObjectIsOwned<OWNED> {
46    fn drop(&mut self) {
47        if OWNED {
48            unsafe { ffi::wxObject_delete(self.0) }
49        }
50    }
51}
52
53// wxObjectRefData
54wxwidgets! {
55    /// This class is just a typedef to wxRefCounter and is used by wxObject.
56    /// - [`ObjectRefData`] represents a C++ `wxObjectRefData` class instance which your code has ownership, [`ObjectRefDataIsOwned`]`<false>` represents one which don't own.
57    /// - Use [`ObjectRefData`]'s `new()` to create an instance of this class.
58    /// - See [C++ `wxObjectRefData` class's documentation](https://docs.wxwidgets.org/3.2/classwx_object_ref_data.html) for more details.
59    #[doc(alias = "wxObjectRefData")]
60    #[doc(alias = "ObjectRefData")]
61    class ObjectRefData
62        = ObjectRefDataIsOwned<true>(wxObjectRefData) impl
63        ObjectRefDataMethods
64}
65impl<const OWNED: bool> ObjectRefDataIsOwned<OWNED> {
66    pub fn none() -> Option<&'static Self> {
67        None
68    }
69}
70impl Clone for ObjectRefDataIsOwned<false> {
71    fn clone(&self) -> Self {
72        Self(self.0)
73    }
74}
75impl<const OWNED: bool> Drop for ObjectRefDataIsOwned<OWNED> {
76    fn drop(&mut self) {
77        if OWNED {
78            unsafe { ffi::wxObjectRefData_delete(self.0) }
79        }
80    }
81}