Thread: [Fxruby-commits] CVS: FXRuby/lib/fox aliases.rb,1.24.2.8,1.24.2.9 canvas.rb,1.1.2.1,1.1.2.2 overload
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <ly...@us...> - 2002-07-08 13:27:54
|
Update of /cvsroot/fxruby/FXRuby/lib/fox
In directory usw-pr-cvs1:/tmp/cvs-serv15718/lib/fox
Modified Files:
Tag: release10
aliases.rb canvas.rb overloads.rb
Log Message:
Removed a lot of scaffolding that we were using to make overloaded
methods work properly. This is now supported directly by SWIG 1.3.14
and so we don't have to do it anymore.
Index: aliases.rb
===================================================================
RCS file: /cvsroot/fxruby/FXRuby/lib/fox/aliases.rb,v
retrieving revision 1.24.2.8
retrieving revision 1.24.2.9
diff -C2 -d -r1.24.2.8 -r1.24.2.9
*** aliases.rb 5 Jun 2002 16:55:33 -0000 1.24.2.8
--- aliases.rb 8 Jul 2002 13:27:51 -0000 1.24.2.9
***************
*** 940,943 ****
--- 940,946 ----
alias selector getSelector
end
+ class FXRegion
+ alias contains? contains
+ end
class FXRegistry
alias appKey getAppKey
Index: canvas.rb
===================================================================
RCS file: /cvsroot/fxruby/FXRuby/lib/fox/Attic/canvas.rb,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** canvas.rb 24 May 2002 23:01:12 -0000 1.1.2.1
--- canvas.rb 8 Jul 2002 13:27:51 -0000 1.1.2.2
***************
*** 20,23 ****
--- 20,26 ----
module Canvas
+ class CanvasError < Exception
+ end
+
class Shape
***************
*** 25,28 ****
--- 28,32 ----
def initialize(x, y)
+ @enabled = true
@visible = true
@selected = false
***************
*** 60,66 ****
end
! # Set the visibility of this shape
! def visible=(visible)
! @visible = visible
end
--- 64,90 ----
end
! # Enable this shape
! def enable
! @enabled = true
! end
!
! # Disable this shape
! def disable
! @enabled = false
! end
!
! # Is this shape enabled?
! def enabled?
! @enabled
! end
!
! # Show this shape
! def show
! @visible = true
! end
!
! # Hide this shape
! def hide
! @visible = false
end
***************
*** 98,101 ****
--- 122,140 ----
def draw(dc)
end
+
+ # Draws outline
+ 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
+
+ # Default: make 6 control points
+ def makeControlPoints
+ end
end
***************
*** 104,111 ****
--- 143,156 ----
include Enumerable
+ # Initialize this shape group
def initialize
@shapes = []
end
+ # Does the group contain this shape?
+ def include?(shape)
+ @shapes.include?(shape)
+ end
+
# Add a shape to this group
def addShape(shape)
***************
*** 260,265 ****
--- 305,377 ----
end
+ # Base class for canvas selection policies
+ class SelectionPolicy
+ def initialize(canvas)
+ @canvas = canvas
+ end
+
+ def selectShape(shape, notify)
+ unless shape.selected?
+ shape.select
+ @canvas.updateShape(shape)
+ if notify && (@canvas.target != nil)
+ @canvas.target.handle(@canvas, MKUINT(@canvas.message, SEL_SELECTED), shape)
+ end
+ end
+ end
+
+ def deselectShape(shape, notify)
+ if shape.selected?
+ shape.deselect
+ @canvas.updateShape(shape)
+ if notify && (@canvas.target != nil)
+ @canvas.target.handle(@canvas, MKUINT(@canvas.message, SEL_DESELECTED), shape)
+ end
+ end
+ end
+ end
+
+ # Single shape selected at one time
+ class SingleSelectionPolicy < SelectionPolicy
+ def initialize(canvas)
+ super
+ end
+
+ def selectShape(shape, notify)
+ unless shape.selected?
+ @canvas.killSelection(notify)
+ end
+ super
+ end
+ end
+
class ShapeCanvas < FXCanvas
+ # Window state flags
+ FLAG_SHOWN = 0x00000001 # Is shown
+ FLAG_ENABLED = 0x00000002 # Able to receive input
+ FLAG_UPDATE = 0x00000004 # Is subject to GUI update
+ FLAG_DROPTARGET = 0x00000008 # Drop target
+ FLAG_FOCUSED = 0x00000010 # Has focus
+ FLAG_DIRTY = 0x00000020 # Needs layout
+ FLAG_RECALC = 0x00000040 # Needs recalculation
+ FLAG_TIP = 0x00000080 # Show tip
+ FLAG_HELP = 0x00000100 # Show help
+ FLAG_DEFAULT = 0x00000200 # Default widget
+ FLAG_INITIAL = 0x00000400 # Initial widget
+ FLAG_SHELL = 0x00000800 # Shell window
+ FLAG_ACTIVE = 0x00001000 # Window is active
+ FLAG_PRESSED = 0x00002000 # Button has been pressed
+ FLAG_KEY = 0x00004000 # Keyboard key pressed
+ FLAG_CARET = 0x00008000 # Caret is on
+ FLAG_CHANGED = 0x00010000 # Window data changed
+ FLAG_LASSO = 0x00020000 # Lasso mode
+ FLAG_TRYDRAG = 0x00040000 # Tentative drag mode
+ FLAG_DODRAG = 0x00080000 # Doing drag mode
+ FLAG_SCROLLINSIDE = 0x00100000 # Scroll only when inside
+ FLAG_SCROLLING = 0x00200000 # Right mouse scrolling
+
+ include Responder
+
attr_accessor :scene
***************
*** 271,278 ****
@scene = ShapeGroup.new
! # Handle paint message
! self.connect(SEL_PAINT, method(:onPaint))
! self.connect(SEL_LEFTBUTTONPRESS, method(:onLeftBtnPress))
! self.connect(SEL_LEFTBUTTONRELEASE, method(:onLeftBtnRelease))
end
--- 383,400 ----
@scene = ShapeGroup.new
! # Selection policy
! @selectionPolicy = SingleSelectionPolicy.new(self)
!
! @flags = 0
!
! # Map
! FXMAPFUNC(SEL_PAINT, 0, "onPaint")
! FXMAPFUNC(SEL_MOTION, 0, "onMotion")
! FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, "onLeftBtnPress")
! FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, "onLeftBtnRelease")
! FXMAPFUNC(SEL_CLICKED,0,"onClicked")
! FXMAPFUNC(SEL_DOUBLECLICKED,0,"onDoubleClicked")
! FXMAPFUNC(SEL_TRIPLECLICKED,0,"onTripleClicked")
! FXMAPFUNC(SEL_COMMAND,0,"onCommand")
end
***************
*** 282,291 ****
return shape if shape.hit?(x, y)
end
end
!
# Paint
def onPaint(sender, sel, evt)
! dc = FXDCWindow.new(sender, evt)
! dc.foreground = sender.backColor
dc.fillRectangle(evt.rect.x, evt.rect.y, evt.rect.w, evt.rect.h)
@scene.each do |shape|
--- 404,481 ----
return shape if shape.hit?(x, y)
end
+ nil
end
!
! # Repaint
! def updateShape(shape)
! if @scene.include?(shape)
! update
! else
! raise CanvasError
! end
! end
!
! # Enable one shape
! def enableShape(shape)
! if @scene.include?(shape)
! unless shape.enabled?
! shape.enable
! updateShape(shape)
! end
! else
! raise CanvasError
! end
! end
!
! # Disable one shape
! def disableShape(shape)
! if @scene.include?(shape)
! if shape.enabled?
! shape.disable
! updateShape(shape)
! end
! else
! raise CanvasError
! end
! end
!
! # Select one shape
! def selectShape(shape, notify=false)
! if @scene.include?(shape)
! @selectionPolicy.selectShape(shape, notify)
! else
! raise CanvasError
! end
! end
!
! # Deselect one shape
! def deselectShape(shape, notify=false)
! if @scene.include?(shape)
! @selectionPolicy.deselectShape(shape, notify)
! else
! raise CanvasError
! end
! end
!
! # Kill selection
! def killSelection(notify)
! changes = false
! @scene.each do |shape|
! if shape.selected?
! shape.deselect
! updateShape(shape)
! changes = true
! if notify && (target != nil)
! target.handle(self, MKUINT(message, SEL_DESELECTED), shape)
! end
! end
! end
! changes
! end
!
# Paint
def onPaint(sender, sel, evt)
! dc = FXDCWindow.new(self, evt)
! dc.foreground = backColor
dc.fillRectangle(evt.rect.x, evt.rect.y, evt.rect.w, evt.rect.h)
@scene.each do |shape|
***************
*** 296,315 ****
end
# Left button press
def onLeftBtnPress(sender, sel, evt)
! return 1
end
# Left button release
def onLeftBtnRelease(sender, sel, evt)
! # First deselect every object in the scene
! @scene.each { |shape| shape.deselect }
!
! # Now select the object at the lowest depth
! shape = findShape(evt.win_x, evt.win_y)
! shape.select unless shape.nil?
!
! # Repaint
! update
end
end
--- 486,607 ----
end
+ # Motion
+ def onMotion(sender, sel, evt)
+ # Drag and drop mode
+ if (@flags & FLAG_DODRAG) != 0
+ handle(self, MKUINT(0, SEL_DRAGGED), evt)
+ return 1
+ end
+
+ # Tentative drag and drop
+ if (@flags & FLAG_TRYDRAG) != 0
+ if evt.moved?
+ @flags &= ~FLAG_TRYDRAG
+ if handle(this, MKUINT(0, SEL_BEGINDRAG), evt) != 0
+ @flags |= FLAG_DODRAG
+ end
+ end
+ return 1
+ end
+ end
+
# Left button press
def onLeftBtnPress(sender, sel, evt)
! handle(self, MKUINT(0, SEL_FOCUS_SELF), evt)
! if enabled?
! grab
! flags &= ~FLAG_UPDATE
!
! # Give target the first chance at handling this
! return 1 if target && (target.handle(self, MKUINT(message, SEL_LEFTBUTTONPRESS), evt) != 0)
!
! # Locate shape
! shape = findShape(evt.win_x, evt.win_y)
!
! # No shape here
! if shape.nil?
! return 1
! end
!
! # Change current shape
! @currentShape = shape
!
! # Change item selection
! if shape.enabled? && !shape.selected?
! selectShape(shape, true)
! end
!
! # Are we dragging?
! if shape.selected? && shape.draggable?
! flags |= FLAG_TRYDRAG
! end
!
! flags |= FLAG_PRESSED
! return 1
! end
! return 0
end
# Left button release
def onLeftBtnRelease(sender, sel, evt)
! flg = @flags
! if enabled?
! ungrab
! @flags |= FLAG_UPDATE
! @flags &= ~(FLAG_PRESSED|FLAG_TRYDRAG|FLAG_LASSO|FLAG_DODRAG)
!
! # First chance callback
! return 1 if target && target.handle(self, MKUINT(message, SEL_LEFTBUTTONRELEASE), evt) != 0
!
! # Was dragging
! if (flg & FLAG_DODRAG) != 0
! handle(self, MKUINT(0, SEL_ENDDRAG), evt)
! return 1
! end
!
! # Must have pressed
! if (flg & FLAG_PRESSED) != 0
! # Change selection
! if @currentShape && @currentShape.enabled?
! deselectShape(@currentShape, true)
! end
!
! # Generate clicked callbacks
! if evt.click_count == 1
! handle(self, MKUINT(0, SEL_CLICKED), @currentShape)
! elsif evt.click_count == 2
! handle(self, MKUINT(0, SEL_DOUBLECLICKED), @currentShape)
! elseif evt.click_count == 3
! handle(self, MKUINT(0, SEL_TRIPLECLICKED), @currentShape)
! end
!
! # Generate command callback only when clicked on item
! if @currentShape && @currentShape.enabled?
! handle(self, MKUINT(0, SEL_COMMAND), @currentShape)
! end
! return 1
! end
! return 0
! end
! end
!
! # Command message
! def onCommand(sender, sel, ptr)
! return target && target.handle(self, MKUINT(message, SEL_COMMAND), ptr)
! end
!
! # Clicked on canvas
! def onClicked(sender, sel, ptr)
! return target && target.handle(self, MKUINT(message, SEL_CLICKED), ptr)
! end
!
! # Double-clicked on canvas
! def onDoubleClicked(sender, sel, ptr)
! return target && target.handle(self, MKUINT(message, SEL_DOUBLECLICKED), ptr)
! end
!
! # Triple-clicked on canvas
! def onTripleClicked(sender, sel, ptr)
! return target && target.handle(self, MKUINT(message, SEL_TRIPLECLICKED), ptr)
end
end
Index: overloads.rb
===================================================================
RCS file: /cvsroot/fxruby/FXRuby/lib/fox/overloads.rb,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -C2 -d -r1.7.2.2 -r1.7.2.3
*** overloads.rb 24 May 2002 22:17:50 -0000 1.7.2.2
--- overloads.rb 8 Jul 2002 13:27:51 -0000 1.7.2.3
***************
*** 1,304 ****
! require 'fox'
!
! module Fox
! class FX_App
! def stopModal(*args)
! if args.length > 0
! if args[0].kind_of? Fixnum
! value = args[0]
! stopModalInnermost(value)
! else
! window = args[0]
! if args.length > 1
! value = args[1]
! stopModalMatching(window, value)
! else
! stopModalMatching(window)
! end
! end
! else
! stopModalInnermost
! end
! end
! end
!
! class FX_DC
! def setStipple(*args)
! if args[0].kind_of? FXBitmap
! setStippleFromBitmap(*args)
! else
! setStippleFromPattern(*args)
! end
! end
! def setClipRectangle(*args)
! if args.length == 1
! setClipRectangle1(args[0])
! else
! setClipRectangle4(args[0], args[1], args[2], args[3])
! end
! end
! end
!
! class FXFileStream
! def FXFileStream.open(filename, save_or_load, container=nil)
! fstream = FXFileStream.new(container)
! status = fstream.open(filename, save_or_load)
! if block_given?
! begin
! yield fstream
! ensure
! fstream.close
! end
! else
! fstream
! end
! end
! end
!
! class FXHMat
! def rot(*args)
! if (args.length == 1)
! rot1(args[0])
! elsif (args.length == 2)
! rot2(args[0], args[1])
! else
! rot3(args[0], args[1], args[2])
! end
! end
! def xrot(*args)
! if (args.length == 1)
! xrot1(args[0])
! else
! xrot2(args[0], args[1])
! end
! end
! def yrot(*args)
! if (args.length == 1)
! yrot1(args[0])
! else
! yrot2(args[0], args[1])
! end
! end
! def zrot(*args)
! if (args.length == 1)
! zrot1(args[0])
! else
! zrot2(args[0], args[1])
! end
! end
! def trans(*args)
! if args.length == 1
! trans1(args[0])
! else
! trans3(args[0], args[1], args[2])
! end
! end
! def scale(*args)
! if args.length == 1
! if args[0].kind_of? Float
! scalef(args[0])
! else
! scalev(args[0])
! end
! else
! scale3(args[0], args[1], args[2])
! end
! end
! end
!
! class FX_Header
! def appendItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! appendItem2(*args)
! else
! appendItem1(*args)
! end
! end
! def insertItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! insertItem2(*args)
! else
! insertItem1(*args)
! end
! end
! def prependItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! prependItem2(*args)
! else
! prependItem1(*args)
! end
! end
! def replaceItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! replaceItem2(*args)
! else
! replaceItem1(*args)
! end
! end
! end
!
! class FX_IconList
! def appendItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! appendItem2(*args)
! else
! appendItem1(*args)
! end
! end
! def insertItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! insertItem2(*args)
! else
! insertItem1(*args)
! end
! end
! def prependItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! prependItem2(*args)
! else
! prependItem1(*args)
! end
! end
! def replaceItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! replaceItem2(*args)
! else
! replaceItem1(*args)
! end
! end
! end
!
! class FX_List
! def appendItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! appendItem2(*args)
! else
! appendItem1(*args)
! end
! end
! def insertItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! insertItem2(*args)
! else
! insertItem1(*args)
! end
! end
! def prependItem(*args)
! if (args.length > 0) && (args[0].kind_of? String)
! prependItem2(*args)
! else
! prependItem1(*args)
! end
! end
! def replaceItem(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! replaceItem2(*args)
! else
! replaceItem1(*args)
! end
! end
! end
!
! class FXRange
! def include(*args)
! if args.length == 3
! includePoint(*args)
! else
! if args[0].kind_of? Fox::FXRange
! includeRange(*args)
! else
! includeVec(*args)
! end
! end
! end
! end
!
! class FXRegion
! def contains?(*args)
! if args.length == 4
! containsRectangle?(args[0], args[1], args[2], args[3])
! else
! containsPoint?(args[0], args[1])
! end
! end
! end
!
! class FX_TreeList
! def addItemAfter(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemAfter2(*args)
! else
! addItemAfter1(*args)
! end
! end
! def addItemBefore(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemBefore2(*args)
! else
! addItemBefore1(*args)
! end
! end
! def addItemFirst(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemFirst2(*args)
! else
! addItemFirst1(*args)
! end
! end
! def addItemLast(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemLast2(*args)
! else
! addItemLast1(*args)
! end
! end
! end
!
! class FX_TreeListBox
! def addItemAfter(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemAfter2(*args)
! else
! addItemAfter1(*args)
! end
! end
! def addItemBefore(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemBefore2(*args)
! else
! addItemBefore1(*args)
! end
! end
! def addItemFirst(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemFirst2(*args)
! else
! addItemFirst1(*args)
! end
! end
! def addItemLast(*args)
! if (args.length > 1) && (args[1].kind_of? String)
! addItemLast2(*args)
! else
! addItemLast1(*args)
! end
! end
! end
!
! class FX_Window
! def repaint(*args)
! if args.length == 4
! repaintArea(args[0], args[1], args[2], args[3])
! else
! repaintWindow
! end
! end
! def update(*args)
! if args.length == 4
! updateArea(args[0], args[1], args[2], args[3])
! else
! updateWindow
! end
! end
! end
! end
--- 1,36 ----
! require 'fox'
!
! module Fox
! class FX_DC
! def setStipple(*args)
! if args[0].kind_of? FXBitmap
! setStippleFromBitmap(*args)
! else
! setStippleFromPattern(*args)
! end
! end
! def setClipRectangle(*args)
! if args.length == 1
! setClipRectangle1(args[0])
! else
! setClipRectangle4(args[0], args[1], args[2], args[3])
! end
! end
! end
!
! class FXFileStream
! def FXFileStream.open(filename, save_or_load, container=nil)
! fstream = FXFileStream.new(container)
! status = fstream.open(filename, save_or_load)
! if block_given?
! begin
! yield fstream
! ensure
! fstream.close
! end
! else
! fstream
! end
! end
! end
! end
|