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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// 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**
///
/// A widget will receive drag move events repeatedly while the drag
/// is within its boundaries, if it accepts
/// [drop events](QWidget::setAcceptDrops())
/// and [enter events](QWidget::dragEnterEvent())
/// . The widget should
/// examine the event to see what kind of [data](mimeData())
/// it
/// provides, and call the accept() function to accept the drop if appropriate.
///
/// The rectangle supplied by the answerRect() function can be used to restrict
/// drops to certain parts of the widget. For example, we can check whether the
/// rectangle intersects with the geometry of a certain child widget and only
/// call [acceptProposedAction()](QDropEvent::acceptProposedAction())
/// if that
/// is the case.
///
/// Note that this class inherits most of its functionality from
/// QDropEvent.
///
/// **See also:** [`DragEnterEvent`]
/// [`DragLeaveEvent`]
/// [`DropEvent`]
/// # 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 DragMoveEvent<'a> {
    #[doc(hidden)]
    pub data: Rc<Cell<Option<*const RUBase>>>,
    #[doc(hidden)]
    pub all_funcs: *const RUDragMoveEventAllFuncs,
    #[doc(hidden)]
    pub owned: bool,
    #[doc(hidden)]
    pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}

impl<'a> DragMoveEvent<'a> {
    #[allow(dead_code)]
    pub(crate) fn new_from_rc(ffi_data: RUDragMoveEvent) -> DragMoveEvent<'a> {
        DragMoveEvent {
            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: RUDragMoveEvent) -> DragMoveEvent<'a> {
        DragMoveEvent {
            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: RUDragMoveEvent) -> DragMoveEvent<'a> {
        DragMoveEvent {
            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 rectangle in the widget where the drop will occur if accepted.
    /// You can use this information to restrict drops to certain places on the
    /// widget.
    pub fn answer_rect(&self) -> Rect {
        let (obj_data, funcs) = self.get_drag_move_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).answer_rect)(obj_data);
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = Rect::new_from_rc(t);
            } else {
                ret_val = Rect::new_from_owned(t);
            }
            ret_val
        }
    }
    ///
    /// The same as accept(), but also notifies that future moves will
    /// also be acceptable if they remain within the *rectangle*
    /// given on the widget. This can improve performance, but may
    /// also be ignored by the underlying system.
    ///
    /// If the rectangle is empty, drag move events will be sent
    /// continuously. This is useful if the source is scrolling in a
    /// timer event.
    ///
    /// **Overloads**
    /// Calls QDropEvent::accept().
    pub fn accept(&self) -> &Self {
        let (obj_data, funcs) = self.get_drag_move_event_obj_funcs();
        unsafe {
            ((*funcs).accept)(obj_data);
        }
        self
    }
    ///
    /// **Overloads**
    /// Calls QDropEvent::ignore().
    ///
    /// The opposite of the accept(const QRect&) function.
    /// Moves within the *rectangle* are not acceptable, and will be
    /// ignored.
    pub fn ignore(&self) -> &Self {
        let (obj_data, funcs) = self.get_drag_move_event_obj_funcs();
        unsafe {
            ((*funcs).ignore)(obj_data);
        }
        self
    }
    ///
    /// The same as accept(), but also notifies that future moves will
    /// also be acceptable if they remain within the *rectangle*
    /// given on the widget. This can improve performance, but may
    /// also be ignored by the underlying system.
    ///
    /// If the rectangle is empty, drag move events will be sent
    /// continuously. This is useful if the source is scrolling in a
    /// timer event.
    ///
    /// **Overloads**
    /// Calls QDropEvent::accept().
    pub fn accept_2<R: RectTrait<'a>>(&self, r: &R) -> &Self {
        let (obj_r_1, _funcs) = r.get_rect_obj_funcs();

        let (obj_data, funcs) = self.get_drag_move_event_obj_funcs();
        unsafe {
            ((*funcs).accept_2)(obj_data, obj_r_1);
        }
        self
    }
    ///
    /// **Overloads**
    /// Calls QDropEvent::ignore().
    ///
    /// The opposite of the accept(const QRect&) function.
    /// Moves within the *rectangle* are not acceptable, and will be
    /// ignored.
    pub fn ignore_2<R: RectTrait<'a>>(&self, r: &R) -> &Self {
        let (obj_r_1, _funcs) = r.get_rect_obj_funcs();

        let (obj_data, funcs) = self.get_drag_move_event_obj_funcs();
        unsafe {
            ((*funcs).ignore_2)(obj_data, obj_r_1);
        }
        self
    }
    #[doc(hidden)]
    pub fn pos(&self) -> Point {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).pos)(obj_data);
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = Point::new_from_rc(t);
            } else {
                ret_val = Point::new_from_owned(t);
            }
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn pos_f(&self) -> Option<PointF> {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).pos_f)(obj_data);
            if ret_val.qt_data == ::std::ptr::null() {
                return None;
            }
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = PointF::new_from_rc(t);
            } else {
                ret_val = PointF::new_from_owned(t);
            }
            Some(ret_val)
        }
    }
    #[doc(hidden)]
    pub fn mouse_buttons(&self) -> MouseButtons {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).mouse_buttons)(obj_data);
            let ret_val = { transmute::<i32, MouseButtons>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn keyboard_modifiers(&self) -> KeyboardModifiers {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).keyboard_modifiers)(obj_data);
            let ret_val = { transmute::<i32, KeyboardModifiers>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn possible_actions(&self) -> DropActions {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).possible_actions)(obj_data);
            let ret_val = { transmute::<i32, DropActions>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn proposed_action(&self) -> DropAction {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).proposed_action)(obj_data);
            let ret_val = { transmute::<i32, DropAction>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn accept_proposed_action(&self) -> &Self {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            ((*funcs).accept_proposed_action)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn drop_action(&self) -> DropAction {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).drop_action)(obj_data);
            let ret_val = { transmute::<i32, DropAction>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn set_drop_action(&self, action: DropAction) -> &Self {
        let enum_action_1 = action as i32;

        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            ((*funcs).set_drop_action)(obj_data, enum_action_1);
        }
        self
    }
    #[doc(hidden)]
    pub fn source(&self) -> Option<Object> {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).source)(obj_data);
            if ret_val.qt_data == ::std::ptr::null() {
                return None;
            }
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = Object::new_from_rc(t);
            } else {
                ret_val = Object::new_from_owned(t);
            }
            Some(ret_val)
        }
    }
    #[doc(hidden)]
    pub fn mime_data(&self) -> Option<MimeData> {
        let (obj_data, funcs) = self.get_drop_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).mime_data)(obj_data);
            if ret_val.qt_data == ::std::ptr::null() {
                return None;
            }
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = MimeData::new_from_rc(t);
            } else {
                ret_val = MimeData::new_from_owned(t);
            }
            Some(ret_val)
        }
    }
    #[doc(hidden)]
    pub fn spontaneous(&self) -> bool {
        let (obj_data, funcs) = self.get_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).spontaneous)(obj_data);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn set_accepted(&self, accepted: bool) -> &Self {
        let (obj_data, funcs) = self.get_event_obj_funcs();
        unsafe {
            ((*funcs).set_accepted)(obj_data, accepted);
        }
        self
    }
    #[doc(hidden)]
    pub fn is_accepted(&self) -> bool {
        let (obj_data, funcs) = self.get_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).is_accepted)(obj_data);
            ret_val
        }
    }
}
pub trait DragMoveEventTrait<'a> {
    #[inline]
    #[doc(hidden)]
    fn get_drag_move_event_obj_funcs(&self) -> (*const RUBase, *const RUDragMoveEventFuncs);
}

impl<'a> EventTrait<'a> for DragMoveEvent<'a> {
    #[doc(hidden)]
    fn get_event_obj_funcs(&self) -> (*const RUBase, *const RUEventFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).event_funcs) }
    }
}

impl<'a> DropEventTrait<'a> for DragMoveEvent<'a> {
    #[doc(hidden)]
    fn get_drop_event_obj_funcs(&self) -> (*const RUBase, *const RUDropEventFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).drop_event_funcs) }
    }
}

impl<'a> DragMoveEventTrait<'a> for DragMoveEvent<'a> {
    #[doc(hidden)]
    fn get_drag_move_event_obj_funcs(&self) -> (*const RUBase, *const RUDragMoveEventFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).drag_move_event_funcs) }
    }
}