use crate::event::{Event, EventType};
use wxdragon_sys as ffi;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScrollEventType {
Top,
Bottom,
LineUp,
LineDown,
PageUp,
PageDown,
ThumbTrack,
ThumbRelease,
Changed,
}
#[derive(Debug)]
pub struct ScrollEvent {
pub event: Event,
}
impl ScrollEvent {
pub fn new(event: Event) -> Self {
Self { event }
}
pub fn get_id(&self) -> i32 {
self.event.get_id()
}
pub fn get_position(&self) -> Option<i32> {
if self.event.is_null() {
return None;
}
let pos = unsafe { ffi::wxd_ScrollEvent_GetPosition(self.event.0) };
if pos == -1 { None } else { Some(pos) }
}
pub fn get_orientation(&self) -> Option<i32> {
if self.event.is_null() {
return None;
}
let orient = unsafe { ffi::wxd_ScrollEvent_GetOrientation(self.event.0) };
if orient == -1 { None } else { Some(orient) }
}
}
crate::implement_category_event_handlers!(ScrollEvents, ScrollEventType, ScrollEvent,
Top => scroll_top, EventType::SCROLL_TOP,
Bottom => scroll_bottom, EventType::SCROLL_BOTTOM,
LineUp => scroll_lineup, EventType::SCROLL_LINEUP,
LineDown => scroll_linedown, EventType::SCROLL_LINEDOWN,
PageUp => scroll_pageup, EventType::SCROLL_PAGEUP,
PageDown => scroll_pagedown, EventType::SCROLL_PAGEDOWN,
ThumbTrack => thumb_track, EventType::SCROLL_THUMBTRACK,
ThumbRelease => thumb_release, EventType::SCROLL_THUMBRELEASE,
Changed => scroll_changed, EventType::SCROLL_CHANGED
);