1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// This file is auto-generated by rute_gen. DO NOT EDIT.
use std::cell::Cell;
use std::rc::Rc;

#[allow(unused_imports)]
use std::marker::PhantomData;

#[allow(unused_imports)]
use std::os::raw::c_void;

#[allow(unused_imports)]
use std::mem::transmute;

#[allow(unused_imports)]
use std::ffi::{CStr, CString};

use rute_ffi_base::*;

#[allow(unused_imports)]
use auto::*;

/// **Notice these docs are heavy WIP and not very relevent yet**
///
/// The size policy of a widget is an expression of its willingness to
/// be resized in various ways, and affects how the widget is treated
/// by the [layout engine](Layout%20Management)
/// . Each widget returns a
/// QSizePolicy that describes the horizontal and vertical resizing
/// policy it prefers when being laid out. You can change this for
/// a specific widget by changing its QWidget::sizePolicy property.
///
/// QSizePolicy contains two independent QSizePolicy::Policy values
/// and two stretch factors; one describes the widgets's horizontal
/// size policy, and the other describes its vertical size policy. It
/// also contains a flag to indicate whether the height and width of
/// its preferred size are related.
///
/// The horizontal and vertical policies can be set in the
/// constructor, and altered using the setHorizontalPolicy() and
/// setVerticalPolicy() functions. The stretch factors can be set
/// using the setHorizontalStretch() and setVerticalStretch()
/// functions. The flag indicating whether the widget's
/// [sizeHint()](QWidget::sizeHint())
/// is width-dependent (such as a
/// menu bar or a word-wrapping label) can be set using the
/// setHeightForWidth() function.
///
/// The current size policies and stretch factors be retrieved using
/// the horizontalPolicy(), verticalPolicy(), horizontalStretch() and
/// verticalStretch() functions. Alternatively, use the transpose()
/// function to swap the horizontal and vertical policies and
/// stretches. The hasHeightForWidth() function returns the current
/// status of the flag indicating the size hint dependencies.
///
/// Use the expandingDirections() function to determine whether the
/// associated widget can make use of more space than its
/// [sizeHint()](QWidget::sizeHint())
/// function indicates, as well as
/// find out in which directions it can expand.
///
/// Finally, the QSizePolicy class provides operators comparing this
/// size policy to a given policy, as well as a QVariant operator
/// storing this QSizePolicy as a QVariant object.
///
/// **See also:** [`Size`]
/// [`Widget::size_hint`]
/// [`Widget::size_policy()`]
/// [`LayoutItem::size_hint`]
/// # Licence
///
/// The documentation is an adoption of the original [Qt Documentation](http://doc.qt.io/) and provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](http://www.gnu.org/licenses/fdl.html) as published by the Free Software Foundation.
#[derive(Clone)]
pub struct SizePolicy<'a> {
    #[doc(hidden)]
    pub data: Rc<Cell<Option<*const RUBase>>>,
    #[doc(hidden)]
    pub all_funcs: *const RUSizePolicyAllFuncs,
    #[doc(hidden)]
    pub owned: bool,
    #[doc(hidden)]
    pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}

impl<'a> SizePolicy<'a> {
    pub fn new() -> SizePolicy<'a> {
        let data = Rc::new(Cell::new(None));

        let ffi_data = unsafe {
            ((*rute_ffi_get()).create_size_policy)(
                ::std::ptr::null(),
                transmute(rute_object_delete_callback as usize),
                Rc::into_raw(data.clone()) as *const c_void,
            )
        };

        data.set(Some(ffi_data.qt_data));

