@@ -42,13 +42,15 @@ def __init__(self, parent, size):
42
42
43
43
self .svg_picture = None
44
44
self .svg_size = None
45
+ self .scale = 0
45
46
46
47
self .Bind (wx .EVT_LEFT_DOWN , self .on_mouse_left_down )
47
48
self .Bind (wx .EVT_LEFT_UP , self .on_mouse_left_up )
48
49
self .Bind (wx .EVT_MOTION , self .on_mouse_move )
49
50
self .Bind (wx .EVT_MOUSEWHEEL , self .on_mouse_wheel )
50
51
self .Bind (wx .EVT_PAINT , self .on_paint )
51
52
self .Bind (wx .EVT_SIZE , self .on_size )
53
+ self .Bind (wx .EVT_KEY_DOWN , self .on_key_down )
52
54
# Do nothing, to avoid flashing on MSW.
53
55
self .Bind (wx .EVT_ERASE_BACKGROUND , lambda x : None )
54
56
@@ -79,6 +81,16 @@ def on_paint(self, event):
79
81
80
82
self .SwapBuffers ()
81
83
84
+ def on_key_down (self , event ):
85
+ keycode = event .GetKeyCode ()
86
+ if (keycode == 43 ): # '+'
87
+ self .scale += 2
88
+ self .Refresh ()
89
+ if (keycode == 45 ): # '-'
90
+ self .scale -= 2
91
+ self .Refresh ()
92
+ event .Skip ()
93
+
82
94
def on_mouse_left_down (self , event ):
83
95
self .is_dragging = True
84
96
self .last_mouse_pos = (event .GetX (), event .GetY ())
@@ -148,9 +160,11 @@ def on_draw(self):
148
160
self .canvas .translate (self .offset_x , self .offset_y )
149
161
150
162
if self .svg_picture :
163
+ self .canvas .scale (1 + self .scale * 0.1 , 1 + self .scale * 0.1 )
151
164
self .canvas .translate (- self .svg_size .width ()/ 2 , - self .svg_size .height ()/ 2 )
152
165
self .svg_picture .render (self .canvas )
153
166
self .canvas .translate (self .svg_size .width ()/ 2 , self .svg_size .height ()/ 2 )
167
+ self .canvas .scale (1 / (1 + self .scale * 0.1 ), 1 / (1 + self .scale * 0.1 ))
154
168
155
169
self .canvas .restore ()
156
170
self .surface .flushAndSubmit ()
0 commit comments