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.
- checksums.yaml +4 -4
- data/INSTALL.md +5 -7
- data/README.md +38 -6
- data/assets/logo.svg +339 -0
- data/assets/logo.xpm +60 -0
- data/assets/screenshot.png +0 -0
- data/assets/social.png +0 -0
- data/bin/wx-shapes +1 -1
- data/lib/wx/shapes/arrow_base.rb +4 -11
- data/lib/wx/shapes/arrows/circle_arrow.rb +22 -11
- data/lib/wx/shapes/arrows/circle_prong_arrow.rb +48 -0
- data/lib/wx/shapes/arrows/cross_bar_arrow.rb +57 -0
- data/lib/wx/shapes/arrows/cross_bar_circle_arrow.rb +56 -0
- data/lib/wx/shapes/arrows/cross_bar_prong_arrow.rb +49 -0
- data/lib/wx/shapes/arrows/crossed_circle.rb +46 -0
- data/lib/wx/shapes/arrows/cup_arrow.rb +65 -0
- data/lib/wx/shapes/arrows/diamond_arrow.rb +8 -13
- data/lib/wx/shapes/arrows/double_cross_bar_arrow.rb +27 -0
- data/lib/wx/shapes/arrows/filled_arrow.rb +60 -0
- data/lib/wx/shapes/arrows/line_arrow.rb +67 -0
- data/lib/wx/shapes/arrows/open_arrow.rb +22 -23
- data/lib/wx/shapes/arrows/prong_arrow.rb +42 -0
- data/lib/wx/shapes/arrows/solid_arrow.rb +21 -35
- data/lib/wx/shapes/arrows/square_arrow.rb +37 -0
- data/lib/wx/shapes/auto_layout.rb +2 -2
- data/lib/wx/shapes/base.rb +1 -1
- data/lib/wx/shapes/canvas_history.rb +20 -0
- data/lib/wx/shapes/connection_point.rb +10 -6
- data/lib/wx/shapes/diagram.rb +98 -78
- data/lib/wx/shapes/events.rb +8 -8
- data/lib/wx/shapes/printout.rb +3 -16
- data/lib/wx/shapes/serializable.rb +2 -436
- data/lib/wx/shapes/serialize/wx.rb +30 -18
- data/lib/wx/shapes/shape.rb +211 -168
- data/lib/wx/shapes/shape_canvas.rb +728 -267
- data/lib/wx/shapes/shape_data_object.rb +99 -18
- data/lib/wx/shapes/shape_handle.rb +18 -11
- data/lib/wx/shapes/shape_list.rb +34 -67
- data/lib/wx/shapes/shapes/bitmap_shape.rb +23 -24
- data/lib/wx/shapes/shapes/box_shape.rb +389 -0
- data/lib/wx/shapes/shapes/circle_shape.rb +19 -22
- data/lib/wx/shapes/shapes/control_shape.rb +77 -41
- data/lib/wx/shapes/shapes/curve_shape.rb +38 -31
- data/lib/wx/shapes/shapes/diamond_shape.rb +7 -17
- data/lib/wx/shapes/shapes/edit_text_shape.rb +6 -9
- data/lib/wx/shapes/shapes/ellipse_shape.rb +12 -15
- data/lib/wx/shapes/shapes/flex_grid_shape.rb +58 -33
- data/lib/wx/shapes/shapes/grid_shape.rb +259 -161
- data/lib/wx/shapes/shapes/line_shape.rb +155 -161
- data/lib/wx/shapes/shapes/manager_shape.rb +77 -0
- data/lib/wx/shapes/shapes/multi_sel_rect.rb +8 -8
- data/lib/wx/shapes/shapes/ortho_shape.rb +31 -36
- data/lib/wx/shapes/shapes/polygon_shape.rb +23 -29
- data/lib/wx/shapes/shapes/rect_shape.rb +95 -53
- data/lib/wx/shapes/shapes/round_ortho_shape.rb +6 -8
- data/lib/wx/shapes/shapes/round_rect_shape.rb +20 -24
- data/lib/wx/shapes/shapes/square_shape.rb +14 -17
- data/lib/wx/shapes/shapes/text_shape.rb +95 -53
- data/lib/wx/shapes/version.rb +1 -1
- data/lib/wx/shapes/wx.rb +16 -7
- data/lib/wx/wx-shapes/cmd/test.rb +1 -1
- data/samples/demo/arrows.json +1 -0
- data/samples/demo/arrows.yaml +793 -0
- data/samples/demo/art/HBox.xpm +22 -0
- data/samples/demo/art/VBox.xpm +22 -0
- data/samples/demo/art/logo.xpm +60 -0
- data/samples/demo/class.json +1 -0
- data/samples/demo/class.yaml +5631 -0
- data/samples/demo/demo.rb +301 -91
- data/samples/demo/dialogs.rb +1405 -0
- data/samples/demo/erd.json +1 -0
- data/samples/demo/erd.yaml +4072 -0
- data/samples/demo/frame_canvas.rb +409 -33
- data/samples/sample1/art/logo.xpm +60 -0
- data/samples/sample1/sample.rb +11 -11
- data/samples/sample2/art/logo.xpm +60 -0
- data/samples/sample2/sample.rb +2 -2
- data/samples/sample2/sample_shape.rb +15 -15
- data/samples/sample3/art/logo.xpm +60 -0
- data/samples/sample3/sample.rb +3 -3
- data/samples/sample4/art/logo.xpm +60 -0
- data/samples/sample4/sample.rb +2 -2
- data/tests/lib/wxapp_runner.rb +4 -0
- data/tests/serializer_tests.rb +8 -441
- data/tests/test_grid_shapes.rb +2 -2
- data/tests/test_serialize_xml.rb +17 -0
- data/tests/test_serialize_yaml.rb +2 -2
- metadata +78 -28
- data/lib/wx/shapes/serialize/core.rb +0 -40
- data/lib/wx/shapes/serialize/id.rb +0 -82
- data/lib/wx/shapes/serializer/json.rb +0 -258
- data/lib/wx/shapes/serializer/yaml.rb +0 -125
- data/samples/demo/art/sample.xpm +0 -251
- data/samples/sample1/art/sample.xpm +0 -251
- data/samples/sample2/art/sample.xpm +0 -251
- data/samples/sample3/art/sample.xpm +0 -251
- data/samples/sample4/art/sample.xpm +0 -251
@@ -9,26 +9,26 @@ module Wx::SF
|
|
9
9
|
# user to create curved connection line.
|
10
10
|
class CurveShape < LineShape
|
11
11
|
|
12
|
-
# @overload initialize()
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# @param [Wx::
|
16
|
-
# @param [Wx::
|
17
|
-
# @param [Array<Wx::RealPoint>] path List of the line control points (can be empty)
|
12
|
+
# @overload initialize(src = DEFAULT::POINT, trg = DEFAULT::POINT, path: nil, manager: nil)
|
13
|
+
# Constructor.
|
14
|
+
# @param [Wx::RealPoint,Wx::Point] src starting line point
|
15
|
+
# @param [Wx::RealPoint,Wx::Point] trg end line point
|
16
|
+
# @param [Array<Wx::RealPoint>,nil] path List of the line control points (can be empty or nil)
|
18
17
|
# @param [Diagram] diagram containing diagram
|
19
|
-
# @overload initialize(src, trg, path, manager)
|
20
|
-
#
|
21
|
-
# @param [
|
18
|
+
# @overload initialize(src, trg, path: nil, manager: nil)
|
19
|
+
# Constructor for connecting two shapes.
|
20
|
+
# @param [Shape] src source shape
|
21
|
+
# @param [Shape] trg target shape
|
22
22
|
# @param [Array<Wx::RealPoint>,nil] path List of the line control points (can be empty or nil)
|
23
23
|
# @param [Diagram] diagram containing diagram
|
24
|
-
def initialize(*args)
|
24
|
+
def initialize(*args, **kwargs)
|
25
25
|
super
|
26
26
|
end
|
27
27
|
|
28
28
|
# Get line's bounding box. The function can be overridden if necessary.
|
29
29
|
# @return [Wx::Rect] Bounding rectangle
|
30
30
|
def get_bounding_box
|
31
|
-
super.inflate(
|
31
|
+
super.inflate(35, 35)
|
32
32
|
end
|
33
33
|
|
34
34
|
# Get a line point laying on the given line segment and shifted
|
@@ -58,17 +58,24 @@ module Wx::SF
|
|
58
58
|
if !@lst_points.empty?
|
59
59
|
(0..@lst_points.size).each do |i|
|
60
60
|
a,b,c,d = get_segment_quaternion(i)
|
61
|
-
|
61
|
+
if i == 0 && @src_arrow
|
62
|
+
src, trg = get_line_segment(i)
|
63
|
+
src = @src_arrow.draw(trg, src, dc)
|
64
|
+
a = b = src.to_real
|
65
|
+
end
|
66
|
+
if i == @lst_points.size && @trg_arrow
|
67
|
+
src, trg = get_line_segment(i)
|
68
|
+
trg = @trg_arrow.draw(src, trg, dc)
|
69
|
+
c = d = trg.to_real
|
70
|
+
end
|
71
|
+
catmul_rom_kubika(a, b, c, d, dc, at_end: i == @lst_points.size)
|
62
72
|
end
|
63
73
|
else
|
64
|
-
|
65
|
-
|
74
|
+
src, trg = get_direct_line.collect(&:to_point)
|
75
|
+
src = @src_arrow.draw(trg, src, dc) if @src_arrow
|
76
|
+
trg = @trg_arrow.draw(src, trg, dc) if @trg_arrow
|
77
|
+
dc.draw_line(src, trg)
|
66
78
|
end
|
67
|
-
# draw target arrow
|
68
|
-
@trg_arrow.draw(b, c, dc) if @trg_arrow
|
69
|
-
b, c = get_line_segment(0)
|
70
|
-
# draw source arrow
|
71
|
-
@src_arrow.draw(c, b, dc) if @src_arrow
|
72
79
|
|
73
80
|
when LINEMODE::UNDERCONSTRUCTION
|
74
81
|
# draw basic line parts
|
@@ -83,17 +90,14 @@ module Wx::SF
|
|
83
90
|
dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do
|
84
91
|
if @lst_points.size > 1
|
85
92
|
dc.draw_line(c.to_point, @unfinished_point)
|
86
|
-
elsif @
|
93
|
+
elsif @src_shape
|
87
94
|
# draw unfinished line segment if any (for interactive line creation)
|
88
95
|
dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
else
|
95
|
-
dc.draw_line(get_mod_src_point.to_point, @unfinished_point)
|
96
|
-
end
|
96
|
+
if @src_shape.get_connection_points.empty?
|
97
|
+
dc.draw_line((@src_shape.get_border_point(@src_shape.get_center, @unfinished_point.to_real)).to_point,
|
98
|
+
@unfinished_point)
|
99
|
+
else
|
100
|
+
dc.draw_line(get_mod_src_point.to_point, @unfinished_point)
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
@@ -141,7 +145,6 @@ module Wx::SF
|
|
141
145
|
# @return [Array(Wx::RealPoint,Wx::RealPoint,Wx::RealPoint,Wx::RealPoint)]
|
142
146
|
def get_segment_quaternion(segment)
|
143
147
|
quart = [nil,nil,nil,nil]
|
144
|
-
# wxXS::RealPointList::compatibility_iterator node
|
145
148
|
index = 2 - segment
|
146
149
|
|
147
150
|
quart[index - 1] = get_src_point if (index - 1) >= 0
|
@@ -165,7 +168,7 @@ module Wx::SF
|
|
165
168
|
elsif index == 3
|
166
169
|
if @mode == LINEMODE::UNDERCONSTRUCTION
|
167
170
|
quart[3] = @unfinished_point.to_real
|
168
|
-
elsif @
|
171
|
+
elsif @trg_shape
|
169
172
|
quart[3] = get_mod_trg_point
|
170
173
|
end
|
171
174
|
end
|
@@ -182,7 +185,7 @@ module Wx::SF
|
|
182
185
|
# @param [Wx::RealPoint] c
|
183
186
|
# @param [Wx::RealPoint] d
|
184
187
|
# @param [Wx::DC] dc
|
185
|
-
def catmul_rom_kubika(a, b, c, d, dc)
|
188
|
+
def catmul_rom_kubika(a, b, c, d, dc, at_end: false)
|
186
189
|
# the beginning of the curve is in the B point
|
187
190
|
point0 = b
|
188
191
|
|
@@ -193,11 +196,15 @@ module Wx::SF
|
|
193
196
|
t = 0.0
|
194
197
|
while t <= (1 + (1.0 / optim_steps))
|
195
198
|
point1 = coord_catmul_rom_kubika(a,b,c,d,t)
|
199
|
+
# make sure not to overshoot at the target/arrow connection point
|
200
|
+
point1 = c if at_end && point0.distance_to(point1) > point0.distance_to(c)
|
196
201
|
dc.draw_line(point0.x.to_i, point0.y.to_i, point1.x.to_i, point1.y.to_i)
|
197
202
|
point0 = point1
|
198
203
|
t += 1.0 / (optim_steps-1)
|
199
204
|
end
|
200
205
|
point1 = coord_catmul_rom_kubika(a,b,c,d,1)
|
206
|
+
# make sure not to overshoot at the target/arrow connection point
|
207
|
+
point1 = c if at_end && point0.distance_to(point1) > point0.distance_to(c)
|
201
208
|
dc.draw_line(point0.x.to_i, point0.y.to_i, point1.x.to_i, point1.y.to_i)
|
202
209
|
end
|
203
210
|
|
@@ -7,28 +7,18 @@ module Wx::SF
|
|
7
7
|
|
8
8
|
class DiamondShape < PolygonShape
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
@diamond ||= [Wx::RealPoint.new(0,25), Wx::RealPoint.new(50,0), Wx::RealPoint.new(100, 25), Wx::RealPoint.new(50, 50)]
|
13
|
-
end
|
10
|
+
module DEFAULT
|
11
|
+
DIAMOND = [Wx::RealPoint.new(0,25), Wx::RealPoint.new(50,0), Wx::RealPoint.new(100, 25), Wx::RealPoint.new(50, 50)]
|
14
12
|
end
|
15
13
|
|
16
14
|
# do not serialize because the vertices are assigned fixed in ctor
|
17
15
|
excludes :vertices
|
18
16
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# @
|
22
|
-
|
23
|
-
|
24
|
-
# @param [Wx::SF::Diagram] diagram parent diagram
|
25
|
-
def initialize(*args)
|
26
|
-
if args.empty?
|
27
|
-
super
|
28
|
-
set_vertices(DiamondShape.diamond)
|
29
|
-
else
|
30
|
-
super(DiamondShape.diamond, *args)
|
31
|
-
end
|
17
|
+
# Constructor.
|
18
|
+
# @param [Wx::RealPoint,Wx::Point] pos Initial position
|
19
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
20
|
+
def initialize(pos = Shape::DEFAULT::POSITION, diagram: nil)
|
21
|
+
super(pos, vertices: DEFAULT::DIAMOND, diagram: diagram)
|
32
22
|
end
|
33
23
|
|
34
24
|
# Test whether the given point is inside the shape. The function
|
@@ -30,7 +30,7 @@ module Wx::SF
|
|
30
30
|
set_insertion_point_end
|
31
31
|
if @parent_shape
|
32
32
|
# update the font size in accordance to the canvas scale
|
33
|
-
font = @parent_shape.get_font
|
33
|
+
font = @parent_shape.get_font.dup
|
34
34
|
font.set_point_size((font.get_point_size * @parent_shape.get_parent_canvas.get_scale).to_i)
|
35
35
|
|
36
36
|
set_font(font)
|
@@ -168,14 +168,11 @@ module Wx::SF
|
|
168
168
|
|
169
169
|
property :force_multiline, :edit_type
|
170
170
|
|
171
|
-
#
|
172
|
-
#
|
173
|
-
# @
|
174
|
-
#
|
175
|
-
|
176
|
-
# @param [String] txt Initial content
|
177
|
-
# @param [Wx::SF::Diagram] diagram parent diagram
|
178
|
-
def initialize(*args)
|
171
|
+
# Constructor.
|
172
|
+
# @param [Wx::RealPoint,Wx::Point] pos Initial position
|
173
|
+
# @param [String] txt Text content
|
174
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
175
|
+
def initialize(pos = Shape::DEFAULT::POSITION, txt = TextShape::DEFAULT::TEXT, diagram: nil)
|
179
176
|
super
|
180
177
|
@text_ctrl = nil
|
181
178
|
@force_multiline = DEFAULT::FORCE_MULTILINE
|
@@ -6,14 +6,11 @@ module Wx::SF
|
|
6
6
|
# Class encapsulating the ellipse shape. It extends the basic rectangular shape.
|
7
7
|
class EllipseShape < RectShape
|
8
8
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# @
|
12
|
-
#
|
13
|
-
|
14
|
-
# @param [Wx::RealPoint] size Initial size
|
15
|
-
# @param [Wx::SF::Diagram] diagram parent diagram
|
16
|
-
def initialize(*args)
|
9
|
+
# Constructor.
|
10
|
+
# @param [Wx::RealPoint,Wx::Point] pos Initial position
|
11
|
+
# @param [Wx::RealPoint,Wx::Size,Wx::Point] size Initial size
|
12
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
13
|
+
def initialize(pos = Shape::DEFAULT::POSITION, size = RectShape::DEFAULT::SIZE, diagram: nil)
|
17
14
|
super
|
18
15
|
end
|
19
16
|
|
@@ -58,8 +55,8 @@ module Wx::SF
|
|
58
55
|
# Draw the shape in the normal way. The function can be overridden if necessary.
|
59
56
|
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
60
57
|
def draw_normal(dc)
|
61
|
-
dc.with_pen(
|
62
|
-
dc.with_brush(
|
58
|
+
dc.with_pen(border) do
|
59
|
+
dc.with_brush(fill) do
|
63
60
|
dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size)
|
64
61
|
end
|
65
62
|
end
|
@@ -69,8 +66,8 @@ module Wx::SF
|
|
69
66
|
# The function can be overridden if necessary.
|
70
67
|
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
71
68
|
def draw_hover(dc)
|
72
|
-
dc.with_pen(Wx::Pen.new(
|
73
|
-
dc.with_brush(
|
69
|
+
dc.with_pen(Wx::Pen.new(hover_colour, 1)) do
|
70
|
+
dc.with_brush(fill) do
|
74
71
|
dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size)
|
75
72
|
end
|
76
73
|
end
|
@@ -81,8 +78,8 @@ module Wx::SF
|
|
81
78
|
# The function can be overridden if necessary.
|
82
79
|
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
83
80
|
def draw_highlighted(dc)
|
84
|
-
dc.with_pen(Wx::Pen.new(
|
85
|
-
dc.with_brush(
|
81
|
+
dc.with_pen(Wx::Pen.new(hover_colour, 2)) do
|
82
|
+
dc.with_brush(fill) do
|
86
83
|
dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size)
|
87
84
|
end
|
88
85
|
end
|
@@ -91,7 +88,7 @@ module Wx::SF
|
|
91
88
|
# Draw shadow under the shape. The function can be overridden if necessary.
|
92
89
|
# @param [Wx::DC] dc Reference to device context where the shadow will be drawn to
|
93
90
|
def draw_shadow(dc)
|
94
|
-
if
|
91
|
+
if fill.style != Wx::BrushStyle::BRUSHSTYLE_TRANSPARENT
|
95
92
|
dc.with_pen(Wx::TRANSPARENT_PEN) do
|
96
93
|
dc.with_brush(get_parent_canvas.get_shadow_fill) do
|
97
94
|
dc.draw_ellipse((get_absolute_position + get_parent_canvas.get_shadow_offset).to_point,
|
@@ -11,38 +11,59 @@ module Wx::SF
|
|
11
11
|
class FlexGridShape < GridShape
|
12
12
|
|
13
13
|
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
# @param [Wx::SF::Diagram] diagram parent diagram
|
24
|
-
def initialize(*args)
|
14
|
+
# Constructor.
|
15
|
+
# @param [Wx::RealPoint,Wx::Point] pos Initial position
|
16
|
+
# @param [Wx::RealPoint,Wx::Size,Wx::Point] size Initial size
|
17
|
+
# @param [Integer] cols Number of grid columns
|
18
|
+
# @param [Integer] max_rows Maximum number of grid rows
|
19
|
+
# @param [Integer] cell_space Additional space between managed shapes
|
20
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
21
|
+
def initialize(pos = Shape::DEFAULT::POSITION, size = RectShape::DEFAULT::SIZE,
|
22
|
+
cols: DEFAULT::COLUMNS, max_rows: 0, cell_space: DEFAULT::CELLSPACE, diagram: nil)
|
25
23
|
super
|
26
24
|
end
|
27
25
|
|
26
|
+
protected
|
27
|
+
|
28
28
|
# Do layout of assigned child shapes
|
29
29
|
def do_children_layout
|
30
30
|
return if @cols == 0 || @rows == 0
|
31
31
|
|
32
|
+
# get maximum size of all managed (child) shapes per row and column
|
33
|
+
row_sizes, col_sizes = get_max_child_sizes
|
34
|
+
total_x = total_y = 0
|
35
|
+
|
36
|
+
# put managed shapes to appropriate positions
|
37
|
+
@cells.each_with_index do |shape, i|
|
38
|
+
col = (i % @cols)
|
39
|
+
row = (i / @cols)
|
40
|
+
if col == 0
|
41
|
+
total_x = 0
|
42
|
+
total_y += row_sizes[row-1] if row > 0
|
43
|
+
else
|
44
|
+
total_x += col_sizes[col-1]
|
45
|
+
end
|
46
|
+
|
47
|
+
if shape
|
48
|
+
fit_shape_to_rect(shape,
|
49
|
+
Wx::Rect.new(total_x + (col+1)*@cell_space,
|
50
|
+
total_y + (row+1)*@cell_space,
|
51
|
+
col_sizes[col], row_sizes[row]))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_max_child_sizes
|
32
57
|
# initialize size arrays
|
33
58
|
row_sizes = ::Array.new(@rows, 0)
|
34
59
|
col_sizes = ::Array.new(@cols, 0)
|
35
60
|
|
36
|
-
# prepare a storage for processed shapes pointers
|
37
|
-
grid_shapes = ::Array.new(@cells.size)
|
38
|
-
|
39
61
|
# get maximum size of all managed (child) shapes per row and column
|
40
|
-
@cells.each_with_index do |
|
41
|
-
if
|
62
|
+
@cells.each_with_index do |shape, i|
|
63
|
+
if shape
|
42
64
|
col = (i % @cols)
|
43
65
|
row = (i / @cols)
|
44
66
|
|
45
|
-
grid_shapes[i] = shape = @child_shapes[id]
|
46
67
|
curr_rect = shape.get_bounding_box
|
47
68
|
|
48
69
|
# update maximum rows and columns sizes
|
@@ -50,26 +71,30 @@ module Wx::SF
|
|
50
71
|
row_sizes[row] = curr_rect.height if (shape.get_v_align != VALIGN::EXPAND) && (curr_rect.height > row_sizes[row])
|
51
72
|
end
|
52
73
|
end
|
74
|
+
[row_sizes, col_sizes]
|
75
|
+
end
|
53
76
|
|
54
|
-
|
77
|
+
def find_cell(child_rect)
|
78
|
+
# get maximum size of all managed (child) shapes per row and column
|
79
|
+
row_sizes, col_sizes = get_max_child_sizes
|
55
80
|
|
56
|
-
|
57
|
-
grid_shapes.each_with_index do |shape, i|
|
58
|
-
if shape
|
59
|
-
col = (i % @cols)
|
60
|
-
row = (i / @cols)
|
61
|
-
if col == 0
|
62
|
-
total_x = 0
|
63
|
-
total_y += row_sizes[row-1] if row > 0
|
64
|
-
else
|
65
|
-
total_x += col_sizes[col-1]
|
66
|
-
end
|
81
|
+
total_x = total_y = 0
|
67
82
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
83
|
+
# find the cell index where the new or dragged child is positioned above and in front of
|
84
|
+
offset = get_bounding_box.top_left
|
85
|
+
cell_count.times.find do |cell|
|
86
|
+
col = (cell % @cols)
|
87
|
+
row = (cell / @cols)
|
88
|
+
if col == 0
|
89
|
+
total_x = 0
|
90
|
+
total_y += row_sizes[row-1] if row > 0
|
91
|
+
else
|
92
|
+
total_x += col_sizes[col-1]
|
72
93
|
end
|
94
|
+
cell_rct = Wx::Rect.new(total_x + (col+1)*@cell_space,
|
95
|
+
total_y + (row+1)*@cell_space,
|
96
|
+
col_sizes[col], row_sizes[row]).offset!(offset)
|
97
|
+
child_rect.right <= cell_rct.right && child_rect.bottom <= cell_rct.bottom
|
73
98
|
end
|
74
99
|
end
|
75
100
|
|