Class: Glimmer::SWT::FontProxy
- Inherits:
-
Object
- Object
- Glimmer::SWT::FontProxy
- Defined in:
- lib/glimmer/swt/font_proxy.rb
Overview
Proxy for org.eclipse.swt.graphics.Font
This class can be optionally used with WidgetProxy to manipulate an SWT widget font (reusing its FontData but building a new Font)
Otherwise, if no WidgetProxy is passed to constructor, it builds new FontData
Invoking ‘#swt_font` returns the SWT Font object wrapped by this proxy
Follows the Proxy Design Pattern
Constant Summary collapse
- ERROR_INVALID_FONT_STYLE =
" is an invalid font style! Valid values are :normal, :bold, and :italic"
- FONT_STYLES =
[:normal, :bold, :italic]
Instance Attribute Summary collapse
-
#font_properties ⇒ Object
readonly
Returns the value of attribute font_properties.
-
#widget_proxy ⇒ Object
readonly
Returns the value of attribute widget_proxy.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(widget_proxy = nil, font_properties) ⇒ FontProxy
constructor
Builds a new font proxy from passed in widget_proxy and font_properties hash,.
- #name ⇒ Object
- #style ⇒ Object
Constructor Details
#initialize(widget_proxy = nil, font_properties) ⇒ FontProxy
Builds a new font proxy from passed in widget_proxy and font_properties hash,
It begins with existing SWT widget font and amends it with font properties.
Font properties consist of: :name, :height, and :style (one needed minimum)
Style (:style value) can only be one of FontProxy::FONT_STYLES values: that is :normal, :bold, or :italic
50 51 52 53 54 |
# File 'lib/glimmer/swt/font_proxy.rb', line 50 def initialize( = nil, font_properties) @widget_proxy = @font_properties = font_properties.symbolize_keys detect_invalid_font_property(font_properties) end |
Instance Attribute Details
#font_properties ⇒ Object (readonly)
Returns the value of attribute font_properties.
40 41 42 |
# File 'lib/glimmer/swt/font_proxy.rb', line 40 def font_properties @font_properties end |
#widget_proxy ⇒ Object (readonly)
Returns the value of attribute widget_proxy.
40 41 42 |
# File 'lib/glimmer/swt/font_proxy.rb', line 40 def @widget_proxy end |
Instance Method Details
#height ⇒ Object
60 61 62 |
# File 'lib/glimmer/swt/font_proxy.rb', line 60 def height font_properties[:height] end |
#name ⇒ Object
56 57 58 |
# File 'lib/glimmer/swt/font_proxy.rb', line 56 def name font_properties[:name] end |
#style ⇒ Object
64 65 66 |
# File 'lib/glimmer/swt/font_proxy.rb', line 64 def style font_properties[:style] end |