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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::Rectangle;
use glib::translate::*;

/// Generated when all or part of a window becomes visible and needs to be
/// redrawn.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EventExpose(crate::Event);

event_wrapper!(EventExpose, GdkEventExpose);
event_subtype!(EventExpose, ffi::GDK_EXPOSE | ffi::GDK_DAMAGE);

impl EventExpose {
    #[doc(alias = "get_region")]
    pub fn region(&self) -> Option<cairo::Region> {
        unsafe { from_glib_none(self.as_ref().region) }
    }

    #[doc(alias = "get_count")]
    pub fn count(&self) -> u32 {
        self.as_ref().count as u32
    }

    #[doc(alias = "get_area")]
    pub fn area(&self) -> Rectangle {
        unsafe { from_glib_none(&self.as_ref().area as *const _) }
    }
}