wxruby3-shapes 0.9.0.pre.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/CREDITS.md +18 -0
- data/INSTALL.md +39 -0
- data/LICENSE +21 -0
- data/README.md +118 -0
- data/assets/screenshot.png +0 -0
- data/bin/wx-shapes +9 -0
- data/lib/wx/shapes/arrow_base.rb +86 -0
- data/lib/wx/shapes/arrows/circle_arrow.rb +39 -0
- data/lib/wx/shapes/arrows/diamond_arrow.rb +33 -0
- data/lib/wx/shapes/arrows/open_arrow.rb +56 -0
- data/lib/wx/shapes/arrows/solid_arrow.rb +69 -0
- data/lib/wx/shapes/art/shape_canvas/page.xpm +73 -0
- data/lib/wx/shapes/auto_layout.rb +358 -0
- data/lib/wx/shapes/base.rb +33 -0
- data/lib/wx/shapes/canvas_history.rb +84 -0
- data/lib/wx/shapes/connection_point.rb +238 -0
- data/lib/wx/shapes/core.rb +19 -0
- data/lib/wx/shapes/diagram.rb +659 -0
- data/lib/wx/shapes/events.rb +389 -0
- data/lib/wx/shapes/printout.rb +136 -0
- data/lib/wx/shapes/serializable.rb +440 -0
- data/lib/wx/shapes/serialize/core.rb +40 -0
- data/lib/wx/shapes/serialize/id.rb +82 -0
- data/lib/wx/shapes/serialize/wx.rb +104 -0
- data/lib/wx/shapes/serializer/json.rb +258 -0
- data/lib/wx/shapes/serializer/yaml.rb +125 -0
- data/lib/wx/shapes/shape.rb +2129 -0
- data/lib/wx/shapes/shape_canvas.rb +3285 -0
- data/lib/wx/shapes/shape_data_object.rb +43 -0
- data/lib/wx/shapes/shape_handle.rb +287 -0
- data/lib/wx/shapes/shape_list.rb +161 -0
- data/lib/wx/shapes/shapes/bitmap_shape.rb +257 -0
- data/lib/wx/shapes/shapes/circle_shape.rb +136 -0
- data/lib/wx/shapes/shapes/control_shape.rb +483 -0
- data/lib/wx/shapes/shapes/curve_shape.rb +231 -0
- data/lib/wx/shapes/shapes/diamond_shape.rb +62 -0
- data/lib/wx/shapes/shapes/edit_text_shape.rb +317 -0
- data/lib/wx/shapes/shapes/ellipse_shape.rb +106 -0
- data/lib/wx/shapes/shapes/flex_grid_shape.rb +78 -0
- data/lib/wx/shapes/shapes/grid_shape.rb +404 -0
- data/lib/wx/shapes/shapes/line_shape.rb +907 -0
- data/lib/wx/shapes/shapes/multi_sel_rect.rb +214 -0
- data/lib/wx/shapes/shapes/ortho_shape.rb +357 -0
- data/lib/wx/shapes/shapes/polygon_shape.rb +294 -0
- data/lib/wx/shapes/shapes/rect_shape.rb +378 -0
- data/lib/wx/shapes/shapes/round_ortho_shape.rb +131 -0
- data/lib/wx/shapes/shapes/round_rect_shape.rb +142 -0
- data/lib/wx/shapes/shapes/square_shape.rb +119 -0
- data/lib/wx/shapes/shapes/text_shape.rb +324 -0
- data/lib/wx/shapes/thumbnail.rb +234 -0
- data/lib/wx/shapes/version.rb +12 -0
- data/lib/wx/shapes/wx.rb +29 -0
- data/lib/wx/shapes.rb +18 -0
- data/lib/wx/wx-shapes/base.rb +87 -0
- data/lib/wx/wx-shapes/cmd/sampler.rb +58 -0
- data/lib/wx/wx-shapes/cmd/test.rb +27 -0
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +7 -0
- data/rakelib/yard/templates/default/layout/html/setup.rb +5 -0
- data/rakelib/yard/yard/relative_markdown_links/version.rb +8 -0
- data/rakelib/yard/yard/relative_markdown_links.rb +39 -0
- data/rakelib/yard/yard-custom-templates.rb +2 -0
- data/rakelib/yard/yard-relative_markdown_links.rb +4 -0
- data/samples/demo/art/AlignBottom.xpm +35 -0
- data/samples/demo/art/AlignCenter.xpm +35 -0
- data/samples/demo/art/AlignLeft.xpm +35 -0
- data/samples/demo/art/AlignMiddle.xpm +35 -0
- data/samples/demo/art/AlignRight.xpm +35 -0
- data/samples/demo/art/AlignTop.xpm +35 -0
- data/samples/demo/art/Bitmap.xpm +25 -0
- data/samples/demo/art/Circle.xpm +22 -0
- data/samples/demo/art/Curve.xpm +21 -0
- data/samples/demo/art/Diamond.xpm +22 -0
- data/samples/demo/art/EditText.xpm +21 -0
- data/samples/demo/art/Ellipse.xpm +22 -0
- data/samples/demo/art/FixedRect.xpm +22 -0
- data/samples/demo/art/FlexGrid.xpm +22 -0
- data/samples/demo/art/GC.xpm +23 -0
- data/samples/demo/art/Grid.xpm +22 -0
- data/samples/demo/art/Line.xpm +21 -0
- data/samples/demo/art/NoSource.xpm +69 -0
- data/samples/demo/art/OrthoLine.xpm +21 -0
- data/samples/demo/art/Rect.xpm +22 -0
- data/samples/demo/art/RoundOrthoLine.xpm +21 -0
- data/samples/demo/art/RoundRect.xpm +22 -0
- data/samples/demo/art/Shadow.xpm +23 -0
- data/samples/demo/art/StandAloneLine.xpm +22 -0
- data/samples/demo/art/Text.xpm +21 -0
- data/samples/demo/art/Tool.xpm +23 -0
- data/samples/demo/art/sample.xpm +251 -0
- data/samples/demo/demo.rb +658 -0
- data/samples/demo/frame_canvas.rb +422 -0
- data/samples/demo/images/motyl.bmp +0 -0
- data/samples/demo/images/motyl2.bmp +0 -0
- data/samples/sample1/art/sample.xpm +251 -0
- data/samples/sample1/sample.rb +263 -0
- data/samples/sample2/art/sample.xpm +251 -0
- data/samples/sample2/sample.rb +133 -0
- data/samples/sample2/sample_canvas.rb +35 -0
- data/samples/sample2/sample_shape.rb +108 -0
- data/samples/sample3/art/sample.xpm +251 -0
- data/samples/sample3/sample.rb +281 -0
- data/samples/sample4/art/sample.xpm +251 -0
- data/samples/sample4/sample.rb +180 -0
- data/tests/art/motyl.bmp +0 -0
- data/tests/lib/wxapp_runner.rb +64 -0
- data/tests/serializer_tests.rb +521 -0
- data/tests/test_grid_shapes.rb +42 -0
- data/tests/test_serialize.rb +7 -0
- data/tests/test_serialize_yaml.rb +17 -0
- metadata +242 -0
@@ -0,0 +1,389 @@
|
|
1
|
+
# Wx::SF event classes
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
|
+
|
4
|
+
module Wx::SF
|
5
|
+
|
6
|
+
# Class encapsulates generic Wx::SF shape's event.
|
7
|
+
class ShapeEvent < Wx::Event
|
8
|
+
# Constructor
|
9
|
+
# @param [Integer] evt_type
|
10
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
11
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
12
|
+
super(evt_type, id.to_i)
|
13
|
+
@shape = nil
|
14
|
+
@vetoed = false
|
15
|
+
end
|
16
|
+
|
17
|
+
# Insert a shape object to the event object.
|
18
|
+
# @param [Wx::SF::Shape] shape shape object
|
19
|
+
def set_shape(shape)
|
20
|
+
@shape = shape
|
21
|
+
end
|
22
|
+
alias :shape= :set_shape
|
23
|
+
|
24
|
+
# Get a shape object from the event object.
|
25
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
26
|
+
def get_shape
|
27
|
+
@shape
|
28
|
+
end
|
29
|
+
alias :shape :get_shape
|
30
|
+
|
31
|
+
# Check if the event has been vetoed or not.
|
32
|
+
# @return [Boolean] true if the event has been vetoed.
|
33
|
+
def is_vetoed
|
34
|
+
@vetoed
|
35
|
+
end
|
36
|
+
alias :vetoed? :is_vetoed
|
37
|
+
|
38
|
+
# Set the veto flag to true.
|
39
|
+
def veto
|
40
|
+
@vetoed = true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Class encapsulates Wx::SF shape's key down event.
|
45
|
+
class ShapeKeyEvent < Wx::Event
|
46
|
+
# Constructor
|
47
|
+
# @param [Integer] evt_type
|
48
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
49
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
50
|
+
super(evt_type, id.to_i)
|
51
|
+
@shape = nil
|
52
|
+
@key_code = 0
|
53
|
+
end
|
54
|
+
|
55
|
+
# Insert a shape object to the event object.
|
56
|
+
# @param [Wx::SF::Shape] shape shape object
|
57
|
+
def set_shape(shape)
|
58
|
+
@shape = shape
|
59
|
+
end
|
60
|
+
alias :shape= :set_shape
|
61
|
+
|
62
|
+
# Get a shape object from the event object.
|
63
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
64
|
+
def get_shape
|
65
|
+
@shape
|
66
|
+
end
|
67
|
+
alias :shape :get_shape
|
68
|
+
|
69
|
+
# Set key code.
|
70
|
+
# @param [Integer] key_code Code of pressed key
|
71
|
+
def set_key_code(key_code)
|
72
|
+
@key_code = key_code
|
73
|
+
end
|
74
|
+
alias :key_code= :set_key_code
|
75
|
+
|
76
|
+
# Get key code.
|
77
|
+
# @return Code of pressed key
|
78
|
+
def get_key_code
|
79
|
+
@key_code
|
80
|
+
end
|
81
|
+
alias :key_code :get_key_code
|
82
|
+
end
|
83
|
+
|
84
|
+
# Class encapsulates Wx::SF shape's mouse event.
|
85
|
+
class ShapeMouseEvent < Wx::Event
|
86
|
+
# Constructor
|
87
|
+
# @param [Integer] evt_type
|
88
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
89
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
90
|
+
super(evt_type, id.to_i)
|
91
|
+
@shape = nil
|
92
|
+
@mouse_pos = Wx::DEFAULT_POSITION
|
93
|
+
end
|
94
|
+
|
95
|
+
# Insert a shape object to the event object.
|
96
|
+
# @param [Wx::SF::Shape] shape shape object
|
97
|
+
def set_shape(shape)
|
98
|
+
@shape = shape
|
99
|
+
end
|
100
|
+
alias :shape= :set_shape
|
101
|
+
|
102
|
+
# Get a shape object from the event object.
|
103
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
104
|
+
def get_shape
|
105
|
+
@shape
|
106
|
+
end
|
107
|
+
alias :shape :get_shape
|
108
|
+
|
109
|
+
# Set absolute position of mouse cursor.
|
110
|
+
# @param [Wx::Point] mouse_position Mouse cursor's absolute position
|
111
|
+
def set_mouse_position(mouse_position)
|
112
|
+
@mouse_position = mouse_position.to_point
|
113
|
+
end
|
114
|
+
alias :mouse_position= :set_mouse_position
|
115
|
+
|
116
|
+
# Get absolute position of mouse cursor
|
117
|
+
# @return [Wx::Point] Mouse cursor's absolute position
|
118
|
+
def get_mouse_position
|
119
|
+
@mouse_position
|
120
|
+
end
|
121
|
+
alias :mouse_position :get_mouse_position
|
122
|
+
end
|
123
|
+
|
124
|
+
# Class encapsulates Wx::SF shape text change event.
|
125
|
+
class ShapeTextEvent < Wx::Event
|
126
|
+
# Constructor
|
127
|
+
# @param [Integer] evt_type
|
128
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
129
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
130
|
+
super(evt_type, id.to_i)
|
131
|
+
@shape = nil
|
132
|
+
@text = ''
|
133
|
+
end
|
134
|
+
|
135
|
+
# Insert a shape object to the event object.
|
136
|
+
# @param [Wx::SF::Shape] shape shape object
|
137
|
+
def set_shape(shape)
|
138
|
+
@shape = shape
|
139
|
+
end
|
140
|
+
alias :shape= :set_shape
|
141
|
+
|
142
|
+
# Get a shape object from the event object.
|
143
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
144
|
+
def get_shape
|
145
|
+
@shape
|
146
|
+
end
|
147
|
+
alias :shape :get_shape
|
148
|
+
|
149
|
+
# Set new shape text
|
150
|
+
# @param [String] text new text
|
151
|
+
def set_text(text)
|
152
|
+
@text = text
|
153
|
+
end
|
154
|
+
alias :text= :set_text
|
155
|
+
|
156
|
+
# Get shape text
|
157
|
+
# @return [String] shape text
|
158
|
+
def get_text
|
159
|
+
@text
|
160
|
+
end
|
161
|
+
alias :text :get_text
|
162
|
+
end
|
163
|
+
|
164
|
+
# Class encapsulates Wx::SF shape handle related event.
|
165
|
+
class ShapeHandleEvent < Wx::Event
|
166
|
+
# Constructor
|
167
|
+
# @param [Integer] evt_type
|
168
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
169
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
170
|
+
super(evt_type, id.to_i)
|
171
|
+
@shape = nil
|
172
|
+
@handle = nil
|
173
|
+
end
|
174
|
+
|
175
|
+
# Insert a shape object to the event object.
|
176
|
+
# @param [Wx::SF::Shape] shape shape object
|
177
|
+
def set_shape(shape)
|
178
|
+
@shape = shape
|
179
|
+
end
|
180
|
+
alias :shape= :set_shape
|
181
|
+
|
182
|
+
# Get a shape object from the event object.
|
183
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
184
|
+
def get_shape
|
185
|
+
@shape
|
186
|
+
end
|
187
|
+
alias :shape :get_shape
|
188
|
+
|
189
|
+
# Set dragged shape handle
|
190
|
+
# @param [Wx::Shape::Handle] handle shape handle
|
191
|
+
def set_handle(handle)
|
192
|
+
@handle = handle
|
193
|
+
end
|
194
|
+
alias :handle= :set_handle
|
195
|
+
|
196
|
+
# Get shape handle
|
197
|
+
# @return [Wx::SF::Shape::Handle] shape handle
|
198
|
+
def get_handle
|
199
|
+
@handle
|
200
|
+
end
|
201
|
+
alias :handle :get_handle
|
202
|
+
end
|
203
|
+
|
204
|
+
if Wx.has_feature?(:USE_DRAG_AND_DROP)
|
205
|
+
|
206
|
+
# Class encapsulates Wx::SF shape on drop event.
|
207
|
+
class ShapeDropEvent < Wx::Event
|
208
|
+
# Constructor
|
209
|
+
# @param [Integer] evt_type
|
210
|
+
# @param [Integer] x
|
211
|
+
# @param [Integer] y
|
212
|
+
# @param [Wx::SF::ShapeCanvas] target
|
213
|
+
# @param [Wx::DragResult] def_result
|
214
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
215
|
+
def initialize(evt_type = Wx::EVT_NULL, x = 0, y = 0, target = nil, def_result = Wx::DragResult::DragNone, id = 0)
|
216
|
+
super(evt_type, id.to_i)
|
217
|
+
@dropped_shapes = []
|
218
|
+
@drop_position = Wx::Point.new(x, y)
|
219
|
+
@drop_target = target
|
220
|
+
@drag_result = def_result
|
221
|
+
end
|
222
|
+
|
223
|
+
# Add given shapes to dropped shapes list.
|
224
|
+
# @param [Array<Wx::SF::Shape>] shapes shape list
|
225
|
+
def set_dropped_shapes(shapes)
|
226
|
+
@dropped_shapes.concat(shapes)
|
227
|
+
end
|
228
|
+
alias :dropped_shapes= :set_dropped_shapes
|
229
|
+
|
230
|
+
# Get list of dropped shapes
|
231
|
+
# @return [Array<Wx::SF::Shape>] shape list
|
232
|
+
def get_dropped_shapes
|
233
|
+
@dropped_shapes
|
234
|
+
end
|
235
|
+
alias :dropped_shapes :get_dropped_shapes
|
236
|
+
|
237
|
+
# Set position where shapes were dropped
|
238
|
+
# @param [Wx::Point] pos drop position
|
239
|
+
def set_drop_position(pos)
|
240
|
+
@drop_position = pos.to_point
|
241
|
+
end
|
242
|
+
alias :drop_position= :set_drop_position
|
243
|
+
|
244
|
+
# Get drop position
|
245
|
+
# @return [Wx::Point] drop position
|
246
|
+
def get_drop_position
|
247
|
+
@drop_position
|
248
|
+
end
|
249
|
+
alias :drop_position :get_drop_position
|
250
|
+
|
251
|
+
# Set target (shape canvas) where shapes were dropped
|
252
|
+
# @param [Wx::SF::ShapeCanvas] trg drop target
|
253
|
+
def set_drop_target(trg)
|
254
|
+
@drop_target = trg
|
255
|
+
end
|
256
|
+
alias :drop_target= :set_drop_target
|
257
|
+
|
258
|
+
# Get drop target
|
259
|
+
# @return [Wx::SF::ShapeCanvas] drop target
|
260
|
+
def get_drop_target
|
261
|
+
@drop_target
|
262
|
+
end
|
263
|
+
alias :drop_target :get_drop_target
|
264
|
+
|
265
|
+
# Set drag result
|
266
|
+
# @param [Wx::DragResult] dr drag result
|
267
|
+
def set_drag_result(dr)
|
268
|
+
@drag_result = dr
|
269
|
+
end
|
270
|
+
alias :drag_result= :set_drag_result
|
271
|
+
|
272
|
+
# Get drag result
|
273
|
+
# @return [Wx::DragResult] drag result
|
274
|
+
def get_drag_result
|
275
|
+
@drag_result
|
276
|
+
end
|
277
|
+
alias :drag_result :get_drag_result
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
# Class encapsulates Wx::SF shape paste event.
|
283
|
+
class ShapePasteEvent < Wx::Event
|
284
|
+
# Constructor
|
285
|
+
# @param [Integer] evt_type
|
286
|
+
# @param [Wx::SF::ShapeCanvas] target
|
287
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
288
|
+
def initialize(evt_type = Wx::EVT_NULL, target = nil, id = 0)
|
289
|
+
super(evt_type, id.to_i)
|
290
|
+
@pasted_shapes = []
|
291
|
+
@drop_target = target
|
292
|
+
end
|
293
|
+
|
294
|
+
# Add given shapes to pasted shapes list.
|
295
|
+
# @param [Array<Wx::SF::Shape>] shapes shape list
|
296
|
+
def set_pasted_shapes(shapes)
|
297
|
+
@pasted_shapes.concat(shapes)
|
298
|
+
end
|
299
|
+
alias :pasted_shapes= :set_pasted_shapes
|
300
|
+
|
301
|
+
# Get list of pasted shapes
|
302
|
+
# @return [Array<Wx::SF::Shape>] shape list
|
303
|
+
def get_pasted_shapes
|
304
|
+
@pasted_shapes
|
305
|
+
end
|
306
|
+
alias :pasted_shapes :get_pasted_shapes
|
307
|
+
|
308
|
+
# Set target (shape canvas) where shapes are pasted
|
309
|
+
# @param [Wx::SF::ShapeCanvas] trg drop target
|
310
|
+
def set_drop_target(trg)
|
311
|
+
@drop_target = trg
|
312
|
+
end
|
313
|
+
alias :drop_target= :set_drop_target
|
314
|
+
|
315
|
+
# Get drop target
|
316
|
+
# @return [Wx::SF::ShapeCanvas] drop target
|
317
|
+
def get_drop_target
|
318
|
+
@drop_target
|
319
|
+
end
|
320
|
+
alias :drop_target :get_drop_target
|
321
|
+
end
|
322
|
+
|
323
|
+
# Class encapsulates Wx::SF shape child drop event.
|
324
|
+
class ShapeChildDropEvent < Wx::Event
|
325
|
+
# Constructor
|
326
|
+
# @param [Integer] evt_type
|
327
|
+
# @param [Wx::SF::Serializable::ID, Integer] id
|
328
|
+
def initialize(evt_type = Wx::EVT_NULL, id = 0)
|
329
|
+
super(evt_type, id.to_i)
|
330
|
+
@shape = nil
|
331
|
+
@child = nil
|
332
|
+
end
|
333
|
+
|
334
|
+
# Insert a shape object to the event object.
|
335
|
+
# @param [Wx::SF::Shape] shape shape object
|
336
|
+
def set_shape(shape)
|
337
|
+
@shape = shape
|
338
|
+
end
|
339
|
+
alias :shape= :set_shape
|
340
|
+
|
341
|
+
# Get a shape object from the event object.
|
342
|
+
# @return [Wx::SF::Shape,nil] shape object.
|
343
|
+
def get_shape
|
344
|
+
@shape
|
345
|
+
end
|
346
|
+
alias :shape :get_shape
|
347
|
+
|
348
|
+
# Set dropped child shape
|
349
|
+
# @param [Wx::SF::Shape] child child shape object
|
350
|
+
def set_child_shape(child)
|
351
|
+
@child = child
|
352
|
+
end
|
353
|
+
alias :child_shape= :set_child_shape
|
354
|
+
|
355
|
+
# Get child shape object from the event object.
|
356
|
+
# @return [Wx::SF::Shape,nil] child shape object.
|
357
|
+
def get_child_shape
|
358
|
+
@child
|
359
|
+
end
|
360
|
+
alias :child_shape :get_child_shape
|
361
|
+
end
|
362
|
+
|
363
|
+
EVT_SF_LINE_DONE = Wx::EvtHandler.register_class(ShapeEvent, nil, 'evt_sf_line_done', 0)
|
364
|
+
EVT_SF_TEXT_CHANGE = Wx::EvtHandler.register_class(ShapeTextEvent, nil, 'evt_sf_text_change', 0)
|
365
|
+
if Wx.has_feature?(:USE_DRAG_AND_DROP)
|
366
|
+
EVT_SF_ON_DROP = Wx::EvtHandler.register_class(ShapeDropEvent, nil, 'evt_sf_on_drop', 0)
|
367
|
+
end
|
368
|
+
EVT_SF_ON_PASTE = Wx::EvtHandler.register_class(ShapePasteEvent, nil, 'evt_sf_on_paste', 0)
|
369
|
+
EVT_SF_SHAPE_LEFT_DOWN = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_left_down', 0)
|
370
|
+
EVT_SF_SHAPE_LEFT_DCLICK = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_left_dclick', 0)
|
371
|
+
EVT_SF_SHAPE_RIGHT_DOWN = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_right_down', 0)
|
372
|
+
EVT_SF_SHAPE_RIGHT_DCLICK = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_right_dclick', 0)
|
373
|
+
EVT_SF_SHAPE_DRAG_BEGIN = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_drag_begin', 0)
|
374
|
+
EVT_SF_SHAPE_DRAG = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_drag', 0)
|
375
|
+
EVT_SF_SHAPE_DRAG_END = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_drag_end', 0)
|
376
|
+
EVT_SF_SHAPE_HANDLE_BEGIN = Wx::EvtHandler.register_class(ShapeHandleEvent, nil, 'evt_sf_shape_handle_begin', 0)
|
377
|
+
EVT_SF_SHAPE_HANDLE = Wx::EvtHandler.register_class(ShapeHandleEvent, nil, 'evt_sf_shape_handle', 0)
|
378
|
+
EVT_SF_SHAPE_HANDLE_END = Wx::EvtHandler.register_class(ShapeHandleEvent, nil, 'evt_sf_shape_handle_end', 0)
|
379
|
+
EVT_SF_SHAPE_KEYDOWN = Wx::EvtHandler.register_class(ShapeKeyEvent, nil, 'evt_sf_shape_keydown', 0)
|
380
|
+
EVT_SF_SHAPE_MOUSE_ENTER = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_mouse_enter', 0)
|
381
|
+
EVT_SF_SHAPE_MOUSE_OVER = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_mouse_over', 0)
|
382
|
+
EVT_SF_SHAPE_MOUSE_LEAVE = Wx::EvtHandler.register_class(ShapeMouseEvent, nil, 'evt_sf_shape_mouse_leave', 0)
|
383
|
+
EVT_SF_SHAPE_CHILD_DROP = Wx::EvtHandler.register_class(ShapeChildDropEvent, nil, 'evt_sf_shape_child_drop', 0)
|
384
|
+
EVT_SF_LINE_BEFORE_DONE = Wx::EvtHandler.register_class(ShapeEvent, nil, 'evt_sf_line_before_done', 0)
|
385
|
+
EVT_SF_LINE_HANDLE_ADD = Wx::EvtHandler.register_class(ShapeHandleEvent, nil, 'evt_sf_line_handle_add', 0)
|
386
|
+
EVT_SF_LINE_HANDLE_REMOVE = Wx::EvtHandler.register_class(ShapeHandleEvent, nil, 'evt_sf_line_handle_remove', 0)
|
387
|
+
EVT_SF_SHAPE_SIZE_CHANGED = Wx::EvtHandler.register_class(ShapeEvent, nil, 'evt_sf_shape_size_changed', 0)
|
388
|
+
|
389
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Wx::SF::Printout - printout class
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
|
+
|
4
|
+
module Wx::SF
|
5
|
+
|
6
|
+
class Printout < Wx::PRT::Printout
|
7
|
+
|
8
|
+
# Constructor.
|
9
|
+
# @param [String] title
|
10
|
+
# @param [ShapeCanvas] canvas canvas to print
|
11
|
+
def initialize(title, canvas)
|
12
|
+
super(title)
|
13
|
+
@canvas = canvas
|
14
|
+
end
|
15
|
+
|
16
|
+
# Access (set/get) canvas (to be) printed.
|
17
|
+
attr_accessor :canvas
|
18
|
+
|
19
|
+
# Called by printing framework. Functions TRUE if a page of given index already exists in printed document.
|
20
|
+
# This function can be overridden if necessary.
|
21
|
+
def has_page(page)
|
22
|
+
page == 1
|
23
|
+
end
|
24
|
+
|
25
|
+
# Called by printing framework. Initialize print job. This function can be overridden if necessary.
|
26
|
+
def on_begin_document(start_page, end_page)
|
27
|
+
# HINT: perform custom actions...
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
# Called by printing framework. Deinitialize the print job. This function can be overridden if necessary.
|
32
|
+
def on_end_document
|
33
|
+
# HINT: perform custom actions...
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
# Called by printing framework. It does the print job. This function can be overridden if necessary.
|
38
|
+
def on_print_page(page)
|
39
|
+
dc = get_dc
|
40
|
+
if dc && @canvas
|
41
|
+
# get drawing size
|
42
|
+
total_bb = @canvas.get_total_bounding_box
|
43
|
+
max_x = total_bb.right
|
44
|
+
max_y = total_bb.bottom
|
45
|
+
|
46
|
+
# set printing mode
|
47
|
+
case @canvas.get_print_mode
|
48
|
+
when ShapeCanvas::PRINTMODE::FIT_TO_PAGE
|
49
|
+
fit_this_size_to_page([max_x, max_y])
|
50
|
+
fit_rect = get_logical_page_rect
|
51
|
+
|
52
|
+
when ShapeCanvas::PRINTMODE::FIT_TO_PAPER
|
53
|
+
fit_this_size_to_paper([max_x, max_y])
|
54
|
+
fit_rect = get_logical_paper_rect
|
55
|
+
|
56
|
+
when ShapeCanvas::PRINTMODE::FIT_TO_MARGINS
|
57
|
+
fit_this_size_to_page_margins([max_x, max_y], ShapeCanvas.page_setup_data)
|
58
|
+
fit_rect = get_logical_page_margins_rect(ShapeCanvas.page_setup_data)
|
59
|
+
|
60
|
+
when ShapeCanvas::PRINTMODE::MAP_TO_PAGE
|
61
|
+
map_screen_size_to_page
|
62
|
+
fit_rect = get_logical_page_rect
|
63
|
+
|
64
|
+
when ShapeCanvas::PRINTMODE::MAP_TO_PAPER
|
65
|
+
map_screen_size_to_paper
|
66
|
+
fit_rect = get_logical_paper_rect
|
67
|
+
|
68
|
+
when ShapeCanvas::PRINTMODE::MAP_TO_MARGINS
|
69
|
+
map_screen_size_to_page
|
70
|
+
fit_rect = get_logical_page_margins_rect(ShapeCanvas.page_setup_data)
|
71
|
+
|
72
|
+
when ShapeCanvas::PRINTMODE::MAP_TO_DEVICE
|
73
|
+
map_screen_size_to_device
|
74
|
+
fit_rect = get_logical_page_rect
|
75
|
+
|
76
|
+
else
|
77
|
+
fit_rect = Wx::Rect.new
|
78
|
+
end
|
79
|
+
|
80
|
+
# This offsets the image so that it is centered within the reference
|
81
|
+
# rectangle defined above.
|
82
|
+
xoff = ((fit_rect.width - max_x - total_bb.left) / 2) - fit_rect.x
|
83
|
+
yoff = ((fit_rect.height - max_y - total_bb.top) / 2) - fit_rect.y
|
84
|
+
|
85
|
+
case @canvas.get_print_h_align
|
86
|
+
when ShapeCanvas::HALIGN::LEFT
|
87
|
+
xoff = 0
|
88
|
+
when ShapeCanvas::HALIGN::RIGHT
|
89
|
+
xoff = fit_rect.width - total_bb.width
|
90
|
+
end
|
91
|
+
|
92
|
+
case @canvas.get_print_v_align
|
93
|
+
when ShapeCanvas::VALIGN::TOP
|
94
|
+
yoff = 0
|
95
|
+
when ShapeCanvas::VALIGN::BOTTOM
|
96
|
+
yoff = fit_rect.height - total_bb.height
|
97
|
+
end
|
98
|
+
|
99
|
+
offset_logical_origin(xoff, yoff)
|
100
|
+
|
101
|
+
# store current canvas properties
|
102
|
+
prev_scale = @canvas.get_scale
|
103
|
+
prev_style = @canvas.get_style
|
104
|
+
prev_colour = @canvas.get_canvas_colour
|
105
|
+
|
106
|
+
# disable canvas background drawing if required
|
107
|
+
unless @canvas.has_style?(ShapeCanvas::STYLE::PRINT_BACKGROUND)
|
108
|
+
@canvas.remove_style(ShapeCanvas::STYLE::GRADIENT_BACKGROUND)
|
109
|
+
@canvas.remove_style(ShapeCanvas::STYLE::GRID_SHOW)
|
110
|
+
@canvas.set_canvas_colour(Wx::WHITE)
|
111
|
+
end
|
112
|
+
|
113
|
+
# draw the canvas content without any scale (dc is scaled by the printing framework)
|
114
|
+
@canvas.set_scale(1.0)
|
115
|
+
@canvas.draw_content(dc, NOT_FROM_PAINT)
|
116
|
+
@canvas.set_scale(prev_scale)
|
117
|
+
|
118
|
+
# restore previous canvas properties if needed
|
119
|
+
unless @canvas.has_style?(ShapeCanvas::STYLE::PRINT_BACKGROUND)
|
120
|
+
@canvas.set_style(prev_style)
|
121
|
+
@canvas.set_canvas_colour(prev_colour)
|
122
|
+
end
|
123
|
+
|
124
|
+
return true
|
125
|
+
end
|
126
|
+
false
|
127
|
+
end
|
128
|
+
|
129
|
+
# Called by printing framework. Supply information about printed pages. This function can be overridden if necessary.
|
130
|
+
def get_page_info
|
131
|
+
[1,1,1,1]
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|