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,422 @@
|
|
1
|
+
# Wx::SF - Demo FrameCanvas
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
|
+
|
4
|
+
require 'wx/shapes'
|
5
|
+
|
6
|
+
class FrameCanvas < Wx::SF::ShapeCanvas
|
7
|
+
|
8
|
+
# Constructor
|
9
|
+
# @param [Wx::SF::Diagram] diagram shape diagram
|
10
|
+
# @param [Wx::Window] parent Parent window
|
11
|
+
# @param [Integer] id Window ID
|
12
|
+
def initialize(diagram, parent, id = Wx::ID_ANY)
|
13
|
+
super(diagram, parent, id)
|
14
|
+
|
15
|
+
# initialize grid
|
16
|
+
add_style(STYLE::GRID_USE)
|
17
|
+
add_style(STYLE::GRID_SHOW)
|
18
|
+
# distances between grid lines can be modified via following function:
|
19
|
+
set_grid_line_mult(10)
|
20
|
+
# grid line style can be set as follows:
|
21
|
+
set_grid_style(Wx::PenStyle::PENSTYLE_SHORT_DASH)
|
22
|
+
|
23
|
+
# canvas background can be printed/omitted during the canvas printing job
|
24
|
+
#add_style(STYLE::PRINT_BACKGROUND)
|
25
|
+
|
26
|
+
# adjust the printed drawing align and style if needed
|
27
|
+
# set_print_v_align(VALIGN::TOP)
|
28
|
+
# set_print_h_align(HALIGN::LEFT)
|
29
|
+
# set_print_mode(PRINTMODE::MAP_TO_MARGINS)
|
30
|
+
|
31
|
+
# the canvas background can be filled with a solid colour ...
|
32
|
+
# remove_style(STYLE::GRADIENT_BACKGROUND)
|
33
|
+
# set_background_colour(DEFAULT::SHAPECANVAS_BACKGROUNDCOLOR)
|
34
|
+
# ... or by a gradient fill
|
35
|
+
add_style(STYLE::GRADIENT_BACKGROUND)
|
36
|
+
set_gradient_from(DEFAULT::GRADIENT_FROM)
|
37
|
+
set_gradient_to(DEFAULT::GRADIENT_TO)
|
38
|
+
|
39
|
+
# also shadows style can be set here:
|
40
|
+
# set_shadow_fill(Wx::Brush.new(Wx::Colour.new(100, 100, 100), Wx::CROSSDIAG_HATCH)) # standard values can be DEFAULT::SHAPECANVAS_SHADOWBRUSH or DEFAULT::SHAPECANVAS_SHADOWCOLOR
|
41
|
+
# set_shadow_offset(Wx::RealPoint.new(7, 7))
|
42
|
+
|
43
|
+
# now you can use also these styles...
|
44
|
+
|
45
|
+
# remove_style(STYLE::HOVERING)
|
46
|
+
# remove_style(STYLE::HIGHLIGHTING)
|
47
|
+
# remove_style(STYLE::UNDOREDO)
|
48
|
+
# remove_style(STYLE::DND)
|
49
|
+
# remove_style(STYLE::CLIPBOARD)
|
50
|
+
# remove_style(STYLE::MULTI_SIZE_CHANGE)
|
51
|
+
# remove_style(STYLE::MULTI_SELECTION)
|
52
|
+
|
53
|
+
# a style flag presence can be tested like this:
|
54
|
+
# if( has_style?(STYLE::GRID_USE) ) do_something()
|
55
|
+
|
56
|
+
# multiple styles can be set in this way:
|
57
|
+
# set_style(STYLE::GRID_USE | STYLE::GRID_SHOW) ... or ...
|
58
|
+
# set_style(STYLE::DEFAULT_CANVAS_STYLE)
|
59
|
+
|
60
|
+
# process mouse wheel if needed
|
61
|
+
add_style(STYLE::PROCESS_MOUSEWHEEL)
|
62
|
+
# set scale boundaries applied on mouse wheel scale change
|
63
|
+
set_min_scale(0.1)
|
64
|
+
set_max_scale(2.0)
|
65
|
+
|
66
|
+
# specify accepted shapes...
|
67
|
+
get_diagram.clear_accepted_shapes
|
68
|
+
get_diagram.accept_shape(Wx::SF::ACCEPT_ALL)
|
69
|
+
|
70
|
+
# ... in addition, specify accepted top shapes (i.e. shapes that can be placed
|
71
|
+
# directly onto the canvas)
|
72
|
+
# get_diagram.clear_accepted_top_shapes
|
73
|
+
# get_diagram.accept_top_shape(Wx::SF::RectShape)
|
74
|
+
|
75
|
+
# get main application frame
|
76
|
+
@parent_frame = Wx.get_app.get_top_window
|
77
|
+
end
|
78
|
+
|
79
|
+
def on_left_down(event)
|
80
|
+
shape = nil
|
81
|
+
case @parent_frame.tool_mode
|
82
|
+
when MainFrame::MODE::BITMAP
|
83
|
+
Wx::FileDialog(self, "Load bitmap image...", __dir__, '', 'BMP Files (*.bmp)|*.bmp', Wx::FD_OPEN | Wx::FD_FILE_MUST_EXIST) do |dlg|
|
84
|
+
|
85
|
+
if dlg.show_modal == Wx::ID_OK
|
86
|
+
_, shape = get_diagram.create_shape(Wx::SF::BitmapShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
87
|
+
if shape
|
88
|
+
# create relative path
|
89
|
+
# wxFileName path( dlg.GetPath() )
|
90
|
+
# path.MakeRelativeTo( wxGetCwd() )
|
91
|
+
# create image from BMP file
|
92
|
+
# ((wxSFBitmapShape*)shape).CreateFromFile( path.GetFullPath(), Wx::BITMAP_TYPE_BMP )
|
93
|
+
shape.create_from_file(dlg.get_path, Wx::BitmapType::BITMAP_TYPE_BMP)
|
94
|
+
|
95
|
+
# set shape policy
|
96
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
97
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
98
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
when MainFrame::MODE::TEXT, MainFrame::MODE::EDITTEXT
|
103
|
+
Wx::TextEntryDialog(self, '', 'Enter text', 'Hello World!') do |dlg|
|
104
|
+
if dlg.show_modal == Wx::ID_OK
|
105
|
+
if @parent_frame.tool_mode == MainFrame::MODE::TEXT
|
106
|
+
_, shape = get_diagram.create_shape(Wx::SF::TextShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
107
|
+
else
|
108
|
+
_, shape = get_diagram.create_shape(Wx::SF::EditTextShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
109
|
+
# editable text shapes can be forced to be multiline at default like this:
|
110
|
+
# shape.force_multiline( true )
|
111
|
+
|
112
|
+
# also edit control type can be set here like this:
|
113
|
+
# shape.set_edit_type(Wx::SF::EditTextShape::EDITTYPE::DIALOG)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
if shape
|
118
|
+
shape.set_text(dlg.get_value)
|
119
|
+
|
120
|
+
# set alignment
|
121
|
+
shape.set_v_align(Wx::SF::Shape::VALIGN::TOP)
|
122
|
+
shape.set_h_align(Wx::SF::Shape::HALIGN::CENTER)
|
123
|
+
shape.set_v_border(10.0)
|
124
|
+
shape.update
|
125
|
+
|
126
|
+
# set shapes policy
|
127
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
128
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
129
|
+
shape.accept_trg_neighbour(Wx::SF::TextShape)
|
130
|
+
shape.accept_trg_neighbour(Wx::SF::EditTextShape)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
when MainFrame::MODE::DIAMOND
|
135
|
+
_, shape = get_diagram.create_shape(Wx::SF::DiamondShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
136
|
+
if shape
|
137
|
+
# set shape policy
|
138
|
+
shape.accept_child(Wx::SF::TextShape)
|
139
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
140
|
+
|
141
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
142
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
143
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
144
|
+
end
|
145
|
+
|
146
|
+
when MainFrame::MODE::FIXEDRECT
|
147
|
+
_, shape = get_diagram.create_shape(Wx::SF::SquareShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
148
|
+
if shape
|
149
|
+
# set shape policy
|
150
|
+
shape.accept_child(Wx::SF::TextShape)
|
151
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
152
|
+
|
153
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
154
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
155
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
156
|
+
end
|
157
|
+
|
158
|
+
when MainFrame::MODE::ROUNDRECT
|
159
|
+
_, shape = get_diagram.create_shape(Wx::SF::RoundRectShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
160
|
+
if shape
|
161
|
+
# set shape policy
|
162
|
+
shape.accept_child(Wx::SF::TextShape)
|
163
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
164
|
+
|
165
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
166
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
167
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
168
|
+
end
|
169
|
+
|
170
|
+
when MainFrame::MODE::RECT
|
171
|
+
_, shape = get_diagram.create_shape(Wx::SF::RectShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
172
|
+
if shape
|
173
|
+
# set shape policy
|
174
|
+
shape.accept_child(Wx::SF::ACCEPT_ALL)
|
175
|
+
|
176
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
177
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
178
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
179
|
+
|
180
|
+
# child shapes can be locked accordingly to their parent's origin if the parent is resized
|
181
|
+
# shape.add_style(Wx::SF::Shape::STYLE::LOCK_CHILDREN)
|
182
|
+
|
183
|
+
# shapes can have fixed connection points defined in the following way:
|
184
|
+
cp = shape.add_connection_point(Wx::SF::ConnectionPoint::CPTYPE::CENTERLEFT)
|
185
|
+
# also direction of connected orthogonal lines can be set in the following way:
|
186
|
+
cp.set_ortho_direction(Wx::SF::ConnectionPoint::CPORTHODIR::HORIZONTAL)
|
187
|
+
cp = shape.add_connection_point(Wx::SF::ConnectionPoint::CPTYPE::CENTERRIGHT)
|
188
|
+
cp.set_ortho_direction(Wx::SF::ConnectionPoint::CPORTHODIR::HORIZONTAL)
|
189
|
+
cp = shape.add_connection_point(Wx::SF::ConnectionPoint::CPTYPE::TOPMIDDLE)
|
190
|
+
cp.set_ortho_direction(Wx::SF::ConnectionPoint::CPORTHODIR::VERTICAL)
|
191
|
+
cp = shape.add_connection_point(Wx::SF::ConnectionPoint::CPTYPE::BOTTOMMIDDLE)
|
192
|
+
cp.set_ortho_direction(Wx::SF::ConnectionPoint::CPORTHODIR::VERTICAL)
|
193
|
+
# user can define also any number of CUSTOM connection points placed relatively to the
|
194
|
+
# parent shape's bounding box ("25, 50" here means 25% of width and 50% of height):
|
195
|
+
shape.add_connection_point([25, 50])
|
196
|
+
shape.add_connection_point([75, 50])
|
197
|
+
# in this case the line connection can be assigned to one of the defined
|
198
|
+
# fixed connection points only.
|
199
|
+
end
|
200
|
+
|
201
|
+
when MainFrame::MODE::GRID, MainFrame::MODE::FLEXGRID
|
202
|
+
if @parent_frame.tool_mode == MainFrame::MODE::GRID
|
203
|
+
_, shape = get_diagram.create_shape(Wx::SF::GridShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
204
|
+
else
|
205
|
+
_, shape = get_diagram.create_shape(Wx::SF::FlexGridShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
206
|
+
end
|
207
|
+
|
208
|
+
if shape
|
209
|
+
# set visual style
|
210
|
+
shape.set_fill(Wx::TRANSPARENT_BRUSH)
|
211
|
+
shape.set_border(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT))
|
212
|
+
|
213
|
+
# number of rows and columns cas be set here (default grid dimension is 3x3) ...
|
214
|
+
# shape.set_dimensions(2, 2)
|
215
|
+
|
216
|
+
# ... as well as the cell spaces (default grid cellspace is 5).
|
217
|
+
# shape.set_cell_space(0)
|
218
|
+
|
219
|
+
# set shape policy
|
220
|
+
shape.accept_child(Wx::SF::ACCEPT_ALL)
|
221
|
+
|
222
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
223
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
224
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
225
|
+
|
226
|
+
# insert some shapes into the grid from code here (it can also be done interactively by drag&drop operations).
|
227
|
+
# shapes inserted to the grid can be aligned relatively to its grid cell region
|
228
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::EllipseShape, Wx::SF::DONT_SAVE_STATE)
|
229
|
+
inner_shape.set_v_align(Wx::SF::Shape::VALIGN::EXPAND )
|
230
|
+
shape.append_to_grid(inner_shape)
|
231
|
+
# add some another shapes...
|
232
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::DiamondShape, Wx::SF::DONT_SAVE_STATE)
|
233
|
+
shape.append_to_grid(inner_shape)
|
234
|
+
# shapes can be also inserted before given lexicographic position (at the first position in self when) in self way ...
|
235
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::RoundRectShape, Wx::SF::DONT_SAVE_STATE)
|
236
|
+
shape.insert_to_grid(0, inner_shape)
|
237
|
+
# ... or can replace previously assigned shape at the position specified by row and column indexes
|
238
|
+
# (note that the previous shape at the given position (if exists) will be moved to the grid's last lexicographic position).
|
239
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::CircleShape, Wx::SF::DONT_SAVE_STATE)
|
240
|
+
shape.insert_to_grid(1, 0, inner_shape)
|
241
|
+
|
242
|
+
# also control shapes can be managed by the grid shape.
|
243
|
+
# _, ctrl = get_diagram.create_shape(Wx::SF::ControlShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
244
|
+
# if ctrl )
|
245
|
+
# ctrl.set_v_align(Wx::SF::Shape::VALIGN::EXPAND)
|
246
|
+
# ctrl.set_h_align(Wx::SF::Shape::HALIGN::EXPAND)
|
247
|
+
# ctrl.set_control(Wx::Button.new( self, Wx::ID_ANY, "Test"))
|
248
|
+
# shape.append_to_grid(ctrl)
|
249
|
+
# end
|
250
|
+
|
251
|
+
# update the grid
|
252
|
+
shape.update
|
253
|
+
end
|
254
|
+
|
255
|
+
when MainFrame::MODE::ELLIPSE
|
256
|
+
_, shape = get_diagram.create_shape(Wx::SF::EllipseShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
257
|
+
if shape
|
258
|
+
# set shape policy
|
259
|
+
shape.accept_child(Wx::SF::TextShape)
|
260
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
261
|
+
|
262
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
263
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
264
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
265
|
+
end
|
266
|
+
|
267
|
+
when MainFrame::MODE::CIRCLE
|
268
|
+
_, shape = get_diagram.create_shape(Wx::SF::CircleShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
269
|
+
if shape
|
270
|
+
# set shape policy
|
271
|
+
shape.remove_style(Wx::SF::Shape::STYLE::SIZE_CHANGE)
|
272
|
+
|
273
|
+
shape.accept_child(Wx::SF::TextShape)
|
274
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
275
|
+
|
276
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
277
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
278
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
279
|
+
end
|
280
|
+
|
281
|
+
when MainFrame::MODE::LINE
|
282
|
+
if get_mode == MODE::READY
|
283
|
+
start_interactive_connection(Wx::SF::LineShape, event.get_position)
|
284
|
+
# interactive connection can be created also from existing object for example
|
285
|
+
# if some connection properties should be modified before the connection creation
|
286
|
+
# process is started:
|
287
|
+
# start_interactive_connection(Wx::SF::LineShape.new, event.get_position)
|
288
|
+
else
|
289
|
+
super
|
290
|
+
end
|
291
|
+
|
292
|
+
when MainFrame::MODE::CURVE
|
293
|
+
if get_mode == MODE::READY
|
294
|
+
start_interactive_connection(Wx::SF::CurveShape, event.get_position)
|
295
|
+
else
|
296
|
+
super
|
297
|
+
end
|
298
|
+
|
299
|
+
when MainFrame::MODE::ORTHOLINE
|
300
|
+
if get_mode == MODE::READY
|
301
|
+
start_interactive_connection(Wx::SF::OrthoLineShape, event.get_position)
|
302
|
+
else
|
303
|
+
super
|
304
|
+
end
|
305
|
+
|
306
|
+
when MainFrame::MODE::ROUNDORTHOLINE
|
307
|
+
if get_mode == MODE::READY
|
308
|
+
start_interactive_connection(Wx::SF::RoundOrthoLineShape, event.get_position)
|
309
|
+
else
|
310
|
+
super
|
311
|
+
end
|
312
|
+
|
313
|
+
when MainFrame::MODE::STANDALONELINE
|
314
|
+
_, shape = get_diagram.create_shape(Wx::SF::LineShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
315
|
+
if shape
|
316
|
+
# set the line to be stand-alone
|
317
|
+
shape.set_stand_alone(true)
|
318
|
+
|
319
|
+
shape.set_src_point((event.get_position - [50, 0]).to_real_point)
|
320
|
+
shape.set_trg_point((event.get_position + [50, 0]).to_real_point)
|
321
|
+
|
322
|
+
# line's ending style can be set as follows:
|
323
|
+
# shape.set_src_arrow(Wx::SF::CircleArrow)
|
324
|
+
# shape.set_trg_arrow(Wx::SF::CircleArrow)
|
325
|
+
|
326
|
+
shape.accept_child(Wx::SF::TextShape)
|
327
|
+
shape.accept_child(Wx::SF::EditTextShape)
|
328
|
+
end
|
329
|
+
|
330
|
+
else
|
331
|
+
# do default actions
|
332
|
+
super
|
333
|
+
end
|
334
|
+
|
335
|
+
if shape
|
336
|
+
show_shadows(@parent_frame.show_shadows, SHADOWMODE::ALL)
|
337
|
+
|
338
|
+
save_canvas_state
|
339
|
+
|
340
|
+
@parent_frame.tool_mode = MainFrame::MODE::DESIGN unless event.control_down
|
341
|
+
|
342
|
+
shape.refresh
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def on_right_down(event)
|
347
|
+
# try to find shape under cursor
|
348
|
+
shape = get_shape_under_cursor
|
349
|
+
# alternatively you can use:
|
350
|
+
# shape = get_shape_at_position(dp2lp(event.getposition), 1, SEARCHMODE::BOTH)
|
351
|
+
|
352
|
+
# print out information about the shape (if found)
|
353
|
+
if shape
|
354
|
+
# show basic info
|
355
|
+
msg = "Class name: #{shape.class}, ID: #{shape.get_id}\n"
|
356
|
+
|
357
|
+
# show info about shape's children
|
358
|
+
lst_shapes = shape.get_child_shapes(nil, Wx::SF::RECURSIVE)
|
359
|
+
unless lst_shapes.empty?
|
360
|
+
msg << "\nChildren:\n"
|
361
|
+
lst_shapes.each_with_index do |child, i|
|
362
|
+
msg << "#{i+1}. Class name: #{child.class}, ID: #{child.get_id}\n"
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
# show info about shape's neighbours
|
367
|
+
lst_shapes = shape.get_neighbours(Wx::SF::LineShape, Wx::SF::Shape::CONNECTMODE::BOTH, Wx::SF::INDIRECT)
|
368
|
+
unless lst_shapes.empty?
|
369
|
+
msg << "\nNeighbours:\n"
|
370
|
+
lst_shapes.each_with_index do |nbr, i|
|
371
|
+
msg << "#{i+1}. Class name: #{nbr.class}, ID: #{nbr.get_id}\n"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
# show message
|
376
|
+
Wx.message_box(msg, 'wxRuby ShapeFramework', Wx::OK | Wx::ICON_INFORMATION)
|
377
|
+
else
|
378
|
+
Wx.message_box('No shape found on this position.', 'wxRuby ShapeFramework', Wx::OK | Wx::ICON_INFORMATION)
|
379
|
+
end
|
380
|
+
|
381
|
+
# call default handler
|
382
|
+
super
|
383
|
+
end
|
384
|
+
|
385
|
+
def on_key_down(event)
|
386
|
+
if event.get_key_code == Wx::K_ESCAPE
|
387
|
+
@parent_frame.tool_mode = MainFrame::MODE::DESIGN
|
388
|
+
end
|
389
|
+
|
390
|
+
# do default actions
|
391
|
+
super
|
392
|
+
end
|
393
|
+
|
394
|
+
def on_connection_finished(connection)
|
395
|
+
if connection
|
396
|
+
# the line's ending style can be set like this:
|
397
|
+
connection.set_trg_arrow(Wx::SF::SolidArrow)
|
398
|
+
# also Wx::SF::OpenArrow, Wx::SF::DiamondArrow and Wx::SF::CircleArrow styles are available.
|
399
|
+
connection.set_src_arrow(Wx::SF::CircleArrow)
|
400
|
+
|
401
|
+
connection.accept_child(Wx::SF::TextShape)
|
402
|
+
connection.accept_child(Wx::SF::EditTextShape)
|
403
|
+
|
404
|
+
connection.accept_connection(Wx::SF::ACCEPT_ALL)
|
405
|
+
connection.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
406
|
+
connection.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
407
|
+
|
408
|
+
connection.set_dock_point(Wx::SF::LineShape::DEFAULT::DOCKPOINT_CENTER)
|
409
|
+
|
410
|
+
@parent_frame.tool_mode = MainFrame::MODE::DESIGN
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
def on_mouse_wheel(event)
|
415
|
+
# do default actions
|
416
|
+
super
|
417
|
+
|
418
|
+
# adjust zoom slider control
|
419
|
+
@parent_frame.zoom_slider.set_value((get_scale * 50).to_i)
|
420
|
+
end
|
421
|
+
|
422
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,251 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * sample_xpm[] = {
|
3
|
+
"32 32 216 2",
|
4
|
+
" c None",
|
5
|
+
". c #872C2C",
|
6
|
+
"+ c #A52827",
|
7
|
+
"@ c #A42828",
|
8
|
+
"# c #553131",
|
9
|
+
"$ c #7D2D2D",
|
10
|
+
"% c #3D3232",
|
11
|
+
"& c #535331",
|
12
|
+
"* c #AEAE26",
|
13
|
+
"= c #85852C",
|
14
|
+
"- c #ACAC26",
|
15
|
+
"; c #88882C",
|
16
|
+
"> c #9B2929",
|
17
|
+
", c #A92626",
|
18
|
+
"' c #F10D0C",
|
19
|
+
") c #B32424",
|
20
|
+
"! c #D91919",
|
21
|
+
"~ c #A52727",
|
22
|
+
"{ c #E51414",
|
23
|
+
"] c #DC1817",
|
24
|
+
"^ c #9F2828",
|
25
|
+
"/ c #A5A527",
|
26
|
+
"( c #F2F20B",
|
27
|
+
"_ c #FFFF00",
|
28
|
+
": c #F1F10C",
|
29
|
+
"< c #AEAE25",
|
30
|
+
"[ c #E7E712",
|
31
|
+
"} c #BEBE22",
|
32
|
+
"| c #999929",
|
33
|
+
"1 c #DE1716",
|
34
|
+
"2 c #A82626",
|
35
|
+
"3 c #EF0E0D",
|
36
|
+
"4 c #CA1E1E",
|
37
|
+
"5 c #C42020",
|
38
|
+
"6 c #EC1010",
|
39
|
+
"7 c #9E2828",
|
40
|
+
"8 c #B12525",
|
41
|
+
"9 c #E91211",
|
42
|
+
"0 c #922A2A",
|
43
|
+
"a c #A8A827",
|
44
|
+
"b c #EFEF0D",
|
45
|
+
"c c #C5C520",
|
46
|
+
"d c #FBFB03",
|
47
|
+
"e c #A6A627",
|
48
|
+
"f c #FAFA04",
|
49
|
+
"g c #CACA1E",
|
50
|
+
"h c #DDDD18",
|
51
|
+
"i c #F8F806",
|
52
|
+
"j c #B8B823",
|
53
|
+
"k c #E3E315",
|
54
|
+
"l c #9E2929",
|
55
|
+
"m c #D01D1D",
|
56
|
+
"n c #B72423",
|
57
|
+
"o c #AD2625",
|
58
|
+
"p c #DD1817",
|
59
|
+
"q c #B22525",
|
60
|
+
"r c #D71A1A",
|
61
|
+
"s c #EBEB10",
|
62
|
+
"t c #B0B025",
|
63
|
+
"u c #C0C021",
|
64
|
+
"v c #E6E613",
|
65
|
+
"w c #97972A",
|
66
|
+
"x c #A22828",
|
67
|
+
"y c #BB2323",
|
68
|
+
"z c #B82424",
|
69
|
+
"A c #4A3232",
|
70
|
+
"B c #842D2D",
|
71
|
+
"C c #912B2B",
|
72
|
+
"D c #5B3131",
|
73
|
+
"E c #70702F",
|
74
|
+
"F c #C6C620",
|
75
|
+
"G c #8E8E2B",
|
76
|
+
"H c #9A9A29",
|
77
|
+
"I c #484832",
|
78
|
+
"J c #A4A428",
|
79
|
+
"K c #9D2828",
|
80
|
+
"L c #E61211",
|
81
|
+
"M c #E51212",
|
82
|
+
"N c #DF1615",
|
83
|
+
"O c #D21B1A",
|
84
|
+
"P c #423232",
|
85
|
+
"Q c #515131",
|
86
|
+
"R c #E4E412",
|
87
|
+
"S c #F3F307",
|
88
|
+
"T c #E2E213",
|
89
|
+
"U c #BEBE20",
|
90
|
+
"V c #ECEC0C",
|
91
|
+
"W c #B1B124",
|
92
|
+
"X c #999928",
|
93
|
+
"Y c #CF1D1D",
|
94
|
+
"Z c #CD1E1D",
|
95
|
+
"` c #D21C1C",
|
96
|
+
" . c #A42727",
|
97
|
+
".. c #ED0F0F",
|
98
|
+
"+. c #7E2D2D",
|
99
|
+
"@. c #92922B",
|
100
|
+
"#. c #FDFD01",
|
101
|
+
"$. c #D1D11C",
|
102
|
+
"%. c #E5E513",
|
103
|
+
"&. c #643030",
|
104
|
+
"*. c #E61313",
|
105
|
+
"=. c #EE0F0E",
|
106
|
+
"-. c #A92726",
|
107
|
+
";. c #C1C121",
|
108
|
+
">. c #ADAD25",
|
109
|
+
",. c #EEEE0E",
|
110
|
+
"'. c #5C5C31",
|
111
|
+
"). c #F00D0C",
|
112
|
+
"!. c #AA2726",
|
113
|
+
"~. c #AF2525",
|
114
|
+
"{. c #EA1110",
|
115
|
+
"]. c #32365A",
|
116
|
+
"^. c #333440",
|
117
|
+
"/. c #E2E215",
|
118
|
+
"(. c #F0F00D",
|
119
|
+
"_. c #C4C420",
|
120
|
+
":. c #F5F508",
|
121
|
+
"<. c #BCBC22",
|
122
|
+
"[. c #FCFC02",
|
123
|
+
"}. c #8C8C2B",
|
124
|
+
"|. c #B92323",
|
125
|
+
"1. c #E51413",
|
126
|
+
"2. c #633030",
|
127
|
+
"3. c #313A74",
|
128
|
+
"4. c #2D43AE",
|
129
|
+
"5. c #2E40A2",
|
130
|
+
"6. c #313975",
|
131
|
+
"7. c #77772E",
|
132
|
+
"8. c #F7F706",
|
133
|
+
"9. c #CBCB1E",
|
134
|
+
"0. c #BABA23",
|
135
|
+
"a. c #D81919",
|
136
|
+
"b. c #A62727",
|
137
|
+
"c. c #D41B1B",
|
138
|
+
"d. c #C91F1E",
|
139
|
+
"e. c #8F2B2B",
|
140
|
+
"f. c #323553",
|
141
|
+
"g. c #2C45BA",
|
142
|
+
"h. c #284CE0",
|
143
|
+
"i. c #2A4AD5",
|
144
|
+
"j. c #2C46C0",
|
145
|
+
"k. c #A3A328",
|
146
|
+
"l. c #DEDE17",
|
147
|
+
"m. c #772E2E",
|
148
|
+
"n. c #EC100F",
|
149
|
+
"o. c #AB2626",
|
150
|
+
"p. c #B12524",
|
151
|
+
"q. c #2B47C8",
|
152
|
+
"r. c #2D43AF",
|
153
|
+
"s. c #2453FF",
|
154
|
+
"t. c #2552FA",
|
155
|
+
"u. c #2D44B6",
|
156
|
+
"v. c #2C45BE",
|
157
|
+
"w. c #BEBE21",
|
158
|
+
"x. c #BFBF22",
|
159
|
+
"y. c #B2B224",
|
160
|
+
"z. c #6B2F2F",
|
161
|
+
"A. c #C6201F",
|
162
|
+
"B. c #2F409F",
|
163
|
+
"C. c #2551F8",
|
164
|
+
"D. c #2C44B9",
|
165
|
+
"E. c #2452FC",
|
166
|
+
"F. c #2F3E92",
|
167
|
+
"G. c #585831",
|
168
|
+
"H. c #8E8E2A",
|
169
|
+
"I. c #79792D",
|
170
|
+
"J. c #5C3030",
|
171
|
+
"K. c #333333",
|
172
|
+
"L. c #313971",
|
173
|
+
"M. c #2551F5",
|
174
|
+
"N. c #2A49D0",
|
175
|
+
"O. c #284EE6",
|
176
|
+
"P. c #294BD9",
|
177
|
+
"Q. c #294CDD",
|
178
|
+
"R. c #2650F1",
|
179
|
+
"S. c #323761",
|
180
|
+
"T. c #606030",
|
181
|
+
"U. c #294CDE",
|
182
|
+
"V. c #2D42AD",
|
183
|
+
"W. c #2D43B3",
|
184
|
+
"X. c #2A4AD6",
|
185
|
+
"Y. c #2C45BD",
|
186
|
+
"Z. c #303B7C",
|
187
|
+
"`. c #2650F0",
|
188
|
+
" + c #2650F3",
|
189
|
+
".+ c #2B46C3",
|
190
|
+
"++ c #284CDE",
|
191
|
+
"@+ c #2A49D1",
|
192
|
+
"#+ c #264FED",
|
193
|
+
"$+ c #31396F",
|
194
|
+
"%+ c #303D90",
|
195
|
+
"&+ c #2B47C6",
|
196
|
+
"*+ c #31386B",
|
197
|
+
"=+ c #2E41A7",
|
198
|
+
"-+ c #313A77",
|
199
|
+
";+ c #303C86",
|
200
|
+
">+ c #2551F7",
|
201
|
+
",+ c #2D43B1",
|
202
|
+
"'+ c #2E41A6",
|
203
|
+
")+ c #2552FB",
|
204
|
+
"!+ c #2552F9",
|
205
|
+
"~+ c #2552F8",
|
206
|
+
"{+ c #323765",
|
207
|
+
"]+ c #2B48CB",
|
208
|
+
"^+ c #2A49CF",
|
209
|
+
"/+ c #274EE7",
|
210
|
+
"(+ c #264FEE",
|
211
|
+
"_+ c #2D42AE",
|
212
|
+
":+ c #2650F2",
|
213
|
+
"<+ c #294BDA",
|
214
|
+
"[+ c #2C46C1",
|
215
|
+
"}+ c #313A78",
|
216
|
+
"|+ c #2D42AA",
|
217
|
+
"1+ c #294BDC",
|
218
|
+
"2+ c #2B48CA",
|
219
|
+
"3+ c #2453FD",
|
220
|
+
" ",
|
221
|
+
" ",
|
222
|
+
" ",
|
223
|
+
" ",
|
224
|
+
" ",
|
225
|
+
" . + + @ # $ + + + % & * * * = & - * * ; ",
|
226
|
+
" > , ' ' ) ! ~ { ' ] ^ / ( _ : < [ } _ _ < | ",
|
227
|
+
" 1 2 3 4 5 ' 6 7 3 8 9 0 a b c d e f _ g h i j k ",
|
228
|
+
" l ' m n o ' ' ' p q ~ ' r s _ < t b _ _ _ < u v _ w ",
|
229
|
+
" x y z A z y y y y B C y y D E F F G H F F F F } I c F J ",
|
230
|
+
" K L L ^ M L L L L , N L O P Q R S T U S S S S V W S S X ",
|
231
|
+
" Y ' Z ` ' ' ' ' .' ..+. @.#._ < _ _ _ _ $.%._ $. ",
|
232
|
+
" &.*.=., ' ' ' ! 5 ' -. } _ ;.( _ _ _ >._ ,.'. ",
|
233
|
+
" C ).!.=.' ' ~.{.Z ].^. /.(._._ _ :.<.[.}. ",
|
234
|
+
" |.` Z ' ' ~ 1.2. 3.4.5.6. 7.8.>._ _ 9.s 0. ",
|
235
|
+
" a.b.' c.d.e. f.g.h.i.j. k.F ,._ < l. ",
|
236
|
+
" m. .n.o.p. q.r.s.t.u.v. w.x.( y.E ",
|
237
|
+
" z.A.$ B.C.D.s.s.r.E.F. G.H._.I. ",
|
238
|
+
" J.K. L.M.N.O.s.s.P.Q.R.S. K.T. ",
|
239
|
+
" K. U.s.V.s.s.s.E.W.s.X. ",
|
240
|
+
" g.s.M.Y.s.s.s.s.W.E.s.V. ",
|
241
|
+
" Z.`. +.+++ + + + +@+N. +#+$+ ",
|
242
|
+
" %+&+&+*+W.&+&+&+&+=+-+&+&+;+ ",
|
243
|
+
" 6.E.>+,+'+)+s.s.!+=+r.E.~+{+ ",
|
244
|
+
" ]+^+/+(+,+s.s._+:+Q.<+[+ ",
|
245
|
+
" }+|+s.s.1+q.2+Q.s.3+=+{+ ",
|
246
|
+
" 6._+_+_+$+$+_+_+_+*+ ",
|
247
|
+
" ",
|
248
|
+
" ",
|
249
|
+
" ",
|
250
|
+
" ",
|
251
|
+
" "};
|