wxruby3-shapes 0.9.0.pre.beta.3 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/INSTALL.md +5 -7
- data/README.md +38 -6
- data/assets/logo.svg +339 -0
- data/assets/logo.xpm +60 -0
- data/assets/screenshot.png +0 -0
- data/assets/social.png +0 -0
- data/bin/wx-shapes +1 -1
- data/lib/wx/shapes/arrow_base.rb +4 -11
- data/lib/wx/shapes/arrows/circle_arrow.rb +22 -11
- data/lib/wx/shapes/arrows/circle_prong_arrow.rb +48 -0
- data/lib/wx/shapes/arrows/cross_bar_arrow.rb +57 -0
- data/lib/wx/shapes/arrows/cross_bar_circle_arrow.rb +56 -0
- data/lib/wx/shapes/arrows/cross_bar_prong_arrow.rb +49 -0
- data/lib/wx/shapes/arrows/crossed_circle.rb +46 -0
- data/lib/wx/shapes/arrows/cup_arrow.rb +65 -0
- data/lib/wx/shapes/arrows/diamond_arrow.rb +8 -13
- data/lib/wx/shapes/arrows/double_cross_bar_arrow.rb +27 -0
- data/lib/wx/shapes/arrows/filled_arrow.rb +60 -0
- data/lib/wx/shapes/arrows/line_arrow.rb +67 -0
- data/lib/wx/shapes/arrows/open_arrow.rb +22 -23
- data/lib/wx/shapes/arrows/prong_arrow.rb +42 -0
- data/lib/wx/shapes/arrows/solid_arrow.rb +21 -35
- data/lib/wx/shapes/arrows/square_arrow.rb +37 -0
- data/lib/wx/shapes/auto_layout.rb +2 -2
- data/lib/wx/shapes/base.rb +1 -1
- data/lib/wx/shapes/canvas_history.rb +20 -0
- data/lib/wx/shapes/connection_point.rb +10 -6
- data/lib/wx/shapes/diagram.rb +98 -78
- data/lib/wx/shapes/events.rb +8 -8
- data/lib/wx/shapes/printout.rb +3 -16
- data/lib/wx/shapes/serializable.rb +2 -436
- data/lib/wx/shapes/serialize/wx.rb +30 -18
- data/lib/wx/shapes/shape.rb +211 -168
- data/lib/wx/shapes/shape_canvas.rb +728 -267
- data/lib/wx/shapes/shape_data_object.rb +99 -18
- data/lib/wx/shapes/shape_handle.rb +18 -11
- data/lib/wx/shapes/shape_list.rb +34 -67
- data/lib/wx/shapes/shapes/bitmap_shape.rb +23 -24
- data/lib/wx/shapes/shapes/box_shape.rb +389 -0
- data/lib/wx/shapes/shapes/circle_shape.rb +19 -22
- data/lib/wx/shapes/shapes/control_shape.rb +77 -41
- data/lib/wx/shapes/shapes/curve_shape.rb +38 -31
- data/lib/wx/shapes/shapes/diamond_shape.rb +7 -17
- data/lib/wx/shapes/shapes/edit_text_shape.rb +6 -9
- data/lib/wx/shapes/shapes/ellipse_shape.rb +12 -15
- data/lib/wx/shapes/shapes/flex_grid_shape.rb +58 -33
- data/lib/wx/shapes/shapes/grid_shape.rb +259 -161
- data/lib/wx/shapes/shapes/line_shape.rb +155 -161
- data/lib/wx/shapes/shapes/manager_shape.rb +77 -0
- data/lib/wx/shapes/shapes/multi_sel_rect.rb +8 -8
- data/lib/wx/shapes/shapes/ortho_shape.rb +31 -36
- data/lib/wx/shapes/shapes/polygon_shape.rb +23 -29
- data/lib/wx/shapes/shapes/rect_shape.rb +95 -53
- data/lib/wx/shapes/shapes/round_ortho_shape.rb +6 -8
- data/lib/wx/shapes/shapes/round_rect_shape.rb +20 -24
- data/lib/wx/shapes/shapes/square_shape.rb +14 -17
- data/lib/wx/shapes/shapes/text_shape.rb +95 -53
- data/lib/wx/shapes/version.rb +1 -1
- data/lib/wx/shapes/wx.rb +16 -7
- data/lib/wx/wx-shapes/cmd/test.rb +1 -1
- data/samples/demo/arrows.json +1 -0
- data/samples/demo/arrows.yaml +793 -0
- data/samples/demo/art/HBox.xpm +22 -0
- data/samples/demo/art/VBox.xpm +22 -0
- data/samples/demo/art/logo.xpm +60 -0
- data/samples/demo/class.json +1 -0
- data/samples/demo/class.yaml +5631 -0
- data/samples/demo/demo.rb +301 -91
- data/samples/demo/dialogs.rb +1405 -0
- data/samples/demo/erd.json +1 -0
- data/samples/demo/erd.yaml +4072 -0
- data/samples/demo/frame_canvas.rb +409 -33
- data/samples/sample1/art/logo.xpm +60 -0
- data/samples/sample1/sample.rb +11 -11
- data/samples/sample2/art/logo.xpm +60 -0
- data/samples/sample2/sample.rb +2 -2
- data/samples/sample2/sample_shape.rb +15 -15
- data/samples/sample3/art/logo.xpm +60 -0
- data/samples/sample3/sample.rb +3 -3
- data/samples/sample4/art/logo.xpm +60 -0
- data/samples/sample4/sample.rb +2 -2
- data/tests/lib/wxapp_runner.rb +4 -0
- data/tests/serializer_tests.rb +8 -441
- data/tests/test_grid_shapes.rb +2 -2
- data/tests/test_serialize_xml.rb +17 -0
- data/tests/test_serialize_yaml.rb +2 -2
- metadata +78 -28
- data/lib/wx/shapes/serialize/core.rb +0 -40
- data/lib/wx/shapes/serialize/id.rb +0 -82
- data/lib/wx/shapes/serializer/json.rb +0 -258
- data/lib/wx/shapes/serializer/yaml.rb +0 -125
- data/samples/demo/art/sample.xpm +0 -251
- data/samples/sample1/art/sample.xpm +0 -251
- data/samples/sample2/art/sample.xpm +0 -251
- data/samples/sample3/art/sample.xpm +0 -251
- data/samples/sample4/art/sample.xpm +0 -251
@@ -1,10 +1,52 @@
|
|
1
1
|
# Wx::SF - Demo FrameCanvas
|
2
2
|
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
3
|
|
4
|
-
|
4
|
+
require_relative './dialogs'
|
5
5
|
|
6
6
|
class FrameCanvas < Wx::SF::ShapeCanvas
|
7
7
|
|
8
|
+
module POPUP_ID
|
9
|
+
include Wx::IDHelper
|
10
|
+
|
11
|
+
# commmon
|
12
|
+
STYLE = self.next_id
|
13
|
+
HOVER_COLOR = self.next_id
|
14
|
+
HALIGN = self.next_id
|
15
|
+
VALIGN = self.next_id
|
16
|
+
HBORDER = self.next_id
|
17
|
+
VBORDER = self.next_id
|
18
|
+
ACCEPTED = self.next_id
|
19
|
+
ACC_CHILDREN = self.next_id
|
20
|
+
ACC_CONNECTIONS = self.next_id
|
21
|
+
ACC_CONNECTION_FROM = self.next_id
|
22
|
+
ACC_CONNECTION_TO = self.next_id
|
23
|
+
CONNECTION_POINTS = self.next_id
|
24
|
+
|
25
|
+
# rect
|
26
|
+
FILL_BRUSH = self.next_id
|
27
|
+
BORDER_PEN = self.next_id
|
28
|
+
|
29
|
+
# line
|
30
|
+
LINE_PEN = self.next_id
|
31
|
+
LINE_ARROWS = self.next_id
|
32
|
+
SRC_ARROW = self.next_id
|
33
|
+
TRG_ARROW = self.next_id
|
34
|
+
|
35
|
+
# text
|
36
|
+
TEXT_FONT = self.next_id
|
37
|
+
TEXT_COLOR = self.next_id
|
38
|
+
|
39
|
+
# box
|
40
|
+
BOX_SPACING = self.next_id
|
41
|
+
|
42
|
+
# grid
|
43
|
+
GRID_SETTINGS = self.next_id
|
44
|
+
GRID_SPACING = self.next_id
|
45
|
+
GRID_MAXROWS = self.next_id
|
46
|
+
|
47
|
+
DUMP = self.next_id
|
48
|
+
end
|
49
|
+
|
8
50
|
# Constructor
|
9
51
|
# @param [Wx::SF::Diagram] diagram shape diagram
|
10
52
|
# @param [Wx::Window] parent Parent window
|
@@ -33,8 +75,8 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
33
75
|
# set_background_colour(DEFAULT::SHAPECANVAS_BACKGROUNDCOLOR)
|
34
76
|
# ... or by a gradient fill
|
35
77
|
add_style(STYLE::GRADIENT_BACKGROUND)
|
36
|
-
set_gradient_from(DEFAULT
|
37
|
-
set_gradient_to(DEFAULT
|
78
|
+
set_gradient_from(DEFAULT.gradient_from)
|
79
|
+
set_gradient_to(DEFAULT.gradient_to)
|
38
80
|
|
39
81
|
# also shadows style can be set here:
|
40
82
|
# 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
|
@@ -161,6 +203,8 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
161
203
|
# set shape policy
|
162
204
|
shape.accept_child(Wx::SF::TextShape)
|
163
205
|
shape.accept_child(Wx::SF::EditTextShape)
|
206
|
+
shape.accept_child(Wx::SF::RectShape)
|
207
|
+
shape.accept_child(Wx::SF::VBoxShape)
|
164
208
|
|
165
209
|
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
166
210
|
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
@@ -210,8 +254,8 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
210
254
|
shape.set_fill(Wx::TRANSPARENT_BRUSH)
|
211
255
|
shape.set_border(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT))
|
212
256
|
|
213
|
-
# number of rows and columns cas be set here (default grid dimension is
|
214
|
-
|
257
|
+
# number of rows and columns cas be set here (default grid dimension is 3x1) ...
|
258
|
+
shape.set_dimensions(2, @parent_frame.grid_columns)
|
215
259
|
|
216
260
|
# ... as well as the cell spaces (default grid cellspace is 5).
|
217
261
|
# shape.set_cell_space(0)
|
@@ -252,6 +296,53 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
252
296
|
shape.update
|
253
297
|
end
|
254
298
|
|
299
|
+
when MainFrame::MODE::VBOX, MainFrame::MODE::HBOX
|
300
|
+
if @parent_frame.tool_mode == MainFrame::MODE::VBOX
|
301
|
+
_, shape = get_diagram.create_shape(Wx::SF::VBoxShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
302
|
+
else
|
303
|
+
_, shape = get_diagram.create_shape(Wx::SF::HBoxShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
304
|
+
end
|
305
|
+
|
306
|
+
if shape
|
307
|
+
# set visual style
|
308
|
+
shape.set_fill(Wx::TRANSPARENT_BRUSH)
|
309
|
+
|
310
|
+
# spacing can be set here (default spacing is 3).
|
311
|
+
# shape.set_spacing(0)
|
312
|
+
|
313
|
+
# set shape policy
|
314
|
+
shape.accept_child(Wx::SF::ACCEPT_ALL)
|
315
|
+
|
316
|
+
shape.accept_connection(Wx::SF::ACCEPT_ALL)
|
317
|
+
shape.accept_src_neighbour(Wx::SF::ACCEPT_ALL)
|
318
|
+
shape.accept_trg_neighbour(Wx::SF::ACCEPT_ALL)
|
319
|
+
|
320
|
+
if @parent_frame.tool_mode == MainFrame::MODE::VBOX
|
321
|
+
|
322
|
+
else
|
323
|
+
# insert some shapes into the grid from code here (it can also be done interactively by drag&drop operations).
|
324
|
+
# shapes inserted to the grid can be aligned relatively to its grid cell region
|
325
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::EllipseShape, Wx::SF::DONT_SAVE_STATE)
|
326
|
+
inner_shape.set_v_align(Wx::SF::Shape::VALIGN::EXPAND )
|
327
|
+
shape.append_to_box(inner_shape)
|
328
|
+
# add another shape...
|
329
|
+
_, inner_shape = get_diagram.create_shape(Wx::SF::DiamondShape, Wx::SF::DONT_SAVE_STATE)
|
330
|
+
shape.append_to_box(inner_shape)
|
331
|
+
end
|
332
|
+
|
333
|
+
# also control shapes can be managed by the grid shape.
|
334
|
+
# _, ctrl = get_diagram.create_shape(Wx::SF::ControlShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
335
|
+
# if ctrl )
|
336
|
+
# ctrl.set_v_align(Wx::SF::Shape::VALIGN::EXPAND)
|
337
|
+
# ctrl.set_h_align(Wx::SF::Shape::HALIGN::EXPAND)
|
338
|
+
# ctrl.set_control(Wx::Button.new( self, Wx::ID_ANY, "Test"))
|
339
|
+
# shape.append_to_box(ctrl)
|
340
|
+
# end
|
341
|
+
|
342
|
+
# update the box
|
343
|
+
shape.update
|
344
|
+
end
|
345
|
+
|
255
346
|
when MainFrame::MODE::ELLIPSE
|
256
347
|
_, shape = get_diagram.create_shape(Wx::SF::EllipseShape, event.get_position, Wx::SF::DONT_SAVE_STATE)
|
257
348
|
if shape
|
@@ -311,14 +402,11 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
311
402
|
end
|
312
403
|
|
313
404
|
when MainFrame::MODE::STANDALONELINE
|
314
|
-
_, shape = get_diagram.
|
405
|
+
_, shape = get_diagram.insert_shape(Wx::SF::LineShape.new((event.get_position - [50, 0]).to_real,
|
406
|
+
(event.get_position + [50, 0]).to_real),
|
407
|
+
event.get_position,
|
408
|
+
Wx::SF::DONT_SAVE_STATE)
|
315
409
|
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
410
|
# line's ending style can be set as follows:
|
323
411
|
# shape.set_src_arrow(Wx::SF::CircleArrow)
|
324
412
|
# shape.set_trg_arrow(Wx::SF::CircleArrow)
|
@@ -343,37 +431,325 @@ class FrameCanvas < Wx::SF::ShapeCanvas
|
|
343
431
|
end
|
344
432
|
end
|
345
433
|
|
434
|
+
def create_shape_popup
|
435
|
+
menu = Wx::Menu.new
|
436
|
+
menu.append(POPUP_ID::STYLE, 'Change style', 'Change style')
|
437
|
+
menu.append(POPUP_ID::HOVER_COLOR, 'Change hover colour', 'Change hover colour')
|
438
|
+
menu.append(POPUP_ID::HALIGN, 'Change horizontal alignment', 'Change horizontal alignment')
|
439
|
+
menu.append(POPUP_ID::VALIGN, 'Change vertical alignment', 'Change vertical alignment')
|
440
|
+
menu.append(POPUP_ID::HBORDER, 'Change horizontal margin', 'Change horizontal margin')
|
441
|
+
menu.append(POPUP_ID::VBORDER, 'Change vertical margin', 'Change vertical margin')
|
442
|
+
submenu = Wx::Menu.new
|
443
|
+
submenu.append(POPUP_ID::ACC_CHILDREN, 'Child shapes', 'Change accepted child shapes')
|
444
|
+
submenu.append(POPUP_ID::ACC_CONNECTIONS, 'Connections', 'Change accepted connections')
|
445
|
+
submenu.append(POPUP_ID::ACC_CONNECTION_FROM, 'Connection sources', 'Change accepted connection sources')
|
446
|
+
submenu.append(POPUP_ID::ACC_CONNECTION_TO, 'Connection targets', 'Change accepted connection targets')
|
447
|
+
menu.append(Wx::MenuItem.new(submenu, POPUP_ID::ACCEPTED, 'Change accepted', '', Wx::ItemKind::ITEM_NORMAL, submenu))
|
448
|
+
menu.append(POPUP_ID::CONNECTION_POINTS, 'Change connection points', 'Change connection points')
|
449
|
+
|
450
|
+
@rect_mi = []
|
451
|
+
@rect_mi << Wx::MenuItem.new(menu, POPUP_ID::FILL_BRUSH, 'Change fill', 'Change fill brush')
|
452
|
+
@rect_mi << Wx::MenuItem.new(menu, POPUP_ID::BORDER_PEN, 'Change border', 'Change border pen')
|
453
|
+
|
454
|
+
@line_mi = []
|
455
|
+
@line_mi << Wx::MenuItem.new(menu, POPUP_ID::LINE_PEN, 'Change line', 'Change line pen')
|
456
|
+
submenu = Wx::Menu.new
|
457
|
+
submenu.append(POPUP_ID::SRC_ARROW, 'Change source arrow', 'Change source arrow')
|
458
|
+
submenu.append(POPUP_ID::TRG_ARROW, 'Change target arrow', 'Change target arrow')
|
459
|
+
@line_mi << Wx::MenuItem.new(menu, POPUP_ID::LINE_ARROWS, 'Change arrows', '', Wx::ItemKind::ITEM_NORMAL, submenu)
|
460
|
+
|
461
|
+
@text_mi = []
|
462
|
+
@text_mi << Wx::MenuItem.new(menu, POPUP_ID::TEXT_FONT, 'Change text font', 'Change text font')
|
463
|
+
@text_mi << Wx::MenuItem.new(menu, POPUP_ID::TEXT_COLOR, 'Change text colour', 'Change text colour')
|
464
|
+
|
465
|
+
@box_mi = Wx::MenuItem.new(menu, POPUP_ID::BOX_SPACING, 'Change slot spacing', 'Change slot spacing')
|
466
|
+
|
467
|
+
submenu = Wx::Menu.new
|
468
|
+
submenu.append(POPUP_ID::GRID_SPACING, 'Change cell spacing', 'Change cell spacing')
|
469
|
+
submenu.append(POPUP_ID::GRID_MAXROWS, 'Change row maximum', 'Change row maximum')
|
470
|
+
@grid_mi = Wx::MenuItem.new(menu, POPUP_ID::GRID_SETTINGS, 'Change grid settings', 'Change grid settings', Wx::ItemKind::ITEM_NORMAL, submenu)
|
471
|
+
|
472
|
+
menu.append_separator
|
473
|
+
menu.append(POPUP_ID::DUMP, 'Show serialized state', 'Show serialized state')
|
474
|
+
menu
|
475
|
+
end
|
476
|
+
private :create_shape_popup
|
477
|
+
|
478
|
+
def remove_popup_items(*item_ids)
|
479
|
+
item_ids.flatten.each { |id| @popup.remove(id) if @popup.find_item(id) }
|
480
|
+
end
|
481
|
+
private :remove_popup_items
|
482
|
+
|
483
|
+
def get_shape_popup(shape)
|
484
|
+
@popup ||= create_shape_popup
|
485
|
+
case shape
|
486
|
+
when Wx::SF::RectShape
|
487
|
+
remove_popup_items(POPUP_ID::LINE_PEN, POPUP_ID::LINE_ARROWS)
|
488
|
+
n = @popup.get_menu_item_count-2
|
489
|
+
@rect_mi.reverse.each { |mi| @popup.insert(n, mi) unless @popup.find_item(mi.id) }
|
490
|
+
case shape
|
491
|
+
when Wx::SF::TextShape
|
492
|
+
remove_popup_items(POPUP_ID::BOX_SPACING, POPUP_ID::GRID_SETTINGS)
|
493
|
+
n = @popup.get_menu_item_count-2
|
494
|
+
@text_mi.reverse.each { |mi| @popup.insert(n, mi) unless @popup.find_item(mi.id) }
|
495
|
+
when Wx::SF::BoxShape
|
496
|
+
remove_popup_items(POPUP_ID::TEXT_FONT, POPUP_ID::TEXT_COLOR, POPUP_ID::GRID_SETTINGS)
|
497
|
+
n = @popup.get_menu_item_count-2
|
498
|
+
@popup.insert(n, @box_mi) unless @popup.find_item(@box_mi.id)
|
499
|
+
when Wx::SF::GridShape
|
500
|
+
remove_popup_items(POPUP_ID::TEXT_FONT, POPUP_ID::TEXT_COLOR, POPUP_ID::BOX_SPACING)
|
501
|
+
n = @popup.get_menu_item_count-2
|
502
|
+
@popup.insert(n, @grid_mi) unless @popup.find_item(@grid_mi.id)
|
503
|
+
else
|
504
|
+
remove_popup_items(POPUP_ID::TEXT_FONT, POPUP_ID::TEXT_COLOR, POPUP_ID::BOX_SPACING, POPUP_ID::GRID_SETTINGS)
|
505
|
+
end
|
506
|
+
when Wx::SF::LineShape
|
507
|
+
remove_popup_items(POPUP_ID::FILL_BRUSH, POPUP_ID::BORDER_PEN,
|
508
|
+
POPUP_ID::TEXT_FONT, POPUP_ID::TEXT_COLOR,
|
509
|
+
POPUP_ID::BOX_SPACING, POPUP_ID::GRID_SETTINGS)
|
510
|
+
n = @popup.get_menu_item_count-2
|
511
|
+
@line_mi.reverse.each { |mi| @popup.insert(n, mi) unless @popup.find_item(mi.id) }
|
512
|
+
else
|
513
|
+
remove_popup_items(POPUP_ID::FILL_BRUSH, POPUP_ID::BORDER_PEN,
|
514
|
+
POPUP_ID::LINE_PEN, POPUP_ID::LINE_ARROWS,
|
515
|
+
POPUP_ID::TEXT_FONT, POPUP_ID::TEXT_COLOR,
|
516
|
+
POPUP_ID::BOX_SPACING, POPUP_ID::GRID_SETTINGS)
|
517
|
+
end
|
518
|
+
@popup
|
519
|
+
end
|
520
|
+
private :get_shape_popup
|
521
|
+
|
522
|
+
def get_enum_choices(enum, excludes: nil)
|
523
|
+
Dialogs.get_enum_choices(enum, excludes: excludes)
|
524
|
+
end
|
525
|
+
|
526
|
+
def get_enum_index(enumerator, excludes: nil)
|
527
|
+
Dialogs.get_enum_index(enumerator, excludes: excludes)
|
528
|
+
end
|
529
|
+
|
530
|
+
def index_to_enum(enum, index, excludes: nil)
|
531
|
+
Dialogs.index_to_enum(enum, index, excludes: excludes)
|
532
|
+
end
|
533
|
+
|
534
|
+
def selections_to_enum(enum, selections, excludes: nil)
|
535
|
+
Dialogs.selections_to_enum(enum, selections, excludes: excludes)
|
536
|
+
end
|
537
|
+
|
538
|
+
def enum_to_selections(enum, style, excludes: nil)
|
539
|
+
Dialogs.enum_to_selections(enum, style, excludes: excludes)
|
540
|
+
end
|
541
|
+
|
542
|
+
SHAPES = [
|
543
|
+
Wx::SF::RectShape,
|
544
|
+
Wx::SF::BitmapShape,
|
545
|
+
Wx::SF::SquareShape,
|
546
|
+
Wx::SF::CircleShape,
|
547
|
+
Wx::SF::PolygonShape,
|
548
|
+
Wx::SF::TextShape,
|
549
|
+
Wx::SF::RoundRectShape,
|
550
|
+
Wx::SF::GridShape,
|
551
|
+
Wx::SF::FlexGridShape,
|
552
|
+
Wx::SF::EllipseShape,
|
553
|
+
Wx::SF::ControlShape,
|
554
|
+
Wx::SF::BoxShape,
|
555
|
+
Wx::SF::VBoxShape,
|
556
|
+
Wx::SF::HBoxShape,
|
557
|
+
Wx::SF::DiamondShape,
|
558
|
+
Wx::SF::EditTextShape
|
559
|
+
]
|
560
|
+
|
561
|
+
CONNECTION_SHAPES = [
|
562
|
+
Wx::SF::LineShape,
|
563
|
+
Wx::SF::CurveShape,
|
564
|
+
Wx::SF::OrthoLineShape,
|
565
|
+
Wx::SF::RoundOrthoLineShape
|
566
|
+
]
|
567
|
+
|
346
568
|
def on_right_down(event)
|
347
569
|
# try to find shape under cursor
|
348
570
|
shape = get_shape_under_cursor
|
349
571
|
# alternatively you can use:
|
350
572
|
# shape = get_shape_at_position(dp2lp(event.getposition), 1, SEARCHMODE::BOTH)
|
351
573
|
|
352
|
-
#
|
574
|
+
# show shape popup (if found)
|
353
575
|
if shape
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
576
|
+
case self.get_popup_menu_selection_from_user(get_shape_popup(shape))
|
577
|
+
when POPUP_ID::STYLE
|
578
|
+
choices = get_enum_choices(Wx::SF::Shape::STYLE,
|
579
|
+
excludes: %i[DEFAULT_SHAPE_STYLE PROPAGATE_ALL])
|
580
|
+
sel = Wx.get_selected_choices('Select styles',
|
581
|
+
'Select multiple',
|
582
|
+
choices,
|
583
|
+
self,
|
584
|
+
initial_selections: enum_to_selections(Wx::SF::Shape::STYLE, shape.get_style,
|
585
|
+
excludes: %i[DEFAULT_SHAPE_STYLE PROPAGATE_ALL]))
|
586
|
+
if sel
|
587
|
+
shape.set_style(selections_to_enum(Wx::SF::Shape::STYLE, sel,
|
588
|
+
excludes: %i[DEFAULT_SHAPE_STYLE PROPAGATE_ALL]))
|
589
|
+
shape.update
|
363
590
|
end
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
591
|
+
when POPUP_ID::HOVER_COLOR
|
592
|
+
color = Wx.get_colour_from_user(self, shape.get_hover_colour, 'Select hover colour')
|
593
|
+
if color.ok?
|
594
|
+
shape.set_hover_colour(color)
|
595
|
+
shape.update
|
596
|
+
end
|
597
|
+
when POPUP_ID::HALIGN
|
598
|
+
case Wx.get_single_choice('Select horizontal alignment',
|
599
|
+
'Select',
|
600
|
+
%w[NONE LEFT CENTER RIGHT EXPAND],
|
601
|
+
self,
|
602
|
+
initial_selection: shape.get_h_align.to_i)
|
603
|
+
when 'NONE' then shape.set_h_align(Wx::SF::Shape::HALIGN::NONE)
|
604
|
+
when 'LEFT' then shape.set_h_align(Wx::SF::Shape::HALIGN::LEFT)
|
605
|
+
when 'CENTER' then shape.set_h_align(Wx::SF::Shape::HALIGN::CENTER)
|
606
|
+
when 'RIGHT' then shape.set_h_align(Wx::SF::Shape::HALIGN::RIGHT)
|
607
|
+
when 'EXPAND' then shape.set_h_align(Wx::SF::Shape::HALIGN::EXPAND)
|
608
|
+
end
|
609
|
+
shape.update
|
610
|
+
when POPUP_ID::VALIGN
|
611
|
+
case Wx.get_single_choice('Select vertical alignment',
|
612
|
+
'Select',
|
613
|
+
%w[NONE TOP MIDDLE BOTTOM EXPAND],
|
614
|
+
self,
|
615
|
+
initial_selection: shape.get_v_align.to_i)
|
616
|
+
when 'NONE' then shape.set_v_align(Wx::SF::Shape::VALIGN::NONE)
|
617
|
+
when 'TOP' then shape.set_v_align(Wx::SF::Shape::VALIGN::TOP)
|
618
|
+
when 'MIDDLE' then shape.set_v_align(Wx::SF::Shape::VALIGN::MIDDLE)
|
619
|
+
when 'BOTTOM' then shape.set_v_align(Wx::SF::Shape::VALIGN::BOTTOM)
|
620
|
+
when 'EXPAND' then shape.set_v_align(Wx::SF::Shape::HALIGN::EXPAND)
|
621
|
+
end
|
622
|
+
shape.update
|
623
|
+
when POPUP_ID::HBORDER
|
624
|
+
Dialogs.FloatDialog(self, 'Enter horizontal margin', value: shape.get_h_border) do |dlg|
|
625
|
+
if dlg.show_modal == Wx::ID_OK
|
626
|
+
shape.set_h_border(dlg.get_value)
|
627
|
+
shape.update
|
628
|
+
end
|
629
|
+
end
|
630
|
+
when POPUP_ID::VBORDER
|
631
|
+
Dialogs.FloatDialog(self, 'Enter vertical margin', value: shape.get_v_border) do |dlg|
|
632
|
+
if dlg.show_modal == Wx::ID_OK
|
633
|
+
shape.set_v_border(dlg.get_value)
|
634
|
+
shape.update
|
635
|
+
end
|
636
|
+
end
|
637
|
+
when POPUP_ID::ACC_CHILDREN
|
638
|
+
Dialogs.AcceptedShapesDialog(self, 'Select acceptable child shapes.', SHAPES, shape.accepted_children) do |dlg|
|
639
|
+
if dlg.show_modal == Wx::ID_OK
|
640
|
+
shape.accepted_children.clear
|
641
|
+
if (ss = dlg.get_selected_shapes(SHAPES))
|
642
|
+
shape.accepted_children.merge(ss)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
end
|
646
|
+
when POPUP_ID::ACC_CONNECTIONS
|
647
|
+
Dialogs.AcceptedShapesDialog(self, 'Select acceptable connection shapes.', CONNECTION_SHAPES, shape.accepted_connections) do |dlg|
|
648
|
+
if dlg.show_modal == Wx::ID_OK
|
649
|
+
shape.accepted_connections.clear
|
650
|
+
if (ss = dlg.get_selected_shapes(CONNECTION_SHAPES))
|
651
|
+
shape.accepted_connections.merge(ss)
|
652
|
+
end
|
653
|
+
end
|
654
|
+
end
|
655
|
+
when POPUP_ID::ACC_CONNECTION_FROM
|
656
|
+
shape_options = SHAPES - [shape.class]
|
657
|
+
Dialogs.AcceptedShapesDialog(self, 'Select acceptable connection source shapes.', shape_options, shape.accepted_src_neighbours) do |dlg|
|
658
|
+
if dlg.show_modal == Wx::ID_OK
|
659
|
+
shape.accepted_src_neighbours.clear
|
660
|
+
if (ss = dlg.get_selected_shapes(shape_options))
|
661
|
+
shape.accepted_src_neighbours.merge(ss)
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
665
|
+
when POPUP_ID::ACC_CONNECTION_TO
|
666
|
+
shape_options = SHAPES - [shape.class]
|
667
|
+
Dialogs.AcceptedShapesDialog(self, 'Select acceptable connection target shapes.', shape_options, shape.accepted_trg_neighbours) do |dlg|
|
668
|
+
if dlg.show_modal == Wx::ID_OK
|
669
|
+
shape.accepted_trg_neighbours.clear
|
670
|
+
if (ss = dlg.get_selected_shapes(shape_options))
|
671
|
+
shape.accepted_trg_neighbours.merge(ss)
|
672
|
+
end
|
673
|
+
end
|
674
|
+
end
|
675
|
+
when POPUP_ID::CONNECTION_POINTS
|
676
|
+
Dialogs.ConnectionPointDialog(self, shape.connection_points) do |dlg|
|
677
|
+
if dlg.show_modal == Wx::ID_OK
|
678
|
+
dlg.set_shape_connection_points(shape)
|
679
|
+
shape.update
|
680
|
+
end
|
681
|
+
end
|
682
|
+
when POPUP_ID::FILL_BRUSH
|
683
|
+
Dialogs.BrushDialog(self, 'Fill brush', shape.fill) do |dlg|
|
684
|
+
if dlg.show_modal == Wx::ID_OK
|
685
|
+
shape.set_fill(dlg.get_brush)
|
686
|
+
shape.update
|
687
|
+
end
|
688
|
+
end
|
689
|
+
when POPUP_ID::BORDER_PEN
|
690
|
+
Dialogs.PenDialog(self, 'Border pen', shape.border) do |dlg|
|
691
|
+
if dlg.show_modal == Wx::ID_OK
|
692
|
+
shape.set_border(dlg.get_pen)
|
693
|
+
shape.update
|
694
|
+
end
|
695
|
+
end
|
696
|
+
when POPUP_ID::TEXT_FONT
|
697
|
+
new_font = Wx.get_font_from_user(self, shape.font, 'Select text font')
|
698
|
+
if new_font.ok?
|
699
|
+
shape.font = new_font
|
700
|
+
shape.update
|
701
|
+
end
|
702
|
+
when POPUP_ID::TEXT_COLOR
|
703
|
+
color = Wx.get_colour_from_user(self, shape.text_colour, 'Select text colour')
|
704
|
+
if color.ok?
|
705
|
+
shape.text_colour(color)
|
706
|
+
shape.update
|
707
|
+
end
|
708
|
+
when POPUP_ID::BOX_SPACING
|
709
|
+
spc = Wx.get_number_from_user('Enter BoxShape slot spacing.', 'Value:', 'Slot spacing',
|
710
|
+
shape.spacing, 0, 100, self)
|
711
|
+
if spc >= 0
|
712
|
+
shape.spacing = spc
|
713
|
+
shape.update
|
714
|
+
end
|
715
|
+
when POPUP_ID::GRID_SPACING
|
716
|
+
spc = Wx.get_number_from_user('Enter GridShape cell spacing.', 'Value:', 'Cell spacing',
|
717
|
+
shape.cell_space, 0, 100, self)
|
718
|
+
if spc >= 0
|
719
|
+
shape.cell_space = spc
|
720
|
+
shape.update
|
721
|
+
end
|
722
|
+
when POPUP_ID::GRID_MAXROWS
|
723
|
+
spc = Wx.get_number_from_user('Enter GridShape maximum rows.', 'Value:', 'Maximum rows',
|
724
|
+
shape.max_rows, 0, 100, self)
|
725
|
+
if spc >= 0
|
726
|
+
shape.max_rows = spc
|
727
|
+
shape.update
|
728
|
+
end
|
729
|
+
when POPUP_ID::LINE_PEN
|
730
|
+
Dialogs.PenDialog(self, 'Line pen', shape.line_pen) do |dlg|
|
731
|
+
if dlg.show_modal == Wx::ID_OK
|
732
|
+
shape.set_line_pen(dlg.get_pen)
|
733
|
+
shape.update
|
734
|
+
end
|
735
|
+
end
|
736
|
+
when POPUP_ID::SRC_ARROW
|
737
|
+
Dialogs.ArrowDialog(self, 'Source arrow', shape.get_src_arrow) do |dlg|
|
738
|
+
if dlg.show_modal == Wx::ID_OK
|
739
|
+
shape.src_arrow = dlg.get_arrow
|
740
|
+
shape.update
|
741
|
+
end
|
372
742
|
end
|
743
|
+
when POPUP_ID::TRG_ARROW
|
744
|
+
Dialogs.ArrowDialog(self, 'Target arrow', shape.get_trg_arrow) do |dlg|
|
745
|
+
if dlg.show_modal == Wx::ID_OK
|
746
|
+
shape.trg_arrow = dlg.get_arrow
|
747
|
+
shape.update
|
748
|
+
end
|
749
|
+
end
|
750
|
+
when POPUP_ID::DUMP
|
751
|
+
Dialogs.StateDialog(self, shape)
|
373
752
|
end
|
374
|
-
|
375
|
-
# show message
|
376
|
-
Wx.message_box(msg, 'wxRuby ShapeFramework', Wx::OK | Wx::ICON_INFORMATION)
|
377
753
|
else
|
378
754
|
Wx.message_box('No shape found on this position.', 'wxRuby ShapeFramework', Wx::OK | Wx::ICON_INFORMATION)
|
379
755
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * logo_xpm[] = {
|
3
|
+
"32 32 25 1",
|
4
|
+
" c None",
|
5
|
+
". c #FFD700",
|
6
|
+
"+ c #000000",
|
7
|
+
"@ c #B22222",
|
8
|
+
"# c #060400",
|
9
|
+
"$ c #052092",
|
10
|
+
"% c #041C91",
|
11
|
+
"& c #051F92",
|
12
|
+
"* c #062594",
|
13
|
+
"= c #041E91",
|
14
|
+
"- c #000004",
|
15
|
+
"; c #052192",
|
16
|
+
"> c #051F8F",
|
17
|
+
", c #052293",
|
18
|
+
"' c #B22323",
|
19
|
+
") c #751616",
|
20
|
+
"! c #062393",
|
21
|
+
"~ c #02128F",
|
22
|
+
"{ c #041B91",
|
23
|
+
"] c #000021",
|
24
|
+
"^ c #00000D",
|
25
|
+
"/ c #052091",
|
26
|
+
"( c #000002",
|
27
|
+
"_ c #041D91",
|
28
|
+
": c #041D92",
|
29
|
+
" ",
|
30
|
+
" ............ ",
|
31
|
+
" ............ ",
|
32
|
+
" ............+++++++++ ",
|
33
|
+
" ............ + ",
|
34
|
+
" .... .... +++++ ",
|
35
|
+
" .... .... +++ ",
|
36
|
+
" .... .... + ",
|
37
|
+
" .... .... @@@@@ ",
|
38
|
+
" ............ @@@@@@@@ ",
|
39
|
+
" ............ @@@@@@@@@@@ ",
|
40
|
+
" ............ @@@ @@@ ",
|
41
|
+
" ............ @@@ @@@ ",
|
42
|
+
" # @@@ @@@ ",
|
43
|
+
" +++ @@@ @@@ ",
|
44
|
+
" +++++ @@@ @@@ ",
|
45
|
+
" + $% @@@ @@@ ",
|
46
|
+
" + &**= @@@@ @@@@ ",
|
47
|
+
" + &****$ @@@@@@@@@@@ ",
|
48
|
+
" -&******; @@@@@@@@@ ",
|
49
|
+
" >*** ***, '@@@@@@ ",
|
50
|
+
" &*** ***, ) ",
|
51
|
+
" &*** ***! + ",
|
52
|
+
" ~*** **; + ",
|
53
|
+
" {*** **; + ",
|
54
|
+
" %*** **$] + ",
|
55
|
+
" %*** **$^+ + ",
|
56
|
+
" %*****/(+++++++++++ ",
|
57
|
+
" _***$ ++ ",
|
58
|
+
" :*$ + ",
|
59
|
+
" * ",
|
60
|
+
" "};
|
data/samples/sample1/sample.rb
CHANGED
@@ -17,7 +17,7 @@ class SFSample1Frame < Wx::Frame
|
|
17
17
|
def initialize(title)
|
18
18
|
super(nil, Wx::StandardID::ID_ANY, title, size: [800,600])
|
19
19
|
|
20
|
-
self.icon = Wx::Icon(:
|
20
|
+
self.icon = Wx::Icon(:logo)
|
21
21
|
|
22
22
|
# initialize event types
|
23
23
|
@event_type_info = {
|
@@ -202,23 +202,23 @@ class SFSample1Frame < Wx::Frame
|
|
202
202
|
def on_shape_handle_event(event)
|
203
203
|
if @log_menu.is_checked(ID::MenuLogHandleEvent)
|
204
204
|
hnd_type =case event.handle.type
|
205
|
-
when Wx::SF::Shape::Handle::LEFTTOP
|
205
|
+
when Wx::SF::Shape::Handle::TYPE::LEFTTOP
|
206
206
|
"left-top"
|
207
|
-
when Wx::SF::Shape::Handle::TOP
|
207
|
+
when Wx::SF::Shape::Handle::TYPE::TOP
|
208
208
|
"top"
|
209
|
-
when Wx::SF::Shape::Handle::RIGHTTOP
|
209
|
+
when Wx::SF::Shape::Handle::TYPE::RIGHTTOP
|
210
210
|
"right-top"
|
211
|
-
when Wx::SF::Shape::Handle::LEFT
|
211
|
+
when Wx::SF::Shape::Handle::TYPE::LEFT
|
212
212
|
"left"
|
213
|
-
when Wx::SF::Shape::Handle::RIGHT
|
213
|
+
when Wx::SF::Shape::Handle::TYPE::RIGHT
|
214
214
|
"right"
|
215
|
-
when Wx::SF::Shape::Handle::LEFTBOTTOM
|
215
|
+
when Wx::SF::Shape::Handle::TYPE::LEFTBOTTOM
|
216
216
|
"left-bottom"
|
217
|
-
when Wx::SF::Shape::Handle::BOTTOM
|
217
|
+
when Wx::SF::Shape::Handle::TYPE::BOTTOM
|
218
218
|
"bottom"
|
219
|
-
when Wx::SF::Shape::Handle::RIGHTBOTTOM
|
219
|
+
when Wx::SF::Shape::Handle::TYPE::RIGHTBOTTOM
|
220
220
|
"right-bottom"
|
221
|
-
when Wx::SF::Shape::Handle::LINECTRL
|
221
|
+
when Wx::SF::Shape::Handle::TYPE::LINECTRL
|
222
222
|
"line-control"
|
223
223
|
else
|
224
224
|
''
|
@@ -248,7 +248,7 @@ class SFSample1Frame < Wx::Frame
|
|
248
248
|
@text_log.append_text("%s, Shape ID: %d, Child ID: %d\n" % [
|
249
249
|
@event_type_info[event.get_event_type],
|
250
250
|
event.get_id,
|
251
|
-
event.get_child_shape.
|
251
|
+
event.get_child_shape.object_id])
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * logo_xpm[] = {
|
3
|
+
"32 32 25 1",
|
4
|
+
" c None",
|
5
|
+
". c #FFD700",
|
6
|
+
"+ c #000000",
|
7
|
+
"@ c #B22222",
|
8
|
+
"# c #060400",
|
9
|
+
"$ c #052092",
|
10
|
+
"% c #041C91",
|
11
|
+
"& c #051F92",
|
12
|
+
"* c #062594",
|
13
|
+
"= c #041E91",
|
14
|
+
"- c #000004",
|
15
|
+
"; c #052192",
|
16
|
+
"> c #051F8F",
|
17
|
+
", c #052293",
|
18
|
+
"' c #B22323",
|
19
|
+
") c #751616",
|
20
|
+
"! c #062393",
|
21
|
+
"~ c #02128F",
|
22
|
+
"{ c #041B91",
|
23
|
+
"] c #000021",
|
24
|
+
"^ c #00000D",
|
25
|
+
"/ c #052091",
|
26
|
+
"( c #000002",
|
27
|
+
"_ c #041D91",
|
28
|
+
": c #041D92",
|
29
|
+
" ",
|
30
|
+
" ............ ",
|
31
|
+
" ............ ",
|
32
|
+
" ............+++++++++ ",
|
33
|
+
" ............ + ",
|
34
|
+
" .... .... +++++ ",
|
35
|
+
" .... .... +++ ",
|
36
|
+
" .... .... + ",
|
37
|
+
" .... .... @@@@@ ",
|
38
|
+
" ............ @@@@@@@@ ",
|
39
|
+
" ............ @@@@@@@@@@@ ",
|
40
|
+
" ............ @@@ @@@ ",
|
41
|
+
" ............ @@@ @@@ ",
|
42
|
+
" # @@@ @@@ ",
|
43
|
+
" +++ @@@ @@@ ",
|
44
|
+
" +++++ @@@ @@@ ",
|
45
|
+
" + $% @@@ @@@ ",
|
46
|
+
" + &**= @@@@ @@@@ ",
|
47
|
+
" + &****$ @@@@@@@@@@@ ",
|
48
|
+
" -&******; @@@@@@@@@ ",
|
49
|
+
" >*** ***, '@@@@@@ ",
|
50
|
+
" &*** ***, ) ",
|
51
|
+
" &*** ***! + ",
|
52
|
+
" ~*** **; + ",
|
53
|
+
" {*** **; + ",
|
54
|
+
" %*** **$] + ",
|
55
|
+
" %*** **$^+ + ",
|
56
|
+
" %*****/(+++++++++++ ",
|
57
|
+
" _***$ ++ ",
|
58
|
+
" :*$ + ",
|
59
|
+
" * ",
|
60
|
+
" "};
|