class Fox::Canvas::Shape
Attributes
Public Class Methods
Source
# File lib/fox16/canvas.rb, line 26 def initialize(x, y) @enabled = true @visible = true @selected = false @draggable = false @x = x @y = y @foreground = FXRGB(0, 0, 0) @target = nil @selector = 0 end
Public Instance Methods
Source
# File lib/fox16/canvas.rb, line 39 def bounds FXRectangle.new(x, y, width, height) end
Return the bounding box for this shape
Source
# File lib/fox16/canvas.rb, line 99 def deselect @selected = false end
Deselect this shape
Source
# File lib/fox16/canvas.rb, line 69 def disable @enabled = false end
Disable this shape
Source
# File lib/fox16/canvas.rb, line 109 def draggable=(d) @draggable = d end
Set this shape’s draggability
Source
# File lib/fox16/canvas.rb, line 114 def draggable? @draggable end
Is this shape draggable?
Source
# File lib/fox16/canvas.rb, line 119 def draw(dc) end
Draw this shape into the specificed device context
Source
# File lib/fox16/canvas.rb, line 123 def drawOutline(dc, x, y, w, h) points = [] points << FXPoint.new(x - 0.5*w, y - 0.5*h) points << FXPoint.new(x + 0.5*w, y) points << FXPoint.new(x + 0.5*w, y + 0.5*h) points << FXPoint.new(x - 0.5*w, y + 0.5*h) points << points[0] dc.drawLines(points) end
Draws outline
Source
# File lib/fox16/canvas.rb, line 64 def enable @enabled = true end
Enable this shape
Source
# File lib/fox16/canvas.rb, line 74 def enabled? @enabled end
Is this shape enabled?
Source
# File lib/fox16/canvas.rb, line 44 def hit?(xpos, ypos) (xpos >= x) && (xpos < x+width) && (ypos >= y) && (ypos < y+height) end
Hit test
Source
# File lib/fox16/canvas.rb, line 134 def makeControlPoints end
Default: make 6 control points
Source
# File lib/fox16/canvas.rb, line 49 def move(x, y) @x, @y = x, y end
Move shape to specified position
Source
# File lib/fox16/canvas.rb, line 58 def position(x, y, w, h) move(x, y) resize(w, h) end
Move and resize the shape
Source
# File lib/fox16/canvas.rb, line 54 def resize(w, h) end
Resize shape to specified width and height
Source
# File lib/fox16/canvas.rb, line 94 def select @selected = true end
Select this shape
Source
# File lib/fox16/canvas.rb, line 104 def selected? @selected end
Is this shape selected?
Source
# File lib/fox16/canvas.rb, line 89 def visible? @visible end
Is this shape visible?
Protected Instance Methods
Source
# File lib/fox16/canvas.rb, line 137 def apply_dc(dc) oldForeground = dc.foreground dc.foreground = foreground yield dc.foreground = oldForeground end