Sha256: b9d80400a011b093cf7a0c0e4f5a89f62818de02979617bf958f55c44589be72

Contents?: true

Size: 1.54 KB

Versions: 34

Compression:

Stored size: 1.54 KB

Contents

require 'fox16'

include Fox

class DropSite < FXMainWindow
  
  def initialize(anApp)
    # Initialize base class
    super(anApp, "Drop Site", :opts => DECOR_ALL, :width => 400, :height => 300)
    
    # Fill main window with canvas
    @canvas = FXCanvas.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
    
    # Handle expose events on the canvas
    @canvas.connect(SEL_PAINT) do |sender, sel, event|
      FXDCWindow.new(@canvas, event) do |dc|
        dc.foreground = @canvas.backColor
        dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w, event.rect.h)
      end
    end

    # Enable canvas for drag-and-drop messages
    @canvas.dropEnable
    
    # Handle SEL_DND_MOTION messages from the canvas
    @canvas.connect(SEL_DND_MOTION) do
      @canvas.acceptDrop if @canvas.offeredDNDType?(FROM_DRAGNDROP, FXWindow.colorType)
    end

    # Handle SEL_DND_DROP message from the canvas
    @canvas.connect(SEL_DND_DROP) do
      # Try to obtain the data as color values first
      data = @canvas.getDNDData(FROM_DRAGNDROP, FXWindow.colorType)

      # Update canvas background color
      @canvas.backColor = Fox.fxdecodeColorData(data) unless data.nil?
    end
  end

  def create
    # Create the main window and canvas
    super
    
    # Register the drag type for colors
    FXWindow.colorType = getApp().registerDragType(FXWindow.colorTypeName)

    # Show the main window
    show(PLACEMENT_SCREEN)
  end
end

if __FILE__ == $0
  FXApp.new("DropSite", "FXRuby") do |theApp|
    DropSite.new(theApp)
    theApp.create
    theApp.run
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
fxruby-1.6.22.pre2-x86-mingw32 examples/dropsite.rb
fxruby-1.6.22.pre2 examples/dropsite.rb
fxrubi-1.6.22.pre1-x86-mingw32 examples/dropsite.rb
fxrubi-1.6.22.pre1 examples/dropsite.rb
fxruby-1.6.20-x86-mingw32 examples/dropsite.rb
fxruby-1.6.20-x86-linux examples/dropsite.rb
fxruby-1.6.20 examples/dropsite.rb
fxruby-1.6.20-universal-darwin-10 examples/dropsite.rb
fxruby-1.6.19-x86-mingw32 examples/dropsite.rb
fxruby-1.6.14-mswin32 examples/dropsite.rb
fxruby-1.6.13-mswin32 examples/dropsite.rb
fxruby-1.6.11 examples/dropsite.rb
fxruby-1.6.10 examples/dropsite.rb
fxruby-1.6.12 examples/dropsite.rb
fxruby-1.6.13 examples/dropsite.rb
fxruby-1.6.14-universal-darwin-9 examples/dropsite.rb
fxruby-1.6.14 examples/dropsite.rb
fxruby-1.6.15-universal-darwin-9 examples/dropsite.rb
fxruby-1.6.15 examples/dropsite.rb
fxruby-1.6.15-x86-mswin32-60 examples/dropsite.rb