        SizePolicy {
            data,
            all_funcs: ffi_data.all_funcs,
            owned: true,
            _marker: PhantomData,
        }
    }
    #[allow(dead_code)]
    pub(crate) fn new_from_rc(ffi_data: RUSizePolicy) -> SizePolicy<'a> {
        SizePolicy {
            data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
            all_funcs: ffi_data.all_funcs,
            owned: false,
            _marker: PhantomData,
        }
    }

    #[allow(dead_code)]
    pub(crate) fn new_from_owned(ffi_data: RUSizePolicy) -> SizePolicy<'a> {
        SizePolicy {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
            all_funcs: ffi_data.all_funcs,
            owned: true,
            _marker: PhantomData,
        }
    }

    #[allow(dead_code)]
    pub(crate) fn new_from_temporary(ffi_data: RUSizePolicy) -> SizePolicy<'a> {
        SizePolicy {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
            all_funcs: ffi_data.all_funcs,
            owned: false,
            _marker: PhantomData,
        }
    }
    ///
    /// Returns the horizontal component of the size policy.
    ///
    /// **See also:** [`set_horizontal_policy()`]
    /// [`vertical_policy()`]
    /// [`horizontal_stretch()`]
    pub fn horizontal_policy(&self) -> Policy {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).horizontal_policy)(obj_data);
            let ret_val = { transmute::<i32, Policy>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns the vertical component of the size policy.
    ///
    /// **See also:** [`set_vertical_policy()`]
    /// [`horizontal_policy()`]
    /// [`vertical_stretch()`]
    pub fn vertical_policy(&self) -> Policy {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).vertical_policy)(obj_data);
            let ret_val = { transmute::<i32, Policy>(ret_val) };
            ret_val
        }
    }
    ///
    /// Sets the horizontal component to the given *policy.*
    ///
    /// **See also:** [`horizontal_policy()`]
    /// [`set_vertical_policy()`]
    /// [`set_horizontal_stretch()`]
    pub fn set_horizontal_policy(&self, d: Policy) -> &Self {
        let enum_d_1 = d as i32;

        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            ((*funcs).set_horizontal_policy)(obj_data, enum_d_1);
        }
        self
    }
    ///
    /// Sets the vertical component to the given *policy.*
    ///
    /// **See also:** [`vertical_policy()`]
    /// [`set_horizontal_policy()`]
    /// [`set_vertical_stretch()`]
    pub fn set_vertical_policy(&self, d: Policy) -> &Self {
        let enum_d_1 = d as i32;

        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            ((*funcs).set_vertical_policy)(obj_data, enum_d_1);
        }
        self
    }
    ///
    /// Returns whether a widget can make use of more space than the
    /// QWidget::sizeHint() function indicates.
    ///
    /// A value of Qt::Horizontal or Qt::Vertical means that the widget
    /// can grow horizontally or vertically (i.e., the horizontal or
    /// vertical policy is [Expanding](Expanding)
    /// or [MinimumExpanding),](MinimumExpanding),)
    /// whereas
    /// Qt::Horizontal | Qt::Vertical means that it can grow in both
    /// dimensions.
    ///
    /// **See also:** [`horizontal_policy()`]
    /// [`vertical_policy()`]
    pub fn expanding_directions(&self) -> Orientations {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).expanding_directions)(obj_data);
            let ret_val = { transmute::<i32, Orientations>(ret_val) };
            ret_val
        }
    }
    ///
    /// Sets the flag determining whether the widget's preferred height
    /// depends on its width, to *dependent.*
    ///
    /// **See also:** [`has_height_for_width()`]
    /// [`set_width_for_height()`]
    pub fn set_height_for_width(&self, b: bool) -> &Self {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            ((*funcs).set_height_for_width)(obj_data, b);
        }
        self
    }
    ///
    /// Returns `true` if the widget's preferred height depends on its
    /// width; otherwise returns `false.`
    ///
    /// **See also:** [`set_height_for_width()`]
    pub fn has_height_for_width(&self) -> bool {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_height_for_width)(obj_data);
            ret_val
        }
    }
    ///
    /// Sets the flag determining whether the widget's width
    /// depends on its height, to *dependent.*
    ///
    /// This is only supported for QGraphicsLayout's subclasses.
    /// It is not possible to have a layout with both height-for-width
    /// and width-for-height constraints at the same time.
    ///
    /// **See also:** [`has_width_for_height()`]
    /// [`set_height_for_width()`]
    pub fn set_width_for_height(&self, b: bool) -> &Self {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            ((*funcs).set_width_for_height)(obj_data, b);
        }
        self
    }
    ///
    /// Returns `true` if the widget's width depends on its
    /// height; otherwise returns `false.`
    ///
    /// **See also:** [`set_width_for_height()`]
    pub fn has_width_for_height(&self) -> bool {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).has_width_for_height)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns whether the layout should retain the widget's size when it is hidden.
    /// This is `false` by default.
    ///
    /// **See also:** [`set_retain_size_when_hidden()`]
    pub fn retain_size_when_hidden(&self) -> bool {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).retain_size_when_hidden)(obj_data);
            ret_val
        }
    }
    ///
    /// Sets whether a layout should retain the widget's size when it is hidden.
    /// If *retainSize* is `true,` the layout will not be changed by hiding the widget.
    ///
    /// **See also:** [`retain_size_when_hidden()`]
    pub fn set_retain_size_when_hidden(&self, retain_size: bool) -> &Self {
        let (obj_data, funcs) = self.get_size_policy_obj_funcs();
        unsafe {
            ((*funcs).set_retain_size_when_hidden)(obj_data, retain_size);
        }
        self
    }
}
pub trait SizePolicyTrait<'a> {
    #[inline]
    #[doc(hidden)]
    fn get_size_policy_obj_funcs(&self) -> (*const RUBase, *const RUSizePolicyFuncs);
}

impl<'a> SizePolicyTrait<'a> for SizePolicy<'a> {
    #[doc(hidden)]
    fn get_size_policy_obj_funcs(&self) -> (*const RUBase, *const RUSizePolicyFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).size_policy_funcs) }
    }
}
#[repr(u32)]
pub enum PolicyFlag {
    GrowFlag,
    ExpandFlag,
    ShrinkFlag,
    IgnoreFlag,
}

#[repr(u32)]
pub enum Policy {
    Fixed,
    Minimum,
    Maximum,
    Preferred,
    MinimumExpanding,
    Expanding,
    Ignored,
}

#[repr(u32)]
pub enum ControlType {
    DefaultType,
    ButtonBox,
    CheckBox,
    ComboBox,
    Frame,
    GroupBox,
    Label,
    Line,
    LineEdit,
    PushButton,
    RadioButton,
    Slider,
    SpinBox,
    TabWidget,
    ToolButton,
}

pub type ControlTypes = ControlType;