Class: Shoes::Swt::Link

Inherits:
Object
  • Object
show all
Includes:
Common::Clickable, Common::Fill, Common::Stroke
Defined in:
shoes-swt/lib/shoes/swt/link.rb

Instance Attribute Summary collapse

Attributes included from Common::Clickable

#pass_coordinates

Instance Method Summary collapse

Methods included from Common::Stroke

#update_stroke

Methods included from Common::Fill

#update_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

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'shoes-swt/lib/shoes/swt/link.rb', line 10

def app
  @app
end

#dslObject (readonly)

Returns the value of attribute dsl.



10
11
12
# File 'shoes-swt/lib/shoes/swt/link.rb', line 10

def dsl
  @dsl
end

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



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

Returns:

  • (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_targetObject



18
19
20
# File 'shoes-swt/lib/shoes/swt/link.rb', line 18

def redraw_target
  @dsl.text_block
end

#removeObject



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