wxruby3-shapes 0.9.0.pre.beta.3 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +5 -7
  3. data/README.md +38 -6
  4. data/assets/logo.svg +339 -0
  5. data/assets/logo.xpm +60 -0
  6. data/assets/screenshot.png +0 -0
  7. data/assets/social.png +0 -0
  8. data/bin/wx-shapes +1 -1
  9. data/lib/wx/shapes/arrow_base.rb +4 -11
  10. data/lib/wx/shapes/arrows/circle_arrow.rb +22 -11
  11. data/lib/wx/shapes/arrows/circle_prong_arrow.rb +48 -0
  12. data/lib/wx/shapes/arrows/cross_bar_arrow.rb +57 -0
  13. data/lib/wx/shapes/arrows/cross_bar_circle_arrow.rb +56 -0
  14. data/lib/wx/shapes/arrows/cross_bar_prong_arrow.rb +49 -0
  15. data/lib/wx/shapes/arrows/crossed_circle.rb +46 -0
  16. data/lib/wx/shapes/arrows/cup_arrow.rb +65 -0
  17. data/lib/wx/shapes/arrows/diamond_arrow.rb +8 -13
  18. data/lib/wx/shapes/arrows/double_cross_bar_arrow.rb +27 -0
  19. data/lib/wx/shapes/arrows/filled_arrow.rb +60 -0
  20. data/lib/wx/shapes/arrows/line_arrow.rb +67 -0
  21. data/lib/wx/shapes/arrows/open_arrow.rb +22 -23
  22. data/lib/wx/shapes/arrows/prong_arrow.rb +42 -0
  23. data/lib/wx/shapes/arrows/solid_arrow.rb +21 -35
  24. data/lib/wx/shapes/arrows/square_arrow.rb +37 -0
  25. data/lib/wx/shapes/auto_layout.rb +2 -2
  26. data/lib/wx/shapes/base.rb +1 -1
  27. data/lib/wx/shapes/canvas_history.rb +20 -0
  28. data/lib/wx/shapes/connection_point.rb +10 -6
  29. data/lib/wx/shapes/diagram.rb +98 -78
  30. data/lib/wx/shapes/events.rb +8 -8
  31. data/lib/wx/shapes/printout.rb +3 -16
  32. data/lib/wx/shapes/serializable.rb +2 -436
  33. data/lib/wx/shapes/serialize/wx.rb +30 -18
  34. data/lib/wx/shapes/shape.rb +211 -168
  35. data/lib/wx/shapes/shape_canvas.rb +728 -267
  36. data/lib/wx/shapes/shape_data_object.rb +99 -18
  37. data/lib/wx/shapes/shape_handle.rb +18 -11
  38. data/lib/wx/shapes/shape_list.rb +34 -67
  39. data/lib/wx/shapes/shapes/bitmap_shape.rb +23 -24
  40. data/lib/wx/shapes/shapes/box_shape.rb +389 -0
  41. data/lib/wx/shapes/shapes/circle_shape.rb +19 -22
  42. data/lib/wx/shapes/shapes/control_shape.rb +77 -41
  43. data/lib/wx/shapes/shapes/curve_shape.rb +38 -31
  44. data/lib/wx/shapes/shapes/diamond_shape.rb +7 -17
  45. data/lib/wx/shapes/shapes/edit_text_shape.rb +6 -9
  46. data/lib/wx/shapes/shapes/ellipse_shape.rb +12 -15
  47. data/lib/wx/shapes/shapes/flex_grid_shape.rb +58 -33
  48. data/lib/wx/shapes/shapes/grid_shape.rb +259 -161
  49. data/lib/wx/shapes/shapes/line_shape.rb +155 -161
  50. data/lib/wx/shapes/shapes/manager_shape.rb +77 -0
  51. data/lib/wx/shapes/shapes/multi_sel_rect.rb +8 -8
  52. data/lib/wx/shapes/shapes/ortho_shape.rb +31 -36
  53. data/lib/wx/shapes/shapes/polygon_shape.rb +23 -29
  54. data/lib/wx/shapes/shapes/rect_shape.rb +95 -53
  55. data/lib/wx/shapes/shapes/round_ortho_shape.rb +6 -8
  56. data/lib/wx/shapes/shapes/round_rect_shape.rb +20 -24
  57. data/lib/wx/shapes/shapes/square_shape.rb +14 -17
  58. data/lib/wx/shapes/shapes/text_shape.rb +95 -53
  59. data/lib/wx/shapes/version.rb +1 -1
  60. data/lib/wx/shapes/wx.rb +16 -7
  61. data/lib/wx/wx-shapes/cmd/test.rb +1 -1
  62. data/samples/demo/arrows.json +1 -0
  63. data/samples/demo/arrows.yaml +793 -0
  64. data/samples/demo/art/HBox.xpm +22 -0
  65. data/samples/demo/art/VBox.xpm +22 -0
  66. data/samples/demo/art/logo.xpm +60 -0
  67. data/samples/demo/class.json +1 -0
  68. data/samples/demo/class.yaml +5631 -0
  69. data/samples/demo/demo.rb +301 -91
  70. data/samples/demo/dialogs.rb +1405 -0
  71. data/samples/demo/erd.json +1 -0
  72. data/samples/demo/erd.yaml +4072 -0
  73. data/samples/demo/frame_canvas.rb +409 -33
  74. data/samples/sample1/art/logo.xpm +60 -0
  75. data/samples/sample1/sample.rb +11 -11
  76. data/samples/sample2/art/logo.xpm +60 -0
  77. data/samples/sample2/sample.rb +2 -2
  78. data/samples/sample2/sample_shape.rb +15 -15
  79. data/samples/sample3/art/logo.xpm +60 -0
  80. data/samples/sample3/sample.rb +3 -3
  81. data/samples/sample4/art/logo.xpm +60 -0
  82. data/samples/sample4/sample.rb +2 -2
  83. data/tests/lib/wxapp_runner.rb +4 -0
  84. data/tests/serializer_tests.rb +8 -441
  85. data/tests/test_grid_shapes.rb +2 -2
  86. data/tests/test_serialize_xml.rb +17 -0
  87. data/tests/test_serialize_yaml.rb +2 -2
  88. metadata +78 -28
  89. data/lib/wx/shapes/serialize/core.rb +0 -40
  90. data/lib/wx/shapes/serialize/id.rb +0 -82
  91. data/lib/wx/shapes/serializer/json.rb +0 -258
  92. data/lib/wx/shapes/serializer/yaml.rb +0 -125
  93. data/samples/demo/art/sample.xpm +0 -251
  94. data/samples/sample1/art/sample.xpm +0 -251
  95. data/samples/sample2/art/sample.xpm +0 -251
  96. data/samples/sample3/art/sample.xpm +0 -251
  97. data/samples/sample4/art/sample.xpm +0 -251
