wxruby3-shapes 0.9.0.pre.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/CREDITS.md +18 -0
- data/INSTALL.md +39 -0
- data/LICENSE +21 -0
- data/README.md +118 -0
- data/assets/screenshot.png +0 -0
- data/bin/wx-shapes +9 -0
- data/lib/wx/shapes/arrow_base.rb +86 -0
- data/lib/wx/shapes/arrows/circle_arrow.rb +39 -0
- data/lib/wx/shapes/arrows/diamond_arrow.rb +33 -0
- data/lib/wx/shapes/arrows/open_arrow.rb +56 -0
- data/lib/wx/shapes/arrows/solid_arrow.rb +69 -0
- data/lib/wx/shapes/art/shape_canvas/page.xpm +73 -0
- data/lib/wx/shapes/auto_layout.rb +358 -0
- data/lib/wx/shapes/base.rb +33 -0
- data/lib/wx/shapes/canvas_history.rb +84 -0
- data/lib/wx/shapes/connection_point.rb +238 -0
- data/lib/wx/shapes/core.rb +19 -0
- data/lib/wx/shapes/diagram.rb +659 -0
- data/lib/wx/shapes/events.rb +389 -0
- data/lib/wx/shapes/printout.rb +136 -0
- data/lib/wx/shapes/serializable.rb +440 -0
- data/lib/wx/shapes/serialize/core.rb +40 -0
- data/lib/wx/shapes/serialize/id.rb +82 -0
- data/lib/wx/shapes/serialize/wx.rb +104 -0
- data/lib/wx/shapes/serializer/json.rb +258 -0
- data/lib/wx/shapes/serializer/yaml.rb +125 -0
- data/lib/wx/shapes/shape.rb +2129 -0
- data/lib/wx/shapes/shape_canvas.rb +3285 -0
- data/lib/wx/shapes/shape_data_object.rb +43 -0
- data/lib/wx/shapes/shape_handle.rb +287 -0
- data/lib/wx/shapes/shape_list.rb +161 -0
- data/lib/wx/shapes/shapes/bitmap_shape.rb +257 -0
- data/lib/wx/shapes/shapes/circle_shape.rb +136 -0
- data/lib/wx/shapes/shapes/control_shape.rb +483 -0
- data/lib/wx/shapes/shapes/curve_shape.rb +231 -0
- data/lib/wx/shapes/shapes/diamond_shape.rb +62 -0
- data/lib/wx/shapes/shapes/edit_text_shape.rb +317 -0
- data/lib/wx/shapes/shapes/ellipse_shape.rb +106 -0
- data/lib/wx/shapes/shapes/flex_grid_shape.rb +78 -0
- data/lib/wx/shapes/shapes/grid_shape.rb +404 -0
- data/lib/wx/shapes/shapes/line_shape.rb +907 -0
- data/lib/wx/shapes/shapes/multi_sel_rect.rb +214 -0
- data/lib/wx/shapes/shapes/ortho_shape.rb +357 -0
- data/lib/wx/shapes/shapes/polygon_shape.rb +294 -0
- data/lib/wx/shapes/shapes/rect_shape.rb +378 -0
- data/lib/wx/shapes/shapes/round_ortho_shape.rb +131 -0
- data/lib/wx/shapes/shapes/round_rect_shape.rb +142 -0
- data/lib/wx/shapes/shapes/square_shape.rb +119 -0
- data/lib/wx/shapes/shapes/text_shape.rb +324 -0
- data/lib/wx/shapes/thumbnail.rb +234 -0
- data/lib/wx/shapes/version.rb +12 -0
- data/lib/wx/shapes/wx.rb +29 -0
- data/lib/wx/shapes.rb +18 -0
- data/lib/wx/wx-shapes/base.rb +87 -0
- data/lib/wx/wx-shapes/cmd/sampler.rb +58 -0
- data/lib/wx/wx-shapes/cmd/test.rb +27 -0
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +7 -0
- data/rakelib/yard/templates/default/layout/html/setup.rb +5 -0
- data/rakelib/yard/yard/relative_markdown_links/version.rb +8 -0
- data/rakelib/yard/yard/relative_markdown_links.rb +39 -0
- data/rakelib/yard/yard-custom-templates.rb +2 -0
- data/rakelib/yard/yard-relative_markdown_links.rb +4 -0
- data/samples/demo/art/AlignBottom.xpm +35 -0
- data/samples/demo/art/AlignCenter.xpm +35 -0
- data/samples/demo/art/AlignLeft.xpm +35 -0
- data/samples/demo/art/AlignMiddle.xpm +35 -0
- data/samples/demo/art/AlignRight.xpm +35 -0
- data/samples/demo/art/AlignTop.xpm +35 -0
- data/samples/demo/art/Bitmap.xpm +25 -0
- data/samples/demo/art/Circle.xpm +22 -0
- data/samples/demo/art/Curve.xpm +21 -0
- data/samples/demo/art/Diamond.xpm +22 -0
- data/samples/demo/art/EditText.xpm +21 -0
- data/samples/demo/art/Ellipse.xpm +22 -0
- data/samples/demo/art/FixedRect.xpm +22 -0
- data/samples/demo/art/FlexGrid.xpm +22 -0
- data/samples/demo/art/GC.xpm +23 -0
- data/samples/demo/art/Grid.xpm +22 -0
- data/samples/demo/art/Line.xpm +21 -0
- data/samples/demo/art/NoSource.xpm +69 -0
- data/samples/demo/art/OrthoLine.xpm +21 -0
- data/samples/demo/art/Rect.xpm +22 -0
- data/samples/demo/art/RoundOrthoLine.xpm +21 -0
- data/samples/demo/art/RoundRect.xpm +22 -0
- data/samples/demo/art/Shadow.xpm +23 -0
- data/samples/demo/art/StandAloneLine.xpm +22 -0
- data/samples/demo/art/Text.xpm +21 -0
- data/samples/demo/art/Tool.xpm +23 -0
- data/samples/demo/art/sample.xpm +251 -0
- data/samples/demo/demo.rb +658 -0
- data/samples/demo/frame_canvas.rb +422 -0
- data/samples/demo/images/motyl.bmp +0 -0
- data/samples/demo/images/motyl2.bmp +0 -0
- data/samples/sample1/art/sample.xpm +251 -0
- data/samples/sample1/sample.rb +263 -0
- data/samples/sample2/art/sample.xpm +251 -0
- data/samples/sample2/sample.rb +133 -0
- data/samples/sample2/sample_canvas.rb +35 -0
- data/samples/sample2/sample_shape.rb +108 -0
- data/samples/sample3/art/sample.xpm +251 -0
- data/samples/sample3/sample.rb +281 -0
- data/samples/sample4/art/sample.xpm +251 -0
- data/samples/sample4/sample.rb +180 -0
- data/tests/art/motyl.bmp +0 -0
- data/tests/lib/wxapp_runner.rb +64 -0
- data/tests/serializer_tests.rb +521 -0
- data/tests/test_grid_shapes.rb +42 -0
- data/tests/test_serialize.rb +7 -0
- data/tests/test_serialize_yaml.rb +17 -0
- metadata +242 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
# Wx::SF::BitmapShape - Bitmap shape class
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
|
+
|
4
|
+
require 'wx/shapes/shapes/rect_shape'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
module Wx::SF
|
8
|
+
|
9
|
+
# Class encapsulating the bitmap shape. The shape can display and control
|
10
|
+
# files stored in formats supported by Wx::Bitmap class loaded from a file or created
|
11
|
+
# from XPM image.
|
12
|
+
class BitmapShape < RectShape
|
13
|
+
|
14
|
+
property :can_scale, :bitmap
|
15
|
+
|
16
|
+
# @overload initialize()
|
17
|
+
# Default constructor.
|
18
|
+
# @overload initialize(pos, bmp_path, diagram)
|
19
|
+
# User constructor.
|
20
|
+
# @param [Wx::RealPoint] pos Initial position
|
21
|
+
# @param [String] bmp_path Bitmap path
|
22
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
23
|
+
def initialize(*args)
|
24
|
+
@bitmap = Wx::NULL_BITMAP
|
25
|
+
@art_path = @art_section = nil
|
26
|
+
if args.empty?
|
27
|
+
super
|
28
|
+
@bitmap_path = nil
|
29
|
+
@original_bitmap = @bitmap = nil
|
30
|
+
@bitmap_type = nil
|
31
|
+
else
|
32
|
+
pos, bmp_path, diagram = args
|
33
|
+
super(pos, RectShape::DEFAULT::SIZE.dup, diagram)
|
34
|
+
create_from_file(bmp_path)
|
35
|
+
end
|
36
|
+
@rescale_in_progress = false
|
37
|
+
@can_scale = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get full name of a source BMP file.
|
41
|
+
# @return [String] String containing full file name
|
42
|
+
def get_bitmap_path
|
43
|
+
@bitmap_path
|
44
|
+
end
|
45
|
+
|
46
|
+
# Enable/disable scaling mode of the bitmap.
|
47
|
+
# @param [Boolean] canscale Set true if the bitmap shape could be scaled
|
48
|
+
def enable_scale(canscale)
|
49
|
+
@can_scale = canscale
|
50
|
+
end
|
51
|
+
alias :set_can_scale :enable_scale
|
52
|
+
|
53
|
+
# Get information about the possibility of the shape scaling.
|
54
|
+
# @return [Boolean] true if the shape can be scaled, otherwise false
|
55
|
+
def can_scale?
|
56
|
+
@can_scale
|
57
|
+
end
|
58
|
+
alias :get_can_scale :can_scale?
|
59
|
+
|
60
|
+
# Load a bitmap from the file.
|
61
|
+
# @param [String,Symbol] file File name (absolute or relative) or base name for art file (for Wx::ArtLocator)
|
62
|
+
# @param [Wx::BitmapType,nil] type Bitmap type (see the wxBitmap class reference)
|
63
|
+
# @param [String] art_path base path to look up the art file for Wx::ArtLocator
|
64
|
+
# @param [String,nil] art_section optional owner folder name for art files for Wx::ArtLocator
|
65
|
+
# @return [Boolean] true on success, otherwise false
|
66
|
+
# @see Wx::ArtLocator
|
67
|
+
def create_from_file(file, type = nil, art_path: nil, art_section: nil)
|
68
|
+
# load bitmap from the file
|
69
|
+
@bitmap_path = file
|
70
|
+
@bitmap_type = type
|
71
|
+
if File.file?(@bitmap_path.to_s)
|
72
|
+
@bitmap = Wx::Bitmap.new
|
73
|
+
success = @bitmap.load_file(@bitmap_path, type ? type : Wx::BITMAP_TYPE_ANY)
|
74
|
+
else
|
75
|
+
art_path ||= File.dirname(caller_locations(1).first.absolute_path)
|
76
|
+
art_section ||= File.basename(caller_locations(1).first.absolute_path, '.*')
|
77
|
+
path = Wx::ArtLocator.find_art(@bitmap_path, art_path: art_path, art_section: art_section, art_type: :bitmap, bmp_type: type)
|
78
|
+
if path
|
79
|
+
@bitmap = Wx::Bitmap.new
|
80
|
+
success = @bitmap.load_file(path, type ? type : Wx::BITMAP_TYPE_ANY)
|
81
|
+
if success
|
82
|
+
p = Pathname.new(art_path)
|
83
|
+
@art_path = p.relative? ? art_path : p.relative_path_from(Dir.getwd).to_s
|
84
|
+
@art_section = art_section
|
85
|
+
end
|
86
|
+
else
|
87
|
+
@bitmap = nil
|
88
|
+
success = false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
@original_bitmap = @bitmap
|
93
|
+
|
94
|
+
if success
|
95
|
+
@rect_size.x = @bitmap.width
|
96
|
+
@rect_size.y = @bitmap.height
|
97
|
+
|
98
|
+
if @can_scale
|
99
|
+
add_style(Shape::STYLE::SIZE_CHANGE)
|
100
|
+
else
|
101
|
+
remove_style(Shape::STYLE::SIZE_CHANGE)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
success
|
106
|
+
end
|
107
|
+
|
108
|
+
# Event handler called during dragging of the shape handle. The function can be overridden if necessary.
|
109
|
+
# @param [Shape::Handle] handle Reference to the dragged shape handle
|
110
|
+
def on_handle(handle)
|
111
|
+
if @can_scale
|
112
|
+
super
|
113
|
+
else
|
114
|
+
remove_style(STYLE::SIZE_CHANGE)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Event handler called when the user finished dragging of the shape handle. The function can be overridden if necessary.
|
119
|
+
# @param [Shape::Handle] handle Reference to the dragged shape handle
|
120
|
+
def on_end_handle(handle)
|
121
|
+
if @can_scale
|
122
|
+
@rescale_in_progress = false
|
123
|
+
rescale_image(@rect_size)
|
124
|
+
end
|
125
|
+
|
126
|
+
super
|
127
|
+
end
|
128
|
+
|
129
|
+
protected
|
130
|
+
|
131
|
+
# Event handler called by ShapeCanvas to request,report canvas changes.
|
132
|
+
# @param [ShapeCanvas::CHANGE] change change type indicator
|
133
|
+
# @param [Array] _args any additional arguments
|
134
|
+
# @return [Boolean,nil]
|
135
|
+
def _on_canvas(change, *_args)
|
136
|
+
if change == ShapeCanvas::CHANGE::RESCALED
|
137
|
+
self.scale(1, 1)
|
138
|
+
end
|
139
|
+
super
|
140
|
+
end
|
141
|
+
|
142
|
+
# Handle action at handle drag beginning
|
143
|
+
def do_begin_handle
|
144
|
+
if @can_scale
|
145
|
+
@rescale_in_progress = true
|
146
|
+
@prev_pos = get_absolute_position
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Scale the rectangle size for this shape.
|
151
|
+
# @param [Float] x Horizontal scale factor
|
152
|
+
# @param [Float] y Vertical scale factor
|
153
|
+
def scale_rectangle(x, y)
|
154
|
+
if @can_scale
|
155
|
+
@rect_size.x *= x
|
156
|
+
@rect_size.y *= y
|
157
|
+
|
158
|
+
rescale_image(@rect_size) unless @rescale_in_progress
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Rescale the bitmap shape so it will fit the given extent. The
|
163
|
+
# shape position is not involved (the left-top bitmap corner is not moved).
|
164
|
+
# @param [Wx::RealPoint] size New bitmap size
|
165
|
+
def rescale_image(size)
|
166
|
+
if get_parent_canvas && @original_bitmap && @original_bitmap.ok?
|
167
|
+
size = size.to_real_point
|
168
|
+
if ShapeCanvas.gc_enabled?
|
169
|
+
Wx::Bitmap.rescale(@bitmap = Wx::Bitmap.new(@original_bitmap), size.to_size)
|
170
|
+
else
|
171
|
+
scale = get_parent_canvas.get_scale
|
172
|
+
Wx::Bitmap.rescale(@bitmap = Wx::Bitmap.new(@original_bitmap), (size * scale).to_size)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Draw the shape in the normal way. The function can be overridden if necessary.
|
178
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
179
|
+
def draw_normal(dc)
|
180
|
+
# HINT: overload it for custom actions...
|
181
|
+
if @rescale_in_progress
|
182
|
+
_draw_bitmap(dc, @prev_pos.to_point)
|
183
|
+
|
184
|
+
dc.with_brush(Wx::TRANSPARENT_BRUSH) do
|
185
|
+
dc.with_pen(Wx::Pen.new(Wx::Colour.new(100, 100, 100), 1, Wx::PenStyle::PENSTYLE_DOT)) do
|
186
|
+
dc.draw_rectangle(get_absolute_position.to_point, @rect_size.to_size)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else
|
190
|
+
_draw_bitmap(dc, get_absolute_position.to_point)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Draw the shape in the hover mode (the mouse cursor is above the shape). The function can be overridden if necessary.
|
195
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
196
|
+
def draw_hover(dc)
|
197
|
+
_draw_bitmap(dc, get_absolute_position.to_point)
|
198
|
+
|
199
|
+
dc.with_brush(Wx::TRANSPARENT_BRUSH) do
|
200
|
+
dc.with_pen(Wx::Pen.new(@hover_color, 1)) do
|
201
|
+
dc.draw_rectangle(get_absolute_position.to_point, @rect_size.to_size)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Draw the shape in the highlighted mode (another shape is dragged over this shape and this shape will accept the
|
207
|
+
# dragged one if it will be dropped on it). The function can be overridden if necessary.
|
208
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
209
|
+
def draw_highlighted(dc)
|
210
|
+
_draw_bitmap(dc, get_absolute_position.to_point)
|
211
|
+
|
212
|
+
dc.with_brush(Wx::TRANSPARENT_BRUSH) do
|
213
|
+
dc.with_pen(Wx::Pen.new(@hover_color, 2)) do
|
214
|
+
dc.draw_rectangle(get_absolute_position.to_point, @rect_size.to_size)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
private
|
220
|
+
|
221
|
+
# draw the bitmap
|
222
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
223
|
+
# @param [Wx::Point] pos
|
224
|
+
def _draw_bitmap(dc, pos)
|
225
|
+
if @bitmap && @bitmap.ok?
|
226
|
+
dc.draw_bitmap(@bitmap, pos)
|
227
|
+
else
|
228
|
+
dc.with_brush(Wx::TRANSPARENT_BRUSH) do
|
229
|
+
dc.with_pen(Wx::BLACK_PEN) do
|
230
|
+
dc.draw_rectangle(pos, @rect_size.to_size)
|
231
|
+
dc.draw_line(pos, [pos.x+@rect_size.x.to_i-1, pos.y+@rect_size.y.to_i-1])
|
232
|
+
dc.draw_line([pos.x, pos.y+@rect_size.y.to_i-1], [pos.x+@rect_size.x.to_i-1, pos.y])
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Serialization only.
|
239
|
+
def get_bitmap
|
240
|
+
if @bitmap && @bitmap.ok?
|
241
|
+
[@bitmap_path, @bitmap_type, @art_path, @art_section]
|
242
|
+
else
|
243
|
+
[nil,nil]
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# Deserialization only.
|
248
|
+
def set_bitmap(bmp_data)
|
249
|
+
file, type, art_path, art_section = bmp_data
|
250
|
+
if file
|
251
|
+
create_from_file(file, type, art_path: art_path, art_section: art_section)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Wx::SF::CircleShape - circle shape class
|
2
|
+
# Copyright (c) M.J.N. Corino, The Netherlands
|
3
|
+
|
4
|
+
require 'wx/shapes/shapes/square_shape'
|
5
|
+
|
6
|
+
module Wx::SF
|
7
|
+
|
8
|
+
# Class encapsulating the circle shape.
|
9
|
+
class CircleShape < SquareShape
|
10
|
+
|
11
|
+
# @overload initialize()
|
12
|
+
# Default constructor.
|
13
|
+
# @overload initialize(pos, size, diagram)
|
14
|
+
# User constructor.
|
15
|
+
# @param [Wx::RealPoint] pos Initial position
|
16
|
+
# @param [Float] radius Initial circle radius
|
17
|
+
# @param [Wx::SF::Diagram] diagram parent diagram
|
18
|
+
def initialize(*args)
|
19
|
+
if args.empty?
|
20
|
+
super
|
21
|
+
set_rect_size(50,50)
|
22
|
+
else
|
23
|
+
pos, rad, diagram = args
|
24
|
+
super(pos, rad*2, diagram)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_radius
|
29
|
+
@rect_size.x/2
|
30
|
+
end
|
31
|
+
alias :radius :get_radius
|
32
|
+
|
33
|
+
def set_radius(rad)
|
34
|
+
set_rect_size(rad*2, rad*2)
|
35
|
+
end
|
36
|
+
alias :radius= :set_radius
|
37
|
+
|
38
|
+
# Test whether the given point is inside the shape. The function
|
39
|
+
# can be overridden if necessary.
|
40
|
+
# @param [Wx::Point] pos Examined point
|
41
|
+
# @return [Boolean] true if the point is inside the shape area, otherwise false
|
42
|
+
def contains?(pos)
|
43
|
+
get_center.distance_to(pos) <= radius
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get intersection point of the shape border and a line leading from
|
47
|
+
# 'start' point to 'end' point. The function can be overridden if necessary.
|
48
|
+
# @param [Wx::RealPoint] start Starting point of the virtual intersection line
|
49
|
+
# @param [Wx::RealPoint] end_pt Ending point of the virtual intersection line
|
50
|
+
# @return [Wx::RealPoint] Intersection point
|
51
|
+
def get_border_point(start, end_pt)
|
52
|
+
start = start.to_real_point; end_pt.to_real_point
|
53
|
+
dist = start.distance_to(end_pt)
|
54
|
+
center = get_center
|
55
|
+
|
56
|
+
if dist != 0.0
|
57
|
+
rad = radius
|
58
|
+
src_dx = rad*(end_pt.x-start.x)/dist - (start.x-center.x)
|
59
|
+
src_dy = rad*(end_pt.y-start.y)/dist - (start.y-center.y)
|
60
|
+
|
61
|
+
Wx::RealPoint.new(start.x + src_dx, start.y + src_dy)
|
62
|
+
else
|
63
|
+
center
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
# Draw the shape in the normal way. The function can be overridden if necessary.
|
70
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
71
|
+
def draw_normal(dc)
|
72
|
+
# HINT: overload it for custom actions...
|
73
|
+
pos = get_absolute_position
|
74
|
+
|
75
|
+
dc.with_pen(@border) do
|
76
|
+
dc.with_brush(@fill) do
|
77
|
+
dc.draw_circle((pos.x + @rect_size.x/2).to_i,
|
78
|
+
(pos.y + @rect_size.y/2).to_i,
|
79
|
+
(@rect_size.x/2).to_i)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Draw the shape in the hover mode (the mouse cursor is above the shape).
|
85
|
+
# The function can be overridden if necessary.
|
86
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
87
|
+
def draw_hover(dc)
|
88
|
+
# HINT: overload it for custom actions...
|
89
|
+
pos = get_absolute_position
|
90
|
+
|
91
|
+
dc.with_pen(Wx::Pen.new(@hover_color, 1)) do
|
92
|
+
dc.with_brush(@fill) do
|
93
|
+
dc.draw_circle((pos.x + @rect_size.x/2).to_i,
|
94
|
+
(pos.y + @rect_size.y/2).to_i,
|
95
|
+
(@rect_size.x/2).to_i)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Draw the shape in the highlighted mode (another shape is dragged over this
|
101
|
+
# shape and this shape will accept the dragged one if it will be dropped on it).
|
102
|
+
# The function can be overridden if necessary.
|
103
|
+
# @param [Wx::DC] dc Reference to device context where the shape will be drawn to
|
104
|
+
def draw_highlighted(dc)
|
105
|
+
# HINT: overload it for custom actions...
|
106
|
+
pos = get_absolute_position
|
107
|
+
|
108
|
+
dc.with_pen(Wx::Pen.new(@hover_color, 2)) do
|
109
|
+
dc.with_brush(@fill) do
|
110
|
+
dc.draw_circle((pos.x + @rect_size.x/2).to_i,
|
111
|
+
(pos.y + @rect_size.y/2).to_i,
|
112
|
+
(@rect_size.x/2).to_i)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Draw shadow under the shape. The function can be overridden if necessary.
|
118
|
+
# @param [Wx::DC] dc Reference to device context where the shadow will be drawn to
|
119
|
+
def draw_shadow(dc)
|
120
|
+
# HINT: overload it for custom actions...
|
121
|
+
pos = get_absolute_position
|
122
|
+
|
123
|
+
if @fill.style != Wx::BrushStyle::BRUSHSTYLE_TRANSPARENT
|
124
|
+
dc.with_pen(Wx::TRANSPARENT_PEN) do
|
125
|
+
dc.with_brush(get_parent_canvas.get_shadow_fill) do
|
126
|
+
dc.draw_circle((pos.x + @rect_size.x/2 + get_parent_canvas.get_shadow_offset.x).to_i,
|
127
|
+
(pos.y + @rect_size.y/2 + get_parent_canvas.get_shadow_offset.y).to_i,
|
128
|
+
(@rect_size.x/2).to_i)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|