gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
DragNDrop Class Reference

#include <DragNDrop.H>

Inheritance diagram for DragNDrop:
[legend]
Collaboration diagram for DragNDrop:
[legend]

Public Member Functions

 DragNDrop ()
 
 DragNDrop (GdkDragContext *context)
 
virtual ~DragNDrop ()
 Destructor. More...
 
void setUserData (gpointer w)
 
gpointer getUserData ()
 
void setDestDefaults (GtkDestDefaults destFlagsIn)
 
GtkDestDefaults getDestDefaults ()
 
void setDragAction (GdkDragAction dragActionIn)
 
GdkDragAction getDragAction ()
 
void getModifierType (GdkModifierType modifierTypeIn)
 
GdkModifierType getModifierType ()
 
GtkTargetEntry * getTargetArray ()
 
DragNDropoperator<< (const GtkTargetEntry &gte)
 
DragNDropoperator>> (const GtkTargetEntry &gte)
 
DragNDropoperator<< (Widget &w)
 

Private Member Functions

void addToTargets (GdkAtom targetData)
 
void init ()
 

Static Private Member Functions

static void addToTargetsStatic (gpointer targetData, gpointer data)
 

Private Attributes

gpointer userData
 If we want DND callbacks to operate on different user data, then this will store it here. More...
 
GtkDestDefaults destFlags
 The drop flags, see setDestDefaults. More...
 
GdkDragAction dragAction
 Action to take once the data is dropped. More...
 
GdkModifierType modifierType
 The modifier which initiates the drag and drop process. More...
 

Detailed Description

Class to setup a drag and drop set of targets for either a source or a sink. This class does a few things. Firstly it allows you to specify different target data types. Secondly, it allows you to specify custom user data to be used in the drag and drop calbbacks.

The data targets are in the inherited std::vector of GtkTargetEntry structures.

Setup data targets like so :

DragNDrop dnd; // instantiate a drag and drop class
dnd<<(GtkTargetEntry){(char*)"INTEGER", 0, 0}; // setup a data type for the dnd system - as there is only one, it is the default

Set the user data for drag and drop callbacks like so :

Widget widget;
DragNDrop dnd; // instantiate a drag and drop class
dnd<<widget; // set the user data for drag and drop callbacks

An example of how to use this class is as follows :

Widget fromW, toW; // setup and source (from) and destination (to) widget.
DragNDrop dnd; // instantiate a drag and drop class
fromW>>dnd; // Tell the Widget it will be dragged around
toW<<dnd; // Tell the other widget it will be the dragging destination
Examples:
DragNDropNowindowTest.C, DragNDropSimpleTest.C, and DragNDropTest.C.

Definition at line 66 of file DragNDrop.H.

Constructor & Destructor Documentation

◆ DragNDrop() [1/2]

DragNDrop::DragNDrop ( )
inline

Constructor

Definition at line 111 of file DragNDrop.H.

◆ DragNDrop() [2/2]

DragNDrop::DragNDrop ( GdkDragContext *  context)
inline

Construct a set of targets from a drag context.

Parameters
contextThe GdkDragContext which is passed around during a drag and drop process. See Widget::dragDropStatic for more information.

Definition at line 118 of file DragNDrop.H.

◆ ~DragNDrop()

virtual DragNDrop::~DragNDrop ( )
inlinevirtual

Destructor.

Definition at line 126 of file DragNDrop.H.

Member Function Documentation

◆ addToTargets()

void DragNDrop::addToTargets ( GdkAtom  targetData)
inlineprivate

Add a GtkTargetEntry to the known list of targets.

Definition at line 83 of file DragNDrop.H.

◆ addToTargetsStatic()

static void DragNDrop::addToTargetsStatic ( gpointer  targetData,
gpointer  data 
)
inlinestaticprivate

Method called on a GList object to add a target pointer to the targets.

Parameters
targetDataA pointer to the specific instance of the GtkTargetEntry to add to the known target list.
dataThe pointer to the instance of this class to operate on.

Definition at line 77 of file DragNDrop.H.

◆ getDestDefaults()

GtkDestDefaults DragNDrop::getDestDefaults ( )
inline

Retrieve the current state of the destFlags.

Definition at line 162 of file DragNDrop.H.

Here is the caller graph for this function:

◆ getDragAction()

GdkDragAction DragNDrop::getDragAction ( )
inline

Get the current dragAction.

Returns
The current state of the dragAction variabl which is a possible combination of GdkDragAction flags, see setDragAction

Definition at line 188 of file DragNDrop.H.

Here is the caller graph for this function:

◆ getModifierType() [1/2]

void DragNDrop::getModifierType ( GdkModifierType  modifierTypeIn)
inline

Get the modifier which initiates the drag operation.

Parameters
modifierTypeInThe modifier to use to start the drag and drop oepration. Known modifiers are :

GDK_SHIFT_MASK the Shift key.

GDK_LOCK_MASK a Lock key (depending on the modifier mapping of the X server this may either be CapsLock or ShiftLock).

GDK_CONTROL_MASK the Control key.

GDK_MOD1_MASK the fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key).

GDK_MOD2_MASK the fifth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier).

GDK_MOD3_MASK the sixth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier).

GDK_MOD4_MASK the seventh modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier).

GDK_MOD5_MASK the eighth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier).

GDK_BUTTON1_MASK the first mouse button.

GDK_BUTTON2_MASK the second mouse button.

GDK_BUTTON3_MASK the third mouse button.

