JX Application Framework
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
JXDNDManager Class Reference

#include <JXDNDManager.h>

Inheritance diagram for JXDNDManager:
[legend]

Classes

class  TargetFinder
 

Public Types

enum  {
  kDNDSelectionAtomIndex ,
  kDNDProxyAtomIndex ,
  kDNDAwareAtomIndex ,
  kDNDTypeListAtomIndex ,
  kDNDEnterAtomIndex ,
  kDNDHereAtomIndex ,
  kDNDStatusAtomIndex ,
  kDNDLeaveAtomIndex ,
  kDNDDropAtomIndex ,
  kDNDFinishedAtomIndex ,
  kDNDActionCopyAtomIndex ,
  kDNDActionMoveAtomIndex ,
  kDNDActionLinkAtomIndex ,
  kDNDActionAskAtomIndex ,
  kDNDActionPrivateAtomIndex ,
  kDNDActionDirectSaveAtomIndex ,
  kDNDActionListAtomIndex ,
  kDNDActionDescriptionAtomIndex ,
  kDNDDirectSave0AtomIndex ,
  kAtomCount
}
 

Public Member Functions

 JXDNDManager (JXDisplay *display)
 
 ~JXDNDManager () override
 
Atom GetDNDSelectionName () const
 
Atom GetCurrentDNDVersion () const
 
JCursorIndex GetDefaultDNDCursor (const bool dropAccepted=false, const Atom action=None) const
 
JCursorIndex GetDefaultDNDCopyCursor () const
 
JCursorIndex GetDefaultDNDMoveCursor () const
 
JCursorIndex GetDefaultDNDLinkCursor () const
 
JCursorIndex GetDefaultDNDAskCursor () const
 
JCursorIndex GetDNDCursor (const bool dropAccepted, const Atom action, const JCursorIndex *cursor) const
 
Atom GetDNDActionCopyXAtom () const
 
Atom GetDNDActionMoveXAtom () const
 
Atom GetDNDActionLinkXAtom () const
 
Atom GetDNDActionAskXAtom () const
 
Atom GetDNDActionPrivateXAtom () const
 
Atom GetDNDActionDirectSaveXAtom () const
 
bool GetAskActions (JArray< Atom > *actionList, JPtrArray< JString > *descriptionList) const
 
bool ChooseDropAction (const JArray< Atom > &actionList, const JPtrArray< JString > &descriptionList, Atom *action) const
 
bool IsDragging () const
 
Window GetDraggerWindow () const
 
bool TargetWillAcceptDrop () const
 
Atom GetDNDDirectSave0XAtom () const
 
JCursorIndex GetDNDFileCursor (const bool dropAccepted=false, const Atom action=None) const
 
JCursorIndex GetDNDCopyFileCursor () const
 
JCursorIndex GetDNDMoveFileCursor () const
 
JCursorIndex GetDNDLinkFileCursor () const
 
JCursorIndex GetDNDAskFileCursor () const
 
JCursorIndex GetDNDDirectoryCursor (const bool dropAccepted=false, const Atom action=None) const
 
JCursorIndex GetDNDCopyDirectoryCursor () const
 
JCursorIndex GetDNDMoveDirectoryCursor () const
 
JCursorIndex GetDNDLinkDirectoryCursor () const
 
JCursorIndex GetDNDAskDirectoryCursor () const
 
JCursorIndex GetDNDFileAndDirectoryCursor (const bool dropAccepted=false, const Atom action=None) const
 
JCursorIndex GetDNDCopyFileAndDirectoryCursor () const
 
JCursorIndex GetDNDMoveFileAndDirectoryCursor () const
 
JCursorIndex GetDNDLinkFileAndDirectoryCursor () const
 
JCursorIndex GetDNDAskFileAndDirectoryCursor () const
 
bool IsDNDAware (const Window xWindow, Window *proxy, JSize *vers) const
 
bool BeginDND (JXWidget *widget, const JPoint &pt, const JXButtonStates &buttonStates, const JXKeyModifiers &modifiers, JXSelectionData *data, TargetFinder *targetFinder)
 
void HandleDND (const JPoint &pt, const JXButtonStates &buttonStates, const JXKeyModifiers &modifiers, const JXMouseButton scrollButton)
 
void FinishDND ()
 
void EnableDND (const Window xWindow) const
 
bool CancelDND ()
 
bool HandleClientMessage (const XClientMessageEvent &clientMessage)
 
bool HandleDestroyNotify (const XDestroyWindowEvent &xEvent)
 
bool IsLastFakePasteTime (const Time time) const
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
virtual JString ToString () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Protected Member Functions

void ReceiveWithFeedback (JBroadcaster *sender, Message *message) override
 
