annotate page_layer.d @ 10:71ca82e0eb76

Checkpoint
author "David Bryant <bagnose@gmail.com>"
date Sat, 11 Jul 2009 22:49:41 +0930
parents
children fb571a3b1f0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
1 import icanvas;
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
2 import tk.geometry;
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
3 import cairo.Context;
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
4 import cairo_support;
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
5
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
6 interface Page {
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
7 }
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
8
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
9 class PageLayer : Layer, Page {
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
10 void draw(const Viewport viewport, in Rectangle damage, Context cr) const {
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
11 // Make the paper white, with a border
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
12
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
13 Point screen_page_left_bottom = viewport.model_to_screen(mPageLeftBottom);
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
14 Point screen_page_right_top = viewport.model_to_screen(mPageRightTop);
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
15
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
16 cr.setSourceRgba(1.0, 1.0, 1.0, 1.0);
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
17 draw_rectangle(cr, Rectangle(screen_page_left_bottom, screen_page_right_top));
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
18 cr.fill();
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
19
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
20 cr.setSourceRgba(0.0, 0.0, 0.0, 1.0);
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
21 draw_rectangle(cr, Rectangle(screen_page_left_bottom, screen_page_right_top));
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
22 cr.stroke();
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
23 }
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
24
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
25 private {
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
26 Point mPageLeftBottom; // model: bottom left corner of page
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
27 Point mPageRightTop; // model: top right corner of page
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
28 }
71ca82e0eb76 Checkpoint
"David Bryant <bagnose@gmail.com>"
parents:
diff changeset
29 }