A drop site widget is a widget that has been registered as a drop site. The user can drop onto a drop site widget by first dragging from a drag source widget, and then moving the mouse over to the drop site widget and releasing the mouse button.The application registers a widget as a drop site by sending it the dropSiteRegister: message of CwWidget with a CwDropSite create argBlock. Sending dropSiteRegister: creates a CwDropSite which represents the drop site during any drag and drop operation. The following drop site resources can be set in the create argBlock:An optional proc that is received whenever the mouse moves over the drop site widget during a drag. The callData reason can be one of the following:The destination application can check the location of the mouse to determine whether a drop in that location is acceptable, and modify the operation and dropSiteStatus fields of the proc's callData accordingly. Modifications to these fields produces a corresponding change in the appearance of the drag cursor. In addition, a drag proc can be used to provide visual feedback to the user about the drop site. For example, to indicate that the cursor is over some semantic area in the widget, an application might draw a border around the area.The following code registers the specified widget as a drop site. This establishes the operations and targets that the drop site supports, as well as hooking a dragProc and a dropProc:The clientData specified when the dragProc was hookedAn instance of CwDragProcCallbackDataThe following code shows a dragProc handler which does drag-under animation based on the coordinates of the mouse in the callData, and chooses the operation based on the mouse coordinates and the valid operations in the callData. Assume the following:
• dropRectanglesFor: answers a collection of rectangles that are acceptable drop areas in the given widget.
• operationForRectangle:widget:callData: answers the operation chosen by the destination application, given a drop rectangle in the widget, and the operation, operations and dropSiteStatus of the callData.
• animateRectangle:widget:operation: does drag-under animation for a drop rectangle in a given widget, based on the selected operation.
• removeAllAnimation: removes all drag-under animation effects from the given widget.The destination application must supply a drop proc when it creates a drop site. In the drop proc, the destination determines if the drop is valid, and starts the drop data transfer. The parameters to the dropProc are as follows:An instance of CwDropProcCallbackDataSome platforms allow the user to press the help key (usually F1) during a drag. In this case, a drop proc is sent with the dropAction field in the callData set to XmDROPHELP.Two different dropProc handlers are shown in the following code. Both examples call startTransfer:targetTypes:clientData:. The code for this method is shown in the following section on the CwDropTransfer object.The first example shows a very simple dropProc handler. This drop site only supports the 'STRING' target type. If the dropProc is called, the drop site knows that the operation is valid and the drag source also supports 'STRING,' therefore it can simply ask for the data in 'STRING' format.The second example dropProc is more complex. This drop site supports more than one target type. In addition, the drop site cares about the semantic location of the mouse, as did the example dragProc in the previous subsection, and it may decide that the operation is invalid. Assume that intersectionOf: answers an OrderedCollection containing the intersection of two collections, and that dropRectanglesFor: and operationForRectangle:widget:callData: are the same methods used in the dragProc example.
|