Class: Shoes::Swt::TextStyleFactory
- Inherits:
-
Object
- Object
- Shoes::Swt::TextStyleFactory
- Defined in:
- shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb
Constant Summary collapse
- UNDERLINE_STYLES =
{ "single" => 0, "double" => 1, "error" => 2, }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #create_style(font, foreground, background, style) ⇒ Object
- #dispose ⇒ Object
-
#initialize ⇒ TextStyleFactory
constructor
A new instance of TextStyleFactory.
Constructor Details
#initialize ⇒ TextStyleFactory
Returns a new instance of TextStyleFactory.
12 13 14 |
# File 'shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb', line 12 def initialize @colors = [] end |
Class Method Details
.apply_styles(gui_style, dsl_style) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb', line 33 def self.apply_styles(gui_style, dsl_style) gui_style[:font_detail][:styles] = parse_font_style(dsl_style) gui_style[:font_detail][:name] = dsl_style[:font] if dsl_style[:font] gui_style[:font_detail][:size] = dsl_style[:size] if dsl_style[:size] gui_style[:fg] = dsl_style[:stroke] gui_style[:bg] = dsl_style[:fill] gui_style[:font_detail][:size] *= dsl_style[:size_modifier] if dsl_style[:size_modifier] gui_style.merge(dsl_style) end |
.parse_font_style(style) ⇒ Object
43 44 45 46 47 48 49 |
# File 'shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb', line 43 def self.parse_font_style(style) font_styles = [] font_styles << ::Swt::SWT::BOLD if style[:weight] font_styles << ::Swt::SWT::ITALIC if style[:emphasis] font_styles << ::Swt::SWT::NORMAL if !style[:weight] && !style[:emphasis] font_styles end |
Instance Method Details
#create_style(font, foreground, background, style) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb', line 21 def create_style(font, foreground, background, style) fg = swt_color(foreground, ::Shoes::COLORS[:black]) bg = swt_color(background) @gui_style = ::Swt::TextStyle.new font, fg, bg set_underline(style) set_undercolor(style) set_rise(style) set_strikethrough(style) set_strikecolor(style) @gui_style end |