Mercurial > projects > doodle
comparison doodle/dia/icanvas.d @ 28:1754cb773d41
Part-way through getting to compile with configure/builder.
author | Graham St Jack <graham.stjack@internode.on.net> |
---|---|
date | Sun, 02 Aug 2009 16:27:21 +0930 |
parents | dia/icanvas.d@f3d91579bb28 |
children | c2f11e1d7470 |
comparison
equal
deleted
inserted
replaced
27:f3d91579bb28 | 28:1754cb773d41 |
---|---|
1 module doodle.dia.icanvas; | |
2 | |
3 public { | |
4 import doodle.tk.geometry; | |
5 import doodle.tk.events; | |
6 import cairo.Context; | |
7 } | |
8 | |
9 private { | |
10 import std.typecons; | |
11 } | |
12 | |
13 mixin(defineEnum!("Cursor", | |
14 "DEFAULT", "HAND", "CROSSHAIR")); | |
15 | |
16 interface Viewport { | |
17 void zoom_relative(in Point pixel_datum, in double factor); | |
18 void pan_relative(in Vector pixel_displacement); | |
19 void set_cursor(in Cursor cursor); | |
20 void damage_model(in Rectangle area); // FIXME could be an inout parameter of the event handling, or a special scope Damage object that supports growth only | |
21 void damage_pixel(in Rectangle area); // FIXME as above | |
22 | |
23 /* | |
24 // FIXME not sure about these: | |
25 double zoom() const; | |
26 Point model_to_pixel(in Point model) const; | |
27 Point pixel_to_model(in Point pixel) const; | |
28 Vector model_to_pixel(in Vector model) const; | |
29 Vector pixel_to_model(in Vector pixel) const; | |
30 Rectangle model_to_pixel(in Rectangle model) const; | |
31 Rectangle pixel_to_model(in Rectangle model) const; | |
32 double model_to_pixel(in double model) const; | |
33 double pixel_to_model(in double pixel) const; | |
34 */ | |
35 } | |
36 | |
37 interface EventHandler { | |
38 bool handle_button_press(scope Viewport viewport, in ButtonEvent event); | |
39 bool handle_button_release(scope Viewport viewport, in ButtonEvent event); | |
40 bool handle_motion(scope Viewport viewport, in MotionEvent event); | |
41 bool handle_scroll(scope Viewport viewport, in ScrollEvent event); | |
42 //bool handle_enter(scope Viewport viewport, CrossingEvent event); | |
43 //bool handle_leave(scope Viewport viewport, CrossingEvent event); | |
44 //bool handle_focus_in(scope Viewport viewport, FocusEvent event); | |
45 //bool handle_focus_out(scope Viewport viewport, FocusEvent event); | |
46 bool handle_key_press(scope Viewport viewport, in KeyEvent event); | |
47 bool handle_key_release(scope Viewport viewport, in KeyEvent event); | |
48 } | |
49 | |
50 abstract class Layer { | |
51 this(in string name) { | |
52 mName = name; | |
53 } | |
54 | |
55 string name() const { return mName; } | |
56 | |
57 Rectangle bounds() const; | |
58 //void zoom_changed | |
59 void draw(in Viewport viewport, | |
60 in Rectangle pixel_damage, scope Context pixel_cr, | |
61 in Rectangle model_damage, scope Context model_cr) const; | |
62 | |
63 private { | |
64 invariant string mName; | |
65 } | |
66 } |