72 lines
1.7 KiB
Rust
72 lines
1.7 KiB
Rust
fn draw_clear(cr: &cairo::Context, w: f64, h: f64)
|
|
{
|
|
use cairo::{FontSlant, FontWeight};
|
|
|
|
// set up for text
|
|
cr.select_font_face("Sans", FontSlant::Normal, FontWeight::Normal);
|
|
cr.set_font_size(14.0);
|
|
|
|
// clear view
|
|
cr.set_source_rgb(0.0, 0.0, 0.0);
|
|
cr.rectangle(0.0, 0.0, w, h);
|
|
cr.fill();
|
|
}
|
|
|
|
fn draw_map_none(cr: &cairo::Context, im: &gdk_pixbuf::Pixbuf, w: f64, h: f64)
|
|
{
|
|
let im_w = f64::from(im.get_width());
|
|
let im_h = f64::from(im.get_height());
|
|
|
|
// draw middle image
|
|
cr.set_source_pixbuf(im, w / 2.0 - im_w / 2.0, h / 2.0 - im_h / 2.0);
|
|
cr.paint();
|
|
|
|
// draw top border (these are separate so the bottom draws over the top)
|
|
cr.set_source_rgb(0.28, 0.0, 0.0);
|
|
cr.rectangle(0.0, 0.0, w, 18.0);
|
|
cr.fill();
|
|
|
|
// draw top text
|
|
cr.set_source_rgb(1.0, 0.0, 0.0);
|
|
cr.move_to(4.0, 14.0);
|
|
cr.show_text("Map Required To Proceed");
|
|
|
|
// draw bottom border
|
|
cr.set_source_rgb(0.28, 0.0, 0.0);
|
|
cr.rectangle(0.0, h - 18.0, w, h);
|
|
cr.fill();
|
|
|
|
// draw bottom text
|
|
cr.set_source_rgb(1.0, 0.0, 0.0);
|
|
cr.move_to(4.0, h - 4.0);
|
|
cr.show_text("CAS.qterm//CyberAcme Systems Inc.");
|
|
}
|
|
|
|
fn mk_draw_area(b: >k::Builder)
|
|
{
|
|
let area: gtk::DrawingArea = get_obj(b, "draw-area");
|
|
|
|
let ax: gtk::Adjustment = get_obj(b, "adj-map-horz");
|
|
let ay: gtk::Adjustment = get_obj(b, "adj-map-vert");
|
|
|
|
let im = load_img("/net/greyserv/maraiah/tycho/tycho1");
|
|
|
|
area.connect_draw(move |area, cr| {
|
|
let w = f64::from(area.get_allocated_width());
|
|
let h = f64::from(area.get_allocated_height());
|
|
|
|
ax.set_lower(0.0);
|
|
ax.set_upper(w);
|
|
|
|
ay.set_lower(0.0);
|
|
ay.set_upper(h);
|
|
|
|
draw_clear(&cr, w, h);
|
|
draw_map_none(&cr, &im, w, h);
|
|
|
|
Inhibit(true)
|
|
});
|
|
}
|
|
|
|
// EOF
|