Class: Shoes::Swt::Link
- Inherits:
-
Object
- Object
- Shoes::Swt::Link
- Includes:
- Common::Clickable, Common::Fill, Common::Stroke
- Defined in:
- shoes-swt/lib/shoes/swt/link.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#link_segments ⇒ Object
readonly
Returns the value of attribute link_segments.
Attributes included from Common::Clickable
Instance Method Summary collapse
- #create_links_in(text_segment_ranges) ⇒ Object
- #in_bounds?(x, y) ⇒ Boolean
-
#initialize(dsl, app) ⇒ Link
constructor
A new instance of Link.
- #redraw_target ⇒ Object
- #remove ⇒ Object
Methods included from Common::Stroke
Methods included from Common::Fill
Methods included from Common::Clickable
#click, #pass_coordinates?, #register_click, #release
Constructor Details
#initialize(dsl, app) ⇒ Link
Returns a new instance of Link.
12 13 14 15 16 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 12 def initialize(dsl, app) @app = app @link_segments = [] @dsl = dsl end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 10 def app @app end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 10 def dsl @dsl end |
#link_segments ⇒ Object (readonly)
Returns the value of attribute link_segments.
10 11 12 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 10 def link_segments @link_segments end |
Instance Method Details
#create_links_in(text_segment_ranges) ⇒ Object
27 28 29 30 31 32 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 27 def create_links_in(text_segment_ranges) @link_segments.clear text_segment_ranges.each do |text_segment, range| @link_segments << LinkSegment.new(text_segment, range) end end |
#in_bounds?(x, y) ⇒ Boolean
34 35 36 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 34 def in_bounds?(x, y) @link_segments.any? { |segment| segment.in_bounds?(x, y) } end |
#redraw_target ⇒ Object
18 19 20 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 18 def redraw_target @dsl.text_block end |
#remove ⇒ Object
22 23 24 25 |
# File 'shoes-swt/lib/shoes/swt/link.rb', line 22 def remove @link_segments.clear app.click_listener.remove_listeners_for(self) end |