GDK_BUTTON4_MASK the fourth mouse button.

GDK_BUTTON5_MASK the fifth mouse button.

GDK_SUPER_MASK the Super modifier.

GDK_HYPER_MASK the Hyper modifier.

GDK_META_MASK the Meta modifier.

GDK_MODIFIER_RESERVED_29_MASK A reserved bit flag; do not use in your own code

GDK_RELEASE_MASK not used in GDK itself. GTK+ uses it to differentiate between (keyval, modifiers) pairs from key press and release events.

GDK_MODIFIER_MASK a mask covering all modifier types.

Definition at line 233 of file DragNDrop.H.

Here is the caller graph for this function:

◆ getModifierType() [2/2]

GdkModifierType DragNDrop::getModifierType ( )
inline

Get the modifier which initiates the drag operation.

Definition at line 239 of file DragNDrop.H.

◆ getTargetArray()

GtkTargetEntry* DragNDrop::getTargetArray ( )
inline

Get the pointer to the array of GtkTargetEntry variables.

Returns
Pointer to the first element in the array, NULL on error.

Definition at line 246 of file DragNDrop.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUserData()

gpointer DragNDrop::getUserData ( )
inline

Find which userData to be used by Widget::operator<< and Widget::operator>> to setup the drag and drop callbacks. NULL implies it will use the widget which executes the Widget::operator<< and Widget::operator>> methods.

Returns
The widget to pass to the drag and drop callbacks.

Definition at line 138 of file DragNDrop.H.

Here is the caller graph for this function:

◆ init()

void DragNDrop::init ( void  )
inlineprivate

Executed in the constructors to set the default member variables. Sets the following :

destFlags=GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT;
dragAction=GDK_ACTION_COPY;
modifierType=GDK_BUTTON1_MASK; // first mouse button
See also
setDestDefaults, setDragAction

Definition at line 101 of file DragNDrop.H.

◆ operator<<() [1/2]

DragNDrop& DragNDrop::operator<< ( const GtkTargetEntry &  gte)
inline

Add a particular type of target to be dragged and dropped.

Parameters
gteThe GtkTargetEntry to add.

Definition at line 257 of file DragNDrop.H.

◆ operator<<() [2/2]

DragNDrop& DragNDrop::operator<< ( Widget w)
inline

Load in a widget and set as the user data.

Definition at line 278 of file DragNDrop.H.

◆ operator>>()

DragNDrop& DragNDrop::operator>> ( const GtkTargetEntry &  gte)
inline

Remove a particular type of target to be dragged and dropped.

Parameters
gteThe GtkTargetEntry to remove.

Definition at line 265 of file DragNDrop.H.

◆ setDestDefaults()

void DragNDrop::setDestDefaults ( GtkDestDefaults  destFlagsIn)
inline

Alter the default set of flags for destination widgets. This only taked effect before the Widget::operator<<(DrageNDrop &) is called.

Parameters
destFlagsInThe new set of flags for the dest in. Possibilities are :

GTK_DEST_DEFAULT_MOTION If set for a widget, GTK+, during a drag over this widget will check if the drag matches this widget’s list of possible targets and actions.

GTK_DEST_DEFAULT_HIGHLIGHT If set for a widget, GTK+ will draw a highlight on this widget as long as a drag is over this widget and the widget drag format and action are acceptable.

GTK_DEST_DEFAULT_DROP If set for a widget, when a drop occurs, GTK+ will will check if the drag matches this widget’s list of possible targets and actions.

GTK_DEST_DEFAULT_ALL If set, specifies that all default actions should be taken.

Definition at line 156 of file DragNDrop.H.

◆ setDragAction()

void DragNDrop::setDragAction ( GdkDragAction  dragActionIn)
inline

Sets the drag action once dropped.

Parameters
dragActionInThe action to take once dropped, possiblities are:

GDK_ACTION_DEFAULT Means nothing, and should not be used.

GDK_ACTION_COPY Copy the data.

GDK_ACTION_MOVE Move the data, i.e. first copy it, then delete it from the source using the DELETE target of the X selection protocol.

GDK_ACTION_LINK Add a link to the data. Note that this is only useful if source and destination agree on what it means.

GDK_ACTION_PRIVATE Special action which tells the source that the destination will do something that the source doesn't understand.

GDK_ACTION_ASK Ask the user what to do with the data.

Definition at line 181 of file DragNDrop.H.

◆ setUserData()

void DragNDrop::setUserData ( gpointer  w)
inline

Use this if you want drag and drop methods to callback using different user data to the Widget instance which has the Widget::operator<< and Widget::operator>> methods.

Parameters
wThe userData to pass to the drag and drop callbacks.

Definition at line 131 of file DragNDrop.H.

Member Data Documentation

◆ destFlags

GtkDestDefaults DragNDrop::destFlags
private

The drop flags, see setDestDefaults.

Definition at line 69 of file DragNDrop.H.

◆ dragAction

GdkDragAction DragNDrop::dragAction
private

Action to take once the data is dropped.

Definition at line 70 of file DragNDrop.H.

◆ modifierType

GdkModifierType DragNDrop::modifierType
private

The modifier which initiates the drag and drop process.

Definition at line 71 of file DragNDrop.H.

◆ userData

gpointer DragNDrop::userData
private

If we want DND callbacks to operate on different user data, then this will store it here.

Definition at line 67 of file DragNDrop.H.


The documentation for this class was generated from the following file:
gtkIOStream: DragNDrop Class Reference
GTK+ IOStream  Beta