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

#initialize(x, y) ⇒ Shape

Returns a new instance of Shape.



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

#foregroundObject

Returns the value of attribute foreground.



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

def foreground
  @foreground
end

#selectorObject

Returns the value of attribute selector.



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

def selector
  @selector
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

#xObject

Returns the value of attribute x.



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

def x
  @x
end

#yObject

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

#apply_dc(dc) ⇒ Object (protected)



137
138
139
140
141
142
# File 'lib/fox16/canvas.rb', line 137

protected def apply_dc(dc)
  oldForeground = dc.foreground
  dc.foreground = foreground
  yield
  dc.foreground = oldForeground
end

#boundsObject

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

#deselectObject

Deselect this shape



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

def deselect
  @selected = false
end

#disableObject

Disable this shape



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

def disable
  @enabled = false
end

#draggable=(d) ⇒ Object

Set this shape’s draggability



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

def draggable=(d)
  @draggable = d
end

#draggable?Boolean

Is this shape draggable?

Returns:

  • (Boolean)


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

def draggable?
  @draggable
end

#draw(dc) ⇒ Object

Draw this shape into the specificed device context



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

def draw(dc)
end

#drawOutline(dc, x, y, w, h) ⇒ Object

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

#enableObject

Enable this shape



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

def enable
  @enabled = true
end

#enabled?Boolean

Is this shape enabled?

Returns:

  • (Boolean)


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

def enabled?
  @enabled
end

#hideObject

Hide this shape



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

def hide
  @visible = false
end

#hit?(xpos, ypos) ⇒ Boolean

Hit test

Returns:

  • (Boolean)


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

#makeControlPointsObject

Default: make 6 control points



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

def makeControlPoints
end

#move(x, y) ⇒ Object

Move shape to specified position



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

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

#position(x, y, w, h) ⇒ Object

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

#resize(w, h) ⇒ Object

Resize shape to specified width and height



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

def resize(w, h)
end

#selectObject

Select this shape



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

def select
  @selected = true
end

#selected?Boolean

Is this shape selected?

Returns:

  • (Boolean)


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

def selected?
  @selected
end

#showObject

Show this shape



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

def show
  @visible = true
end

#visible?Boolean

Is this shape visible?

Returns:

  • (Boolean)


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

def visible?
  @visible
end