void ReceiveGoingAway (JBroadcaster *sender) override
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
virtual void Receive (JBroadcaster *sender, const Message &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 

Detailed Description

Global object to manage Drag-And-Drop interactions.

When the drop is intra-application, we simply call the Widget directly.
When the drop is inter-application, we send ClientMessages.

Refer to http://johnlindal.wixsite.com/xdnd for the complete protocol.

When we are the source, itsDragger, itsDraggerWindow, and itsDraggerTypeList
refer to the source Widget.  If the mouse is in a local window, itsMouseContainer
points to the Widget that the mouse is in.  If the mouse is in the window
of another application, itsMouseWindow is the XID of the window.

When we are the target (always inter-application), itsDraggerWindow
refers to the source window.  itsDraggerTypeList is the list of types from
the source.  itsMouseWindow refers to the target window, and itsMouseContainer
is the Widget that the mouse is in.  Since we only receive window-level
XdndEnter and XdndLeave messages, we have to manually generate DNDEnter()
and DNDLeave() calls to each widget.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kDNDSelectionAtomIndex 
kDNDProxyAtomIndex 
kDNDAwareAtomIndex 
kDNDTypeListAtomIndex 
kDNDEnterAtomIndex 
kDNDHereAtomIndex 
kDNDStatusAtomIndex 
kDNDLeaveAtomIndex 
kDNDDropAtomIndex 
kDNDFinishedAtomIndex 
kDNDActionCopyAtomIndex 
kDNDActionMoveAtomIndex 
kDNDActionLinkAtomIndex 
kDNDActionAskAtomIndex 
kDNDActionPrivateAtomIndex 
kDNDActionDirectSaveAtomIndex 
kDNDActionListAtomIndex 
kDNDActionDescriptionAtomIndex 
kDNDDirectSave0AtomIndex 
kAtomCount 

Constructor & Destructor Documentation

◆ JXDNDManager()

JXDNDManager::JXDNDManager ( JXDisplay display)

◆ ~JXDNDManager()

JXDNDManager::~JXDNDManager ( )
override

Member Function Documentation

◆ BeginDND()

bool JXDNDManager::BeginDND ( JXWidget widget,
const JPoint pt,
const JXButtonStates buttonStates,
const JXKeyModifiers modifiers,
JXSelectionData data,
TargetFinder targetFinder 
)

Returns false if we are unable to initiate DND.

We do not take ownership of targetFinder.

◆ CancelDND()

bool JXDNDManager::CancelDND ( )

Returns true if the cancel was during a drag.

◆ ChooseDropAction()

bool JXDNDManager::ChooseDropAction ( const JArray< Atom > &  actionList,
const JPtrArray< JString > &  descriptionList,
Atom *  action 
) const

Asks the user which action to perform. Returns false if cancelled.

If the initial value of *action is one of the elements in actionList, the corresponding radio button becomes the initial choice.

◆ EnableDND()

void JXDNDManager::EnableDND ( const Window  xWindow) const

Creates the XdndAware property on the specified window.

We cannot include a list of data types because JXWindows contain many widgets.

◆ FinishDND()

void JXDNDManager::FinishDND ( )

◆ GetAskActions()

bool JXDNDManager::GetAskActions ( JArray< Atom > *  actionList,
JPtrArray< JString > *  descriptionList 
) const

If successful, returns a list of the actions supported by the source. The caller must be prepared for this to fail by supporting a fallback operation.

This function is not hidden inside ChooseDropAction() because the target may want to modify the list before presenting it to the user.

◆ GetCurrentDNDVersion()

Atom JXDNDManager::GetCurrentDNDVersion ( ) const

◆ GetDefaultDNDAskCursor()

JCursorIndex JXDNDManager::GetDefaultDNDAskCursor ( ) const
inline

◆ GetDefaultDNDCopyCursor()

JCursorIndex JXDNDManager::GetDefaultDNDCopyCursor ( ) const
inline

◆ GetDefaultDNDCursor()

JCursorIndex JXDNDManager::GetDefaultDNDCursor ( const bool  dropAccepted = false,
const Atom  action = None 
) const
inline

◆ GetDefaultDNDLinkCursor()

JCursorIndex JXDNDManager::GetDefaultDNDLinkCursor ( ) const
inline

◆ GetDefaultDNDMoveCursor()

JCursorIndex JXDNDManager::GetDefaultDNDMoveCursor ( ) const
inline

◆ GetDNDActionAskXAtom()

Atom JXDNDManager::GetDNDActionAskXAtom ( ) const
inline

◆ GetDNDActionCopyXAtom()

Atom JXDNDManager::GetDNDActionCopyXAtom ( ) const
inline

◆ GetDNDActionDirectSaveXAtom()

Atom JXDNDManager::GetDNDActionDirectSaveXAtom ( ) const
inline

◆ GetDNDActionLinkXAtom()

Atom JXDNDManager::GetDNDActionLinkXAtom ( ) const
inline

◆ GetDNDActionMoveXAtom()

Atom JXDNDManager::GetDNDActionMoveXAtom ( ) const
inline

◆ GetDNDActionPrivateXAtom()

Atom JXDNDManager::GetDNDActionPrivateXAtom ( ) const
inline

◆ GetDNDAskDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDAskDirectoryCursor ( ) const
inline

◆ GetDNDAskFileAndDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDAskFileAndDirectoryCursor ( ) const
inline

◆ GetDNDAskFileCursor()

JCursorIndex JXDNDManager::GetDNDAskFileCursor ( ) const
inline

◆ GetDNDCopyDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDCopyDirectoryCursor ( ) const
inline

◆ GetDNDCopyFileAndDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDCopyFileAndDirectoryCursor ( ) const
inline

◆ GetDNDCopyFileCursor()

JCursorIndex JXDNDManager::GetDNDCopyFileCursor ( ) const
inline

◆ GetDNDCursor()

JCursorIndex JXDNDManager::GetDNDCursor ( const bool  dropAccepted,
const Atom  action,
const JCursorIndex cursor 
) const

Returns the appropriate cursor for the given response.

cursor must be an array of 4 cursors: copy, move, link, ask

◆ GetDNDDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDDirectoryCursor ( const bool  dropAccepted = false,
const Atom  action = None 
) const
inline

◆ GetDNDDirectSave0XAtom()

Atom JXDNDManager::GetDNDDirectSave0XAtom ( ) const
inline

◆ GetDNDFileAndDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDFileAndDirectoryCursor ( const bool  dropAccepted = false,
const Atom  action = None 
) const
inline

◆ GetDNDFileCursor()

JCursorIndex JXDNDManager::GetDNDFileCursor ( const bool  dropAccepted = false,
const Atom  action = None 
) const
inline

◆ GetDNDLinkDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDLinkDirectoryCursor ( ) const
inline

◆ GetDNDLinkFileAndDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDLinkFileAndDirectoryCursor ( ) const
inline

◆ GetDNDLinkFileCursor()

JCursorIndex JXDNDManager::GetDNDLinkFileCursor ( ) const
inline

◆ GetDNDMoveDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDMoveDirectoryCursor ( ) const
inline

◆ GetDNDMoveFileAndDirectoryCursor()

JCursorIndex JXDNDManager::GetDNDMoveFileAndDirectoryCursor ( ) const
inline

◆ GetDNDMoveFileCursor()

JCursorIndex JXDNDManager::GetDNDMoveFileCursor ( ) const
inline

◆ GetDNDSelectionName()

Atom JXDNDManager::GetDNDSelectionName ( ) const
inline

◆ GetDraggerWindow()

Window JXDNDManager::GetDraggerWindow ( ) const
inline

This should only be called while dragging.

◆ HandleClientMessage()

bool JXDNDManager::HandleClientMessage ( const XClientMessageEvent &  clientMessage)

◆ HandleDestroyNotify()

bool JXDNDManager::HandleDestroyNotify ( const XDestroyWindowEvent &  xEvent)

This catches source crashes while the source is processing XdndStatus.

◆ HandleDND()

void JXDNDManager::HandleDND ( const JPoint pt,
const JXButtonStates buttonStates,
const JXKeyModifiers modifiers,
const JXMouseButton  scrollButton 
)

scrollButton can be 4,5,6,7

◆ IsDNDAware()

bool JXDNDManager::IsDNDAware ( const Window  xWindow,
Window *  proxy,
JSize vers 
) const

Returns true if the given X window supports the XDND protocol.

proxy is the window to which the client messages should be sent. vers is the version to use.

◆ IsDragging()

bool JXDNDManager::IsDragging ( ) const
inline

Returns true while dragging.

◆ IsLastFakePasteTime()

bool JXDNDManager::IsLastFakePasteTime ( const Time  time) const
inline

◆ ReceiveGoingAway()

void JXDNDManager::ReceiveGoingAway ( JBroadcaster sender)
overrideprotectedvirtual

This catches destruction of source and target windows. It is safe to do work here because JXDNDManager is deleted by JXDisplay after all windows are gone.

Reimplemented from JBroadcaster.

◆ ReceiveWithFeedback()

void JXDNDManager::ReceiveWithFeedback ( JBroadcaster sender,
Message message 
)
overrideprotectedvirtual

This catches: 1) target crashes 2) source crashes while a message is in the network

Reimplemented from JBroadcaster.

◆ TargetWillAcceptDrop()

bool JXDNDManager::TargetWillAcceptDrop ( ) const
inline

This should only be called from JXWidget::HandleDNDHere().


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