Module: VRDragDropSource

Includes:
VRMessageHandler
Included in:
VRDragFileSource
Defined in:
lib/vr/vrddrop.rb

Constant Summary collapse

DragDetect =
Win32API.new("user32","DragDetect","IP","I")
GetCursorPos =
Win32API.new("user32","GetCursorPos","P","I")
WindowFromPoint =
Win32API.new("user32","WindowFromPoint","II","I")
GetParent =
Win32API.new("user32","GetParent","I","I")

Constants included from VRMessageHandler

VRMessageHandler::PREHANDLERSTR

Instance Method Summary collapse

Methods included from VRMessageHandler

#acceptEvents, #addHandler, #addNoRelayMessages, #controlmsg_dispatching, #deleteHandler, #msghandlerinit, #selfmsg_dispatching

Instance Method Details

#createDropItemObject



121
122
123
124
# File 'lib/vr/vrddrop.rb', line 121

def createDropItem()
  # msg,wParam,lParam
  return nil,nil,nil
end

#dragDetectObject



108
109
110
# File 'lib/vr/vrddrop.rb', line 108

def dragDetect
  DragDetect.call(self.hWnd,@_vr_pointbuffer)!=0
end

#dragdropsourceinitObject



89
90
91
92
93
94
95
96
97
98
# File 'lib/vr/vrddrop.rb', line 89

def dragdropsourceinit
  @_vr_dragging=false
  @_vr_droptotoplevel=true;
  @_vr_pointbuffer=[0,0].pack("II")
  unless @_vr_dragging_cursor then
    @_vr_dragging_cursor=@screen.application::SysCursors.Cross 
  end
  addHandler(WMsg::WM_LBUTTONUP,"_vrdsrclbuttonup",MSGTYPE::ARGINTINT,nil)
  acceptEvents [WMsg::WM_LBUTTONUP]
end

#dragStartObject



112
113
114
115
116
117
118
119
# File 'lib/vr/vrddrop.rb', line 112

def dragStart()
  GetCursorPos.call(@_vr_pointbuffer)
  if DragDetect.call(self.hWnd,@_vr_pointbuffer)!=0 then
    @_vr_dragging=true
    @screen.application.setCursor @_vr_dragging_cursor
    setCapture
  end
end

#dropToplevelObject



105
# File 'lib/vr/vrddrop.rb', line 105

def dropToplevel() @_vr_droptotoplevel; end

#dropToplevel=(f) ⇒ Object



106
# File 'lib/vr/vrddrop.rb', line 106

def dropToplevel=(f) @_vr_droptotoplevel=f;end

#self__vrdsrclbuttonup(shift, xy) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/vr/vrddrop.rb', line 126

def self__vrdsrclbuttonup(shift,xy)
  if @_vr_dragging then
    @screen.application.setCursor @screen.application::SysCursors.Arrow
    GetCursorPos.call(@_vr_pointbuffer)
    handle=WindowFromPoint.call(*@_vr_pointbuffer.unpack("II"))
    releaseCapture

    if @_vr_droptotoplevel then
      while handle!=0 do   # search the top level window
        droptarget=handle; handle=GetParent.call(handle)
      end
    else
      droptarget=handle;
    end

    msg,wParam,lParam = self.createDropItem
    SMSG::postMessage droptarget,msg,wParam,lParam
  end
  @_vr_dragging=false
end

#vrinitObject



100
101
102
103
# File 'lib/vr/vrddrop.rb', line 100

def vrinit
  super
  dragdropsourceinit
end