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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
// 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**
///
/// Wheel events are sent to the widget under the mouse cursor, but
/// if that widget does not handle the event they are sent to the
/// focus widget. Wheel events are generated for both mouse wheels
/// and trackpad scroll gestures. There are two ways to read the
/// wheel event delta: angleDelta() returns the delta in wheel
/// degrees. This value is always provided. pixelDelta() returns
/// the delta in screen pixels and is available on platforms that
/// have high-resolution trackpads, such as MacOS . If that is the
/// case, source() will return Qt::MouseEventSynthesizedBySystem.
///
/// The functions pos() and globalPos() return the mouse cursor's
/// location at the time of the event.
///
/// A wheel event contains a special accept flag that indicates
/// whether the receiver wants the event. You should call ignore() if
/// you do not handle the wheel event; this ensures that it will be
/// sent to the parent widget.
///
/// The QWidget::setEnabled() function can be used to enable or
/// disable mouse and keyboard events for a widget.
///
/// The event handler QWidget::wheelEvent() receives wheel events.
///
/// **See also:** [`MouseEvent`]
/// [`Widget::grab_mouse`]
/// # 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 WheelEvent<'a> {
    #[doc(hidden)]
    pub data: Rc<Cell<Option<*const RUBase>>>,
    #[doc(hidden)]
    pub all_funcs: *const RUWheelEventAllFuncs,
    #[doc(hidden)]
    pub owned: bool,
    #[doc(hidden)]
    pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}

