123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- deferred class IUP_DRAG_AND_DROP
- -- Commands related to drag & drop.
- inherit
- IUP_WIDGET_INTERNALS
-
- feature {ANY}
- -- Attributes at Drag Source
- set_drag_cursor (name: STRING)
- -- (non inheritable): name of an image to be used as cursor during drag.
- -- See also IUP_IMAGE.
- do
- iup_open.set_attribute(Current, "DRAGCURSOR", name)
- end
- set_drag_source (state: BOOLEAN)
- -- (non inheritable): Set up a control as a source for drag operations.
- -- Default: False.
- do
- iup_open.set_attribute(Current, "DRAGSOURCE", boolean_to_yesno(state))
- end
- set_drag_types (types: STRING)
- -- (non inheritable): A list of data types that are supported by the
- -- source. Accepts a string with one or more names separated by commas.
- -- Must be set.
- --
- -- Drag and Drop support can be set independently. A control can have
- -- drop without drag support and vice-versa.
- --
- -- Here are some common Drag&Drop types defined by existing applications:
- --
- -- * "TEXT" used for regular text without formatting. Automatically
- -- translated to CF_TEXT in Windows.
- -- * content MIME types, like "text/uri-list", "text/html", "image/png",
- -- "image/jpeg", "image/bmp" and "image/gif".
- -- * "UTF8_STRING" in GTK and "UNICODETEXT" in Windows.
- -- * "COMPOUND_TEXT" in GTK and "Rich Text Format" in Windows.
- -- * "BITMAP" and "DIB" in Windows. Automatically translated to CF_BITMAP
- -- and CF_DIB.
- do
- iup_open.set_attribute(Current, "DRAGTYPES", types)
- end
- set_drag_source_move (state: BOOLEAN)
- -- (non inheritable): Enables the move action. Default: False (only copy
- -- is enabled).
- do
- iup_open.set_attribute(Current, "DRAGSOURCEMOVE",
- boolean_to_yesno(state))
- end
- -- Attributes at Drop Target
- set_drop_target (state: BOOLEAN)
- -- (non inheritable): Set up a control as a destination for drop
- -- operations. Default: False.
- do
- iup_open.set_attribute(Current, "DROPTARGET",
- boolean_to_yesno(state))
- end
- set_drop_types (types: STRING)
- -- (non inheritable): A list of data types that are supported by the
- -- target. Accepts a string with one or more names separated by commas.
- -- Must be set.
- --
- -- Drag and Drop support can be set independently. A control can have
- -- drop without drag support and vice-versa.
- --
- -- Here are some common Drag&Drop types defined by existing applications:
- --
- -- * "TEXT" used for regular text without formatting. Automatically
- -- translated to CF_TEXT in Windows.
- -- * content MIME types, like "text/uri-list", "text/html", "image/png",
- -- "image/jpeg", "image/bmp" and "image/gif".
- -- * "UTF8_STRING" in GTK and "UNICODETEXT" in Windows.
- -- * "COMPOUND_TEXT" in GTK and "Rich Text Format" in Windows.
- -- * "BITMAP" and "DIB" in Windows. Automatically translated to CF_BITMAP
- -- and CF_DIB.
- do
- iup_open.set_attribute(Current, "DROPTYPES", types)
- end
- -- Callbacks at Drag Source (Must be set when DRAGSOURCE=True)
- set_cb_drag_begin (act: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER, INTEGER], STRING])
- -- Notifies source that drag started. It is called when the mouse starts
- -- a drag operation.
- --
- -- ih: identifier of the element that activated the event.
- -- x, y: cursor position relative to the top-left corner of the element.
- --
- -- Returns: If IUP_IGNORE is returned the drag is aborted.
- local
- operation: INTEGER
- do
- cb_dragbegin := act
-
- if cb_dragbegin /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DRAGBEGIN_CB", "NONEEDED", operation)
- end
- set_cb_drag_data_size (act: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING], INTEGER])
- -- Request for size of drag data from source. It is called when the data
- -- is dropped, before the DRAGDATA_CB callback.
- --
- -- ih: identifier of the element that activated the event.
- -- type: type of the data. It is one of the registered types in DRAGTYPES.
- --
- -- Returns: the size in bytes for the data. It will be used to allocate
- -- the buffer size for the data in transfer.
- local
- operation: INTEGER
- do
- cb_dragdatasize := act
-
- if cb_dragdatasize /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DRAGDATASIZE_CB", "NONEEDED", operation)
- end
- set_cb_drag_data (act: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING, POINTER, INTEGER], STRING])
- -- Request for drag data from source. It is called when the data is
- -- dropped.
- --
- -- ih: identifier of the element that activated the event.
- -- type: type of the data. It is one of the registered types in DRAGTYPES.
- -- data: buffer to be filled by the application.
- -- size: buffer size in bytes. The same value returned by
- -- DRAGDATASIZE_CB.
- local
- operation: INTEGER
- do
- cb_dragdata := act
-
- if cb_dragdata /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DRAGDATA_CB", "NONEEDED", operation)
- end
- set_cb_drag_end (act: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER], STRING])
- -- Notifies source that drag is done. The only drag callback that is
- -- optional. It is called after the data has been dropped.
- --
- -- ih: identifier of the element that activated the event.
- -- action: action performed by the operation (1 = move, 0 = copy, -1 =
- -- drag failed or aborted)
- --
- -- If action is 1 it is responsibility of the application to remove the
- -- data from source.
- local
- operation: INTEGER
- do
- cb_dragend := act
-
- if cb_dragend /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DRAGEND_CB", "NONEEDED", operation)
- end
- -- Callbacks at Drop Target (Must be set when DROPTARGET=True)
- set_cb_drop_data (act: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING, POINTER, INTEGER, INTEGER, INTEGER], STRING])
- -- Source has sent target the requested data. It is called when the data
- -- is dropped. If both drag and drop would be in the same application it
- -- would be called after the DRAGDATA_CB callback.
- --
- -- ih: identifier of the element that activated the event.
- -- type: type of the data. It is one of the registered types in DROPTYPES.
- -- data: content data received in the drop operation. In Lua is a light
- -- userdata.
- -- size: data size in bytes.
- -- x, y: cursor position relative to the top-left corner of the element.
- local
- operation: INTEGER
- do
- cb_dropdata := act
-
- if cb_dropdata /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DROPDATA_CB", "NONEEDED", operation)
- end
- set_cb_drop_motion (act: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER, INTEGER, STRING], STRING])
- -- Notifies destination about drag pointer motion. The only drop callback
- -- that is optional. It is called when the mouse moves over any valid
- -- drop site.
- --
- -- ih: identifier of the element that activated the event.
- -- x, y: position in the canvas where the event has occurred, in pixels.
- -- status: status of mouse buttons and certain keyboard keys at the
- -- moment the event was generated. The same macros used for BUTTON_CB can
- -- be used for this status.
- local
- operation: INTEGER
- do
- cb_dropmotion := act
-
- if cb_dropmotion /= Void then
- operation := 1
- else
- operation := 0
- end
-
- iup_open.set_callback (Current, "DROPMOTION_CB", "NONEEDED", operation)
- end
- feature {IUP}
- -- Drag callbacks
- execute_dragbegin (x, y: INTEGER): STRING
- do
- if attached cb_dragbegin as int_cb then
- Result := int_cb.item([Current, x, y])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dragdatasize (type: STRING): INTEGER
- do
- if attached cb_dragdatasize as int_cb then
- Result := int_cb.item([Current, type])
- else
- Result := 0
- end
- end
- execute_dragdata (type: STRING; data: POINTER; size: INTEGER): STRING
- do
- if attached cb_dragdata as int_cb then
- Result := int_cb.item([Current, type, data, size])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dragend (action: INTEGER): STRING
- do
- if attached cb_dragend as int_cb then
- Result := int_cb.item([Current, action])
- else
- Result := "IUP_DEFAULT"
- end
- end
- -- Drop callbacks
- execute_dropdata (type: STRING; data: POINTER; size, x, y: INTEGER): STRING
- do
- if attached cb_dropdata as int_cb then
- Result := int_cb.item([Current, type, data, size, x, y])
- else
- Result := "IUP_DEFAULT"
- end
- end
- execute_dropmotion (x, y: INTEGER; status: STRING): STRING
- do
- if attached cb_dropmotion as int_cb then
- Result := int_cb.item([Current, x, y, status])
- else
- Result := "IUP_DEFAULT"
- end
-
- end
- feature {NONE}
- cb_dragbegin: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER, INTEGER], STRING]
- cb_dragdatasize: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING], INTEGER]
- cb_dragdata: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING, POINTER, INTEGER], STRING]
- cb_dragend: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER], STRING]
- cb_dropdata: detachable FUNCTION[TUPLE[IUP_WIDGET, STRING, POINTER, INTEGER, INTEGER, INTEGER], STRING]
- cb_dropmotion: detachable FUNCTION[TUPLE[IUP_WIDGET, INTEGER, INTEGER, STRING], STRING]
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016, 2019, 2020 by German A. Arias
- -- Permission is hereby granted, free of charge, to any person obtaining a copy
- -- of this software and associated documentation files (the "Software"), to deal
- -- in the Software without restriction, including without limitation the rights
- -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- -- copies of the Software, and to permit persons to whom the Software is
- -- furnished to do so, subject to the following conditions:
- --
- -- The above copyright notice and this permission notice shall be included in
- -- all copies or substantial portions of the Software.
- --
- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- -- SOFTWARE.
|