Function push_clip

Source
pub fn push_clip(x: i32, y: i32, w: i32, h: i32)
Expand description

Limits drawing to a region

Examples found in repository?
examples/table.rs (line 47)
46fn draw_header(txt: &str, x: i32, y: i32, w: i32, h: i32) {
47    draw::push_clip(x, y, w, h);
48    draw::draw_box(
49        enums::FrameType::ThinUpBox,
50        x,
51        y,
52        w,
53        h,
54        enums::Color::FrameDefault,
55    );
56    draw::set_draw_color(enums::Color::Black);
57    draw::set_font(enums::Font::Helvetica, 14);
58    draw::draw_text_boxed(txt, x, y, w, h, enums::Align::Center);
59    draw::pop_clip();
60}
61
62// The selected flag sets the color of the cell to a grayish color, otherwise white
63fn draw_data(txt: &str, x: i32, y: i32, w: i32, h: i32, selected: bool) {
64    draw::push_clip(x, y, w, h);
65    if selected {
66        draw::set_draw_color(enums::Color::from_u32(0x00D3_D3D3));
67    } else {
68        draw::set_draw_color(enums::Color::White);
69    }
70    draw::draw_rectf(x, y, w, h);
71    draw::set_draw_color(enums::Color::Gray0);
72    draw::set_font(enums::Font::Helvetica, 14);
73    draw::draw_text_boxed(txt, x, y, w, h, enums::Align::Center);
74    draw::draw_rect(x, y, w, h);
75    draw::pop_clip();
76}
More examples
Hide additional examples
examples/spreadsheet.rs (line 113)
112    fn draw_header(txt: &str, x: i32, y: i32, w: i32, h: i32) {
113        draw::push_clip(x, y, w, h);
114        draw::draw_box(
115            enums::FrameType::ThinUpBox,
116            x,
117            y,
118            w,
119            h,
120            enums::Color::FrameDefault,
121        );
122        draw::set_draw_color(enums::Color::Black);
123        draw::set_font(enums::Font::Helvetica, 14);
124        draw::draw_text_boxed(txt, x, y, w, h, enums::Align::Center);
125        draw::pop_clip();
126    }
127
128    // The selected flag sets the color of the cell to a grayish color, otherwise white
129    fn draw_data(txt: &str, x: i32, y: i32, w: i32, h: i32, selected: bool) {
130        draw::push_clip(x, y, w, h);
131        if selected {
132            draw::set_draw_color(enums::Color::from_u32(0x00D3_D3D3));
133        } else {
134            draw::set_draw_color(enums::Color::White);
135        }
136        draw::draw_rectf(x, y, w, h);
137        draw::set_draw_color(enums::Color::Gray0);
138        draw::set_font(enums::Font::Helvetica, 14);
139        draw::draw_text_boxed(txt, x, y, w, h, enums::Align::Center);
140        draw::draw_rect(x, y, w, h);
141        draw::pop_clip();
142    }