impl<'a> WheelEvent<'a> {
    #[allow(dead_code)]
    pub(crate) fn new_from_rc(ffi_data: RUWheelEvent) -> WheelEvent<'a> {
        WheelEvent {
            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: RUWheelEvent) -> WheelEvent<'a> {
        WheelEvent {
            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: RUWheelEvent) -> WheelEvent<'a> {
        WheelEvent {
            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 scrolling distance in pixels on screen. This value is
    /// provided on platforms that support high-resolution pixel-based
    /// delta values, such as MacOS . The value should be used directly
    /// to scroll content on screen.
    ///
    /// Example:
    ///
    /// **Note**: On platforms that support scrolling [phases](phase())
    /// , the delta may be null when:
    /// * scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
    /// * or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
    /// **Note**: On X11 this value is driver specific and unreliable, use angleDelta() instead
    pub fn pixel_delta(&self) -> Point {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).pixel_delta)(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
        }
    }
    ///
    /// Returns the distance that the wheel is rotated, in eighths of a
    /// degree. A positive value indicates that the wheel was rotated
    /// forwards away from the user; a negative value indicates that the
    /// wheel was rotated backwards toward the user.
    ///
    /// Most mouse types work in steps of 15 degrees, in which case the
    /// delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
    ///
    /// However, some mice have finer-resolution wheels and send delta values
    /// that are less than 120 units (less than 15 degrees). To support this
    /// possibility, you can either cumulatively add the delta values from events
    /// until the value of 120 is reached, then scroll the widget, or you can
    /// partially scroll the widget in response to each wheel event.
    ///
    /// Example:
    ///
    /// **Note**: On platforms that support scrolling [phases](phase())
    /// , the delta may be null when:
    /// * scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
    /// * or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
    pub fn angle_delta(&self) -> Point {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).angle_delta)(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
        }
    }
    ///
    /// This function has been deprecated, use pixelDelta() or angleDelta() instead.
    pub fn delta(&self) -> i32 {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).delta)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns the wheel's orientation.
    ///
    /// Use angleDelta() instead.
    pub fn orientation(&self) -> Orientation {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).orientation)(obj_data);
            let ret_val = { transmute::<i32, Orientation>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns the position of the mouse cursor relative to the widget
    /// that received the event.
    ///
    /// If you move your widgets around in response to mouse events,
    /// use globalPos() instead of this function.
    ///
    /// **See also:** [`x()`]
    /// [`y()`]
    /// [`global_pos()`]
    ///
    /// Returns the position of the mouse cursor relative to the widget
    /// that received the event.
    ///
    /// If you move your widgets around in response to mouse events,
    /// use globalPosF() instead of this function.
    ///
    /// **See also:** [`global_pos_f()`]
    pub fn pos(&self) -> Point {
        let (obj_data, funcs) = self.get_wheel_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
        }
    }
    ///
    /// Returns the global position of the mouse pointer *at the time
    /// of the event* . This is important on asynchronous window systems
    /// such as X11; whenever you move your widgets around in response to
    /// mouse events, globalPos() can differ a lot from the current
    /// cursor position returned by QCursor::pos().
    ///
    /// **See also:** [`global_x()`]
    /// [`global_y()`]
    ///
    /// Returns the global position of the mouse pointer *at the time
    /// of the event* . This is important on asynchronous window systems
    /// such as X11; whenever you move your widgets around in response to
    /// mouse events, globalPosF() can differ a lot from the current
    /// cursor position returned by QCursor::pos().
    ///
    /// **See also:** [`pos_f()`]
    pub fn global_pos(&self) -> Point {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).global_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
        }
    }
    ///
    /// Returns the x position of the mouse cursor, relative to the
    /// widget that received the event.
    ///
    /// **See also:** [`y()`]
    /// [`pos()`]
    pub fn x(&self) -> i32 {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).x)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns the y position of the mouse cursor, relative to the
    /// widget that received the event.
    ///
    /// **See also:** [`x()`]
    /// [`pos()`]
    pub fn y(&self) -> i32 {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).y)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns the global x position of the mouse cursor at the time of
    /// the event.
    ///
    /// **See also:** [`global_y()`]
    /// [`global_pos()`]
    pub fn global_x(&self) -> i32 {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).global_x)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns the global y position of the mouse cursor at the time of
    /// the event.
    ///
    /// **See also:** [`global_x()`]
    /// [`global_pos()`]
    pub fn global_y(&self) -> i32 {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).global_y)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns the position of the mouse cursor relative to the widget
    /// that received the event.
    ///
    /// If you move your widgets around in response to mouse events,
    /// use globalPosF() instead of this function.
    ///
    /// **See also:** [`global_pos_f()`]
    pub fn pos_f(&self) -> Option<PointF> {
        let (obj_data, funcs) = self.get_wheel_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)
        }
    }
    ///
    /// Returns the global position of the mouse pointer *at the time
    /// of the event* . This is important on asynchronous window systems
    /// such as X11; whenever you move your widgets around in response to
    /// mouse events, globalPosF() can differ a lot from the current
    /// cursor position returned by QCursor::pos().
    ///
    /// **See also:** [`pos_f()`]
    pub fn global_pos_f(&self) -> Option<PointF> {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).global_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)
        }
    }
    ///
    /// Returns the mouse state when the event occurred.
    pub fn buttons(&self) -> MouseButtons {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).buttons)(obj_data);
            let ret_val = { transmute::<i32, MouseButtons>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns the scrolling phase of this wheel event.
    ///
    /// **Note**: The Qt::ScrollBegin and Qt::ScrollEnd phases are currently
    /// supported only on MacOS .
    pub fn phase(&self) -> ScrollPhase {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).phase)(obj_data);
            let ret_val = { transmute::<i32, ScrollPhase>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns whether the delta values delivered with the event are inverted.
    ///
    /// Normally, a vertical wheel will produce a QWheelEvent with positive delta
    /// values if the top of the wheel is rotating away from the hand operating it.
    /// Similarly, a horizontal wheel movement will produce a QWheelEvent with
    /// positive delta values if the top of the wheel is moved to the left.
    ///
    /// However, on some platforms this is configurable, so that the same
    /// operations described above will produce negative delta values (but with the
    /// same magnitude). With the inverted property a wheel event consumer can
    /// choose to always follow the direction of the wheel, regardless of the
    /// system settings, but only for specific widgets. (One such use case could be
    /// that the user is rotating the wheel in the same direction as a visual
    /// Tumbler rotates. Another usecase is to make a slider handle follow the
    /// direction of movement of fingers on a touchpad regardless of system
    /// configuration.)
    ///
    /// **Note**: Many platforms provide no such information. On such platforms
    /// [inverted](inverted)
    /// always returns false.
    pub fn inverted(&self) -> bool {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).inverted)(obj_data);
            ret_val
        }
    }
    ///
    /// Returns information about the wheel event source.
    ///
    /// The source can be used to distinguish between events that come from a mouse
    /// with a physical wheel and events that are generated by some other means,
    /// such as a flick gesture on a touchpad.
    ///
    /// **Note**: Many platforms provide no such information. On such platforms
    /// [Qt::MouseEventNotSynthesized](Qt::MouseEventNotSynthesized)
    /// is returned always.
    ///
    /// **See also:** [`t::mouse_event_source()`]
    pub fn source(&self) -> MouseEventSource {
        let (obj_data, funcs) = self.get_wheel_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).source)(obj_data);
            let ret_val = { transmute::<i32, MouseEventSource>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn modifiers(&self) -> KeyboardModifiers {
        let (obj_data, funcs) = self.get_input_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).modifiers)(obj_data);
            let ret_val = { transmute::<i32, KeyboardModifiers>(ret_val) };
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn set_modifiers(&self, amodifiers: KeyboardModifiers) -> &Self {
        let enum_amodifiers_1 = amodifiers as i32;

        let (obj_data, funcs) = self.get_input_event_obj_funcs();
        unsafe {
            ((*funcs).set_modifiers)(obj_data, enum_amodifiers_1);
        }
        self
    }
    #[doc(hidden)]
    pub fn timestamp(&self) -> u64 {
        let (obj_data, funcs) = self.get_input_event_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).timestamp)(obj_data);
            ret_val
        }
    }
    #[doc(hidden)]
    pub fn set_timestamp(&self, atimestamp: u64) -> &Self {
        let (obj_data, funcs) = self.get_input_event_obj_funcs();
        unsafe {
            ((*funcs).set_timestamp)(obj_data, atimestamp);
        }
        self
    }
    #[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
        }
    }
    #[doc(hidden)]
    pub fn accept(&self) -> &Self {
        let (obj_data, funcs) = self.get_event_obj_funcs();
        unsafe {
            ((*funcs).accept)(obj_data);
        }
        self
    }
    #[doc(hidden)]
    pub fn ignore(&self) -> &Self {
        let (obj_data, funcs) = self.get_event_obj_funcs();
        unsafe {
            ((*funcs).ignore)(obj_data);
        }
        self
    }
}
pub trait WheelEventTrait<'a> {
    #[inline]
    #[doc(hidden)]
    fn get_wheel_event_obj_funcs(&self) -> (*const RUBase, *const RUWheelEventFuncs);
}

impl<'a> EventTrait<'a> for WheelEvent<'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> InputEventTrait<'a> for WheelEvent<'a> {
    #[doc(hidden)]
    fn get_input_event_obj_funcs(&self) -> (*const RUBase, *const RUInputEventFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).input_event_funcs) }
    }
}

impl<'a> WheelEventTrait<'a> for WheelEvent<'a> {
    #[doc(hidden)]
    fn get_wheel_event_obj_funcs(&self) -> (*const RUBase, *const RUWheelEventFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).wheel_event_funcs) }
    }
}
#[repr(u32)]
pub enum WheelEventFixMeEnums {
    DefaultDeltasPerStep,
}