Class: Fox::Canvas::Shape

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Shape) initialize(x, y)



26
27
28
29
30
31
32
33
34
35
36
# 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

Instance Attribute Details

- (Object) foreground

Returns the value of attribute foreground



24
25
26
# File 'lib/fox16/canvas.rb', line 24

def foreground
  @foreground
end

- (Object) selector

Returns the value of attribute selector



24
25
26
# File 'lib/fox16/canvas.rb', line 24

def selector
  @selector
end

- (Object) target

Returns the value of attribute target



24
25
26
# File 'lib/fox16/canvas.rb', line 24

def target
  @target
end

- (Object) x

Returns the value of attribute x



24
25
26
# File 'lib/fox16/canvas.rb', line 24

def x
  @x
end

- (Object) y

Returns the value of attribute y



24
25
26
# File 'lib/fox16/canvas.rb', line 24

def y
  @y
end

Instance Method Details

- (Object) bounds

Return the bounding box for this shape



39
40
41
# File 'lib/fox16/canvas.rb', line 39

def bounds
	FXRectangle.new(x, y, width, height)
end

- (Object) deselect

Deselect this shape



99
100
101
# File 'lib/fox16/canvas.rb', line 99

def deselect
	@selected = false
end

- (Object) disable

Disable this shape



69
70
71
# File 'lib/fox16/canvas.rb', line 69

def disable
	@enabled = false
end

- (Object) draggable=(d)

Set this shape's draggability



109
110
111
# File 'lib/fox16/canvas.rb', line 109

def draggable=(d)
	@draggable = d
end

- (Boolean) draggable?

Is this shape draggable?



114
115
116
# File 'lib/fox16/canvas.rb', line 114

def draggable?
	@draggable
end

- (Object) draw(dc)

Draw this shape into the specificed device context



119
120
# File 'lib/fox16/canvas.rb', line 119

def draw(dc)
end

- (Object) drawOutline(dc, x, y, w, h)

Draws outline



123
124
125
126
127
128
129
130
131
# 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

- (Object) enable

Enable this shape



64
65
66
# File 'lib/fox16/canvas.rb', line 64

def enable
	@enabled = true
end

- (Boolean) enabled?

Is this shape enabled?



74
75
76
# File 'lib/fox16/canvas.rb', line 74

def enabled?
	@enabled
end

- (Object) hide

Hide this shape



84
85
86
# File 'lib/fox16/canvas.rb', line 84

def hide
	@visible = false
end

- (Boolean) hit?(xpos, ypos)

Hit test



44
45
46
# File 'lib/fox16/canvas.rb', line 44

def hit?(xpos, ypos)
	(xpos >= x) && (xpos < x+width) && (ypos >= y) && (ypos < y+height)
end

- (Object) makeControlPoints

Default: make 6 control points



134
135
# File 'lib/fox16/canvas.rb', line 134

def makeControlPoints
end

- (Object) move(x, y)

Move shape to specified position



49
50
51
# File 'lib/fox16/canvas.rb', line 49

def move(x, y)
	@x, @y = x, y
end

- (Object) position(x, y, w, h)

Move and resize the shape



58
59
60
61
# File 'lib/fox16/canvas.rb', line 58

def position(x, y, w, h)
	move(x, y)
	resize(w, h)
end

- (Object) resize(w, h)

Resize shape to specified width and height



54
55
# File 'lib/fox16/canvas.rb', line 54

def resize(w, h)
end

- (Object) select

Select this shape



94
95
96
# File 'lib/fox16/canvas.rb', line 94

def select
	@selected = true
end

- (Boolean) selected?

Is this shape selected?



104
105
106
# File 'lib/fox16/canvas.rb', line 104

def selected?
	@selected
end

- (Object) show

Show this shape



79
80
81
# File 'lib/fox16/canvas.rb', line 79

def show
	@visible = true
end

- (Boolean) visible?

Is this shape visible?



89
90
91
# File 'lib/fox16/canvas.rb', line 89

def visible?
	@visible
end