Class: RFont

Inherits:
Object
  • Object
show all
Extended by:
Glimmer
Defined in:
lib/command_handlers/models/r_font.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Glimmer

add_contents, add_contents, dsl, dsl, extended, included, logger, method_missing, method_missing

Methods included from SwtPackages

included

Constructor Details

#initialize(r_widget, display = nil) ⇒ RFont

Returns a new instance of RFont.



26
27
28
29
# File 'lib/command_handlers/models/r_font.rb', line 26

def initialize(r_widget, display = nil)
  @r_widget = r_widget
  @display = display || @r_widget.widget.display
end

Instance Attribute Details

#displayObject

Returns the value of attribute display.



9
10
11
# File 'lib/command_handlers/models/r_font.rb', line 9

def display
  @display
end

#r_widgetObject

Returns the value of attribute r_widget.



8
9
10
# File 'lib/command_handlers/models/r_font.rb', line 8

def r_widget
  @r_widget
end

Class Method Details

.for(r_widget) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/command_handlers/models/r_font.rb', line 12

def for(r_widget)
  @instances ||= {}
  unless @instances[r_widget]
    @instances[r_widget] = new(r_widget)
    add_contents(r_widget) {
      on_widget_disposed { |dispose_event|
        @instances.delete(r_widget)
      }
    }
  end
  @instances[r_widget]
end

Instance Method Details

#font(font_properties) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/command_handlers/models/r_font.rb', line 52

def font(font_properties)
  font_properties[:style] = RSwt[*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)
  Font.new(@display, font_datum)
end

#font_datumObject



36
37
38
# File 'lib/command_handlers/models/r_font.rb', line 36

def font_datum
  @font_datum ||= @r_widget.widget.getFont.getFontData[0]
end

#heightObject



44
45
46
# File 'lib/command_handlers/models/r_font.rb', line 44

def height
  font_datum.getHeight
end

#nameObject



40
41
42
# File 'lib/command_handlers/models/r_font.rb', line 40

def name
  font_datum.getName
end

#styleObject



48
49
50
# File 'lib/command_handlers/models/r_font.rb', line 48

def style
  font_datum.getStyle
end