Class: Fox::Canvas::TextShape

Inherits:
RectangleShape show all
Defined in:
lib/fox16/canvas.rb

Instance Attribute Summary collapse

Attributes inherited from RectangleShape

#height, #width

Attributes inherited from Shape

#foreground, #selector, #target, #x, #y

Instance Method Summary collapse

Methods inherited from Shape

#bounds, #deselect, #disable, #draggable=, #draggable?, #drawOutline, #enable, #enabled?, #hide, #hit?, #makeControlPoints, #move, #position, #resize, #select, #selected?, #show, #visible?

Constructor Details

#initialize(x, y, w, h, text = nil) ⇒ TextShape


242
243
244
245
246
# File 'lib/fox16/canvas.rb', line 242

def initialize(x, y, w, h, text=nil)
  super(x, y, w, h)
  @text = text
  @font = FXApp.instance.normalFont
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font


240
241
242
# File 'lib/fox16/canvas.rb', line 240

def font
  @font
end

#textObject (readonly)

Returns the value of attribute text


240
241
242
# File 'lib/fox16/canvas.rb', line 240

def text
  @text
end

Instance Method Details

#draw(dc) ⇒ Object


248
249
250
251
252
253
254
255
256
# File 'lib/fox16/canvas.rb', line 248

def draw(dc)
  super(dc)
  oldForeground = dc.foreground
  oldTextFont = dc.font
  dc.font = @font
  dc.drawImageText(x, y, text)
  dc.font = oldTextFont if oldTextFont
  dc.foreground = oldForeground
end