Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gdk::DragContext Class Reference

A GdkDragContext C++ wrapper class. More...

`#include <xfc/gdk/dnd.hh>`

Inheritance diagram for Xfc::Gdk::DragContext:

List of all members.

## Public Member Functions

Constructors

- virtual ~DragContext ()
    Destructor.

Accessors

- GdkDragContext * gdk_drag_context () const
    Get a pointer to the GdkDragContext structure.
- operator GdkDragContext * () const
    Conversion operator; safely converts a DragContext to a GdkDragContext pointer.
- DragProtocol protocol () const
    Returns the DND protocol which governs this drag.
- bool is_source () const
    Returns true if the context is used on the source side.
- Window * source_window () const
    Returns the source window of this drag.
- Window * dest_window () const
    Returns the destination window of this drag.
- bool targets (std::vector< Atom > &target_list) const
    Gets a list of targets offered by the source.
- DragActionField actions () const
    Returns a bitmask of actions proposed by the source when suggested_action is ACTION_ASK.
- DragActionField suggested_action () const
    Returns the action suggested by the source.
- DragActionField action () const
    Returns the action chosen by the destination.
- unsigned int start_time () const
    Returns a timestamp recording the start time of this drag.
- Atom get_selection () const
    Gets the selection atom for the current source window.
- bool drag_drop_succeeded () const
    Determines wether the dropped data has been successfully transferred.

Methods

- void drag_status (DragActionField action, unsigned int time)
    Selects one of the actions offered by the drag source.
- void drop_reply (bool ok, unsigned int time)
    Accepts or rejects a drop.
- void drop_finish (bool success, unsigned int time)
    Ends the drag operation after a drop.
- void find_window (int x_root, int y_root, Window **dest_window, DragProtocol *protocol, const Screen *screen=0)
    Finds the destination window and DND protocol to use at the given pointer position.
- bool drag_motion (const Window &dest_window, DragProtocol protocol, int x_root, int y_root, DragActionField suggested_action, DragActionField possible_actions, unsigned int time)
    Updates the drag context when the pointer moves or the set of actions changes.
- void drag_drop (unsigned int time)
    Drops on the current destination.
- void drag_abort (unsigned int time)
    Aborts a drag without dropping.
- void set_action (DragActionField action)
    Set the drag action value that specifies what destination should do with the dropped data.

## Static Public Member Functions

Accessors

- unsigned int drag_get_protocol (unsigned int xid, DragProtocol *protocol, const Display *display=0)
    Finds out the DND protocol supported by a window.

Methods

- Pointer< DragContext > drag_begin (const Window &window, const std::vector< Atom > &targets)
    Starts a drag and creates a new drag context for it.

## Protected Member Functions

Constructors

- DragContext ()
    Constructs a new drag context.
- DragContext (GdkDragContext *drag_context, bool owns_reference=true)
    Construct a new DragContext from an existing GdkDragContext.

## Detailed Description

A GdkDragContext C++ wrapper class.

DragContext provides a low level interface for drag and drop. The X backend of GDK supports both the Xdnd and Motif drag and drop protocols transparently, the Win32 backend supports the WM_DROPFILES protocol.

GTK+ provides a higher level abstraction based on top of this inteface, so it's not normally needed in GTK+ applications.

## Constructor & Destructor Documentation

Xfc::Gdk::DragContext::DragContext | ( | GdkDragContext * | drag_context,
|  | bool | owns_reference = `true`
| ) | `[explicit, protected]`

Construct a new DragContext from an existing GdkDragContext.

Parameters:

  | drag_context | A pointer to a GdkDragContext.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.

The drag_context can be a newly created GdkDragContext or an existing GdkDragContext. (see G::Object::Object).

Reimplemented in Xfc::Gtk::DragContext.

## Member Function Documentation

void Xfc::Gdk::DragContext::drag_abort | ( | unsigned int | time | ) |

Aborts a drag without dropping.

Parameters:

  | time | The timestamp for this operation.

This method is called by the drag source.

Pointer<DragContext> Xfc::Gdk::DragContext::drag_begin | ( | const Window & | window,
|  | const std::vector< Atom > & | targets
| ) | `[static]`

Starts a drag and creates a new drag context for it.

Parameters:

  | window | The source window for this drag.
  | targets | A reference to a vector of Atom holding the list of offered targets.

Returns:
  A smart pointer to a newly created DragContext.

