Class: Glimmer::SWT::FontProxy

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

Instance Method Summary collapse

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(widget_proxy = nil, font_properties)
  @widget_proxy = widget_proxy
  @font_properties = font_properties.symbolize_keys
  detect_invalid_font_property(font_properties)
end

Instance Attribute Details

#font_propertiesObject (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_proxyObject (readonly)

Returns the value of attribute widget_proxy.



40
41
42
# File 'lib/glimmer/swt/font_proxy.rb', line 40

def widget_proxy
  @widget_proxy
end

Instance Method Details

#heightObject



60
61
62
# File 'lib/glimmer/swt/font_proxy.rb', line 60

def height
  font_properties[:height]
end

#nameObject



56
57
58
# File 'lib/glimmer/swt/font_proxy.rb', line 56

def name
  font_properties[:name]
end

#styleObject



64
65
66
# File 'lib/glimmer/swt/font_proxy.rb', line 64

def style
  font_properties[:style]
end