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.
-
#swt_font ⇒ Object
readonly
Returns the value of attribute swt_font.
-
#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
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/glimmer/swt/font_proxy.rb', line 55 def initialize( = nil, font_properties) @widget_proxy = @font_properties = font_properties detect_invalid_font_property(font_properties) font_properties[:style] = SWTProxy[*font_properties[:style]] font_data_args = [:name, :height, :style].map do |font_property_name| font_properties[font_property_name] || send(font_property_name) end font_datum = FontData.new(*font_data_args) @swt_font = Font.new(DisplayProxy.instance.swt_display, font_datum) end |
Instance Attribute Details
#font_properties ⇒ Object (readonly)
Returns the value of attribute font_properties.
44 45 46 |
# File 'lib/glimmer/swt/font_proxy.rb', line 44 def font_properties @font_properties end |
#swt_font ⇒ Object (readonly)
Returns the value of attribute swt_font.
44 45 46 |
# File 'lib/glimmer/swt/font_proxy.rb', line 44 def swt_font @swt_font end |
#widget_proxy ⇒ Object (readonly)
Returns the value of attribute widget_proxy.
44 45 46 |
# File 'lib/glimmer/swt/font_proxy.rb', line 44 def @widget_proxy end |
Instance Method Details
#height ⇒ Object
71 72 73 |
# File 'lib/glimmer/swt/font_proxy.rb', line 71 def height font_datum.getHeight end |
#name ⇒ Object
67 68 69 |
# File 'lib/glimmer/swt/font_proxy.rb', line 67 def name font_datum.getName end |
#style ⇒ Object
75 76 77 |
# File 'lib/glimmer/swt/font_proxy.rb', line 75 def style font_datum.getStyle end |