This method is called by the drag source.

void Xfc::Gdk::DragContext::drag_drop | ( | unsigned int | time | ) |

Drops on the current destination.

Parameters:

  | time | The timestamp for this operation.

This method is called by the drag source.

bool Xfc::Gdk::DragContext::drag_drop_succeeded | ( |  | ) | const

Determines wether the dropped data has been successfully transferred.

Returns:
  true if the drop was successful.

This method is intended to be used while handling a Gdk::DROP_FINISHED event, its return value is meaningless at other times.

unsigned int Xfc::Gdk::DragContext::drag_get_protocol | ( | unsigned int | xid,
|  | DragProtocol * | protocol,
|  | const Display * | display = `0`
| ) | `[static]`

Finds out the DND protocol supported by a window.

Parameters:

  | xid | The X id of the destination window.
  | protocol | The location where the supported DND protocol is returned.
  | display | The Display where the destination window resides, or null for the defualt display.

Returns:
  The X id of the window where the drop should happen.

The X id may be xid or the X id of a proxy window, or none if xid doesn't support Drag and Drop.

bool Xfc::Gdk::DragContext::drag_motion | ( | const Window & | dest_window,
|  | DragProtocol | protocol,
|  | int | x_root,
|  | int | y_root,
|  | DragActionField | suggested_action,
|  | DragActionField | possible_actions,
|  | unsigned int | time
| ) |

Updates the drag context when the pointer moves or the set of actions changes.

Parameters:

  | dest_window | The new destination window, obtained by find_window().
  | protocol | The DND protocol in use, obtained by find_window().
  | x_root | The X position of the pointer in root coordinates.
  | y_root | The y position of the pointer in root coordinates.
  | suggested_action | The suggested action.
  | possible_actions | The possible actions.
  | time | The timestamp for this operation.

Returns:

This method is called by the drag source.

void Xfc::Gdk::DragContext::drag_status | ( | DragActionField | action,
|  | unsigned int | time
| ) |

Selects one of the actions offered by the drag source.

Parameters:

  | action | The selected action which will be taken when a drop happens, or 0 to indicate that a drop will not be accepted.
  | time | The timestamp for this operation.

This method is called by the drag destination in response to drag_motion() called by the drag source.

void Xfc::Gdk::DragContext::drop_finish | ( | bool | success,
|  | unsigned int | time
| ) |

Ends the drag operation after a drop.

Parameters:

  | success | set true if the data was successfully received.
  | time | The timestamp for this operation.

This method is called by the drag destination.

void Xfc::Gdk::DragContext::drop_reply | ( | bool | ok,
|  | unsigned int | time
| ) |

Accepts or rejects a drop.

Parameters:

  | ok | Set true if the drop is accepted.
  | time | The timestamp for this operation.

This method is called by the drag destination in response to a drop initiated by the drag source.

void Xfc::Gdk::DragContext::find_window | ( | int | x_root,
|  | int | y_root,
|  | Window ** | dest_window,
|  | DragProtocol * | protocol,
|  | const Screen * | screen = `0`
| ) |

Finds the destination window and DND protocol to use at the given pointer position.

Parameters:

  | x_root | The X position of the pointer in root coordinates.
  | y_root | The Y position of the pointer in root coordinates.
  | dest_window | The location to store the destination window in.
  | protocol | The location to store the DND protocol in.
  | screen | The screen where the destination window is sought, or null for the screen the source window is on.

This method is called by the drag source to obtain the dest_window and protocol parameters for motion().

Atom Xfc::Gdk::DragContext::get_selection | ( |  | ) | const

Gets the selection atom for the current source window.

Returns:
  The selection atom.

void Xfc::Gdk::DragContext::set_action | ( | DragActionField | action | ) |

Set the drag action value that specifies what destination should do with the dropped data.

Parameters:

  | action | The new Gdk::DragAction value to set.

You would typically call this method from within a Gtk::Widget drag_data_received signal handler. By calling action(), you can inspect the drag action chosen by the drop site and modify its value.

bool Xfc::Gdk::DragContext::targets | ( | std::vector< Atom > & | target_list | ) | const

Gets a list of targets offered by the source.

Parameters:

  | target_list | A reference to a vector of Atom to hold the list of targets.

Returns:
  true if the vector is not empty.

The documentation for this class was generated from the following file:

- gdk/dnd.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3