Class: Shoes::Swt::TextBlock::CenteredTextSegment

Inherits:
TextSegment
  • Object
show all
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

TextSegment::DEFAULT_SPACING

Instance Attribute Summary

Attributes inherited from TextSegment

#element_left, #element_top, #fill_background, #layout

Instance Method Summary collapse

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_widthObject

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