@@ -0,0 +1,1405 @@
1
+ # Wx::SF - Demo Dialogs
2
+ # Copyright (c) M.J.N. Corino, The Netherlands
3
+
4
+ require 'wx/shapes'
5
+
6
+ module Dialogs
7
+
8
+ class << self
9
+ def get_enum_choices(enum, excludes: nil)
10
+ enumerators = enum.enumerators(excludes).sort_by(&:first)
11
+ enumerators.collect { |_, esym| esym.to_s }
12
+ end
13
+
14
+ def get_enum_index(enumerator, excludes: nil)
15
+ enum = enumerator.class
16
+ enumerators = enum.enumerators(excludes).sort_by(&:first)
17
+ enumerators.index { |e, _| enumerator == e }
18
+ end
19
+
20
+ def index_to_enum(enum, index, excludes: nil)
21
+ enumerators = enum.enumerators(excludes).sort_by(&:first)
22
+ enum[enumerators[index].last]
23
+ end
24
+
25
+ def selections_to_enum(enum, selections, excludes: nil)
26
+ enumerators = enum.enumerators(excludes).sort_by(&:first)
27
+ selections.inject(enum.new(0)) do |mask, ix|
28
+ mask | enumerators[ix].first
29
+ end
30
+ end
31
+
32
+ def enum_to_selections(enum, style, excludes: nil)
33
+ sel = []
34
+ enumerators = enum.enumerators(excludes).sort_by(&:first)
35
+ enumerators.each_with_index do |(e, _), ix|
36
+ sel << ix if style.allbits?(e)
37
+ end
38
+ sel
39
+ end
40
+ end
41
+
42
+ class WXSFPreferencesDialog < Wx::PropertySheetDialog
43
+
44
+ # @param [Wx::Window] parent
45
+ # @param [FrameCanvas] canvas
46
+ def initialize(parent, canvas)
47
+ super()
48
+
49
+ create(parent, Wx::ID_ANY, "Preferences")
50
+ create_buttons(Wx::OK|Wx::CANCEL|Wx::APPLY)
51
+
52
+ @canvas = canvas
53
+ @changed = false
54
+
55
+ book_ctrl.add_page(canvas_panel, 'Appearance', true)
56
+ book_ctrl.add_page(behaviour_panel, 'Behaviour', true)
57
+ book_ctrl.add_page(print_panel, 'Print', true)
58
+ book_ctrl.add_page(shapes_panel, 'Shapes', true)
59
+
60
+ book_ctrl.change_selection(0)
61
+
62
+ layout_dialog
63
+
64
+ evt_update_ui Wx::ID_ANY, :on_update_ui
65
+ evt_radiobutton Wx::ID_ANY, :on_change
66
+ evt_checkbox Wx::ID_ANY, :on_change
67
+ evt_colourpicker_changed Wx::ID_ANY, :on_change
68
+ evt_fontpicker_changed Wx::ID_ANY, :on_change
69
+ evt_combobox Wx::ID_ANY, :on_change
70
+ evt_spinctrl Wx::ID_ANY, :on_change
71
+ evt_spinctrldouble Wx::ID_ANY, :on_change
72
+ evt_button Wx::ID_APPLY, :on_apply
73
+ evt_button Wx::ID_OK, :on_apply
74
+ end
75
+
76
+ def canvas_panel
77
+ Wx::Panel.new(book_ctrl) do |panel|
78
+ panel.sizer = Wx::VBoxSizer.new do |vszr|
79
+
80
+ vszr.add Wx::HBoxSizer.new { |hszr|
81
+ hszr.add(Wx::StaticText.new(panel, :label => "Colours"), Wx::SizerFlags.new)
82
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
83
+ }, Wx::SizerFlags.new.expand.border
84
+ vszr.add Wx::HBoxSizer.new { |hszr|
85
+ hszr.add Wx::VBoxSizer.new { |bgc_vszr|
86
+ bgc_vszr.add(@rb_use_bgc = Wx::RadioButton.new(panel, Wx::ID_ANY, 'Use regular background colour', style: Wx::RB_GROUP),
87
+ Wx::SizerFlags.new.left.border(Wx::BOTTOM))
88
+ bgc_vszr.add @use_bgc_szr = Wx::HBoxSizer.new { |hszr_|
89
+ hszr_.add(Wx::StaticText.new(panel, :label => "Background colour:"), Wx::SizerFlags.new)
90
+ hszr_.add(@bg_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
91
+ Wx::SizerFlags.new.horz_border)
92
+ }, Wx::SizerFlags.new.horz_border
93
+ }, Wx::SizerFlags.new
94
+ hszr.add Wx::VBoxSizer.new { |gbgc_vszr|
95
+ gbgc_vszr.add(@rb_use_gbgc = Wx::RadioButton.new(panel, Wx::ID_ANY, 'Use gradient background colour'),
96
+ Wx::SizerFlags.new.left.border(Wx::BOTTOM))
97
+ gbgc_vszr.add @use_gbgc_szr = Wx::HBoxSizer.new { |hszr_|
98
+ hszr_.add(Wx::StaticText.new(panel, :label => "Gradient from:"), Wx::SizerFlags.new)
99
+ hszr_.add(@gbg_from_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
100
+ Wx::SizerFlags.new.horz_border)
101
+ hszr_.add(Wx::StaticText.new(panel, :label => "to:"), Wx::SizerFlags.new)
102
+ hszr_.add(@gbg_to_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
103
+ Wx::SizerFlags.new.horz_border)
104
+ }, Wx::SizerFlags.new.horz_border
105
+ }, Wx::SizerFlags.new
106
+ }, Wx::SizerFlags.new.border
107
+
108
+ @bg_clr.colour = @canvas.get_canvas_colour
109
+ @gbg_from_clr.colour = @canvas.get_gradient_from
110
+ @gbg_to_clr.colour = @canvas.get_gradient_to
111
+ @rb_use_gbgc.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRADIENT_BACKGROUND)
112
+
113
+ vszr.add Wx::HBoxSizer.new { |hszr|
114
+ hszr.add(Wx::StaticText.new(panel, :label => "Highlight colour:"), Wx::SizerFlags.new.border(Wx::LEFT))
115
+ hszr.add(@hover_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
116
+ Wx::SizerFlags.new.border(Wx::LEFT))
117
+ }, Wx::SizerFlags.new.border
118
+
119
+ @hover_clr.colour = @canvas.get_hover_colour
120
+
121
+ vszr.add Wx::HBoxSizer.new { |hszr|
122
+ hszr.add(Wx::StaticText.new(panel, :label => "Grid"), Wx::SizerFlags.new)
123
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
124
+ }, Wx::SizerFlags.new.expand.border
125
+ vszr.add Wx::HBoxSizer.new { |hszr|
126
+ hszr.add(Wx::StaticText.new(panel, :label => "Grid size (px):"), Wx::SizerFlags.new.border(Wx::LEFT))
127
+ hszr.add(@grid_sz = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
128
+ Wx::SizerFlags.new.horz_border)
129
+ hszr.add(Wx::StaticText.new(panel, :label => "Grid line multiplier:"), Wx::SizerFlags.new.border(Wx::LEFT))
130
+ hszr.add(@grid_ln_mult = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
131
+ Wx::SizerFlags.new.horz_border)
132
+ }, Wx::SizerFlags.new.border
133
+ vszr.add Wx::HBoxSizer.new { |hszr|
134
+ hszr.add(@cb_grid_show = Wx::CheckBox.new(panel, label: 'Show grid:', style: Wx::ALIGN_RIGHT), Wx::SizerFlags.new.border(Wx::LEFT, 3))
135
+ hszr.add Wx::HBoxSizer.new { |hszr_|
136
+ @grid_pen_szr = hszr_
137
+ hszr_.add(Wx::StaticText.new(panel, :label => "Grid colour:"), Wx::SizerFlags.new.double_border(Wx::LEFT))
138
+ hszr_.add(@grid_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
139
+ Wx::SizerFlags.new.horz_border)
140
+ hszr_.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Grid line style:'), Wx::SizerFlags.new)
141
+ @grid_line_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
142
+ choices: get_enum_choices(
143
+ Wx::PenStyle,
144
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
145
+ hszr_.add(@grid_line_style, Wx::SizerFlags.new.horz_border)
146
+ }
147
+ }, Wx::SizerFlags.new.border
148
+ vszr.add Wx::HBoxSizer.new { |hszr|
149
+ hszr.add(@cb_grid_use = Wx::CheckBox.new(panel, label: 'Snap to grid:', style: Wx::ALIGN_RIGHT), Wx::SizerFlags.new.border(Wx::LEFT, 3))
150
+ }, Wx::SizerFlags.new.border
151
+
152
+ @grid_sz.value = @canvas.grid_size
153
+ @grid_ln_mult.value = @canvas.grid_line_mult
154
+ @grid_clr.colour = @canvas.grid_colour
155
+ @grid_line_style.selection = pen_style_index(@canvas.grid_style)
156
+ @cb_grid_show.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRID_SHOW)
157
+ @cb_grid_use.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRID_USE)
158
+
159
+ vszr.add Wx::HBoxSizer.new { |hszr|
160
+ hszr.add(Wx::StaticText.new(panel, :label => "Shadows"), Wx::SizerFlags.new)
161
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
162
+ }, Wx::SizerFlags.new.expand.border
163
+ vszr.add Wx::HBoxSizer.new { |hszr|
164
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Shadow offset x:'), Wx::SizerFlags.new.border(Wx::LEFT))
165
+ hszr.add(@shadow_off_x = Wx::SpinCtrlDouble.new(panel, min: 0.0, inc: 1.0),
166
+ Wx::SizerFlags.new.border(Wx::LEFT))
167
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'y:'), Wx::SizerFlags.new.border(Wx::LEFT))
168
+ hszr.add(@shadow_off_y = Wx::SpinCtrlDouble.new(panel, min: 0.0, inc: 1.0),
169
+ Wx::SizerFlags.new.border(Wx::LEFT))
170
+ }, Wx::SizerFlags.new.border
171
+ vszr.add Wx::HBoxSizer.new { |hszr|
172
+ hszr.add(Wx::StaticText.new(panel, :label => "Shadow colour:"), Wx::SizerFlags.new.border(Wx::LEFT))
173
+ hszr.add(@shadow_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
174
+ Wx::SizerFlags.new.border(Wx::LEFT))
175
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Shadow style:'), Wx::SizerFlags.new.border(Wx::LEFT))
176
+ @shadow_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
177
+ choices: get_enum_choices(
178
+ Wx::BrushStyle,
179
+ excludes: EXCL_BRUSH_STYLES))
180
+ hszr.add(@shadow_style, Wx::SizerFlags.new.border(Wx::LEFT))
181
+ }, Wx::SizerFlags.new.border
182
+
183
+ @shadow_off_x.value = @canvas.shadow_offset.x
184
+ @shadow_off_y.value = @canvas.shadow_offset.y
185
+ @shadow_clr.colour = @canvas.shadow_fill.colour
186
+ @shadow_style.selection = brush_style_index(@canvas.shadow_fill.style)
187
+
188
+ vszr.add Wx::HBoxSizer.new { |hszr|
189
+ hszr.add(Wx::StaticText.new(panel, :label => "Scaling"), Wx::SizerFlags.new)
190
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
191
+ }, Wx::SizerFlags.new.expand.border
192
+ vszr.add Wx::HBoxSizer.new { |hszr|
193
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Minimum scale:'), Wx::SizerFlags.new.border(Wx::LEFT))
194
+ hszr.add(@min_scale = Wx::SpinCtrlDouble.new(panel, inc: 0.1),
195
+ Wx::SizerFlags.new.border(Wx::LEFT))
196
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Maximum scale:'), Wx::SizerFlags.new.border(Wx::LEFT))
197
+ hszr.add(@max_scale = Wx::SpinCtrlDouble.new(panel, inc: 0.1),
198
+ Wx::SizerFlags.new.border(Wx::LEFT))
199
+ }, Wx::SizerFlags.new.border
200
+ vszr.add Wx::HBoxSizer.new { |hszr|
201
+ hszr.add(@cb_mouse_wheel_scale = Wx::CheckBox.new(panel, label: 'Mouse wheel scales:', style: Wx::ALIGN_RIGHT),
202
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
203
+ }, Wx::SizerFlags.new.border
204
+
205
+ @min_scale.set_range(0.1, @canvas.max_scale)
206
+ @min_scale.value = @canvas.min_scale
207
+ @max_scale.set_range(@canvas.min_scale, 100.0)
208
+ @max_scale.value = @canvas.max_scale
209
+ @cb_mouse_wheel_scale.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::PROCESS_MOUSEWHEEL)
210
+
211
+ end
212
+ end
213
+ end
214
+
215
+ def behaviour_panel
216
+ Wx::Panel.new(book_ctrl) do |panel|
217
+ panel.sizer = Wx::VBoxSizer.new do |vszr|
218
+
219
+ vszr.add Wx::HBoxSizer.new { |hszr|
220
+ hszr.add(Wx::StaticText.new(panel, :label => "Selection"), Wx::SizerFlags.new)
221
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
222
+ }, Wx::SizerFlags.new.expand.border
223
+ vszr.add Wx::HBoxSizer.new { |hszr|
224
+ hszr.add(@cb_hover_highlight = Wx::CheckBox.new(panel, label: 'Highlight shapes on hover:', style: Wx::ALIGN_RIGHT),
225
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
226
+ }, Wx::SizerFlags.new.border
227
+ vszr.add Wx::HBoxSizer.new { |hszr|
228
+ hszr.add(@cb_multi_select = Wx::CheckBox.new(panel, label: 'Allow selecting multiple shapes:', style: Wx::ALIGN_RIGHT),
229
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
230
+ hszr.add(@cb_multi_resize = Wx::CheckBox.new(panel, label: 'Allow resizing multiple shapes:', style: Wx::ALIGN_RIGHT),
231
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
232
+ }, Wx::SizerFlags.new.border
233
+
234
+ @cb_hover_highlight.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::HOVERING)
235
+ @cb_multi_select.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::MULTI_SELECTION)
236
+ @cb_multi_resize.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::MULTI_SIZE_CHANGE)
237
+
238
+ vszr.add Wx::HBoxSizer.new { |hszr|
239
+ hszr.add(Wx::StaticText.new(panel, :label => "Editing"), Wx::SizerFlags.new)
240
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
241
+ }, Wx::SizerFlags.new.expand.border
242
+ vszr.add Wx::HBoxSizer.new { |hszr|
243
+ hszr.add(@cb_clipboard = Wx::CheckBox.new(panel, label: 'Enable Clipboard operations:', style: Wx::ALIGN_RIGHT),
244
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
245
+ hszr.add(@cb_undo_redo = Wx::CheckBox.new(panel, label: 'Enable Undo/Redo operations:', style: Wx::ALIGN_RIGHT),
246
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
247
+ }, Wx::SizerFlags.new.border
248
+
249
+ @cb_clipboard.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::CLIPBOARD)
250
+ @cb_undo_redo.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::UNDOREDO)
251
+
252
+ if Wx.has_feature?(:USE_DRAG_AND_DROP)
253
+ vszr.add Wx::HBoxSizer.new { |hszr|
254
+ hszr.add(@cb_dnd = Wx::CheckBox.new(panel, label: 'Enable Drag&Drop operations:', style: Wx::ALIGN_RIGHT),
255
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
256
+ hszr.add(@cb_drop_highlight = Wx::CheckBox.new(panel, label: 'Highlight when drop allowed:', style: Wx::ALIGN_RIGHT),
257
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
258
+ }, Wx::SizerFlags.new.border
259
+
260
+ @cb_dnd.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::DND)
261
+ @cb_drop_highlight.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::HIGHLIGHTING)
262
+ end
263
+
264
+ end
265
+ end
266
+ end
267
+
268
+ def print_panel
269
+ Wx::Panel.new(book_ctrl) do |panel|
270
+ panel.sizer = Wx::VBoxSizer.new do |vszr|
271
+
272
+ vszr.add Wx::HBoxSizer.new { |hszr|
273
+ hszr.add(Wx::StaticText.new(panel, :label => "Content"), Wx::SizerFlags.new)
274
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
275
+ }, Wx::SizerFlags.new.expand.border
276
+ vszr.add Wx::HBoxSizer.new { |hszr|
277
+ hszr.add(@cb_print_bg = Wx::CheckBox.new(panel, label: 'Print background:', style: Wx::ALIGN_RIGHT),
278
+ Wx::SizerFlags.new.border(Wx::LEFT, 3))
279
+ }, Wx::SizerFlags.new.border
280
+
281
+ @cb_print_bg.value = @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::PRINT_BACKGROUND)
282
+
283
+ vszr.add Wx::HBoxSizer.new { |hszr|
284
+ hszr.add(Wx::StaticText.new(panel, :label => "Printout"), Wx::SizerFlags.new)
285
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
286
+ }, Wx::SizerFlags.new.expand.border
287
+ vszr.add Wx::HBoxSizer.new { |hszr|
288
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Print mode:'), Wx::SizerFlags.new.border(Wx::LEFT))
289
+ @print_mode = Wx::ComboBox.new(panel, Wx::ID_ANY,
290
+ choices: get_enum_choices(Wx::SF::ShapeCanvas::PRINTMODE))
291
+ hszr.add(@print_mode, Wx::SizerFlags.new.border(Wx::LEFT))
292
+ }, Wx::SizerFlags.new.border
293
+ vszr.add Wx::HBoxSizer.new { |hszr|
294
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Horizontal alignment:'), Wx::SizerFlags.new.border(Wx::LEFT))
295
+ @print_halign = Wx::ComboBox.new(panel, Wx::ID_ANY,
296
+ choices: get_enum_choices(Wx::SF::ShapeCanvas::HALIGN))
297
+ hszr.add(@print_halign, Wx::SizerFlags.new.border(Wx::LEFT))
298
+ }, Wx::SizerFlags.new.border
299
+ vszr.add Wx::HBoxSizer.new { |hszr|
300
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Vertical alignment:'), Wx::SizerFlags.new.border(Wx::LEFT))
301
+ @print_valign = Wx::ComboBox.new(panel, Wx::ID_ANY,
302
+ choices: get_enum_choices(Wx::SF::ShapeCanvas::VALIGN))
303
+ hszr.add(@print_valign, Wx::SizerFlags.new.border(Wx::LEFT))
304
+ }, Wx::SizerFlags.new.border
305
+
306
+ @print_mode.selection = get_enum_index(@canvas.print_mode)
307
+ @print_halign.selection = get_enum_index(@canvas.print_h_align)
308
+ @print_valign.selection = get_enum_index(@canvas.print_v_align)
309
+
310
+ end
311
+ end
312
+ end
313
+
314
+ def shapes_panel
315
+ Wx::Panel.new(book_ctrl) do |panel|
316
+ panel.sizer = Wx::VBoxSizer.new do |vszr|
317
+
318
+ vszr.add Wx::HBoxSizer.new { |hszr|
319
+ hszr.add(Wx::StaticText.new(panel, :label => "Common"), Wx::SizerFlags.new)
320
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
321
+ }, Wx::SizerFlags.new.expand.border
322
+ vszr.add Wx::HBoxSizer.new { |hszr|
323
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
324
+ hszr.add(@border_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
325
+ Wx::SizerFlags.new)
326
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border width:'), Wx::SizerFlags.new.horz_border)
327
+ hszr.add(@border_wdt = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
328
+ Wx::SizerFlags.new)
329
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border style:'), Wx::SizerFlags.new.horz_border)
330
+ @border_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
331
+ choices: get_enum_choices(
332
+ Wx::PenStyle,
333
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
334
+ hszr.add(@border_style, Wx::SizerFlags.new)
335
+ }, Wx::SizerFlags.new.border
336
+ vszr.add Wx::HBoxSizer.new { |hszr|
337
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Fill colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
338
+ hszr.add(@fill_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
339
+ Wx::SizerFlags.new)
340
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Fill style:'), Wx::SizerFlags.new.horz_border)
341
+ @fill_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
342
+ choices: get_enum_choices(Wx::BrushStyle,
343
+ excludes: EXCL_BRUSH_STYLES))
344
+ hszr.add(@fill_style, Wx::SizerFlags.new)
345
+ }, Wx::SizerFlags.new.border
346
+
347
+ @border_clr.colour = @canvas.border_pen.colour
348
+ @border_wdt.value = @canvas.border_pen.width
349
+ @border_style.selection = pen_style_index(@canvas.border_pen.style)
350
+ @fill_clr.colour = @canvas.fill_brush.colour
351
+ @fill_style.selection = brush_style_index(@canvas.fill_brush.style)
352
+
353
+ vszr.add Wx::HBoxSizer.new { |hszr|
354
+ hszr.add(Wx::StaticText.new(panel, :label => "Text shapes"), Wx::SizerFlags.new)
355
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
356
+ }, Wx::SizerFlags.new.expand.border
357
+ vszr.add Wx::HBoxSizer.new { |hszr|
358
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Text colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
359
+ hszr.add(@text_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
360
+ Wx::SizerFlags.new)
361
+ }, Wx::SizerFlags.new.border
362
+ vszr.add Wx::HBoxSizer.new { |hszr|
363
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Background colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
364
+ hszr.add(@text_fill_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
365
+ Wx::SizerFlags.new)
366
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Background style:'), Wx::SizerFlags.new.horz_border)
367
+ @text_fill_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
368
+ choices: get_enum_choices(Wx::BrushStyle,
369
+ excludes: EXCL_BRUSH_STYLES))
370
+ hszr.add(@text_fill_style, Wx::SizerFlags.new)
371
+ }, Wx::SizerFlags.new.border
372
+ vszr.add Wx::HBoxSizer.new { |hszr|
373
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
374
+ hszr.add(@text_border_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
375
+ Wx::SizerFlags.new)
376
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border width:'), Wx::SizerFlags.new.horz_border)
377
+ hszr.add(@text_border_wdt = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
378
+ Wx::SizerFlags.new)
379
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border style:'), Wx::SizerFlags.new.horz_border)
380
+ @text_border_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
381
+ choices: get_enum_choices(
382
+ Wx::PenStyle,
383
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
384
+ hszr.add(@text_border_style, Wx::SizerFlags.new)
385
+ }, Wx::SizerFlags.new.border
386
+ vszr.add Wx::HBoxSizer.new { |hszr|
387
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Font:'), Wx::SizerFlags.new.border(Wx::RIGHT))
388
+ hszr.add(@text_font = Wx::FontPickerCtrl.new(panel, Wx::ID_ANY),
389
+ Wx::SizerFlags.new)
390
+ }, Wx::SizerFlags.new.border
391
+
392
+ @text_clr.colour = @canvas.text_colour
393
+ @text_border_clr.colour = @canvas.text_border.colour
394
+ @text_border_wdt.value = @canvas.text_border.width
395
+ @text_border_style.selection = pen_style_index(@canvas.text_border.style)
396
+ @text_fill_clr.colour = @canvas.text_fill.colour
397
+ @text_fill_style.selection = brush_style_index(@canvas.text_fill.style)
398
+ @text_font.selected_font = @canvas.text_font
399
+
400
+ vszr.add Wx::HBoxSizer.new { |hszr|
401
+ hszr.add(Wx::StaticText.new(panel, :label => "Control shapes"), Wx::SizerFlags.new)
402
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
403
+ }, Wx::SizerFlags.new.expand.border
404
+ vszr.add Wx::HBoxSizer.new { |hszr|
405
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Background colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
406
+ hszr.add(@ctrl_fill_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
407
+ Wx::SizerFlags.new)
408
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Background style:'), Wx::SizerFlags.new.horz_border)
409
+ @ctrl_fill_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
410
+ choices: get_enum_choices(Wx::BrushStyle,
411
+ excludes: EXCL_BRUSH_STYLES))
412
+ hszr.add(@ctrl_fill_style, Wx::SizerFlags.new)
413
+ }, Wx::SizerFlags.new.border
414
+ vszr.add Wx::HBoxSizer.new { |hszr|
415
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
416
+ hszr.add(@ctrl_border_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
417
+ Wx::SizerFlags.new)
418
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border width:'), Wx::SizerFlags.new.horz_border)
419
+ hszr.add(@ctrl_border_wdt = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
420
+ Wx::SizerFlags.new)
421
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Border style:'), Wx::SizerFlags.new.horz_border)
422
+ @ctrl_border_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
423
+ choices: get_enum_choices(
424
+ Wx::PenStyle,
425
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
426
+ hszr.add(@ctrl_border_style, Wx::SizerFlags.new)
427
+ }, Wx::SizerFlags.new.border
428
+ vszr.add Wx::StaticBoxSizer.new(Wx::VERTICAL, panel, 'While modifying (resize, drag)') { |sb_vszr|
429
+ sb_vszr.add Wx::HBoxSizer.new { |hszr|
430
+ hszr.add(Wx::StaticText.new(sb_vszr.static_box, Wx::ID_ANY, 'Background colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
431
+ hszr.add(@ctrl_mod_fill_clr = Wx::ColourPickerCtrl.new(sb_vszr.static_box, Wx::ID_ANY),
432
+ Wx::SizerFlags.new)
433
+ hszr.add(Wx::StaticText.new(sb_vszr.static_box, Wx::ID_ANY, 'Background style:'), Wx::SizerFlags.new.horz_border)
434
+ @ctrl_mod_fill_style = Wx::ComboBox.new(sb_vszr.static_box, Wx::ID_ANY,
435
+ choices: get_enum_choices(Wx::BrushStyle,
436
+ excludes: EXCL_BRUSH_STYLES))
437
+ hszr.add(@ctrl_mod_fill_style, Wx::SizerFlags.new)
438
+ }, Wx::SizerFlags.new.border
439
+ sb_vszr.add Wx::HBoxSizer.new { |hszr|
440
+ hszr.add(Wx::StaticText.new(sb_vszr.static_box, Wx::ID_ANY, 'Border colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
441
+ hszr.add(@ctrl_mod_border_clr = Wx::ColourPickerCtrl.new(sb_vszr.static_box, Wx::ID_ANY),
442
+ Wx::SizerFlags.new)
443
+ hszr.add(Wx::StaticText.new(sb_vszr.static_box, Wx::ID_ANY, 'Border width:'), Wx::SizerFlags.new.horz_border)
444
+ hszr.add(@ctrl_mod_border_wdt = Wx::SpinCtrl.new(sb_vszr.static_box, Wx::ID_ANY),
445
+ Wx::SizerFlags.new)
446
+ hszr.add(Wx::StaticText.new(sb_vszr.static_box, Wx::ID_ANY, 'Border style:'), Wx::SizerFlags.new.horz_border)
447
+ @ctrl_mod_border_style = Wx::ComboBox.new(sb_vszr.static_box, Wx::ID_ANY,
448
+ choices: get_enum_choices(
449
+ Wx::PenStyle,
450
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
451
+ hszr.add(@ctrl_mod_border_style, Wx::SizerFlags.new)
452
+ }, Wx::SizerFlags.new.border
453
+ }, Wx::SizerFlags.new.border
454
+
455
+ @ctrl_border_clr.colour = @canvas.control_border.colour
456
+ @ctrl_border_wdt.value = @canvas.control_border.width
457
+ @ctrl_border_style.selection = pen_style_index(@canvas.control_border.style)
458
+ @ctrl_fill_clr.colour = @canvas.control_fill.colour
459
+ @ctrl_fill_style.selection = brush_style_index(@canvas.control_fill.style)
460
+ @ctrl_mod_border_clr.colour = @canvas.control_mod_border.colour
461
+ @ctrl_mod_border_wdt.value = @canvas.control_mod_border.width
462
+ @ctrl_mod_border_style.selection = pen_style_index(@canvas.control_mod_border.style)
463
+ @ctrl_mod_fill_clr.colour = @canvas.control_mod_fill.colour
464
+ @ctrl_mod_fill_style.selection = brush_style_index(@canvas.control_mod_fill.style)
465
+
466
+ vszr.add Wx::HBoxSizer.new { |hszr|
467
+ hszr.add(Wx::StaticText.new(panel, :label => "Line shapes"), Wx::SizerFlags.new)
468
+ hszr.add(Wx::StaticLine.new(panel, size: [1,1]), Wx::SizerFlags.new(1).centre)
469
+ }, Wx::SizerFlags.new.expand.border
470
+ vszr.add Wx::HBoxSizer.new { |hszr|
471
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Line colour:'), Wx::SizerFlags.new.border(Wx::RIGHT))
472
+ hszr.add(@line_clr = Wx::ColourPickerCtrl.new(panel, Wx::ID_ANY),
473
+ Wx::SizerFlags.new)
474
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Line width:'), Wx::SizerFlags.new.horz_border)
475
+ hszr.add(@line_wdt = Wx::SpinCtrl.new(panel, Wx::ID_ANY),
476
+ Wx::SizerFlags.new)
477
+ hszr.add(Wx::StaticText.new(panel, Wx::ID_ANY, 'Line style:'), Wx::SizerFlags.new.horz_border)
478
+ @line_style = Wx::ComboBox.new(panel, Wx::ID_ANY,
479
+ choices: get_enum_choices(
480
+ Wx::PenStyle,
481
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
482
+ hszr.add(@line_style, Wx::SizerFlags.new)
483
+ }, Wx::SizerFlags.new.border
484
+
485
+ @line_clr.colour = @canvas.line_pen.colour
486
+ @line_wdt.value = @canvas.line_pen.width
487
+ @line_style.selection = pen_style_index(@canvas.line_pen.style)
488
+
489
+ end
490
+ end
491
+ end
492
+
493
+ def update_canvas_style(set, style)
494
+ if set then @canvas.add_style(style) else @canvas.remove_style(style) end
495
+ end
496
+ private :update_canvas_style
497
+
498
+ def on_apply(evt)
499
+ if @changed
500
+ if @rb_use_bgc.value
501
+ @canvas.remove_style(Wx::SF::ShapeCanvas::STYLE::GRADIENT_BACKGROUND)
502
+ @canvas.canvas_colour = @bg_clr.colour
503
+ else
504
+ @canvas.add_style(Wx::SF::ShapeCanvas::STYLE::GRADIENT_BACKGROUND)
505
+ @canvas.gradient_from = @gbg_from_clr.colour
506
+ @canvas.gradient_to = @gbg_to_clr.colour
507
+ end
508
+
509
+ @canvas.hover_color = @hover_clr.colour
510
+
511
+ @canvas.grid_size = @grid_sz.value
512
+ @canvas.grid_line_mult = @grid_ln_mult.value
513
+ @canvas.grid_colour = @grid_clr.colour
514
+ @canvas.grid_style = selected_pen_style(@grid_line_style.selection)
515
+ update_canvas_style(@cb_grid_show.value, Wx::SF::ShapeCanvas::STYLE::GRID_SHOW)
516
+ update_canvas_style(@cb_grid_use.value, Wx::SF::ShapeCanvas::STYLE::GRID_USE)
517
+
518
+ @canvas.shadow_offset = Wx::RealPoint.new(@shadow_off_x.value, @shadow_off_y.value)
519
+ @canvas.set_shadow_fill(@shadow_clr.colour, @canvas.shadow_fill.style)
520
+
521
+ @canvas.min_scale = @min_scale.value
522
+ @canvas.max_scale = @max_scale.value
523
+ update_canvas_style(@cb_mouse_wheel_scale.value, Wx::SF::ShapeCanvas::STYLE::PROCESS_MOUSEWHEEL)
524
+
525
+ update_canvas_style(@cb_hover_highlight.value, Wx::SF::ShapeCanvas::STYLE::HOVERING)
526
+ update_canvas_style(@cb_multi_select.value, Wx::SF::ShapeCanvas::STYLE::MULTI_SELECTION)
527
+ update_canvas_style(@cb_multi_resize.value, Wx::SF::ShapeCanvas::STYLE::MULTI_SIZE_CHANGE)
528
+ update_canvas_style(@cb_clipboard.value, Wx::SF::ShapeCanvas::STYLE::CLIPBOARD)
529
+ update_canvas_style(@cb_undo_redo.value, Wx::SF::ShapeCanvas::STYLE::UNDOREDO)
530
+ if Wx.has_feature?(:USE_DRAG_AND_DROP)
531
+ update_canvas_style(@cb_dnd.value, Wx::SF::ShapeCanvas::STYLE::DND)
532
+ end
533
+ update_canvas_style(@cb_drop_highlight.value, Wx::SF::ShapeCanvas::STYLE::HIGHLIGHTING)
534
+
535
+ update_canvas_style(@cb_print_bg.value, Wx::SF::ShapeCanvas::STYLE::PRINT_BACKGROUND)
536
+
537
+ @canvas.print_mode = index_to_enum(Wx::SF::ShapeCanvas::PRINTMODE, @print_mode.selection)
538
+ @canvas.print_h_align = index_to_enum(Wx::SF::ShapeCanvas::HALIGN, @print_halign.selection)
539
+ @canvas.print_v_align = index_to_enum(Wx::SF::ShapeCanvas::HALIGN, @print_valign.selection)
540
+
541
+ @canvas.set_border_pen(@border_clr.colour, @border_wdt.value, selected_pen_style(@border_style.selection))
542
+ @canvas.set_fill_brush(@fill_clr.colour, selected_brush_style(@fill_style.selection))
543
+
544
+ @canvas.text_colour = @text_clr.colour
545
+ @canvas.set_text_border(@text_border_clr.colour, @text_border_wdt.value, selected_pen_style(@text_border_style.selection))
546
+ @canvas.set_text_fill(@text_fill_clr.colour, selected_brush_style(@text_fill_style.selection))
547
+ @canvas.text_font = @text_font.selected_font
548
+
549
+ @canvas.set_control_border(@ctrl_border_clr.colour, @ctrl_border_wdt.value, selected_pen_style(@ctrl_border_style.selection))
550
+ @canvas.set_control_fill(@ctrl_fill_clr.colour, selected_brush_style(@ctrl_fill_style.selection))
551
+ @canvas.set_control_mod_border(@ctrl_mod_border_clr.colour, @ctrl_mod_border_wdt.value, selected_pen_style(@ctrl_mod_border_style.selection))
552
+ @canvas.set_control_mod_fill(@ctrl_mod_fill_clr.colour, selected_brush_style(@ctrl_mod_fill_style.selection))
553
+
554
+ @canvas.set_line_pen(@line_clr.colour, @line_wdt.value, selected_pen_style(@line_style.selection))
555
+
556
+ @changed = false
557
+ @canvas.invalidate_visible_rect
558
+ @canvas.refresh_invalidated_rect
559
+ end
560
+ evt.skip
561
+ end
562
+ private :on_apply
563
+
564
+ def on_update_ui(evt)
565
+ case evt.id
566
+ when Wx::ID_OK, Wx::ID_APPLY
567
+ evt.event_object.enable(@changed)
568
+ when @bg_clr.id
569
+ @use_bgc_szr.each_child { |c| c.window.enable(@rb_use_bgc.value) }
570
+ when @gbg_from_clr.id
571
+ @use_gbgc_szr.each_child { |c| c.window.enable(@rb_use_gbgc.value) }
572
+ when @grid_clr.id
573
+ @grid_pen_szr.each_child { |c| c.window.enable(@cb_grid_show.value) }
574
+ end
575
+ end
576
+
577
+ def on_change(evt)
578
+ case evt.id
579
+ when @rb_use_bgc.id
580
+ @changed ||= @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRADIENT_BACKGROUND) == @rb_use_bgc.value
581
+ when @rb_use_gbgc.id
582
+ @changed ||= @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRADIENT_BACKGROUND) != @rb_use_gbgc.value
583
+ when @bg_clr.id
584
+ @changed ||= @bg_clr.colour != @canvas.canvas_colour
585
+ when @gbg_from_clr.id
586
+ @changed ||= @gbg_from_clr.colour != @canvas.gradient_from
587
+ when @gbg_to_clr.id
588
+ @changed ||= @gbg_to_clr.colour != @canvas.gradient_to
589
+ when @hover_clr.id
590
+ @changed ||= @hover_clr.color != @canvas.hover_color
591
+ when @grid_sz.id
592
+ @changed ||= @grid_sz.value != @canvas.grid_size
593
+ when @grid_ln_mult.id
594
+ @changed ||= @grid_ln_mult.value != @canvas.grid_line_mult
595
+ when @cb_grid_show.id
596
+ @changed ||= @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRID_SHOW) != @cb_grid_show.value
597
+ when @cb_grid_use.id
598
+ @changed ||= @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::GRID_USE) != @cb_grid_use.value
599
+ when @grid_clr.id
600
+ @changed ||= @grid_clr.colour != @canvas.grid_colour
601
+ when @grid_line_style.id
602
+ @changed ||= selected_pen_style(@grid_line_style.selection) != @canvas.grid_style
603
+ when @shadow_clr.id
604
+ @changed ||= @shadow_clr.colour != @canvas.shadow_fill.colour
605
+ when @shadow_off_x.id
606
+ @changed ||= @shadow_off_x.value != @canvas.shadow_offset.x
607
+ when @shadow_off_y.id
608
+ @changed ||= @shadow_off_y.value != @canvas.shadow_offset.y
609
+ when @shadow_style.id
610
+ @changed ||= selected_brush_style(@shadow_style.selection) != @canvas.shadow_fill.style
611
+ when @min_scale.id
612
+ @changed ||= @min_scale.value != @canvas.min_scale
613
+ @max_scale.set_range(@min_scale.value, 100.0)
614
+ when @max_scale.id
615
+ @changed ||= @max_scale.value != @canvas.max_scale
616
+ @min_scale.set_range(0.1, @max_scale.value)
617
+ when @cb_mouse_wheel_scale.id
618
+ @changed ||= @cb_mouse_wheel_scale.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::PROCESS_MOUSEWHEEL)
619
+ when @cb_hover_highlight.id
620
+ @changed ||= @cb_hover_highlight.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::HOVERING)
621
+ when @cb_multi_select.id
622
+ @changed ||= @cb_multi_select.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::MULTI_SELECTION)
623
+ when @cb_multi_resize.id
624
+ @changed ||= @cb_multi_resize.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::MULTI_SIZE_CHANGE)
625
+ when @cb_clipboard.id
626
+ @changed ||= @cb_clipboard.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::CLIPBOARD)
627
+ when @cb_undo_redo.id
628
+ @changed ||= @cb_undo_redo.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::UNDOREDO)
629
+ when @cb_drop_highlight.id
630
+ @changed ||= @cb_drop_highlight.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::HIGHLIGHTING)
631
+ when @cb_print_bg.id
632
+ @changed ||= @cb_print_bg.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::PRINT_BACKGROUND)
633
+ when @print_mode.id
634
+ @changed ||= @print_mode.selection != get_enum_index(@canvas.print_mode)
635
+ when @print_halign.id
636
+ @changed ||= @print_halign.selection != get_enum_index(@canvas.print_h_align)
637
+ when @print_valign.id
638
+ @changed ||= @print_valign.selection != get_enum_index(@canvas.print_v_align)
639
+ when @border_clr.id
640
+ @changed ||= @border_clr.colour != @canvas.border_pen.colour
641
+ when @border_wdt.id
642
+ @changed ||= @border_wdt.value != @canvas.border_pen.width
643
+ when @border_style.id
644
+ @changed ||= @border_style.selection = pen_style_index(@canvas.border_pen.style)
645
+ when @fill_clr.id
646
+ @changed ||= @fill_clr.colour != @canvas.fill_brush.colour
647
+ when @fill_style.id
648
+ @changed ||= @fill_style.selection = brush_style_index(@canvas.fill_brush.style)
649
+ when @text_clr.id
650
+ @changed ||= @text_clr.colour != @canvas.text_colour
651
+ when @text_border_clr.id
652
+ @changed ||= @text_border_clr.colour != @canvas.text_border.colour
653
+ when @text_border_wdt.id
654
+ @changed ||= @text_border_wdt.value != @canvas.text_border.width
655
+ when @text_border_style.id
656
+ @changed ||= @text_border_style.selection != pen_style_index(@canvas.text_border.style)
657
+ when @text_fill_clr.id
658
+ @changed ||= @text_fill_clr.colour != @canvas.text_fill.colour
659
+ when @text_fill_style.id
660
+ @changed ||= @text_fill_style.selection != brush_style_index(@canvas.text_fill.style)
661
+ when @text_font.id
662
+ @changed ||= @text_font.selected_font != @canvas.text_font
663
+ when @ctrl_border_clr.id
664
+ @changed ||= @ctrl_border_clr.colour != @canvas.control_border.colour
665
+ when @ctrl_border_wdt.id
666
+ @changed ||= @ctrl_border_wdt.value != @canvas.control_border.width
667
+ when @ctrl_border_style.id
668
+ @changed ||= @ctrl_border_style.selection != pen_style_index(@canvas.control_border.style)
669
+ when @ctrl_fill_clr.id
670
+ @changed ||= @ctrl_fill_clr.colour != @canvas.control_fill.colour
671
+ when @ctrl_fill_style.id
672
+ @changed ||= @ctrl_fill_style.selection != brush_style_index(@canvas.control_fill.style)
673
+ when @ctrl_mod_border_clr.id
674
+ @changed ||= @ctrl_mod_border_clr.colour != @canvas.control_mod_border.colour
675
+ when @ctrl_mod_border_wdt.id
676
+ @changed ||= @ctrl_mod_border_wdt.value != @canvas.control_mod_border.width
677
+ when @ctrl_mod_border_style.id
678
+ @changed ||= @ctrl_mod_border_style.selection != pen_style_index(@canvas.control_mod_border.style)
679
+ when @ctrl_mod_fill_clr.id
680
+ @changed ||= @ctrl_mod_fill_clr.colour != @canvas.control_mod_fill.colour
681
+ when @ctrl_mod_fill_style.id
682
+ @changed ||= @ctrl_mod_fill_style.selection != brush_style_index(@canvas.control_mod_fill.style)
683
+ when @line_clr.id
684
+ @changed ||= @line_clr.colour != @canvas.line_pen.colour
685
+ when @line_wdt.id
686
+ @changed ||= @line_wdt.value != @canvas.line_pen.width
687
+ when @line_style.id
688
+ @changed ||= @line_style.selection != pen_style_index(@canvas.line_pen.style)
689
+ else
690
+ if Wx.has_feature?(:USE_DRAG_AND_DROP) && evt.id == @cb_dnd.id
691
+ @changed ||= @cb_dnd.value != @canvas.has_style?(Wx::SF::ShapeCanvas::STYLE::DND)
692
+ end
693
+ end
694
+ end
695
+
696
+ def pen_style_index(style)
697
+ get_enum_index(style,
698
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])
699
+ end
700
+ private :pen_style_index
701
+
702
+ def selected_pen_style(index)
703
+ index_to_enum(Wx::PenStyle,
704
+ index,
705
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])
706
+ end
707
+ private :selected_pen_style
708
+
709
+ def brush_style_index(style)
710
+ get_enum_index(style,
711
+ excludes: EXCL_BRUSH_STYLES)
712
+ end
713
+ private :brush_style_index
714
+
715
+ def selected_brush_style(index)
716
+ index_to_enum(Wx::BrushStyle,
717
+ index,
718
+ excludes: EXCL_BRUSH_STYLES)
719
+ end
720
+ private :selected_brush_style
721
+
722
+ def get_enum_choices(enum, excludes: nil)
723
+ Dialogs.get_enum_choices(enum, excludes: excludes)
724
+ end
725
+ private :get_enum_choices
726
+
727
+ def get_enum_index(enumerator, excludes: nil)
728
+ Dialogs.get_enum_index(enumerator, excludes: excludes)
729
+ end
730
+ private :get_enum_index
731
+
732
+ def index_to_enum(enum, index, excludes: nil)
733
+ Dialogs.index_to_enum(enum, index, excludes: excludes)
734
+ end
735
+ private :index_to_enum
736
+
737
+ end
738
+
739
+ EXCL_BRUSH_STYLES = [
740
+ :BRUSHSTYLE_INVALID,
741
+ :BRUSHSTYLE_STIPPLE,
742
+ :BRUSHSTYLE_STIPPLE_MASK,
743
+ :BRUSHSTYLE_STIPPLE_MASK_OPAQUE,
744
+ :BRUSHSTYLE_FIRST_HATCH,
745
+ :BRUSHSTYLE_LAST_HATCH
746
+ ]
747
+
748
+ class FloatDialog < Wx::Dialog
749
+ def initialize(parent, title, label: 'Value:', value: 0.0, min: 0.0, max: 100.0, inc: 1.0)
750
+ super(parent, Wx::ID_ANY, title, size: [400, -1])
751
+ sizer_top = Wx::VBoxSizer.new do |vszr|
752
+ vszr.add Wx::HBoxSizer.new { |hszr|
753
+ hszr.add(Wx::StaticText.new(self, Wx::ID_ANY, label), Wx::SizerFlags.new.border(Wx::ALL, 5))
754
+ @spin_ctrl = Wx::SpinCtrlDouble.new(self, Wx::ID_ANY, value.to_s, min: min, max: max, inc: inc)
755
+ hszr.add(@spin_ctrl, Wx::SizerFlags.new.border(Wx::ALL, 5))
756
+ }, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::ALL, 5)
757
+ vszr.add Wx::HBoxSizer.new { |hszr|
758
+ hszr.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
759
+ hszr.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
760
+ }, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80)
761
+ end
762
+ set_auto_layout(true)
763
+ set_sizer(sizer_top)
764
+
765
+ sizer_top.set_size_hints(self)
766
+ sizer_top.fit(self)
767
+ end
768
+
769
+ def get_value
770
+ @spin_ctrl.get_value
771
+ end
772
+ end
773
+
774
+ class ConnectionPointDialog < Wx::Dialog
775
+
776
+ def initialize(parent, conn_pts)
777
+ super(parent, Wx::ID_ANY, 'Change connection points')
778
+ sizer_top = Wx::VBoxSizer.new
779
+
780
+ sizer = Wx::HBoxSizer.new
781
+ vszr = Wx::VBoxSizer.new
782
+ vszr.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Connection points:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
783
+ @lst_view = Wx::ListView.new(self)
784
+ @lst_view.append_column("Connection type",Wx::LIST_FORMAT_LEFT, Wx::LIST_AUTOSIZE_USEHEADER)
785
+ @lst_view.append_column("Id",Wx::LIST_FORMAT_LEFT, Wx::LIST_AUTOSIZE_USEHEADER)
786
+ @lst_view.append_column("Otho direction",Wx::LIST_FORMAT_LEFT, Wx::LIST_AUTOSIZE_USEHEADER)
787
+ @lst_view.append_column("Rel position",Wx::LIST_FORMAT_LEFT, Wx::LIST_AUTOSIZE_USEHEADER)
788
+
789
+ (@cpts = conn_pts.dup).each do |cpt|
790
+ add_list_item(cpt)
791
+ end
792
+
793
+ vszr.add(@lst_view, Wx::SizerFlags.new.border(Wx::ALL, 5))
794
+ sizer.add(vszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
795
+
796
+ vszr = Wx::VBoxSizer.new
797
+ @cpt_szr = Wx::StaticBoxSizer.new(Wx::Orientation::VERTICAL, self, 'Connection point')
798
+ hszr = Wx::HBoxSizer.new
799
+ hszr.add(Wx::StaticText.new(@cpt_szr.static_box, Wx::ID_ANY, 'Type:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
800
+ @cpt_type = Wx::ComboBox.new(@cpt_szr.static_box, Wx::ID_ANY,
801
+ choices: get_enum_choices(Wx::SF::ConnectionPoint::CPTYPE))
802
+ hszr.add(@cpt_type, Wx::SizerFlags.new.border(Wx::ALL, 5))
803
+ @cpt_szr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
804
+
805
+ hszr = Wx::HBoxSizer.new
806
+ hszr.add(Wx::StaticText.new(@cpt_szr.static_box, Wx::ID_ANY, 'Id:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
807
+ @cpt_id = Wx::TextCtrl.new(@cpt_szr.static_box, validator: Wx::TextValidator.new(Wx::TextValidatorStyle::FILTER_DIGITS))
808
+ @cpt_id.enable(false)
809
+ hszr.add(@cpt_id, Wx::SizerFlags.new.border(Wx::ALL, 5))
810
+ @cpt_szr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
811
+
812
+ hszr = Wx::HBoxSizer.new
813
+ hszr.add(Wx::StaticText.new(@cpt_szr.static_box, Wx::ID_ANY, 'Orthogonal direction:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
814
+ @cpt_odir = Wx::ComboBox.new(@cpt_szr.static_box, Wx::ID_ANY,
815
+ choices: get_enum_choices(Wx::SF::ConnectionPoint::CPORTHODIR))
816
+ hszr.add(@cpt_odir, Wx::SizerFlags.new.border(Wx::ALL, 5))
817
+ @cpt_szr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
818
+
819
+ hszr = Wx::HBoxSizer.new
820
+ hszr.add(Wx::StaticText.new(@cpt_szr.static_box, Wx::ID_ANY, 'Relative position x:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
821
+ @rpos_x = Wx::SpinCtrlDouble.new(@cpt_szr.static_box, Wx::ID_ANY, min: 0.0, inc: 1.0)
822
+ hszr.add(@rpos_x, Wx::SizerFlags.new.border(Wx::ALL, 5))
823
+ hszr.add(Wx::StaticText.new(@cpt_szr.static_box, Wx::ID_ANY, 'y:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
824
+ @rpos_y = Wx::SpinCtrlDouble.new(@cpt_szr.static_box, Wx::ID_ANY, min: 0.0, inc: 1.0)
825
+ hszr.add(@rpos_y, Wx::SizerFlags.new.border(Wx::ALL, 5))
826
+ @cpt_szr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
827
+
828
+ hszr = Wx::HBoxSizer.new
829
+ @add_btn = Wx::Button.new(@cpt_szr.static_box, Wx::ID_ANY, 'Add')
830
+ @add_btn.enable(false)
831
+ hszr.add(@add_btn, Wx::SizerFlags.new.border(Wx::ALL, 5))
832
+ @chg_btn = Wx::Button.new(@cpt_szr.static_box, Wx::ID_ANY, 'Change selected')
833
+ hszr.add(@chg_btn, Wx::SizerFlags.new.border(Wx::ALL, 5))
834
+ @chg_btn.enable(false)
835
+ @cpt_szr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
836
+
837
+ vszr.add(@cpt_szr, Wx::SizerFlags.new.border(Wx::ALL, 5))
838
+
839
+ hszr = Wx::HBoxSizer.new
840
+ @del_btn = Wx::Button.new(self, Wx::ID_ANY, 'Delete selected')
841
+ @del_btn.enable(false)
842
+ hszr.add(@del_btn, Wx::SizerFlags.new.border(Wx::ALL, 5))
843
+ @clear_btn = Wx::Button.new(self, Wx::ID_ANY, 'Delete all')
844
+ @clear_btn.enable(!@cpts.empty?)
845
+ hszr.add(@clear_btn, Wx::SizerFlags.new.border(Wx::ALL, 5))
846
+ vszr.add(hszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
847
+
848
+ sizer.add(vszr, Wx::SizerFlags.new.border(Wx::ALL, 5))
849
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_CENTRE_HORIZONTAL).border(Wx::ALL, 5))
850
+
851
+
852
+ sizer = Wx::HBoxSizer.new
853
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
854
+ sizer.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
855
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80))
856
+
857
+ set_auto_layout(true)
858
+ set_sizer(sizer_top)
859
+
860
+ sizer_top.set_size_hints(self)
861
+ sizer_top.fit(self)
862
+
863
+ evt_update_ui @cpt_type, :on_cpt_type_update
864
+ evt_update_ui @add_btn, :on_add_cpt_update
865
+ evt_update_ui @del_btn, :on_del_cpt_update
866
+ evt_update_ui @chg_btn, :on_chg_cpt_update
867
+ evt_update_ui(@clear_btn) { @clear_btn.enable(!@cpts.empty?) }
868
+ evt_list_item_selected @lst_view, :on_list_item_selected
869
+ evt_button @del_btn, :on_delete_cpt
870
+ evt_button @chg_btn, :on_change_cpt
871
+ evt_button @add_btn, :on_add_cpt
872
+ evt_button(@clear_btn) { @lst_view.delete_all_items; @cpts.clear }
873
+ end
874
+
875
+ def set_shape_connection_points(shape)
876
+ @cpts.each { |cpt| cpt.set_parent_shape(shape) }
877
+ shape.connection_points.replace(@cpts)
878
+ end
879
+
880
+ def on_cpt_type_update(_evt)
881
+ @cpt_id.enable(@cpt_type.string_selection == 'CUSTOM')
882
+ end
883
+ private :on_cpt_type_update
884
+
885
+ def on_add_cpt_update(_evt)
886
+ @add_btn.enable(@cpt_type.selection != -1 && @cpt_odir.selection != -1)
887
+ end
888
+ private :on_add_cpt_update
889
+
890
+ def on_del_cpt_update(_evt)
891
+ @del_btn.enable(@lst_view.get_selected_item_count > 0)
892
+ end
893
+ private :on_del_cpt_update
894
+
895
+ def on_chg_cpt_update(_evt)
896
+ @chg_btn.enable(@lst_view.get_selected_item_count == 1)
897
+ end
898
+ private :on_chg_cpt_update
899
+
900
+ def on_list_item_selected(evt)
901
+ sel_cpt = @cpts[evt.index]
902
+ @cpt_type.set_selection(Wx::SF::ConnectionPoint::CPTYPE.enumerators.keys.index(sel_cpt.type.to_i))
903
+ @cpt_id.value = sel_cpt.id.to_s
904
+ @cpt_odir.set_selection(Wx::SF::ConnectionPoint::CPORTHODIR.enumerators.keys.index(sel_cpt.ortho_direction.to_i))
905
+ @rpos_x.value = sel_cpt.relative_position.x
906
+ @rpos_y.value = sel_cpt.relative_position.y
907
+ end
908
+ private :on_list_item_selected
909
+
910
+ def on_delete_cpt(_evt)
911
+ @lst_view.each_selected.reverse_each do |sel|
912
+ @lst_view.delete_item(sel)
913
+ @cpts.delete_at(sel)
914
+ end
915
+ end
916
+ private :on_delete_cpt
917
+
918
+ def update_connection_point(cpt)
919
+ cpt.type = index_to_enum(Wx::SF::ConnectionPoint::CPTYPE, @cpt_type.selection)
920
+ cpt.id = (@cpt_type.string_selection == 'CUSTOM' && !@cpt_id.value.empty?) ? @cpt_id.value.to_i : nil
921
+ cpt.ortho_direction = index_to_enum(Wx::SF::ConnectionPoint::CPORTHODIR, @cpt_odir.selection)
922
+ cpt.relative_position = Wx::RealPoint.new(@rpos_x.value, @rpos_y.value)
923
+ end
924
+ private :update_connection_point
925
+
926
+ def update_list_item(item)
927
+ @lst_view.set_item(item, 0, Wx::SF::ConnectionPoint::CPTYPE.enumerators[@cpts[item].type.to_i].to_s)
928
+ @lst_view.set_item(item, 1, @cpts[item].id.to_s)
929
+ @lst_view.set_item(item, 2, Wx::SF::ConnectionPoint::CPORTHODIR.enumerators[@cpts[item].ortho_direction.to_i].to_s)
930
+ @lst_view.set_item(item, 3, '%.2f x %.2f' % @cpts[item].relative_position.to_ary)
931
+ end
932
+ private :update_list_item
933
+
934
+ def on_change_cpt(_evt)
935
+ unless (sel = @lst_view.get_first_selected) == -1
936
+ update_connection_point(@cpts[sel])
937
+ update_list_item(sel)
938
+ end
939
+ end
940
+ private :on_change_cpt
941
+
942
+ def add_list_item(cpt)
943
+ item = @lst_view.insert_item(@lst_view.item_count, Wx::SF::ConnectionPoint::CPTYPE.enumerators[cpt.type.to_i].to_s)
944
+ @lst_view.set_item(item, 1, cpt.id.to_s)
945
+ @lst_view.set_item(item, 2, Wx::SF::ConnectionPoint::CPORTHODIR.enumerators[cpt.ortho_direction.to_i].to_s)
946
+ @lst_view.set_item(item, 3, '%.2f x %.2f' % cpt.relative_position.to_ary)
947
+ end
948
+ private :add_list_item
949
+
950
+ def on_add_cpt(_evt)
951
+ @cpts << Wx::SF::ConnectionPoint.new
952
+ update_connection_point(@cpts.last)
953
+ add_list_item(@cpts.last)
954
+ end
955
+
956
+ def get_enum_choices(enum, excludes: nil)
957
+ Dialogs.get_enum_choices(enum, excludes: excludes)
958
+ end
959
+ private :get_enum_choices
960
+
961
+ def get_enum_index(enumerator, excludes: nil)
962
+ Dialogs.get_enum_index(enumerator, excludes: excludes)
963
+ end
964
+ private :get_enum_index
965
+
966
+ def index_to_enum(enum, index, excludes: nil)
967
+ Dialogs.index_to_enum(enum, index, excludes: excludes)
968
+ end
969
+ private :index_to_enum
970
+
971
+ end
972
+
973
+ class AcceptedShapesDialog < Wx::Dialog
974
+
975
+ def initialize(parent, message, selectable_shapes, accepted_shapes)
976
+ super(parent, Wx::ID_ANY, 'Select shapes')
977
+ sizer_top = Wx::VBoxSizer.new
978
+
979
+ sizer_top.add(Wx::StaticText.new(self, Wx::ID_ANY, message), Wx::SizerFlags.new.border(Wx::ALL, 5))
980
+
981
+ sizer = Wx::HBoxSizer.new
982
+ @none_rb = Wx::RadioButton.new(self, Wx::ID_ANY, 'Accept NONE', style: Wx::RB_GROUP)
983
+ sizer.add(@none_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
984
+ @all_rb = Wx::RadioButton.new(self, Wx::ID_ANY, 'Accept ALL')
985
+ sizer.add(@all_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
986
+ @some_rb = Wx::RadioButton.new(self, Wx::ID_ANY, 'Accept selection')
987
+ sizer.add(@some_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
988
+ sizer_top.add(sizer, Wx::SizerFlags.new.border(Wx::ALL, 5))
989
+
990
+ sizer = Wx::HBoxSizer.new
991
+ @lbox = Wx::CheckListBox.new(self, Wx::ID_ANY, choices: get_shape_choices(selectable_shapes))
992
+ sizer.add(@lbox, Wx::SizerFlags.new.border(Wx::ALL, 5))
993
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_CENTRE_HORIZONTAL).border(Wx::ALL, 5))
994
+
995
+ if accepted_shapes.empty?
996
+ @none_rb.value = true
997
+ @lbox.enable(false)
998
+ elsif accepted_shapes.include?(Wx::SF::ACCEPT_ALL)
999
+ @all_rb.value = true
1000
+ @lbox.enable(false)
1001
+ else
1002
+ @some_rb.value = true
1003
+ get_shape_selections(selectable_shapes, accepted_shapes).each { |ix| @lbox.check(ix, true) }
1004
+ end
1005
+
1006
+ sizer = Wx::HBoxSizer.new
1007
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1008
+ sizer.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1009
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80))
1010
+
1011
+ set_auto_layout(true)
1012
+ set_sizer(sizer_top)
1013
+
1014
+ sizer_top.set_size_hints(self)
1015
+ sizer_top.fit(self)
1016
+
1017
+ evt_radiobutton Wx::ID_ANY, :on_radiobutton
1018
+ end
1019
+
1020
+ def get_shape_choices(shapes)
1021
+ shapes.collect { |c| c.name }
1022
+ end
1023
+
1024
+ def get_shape_selections(shapes, accepted_shapes)
1025
+ accepted_shapes.collect { |ac| shapes.index(ac) }
1026
+ end
1027
+
1028
+ def get_selected_shapes(selectable_shapes)
1029
+ if @none_rb.value
1030
+ nil
1031
+ elsif @all_rb.value
1032
+ [Wx::SF::ACCEPT_ALL]
1033
+ else
1034
+ sel = @lbox.get_checked_items.collect { |ix| selectable_shapes[ix] }
1035
+ sel.empty? ? nil : sel
1036
+ end
1037
+ end
1038
+
1039
+ def on_radiobutton(_evt)
1040
+ @lbox.enable(@some_rb.value)
1041
+ end
1042
+ private :on_radiobutton
1043
+
1044
+ end
1045
+
1046
+ class BrushDialog < Wx::Dialog
1047
+
1048
+ def initialize(parent, title, brush)
1049
+ super(parent, Wx::ID_ANY, title)
1050
+ sizer_top = Wx::VBoxSizer.new
1051
+
1052
+ sizer = Wx::HBoxSizer.new
1053
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Colour:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1054
+ @fill_clr = Wx::ColourPickerCtrl.new(self, Wx::ID_ANY)
1055
+ sizer.add(@fill_clr, Wx::SizerFlags.new.border(Wx::ALL, 5))
1056
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Style:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1057
+ @fill_style = Wx::ComboBox.new(self, Wx::ID_ANY,
1058
+ choices: get_enum_choices(Wx::BrushStyle,
1059
+ excludes: EXCL_BRUSH_STYLES))
1060
+ sizer.add(@fill_style, Wx::SizerFlags.new.border(Wx::ALL, 5))
1061
+ sizer_top.add(sizer, Wx::SizerFlags.new.border(Wx::ALL, 5))
1062
+
1063
+ @fill_clr.colour = brush.colour
1064
+ @fill_style.selection = get_enum_index(brush.style,
1065
+ excludes: EXCL_BRUSH_STYLES)
1066
+
1067
+ sizer = Wx::HBoxSizer.new
1068
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1069
+ sizer.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1070
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80))
1071
+
1072
+ set_auto_layout(true)
1073
+ set_sizer(sizer_top)
1074
+
1075
+ sizer_top.set_size_hints(self)
1076
+ sizer_top.fit(self)
1077
+ end
1078
+
1079
+ def get_brush
1080
+ Wx::Brush.new(@fill_clr.colour,
1081
+ index_to_enum(Wx::BrushStyle, @fill_style.selection,
1082
+ excludes: EXCL_BRUSH_STYLES))
1083
+ end
1084
+
1085
+ def get_enum_choices(enum, excludes: nil)
1086
+ Dialogs.get_enum_choices(enum, excludes: excludes)
1087
+ end
1088
+ private :get_enum_choices
1089
+
1090
+ def get_enum_index(enumerator, excludes: nil)
1091
+ Dialogs.get_enum_index(enumerator, excludes: excludes)
1092
+ end
1093
+ private :get_enum_index
1094
+
1095
+ def index_to_enum(enum, index, excludes: nil)
1096
+ Dialogs.index_to_enum(enum, index, excludes: excludes)
1097
+ end
1098
+ private :index_to_enum
1099
+
1100
+ end
1101
+
1102
+ class PenDialog < Wx::Dialog
1103
+
1104
+ def initialize(parent, title, pen)
1105
+ super(parent, Wx::ID_ANY, title)
1106
+ sizer_top = Wx::VBoxSizer.new
1107
+
1108
+ sizer = Wx::HBoxSizer.new
1109
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Colour:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1110
+ @line_clr = Wx::ColourPickerCtrl.new(self, Wx::ID_ANY)
1111
+ sizer.add(@line_clr, Wx::SizerFlags.new.border(Wx::ALL, 5))
1112
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Width:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1113
+ @line_wdt = Wx::SpinCtrl.new(self, Wx::ID_ANY)
1114
+ sizer.add(@line_wdt, Wx::SizerFlags.new.border(Wx::ALL, 5))
1115
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Style:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1116
+ @line_style = Wx::ComboBox.new(self, Wx::ID_ANY,
1117
+ choices: get_enum_choices(Wx::PenStyle,
1118
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
1119
+ sizer.add(@line_style, Wx::SizerFlags.new.border(Wx::ALL, 5))
1120
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::ALL, 5))
1121
+
1122
+ @line_clr.colour = pen.colour
1123
+ @line_wdt.value = pen.width
1124
+ @line_style.selection = get_enum_index(pen.style,
1125
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])
1126
+
1127
+ sizer = Wx::HBoxSizer.new
1128
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1129
+ sizer.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1130
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80))
1131
+
1132
+ set_auto_layout(true)
1133
+ set_sizer(sizer_top)
1134
+
1135
+ sizer_top.set_size_hints(self)
1136
+ sizer_top.fit(self)
1137
+ end
1138
+
1139
+ def get_pen
1140
+ Wx::Pen.new(@line_clr.colour, @line_wdt.value,
1141
+ index_to_enum(Wx::PenStyle, @line_style.selection,
1142
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
1143
+ end
1144
+
1145
+ def get_enum_choices(enum, excludes: nil)
1146
+ Dialogs.get_enum_choices(enum, excludes: excludes)
1147
+ end
1148
+ private :get_enum_choices
1149
+
1150
+ def get_enum_index(enumerator, excludes: nil)
1151
+ Dialogs.get_enum_index(enumerator, excludes: excludes)
1152
+ end
1153
+ private :get_enum_index
1154
+
1155
+ def index_to_enum(enum, index, excludes: nil)
1156
+ Dialogs.index_to_enum(enum, index, excludes: excludes)
1157
+ end
1158
+ private :index_to_enum
1159
+
1160
+ end
1161
+
1162
+ class ArrowDialog < Wx::Dialog
1163
+
1164
+ def initialize(parent, title, arrow)
1165
+ super(parent, Wx::ID_ANY, title)
1166
+ sizer_top = Wx::VBoxSizer.new
1167
+
1168
+ sizer = Wx::HBoxSizer.new
1169
+ sizer.add(Wx::StaticText.new(self, Wx::ID_ANY, 'Arrow type:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1170
+ @arrow = Wx::ComboBox.new(self, Wx::ID_ANY, arrow_type(arrow),
1171
+ choices: %w[None Open Prong Crossbar DoubleCrossbar Cup Solid Diamond Circle Square CrossBarCircle CrossBarProng CircleProng CrossedCircle])
1172
+ sizer.add(@arrow, Wx::SizerFlags.new.border(Wx::ALL, 5))
1173
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::ALL, 5))
1174
+
1175
+ @line_szr = Wx::StaticBoxSizer.new(Wx::Orientation::VERTICAL, self, 'Pen')
1176
+ sizer = Wx::HBoxSizer.new
1177
+ @line_pen_rb = Wx::RadioButton.new(@line_szr.static_box, Wx::ID_ANY, 'Use line pen', style: Wx::RB_GROUP)
1178
+ sizer.add(@line_pen_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
1179
+ @custom_pen_rb = Wx::RadioButton.new(@line_szr.static_box, Wx::ID_ANY, 'Use custom pen')
1180
+ sizer.add(@custom_pen_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
1181
+ @line_szr.add(sizer, Wx::SizerFlags.new.border(Wx::ALL, 5))
1182
+ sizer = Wx::HBoxSizer.new
1183
+ sizer.add(Wx::StaticText.new(@line_szr.static_box, Wx::ID_ANY, 'Colour:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1184
+ @line_clr = Wx::ColourPickerCtrl.new(@line_szr.static_box, Wx::ID_ANY)
1185
+ sizer.add(@line_clr, Wx::SizerFlags.new.border(Wx::ALL, 5))
1186
+ sizer.add(Wx::StaticText.new(@line_szr.static_box, Wx::ID_ANY, 'Width:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1187
+ @line_wdt = Wx::SpinCtrl.new(@line_szr.static_box, Wx::ID_ANY)
1188
+ sizer.add(@line_wdt, Wx::SizerFlags.new.border(Wx::ALL, 5))
1189
+ sizer.add(Wx::StaticText.new(@line_szr.static_box, Wx::ID_ANY, 'Style:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1190
+ @line_style = Wx::ComboBox.new(@line_szr.static_box, Wx::ID_ANY,
1191
+ choices: get_enum_choices(Wx::PenStyle,
1192
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE]))
1193
+ sizer.add(@line_style, Wx::SizerFlags.new.border(Wx::ALL, 5))
1194
+ @line_szr.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::ALL, 5))
1195
+ sizer_top.add(@line_szr, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::ALL, 5))
1196
+
1197
+ if Wx::SF::LineArrow === arrow
1198
+ @line_pen_rb.value = true
1199
+ @line_clr.colour = arrow.pen.colour
1200
+ @line_wdt.value = arrow.pen.width
1201
+ @line_style.selection = get_enum_index(arrow.pen.style,
1202
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])
1203
+ @line_clr.enable(false)
1204
+ @line_wdt.enable(false)
1205
+ @line_style.enable(false)
1206
+ else
1207
+ @line_szr.static_box.enable(false)
1208
+ end
1209
+
1210
+ @fill_szr = Wx::StaticBoxSizer.new(Wx::Orientation::VERTICAL, self, 'Fill')
1211
+ sizer = Wx::HBoxSizer.new
1212
+ @def_brush_rb = Wx::RadioButton.new(@fill_szr.static_box, Wx::ID_ANY, 'Use default brush', style: Wx::RB_GROUP)
1213
+ sizer.add(@def_brush_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
1214
+ @custom_brush_rb = Wx::RadioButton.new(@fill_szr.static_box, Wx::ID_ANY, 'Use custom brush')
1215
+ sizer.add(@custom_brush_rb, Wx::SizerFlags.new.border(Wx::ALL, 5))
1216
+ @fill_szr.add(sizer, Wx::SizerFlags.new.border(Wx::ALL, 5))
1217
+ sizer = Wx::HBoxSizer.new
1218
+ sizer.add(Wx::StaticText.new(@fill_szr.static_box, Wx::ID_ANY, 'Colour:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1219
+ @fill_clr = Wx::ColourPickerCtrl.new(@fill_szr.static_box, Wx::ID_ANY)
1220
+ sizer.add(@fill_clr, Wx::SizerFlags.new.border(Wx::ALL, 5))
1221
+ sizer.add(Wx::StaticText.new(@fill_szr.static_box, Wx::ID_ANY, 'Style:'), Wx::SizerFlags.new.border(Wx::ALL, 5))
1222
+ @fill_style = Wx::ComboBox.new(@fill_szr.static_box, Wx::ID_ANY,
1223
+ choices: get_enum_choices(Wx::BrushStyle,
1224
+ excludes: EXCL_BRUSH_STYLES))
1225
+ sizer.add(@fill_style, Wx::SizerFlags.new.border(Wx::ALL, 5))
1226
+ @fill_szr.add(sizer, Wx::SizerFlags.new.border(Wx::ALL, 5))
1227
+ sizer_top.add(@fill_szr, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).expand.border(Wx::ALL, 5))
1228
+
1229
+ if Wx::SF::FilledArrow === arrow
1230
+ @def_brush_rb.value = true
1231
+ @fill_clr.colour = arrow.fill.colour
1232
+ @fill_style.selection = get_enum_index(arrow.fill.style,
1233
+ excludes: EXCL_BRUSH_STYLES)
1234
+ @fill_clr.enable(false)
1235
+ @fill_style.enable(false)
1236
+ else
1237
+ @fill_szr.static_box.enable(false)
1238
+ end
1239
+
1240
+ sizer = Wx::HBoxSizer.new
1241
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1242
+ sizer.add(Wx::Button.new(self, Wx::ID_CANCEL, "&Cancel"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1243
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_LEFT).border(Wx::RIGHT, 80))
1244
+
1245
+ set_auto_layout(true)
1246
+ set_sizer(sizer_top)
1247
+
1248
+ sizer_top.set_size_hints(self)
1249
+ sizer_top.fit(self)
1250
+
1251
+ evt_combobox @arrow, :on_arrow_type
1252
+ evt_radiobutton Wx::ID_ANY, :on_radiobutton
1253
+ end
1254
+
1255
+ def get_arrow
1256
+ case @arrow.get_value
1257
+ when 'None'
1258
+ nil
1259
+ when 'Open', 'Cup', 'Prong', 'Crossbar', 'DoubleCrossbar', 'CrossBarProng'
1260
+ arrow = case @arrow.get_value
1261
+ when 'Open' then Wx::SF::OpenArrow.new
1262
+ when 'Prong' then Wx::SF::ProngArrow.new
1263
+ when 'Cup' then Wx::SF::CupArrow.new
1264
+ when 'Crossbar' then Wx::SF::CrossBarArrow.new
1265
+ when 'DoubleCrossbar' then Wx::SF::DoubleCrossBarArrow.new
1266
+ when 'CrossBarProng' then Wx::SF::CrossBarProngArrow.new
1267
+ end
1268
+ if @custom_pen_rb.value
1269
+ arrow.set_pen(Wx::Pen.new(@line_clr.colour, @line_wdt.value,
1270
+ index_to_enum(Wx::PenStyle, @line_style.selection,
1271
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])))
1272
+ end
1273
+ arrow
1274
+ else
1275
+ arrow = case @arrow.get_value
1276
+ when 'Solid' then Wx::SF::SolidArrow.new
1277
+ when 'Diamond' then Wx::SF::DiamondArrow.new
1278
+ when 'Circle' then Wx::SF::CircleArrow.new
1279
+ when 'Square' then Wx::SF::SquareArrow.new
1280
+ when 'CrossBarCircle' then Wx::SF::CrossBarCircleArrow.new
1281
+ when 'CircleProng' then Wx::SF::CircleProngArrow.new
1282
+ when 'CrossedCircle' then Wx::SF::CrossedCircleArrow.new
1283
+ end
1284
+ if @custom_pen_rb.value
1285
+ arrow.set_pen(Wx::Pen.new(@line_clr.colour, @line_wdt.value,
1286
+ index_to_enum(Wx::PenStyle, @line_style.selection,
1287
+ excludes: %i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH PENSTYLE_STIPPLE])))
1288
+ end
1289
+ if @custom_brush_rb.value
1290
+ arrow.set_fill(Wx::Brush.new(@fill_clr.colour,
1291
+ index_to_enum(Wx::BrushStyle, @fill_style.selection,
1292
+ excludes: EXCL_BRUSH_STYLES)))
1293
+ end
1294
+ arrow
1295
+ end
1296
+ end
1297
+
1298
+ def arrow_type(arrow)
1299
+ case arrow
1300
+ when Wx::SF::CrossBarProngArrow then 'CrossBarProng'
1301
+ when Wx::SF::ProngArrow then 'Prong'
1302
+ when Wx::SF::OpenArrow then 'Open'
1303
+ when Wx::SF::CupArrow then 'Cup'
1304
+ when Wx::SF::DoubleCrossBarArrow then 'DoubleCrossbar'
1305
+ when Wx::SF::CrossBarArrow then 'Crossbar'
1306
+ when Wx::SF::DiamondArrow then 'Diamond'
1307
+ when Wx::SF::SquareArrow then 'Square'
1308
+ when Wx::SF::SolidArrow then 'Solid'
1309
+ when Wx::SF::CrossedCircleArrow then 'CrossedCircle'
1310
+ when Wx::SF::CircleProngArrow then 'CircleProng'
1311
+ when Wx::SF::CrossBarCircleArrow then 'CrossBarCircle'
1312
+ when Wx::SF::CircleArrow then 'Circle'
1313
+ else
1314
+ 'None'
1315
+ end
1316
+ end
1317
+ private :arrow_type
1318
+
1319
+ def get_enum_choices(enum, excludes: nil)
1320
+ Dialogs.get_enum_choices(enum, excludes: excludes)
1321
+ end
1322
+ private :get_enum_choices
1323
+
1324
+ def get_enum_index(enumerator, excludes: nil)
1325
+ Dialogs.get_enum_index(enumerator, excludes: excludes)
1326
+ end
1327
+ private :get_enum_index
1328
+
1329
+ def index_to_enum(enum, index, excludes: nil)
1330
+ Dialogs.index_to_enum(enum, index, excludes: excludes)
1331
+ end
1332
+ private :index_to_enum
1333
+
1334
+ def on_radiobutton(_evt)
1335
+ if @line_pen_rb.value
1336
+ @line_clr.enable(false)
1337
+ @line_wdt.enable(false)
1338
+ @line_style.enable(false)
1339
+ else
1340
+ @line_clr.enable(true)
1341
+ @line_wdt.enable(true)
1342
+ @line_style.enable(true)
1343
+ end
1344
+ if @def_brush_rb.value
1345
+ @fill_clr.enable(false)
1346
+ @fill_style.enable(false)
1347
+ else
1348
+ @fill_clr.enable(true)
1349
+ @fill_style.enable(true)
1350
+ end
1351
+ end
1352
+ private :on_radiobutton
1353
+
1354
+ def on_arrow_type(_evt)
1355
+ case @arrow.get_value
1356
+ when 'None'
1357
+ @line_szr.static_box.enable(false)
1358
+ @fill_szr.static_box.enable(false)
1359
+ else
1360
+ @line_szr.static_box.enable(true)
1361
+ @line_pen_rb.value = true
1362
+ @line_clr.enable(false)
1363
+ @line_style.enable(false)
1364
+ @line_wdt.enable(false)
1365
+ case @arrow.get_value
1366
+ when 'Open', 'Prong', 'Cup', 'Crossbar', 'DoubleCrossbar', 'CrossBarProng'
1367
+ @fill_szr.static_box.enable(false)
1368
+ else
1369
+ @fill_szr.static_box.enable(true)
1370
+ end
1371
+ end
1372
+ end
1373
+ protected :get_enum_choices
1374
+
1375
+ end
1376
+
1377
+ class StateDialog < Wx::Dialog
1378
+
1379
+ def initialize(parent, shape)
1380
+ super(parent, title: "State of #{shape}")
1381
+ sizer_top = Wx::VBoxSizer.new
1382
+
1383
+ sizer = Wx::HBoxSizer.new
1384
+ text = Wx::TextCtrl.new(self, size: [500, 350], style: Wx::TE_MULTILINE|Wx::TE_READONLY|Wx::HSCROLL)
1385
+ txt_attr = text.get_default_style
1386
+ txt_attr.font = Wx::Font.new(Wx::FontInfo.new(10.0).family(Wx::FontFamily::FONTFAMILY_TELETYPE))
1387
+ text.set_default_style(txt_attr)
1388
+ text.set_value(shape.serialize(format: :yaml))
1389
+ sizer.add(text, Wx::SizerFlags.new.border(Wx::ALL, 5))
1390
+ sizer_top.add(sizer, Wx::SizerFlags.new)
1391
+
1392
+ sizer = Wx::HBoxSizer.new
1393
+ sizer.add(Wx::Button.new(self, Wx::ID_OK, "&Ok"), Wx::SizerFlags.new.border(Wx::ALL, 5))
1394
+ sizer_top.add(sizer, Wx::SizerFlags.new.align(Wx::ALIGN_RIGHT).border(Wx::LEFT, 80))
1395
+
1396
+ set_auto_layout(true)
1397
+ set_sizer(sizer_top)
1398
+
1399
+ sizer_top.set_size_hints(self)
1400
+ sizer_top.fit(self)
1401
+ end
1402
+
1403
+ end
1404
+
1405
+ end