wxruby3-shapes 0.9.0.pre.beta.3
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 +7 -0
- data/.yardopts +12 -0
- data/CREDITS.md +18 -0
- data/INSTALL.md +39 -0
- data/LICENSE +21 -0
- data/README.md +118 -0
- data/assets/screenshot.png +0 -0
- data/bin/wx-shapes +9 -0
- data/lib/wx/shapes/arrow_base.rb +86 -0
- data/lib/wx/shapes/arrows/circle_arrow.rb +39 -0
- data/lib/wx/shapes/arrows/diamond_arrow.rb +33 -0
- data/lib/wx/shapes/arrows/open_arrow.rb +56 -0
- data/lib/wx/shapes/arrows/solid_arrow.rb +69 -0
- data/lib/wx/shapes/art/shape_canvas/page.xpm +73 -0
- data/lib/wx/shapes/auto_layout.rb +358 -0
- data/lib/wx/shapes/base.rb +33 -0
- data/lib/wx/shapes/canvas_history.rb +84 -0
- data/lib/wx/shapes/connection_point.rb +238 -0
- data/lib/wx/shapes/core.rb +19 -0
- data/lib/wx/shapes/diagram.rb +659 -0
- data/lib/wx/shapes/events.rb +389 -0
- data/lib/wx/shapes/printout.rb +136 -0
- data/lib/wx/shapes/serializable.rb +440 -0
- data/lib/wx/shapes/serialize/core.rb +40 -0
- data/lib/wx/shapes/serialize/id.rb +82 -0
- data/lib/wx/shapes/serialize/wx.rb +104 -0
- data/lib/wx/shapes/serializer/json.rb +258 -0
- data/lib/wx/shapes/serializer/yaml.rb +125 -0
- data/lib/wx/shapes/shape.rb +2129 -0
- data/lib/wx/shapes/shape_canvas.rb +3285 -0
- data/lib/wx/shapes/shape_data_object.rb +43 -0
- data/lib/wx/shapes/shape_handle.rb +287 -0
- data/lib/wx/shapes/shape_list.rb +161 -0
- data/lib/wx/shapes/shapes/bitmap_shape.rb +257 -0
- data/lib/wx/shapes/shapes/circle_shape.rb +136 -0
- data/lib/wx/shapes/shapes/control_shape.rb +483 -0
- data/lib/wx/shapes/shapes/curve_shape.rb +231 -0
- data/lib/wx/shapes/shapes/diamond_shape.rb +62 -0
- data/lib/wx/shapes/shapes/edit_text_shape.rb +317 -0
- data/lib/wx/shapes/shapes/ellipse_shape.rb +106 -0
- data/lib/wx/shapes/shapes/flex_grid_shape.rb +78 -0
- data/lib/wx/shapes/shapes/grid_shape.rb +404 -0
- data/lib/wx/shapes/shapes/line_shape.rb +907 -0
- data/lib/wx/shapes/shapes/multi_sel_rect.rb +214 -0
- data/lib/wx/shapes/shapes/ortho_shape.rb +357 -0
- data/lib/wx/shapes/shapes/polygon_shape.rb +294 -0
- data/lib/wx/shapes/shapes/rect_shape.rb +378 -0
- data/lib/wx/shapes/shapes/round_ortho_shape.rb +131 -0
- data/lib/wx/shapes/shapes/round_rect_shape.rb +142 -0
- data/lib/wx/shapes/shapes/square_shape.rb +119 -0
- data/lib/wx/shapes/shapes/text_shape.rb +324 -0
- data/lib/wx/shapes/thumbnail.rb +234 -0
- data/lib/wx/shapes/version.rb +12 -0
- data/lib/wx/shapes/wx.rb +29 -0
- data/lib/wx/shapes.rb +18 -0
- data/lib/wx/wx-shapes/base.rb +87 -0
- data/lib/wx/wx-shapes/cmd/sampler.rb +58 -0
- data/lib/wx/wx-shapes/cmd/test.rb +27 -0
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +7 -0
- data/rakelib/yard/templates/default/layout/html/setup.rb +5 -0
- data/rakelib/yard/yard/relative_markdown_links/version.rb +8 -0
- data/rakelib/yard/yard/relative_markdown_links.rb +39 -0
- data/rakelib/yard/yard-custom-templates.rb +2 -0
- data/rakelib/yard/yard-relative_markdown_links.rb +4 -0
- data/samples/demo/art/AlignBottom.xpm +35 -0
- data/samples/demo/art/AlignCenter.xpm +35 -0
- data/samples/demo/art/AlignLeft.xpm +35 -0
- data/samples/demo/art/AlignMiddle.xpm +35 -0
- data/samples/demo/art/AlignRight.xpm +35 -0
- data/samples/demo/art/AlignTop.xpm +35 -0
- data/samples/demo/art/Bitmap.xpm +25 -0
- data/samples/demo/art/Circle.xpm +22 -0
- data/samples/demo/art/Curve.xpm +21 -0
- data/samples/demo/art/Diamond.xpm +22 -0
- data/samples/demo/art/EditText.xpm +21 -0
- data/samples/demo/art/Ellipse.xpm +22 -0
- data/samples/demo/art/FixedRect.xpm +22 -0
- data/samples/demo/art/FlexGrid.xpm +22 -0
- data/samples/demo/art/GC.xpm +23 -0
- data/samples/demo/art/Grid.xpm +22 -0
- data/samples/demo/art/Line.xpm +21 -0
- data/samples/demo/art/NoSource.xpm +69 -0
- data/samples/demo/art/OrthoLine.xpm +21 -0
- data/samples/demo/art/Rect.xpm +22 -0
- data/samples/demo/art/RoundOrthoLine.xpm +21 -0
- data/samples/demo/art/RoundRect.xpm +22 -0
- data/samples/demo/art/Shadow.xpm +23 -0
- data/samples/demo/art/StandAloneLine.xpm +22 -0
- data/samples/demo/art/Text.xpm +21 -0
- data/samples/demo/art/Tool.xpm +23 -0
- data/samples/demo/art/sample.xpm +251 -0
- data/samples/demo/demo.rb +658 -0
- data/samples/demo/frame_canvas.rb +422 -0
- data/samples/demo/images/motyl.bmp +0 -0
- data/samples/demo/images/motyl2.bmp +0 -0
- data/samples/sample1/art/sample.xpm +251 -0
- data/samples/sample1/sample.rb +263 -0
- data/samples/sample2/art/sample.xpm +251 -0
- data/samples/sample2/sample.rb +133 -0
- data/samples/sample2/sample_canvas.rb +35 -0
- data/samples/sample2/sample_shape.rb +108 -0
- data/samples/sample3/art/sample.xpm +251 -0
- data/samples/sample3/sample.rb +281 -0
- data/samples/sample4/art/sample.xpm +251 -0
- data/samples/sample4/sample.rb +180 -0
- data/tests/art/motyl.bmp +0 -0
- data/tests/lib/wxapp_runner.rb +64 -0
- data/tests/serializer_tests.rb +521 -0
- data/tests/test_grid_shapes.rb +42 -0
- data/tests/test_serialize.rb +7 -0
- data/tests/test_serialize_yaml.rb +17 -0
- metadata +242 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Wx::SF - Sample2 SampleShape class
|
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
|
3
|
+
|
|
4
|
+
require 'wx/shapes'
|
|
5
|
+
|
|
6
|
+
class SampleShape < Wx::SF::RectShape
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# override required wxSF virtual functions
|
|
13
|
+
def on_left_click(pos)
|
|
14
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_left_click', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
15
|
+
|
|
16
|
+
# call original handler if required
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
def on_right_click(pos)
|
|
20
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_right_click', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
21
|
+
|
|
22
|
+
# call original handler if required
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
def on_left_double_click(pos)
|
|
26
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_left_double_click', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
27
|
+
|
|
28
|
+
# call original handler if required
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
def on_right_double_click(pos)
|
|
32
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_right_double_click', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
33
|
+
|
|
34
|
+
# call original handler if required
|
|
35
|
+
super
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def on_begin_drag(pos)
|
|
39
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_begin_drag', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
40
|
+
|
|
41
|
+
# call original handler if required
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
def on_dragging(pos)
|
|
45
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_dragging', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
46
|
+
|
|
47
|
+
# call original handler if required
|
|
48
|
+
super
|
|
49
|
+
end
|
|
50
|
+
def on_end_drag(pos)
|
|
51
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_end_drag', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
52
|
+
|
|
53
|
+
# call original handler if required
|
|
54
|
+
super
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def on_begin_handle(handle)
|
|
58
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::HandleEvent, "Called handler: 'on_begin_handle()', Shape ID: #{get_id}, Handle type: #{handle.type}\n")
|
|
59
|
+
|
|
60
|
+
# call original handler if required
|
|
61
|
+
super
|
|
62
|
+
end
|
|
63
|
+
def on_handle(handle)
|
|
64
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::HandleEvent, "Called handler: 'on_handle()', Shape ID: #{get_id}, Handle type: #{handle.type}\n")
|
|
65
|
+
|
|
66
|
+
# call original handler if required
|
|
67
|
+
super
|
|
68
|
+
end
|
|
69
|
+
def on_end_handle(handle)
|
|
70
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::HandleEvent, "Called handler: 'on_end_handle()', Shape ID: #{get_id}, Handle type: #{handle.type}\n")
|
|
71
|
+
|
|
72
|
+
# call original handler if required
|
|
73
|
+
super
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def on_mouse_enter(pos)
|
|
77
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_mouse_enter', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
78
|
+
|
|
79
|
+
# call original handler if required
|
|
80
|
+
super
|
|
81
|
+
end
|
|
82
|
+
def on_mouse_over(pos)
|
|
83
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_mouse_over', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
84
|
+
|
|
85
|
+
# call original handler if required
|
|
86
|
+
super
|
|
87
|
+
end
|
|
88
|
+
def on_mouse_leave(pos)
|
|
89
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::MouseEvent, "Called handler: 'on_mouse_leave', Shape ID: #{get_id}, Position: #{pos}\n")
|
|
90
|
+
|
|
91
|
+
# call original handler if required
|
|
92
|
+
super
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def on_key(key)
|
|
96
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::KeyEvent, "Called handler: 'on_key()', Shape ID: #{get_id}, Key code: #{key}\n")
|
|
97
|
+
|
|
98
|
+
# call original handler if required
|
|
99
|
+
super
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def on_child_dropped(pos, child)
|
|
103
|
+
SFSample2Frame.log(SFSample2Frame::LOGTYPE::ChildDropEvent, "Called handler: 'on_child_dropped()', Parent shape ID: #{get_id}, Child shape ID: #{child.get_id}\n")
|
|
104
|
+
|
|
105
|
+
# call original handler if required
|
|
106
|
+
super
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/* XPM */
|
|
2
|
+
static char * sample_xpm[] = {
|
|
3
|
+
"32 32 216 2",
|
|
4
|
+
" c None",
|
|
5
|
+
". c #872C2C",
|
|
6
|
+
"+ c #A52827",
|
|
7
|
+
"@ c #A42828",
|
|
8
|
+
"# c #553131",
|
|
9
|
+
"$ c #7D2D2D",
|
|
10
|
+
"% c #3D3232",
|
|
11
|
+
"& c #535331",
|
|
12
|
+
"* c #AEAE26",
|
|
13
|
+
"= c #85852C",
|
|
14
|
+
"- c #ACAC26",
|
|
15
|
+
"; c #88882C",
|
|
16
|
+
"> c #9B2929",
|
|
17
|
+
", c #A92626",
|
|
18
|
+
"' c #F10D0C",
|
|
19
|
+
") c #B32424",
|
|
20
|
+
"! c #D91919",
|
|
21
|
+
"~ c #A52727",
|
|
22
|
+
"{ c #E51414",
|
|
23
|
+
"] c #DC1817",
|
|
24
|
+
"^ c #9F2828",
|
|
25
|
+
"/ c #A5A527",
|
|
26
|
+
"( c #F2F20B",
|
|
27
|
+
"_ c #FFFF00",
|
|
28
|
+
": c #F1F10C",
|
|
29
|
+
"< c #AEAE25",
|
|
30
|
+
"[ c #E7E712",
|
|
31
|
+
"} c #BEBE22",
|
|
32
|
+
"| c #999929",
|
|
33
|
+
"1 c #DE1716",
|
|
34
|
+
"2 c #A82626",
|
|
35
|
+
"3 c #EF0E0D",
|
|
36
|
+
"4 c #CA1E1E",
|
|
37
|
+
"5 c #C42020",
|
|
38
|
+
"6 c #EC1010",
|
|
39
|
+
"7 c #9E2828",
|
|
40
|
+
"8 c #B12525",
|
|
41
|
+
"9 c #E91211",
|
|
42
|
+
"0 c #922A2A",
|
|
43
|
+
"a c #A8A827",
|
|
44
|
+
"b c #EFEF0D",
|
|
45
|
+
"c c #C5C520",
|
|
46
|
+
"d c #FBFB03",
|
|
47
|
+
"e c #A6A627",
|
|
48
|
+
"f c #FAFA04",
|
|
49
|
+
"g c #CACA1E",
|
|
50
|
+
"h c #DDDD18",
|
|
51
|
+
"i c #F8F806",
|
|
52
|
+
"j c #B8B823",
|
|
53
|
+
"k c #E3E315",
|
|
54
|
+
"l c #9E2929",
|
|
55
|
+
"m c #D01D1D",
|
|
56
|
+
"n c #B72423",
|
|
57
|
+
"o c #AD2625",
|
|
58
|
+
"p c #DD1817",
|
|
59
|
+
"q c #B22525",
|
|
60
|
+
"r c #D71A1A",
|
|
61
|
+
"s c #EBEB10",
|
|
62
|
+
"t c #B0B025",
|
|
63
|
+
"u c #C0C021",
|
|
64
|
+
"v c #E6E613",
|
|
65
|
+
"w c #97972A",
|
|
66
|
+
"x c #A22828",
|
|
67
|
+
"y c #BB2323",
|
|
68
|
+
"z c #B82424",
|
|
69
|
+
"A c #4A3232",
|
|
70
|
+
"B c #842D2D",
|
|
71
|
+
"C c #912B2B",
|
|
72
|
+
"D c #5B3131",
|
|
73
|
+
"E c #70702F",
|
|
74
|
+
"F c #C6C620",
|
|
75
|
+
"G c #8E8E2B",
|
|
76
|
+
"H c #9A9A29",
|
|
77
|
+
"I c #484832",
|
|
78
|
+
"J c #A4A428",
|
|
79
|
+
"K c #9D2828",
|
|
80
|
+
"L c #E61211",
|
|
81
|
+
"M c #E51212",
|
|
82
|
+
"N c #DF1615",
|
|
83
|
+
"O c #D21B1A",
|
|
84
|
+
"P c #423232",
|
|
85
|
+
"Q c #515131",
|
|
86
|
+
"R c #E4E412",
|
|
87
|
+
"S c #F3F307",
|
|
88
|
+
"T c #E2E213",
|
|
89
|
+
"U c #BEBE20",
|
|
90
|
+
"V c #ECEC0C",
|
|
91
|
+
"W c #B1B124",
|
|
92
|
+
"X c #999928",
|
|
93
|
+
"Y c #CF1D1D",
|
|
94
|
+
"Z c #CD1E1D",
|
|
95
|
+
"` c #D21C1C",
|
|
96
|
+
" . c #A42727",
|
|
97
|
+
".. c #ED0F0F",
|
|
98
|
+
"+. c #7E2D2D",
|
|
99
|
+
"@. c #92922B",
|
|
100
|
+
"#. c #FDFD01",
|
|
101
|
+
"$. c #D1D11C",
|
|
102
|
+
"%. c #E5E513",
|
|
103
|
+
"&. c #643030",
|
|
104
|
+
"*. c #E61313",
|
|
105
|
+
"=. c #EE0F0E",
|
|
106
|
+
"-. c #A92726",
|
|
107
|
+
";. c #C1C121",
|
|
108
|
+
">. c #ADAD25",
|
|
109
|
+
",. c #EEEE0E",
|
|
110
|
+
"'. c #5C5C31",
|
|
111
|
+
"). c #F00D0C",
|
|
112
|
+
"!. c #AA2726",
|
|
113
|
+
"~. c #AF2525",
|
|
114
|
+
"{. c #EA1110",
|
|
115
|
+
"]. c #32365A",
|
|
116
|
+
"^. c #333440",
|
|
117
|
+
"/. c #E2E215",
|
|
118
|
+
"(. c #F0F00D",
|
|
119
|
+
"_. c #C4C420",
|
|
120
|
+
":. c #F5F508",
|
|
121
|
+
"<. c #BCBC22",
|
|
122
|
+
"[. c #FCFC02",
|
|
123
|
+
"}. c #8C8C2B",
|
|
124
|
+
"|. c #B92323",
|
|
125
|
+
"1. c #E51413",
|
|
126
|
+
"2. c #633030",
|
|
127
|
+
"3. c #313A74",
|
|
128
|
+
"4. c #2D43AE",
|
|
129
|
+
"5. c #2E40A2",
|
|
130
|
+
"6. c #313975",
|
|
131
|
+
"7. c #77772E",
|
|
132
|
+
"8. c #F7F706",
|
|
133
|
+
"9. c #CBCB1E",
|
|
134
|
+
"0. c #BABA23",
|
|
135
|
+
"a. c #D81919",
|
|
136
|
+
"b. c #A62727",
|
|
137
|
+
"c. c #D41B1B",
|
|
138
|
+
"d. c #C91F1E",
|
|
139
|
+
"e. c #8F2B2B",
|
|
140
|
+
"f. c #323553",
|
|
141
|
+
"g. c #2C45BA",
|
|
142
|
+
"h. c #284CE0",
|
|
143
|
+
"i. c #2A4AD5",
|
|
144
|
+
"j. c #2C46C0",
|
|
145
|
+
"k. c #A3A328",
|
|
146
|
+
"l. c #DEDE17",
|
|
147
|
+
"m. c #772E2E",
|
|
148
|
+
"n. c #EC100F",
|
|
149
|
+
"o. c #AB2626",
|
|
150
|
+
"p. c #B12524",
|
|
151
|
+
"q. c #2B47C8",
|
|
152
|
+
"r. c #2D43AF",
|
|
153
|
+
"s. c #2453FF",
|
|
154
|
+
"t. c #2552FA",
|
|
155
|
+
"u. c #2D44B6",
|
|
156
|
+
"v. c #2C45BE",
|
|
157
|
+
"w. c #BEBE21",
|
|
158
|
+
"x. c #BFBF22",
|
|
159
|
+
"y. c #B2B224",
|
|
160
|
+
"z. c #6B2F2F",
|
|
161
|
+
"A. c #C6201F",
|
|
162
|
+
"B. c #2F409F",
|
|
163
|
+
"C. c #2551F8",
|
|
164
|
+
"D. c #2C44B9",
|
|
165
|
+
"E. c #2452FC",
|
|
166
|
+
"F. c #2F3E92",
|
|
167
|
+
"G. c #585831",
|
|
168
|
+
"H. c #8E8E2A",
|
|
169
|
+
"I. c #79792D",
|
|
170
|
+
"J. c #5C3030",
|
|
171
|
+
"K. c #333333",
|
|
172
|
+
"L. c #313971",
|
|
173
|
+
"M. c #2551F5",
|
|
174
|
+
"N. c #2A49D0",
|
|
175
|
+
"O. c #284EE6",
|
|
176
|
+
"P. c #294BD9",
|
|
177
|
+
"Q. c #294CDD",
|
|
178
|
+
"R. c #2650F1",
|
|
179
|
+
"S. c #323761",
|
|
180
|
+
"T. c #606030",
|
|
181
|
+
"U. c #294CDE",
|
|
182
|
+
"V. c #2D42AD",
|
|
183
|
+
"W. c #2D43B3",
|
|
184
|
+
"X. c #2A4AD6",
|
|
185
|
+
"Y. c #2C45BD",
|
|
186
|
+
"Z. c #303B7C",
|
|
187
|
+
"`. c #2650F0",
|
|
188
|
+
" + c #2650F3",
|
|
189
|
+
".+ c #2B46C3",
|
|
190
|
+
"++ c #284CDE",
|
|
191
|
+
"@+ c #2A49D1",
|
|
192
|
+
"#+ c #264FED",
|
|
193
|
+
"$+ c #31396F",
|
|
194
|
+
"%+ c #303D90",
|
|
195
|
+
"&+ c #2B47C6",
|
|
196
|
+
"*+ c #31386B",
|
|
197
|
+
"=+ c #2E41A7",
|
|
198
|
+
"-+ c #313A77",
|
|
199
|
+
";+ c #303C86",
|
|
200
|
+
">+ c #2551F7",
|
|
201
|
+
",+ c #2D43B1",
|
|
202
|
+
"'+ c #2E41A6",
|
|
203
|
+
")+ c #2552FB",
|
|
204
|
+
"!+ c #2552F9",
|
|
205
|
+
"~+ c #2552F8",
|
|
206
|
+
"{+ c #323765",
|
|
207
|
+
"]+ c #2B48CB",
|
|
208
|
+
"^+ c #2A49CF",
|
|
209
|
+
"/+ c #274EE7",
|
|
210
|
+
"(+ c #264FEE",
|
|
211
|
+
"_+ c #2D42AE",
|
|
212
|
+
":+ c #2650F2",
|
|
213
|
+
"<+ c #294BDA",
|
|
214
|
+
"[+ c #2C46C1",
|
|
215
|
+
"}+ c #313A78",
|
|
216
|
+
"|+ c #2D42AA",
|
|
217
|
+
"1+ c #294BDC",
|
|
218
|
+
"2+ c #2B48CA",
|
|
219
|
+
"3+ c #2453FD",
|
|
220
|
+
" ",
|
|
221
|
+
" ",
|
|
222
|
+
" ",
|
|
223
|
+
" ",
|
|
224
|
+
" ",
|
|
225
|
+
" . + + @ # $ + + + % & * * * = & - * * ; ",
|
|
226
|
+
" > , ' ' ) ! ~ { ' ] ^ / ( _ : < [ } _ _ < | ",
|
|
227
|
+
" 1 2 3 4 5 ' 6 7 3 8 9 0 a b c d e f _ g h i j k ",
|
|
228
|
+
" l ' m n o ' ' ' p q ~ ' r s _ < t b _ _ _ < u v _ w ",
|
|
229
|
+
" x y z A z y y y y B C y y D E F F G H F F F F } I c F J ",
|
|
230
|
+
" K L L ^ M L L L L , N L O P Q R S T U S S S S V W S S X ",
|
|
231
|
+
" Y ' Z ` ' ' ' ' .' ..+. @.#._ < _ _ _ _ $.%._ $. ",
|
|
232
|
+
" &.*.=., ' ' ' ! 5 ' -. } _ ;.( _ _ _ >._ ,.'. ",
|
|
233
|
+
" C ).!.=.' ' ~.{.Z ].^. /.(._._ _ :.<.[.}. ",
|
|
234
|
+
" |.` Z ' ' ~ 1.2. 3.4.5.6. 7.8.>._ _ 9.s 0. ",
|
|
235
|
+
" a.b.' c.d.e. f.g.h.i.j. k.F ,._ < l. ",
|
|
236
|
+
" m. .n.o.p. q.r.s.t.u.v. w.x.( y.E ",
|
|
237
|
+
" z.A.$ B.C.D.s.s.r.E.F. G.H._.I. ",
|
|
238
|
+
" J.K. L.M.N.O.s.s.P.Q.R.S. K.T. ",
|
|
239
|
+
" K. U.s.V.s.s.s.E.W.s.X. ",
|
|
240
|
+
" g.s.M.Y.s.s.s.s.W.E.s.V. ",
|
|
241
|
+
" Z.`. +.+++ + + + +@+N. +#+$+ ",
|
|
242
|
+
" %+&+&+*+W.&+&+&+&+=+-+&+&+;+ ",
|
|
243
|
+
" 6.E.>+,+'+)+s.s.!+=+r.E.~+{+ ",
|
|
244
|
+
" ]+^+/+(+,+s.s._+:+Q.<+[+ ",
|
|
245
|
+
" }+|+s.s.1+q.2+Q.s.3+=+{+ ",
|
|
246
|
+
" 6._+_+_+$+$+_+_+_+*+ ",
|
|
247
|
+
" ",
|
|
248
|
+
" ",
|
|
249
|
+
" ",
|
|
250
|
+
" ",
|
|
251
|
+
" "};
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# Wx::SF - Sample3
|
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
|
3
|
+
|
|
4
|
+
require 'wx/shapes'
|
|
5
|
+
|
|
6
|
+
class StarShape < Wx::SF::PolygonShape
|
|
7
|
+
|
|
8
|
+
# star shape vertices
|
|
9
|
+
STAR = [Wx::RealPoint.new(0, -50), Wx::RealPoint.new(15, -10),
|
|
10
|
+
Wx::RealPoint.new(50, -10), Wx::RealPoint.new(22, 10),
|
|
11
|
+
Wx::RealPoint.new(40, 50), Wx::RealPoint.new(0, 20),
|
|
12
|
+
Wx::RealPoint.new(-40, 50), Wx::RealPoint.new(-22, 10),
|
|
13
|
+
Wx::RealPoint.new(-50, -10), Wx::RealPoint.new(-15, -10)]
|
|
14
|
+
|
|
15
|
+
# regular property
|
|
16
|
+
property :description
|
|
17
|
+
# component shape property (this specifies that this item should be serialized as a property of this class and
|
|
18
|
+
# not from any reference elsewhere like it's parents child shapes list)
|
|
19
|
+
component :title
|
|
20
|
+
# disable serialization of polygon vertices for this PolygonShape derivative,
|
|
21
|
+
# because they are always set in constructor for this class
|
|
22
|
+
excludes :vertices
|
|
23
|
+
|
|
24
|
+
# @overload initialize()
|
|
25
|
+
# Default constructor.
|
|
26
|
+
# @overload initialize(pos, size, diagram)
|
|
27
|
+
# User constructor.
|
|
28
|
+
# @param [Wx::RealPoint] pos Initial position
|
|
29
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
|
30
|
+
def initialize(*args)
|
|
31
|
+
if args.empty?
|
|
32
|
+
super()
|
|
33
|
+
set_vertices(STAR)
|
|
34
|
+
else
|
|
35
|
+
pos, diagram = args
|
|
36
|
+
super(STAR, pos, diagram)
|
|
37
|
+
end
|
|
38
|
+
init
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
protected
|
|
42
|
+
|
|
43
|
+
def get_description
|
|
44
|
+
@description
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def set_description(desc)
|
|
48
|
+
@description = desc
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get_title
|
|
52
|
+
@text
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def set_title(txt)
|
|
58
|
+
@text = txt
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def init
|
|
62
|
+
# initialize custom data members...
|
|
63
|
+
@description = "Insert some shape's description text here..."
|
|
64
|
+
|
|
65
|
+
# polygon-based shapes can be connected either to the vertices or to the
|
|
66
|
+
# nearest border point (default value is true).
|
|
67
|
+
set_connect_to_vertex(false)
|
|
68
|
+
|
|
69
|
+
# set accepted connections for the new shape
|
|
70
|
+
accept_connection(Wx::SF::ACCEPT_ALL)
|
|
71
|
+
accept_src_neighbour(StarShape)
|
|
72
|
+
accept_trg_neighbour(StarShape)
|
|
73
|
+
|
|
74
|
+
# create associated shape(s)
|
|
75
|
+
@text = Wx::SF::EditTextShape.new
|
|
76
|
+
# set some properties
|
|
77
|
+
if @text
|
|
78
|
+
# set text
|
|
79
|
+
@text.set_text('Hello!')
|
|
80
|
+
# set alignment
|
|
81
|
+
@text.set_v_align(Wx::SF::Shape::VALIGN::MIDDLE)
|
|
82
|
+
@text.set_h_align(Wx::SF::Shape::HALIGN::CENTER)
|
|
83
|
+
|
|
84
|
+
# set required shape style(s)
|
|
85
|
+
@text.set_style(STYLE::ALWAYS_INSIDE | STYLE::HOVERING | STYLE::PROCESS_DEL | STYLE::PROPAGATE_DRAGGING | STYLE::PROPAGATE_SELECTION | STYLE::PROPAGATE_INTERACTIVE_CONNECTION)
|
|
86
|
+
# you can also force displaying of the shapes handles even if the interactive
|
|
87
|
+
# size change is not allowed:
|
|
88
|
+
#@text.add_style(STYLE::SHOW_HANDLES)
|
|
89
|
+
|
|
90
|
+
# we use #set_parent_shape and not #add_child_shape as we do not want it checked against the acceptance list
|
|
91
|
+
# (which is empty and we want to keep it like that) and we already know it's not yet on the diagram so does
|
|
92
|
+
# not need to be removed as toplevel shape
|
|
93
|
+
@text.set_parent_shape(self)
|
|
94
|
+
# component will/should be added as child shape but will not be serialized as such
|
|
95
|
+
# instead the 'component :title' declaration above makes sure it will be serialized
|
|
96
|
+
# as a dedicated property of instances of this class
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class SFSample3Frame < Wx::Frame
|
|
104
|
+
|
|
105
|
+
module ID
|
|
106
|
+
MenuQuit = 1000
|
|
107
|
+
MenuOpen = 1001
|
|
108
|
+
MenuSave = 1002
|
|
109
|
+
MenuAbout = 1003
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def initialize(title)
|
|
113
|
+
super(nil, Wx::StandardID::ID_ANY, title, size: [800,600])
|
|
114
|
+
|
|
115
|
+
self.icon = Wx::Icon(:sample)
|
|
116
|
+
|
|
117
|
+
if Wx.has_feature?(:USE_MENUS)
|
|
118
|
+
# create a menu bar
|
|
119
|
+
mbar = Wx::MenuBar.new
|
|
120
|
+
file_menu = Wx::Menu.new
|
|
121
|
+
file_menu.append(ID::MenuOpen, "&Open\tCtrl-O", 'Open diagram from XML file')
|
|
122
|
+
file_menu.append(ID::MenuSave, "&Save\tCtrl-S", 'Save diagram to XML file')
|
|
123
|
+
file_menu.append_separator
|
|
124
|
+
file_menu.append(ID::MenuQuit, "&Quit\tAlt-F4", "Quit the application")
|
|
125
|
+
mbar.append(file_menu, "&File")
|
|
126
|
+
|
|
127
|
+
help_menu = Wx::Menu.new
|
|
128
|
+
help_menu.append(ID::MenuAbout, "&About\tF1", "Show info about this application")
|
|
129
|
+
mbar.append(help_menu, "&Help")
|
|
130
|
+
|
|
131
|
+
self.menu_bar = mbar
|
|
132
|
+
|
|
133
|
+
evt_menu(ID::MenuOpen, :on_open)
|
|
134
|
+
evt_menu(ID::MenuSave, :on_save)
|
|
135
|
+
evt_menu(ID::MenuQuit, :on_quit)
|
|
136
|
+
evt_menu(ID::MenuAbout, :on_about)
|
|
137
|
+
end # wxUSE_MENUS
|
|
138
|
+
@diagram = Wx::SF::Diagram.new
|
|
139
|
+
# set some diagram manager properties if necessary...
|
|
140
|
+
# set accepted shapes (accept only Wx::SF::RectShape)
|
|
141
|
+
@diagram.clear_accepted_shapes
|
|
142
|
+
@diagram.accept_shape(StarShape)
|
|
143
|
+
@diagram.accept_shape(Wx::SF::TextShape)
|
|
144
|
+
@diagram.accept_shape(Wx::SF::LineShape)
|
|
145
|
+
|
|
146
|
+
# create shape canvas and associate it with shape manager
|
|
147
|
+
@canvas = Wx::SF::ShapeCanvas.new(@diagram, self)
|
|
148
|
+
# set some shape canvas properties if necessary...
|
|
149
|
+
@canvas.add_style(Wx::SF::ShapeCanvas::STYLE::GRID_SHOW)
|
|
150
|
+
@canvas.add_style(Wx::SF::ShapeCanvas::STYLE::GRID_USE)
|
|
151
|
+
|
|
152
|
+
evt_close :on_close
|
|
153
|
+
|
|
154
|
+
# connect (some) shape canvas events
|
|
155
|
+
@canvas.evt_left_down { |evt| self.on_left_click_canvas(evt) }
|
|
156
|
+
@canvas.evt_right_down { |evt| self.on_right_click_canvas(evt) }
|
|
157
|
+
|
|
158
|
+
# connect (some) shape events (for full list of available shape/shape canvas events see Wx::SF reference documentation).
|
|
159
|
+
@canvas.evt_sf_line_done { |evt| self.on_line_done(evt) }
|
|
160
|
+
@canvas.evt_sf_text_change { |evt| self.on_text_change(evt) }
|
|
161
|
+
|
|
162
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
|
163
|
+
# create a status bar with some information about the used wxWidgets version
|
|
164
|
+
create_status_bar(2)
|
|
165
|
+
set_status_text('Hello wxRuby ShapeFramework user!',0)
|
|
166
|
+
set_status_text("wxRuby #{Wx::WXRUBY_VERSION} #{Wx::PLATFORM} (wxWidgets #{Wx::WXWIDGETS_VERSION})", 1)
|
|
167
|
+
end # wxUSE_STATUSBAR
|
|
168
|
+
|
|
169
|
+
center
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Window event handlers
|
|
173
|
+
|
|
174
|
+
def on_close(_event)
|
|
175
|
+
destroy
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def on_quit(_event)
|
|
179
|
+
destroy
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def on_about(_event)
|
|
183
|
+
msg = "wxRuby ShapeFramework #{Wx::SF::VERSION}\n(wxRuby #{Wx::WXRUBY_VERSION} #{Wx::PLATFORM}; #{Wx::WXWIDGETS_VERSION})\n\n"
|
|
184
|
+
|
|
185
|
+
msg += "Welcome to wxRuby ShapeFramework Sample3 (c) Martin Corino, 2023\n"
|
|
186
|
+
msg += "(ported from wxSFShapeFramework original (c) Michal Bliznak, 2007 - 2013)\n\n"
|
|
187
|
+
msg += "Sample demonstrates basic Wx::SF functionality.\n"
|
|
188
|
+
msg += " - New custom 'composite' shape is created.\n"
|
|
189
|
+
msg += " - Shapes can be joined together by lines.\n\n"
|
|
190
|
+
msg += "Usage:\n"
|
|
191
|
+
msg += " - Left mouse click operates with inserted shapes\n"
|
|
192
|
+
msg += " - Right mouse click inserts a custom shape to the canvas or starts\n"
|
|
193
|
+
msg += " interactive connection line's creation process\n"
|
|
194
|
+
msg += " - You can modify the star's text (double click it by the left mouse button)\n"
|
|
195
|
+
msg += " - DEL key removes selected shape\n"
|
|
196
|
+
|
|
197
|
+
Wx.message_box(msg, "wxRuby ShapeFramework Sample 3")
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# event handlers for shape canvas
|
|
201
|
+
|
|
202
|
+
def on_left_click_canvas(event)
|
|
203
|
+
# HINT: perform your user actions here...
|
|
204
|
+
|
|
205
|
+
# ... and then process standard canvas operations
|
|
206
|
+
event.skip
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def on_right_click_canvas(event)
|
|
210
|
+
# find out whether some shape has been clicked
|
|
211
|
+
if @canvas.get_shape_at_position(@canvas.dp2lp(event.get_position))
|
|
212
|
+
# start interactive connection creation
|
|
213
|
+
@canvas.start_interactive_connection(Wx::SF::LineShape, event.get_position)
|
|
214
|
+
else
|
|
215
|
+
# create new composite shape
|
|
216
|
+
@diagram.add_shape(s = StarShape.new, nil, event.get_position, Wx::SF::INITIALIZE, Wx::SF::DONT_SAVE_STATE)
|
|
217
|
+
|
|
218
|
+
# ... and process standard canvas operations
|
|
219
|
+
event.skip
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# event handlers for shapes
|
|
224
|
+
|
|
225
|
+
# Event handler called when the interactive line creation process is finished.
|
|
226
|
+
# Alternatively you can override virtual function Wx::SF::ShapeCanvas#on_connection_finished.
|
|
227
|
+
def on_line_done(event)
|
|
228
|
+
# get new line shape (if created)
|
|
229
|
+
line = event.get_shape
|
|
230
|
+
|
|
231
|
+
if line.is_a?(Wx::SF::LineShape)
|
|
232
|
+
# assign target arrow to the line shape (also source arrow can be created)
|
|
233
|
+
line.set_trg_arrow(Wx::SF::SolidArrow)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Event handler called when a text inside the star was changed.
|
|
238
|
+
# Alternatively you can override virtual function Wx::SF::ShapeCanvas#on_text_change.
|
|
239
|
+
def on_text_change(event)
|
|
240
|
+
# get changed text shape
|
|
241
|
+
text = event.get_shape
|
|
242
|
+
|
|
243
|
+
if text.is_a?(Wx::SF::TextShape)
|
|
244
|
+
# update the text shape and its parent(s)
|
|
245
|
+
text.update
|
|
246
|
+
# display some info...
|
|
247
|
+
Wx.log_message("New text of the star with ID #{text.get_parent_shape.id.to_i} is : '#{event.text}'")
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def on_open(_event)
|
|
252
|
+
Wx::FileDialog(self, 'Load diagram from file...', Dir.getwd, '', "JSON Files (*.json)|*.json", Wx::FD_OPEN) do |dlg|
|
|
253
|
+
if dlg.show_modal == Wx::ID_OK
|
|
254
|
+
File.open(dlg.get_path, 'r') do |f|
|
|
255
|
+
@canvas.set_diagram(Wx::SF::Serializable.deserialize(f))
|
|
256
|
+
@canvas.clear_canvas_history
|
|
257
|
+
@canvas.save_canvas_state
|
|
258
|
+
end
|
|
259
|
+
@diagram = @canvas.get_diagram
|
|
260
|
+
@canvas.refresh(false)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def on_save(_event)
|
|
266
|
+
Wx::FileDialog(self, 'Save diagram to XML...', Dir.getwd, '', 'JSON Files (*.json)|*.json', Wx::FD_SAVE) do |dlg|
|
|
267
|
+
if dlg.show_modal == Wx::ID_OK
|
|
268
|
+
# save diagram to file
|
|
269
|
+
File.open(dlg.get_path, 'w+') do |f|
|
|
270
|
+
@diagram.serialize(f, pretty: true)
|
|
271
|
+
end
|
|
272
|
+
Wx.message_box("The diagram has been saved to '#{dlg.get_path}'.", 'wxRuby ShapeFramework')
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
Wx::App.run do
|
|
280
|
+
SFSample3Frame.new('wxShapeFramework Sample 3').show
|
|
281
|
+
end
|