Class: Shoes::Swt::TextBlock::CenteredTextSegment
- Inherits:
-
TextSegment
- Object
- TextSegment
- Shoes::Swt::TextBlock::CenteredTextSegment
- Defined in:
- shoes-swt/lib/shoes/swt/text_block/centered_text_segment.rb
Overview
Presently centering always takes the whole line, so this class easily allows us to keep those alternate overrides separate from the main flowing text definitions for a segment.
Constant Summary
Constants inherited from TextSegment
Instance Attribute Summary
Attributes inherited from TextSegment
#element_left, #element_top, #fill_background, #layout
Instance Method Summary collapse
-
#initialize(dsl, width) ⇒ CenteredTextSegment
constructor
A new instance of CenteredTextSegment.
-
#last_line_width ⇒ Object
Overrides to not allow for flowing on final line–whole width only.
Methods inherited from TextSegment
#dispose, #draw, #font_styling, #get_location, #height, #in_bounds?, #last_line_height, #position_at, #set_style, #style_from
Constructor Details
#initialize(dsl, width) ⇒ CenteredTextSegment
Returns a new instance of CenteredTextSegment.
10 11 12 13 14 15 |
# File 'shoes-swt/lib/shoes/swt/text_block/centered_text_segment.rb', line 10 def initialize(dsl, width) super(dsl, dsl.text, width) # Centered text always takes all the width it's given layout.width = width end |
Instance Method Details
#last_line_width ⇒ Object
Overrides to not allow for flowing on final line–whole width only
18 19 20 |
# File 'shoes-swt/lib/shoes/swt/text_block/centered_text_segment.rb', line 18 def last_line_width layout.width end |