1. wxDropTarget::OnData() returns wxDragResult now, not bool
2. fixed assert failure in wxMSW::wxListBox 3. wxFileHistory automatically deletes non existinf files from menu 4. wxDropTarget coordinates are client (and not screen) under MSW too 5. wxConvertBitmapToDib and vice versa seem to work! 6. client data field if filled by wxListBox and wxChoice and it's also deleted (this just wasn't done before!) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4d85bcd1f5
commit
8ee9d6182c
@ -32,6 +32,11 @@ enum wxDragResult
|
|||||||
wxDragCancel // the operation was cancelled by user (not an error)
|
wxDragCancel // the operation was cancelled by user (not an error)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline WXDLLEXPORT bool wxIsDragResultOk(wxDragResult res)
|
||||||
|
{
|
||||||
|
return res == wxDragCopy || res == wxDragMove;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDropSource is the object you need to create (and call DoDragDrop on it)
|
// wxDropSource is the object you need to create (and call DoDragDrop on it)
|
||||||
// to initiate a drag-and-drop operation
|
// to initiate a drag-and-drop operation
|
||||||
@ -127,8 +132,10 @@ public:
|
|||||||
|
|
||||||
// called after OnDrop() returns TRUE: you will usually just call
|
// called after OnDrop() returns TRUE: you will usually just call
|
||||||
// GetData() from here and, probably, also refresh something to update the
|
// GetData() from here and, probably, also refresh something to update the
|
||||||
// new data
|
// new data and, finally, return the code indicating how did the operation
|
||||||
virtual bool OnData(wxCoord x, wxCoord y) = 0;
|
// complete (returning default value in case of success and wxDragError on
|
||||||
|
// failure is usually ok)
|
||||||
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0;
|
||||||
|
|
||||||
// may be called *only* from inside OnData() and will fill m_dataObject
|
// may be called *only* from inside OnData() and will fill m_dataObject
|
||||||
// with the data from the drop source if it returns TRUE
|
// with the data from the drop source if it returns TRUE
|
||||||
@ -138,11 +145,6 @@ protected:
|
|||||||
wxDataObject *m_dataObject;
|
wxDataObject *m_dataObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// the platform-specific headers also define standard wxDropTarget
|
|
||||||
// implementations wxTextDropTarget and wxFileDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// include platform dependent class declarations
|
// include platform dependent class declarations
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -164,6 +166,35 @@ protected:
|
|||||||
#include "wx/stubs/dnd.h"
|
#include "wx/stubs/dnd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// standard wxDropTarget implementations (implemented in common/dobjcmn.cpp)
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// A simple wxDropTarget derived class for text data: you only need to
|
||||||
|
// override OnDropText() to get something working
|
||||||
|
class WXDLLEXPORT wxTextDropTarget : public wxDropTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxTextDropTarget();
|
||||||
|
|
||||||
|
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
|
||||||
|
|
||||||
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
|
};
|
||||||
|
|
||||||
|
// A drop target which accepts files (dragged from File Manager or Explorer)
|
||||||
|
class WXDLLEXPORT wxFileDropTarget : public wxDropTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxFileDropTarget();
|
||||||
|
|
||||||
|
// parameters are the number of files and the array of file names
|
||||||
|
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
||||||
|
const wxArrayString& filenames) = 0;
|
||||||
|
|
||||||
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
|
};
|
||||||
|
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
#endif // _WX_DND_H_BASE_
|
#endif // _WX_DND_H_BASE_
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
#pragma interface "choicdgg.h"
|
#pragma interface "choicdgg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/listbox.h"
|
|
||||||
|
class WXDLLEXPORT wxListBox;
|
||||||
|
|
||||||
#define wxCHOICE_HEIGHT 150
|
#define wxCHOICE_HEIGHT 150
|
||||||
#define wxCHOICE_WIDTH 200
|
#define wxCHOICE_WIDTH 200
|
||||||
|
@ -44,10 +44,10 @@ class wxDropTarget: public wxDropTargetBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
|
wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
|
||||||
|
|
||||||
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
virtual bool OnDrop(wxCoord x, wxCoord y);
|
virtual bool OnDrop(wxCoord x, wxCoord y);
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
virtual bool GetData();
|
virtual bool GetData();
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
@ -69,37 +69,6 @@ public:
|
|||||||
void SetDragTime( guint time ) { m_dragTime = time; }
|
void SetDragTime( guint time ) { m_dragTime = time; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A simple wxDropTarget derived class for text data: you only need to
|
|
||||||
// override OnDropText() to get something working
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxTextDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxTextDropTarget();
|
|
||||||
|
|
||||||
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A drop target which accepts files (dragged from File Manager or Explorer)
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxFileDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxFileDropTarget();
|
|
||||||
|
|
||||||
// parameters are the number of files and the array of file names
|
|
||||||
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
|
||||||
const wxArrayString& filenames) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// wxDropSource
|
// wxDropSource
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -126,15 +95,15 @@ public:
|
|||||||
void UnregisterWindow();
|
void UnregisterWindow();
|
||||||
|
|
||||||
void PrepareIcon( int hot_x, int hot_y, GdkDragContext *context );
|
void PrepareIcon( int hot_x, int hot_y, GdkDragContext *context );
|
||||||
|
|
||||||
GtkWidget *m_widget;
|
GtkWidget *m_widget;
|
||||||
GtkWidget *m_iconWindow;
|
GtkWidget *m_iconWindow;
|
||||||
GdkDragContext *m_dragContext;
|
GdkDragContext *m_dragContext;
|
||||||
wxWindow *m_window;
|
wxWindow *m_window;
|
||||||
|
|
||||||
wxDragResult m_retValue;
|
wxDragResult m_retValue;
|
||||||
wxIcon m_icon;
|
wxIcon m_icon;
|
||||||
|
|
||||||
bool m_waiting;
|
bool m_waiting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ class wxDropTarget: public wxDropTargetBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
|
wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
|
||||||
|
|
||||||
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
virtual bool OnDrop(wxCoord x, wxCoord y);
|
virtual bool OnDrop(wxCoord x, wxCoord y);
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||||
virtual bool GetData();
|
virtual bool GetData();
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
@ -69,37 +69,6 @@ public:
|
|||||||
void SetDragTime( guint time ) { m_dragTime = time; }
|
void SetDragTime( guint time ) { m_dragTime = time; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A simple wxDropTarget derived class for text data: you only need to
|
|
||||||
// override OnDropText() to get something working
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxTextDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxTextDropTarget();
|
|
||||||
|
|
||||||
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A drop target which accepts files (dragged from File Manager or Explorer)
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxFileDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxFileDropTarget();
|
|
||||||
|
|
||||||
// parameters are the number of files and the array of file names
|
|
||||||
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
|
||||||
const wxArrayString& filenames) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// wxDropSource
|
// wxDropSource
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -126,15 +95,15 @@ public:
|
|||||||
void UnregisterWindow();
|
void UnregisterWindow();
|
||||||
|
|
||||||
void PrepareIcon( int hot_x, int hot_y, GdkDragContext *context );
|
void PrepareIcon( int hot_x, int hot_y, GdkDragContext *context );
|
||||||
|
|
||||||
GtkWidget *m_widget;
|
GtkWidget *m_widget;
|
||||||
GtkWidget *m_iconWindow;
|
GtkWidget *m_iconWindow;
|
||||||
GdkDragContext *m_dragContext;
|
GdkDragContext *m_dragContext;
|
||||||
wxWindow *m_window;
|
wxWindow *m_window;
|
||||||
|
|
||||||
wxDragResult m_retValue;
|
wxDragResult m_retValue;
|
||||||
wxIcon m_icon;
|
wxIcon m_icon;
|
||||||
|
|
||||||
bool m_waiting;
|
bool m_waiting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,17 +16,15 @@
|
|||||||
#pragma interface "checklst.h"
|
#pragma interface "checklst.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// No!
|
|
||||||
// typedef unsigned int size_t;
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#if !wxUSE_OWNER_DRAWN
|
#if !wxUSE_OWNER_DRAWN
|
||||||
#error "wxCheckListBox class requires owner-drawn functionality."
|
#error "wxCheckListBox class requires owner-drawn functionality."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class wxCheckListBoxItem; // fwd decl, define in checklst.cpp
|
#include "wx/listbox.h"
|
||||||
|
|
||||||
|
class wxCheckListBoxItem; // fwd decl, defined in checklst.cpp
|
||||||
|
|
||||||
class WXDLLEXPORT wxCheckListBox : public wxListBox
|
class WXDLLEXPORT wxCheckListBox : public wxListBox
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@ class WXDLLEXPORT wxChoice : public wxChoiceBase
|
|||||||
public:
|
public:
|
||||||
// ctors
|
// ctors
|
||||||
wxChoice() { }
|
wxChoice() { }
|
||||||
|
virtual ~wxChoice();
|
||||||
|
|
||||||
wxChoice(wxWindow *parent,
|
wxChoice(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@ -77,6 +78,9 @@ protected:
|
|||||||
virtual void DoSetSize(int x, int y,
|
virtual void DoSetSize(int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO);
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
|
|
||||||
|
// free all memory we have (used by Clear() and dtor)
|
||||||
|
void Free();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_CHOICE_H_
|
#endif // _WX_CHOICE_H_
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_LISTBOX_H_
|
#ifndef _WX_LISTBOX_H_
|
||||||
#define _WX_LISTBOX_H_
|
#define _WX_LISTBOX_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "listbox.h"
|
#pragma interface "listbox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -120,6 +120,9 @@ protected:
|
|||||||
// do we have multiple selections?
|
// do we have multiple selections?
|
||||||
bool HasMultipleSelection() const;
|
bool HasMultipleSelection() const;
|
||||||
|
|
||||||
|
// free memory (common part of Clear() and dtor)
|
||||||
|
void Free();
|
||||||
|
|
||||||
int m_noItems;
|
int m_noItems;
|
||||||
int m_selected;
|
int m_selected;
|
||||||
|
|
||||||
|
@ -71,35 +71,4 @@ private:
|
|||||||
IDataObject *m_pIDataSource; // the pointer to the source data object
|
IDataObject *m_pIDataSource; // the pointer to the source data object
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A simple wxDropTarget derived class for text data: you only need to
|
|
||||||
// override OnDropText() to get something working
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTextDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxTextDropTarget();
|
|
||||||
|
|
||||||
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// A drop target which accepts files (dragged from File Manager or Explorer)
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxFileDropTarget : public wxDropTarget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxFileDropTarget();
|
|
||||||
|
|
||||||
// parameters are the number of files and the array of file names
|
|
||||||
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
|
||||||
const wxArrayString& filenames) = 0;
|
|
||||||
|
|
||||||
virtual bool OnData(wxCoord x, wxCoord y);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_WX_OLEDROPTGT_H
|
#endif //_WX_OLEDROPTGT_H
|
||||||
|
@ -420,8 +420,6 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( format == wxDF_BITMAP, "unsupported format" );
|
|
||||||
|
|
||||||
if ( !m_hasBitmap )
|
if ( !m_hasBitmap )
|
||||||
CreateBitmap();
|
CreateBitmap();
|
||||||
|
|
||||||
@ -544,19 +542,19 @@ public:
|
|||||||
{ m_frame->SetStatusText("Mouse entered the frame"); }
|
{ m_frame->SetStatusText("Mouse entered the frame"); }
|
||||||
virtual void OnLeave()
|
virtual void OnLeave()
|
||||||
{ m_frame->SetStatusText("Mouse left the frame"); }
|
{ m_frame->SetStatusText("Mouse left the frame"); }
|
||||||
virtual bool OnData(wxCoord x, wxCoord y)
|
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
|
||||||
{
|
{
|
||||||
if ( !GetData() )
|
if ( !GetData() )
|
||||||
{
|
{
|
||||||
wxLogError("Failed to get drag and drop data");
|
wxLogError("Failed to get drag and drop data");
|
||||||
|
|
||||||
return FALSE;
|
return wxDragNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->OnDrop(x, y,
|
m_frame->OnDrop(x, y,
|
||||||
((DnDShapeDataObject *)GetDataObject())->GetShape());
|
((DnDShapeDataObject *)GetDataObject())->GetShape());
|
||||||
|
|
||||||
return TRUE;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1299,9 +1297,6 @@ void DnDShapeFrame::OnDrop(wxCoord x, wxCoord y, DnDShape *shape)
|
|||||||
ms_lastDropTarget = this;
|
ms_lastDropTarget = this;
|
||||||
|
|
||||||
wxPoint pt(x, y);
|
wxPoint pt(x, y);
|
||||||
#ifdef __WXMSW__ //temporary hack (FIXME)
|
|
||||||
pt = ScreenToClient(pt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxString s;
|
wxString s;
|
||||||
s.Printf("Shape dropped at (%ld, %ld)", pt.x, pt.y);
|
s.Printf("Shape dropped at (%ld, %ld)", pt.x, pt.y);
|
||||||
|
@ -31,14 +31,6 @@
|
|||||||
#include "wx/clipbrd.h"
|
#include "wx/clipbrd.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// wxClipboardBase
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxClipboardBase::wxClipboardBase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxClipboardModule: module responsible for initializing the global clipboard
|
// wxClipboardModule: module responsible for initializing the global clipboard
|
||||||
// object
|
// object
|
||||||
@ -47,12 +39,8 @@ wxClipboardBase::wxClipboardBase()
|
|||||||
class wxClipboardModule : public wxModule
|
class wxClipboardModule : public wxModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxClipboardModule() { }
|
bool OnInit();
|
||||||
|
void OnExit();
|
||||||
bool OnInit()
|
|
||||||
{ wxTheClipboard = new wxClipboard; return TRUE; }
|
|
||||||
void OnExit()
|
|
||||||
{ delete wxTheClipboard; wxTheClipboard = (wxClipboard *)NULL; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxClipboardModule)
|
DECLARE_DYNAMIC_CLASS(wxClipboardModule)
|
||||||
@ -63,3 +51,27 @@ private:
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
|
||||||
|
|
||||||
|
wxClipboard* wxTheClipboard = (wxClipboard *)NULL;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxClipboardBase::wxClipboardBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboardModule::OnInit()
|
||||||
|
{
|
||||||
|
wxTheClipboard = new wxClipboard;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxClipboardModule::OnExit()
|
||||||
|
{
|
||||||
|
delete wxTheClipboard;
|
||||||
|
|
||||||
|
wxTheClipboard = (wxClipboard *)NULL;
|
||||||
|
}
|
||||||
|
@ -289,3 +289,45 @@ bool wxCustomDataObject::SetData(size_t size, const void *buf)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// some common dnd related code
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#include "wx/dnd.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxTextDropTarget
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxTextDropTarget::wxTextDropTarget()
|
||||||
|
: wxDropTarget(new wxTextDataObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDragResult wxTextDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
|
||||||
|
{
|
||||||
|
if ( !GetData() )
|
||||||
|
return wxDragNone;
|
||||||
|
|
||||||
|
wxTextDataObject *dobj = (wxTextDataObject *)m_dataObject;
|
||||||
|
return OnDropText(x, y, dobj->GetText()) ? def : wxDragNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFileDropTarget
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxFileDropTarget::wxFileDropTarget()
|
||||||
|
: wxDropTarget(new wxFileDataObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDragResult wxFileDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
|
||||||
|
{
|
||||||
|
if ( !GetData() )
|
||||||
|
return wxDragNone;
|
||||||
|
|
||||||
|
wxFileDataObject *dobj = (wxFileDataObject *)m_dataObject;
|
||||||
|
return OnDropFiles(x, y, dobj->GetFilenames()) ? def : wxDragNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,6 @@ wxDocManager::wxDocManager(long flags, bool initialize)
|
|||||||
m_currentView = (wxView *) NULL;
|
m_currentView = (wxView *) NULL;
|
||||||
m_maxDocsOpen = 10000;
|
m_maxDocsOpen = 10000;
|
||||||
m_fileHistory = (wxFileHistory *) NULL;
|
m_fileHistory = (wxFileHistory *) NULL;
|
||||||
m_lastDirectory = wxT("") ;
|
|
||||||
if (initialize)
|
if (initialize)
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
@ -1910,11 +1909,8 @@ void wxFileHistory::RemoveFileFromHistory(int i)
|
|||||||
{
|
{
|
||||||
wxMenu* menu = (wxMenu*) node->Data();
|
wxMenu* menu = (wxMenu*) node->Data();
|
||||||
|
|
||||||
// wxMenu::Delete() is missing from wxGTK, so this can't be done :-(
|
|
||||||
#if 0
|
|
||||||
// delete the menu items
|
// delete the menu items
|
||||||
menu->Delete(wxID_FILE1 + i);
|
menu->Delete(wxID_FILE1 + i);
|
||||||
#endif
|
|
||||||
|
|
||||||
// delete the element from the array (could use memmove() too...)
|
// delete the element from the array (could use memmove() too...)
|
||||||
delete [] m_fileHistory[i];
|
delete [] m_fileHistory[i];
|
||||||
@ -1933,11 +1929,6 @@ void wxFileHistory::RemoveFileFromHistory(int i)
|
|||||||
menu->SetLabel(wxID_FILE1 + j, buf);
|
menu->SetLabel(wxID_FILE1 + j, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// to be removed as soon as wxMenu::Delete() is implemented
|
|
||||||
#if 1
|
|
||||||
menu->SetLabel(wxID_FILE1 + m_fileHistoryN - 1, wxT(""));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
m_fileHistoryN--;
|
m_fileHistoryN--;
|
||||||
@ -1945,10 +1936,17 @@ void wxFileHistory::RemoveFileFromHistory(int i)
|
|||||||
|
|
||||||
wxString wxFileHistory::GetHistoryFile(int i) const
|
wxString wxFileHistory::GetHistoryFile(int i) const
|
||||||
{
|
{
|
||||||
if (i < m_fileHistoryN)
|
wxString s;
|
||||||
return wxString(m_fileHistory[i]);
|
if ( i < m_fileHistoryN )
|
||||||
|
{
|
||||||
|
s = m_fileHistory[i];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return wxString("");
|
{
|
||||||
|
wxFAIL_MSG( wxT("bad index in wxFileHistory::GetHistoryFile") );
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileHistory::UseMenu(wxMenu *menu)
|
void wxFileHistory::UseMenu(wxMenu *menu)
|
||||||
|
@ -84,7 +84,7 @@ bool wxListBoxBase::SetStringSelection(const wxString& s, bool select)
|
|||||||
|
|
||||||
void wxListBoxBase::Command(wxCommandEvent& event)
|
void wxListBoxBase::Command(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
SetSelection(event.m_commandInt, event.m_extraLong);
|
SetSelection(event.m_commandInt, event.m_extraLong != 0);
|
||||||
(void)ProcessEvent(event);
|
(void)ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ extern void wxapp_uninstall_thread_wakeup();
|
|||||||
// data
|
// data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
|
|
||||||
|
|
||||||
GdkAtom g_clipboardAtom = 0;
|
GdkAtom g_clipboardAtom = 0;
|
||||||
GdkAtom g_targetsAtom = 0;
|
GdkAtom g_targetsAtom = 0;
|
||||||
|
|
||||||
|
148
src/gtk/dnd.cpp
148
src/gtk/dnd.cpp
@ -147,8 +147,11 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
|
|||||||
this is only valid for the duration of this call */
|
this is only valid for the duration of this call */
|
||||||
drop_target->SetDragContext( context );
|
drop_target->SetDragContext( context );
|
||||||
|
|
||||||
wxDragResult result = wxDragMove;
|
wxDragResult result;
|
||||||
if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy;
|
if ( context->suggested_action == GDK_ACTION_COPY )
|
||||||
|
result = wxDragCopy;
|
||||||
|
else
|
||||||
|
result = wxDragMove;
|
||||||
|
|
||||||
if (drop_target->m_firstMotion)
|
if (drop_target->m_firstMotion)
|
||||||
{
|
{
|
||||||
@ -161,11 +164,15 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
|
|||||||
result = drop_target->OnDragOver( x, y, result );
|
result = drop_target->OnDragOver( x, y, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = result != wxDragNone;
|
bool ret = wxIsDragResultOk( result );
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
GdkDragAction action = GDK_ACTION_MOVE;
|
GdkDragAction action;
|
||||||
if (result == wxDragCopy) action = GDK_ACTION_COPY;
|
if (result == wxDragCopy)
|
||||||
|
action = GDK_ACTION_COPY;
|
||||||
|
else
|
||||||
|
action = GDK_ACTION_MOVE;
|
||||||
|
|
||||||
gdk_drag_status( context, action, time );
|
gdk_drag_status( context, action, time );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +231,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
||||||
|
|
||||||
/* cancel the whole thing */
|
/* cancel the whole thing */
|
||||||
gtk_drag_finish( context,
|
gtk_drag_finish( context,
|
||||||
FALSE, /* no success */
|
FALSE, /* no success */
|
||||||
@ -234,7 +241,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
/* disable GUI threads */
|
/* disable GUI threads */
|
||||||
wxapp_uninstall_thread_wakeup();
|
wxapp_uninstall_thread_wakeup();
|
||||||
@ -242,11 +249,11 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
|
|
||||||
GdkAtom format = drop_target->GetMatchingPair();
|
GdkAtom format = drop_target->GetMatchingPair();
|
||||||
wxASSERT( format );
|
wxASSERT( format );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GdkDragAction action = GDK_ACTION_MOVE;
|
GdkDragAction action = GDK_ACTION_MOVE;
|
||||||
if (result == wxDragCopy) action == GDK_ACTION_COPY;
|
if (result == wxDragCopy) action == GDK_ACTION_COPY;
|
||||||
context->action = action;
|
context->action = action;
|
||||||
*/
|
*/
|
||||||
/* this should trigger an "drag_data_received" event */
|
/* this should trigger an "drag_data_received" event */
|
||||||
gtk_drag_get_data( widget,
|
gtk_drag_get_data( widget,
|
||||||
@ -290,7 +297,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
/* Owen Taylor: "call gtk_drag_finish() with
|
/* Owen Taylor: "call gtk_drag_finish() with
|
||||||
success == TRUE" */
|
success == TRUE" */
|
||||||
|
|
||||||
|
|
||||||
if ((data->length <= 0) || (data->format != 8))
|
if ((data->length <= 0) || (data->format != 8))
|
||||||
{
|
{
|
||||||
/* negative data length and non 8-bit data format
|
/* negative data length and non 8-bit data format
|
||||||
@ -301,22 +307,28 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug( wxT( "Drop target: data received event") );
|
wxLogDebug( wxT( "Drop target: data received event") );
|
||||||
|
|
||||||
/* inform the wxDropTarget about the current GtkSelectionData.
|
/* inform the wxDropTarget about the current GtkSelectionData.
|
||||||
this is only valid for the duration of this call */
|
this is only valid for the duration of this call */
|
||||||
drop_target->SetDragData( data );
|
drop_target->SetDragData( data );
|
||||||
|
|
||||||
if (drop_target->OnData( x, y ))
|
wxDragResult result;
|
||||||
|
if ( context->suggested_action == GDK_ACTION_COPY )
|
||||||
|
result = wxDragCopy;
|
||||||
|
else
|
||||||
|
result = wxDragMove;
|
||||||
|
|
||||||
|
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnData returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnData returned TRUE") );
|
||||||
|
|
||||||
/* tell GTK that data transfer was successfull */
|
/* tell GTK that data transfer was successfull */
|
||||||
gtk_drag_finish( context, TRUE, FALSE, time );
|
gtk_drag_finish( context, TRUE, FALSE, time );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnData returned FALSE") );
|
wxLogDebug( wxT( "Drop target: OnData returned FALSE") );
|
||||||
|
|
||||||
/* tell GTK that data transfer was not successfull */
|
/* tell GTK that data transfer was not successfull */
|
||||||
gtk_drag_finish( context, FALSE, FALSE, time );
|
gtk_drag_finish( context, FALSE, FALSE, time );
|
||||||
}
|
}
|
||||||
@ -329,8 +341,8 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
// wxDropTarget
|
// wxDropTarget
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxDropTarget::wxDropTarget( wxDataObject *data )
|
wxDropTarget::wxDropTarget( wxDataObject *data )
|
||||||
: wxDropTargetBase( data )
|
: wxDropTargetBase( data )
|
||||||
{
|
{
|
||||||
m_firstMotion = TRUE;
|
m_firstMotion = TRUE;
|
||||||
m_dragContext = (GdkDragContext*) NULL;
|
m_dragContext = (GdkDragContext*) NULL;
|
||||||
@ -343,7 +355,7 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
|
|||||||
wxCoord WXUNUSED(y),
|
wxCoord WXUNUSED(y),
|
||||||
wxDragResult def )
|
wxDragResult def )
|
||||||
{
|
{
|
||||||
// GetMatchingPair() checks for m_dataObject too, no need to do it here
|
// GetMatchingPair() checks for m_dataObject too, no need to do it here
|
||||||
|
|
||||||
// disable the debug message from GetMatchingPair() - there are too many
|
// disable the debug message from GetMatchingPair() - there are too many
|
||||||
// of them otherwise
|
// of them otherwise
|
||||||
@ -358,27 +370,28 @@ bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
|||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (GetMatchingPair() != (GdkAtom) 0);
|
return (GetMatchingPair() != (GdkAtom) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||||
|
wxDragResult def )
|
||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (GetMatchingPair() == (GdkAtom) 0)
|
if (GetMatchingPair() == (GdkAtom) 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return GetData();
|
return GetData() ? def : wxDragNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkAtom wxDropTarget::GetMatchingPair()
|
GdkAtom wxDropTarget::GetMatchingPair()
|
||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return (GdkAtom) 0;
|
return (GdkAtom) 0;
|
||||||
|
|
||||||
if (!m_dragContext)
|
if (!m_dragContext)
|
||||||
return (GdkAtom) 0;
|
return (GdkAtom) 0;
|
||||||
|
|
||||||
GList *child = m_dragContext->targets;
|
GList *child = m_dragContext->targets;
|
||||||
@ -403,14 +416,14 @@ GdkAtom wxDropTarget::GetMatchingPair()
|
|||||||
|
|
||||||
bool wxDropTarget::GetData()
|
bool wxDropTarget::GetData()
|
||||||
{
|
{
|
||||||
if (!m_dragData)
|
if (!m_dragData)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wxDataFormat dragFormat( m_dragData->target );
|
wxDataFormat dragFormat( m_dragData->target );
|
||||||
|
|
||||||
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -485,41 +498,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
|
|||||||
GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
|
GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxTextDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxTextDropTarget::wxTextDropTarget()
|
|
||||||
: wxDropTarget(new wxTextDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxTextDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropText(x, y, ((wxTextDataObject *)m_dataObject)->GetText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxFileDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxFileDropTarget::wxFileDropTarget()
|
|
||||||
: wxDropTarget(new wxFileDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxFileDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropFiles(x, y,
|
|
||||||
((wxFileDataObject *)m_dataObject)->GetFilenames());
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// "drag_data_get"
|
// "drag_data_get"
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -535,13 +513,13 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
if (g_isIdle) wxapp_install_idle_handler();
|
if (g_isIdle) wxapp_install_idle_handler();
|
||||||
|
|
||||||
wxDataFormat format( selection_data->target );
|
wxDataFormat format( selection_data->target );
|
||||||
|
|
||||||
wxLogDebug( wxT("Drop source: format requested: %s"), format.GetId().c_str() );
|
wxLogDebug( wxT("Drop source: format requested: %s"), format.GetId().c_str() );
|
||||||
|
|
||||||
drop_source->m_retValue = wxDragCancel;
|
drop_source->m_retValue = wxDragCancel;
|
||||||
|
|
||||||
wxDataObject *data = drop_source->GetDataObject();
|
wxDataObject *data = drop_source->GetDataObject();
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT("Drop source: no data object") );
|
wxLogDebug( wxT("Drop source: no data object") );
|
||||||
@ -559,13 +537,13 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
wxLogDebug( wxT("Drop source: empty data") );
|
wxLogDebug( wxT("Drop source: empty data") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = data->GetDataSize(format);
|
size_t size = data->GetDataSize(format);
|
||||||
|
|
||||||
// printf( "data size: %d.\n", (int)data_size );
|
// printf( "data size: %d.\n", (int)data_size );
|
||||||
|
|
||||||
guchar *d = new guchar[size];
|
guchar *d = new guchar[size];
|
||||||
|
|
||||||
if (!data->GetDataHere( format, (void*)d ))
|
if (!data->GetDataHere( format, (void*)d ))
|
||||||
{
|
{
|
||||||
delete[] d;
|
delete[] d;
|
||||||
@ -589,7 +567,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] d;
|
delete[] d;
|
||||||
|
|
||||||
/* so far only copy, no moves. TODO. */
|
/* so far only copy, no moves. TODO. */
|
||||||
drop_source->m_retValue = wxDragCopy;
|
drop_source->m_retValue = wxDragCopy;
|
||||||
}
|
}
|
||||||
@ -641,10 +619,10 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget),
|
|||||||
// "configure_event" from m_iconWindow
|
// "configure_event" from m_iconWindow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
|
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
|
||||||
{
|
{
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
wxDragResult action = wxDragNone;
|
wxDragResult action = wxDragNone;
|
||||||
@ -652,7 +630,7 @@ gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigur
|
|||||||
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
|
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
|
||||||
|
|
||||||
source->GiveFeedback( action, FALSE );
|
source->GiveFeedback( action, FALSE );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +644,7 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &icon )
|
|||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
m_iconWindow = (GtkWidget*) NULL;
|
m_iconWindow = (GtkWidget*) NULL;
|
||||||
|
|
||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
@ -680,15 +658,15 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &icon )
|
|||||||
wxDropSource::wxDropSource( wxDataObject& data, wxWindow *win, const wxIcon &icon )
|
wxDropSource::wxDropSource( wxDataObject& data, wxWindow *win, const wxIcon &icon )
|
||||||
{
|
{
|
||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
SetData( data );
|
SetData( data );
|
||||||
|
|
||||||
m_iconWindow = (GtkWidget*) NULL;
|
m_iconWindow = (GtkWidget*) NULL;
|
||||||
|
|
||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
|
|
||||||
m_retValue = wxDragCancel;
|
m_retValue = wxDragCancel;
|
||||||
|
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
@ -725,9 +703,9 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context )
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
|
gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );
|
||||||
|
|
||||||
gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
|
gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
|
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
|
||||||
|
|
||||||
@ -738,12 +716,12 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
{
|
{
|
||||||
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
|
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
|
||||||
|
|
||||||
if (!m_data)
|
if (!m_data)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
|
|
||||||
if (m_data->GetFormatCount() == 0)
|
if (m_data->GetFormatCount() == 0)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
|
|
||||||
g_blockEventsOnDrag = TRUE;
|
g_blockEventsOnDrag = TRUE;
|
||||||
|
|
||||||
RegisterWindow();
|
RegisterWindow();
|
||||||
@ -751,7 +729,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
||||||
|
|
||||||
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
|
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
|
||||||
m_data->GetAllFormats( array );
|
m_data->GetAllFormats( array );
|
||||||
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
||||||
@ -792,9 +770,9 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
(GdkDragAction)(GDK_ACTION_COPY|GDK_ACTION_MOVE),
|
(GdkDragAction)(GDK_ACTION_COPY|GDK_ACTION_MOVE),
|
||||||
button_number, /* number of mouse button which started drag */
|
button_number, /* number of mouse button which started drag */
|
||||||
(GdkEvent*) &event );
|
(GdkEvent*) &event );
|
||||||
|
|
||||||
m_dragContext = context;
|
m_dragContext = context;
|
||||||
|
|
||||||
PrepareIcon( 0, 0, context );
|
PrepareIcon( 0, 0, context );
|
||||||
|
|
||||||
while (m_waiting) gtk_main_iteration();;
|
while (m_waiting) gtk_main_iteration();;
|
||||||
|
@ -36,8 +36,6 @@ extern void wxapp_uninstall_thread_wakeup();
|
|||||||
// data
|
// data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
|
|
||||||
|
|
||||||
GdkAtom g_clipboardAtom = 0;
|
GdkAtom g_clipboardAtom = 0;
|
||||||
GdkAtom g_targetsAtom = 0;
|
GdkAtom g_targetsAtom = 0;
|
||||||
|
|
||||||
|
148
src/gtk1/dnd.cpp
148
src/gtk1/dnd.cpp
@ -147,8 +147,11 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
|
|||||||
this is only valid for the duration of this call */
|
this is only valid for the duration of this call */
|
||||||
drop_target->SetDragContext( context );
|
drop_target->SetDragContext( context );
|
||||||
|
|
||||||
wxDragResult result = wxDragMove;
|
wxDragResult result;
|
||||||
if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy;
|
if ( context->suggested_action == GDK_ACTION_COPY )
|
||||||
|
result = wxDragCopy;
|
||||||
|
else
|
||||||
|
result = wxDragMove;
|
||||||
|
|
||||||
if (drop_target->m_firstMotion)
|
if (drop_target->m_firstMotion)
|
||||||
{
|
{
|
||||||
@ -161,11 +164,15 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
|
|||||||
result = drop_target->OnDragOver( x, y, result );
|
result = drop_target->OnDragOver( x, y, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = result != wxDragNone;
|
bool ret = wxIsDragResultOk( result );
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
GdkDragAction action = GDK_ACTION_MOVE;
|
GdkDragAction action;
|
||||||
if (result == wxDragCopy) action = GDK_ACTION_COPY;
|
if (result == wxDragCopy)
|
||||||
|
action = GDK_ACTION_COPY;
|
||||||
|
else
|
||||||
|
action = GDK_ACTION_MOVE;
|
||||||
|
|
||||||
gdk_drag_status( context, action, time );
|
gdk_drag_status( context, action, time );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +231,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
||||||
|
|
||||||
/* cancel the whole thing */
|
/* cancel the whole thing */
|
||||||
gtk_drag_finish( context,
|
gtk_drag_finish( context,
|
||||||
FALSE, /* no success */
|
FALSE, /* no success */
|
||||||
@ -234,7 +241,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnDrop returned TRUE") );
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
/* disable GUI threads */
|
/* disable GUI threads */
|
||||||
wxapp_uninstall_thread_wakeup();
|
wxapp_uninstall_thread_wakeup();
|
||||||
@ -242,11 +249,11 @@ static gboolean target_drag_drop( GtkWidget *widget,
|
|||||||
|
|
||||||
GdkAtom format = drop_target->GetMatchingPair();
|
GdkAtom format = drop_target->GetMatchingPair();
|
||||||
wxASSERT( format );
|
wxASSERT( format );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GdkDragAction action = GDK_ACTION_MOVE;
|
GdkDragAction action = GDK_ACTION_MOVE;
|
||||||
if (result == wxDragCopy) action == GDK_ACTION_COPY;
|
if (result == wxDragCopy) action == GDK_ACTION_COPY;
|
||||||
context->action = action;
|
context->action = action;
|
||||||
*/
|
*/
|
||||||
/* this should trigger an "drag_data_received" event */
|
/* this should trigger an "drag_data_received" event */
|
||||||
gtk_drag_get_data( widget,
|
gtk_drag_get_data( widget,
|
||||||
@ -290,7 +297,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
/* Owen Taylor: "call gtk_drag_finish() with
|
/* Owen Taylor: "call gtk_drag_finish() with
|
||||||
success == TRUE" */
|
success == TRUE" */
|
||||||
|
|
||||||
|
|
||||||
if ((data->length <= 0) || (data->format != 8))
|
if ((data->length <= 0) || (data->format != 8))
|
||||||
{
|
{
|
||||||
/* negative data length and non 8-bit data format
|
/* negative data length and non 8-bit data format
|
||||||
@ -301,22 +307,28 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug( wxT( "Drop target: data received event") );
|
wxLogDebug( wxT( "Drop target: data received event") );
|
||||||
|
|
||||||
/* inform the wxDropTarget about the current GtkSelectionData.
|
/* inform the wxDropTarget about the current GtkSelectionData.
|
||||||
this is only valid for the duration of this call */
|
this is only valid for the duration of this call */
|
||||||
drop_target->SetDragData( data );
|
drop_target->SetDragData( data );
|
||||||
|
|
||||||
if (drop_target->OnData( x, y ))
|
wxDragResult result;
|
||||||
|
if ( context->suggested_action == GDK_ACTION_COPY )
|
||||||
|
result = wxDragCopy;
|
||||||
|
else
|
||||||
|
result = wxDragMove;
|
||||||
|
|
||||||
|
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnData returned TRUE") );
|
wxLogDebug( wxT( "Drop target: OnData returned TRUE") );
|
||||||
|
|
||||||
/* tell GTK that data transfer was successfull */
|
/* tell GTK that data transfer was successfull */
|
||||||
gtk_drag_finish( context, TRUE, FALSE, time );
|
gtk_drag_finish( context, TRUE, FALSE, time );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Drop target: OnData returned FALSE") );
|
wxLogDebug( wxT( "Drop target: OnData returned FALSE") );
|
||||||
|
|
||||||
/* tell GTK that data transfer was not successfull */
|
/* tell GTK that data transfer was not successfull */
|
||||||
gtk_drag_finish( context, FALSE, FALSE, time );
|
gtk_drag_finish( context, FALSE, FALSE, time );
|
||||||
}
|
}
|
||||||
@ -329,8 +341,8 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
|
|||||||
// wxDropTarget
|
// wxDropTarget
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxDropTarget::wxDropTarget( wxDataObject *data )
|
wxDropTarget::wxDropTarget( wxDataObject *data )
|
||||||
: wxDropTargetBase( data )
|
: wxDropTargetBase( data )
|
||||||
{
|
{
|
||||||
m_firstMotion = TRUE;
|
m_firstMotion = TRUE;
|
||||||
m_dragContext = (GdkDragContext*) NULL;
|
m_dragContext = (GdkDragContext*) NULL;
|
||||||
@ -343,7 +355,7 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
|
|||||||
wxCoord WXUNUSED(y),
|
wxCoord WXUNUSED(y),
|
||||||
wxDragResult def )
|
wxDragResult def )
|
||||||
{
|
{
|
||||||
// GetMatchingPair() checks for m_dataObject too, no need to do it here
|
// GetMatchingPair() checks for m_dataObject too, no need to do it here
|
||||||
|
|
||||||
// disable the debug message from GetMatchingPair() - there are too many
|
// disable the debug message from GetMatchingPair() - there are too many
|
||||||
// of them otherwise
|
// of them otherwise
|
||||||
@ -358,27 +370,28 @@ bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
|||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (GetMatchingPair() != (GdkAtom) 0);
|
return (GetMatchingPair() != (GdkAtom) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||||
|
wxDragResult def )
|
||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (GetMatchingPair() == (GdkAtom) 0)
|
if (GetMatchingPair() == (GdkAtom) 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return GetData();
|
return GetData() ? def : wxDragNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkAtom wxDropTarget::GetMatchingPair()
|
GdkAtom wxDropTarget::GetMatchingPair()
|
||||||
{
|
{
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return (GdkAtom) 0;
|
return (GdkAtom) 0;
|
||||||
|
|
||||||
if (!m_dragContext)
|
if (!m_dragContext)
|
||||||
return (GdkAtom) 0;
|
return (GdkAtom) 0;
|
||||||
|
|
||||||
GList *child = m_dragContext->targets;
|
GList *child = m_dragContext->targets;
|
||||||
@ -403,14 +416,14 @@ GdkAtom wxDropTarget::GetMatchingPair()
|
|||||||
|
|
||||||
bool wxDropTarget::GetData()
|
bool wxDropTarget::GetData()
|
||||||
{
|
{
|
||||||
if (!m_dragData)
|
if (!m_dragData)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!m_dataObject)
|
if (!m_dataObject)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wxDataFormat dragFormat( m_dragData->target );
|
wxDataFormat dragFormat( m_dragData->target );
|
||||||
|
|
||||||
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -485,41 +498,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
|
|||||||
GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
|
GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxTextDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxTextDropTarget::wxTextDropTarget()
|
|
||||||
: wxDropTarget(new wxTextDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxTextDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropText(x, y, ((wxTextDataObject *)m_dataObject)->GetText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxFileDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxFileDropTarget::wxFileDropTarget()
|
|
||||||
: wxDropTarget(new wxFileDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxFileDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropFiles(x, y,
|
|
||||||
((wxFileDataObject *)m_dataObject)->GetFilenames());
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// "drag_data_get"
|
// "drag_data_get"
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -535,13 +513,13 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
if (g_isIdle) wxapp_install_idle_handler();
|
if (g_isIdle) wxapp_install_idle_handler();
|
||||||
|
|
||||||
wxDataFormat format( selection_data->target );
|
wxDataFormat format( selection_data->target );
|
||||||
|
|
||||||
wxLogDebug( wxT("Drop source: format requested: %s"), format.GetId().c_str() );
|
wxLogDebug( wxT("Drop source: format requested: %s"), format.GetId().c_str() );
|
||||||
|
|
||||||
drop_source->m_retValue = wxDragCancel;
|
drop_source->m_retValue = wxDragCancel;
|
||||||
|
|
||||||
wxDataObject *data = drop_source->GetDataObject();
|
wxDataObject *data = drop_source->GetDataObject();
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT("Drop source: no data object") );
|
wxLogDebug( wxT("Drop source: no data object") );
|
||||||
@ -559,13 +537,13 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
wxLogDebug( wxT("Drop source: empty data") );
|
wxLogDebug( wxT("Drop source: empty data") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = data->GetDataSize(format);
|
size_t size = data->GetDataSize(format);
|
||||||
|
|
||||||
// printf( "data size: %d.\n", (int)data_size );
|
// printf( "data size: %d.\n", (int)data_size );
|
||||||
|
|
||||||
guchar *d = new guchar[size];
|
guchar *d = new guchar[size];
|
||||||
|
|
||||||
if (!data->GetDataHere( format, (void*)d ))
|
if (!data->GetDataHere( format, (void*)d ))
|
||||||
{
|
{
|
||||||
delete[] d;
|
delete[] d;
|
||||||
@ -589,7 +567,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] d;
|
delete[] d;
|
||||||
|
|
||||||
/* so far only copy, no moves. TODO. */
|
/* so far only copy, no moves. TODO. */
|
||||||
drop_source->m_retValue = wxDragCopy;
|
drop_source->m_retValue = wxDragCopy;
|
||||||
}
|
}
|
||||||
@ -641,10 +619,10 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget),
|
|||||||
// "configure_event" from m_iconWindow
|
// "configure_event" from m_iconWindow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
|
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
|
||||||
{
|
{
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
wxDragResult action = wxDragNone;
|
wxDragResult action = wxDragNone;
|
||||||
@ -652,7 +630,7 @@ gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigur
|
|||||||
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
|
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
|
||||||
|
|
||||||
source->GiveFeedback( action, FALSE );
|
source->GiveFeedback( action, FALSE );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +644,7 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &icon )
|
|||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
m_iconWindow = (GtkWidget*) NULL;
|
m_iconWindow = (GtkWidget*) NULL;
|
||||||
|
|
||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
@ -680,15 +658,15 @@ wxDropSource::wxDropSource( wxWindow *win, const wxIcon &icon )
|
|||||||
wxDropSource::wxDropSource( wxDataObject& data, wxWindow *win, const wxIcon &icon )
|
wxDropSource::wxDropSource( wxDataObject& data, wxWindow *win, const wxIcon &icon )
|
||||||
{
|
{
|
||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
SetData( data );
|
SetData( data );
|
||||||
|
|
||||||
m_iconWindow = (GtkWidget*) NULL;
|
m_iconWindow = (GtkWidget*) NULL;
|
||||||
|
|
||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
|
|
||||||
m_retValue = wxDragCancel;
|
m_retValue = wxDragCancel;
|
||||||
|
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
@ -725,9 +703,9 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context )
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
|
gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this );
|
||||||
|
|
||||||
gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
|
gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE);
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
|
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
|
||||||
|
|
||||||
@ -738,12 +716,12 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
{
|
{
|
||||||
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
|
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
|
||||||
|
|
||||||
if (!m_data)
|
if (!m_data)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
|
|
||||||
if (m_data->GetFormatCount() == 0)
|
if (m_data->GetFormatCount() == 0)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
|
|
||||||
g_blockEventsOnDrag = TRUE;
|
g_blockEventsOnDrag = TRUE;
|
||||||
|
|
||||||
RegisterWindow();
|
RegisterWindow();
|
||||||
@ -751,7 +729,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
m_waiting = TRUE;
|
m_waiting = TRUE;
|
||||||
|
|
||||||
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
||||||
|
|
||||||
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
|
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
|
||||||
m_data->GetAllFormats( array );
|
m_data->GetAllFormats( array );
|
||||||
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
||||||
@ -792,9 +770,9 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
(GdkDragAction)(GDK_ACTION_COPY|GDK_ACTION_MOVE),
|
(GdkDragAction)(GDK_ACTION_COPY|GDK_ACTION_MOVE),
|
||||||
button_number, /* number of mouse button which started drag */
|
button_number, /* number of mouse button which started drag */
|
||||||
(GdkEvent*) &event );
|
(GdkEvent*) &event );
|
||||||
|
|
||||||
m_dragContext = context;
|
m_dragContext = context;
|
||||||
|
|
||||||
PrepareIcon( 0, 0, context );
|
PrepareIcon( 0, 0, context );
|
||||||
|
|
||||||
while (m_waiting) gtk_main_iteration();;
|
while (m_waiting) gtk_main_iteration();;
|
||||||
|
@ -85,6 +85,11 @@ bool wxChoice::Create(wxWindow *parent,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxChoice::~wxChoice()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// adding/deleting items to/from the list
|
// adding/deleting items to/from the list
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -113,6 +118,13 @@ void wxChoice::Delete(int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::Clear()
|
void wxChoice::Clear()
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
|
SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxChoice::Free()
|
||||||
{
|
{
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
{
|
{
|
||||||
@ -122,8 +134,6 @@ void wxChoice::Clear()
|
|||||||
delete GetClientObject(n);
|
delete GetClientObject(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -216,7 +226,7 @@ void* wxChoice::DoGetItemClientData( int n ) const
|
|||||||
wxLogLastError(wxT("CB_GETITEMDATA"));
|
wxLogLastError(wxT("CB_GETITEMDATA"));
|
||||||
|
|
||||||
// unfortunately, there is no way to return an error code to the user
|
// unfortunately, there is no way to return an error code to the user
|
||||||
rc = (LPARAM) NULL;
|
rc = (LPARAM) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (void *)rc;
|
return (void *)rc;
|
||||||
|
@ -419,8 +419,6 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat,
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||||
|
|
||||||
wxClipboard* wxTheClipboard = (wxClipboard *)NULL;
|
|
||||||
|
|
||||||
wxClipboard::wxClipboard()
|
wxClipboard::wxClipboard()
|
||||||
{
|
{
|
||||||
m_clearOnExit = FALSE;
|
m_clearOnExit = FALSE;
|
||||||
|
@ -230,12 +230,7 @@ bool wxListBox::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
{
|
{
|
||||||
#if wxUSE_OWNER_DRAWN
|
Free();
|
||||||
size_t uiCount = m_aItems.Count();
|
|
||||||
while ( uiCount-- != 0 ) {
|
|
||||||
delete m_aItems[uiCount];
|
|
||||||
}
|
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetupColours()
|
void wxListBox::SetupColours()
|
||||||
@ -353,6 +348,15 @@ int wxListBox::FindString(const wxString& s) const
|
|||||||
|
|
||||||
void wxListBox::Clear()
|
void wxListBox::Clear()
|
||||||
{
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
|
ListBox_ResetContent(GetHwnd());
|
||||||
|
|
||||||
|
m_noItems = 0;
|
||||||
|
SetHorizontalExtent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::Free()
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
size_t uiCount = m_aItems.Count();
|
size_t uiCount = m_aItems.Count();
|
||||||
while ( uiCount-- != 0 ) {
|
while ( uiCount-- != 0 ) {
|
||||||
@ -369,11 +373,6 @@ void wxListBox::Clear()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||||
|
|
||||||
ListBox_ResetContent(GetHwnd());
|
|
||||||
|
|
||||||
m_noItems = 0;
|
|
||||||
SetHorizontalExtent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetSelection(int N, bool select)
|
void wxListBox::SetSelection(int N, bool select)
|
||||||
@ -655,44 +654,39 @@ wxSize wxListBox::DoGetBestSize()
|
|||||||
|
|
||||||
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
||||||
{
|
{
|
||||||
/*
|
if ( param == LBN_SELCHANGE )
|
||||||
if (param == LBN_SELCANCEL)
|
|
||||||
{
|
|
||||||
event.extraLong = FALSE;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (param == LBN_SELCHANGE)
|
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
wxArrayInt aSelections;
|
wxArrayInt aSelections;
|
||||||
int count = GetSelections(aSelections);
|
int n, count = GetSelections(aSelections);
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
event.m_commandInt = aSelections[0];
|
n = aSelections[0];
|
||||||
event.m_clientData = GetClientData(event.m_commandInt);
|
if ( HasClientObjectData() )
|
||||||
wxString str(GetString(event.m_commandInt));
|
event.SetClientObject( GetClientObject(n) );
|
||||||
if (str != wxT(""))
|
else if ( HasClientUntypedData() )
|
||||||
{
|
event.SetClientData( GetClientData(n) );
|
||||||
event.m_commandString = str;
|
event.SetString( GetString(n) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event.m_commandInt = -1;
|
n = -1;
|
||||||
event.m_commandString.Empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.SetEventObject( this );
|
event.m_commandInt = n;
|
||||||
ProcessCommand(event);
|
|
||||||
return TRUE;
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
else if (param == LBN_DBLCLK)
|
else if ( param == LBN_DBLCLK )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent(event);
|
|
||||||
return TRUE;
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
//else:
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -463,6 +463,12 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
|
|||||||
size = 0;
|
size = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CF_DIB:
|
||||||
|
// the handler will calculate size itself (it's too
|
||||||
|
// complicated to do it here)
|
||||||
|
size = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// we suppose that the size precedes the data
|
// we suppose that the size precedes the data
|
||||||
@ -944,64 +950,122 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData)
|
|||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// otherwise VC++ would give here:
|
static size_t wxGetNumOfBitmapColors(size_t bitsPerPixel)
|
||||||
// "local variable 'bi' may be used without having been initialized"
|
{
|
||||||
// even though in fact it may not
|
switch ( bitsPerPixel )
|
||||||
#ifdef __VISUALC__
|
{
|
||||||
#pragma warning(disable:4701)
|
case 1:
|
||||||
#endif // __VISUALC__
|
// monochrome bitmap, 2 entries
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
return 16;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
return 256;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
// may be used with 24bit bitmaps, but we don't use it here - fall
|
||||||
|
// through
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
case 32:
|
||||||
|
// bmiColors not used at all with these bitmaps
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( wxT("unknown bitmap format") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap)
|
size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( bitmap.Ok(), wxT("invalid bmp can't be converted to DIB") );
|
||||||
|
|
||||||
// shouldn't be selected into a DC or GetDIBits() would fail
|
// shouldn't be selected into a DC or GetDIBits() would fail
|
||||||
wxASSERT_MSG( !bitmap.GetSelectedInto(),
|
wxASSERT_MSG( !bitmap.GetSelectedInto(),
|
||||||
wxT("can't copy bitmap selected into wxMemoryDC") );
|
wxT("can't copy bitmap selected into wxMemoryDC") );
|
||||||
|
|
||||||
|
// prepare all the info we need
|
||||||
|
BITMAP bm;
|
||||||
HBITMAP hbmp = (HBITMAP)bitmap.GetHBITMAP();
|
HBITMAP hbmp = (HBITMAP)bitmap.GetHBITMAP();
|
||||||
|
if ( !GetObject(hbmp, sizeof(bm), &bm) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetObject(bitmap)");
|
||||||
|
|
||||||
BITMAPINFO bi;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// first get the info
|
// calculate the number of bits per pixel and the number of items in
|
||||||
|
// bmiColors array (whose meaning depends on the bitmap format)
|
||||||
|
WORD biBits = bm.bmPlanes * bm.bmBitsPixel;
|
||||||
|
WORD biColors = wxGetNumOfBitmapColors(biBits);
|
||||||
|
|
||||||
|
BITMAPINFO bi2;
|
||||||
|
|
||||||
|
bool wantSizeOnly = pbi == NULL;
|
||||||
|
if ( wantSizeOnly )
|
||||||
|
pbi = &bi2;
|
||||||
|
|
||||||
|
// just for convenience
|
||||||
|
BITMAPINFOHEADER& bi = pbi->bmiHeader;
|
||||||
|
|
||||||
|
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
bi.biWidth = bm.bmWidth;
|
||||||
|
bi.biHeight = bm.bmHeight;
|
||||||
|
bi.biPlanes = 1;
|
||||||
|
bi.biBitCount = biBits;
|
||||||
|
bi.biCompression = BI_RGB;
|
||||||
|
bi.biSizeImage = 0;
|
||||||
|
bi.biXPelsPerMeter = 0;
|
||||||
|
bi.biYPelsPerMeter = 0;
|
||||||
|
bi.biClrUsed = 0;
|
||||||
|
bi.biClrImportant = 0;
|
||||||
|
|
||||||
|
// memory we need for BITMAPINFO only
|
||||||
|
DWORD dwLen = bi.biSize + biColors * sizeof(RGBQUAD);
|
||||||
|
|
||||||
|
// first get the image size
|
||||||
ScreenHDC hdc;
|
ScreenHDC hdc;
|
||||||
if ( !GetDIBits(hdc, hbmp, 0, 0, NULL, pbi ? pbi : &bi, DIB_RGB_COLORS) )
|
if ( !GetDIBits(hdc, hbmp, 0, bi.biHeight, NULL, pbi, DIB_RGB_COLORS) )
|
||||||
{
|
{
|
||||||
wxLogLastError("GetDIBits(NULL)");
|
wxLogLastError("GetDIBits(NULL)");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !pbi )
|
if ( wantSizeOnly )
|
||||||
{
|
{
|
||||||
// we were only asked for size needed for the buffer, not to actually
|
// size of the header + size of the image
|
||||||
// copy the data
|
return dwLen + bi.biSizeImage;
|
||||||
return sizeof(BITMAPINFO) + bi.bmiHeader.biSizeImage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// and now copy the bits
|
// and now copy the bits
|
||||||
if ( !GetDIBits(hdc, hbmp, 0, pbi->bmiHeader.biHeight, pbi + 1,
|
void *image = (char *)pbi + dwLen;
|
||||||
pbi, DIB_RGB_COLORS) )
|
if ( !GetDIBits(hdc, hbmp, 0, bi.biHeight, image, pbi, DIB_RGB_COLORS) )
|
||||||
{
|
{
|
||||||
wxLogLastError("GetDIBits");
|
wxLogLastError("GetDIBits");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sizeof(BITMAPINFO) + pbi->bmiHeader.biSizeImage;
|
return dwLen + bi.biSizeImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __VISUALC__
|
|
||||||
#pragma warning(default:4701)
|
|
||||||
#endif // __VISUALC__
|
|
||||||
|
|
||||||
wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *pbmi)
|
wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *pbmi)
|
||||||
{
|
{
|
||||||
// here we get BITMAPINFO struct followed by the actual bitmap bits and
|
// here we get BITMAPINFO struct followed by the actual bitmap bits and
|
||||||
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
|
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
|
||||||
const BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
|
const BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
|
||||||
|
|
||||||
|
// offset of image from the beginning of the header
|
||||||
|
DWORD ofs = wxGetNumOfBitmapColors(pbmih->biBitCount) * sizeof(RGBQUAD);
|
||||||
|
void *image = (char *)pbmih + sizeof(BITMAPINFOHEADER) + ofs;
|
||||||
|
|
||||||
ScreenHDC hdc;
|
ScreenHDC hdc;
|
||||||
HBITMAP hbmp = CreateDIBitmap(hdc, pbmih, CBM_INIT,
|
HBITMAP hbmp = CreateDIBitmap(hdc, pbmih, CBM_INIT,
|
||||||
pbmi + 1, pbmi, DIB_RGB_COLORS);
|
image, pbmi, DIB_RGB_COLORS);
|
||||||
if ( !hbmp )
|
if ( !hbmp )
|
||||||
{
|
{
|
||||||
wxLogLastError("CreateDIBitmap");
|
wxLogLastError("CreateDIBitmap");
|
||||||
|
@ -60,23 +60,28 @@
|
|||||||
class wxIDropTarget : public IDropTarget
|
class wxIDropTarget : public IDropTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxIDropTarget(wxDropTarget *p);
|
wxIDropTarget(wxDropTarget *p);
|
||||||
~wxIDropTarget();
|
~wxIDropTarget();
|
||||||
|
|
||||||
// IDropTarget methods
|
// accessors for wxDropTarget
|
||||||
STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
void SetHwnd(HWND hwnd) { m_hwnd = hwnd; }
|
||||||
STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
|
|
||||||
STDMETHODIMP DragLeave(void);
|
|
||||||
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
|
||||||
|
|
||||||
DECLARE_IUNKNOWN_METHODS;
|
// IDropTarget methods
|
||||||
|
STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
||||||
|
STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
|
||||||
|
STDMETHODIMP DragLeave();
|
||||||
|
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
||||||
|
|
||||||
|
DECLARE_IUNKNOWN_METHODS;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IDataObject *m_pIDataObject; // !NULL between DragEnter and DragLeave/Drop
|
IDataObject *m_pIDataObject; // !NULL between DragEnter and DragLeave/Drop
|
||||||
wxDropTarget *m_pTarget; // the real target (we're just a proxy)
|
wxDropTarget *m_pTarget; // the real target (we're just a proxy)
|
||||||
|
|
||||||
private:
|
HWND m_hwnd; // window we're associated with
|
||||||
static inline DWORD GetDropEffect(DWORD flags);
|
|
||||||
|
// get default drop effect for given keyboard flags
|
||||||
|
static inline DWORD GetDropEffect(DWORD flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -90,7 +95,7 @@ static DWORD ConvertDragResultToEffect(wxDragResult result);
|
|||||||
// wxIDropTarget implementation
|
// wxIDropTarget implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// Name : static wxDropTarget::GetDropEffect
|
// Name : static wxIDropTarget::GetDropEffect
|
||||||
// Purpose : determine the drop operation from keyboard/mouse state.
|
// Purpose : determine the drop operation from keyboard/mouse state.
|
||||||
// Returns : DWORD combined from DROPEFFECT_xxx constants
|
// Returns : DWORD combined from DROPEFFECT_xxx constants
|
||||||
// Params : [in] DWORD flags kbd & mouse flags as passed to
|
// Params : [in] DWORD flags kbd & mouse flags as passed to
|
||||||
@ -134,31 +139,35 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
|||||||
POINTL pt,
|
POINTL pt,
|
||||||
DWORD *pdwEffect)
|
DWORD *pdwEffect)
|
||||||
{
|
{
|
||||||
wxLogDebug(wxT("IDropTarget::DragEnter"));
|
wxLogDebug(wxT("IDropTarget::DragEnter"));
|
||||||
|
|
||||||
wxASSERT( m_pIDataObject == NULL );
|
wxASSERT( m_pIDataObject == NULL );
|
||||||
|
|
||||||
if ( !m_pTarget->IsAcceptedData(pIDataSource) ) {
|
if ( !m_pTarget->IsAcceptedData(pIDataSource) ) {
|
||||||
// we don't accept this kind of data
|
// we don't accept this kind of data
|
||||||
*pdwEffect = DROPEFFECT_NONE;
|
*pdwEffect = DROPEFFECT_NONE;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get hold of the data object
|
||||||
|
m_pIDataObject = pIDataSource;
|
||||||
|
m_pIDataObject->AddRef();
|
||||||
|
|
||||||
|
// we need client coordinates to pass to wxWin functions
|
||||||
|
if ( !ScreenToClient(m_hwnd, (POINT *)&pt) )
|
||||||
|
{
|
||||||
|
wxLogLastError("ScreenToClient");
|
||||||
|
}
|
||||||
|
|
||||||
|
// give some visual feedback
|
||||||
|
*pdwEffect = ConvertDragResultToEffect(
|
||||||
|
m_pTarget->OnEnter(pt.x, pt.y,
|
||||||
|
ConvertDragEffectToResult(GetDropEffect(grfKeyState))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
|
||||||
|
|
||||||
// get hold of the data object
|
|
||||||
m_pIDataObject = pIDataSource;
|
|
||||||
m_pIDataObject->AddRef();
|
|
||||||
|
|
||||||
// give some visual feedback
|
|
||||||
*pdwEffect = ConvertDragResultToEffect(
|
|
||||||
m_pTarget->OnEnter(pt.x, pt.y,
|
|
||||||
ConvertDragEffectToResult(
|
|
||||||
GetDropEffect(grfKeyState)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name : wxIDropTarget::DragOver
|
// Name : wxIDropTarget::DragOver
|
||||||
@ -174,22 +183,28 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
|||||||
POINTL pt,
|
POINTL pt,
|
||||||
LPDWORD pdwEffect)
|
LPDWORD pdwEffect)
|
||||||
{
|
{
|
||||||
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
|
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
|
||||||
|
|
||||||
wxDragResult result;
|
wxDragResult result;
|
||||||
if ( m_pIDataObject ) {
|
if ( m_pIDataObject ) {
|
||||||
result = ConvertDragEffectToResult(GetDropEffect(grfKeyState));
|
result = ConvertDragEffectToResult(GetDropEffect(grfKeyState));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// can't accept data anyhow normally
|
// can't accept data anyhow normally
|
||||||
result = wxDragNone;
|
result = wxDragNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pdwEffect = ConvertDragResultToEffect(
|
// we need client coordinates to pass to wxWin functions
|
||||||
m_pTarget->OnDragOver(pt.x, pt.y, result)
|
if ( !ScreenToClient(m_hwnd, (POINT *)&pt) )
|
||||||
);
|
{
|
||||||
|
wxLogLastError("ScreenToClient");
|
||||||
|
}
|
||||||
|
|
||||||
return S_OK;
|
*pdwEffect = ConvertDragResultToEffect(
|
||||||
|
m_pTarget->OnDragOver(pt.x, pt.y, result)
|
||||||
|
);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name : wxIDropTarget::DragLeave
|
// Name : wxIDropTarget::DragLeave
|
||||||
@ -232,15 +247,23 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
|||||||
// by default, nothing happens
|
// by default, nothing happens
|
||||||
*pdwEffect = DROPEFFECT_NONE;
|
*pdwEffect = DROPEFFECT_NONE;
|
||||||
|
|
||||||
|
// we need client coordinates to pass to wxWin functions
|
||||||
|
if ( !ScreenToClient(m_hwnd, (POINT *)&pt) )
|
||||||
|
{
|
||||||
|
wxLogLastError("ScreenToClient");
|
||||||
|
}
|
||||||
|
|
||||||
// first ask the drop target if it wants data
|
// first ask the drop target if it wants data
|
||||||
if ( m_pTarget->OnDrop(pt.x, pt.y) ) {
|
if ( m_pTarget->OnDrop(pt.x, pt.y) ) {
|
||||||
// it does, so give it the data source
|
// it does, so give it the data source
|
||||||
m_pTarget->SetDataSource(pIDataSource);
|
m_pTarget->SetDataSource(pIDataSource);
|
||||||
|
|
||||||
// and now it has the data
|
// and now it has the data
|
||||||
if ( m_pTarget->OnData(pt.x, pt.y) ) {
|
wxDragResult rc = ConvertDragEffectToResult(GetDropEffect(grfKeyState));
|
||||||
|
rc = m_pTarget->OnData(pt.x, pt.y, rc);
|
||||||
|
if ( wxIsDragResultOk(rc) ) {
|
||||||
// operation succeeded
|
// operation succeeded
|
||||||
*pdwEffect = GetDropEffect(grfKeyState);
|
*pdwEffect = ConvertDragResultToEffect(rc);
|
||||||
}
|
}
|
||||||
//else: *pdwEffect is already DROPEFFECT_NONE
|
//else: *pdwEffect is already DROPEFFECT_NONE
|
||||||
}
|
}
|
||||||
@ -294,6 +317,9 @@ bool wxDropTarget::Register(WXHWND hwnd)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we will need the window handle for coords transformation later
|
||||||
|
m_pIDropTarget->SetHwnd((HWND)hwnd);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +332,8 @@ void wxDropTarget::Revoke(WXHWND hwnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
::CoLockObjectExternal(m_pIDropTarget, FALSE, TRUE);
|
::CoLockObjectExternal(m_pIDropTarget, FALSE, TRUE);
|
||||||
|
|
||||||
|
m_pIDropTarget->SetHwnd(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -420,41 +448,6 @@ wxDataFormat wxDropTarget::GetSupportedFormat(IDataObject *pIDataSource) const
|
|||||||
return n < nFormats ? format : wxFormatInvalid;
|
return n < nFormats ? format : wxFormatInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxTextDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxTextDropTarget::wxTextDropTarget()
|
|
||||||
: wxDropTarget(new wxTextDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxTextDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropText(x, y, ((wxTextDataObject *)m_dataObject)->GetText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxFileDropTarget
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxFileDropTarget::wxFileDropTarget()
|
|
||||||
: wxDropTarget(new wxFileDataObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxFileDropTarget::OnData(wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
if ( !GetData() )
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return OnDropFiles(x, y,
|
|
||||||
((wxFileDataObject *)m_dataObject)->GetFilenames());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user