wxPrivateDataObject works under MSW as well (hopefully it still does under
GTK too) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2578 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,19 +1,142 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: dataobj.h
|
||||||
|
// Purpose: common data object classes
|
||||||
|
// Author: Robert Roebling, Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 26.05.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows Team
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_DATAOBJ_H_BASE_
|
#ifndef _WX_DATAOBJ_H_BASE_
|
||||||
#define _WX_DATAOBJ_H_BASE_
|
#define _WX_DATAOBJ_H_BASE_
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
#include "wx/msw/ole/dataobj.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDataFormat identifies the single format of data
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDataFormat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// the clipboard formats under Win32 are UINTs
|
||||||
|
typedef unsigned int NativeFormat;
|
||||||
|
|
||||||
|
wxDataFormat(NativeFormat format = wxDF_INVALID) { m_format = format; }
|
||||||
|
wxDataFormat& operator=(NativeFormat format)
|
||||||
|
{ m_format = format; return *this; }
|
||||||
|
|
||||||
|
// defautl copy ctor/assignment operators ok
|
||||||
|
|
||||||
|
// comparison (must have both versions)
|
||||||
|
bool operator==(wxDataFormatId format) const
|
||||||
|
{ return m_format == (NativeFormat)format; }
|
||||||
|
bool operator!=(wxDataFormatId format) const
|
||||||
|
{ return m_format != (NativeFormat)format; }
|
||||||
|
bool operator==(const wxDataFormat& format) const
|
||||||
|
{ return m_format == format.m_format; }
|
||||||
|
bool operator!=(const wxDataFormat& format) const
|
||||||
|
{ return m_format != format.m_format; }
|
||||||
|
|
||||||
|
// explicit and implicit conversions to NativeFormat which is one of
|
||||||
|
// standard data types (implicit conversion is useful for preserving the
|
||||||
|
// compatibility with old code)
|
||||||
|
NativeFormat GetFormatId() const { return m_format; }
|
||||||
|
operator NativeFormat() const { return m_format; }
|
||||||
|
|
||||||
|
// this only works with standard ids
|
||||||
|
void SetId(wxDataFormatId format) { m_format = format; }
|
||||||
|
|
||||||
|
// string ids are used for custom types - this SetId() must be used for
|
||||||
|
// application-specific formats
|
||||||
|
wxString GetId() const;
|
||||||
|
void SetId(const wxChar *format);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// returns TRUE if the format is one of those defined in wxDataFormatId
|
||||||
|
bool IsStandard() const { return m_format > 0 && m_format < wxDF_MAX; }
|
||||||
|
|
||||||
|
NativeFormat m_format;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "wx/msw/ole/dataobj.h"
|
||||||
#elif defined(__WXMOTIF__)
|
#elif defined(__WXMOTIF__)
|
||||||
#include "wx/motif/dataobj.h"
|
#include "wx/motif/dataobj.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
#include "wx/gtk/dataobj.h"
|
#include "wx/gtk/dataobj.h"
|
||||||
#elif defined(__WXQT__)
|
#elif defined(__WXQT__)
|
||||||
#include "wx/qt/dnd.h"
|
#include "wx/qt/dnd.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#include "wx/mac/dnd.h"
|
#include "wx/mac/dnd.h"
|
||||||
#elif defined(__WXSTUBS__)
|
#elif defined(__WXSTUBS__)
|
||||||
#include "wx/stubs/dnd.h"
|
#include "wx/stubs/dnd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxPrivateDataObject is a specialization of wxDataObject for app specific
|
||||||
|
// data (of some given kind, derive directly from wxDataObject if you wish to
|
||||||
|
// efficiently support multiple formats)
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxPrivateDataObject : public wxDataObject
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxPrivateDataObject();
|
||||||
|
virtual ~wxPrivateDataObject() { Free(); }
|
||||||
|
|
||||||
|
// get the format object - it is used to decide whether we support the
|
||||||
|
// given output format or not
|
||||||
|
wxDataFormat& GetFormat() { return m_format; }
|
||||||
|
|
||||||
|
// set data. will make copy of the data
|
||||||
|
void SetData( const void *data, size_t size );
|
||||||
|
|
||||||
|
// returns pointer to data
|
||||||
|
void *GetData() const { return m_data; }
|
||||||
|
|
||||||
|
// get the size of the data
|
||||||
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
|
// copy data to the given buffer
|
||||||
|
virtual void WriteData( void *dest ) const;
|
||||||
|
|
||||||
|
// these functions are provided for wxGTK compatibility, their usage is
|
||||||
|
// deprecated - use GetFormat().SetId() instead
|
||||||
|
void SetId( const wxString& id ) { m_format.SetId(id); }
|
||||||
|
wxString GetId() const { return m_format.GetId(); }
|
||||||
|
|
||||||
|
// implement the base class pure virtuals
|
||||||
|
virtual wxDataFormat GetPreferredFormat() const
|
||||||
|
{ return m_format; }
|
||||||
|
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||||
|
{ return m_format == format; }
|
||||||
|
virtual size_t GetDataSize() const
|
||||||
|
{ return m_size; }
|
||||||
|
virtual void GetDataHere(void *dest) const
|
||||||
|
{ WriteData(dest); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// the function which really copies the data - called by WriteData() above
|
||||||
|
// and uses GetSize() to get the size of the data
|
||||||
|
//
|
||||||
|
// VZ: I really wonder why do we need it
|
||||||
|
void WriteData( const void *data, void *dest ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// free the data
|
||||||
|
inline void Free();
|
||||||
|
|
||||||
|
// the data
|
||||||
|
size_t m_size;
|
||||||
|
void *m_data;
|
||||||
|
|
||||||
|
// the data format
|
||||||
|
wxDataFormat m_format;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_DATAOBJ_H_BASE_
|
// _WX_DATAOBJ_H_BASE_
|
||||||
|
@@ -109,7 +109,7 @@
|
|||||||
// Currently Only MS-Windows/NT, XView and Motif are supported
|
// Currently Only MS-Windows/NT, XView and Motif are supported
|
||||||
//
|
//
|
||||||
#if defined(__HPUX__) && !defined(__WXGTK__)
|
#if defined(__HPUX__) && !defined(__WXGTK__)
|
||||||
#ifndef __WXMOTIF__
|
#ifndef __WXMOTIF__
|
||||||
#define __WXMOTIF__
|
#define __WXMOTIF__
|
||||||
#endif // __WXMOTIF__
|
#endif // __WXMOTIF__
|
||||||
#endif
|
#endif
|
||||||
@@ -408,7 +408,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
|
|||||||
#define wxMINIMIZE wxICONIZE
|
#define wxMINIMIZE wxICONIZE
|
||||||
#define wxMAXIMIZE 0x2000
|
#define wxMAXIMIZE 0x2000
|
||||||
#define wxTHICK_FRAME 0x1000
|
#define wxTHICK_FRAME 0x1000
|
||||||
#define wxSYSTEM_MENU 0x0800
|
#define wxSYSTEM_MENU 0x0800
|
||||||
#define wxMINIMIZE_BOX 0x0400
|
#define wxMINIMIZE_BOX 0x0400
|
||||||
#define wxMAXIMIZE_BOX 0x0200
|
#define wxMAXIMIZE_BOX 0x0200
|
||||||
#define wxTINY_CAPTION_HORIZ 0x0100
|
#define wxTINY_CAPTION_HORIZ 0x0100
|
||||||
@@ -432,7 +432,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
|
|||||||
#else
|
#else
|
||||||
// Under Unix, the dialogs don't have a system menu. Specifying
|
// Under Unix, the dialogs don't have a system menu. Specifying
|
||||||
// wxSYSTEM_MENU here, will make a close button appear.
|
// wxSYSTEM_MENU here, will make a close button appear.
|
||||||
# define wxDEFAULT_DIALOG_STYLE (wxCAPTION)
|
# define wxDEFAULT_DIALOG_STYLE (wxCAPTION)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -778,9 +778,7 @@ typedef enum
|
|||||||
// Don't do parent client adjustments (for implementation only)
|
// Don't do parent client adjustments (for implementation only)
|
||||||
#define wxSIZE_NO_ADJUSTMENTS 0x0008
|
#define wxSIZE_NO_ADJUSTMENTS 0x0008
|
||||||
|
|
||||||
#ifndef __WXGTK__
|
enum wxDataFormatId
|
||||||
|
|
||||||
enum wxDataFormat
|
|
||||||
{
|
{
|
||||||
wxDF_INVALID = 0,
|
wxDF_INVALID = 0,
|
||||||
wxDF_TEXT = 1, /* CF_TEXT */
|
wxDF_TEXT = 1, /* CF_TEXT */
|
||||||
@@ -799,11 +797,10 @@ enum wxDataFormat
|
|||||||
wxDF_ENHMETAFILE = 14,
|
wxDF_ENHMETAFILE = 14,
|
||||||
wxDF_FILENAME = 15, /* CF_HDROP */
|
wxDF_FILENAME = 15, /* CF_HDROP */
|
||||||
wxDF_LOCALE = 16,
|
wxDF_LOCALE = 16,
|
||||||
wxDF_PRIVATE = 20
|
wxDF_PRIVATE = 20,
|
||||||
|
wxDF_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Virtual keycodes */
|
/* Virtual keycodes */
|
||||||
|
|
||||||
enum wxKeyCode
|
enum wxKeyCode
|
||||||
@@ -884,7 +881,7 @@ enum wxKeyCode
|
|||||||
WXK_SCROLL,
|
WXK_SCROLL,
|
||||||
WXK_PAGEUP,
|
WXK_PAGEUP,
|
||||||
WXK_PAGEDOWN,
|
WXK_PAGEDOWN,
|
||||||
|
|
||||||
WXK_NUMPAD_SPACE,
|
WXK_NUMPAD_SPACE,
|
||||||
WXK_NUMPAD_TAB,
|
WXK_NUMPAD_TAB,
|
||||||
WXK_NUMPAD_ENTER,
|
WXK_NUMPAD_ENTER,
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
#define _WX_DND_H_BASE_
|
#define _WX_DND_H_BASE_
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
#include "wx/dataobj.h"
|
||||||
#include "wx/msw/ole/dropsrc.h"
|
#include "wx/msw/ole/dropsrc.h"
|
||||||
#include "wx/msw/ole/droptgt.h"
|
#include "wx/msw/ole/droptgt.h"
|
||||||
#include "wx/msw/ole/dataobj.h"
|
|
||||||
#elif defined(__WXMOTIF__)
|
#elif defined(__WXMOTIF__)
|
||||||
#include "wx/motif/dnd.h"
|
#include "wx/motif/dnd.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
|
@@ -31,63 +31,42 @@ class wxBitmapDataObject;
|
|||||||
class wxPrivateDataObject;
|
class wxPrivateDataObject;
|
||||||
class wxFileDataObject;
|
class wxFileDataObject;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
// wxDataType (internal)
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
enum wxDataType
|
|
||||||
{
|
|
||||||
wxDF_INVALID = 0,
|
|
||||||
wxDF_TEXT = 1, /* CF_TEXT */
|
|
||||||
wxDF_BITMAP = 2, /* CF_BITMAP */
|
|
||||||
wxDF_METAFILE = 3, /* CF_METAFILEPICT */
|
|
||||||
wxDF_SYLK = 4,
|
|
||||||
wxDF_DIF = 5,
|
|
||||||
wxDF_TIFF = 6,
|
|
||||||
wxDF_OEMTEXT = 7, /* CF_OEMTEXT */
|
|
||||||
wxDF_DIB = 8, /* CF_DIB */
|
|
||||||
wxDF_PALETTE = 9,
|
|
||||||
wxDF_PENDATA = 10,
|
|
||||||
wxDF_RIFF = 11,
|
|
||||||
wxDF_WAVE = 12,
|
|
||||||
wxDF_UNICODETEXT = 13,
|
|
||||||
wxDF_ENHMETAFILE = 14,
|
|
||||||
wxDF_FILENAME = 15, /* CF_HDROP */
|
|
||||||
wxDF_LOCALE = 16,
|
|
||||||
wxDF_PRIVATE = 20
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// wxDataFormat (internal)
|
// wxDataFormat (internal)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxDataFormat : public wxObject
|
class wxDataFormat : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_CLASS( wxDataFormat )
|
DECLARE_CLASS( wxDataFormat )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxDataFormat();
|
||||||
wxDataFormat();
|
wxDataFormat( wxDataFormatId type );
|
||||||
wxDataFormat( wxDataType type );
|
wxDataFormat( const wxString &id );
|
||||||
wxDataFormat( const wxString &id );
|
wxDataFormat( const wxChar *id );
|
||||||
wxDataFormat( const wxChar *id );
|
wxDataFormat( wxDataFormat &format );
|
||||||
wxDataFormat( wxDataFormat &format );
|
wxDataFormat( const GdkAtom atom );
|
||||||
wxDataFormat( const GdkAtom atom );
|
|
||||||
|
void SetType( wxDataFormatId type );
|
||||||
|
wxDataFormatId GetType() const;
|
||||||
|
|
||||||
|
/* the string Id identifies the format of clipboard or DnD data. a word
|
||||||
|
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
||||||
|
* to the clipboard - the latter with the Id "application/wxword", an
|
||||||
|
* image manipulation program would put a wxBitmapDataObject and a
|
||||||
|
* wxPrivateDataObject to the clipboard - the latter with "image/png". */
|
||||||
|
|
||||||
|
wxString GetId() const;
|
||||||
|
void SetId( const wxChar *id );
|
||||||
|
|
||||||
|
GdkAtom GetAtom();
|
||||||
|
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
||||||
|
|
||||||
void SetType( wxDataType type );
|
|
||||||
wxDataType GetType() const;
|
|
||||||
|
|
||||||
wxString GetId() const;
|
|
||||||
void SetId( const wxChar *id );
|
|
||||||
|
|
||||||
GdkAtom GetAtom();
|
|
||||||
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
|
||||||
private:
|
private:
|
||||||
|
wxDataFormatId m_type;
|
||||||
wxDataType m_type;
|
wxString m_id;
|
||||||
wxString m_id;
|
bool m_hasAtom;
|
||||||
bool m_hasAtom;
|
GdkAtom m_atom;
|
||||||
GdkAtom m_atom;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -102,36 +81,36 @@ public:
|
|||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxDataBroker();
|
wxDataBroker();
|
||||||
|
|
||||||
/* add data object */
|
/* add data object */
|
||||||
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* OLE implementation, the methods don't need to be overridden */
|
/* OLE implementation, the methods don't need to be overridden */
|
||||||
|
|
||||||
/* get number of supported formats */
|
/* get number of supported formats */
|
||||||
virtual size_t GetFormatCount() const;
|
virtual size_t GetFormatCount() const;
|
||||||
|
|
||||||
/* return nth supported format */
|
/* return nth supported format */
|
||||||
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
||||||
|
|
||||||
/* return preferrd/best supported format */
|
/* return preferrd/best supported format */
|
||||||
virtual wxDataFormat &GetPreferredFormat() const;
|
virtual wxDataFormat &GetPreferredFormat() const;
|
||||||
|
|
||||||
/* search through m_dataObjects, return TRUE if found */
|
/* search through m_dataObjects, return TRUE if found */
|
||||||
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
||||||
|
|
||||||
/* search through m_dataObjects and call child's GetSize() */
|
/* search through m_dataObjects and call child's GetSize() */
|
||||||
virtual size_t GetSize( wxDataFormat& format ) const;
|
virtual size_t GetSize( wxDataFormat& format ) const;
|
||||||
|
|
||||||
/* search through m_dataObjects and call child's WriteData(dest) */
|
/* search through m_dataObjects and call child's WriteData(dest) */
|
||||||
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wxList m_dataObjects;
|
wxList m_dataObjects;
|
||||||
size_t m_preferred;
|
size_t m_preferred;
|
||||||
};
|
};
|
||||||
@@ -143,29 +122,29 @@ public:
|
|||||||
class wxDataObject : public wxObject
|
class wxDataObject : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxDataObject();
|
wxDataObject();
|
||||||
|
|
||||||
/* destructor */
|
/* destructor */
|
||||||
~wxDataObject();
|
~wxDataObject();
|
||||||
|
|
||||||
/* write data to dest */
|
/* write data to dest */
|
||||||
virtual void WriteData( void *dest ) const = 0;
|
virtual void WriteData( void *dest ) const = 0;
|
||||||
|
|
||||||
/* get size of data */
|
/* get size of data */
|
||||||
virtual size_t GetSize() const = 0;
|
virtual size_t GetSize() const = 0;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxDataFormat &GetFormat();
|
wxDataFormat &GetFormat();
|
||||||
|
|
||||||
wxDataType GetFormatType() const;
|
wxDataFormatId GetFormatType() const;
|
||||||
wxString GetFormatId() const;
|
wxString GetFormatId() const;
|
||||||
GdkAtom GetFormatAtom() const;
|
GdkAtom GetFormatAtom() const;
|
||||||
|
|
||||||
wxDataFormat m_format;
|
wxDataFormat m_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -182,27 +161,27 @@ public:
|
|||||||
/* default constructor. call SetText() later or override
|
/* default constructor. call SetText() later or override
|
||||||
WriteData() and GetSize() for working on-demand */
|
WriteData() and GetSize() for working on-demand */
|
||||||
wxTextDataObject();
|
wxTextDataObject();
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxTextDataObject( const wxString& data );
|
wxTextDataObject( const wxString& data );
|
||||||
|
|
||||||
/* set current text data */
|
/* set current text data */
|
||||||
void SetText( const wxString& data );
|
void SetText( const wxString& data );
|
||||||
|
|
||||||
/* get current text data */
|
/* get current text data */
|
||||||
wxString GetText() const;
|
wxString GetText() const;
|
||||||
|
|
||||||
/* by default calls WriteString() with string set by constructor or
|
/* by default calls WriteString() with string set by constructor or
|
||||||
by SetText(). can be overridden for working on-demand */
|
by SetText(). can be overridden for working on-demand */
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
|
|
||||||
/* by default, returns length of string as set by constructor or
|
/* by default, returns length of string as set by constructor or
|
||||||
by SetText(). can be overridden for working on-demand */
|
by SetText(). can be overridden for working on-demand */
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
/* write string to dest */
|
/* write string to dest */
|
||||||
void WriteString( const wxString &str, void *dest ) const;
|
void WriteString( const wxString &str, void *dest ) const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxString m_data;
|
wxString m_data;
|
||||||
@@ -220,20 +199,20 @@ public:
|
|||||||
|
|
||||||
/* default constructor */
|
/* default constructor */
|
||||||
wxFileDataObject();
|
wxFileDataObject();
|
||||||
|
|
||||||
/* add file name to list */
|
/* add file name to list */
|
||||||
void AddFile( const wxString &file );
|
void AddFile( const wxString &file );
|
||||||
|
|
||||||
/* get all filename as one string. each file name is 0 terminated,
|
/* get all filename as one string. each file name is 0 terminated,
|
||||||
the list is double zero terminated */
|
the list is double zero terminated */
|
||||||
wxString GetFiles() const;
|
wxString GetFiles() const;
|
||||||
|
|
||||||
/* write list of filenames */
|
/* write list of filenames */
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
|
|
||||||
/* return length of list of filenames */
|
/* return length of list of filenames */
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxString m_files;
|
wxString m_files;
|
||||||
@@ -253,66 +232,21 @@ public:
|
|||||||
|
|
||||||
wxBitmapDataObject();
|
wxBitmapDataObject();
|
||||||
wxBitmapDataObject( const wxBitmap& bitmap );
|
wxBitmapDataObject( const wxBitmap& bitmap );
|
||||||
|
|
||||||
void SetBitmap( const wxBitmap &bitmap );
|
void SetBitmap( const wxBitmap &bitmap );
|
||||||
wxBitmap GetBitmap() const;
|
wxBitmap GetBitmap() const;
|
||||||
|
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
wxBitmap m_bitmap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
#endif
|
||||||
// wxPrivateDataObject is a specialization of wxDataObject for app specific data
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxPrivateDataObject : public wxDataObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/* see wxTextDataObject for explanation of functions */
|
|
||||||
|
|
||||||
wxPrivateDataObject();
|
|
||||||
~wxPrivateDataObject();
|
|
||||||
|
|
||||||
/* the string Id identifies the format of clipboard or DnD data. a word
|
|
||||||
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
|
||||||
* to the clipboard - the latter with the Id "application/wxword", an
|
|
||||||
* image manipulation program would put a wxBitmapDataObject and a
|
|
||||||
* wxPrivateDataObject to the clipboard - the latter with "image/png". */
|
|
||||||
|
|
||||||
void SetId( const wxString& id );
|
|
||||||
|
|
||||||
/* get id */
|
|
||||||
wxString GetId() const;
|
|
||||||
|
|
||||||
/* set data. will make internal copy. */
|
|
||||||
void SetData( const char *data, size_t size );
|
|
||||||
|
|
||||||
/* returns pointer to data */
|
|
||||||
char* GetData() const;
|
|
||||||
|
|
||||||
virtual void WriteData( void *dest ) const;
|
|
||||||
virtual size_t GetSize() const;
|
|
||||||
|
|
||||||
void WriteData( const char *data, void *dest ) const;
|
|
||||||
|
|
||||||
// implementation
|
|
||||||
|
|
||||||
size_t m_size;
|
|
||||||
char* m_data;
|
|
||||||
wxString m_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
//__GTKDNDH__
|
//__GTKDNDH__
|
||||||
|
|
||||||
|
@@ -31,63 +31,42 @@ class wxBitmapDataObject;
|
|||||||
class wxPrivateDataObject;
|
class wxPrivateDataObject;
|
||||||
class wxFileDataObject;
|
class wxFileDataObject;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
// wxDataType (internal)
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
enum wxDataType
|
|
||||||
{
|
|
||||||
wxDF_INVALID = 0,
|
|
||||||
wxDF_TEXT = 1, /* CF_TEXT */
|
|
||||||
wxDF_BITMAP = 2, /* CF_BITMAP */
|
|
||||||
wxDF_METAFILE = 3, /* CF_METAFILEPICT */
|
|
||||||
wxDF_SYLK = 4,
|
|
||||||
wxDF_DIF = 5,
|
|
||||||
wxDF_TIFF = 6,
|
|
||||||
wxDF_OEMTEXT = 7, /* CF_OEMTEXT */
|
|
||||||
wxDF_DIB = 8, /* CF_DIB */
|
|
||||||
wxDF_PALETTE = 9,
|
|
||||||
wxDF_PENDATA = 10,
|
|
||||||
wxDF_RIFF = 11,
|
|
||||||
wxDF_WAVE = 12,
|
|
||||||
wxDF_UNICODETEXT = 13,
|
|
||||||
wxDF_ENHMETAFILE = 14,
|
|
||||||
wxDF_FILENAME = 15, /* CF_HDROP */
|
|
||||||
wxDF_LOCALE = 16,
|
|
||||||
wxDF_PRIVATE = 20
|
|
||||||
};
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// wxDataFormat (internal)
|
// wxDataFormat (internal)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxDataFormat : public wxObject
|
class wxDataFormat : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_CLASS( wxDataFormat )
|
DECLARE_CLASS( wxDataFormat )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxDataFormat();
|
||||||
wxDataFormat();
|
wxDataFormat( wxDataFormatId type );
|
||||||
wxDataFormat( wxDataType type );
|
wxDataFormat( const wxString &id );
|
||||||
wxDataFormat( const wxString &id );
|
wxDataFormat( const wxChar *id );
|
||||||
wxDataFormat( const wxChar *id );
|
wxDataFormat( wxDataFormat &format );
|
||||||
wxDataFormat( wxDataFormat &format );
|
wxDataFormat( const GdkAtom atom );
|
||||||
wxDataFormat( const GdkAtom atom );
|
|
||||||
|
void SetType( wxDataFormatId type );
|
||||||
|
wxDataFormatId GetType() const;
|
||||||
|
|
||||||
|
/* the string Id identifies the format of clipboard or DnD data. a word
|
||||||
|
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
||||||
|
* to the clipboard - the latter with the Id "application/wxword", an
|
||||||
|
* image manipulation program would put a wxBitmapDataObject and a
|
||||||
|
* wxPrivateDataObject to the clipboard - the latter with "image/png". */
|
||||||
|
|
||||||
|
wxString GetId() const;
|
||||||
|
void SetId( const wxChar *id );
|
||||||
|
|
||||||
|
GdkAtom GetAtom();
|
||||||
|
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
||||||
|
|
||||||
void SetType( wxDataType type );
|
|
||||||
wxDataType GetType() const;
|
|
||||||
|
|
||||||
wxString GetId() const;
|
|
||||||
void SetId( const wxChar *id );
|
|
||||||
|
|
||||||
GdkAtom GetAtom();
|
|
||||||
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
|
||||||
private:
|
private:
|
||||||
|
wxDataFormatId m_type;
|
||||||
wxDataType m_type;
|
wxString m_id;
|
||||||
wxString m_id;
|
bool m_hasAtom;
|
||||||
bool m_hasAtom;
|
GdkAtom m_atom;
|
||||||
GdkAtom m_atom;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -102,36 +81,36 @@ public:
|
|||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxDataBroker();
|
wxDataBroker();
|
||||||
|
|
||||||
/* add data object */
|
/* add data object */
|
||||||
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* OLE implementation, the methods don't need to be overridden */
|
/* OLE implementation, the methods don't need to be overridden */
|
||||||
|
|
||||||
/* get number of supported formats */
|
/* get number of supported formats */
|
||||||
virtual size_t GetFormatCount() const;
|
virtual size_t GetFormatCount() const;
|
||||||
|
|
||||||
/* return nth supported format */
|
/* return nth supported format */
|
||||||
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
||||||
|
|
||||||
/* return preferrd/best supported format */
|
/* return preferrd/best supported format */
|
||||||
virtual wxDataFormat &GetPreferredFormat() const;
|
virtual wxDataFormat &GetPreferredFormat() const;
|
||||||
|
|
||||||
/* search through m_dataObjects, return TRUE if found */
|
/* search through m_dataObjects, return TRUE if found */
|
||||||
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
||||||
|
|
||||||
/* search through m_dataObjects and call child's GetSize() */
|
/* search through m_dataObjects and call child's GetSize() */
|
||||||
virtual size_t GetSize( wxDataFormat& format ) const;
|
virtual size_t GetSize( wxDataFormat& format ) const;
|
||||||
|
|
||||||
/* search through m_dataObjects and call child's WriteData(dest) */
|
/* search through m_dataObjects and call child's WriteData(dest) */
|
||||||
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wxList m_dataObjects;
|
wxList m_dataObjects;
|
||||||
size_t m_preferred;
|
size_t m_preferred;
|
||||||
};
|
};
|
||||||
@@ -143,29 +122,29 @@ public:
|
|||||||
class wxDataObject : public wxObject
|
class wxDataObject : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxDataObject();
|
wxDataObject();
|
||||||
|
|
||||||
/* destructor */
|
/* destructor */
|
||||||
~wxDataObject();
|
~wxDataObject();
|
||||||
|
|
||||||
/* write data to dest */
|
/* write data to dest */
|
||||||
virtual void WriteData( void *dest ) const = 0;
|
virtual void WriteData( void *dest ) const = 0;
|
||||||
|
|
||||||
/* get size of data */
|
/* get size of data */
|
||||||
virtual size_t GetSize() const = 0;
|
virtual size_t GetSize() const = 0;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxDataFormat &GetFormat();
|
wxDataFormat &GetFormat();
|
||||||
|
|
||||||
wxDataType GetFormatType() const;
|
wxDataFormatId GetFormatType() const;
|
||||||
wxString GetFormatId() const;
|
wxString GetFormatId() const;
|
||||||
GdkAtom GetFormatAtom() const;
|
GdkAtom GetFormatAtom() const;
|
||||||
|
|
||||||
wxDataFormat m_format;
|
wxDataFormat m_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -182,27 +161,27 @@ public:
|
|||||||
/* default constructor. call SetText() later or override
|
/* default constructor. call SetText() later or override
|
||||||
WriteData() and GetSize() for working on-demand */
|
WriteData() and GetSize() for working on-demand */
|
||||||
wxTextDataObject();
|
wxTextDataObject();
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
wxTextDataObject( const wxString& data );
|
wxTextDataObject( const wxString& data );
|
||||||
|
|
||||||
/* set current text data */
|
/* set current text data */
|
||||||
void SetText( const wxString& data );
|
void SetText( const wxString& data );
|
||||||
|
|
||||||
/* get current text data */
|
/* get current text data */
|
||||||
wxString GetText() const;
|
wxString GetText() const;
|
||||||
|
|
||||||
/* by default calls WriteString() with string set by constructor or
|
/* by default calls WriteString() with string set by constructor or
|
||||||
by SetText(). can be overridden for working on-demand */
|
by SetText(). can be overridden for working on-demand */
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
|
|
||||||
/* by default, returns length of string as set by constructor or
|
/* by default, returns length of string as set by constructor or
|
||||||
by SetText(). can be overridden for working on-demand */
|
by SetText(). can be overridden for working on-demand */
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
/* write string to dest */
|
/* write string to dest */
|
||||||
void WriteString( const wxString &str, void *dest ) const;
|
void WriteString( const wxString &str, void *dest ) const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxString m_data;
|
wxString m_data;
|
||||||
@@ -220,20 +199,20 @@ public:
|
|||||||
|
|
||||||
/* default constructor */
|
/* default constructor */
|
||||||
wxFileDataObject();
|
wxFileDataObject();
|
||||||
|
|
||||||
/* add file name to list */
|
/* add file name to list */
|
||||||
void AddFile( const wxString &file );
|
void AddFile( const wxString &file );
|
||||||
|
|
||||||
/* get all filename as one string. each file name is 0 terminated,
|
/* get all filename as one string. each file name is 0 terminated,
|
||||||
the list is double zero terminated */
|
the list is double zero terminated */
|
||||||
wxString GetFiles() const;
|
wxString GetFiles() const;
|
||||||
|
|
||||||
/* write list of filenames */
|
/* write list of filenames */
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
|
|
||||||
/* return length of list of filenames */
|
/* return length of list of filenames */
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
/* implementation */
|
/* implementation */
|
||||||
|
|
||||||
wxString m_files;
|
wxString m_files;
|
||||||
@@ -253,66 +232,21 @@ public:
|
|||||||
|
|
||||||
wxBitmapDataObject();
|
wxBitmapDataObject();
|
||||||
wxBitmapDataObject( const wxBitmap& bitmap );
|
wxBitmapDataObject( const wxBitmap& bitmap );
|
||||||
|
|
||||||
void SetBitmap( const wxBitmap &bitmap );
|
void SetBitmap( const wxBitmap &bitmap );
|
||||||
wxBitmap GetBitmap() const;
|
wxBitmap GetBitmap() const;
|
||||||
|
|
||||||
virtual void WriteData( void *dest ) const;
|
virtual void WriteData( void *dest ) const;
|
||||||
virtual size_t GetSize() const;
|
virtual size_t GetSize() const;
|
||||||
|
|
||||||
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
wxBitmap m_bitmap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
#endif
|
||||||
// wxPrivateDataObject is a specialization of wxDataObject for app specific data
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxPrivateDataObject : public wxDataObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/* see wxTextDataObject for explanation of functions */
|
|
||||||
|
|
||||||
wxPrivateDataObject();
|
|
||||||
~wxPrivateDataObject();
|
|
||||||
|
|
||||||
/* the string Id identifies the format of clipboard or DnD data. a word
|
|
||||||
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
|
||||||
* to the clipboard - the latter with the Id "application/wxword", an
|
|
||||||
* image manipulation program would put a wxBitmapDataObject and a
|
|
||||||
* wxPrivateDataObject to the clipboard - the latter with "image/png". */
|
|
||||||
|
|
||||||
void SetId( const wxString& id );
|
|
||||||
|
|
||||||
/* get id */
|
|
||||||
wxString GetId() const;
|
|
||||||
|
|
||||||
/* set data. will make internal copy. */
|
|
||||||
void SetData( const char *data, size_t size );
|
|
||||||
|
|
||||||
/* returns pointer to data */
|
|
||||||
char* GetData() const;
|
|
||||||
|
|
||||||
virtual void WriteData( void *dest ) const;
|
|
||||||
virtual size_t GetSize() const;
|
|
||||||
|
|
||||||
void WriteData( const char *data, void *dest ) const;
|
|
||||||
|
|
||||||
// implementation
|
|
||||||
|
|
||||||
size_t m_size;
|
|
||||||
char* m_data;
|
|
||||||
wxString m_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
//__GTKDNDH__
|
//__GTKDNDH__
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
|
#include "wx/dataobj.h" // for wxDataFormat
|
||||||
|
|
||||||
// These functions superceded by wxClipboard, but retained in order to
|
// These functions superceded by wxClipboard, but retained in order to
|
||||||
// implement wxClipboard, and for compatibility.
|
// implement wxClipboard, and for compatibility.
|
||||||
|
@@ -20,37 +20,14 @@ struct IDataObject;
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDataObject is a "smart" and polymorphic piece of data.
|
// wxDataObject is a "smart" and polymorphic piece of data.
|
||||||
//
|
//
|
||||||
// @@@ it's currently "read-only" from COM point of view, i.e. we don't support
|
// TODO it's currently "read-only" from COM point of view, i.e. we don't support
|
||||||
// SetData. We don't support all advise functions neither (but it's easy to
|
// SetData. We don't support all advise functions neither (but it's easy to
|
||||||
// do if we really want them)
|
// do if we really want them)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxDataObject
|
class WXDLLEXPORT wxDataObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// all data formats (values are the same as in windows.h, do not change!)
|
|
||||||
enum StdFormat
|
|
||||||
{
|
|
||||||
Invalid,
|
|
||||||
Text,
|
|
||||||
Bitmap,
|
|
||||||
MetafilePict,
|
|
||||||
Sylk,
|
|
||||||
Dif,
|
|
||||||
Tiff,
|
|
||||||
OemText,
|
|
||||||
Dib,
|
|
||||||
Palette,
|
|
||||||
Pendata,
|
|
||||||
Riff,
|
|
||||||
Wave,
|
|
||||||
UnicodeText,
|
|
||||||
EnhMetafile,
|
|
||||||
Hdrop,
|
|
||||||
Locale,
|
|
||||||
Max
|
|
||||||
};
|
|
||||||
|
|
||||||
// function to return symbolic name of clipboard format (debug messages)
|
// function to return symbolic name of clipboard format (debug messages)
|
||||||
static const char *GetFormatName(wxDataFormat format);
|
static const char *GetFormatName(wxDataFormat format);
|
||||||
|
|
||||||
@@ -62,7 +39,7 @@ public:
|
|||||||
// get the best suited format for our data
|
// get the best suited format for our data
|
||||||
virtual wxDataFormat GetPreferredFormat() const = 0;
|
virtual wxDataFormat GetPreferredFormat() const = 0;
|
||||||
// decide if we support this format (should be one of values of
|
// decide if we support this format (should be one of values of
|
||||||
// StdFormat enumerations or a user-defined format)
|
// wxDataFormatId enumerations or a user-defined format)
|
||||||
virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
|
virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
|
||||||
// get the (total) size of data
|
// get the (total) size of data
|
||||||
virtual size_t GetDataSize() const = 0;
|
virtual size_t GetDataSize() const = 0;
|
||||||
@@ -93,9 +70,9 @@ public:
|
|||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual wxDataFormat GetPreferredFormat() const
|
virtual wxDataFormat GetPreferredFormat() const
|
||||||
{ return (wxDataFormat) wxDataObject::Text; }
|
{ return wxDF_TEXT; }
|
||||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||||
{ return format == wxDataObject::Text || format == wxDataObject::Locale; }
|
{ return format == wxDF_TEXT || format == wxDF_LOCALE; }
|
||||||
virtual size_t GetDataSize() const
|
virtual size_t GetDataSize() const
|
||||||
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
|
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
|
||||||
virtual void GetDataHere(void *pBuf) const
|
virtual void GetDataHere(void *pBuf) const
|
||||||
@@ -133,9 +110,9 @@ public:
|
|||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual wxDataFormat GetPreferredFormat() const
|
virtual wxDataFormat GetPreferredFormat() const
|
||||||
{ return (wxDataFormat) wxDataObject::Bitmap; }
|
{ return wxDF_BITMAP; }
|
||||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||||
{ return format == wxDataObject::Bitmap; }
|
{ return format == wxDF_BITMAP; }
|
||||||
virtual size_t GetDataSize() const
|
virtual size_t GetDataSize() const
|
||||||
{ wxASSERT(false); return 0; } // BEMIMP
|
{ wxASSERT(false); return 0; } // BEMIMP
|
||||||
virtual void GetDataHere(void *pBuf) const
|
virtual void GetDataHere(void *pBuf) const
|
||||||
|
@@ -4,11 +4,11 @@
|
|||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Id: $Id$
|
// Id: $Id$
|
||||||
// Copyright: (c) 1998 Robert Roebling
|
// Copyright: (c) 1998 Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "dataobj.h"
|
#pragma implementation "dataobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
@@ -38,7 +38,7 @@ wxDataFormat::wxDataFormat()
|
|||||||
m_atom = (GdkAtom) 0;
|
m_atom = (GdkAtom) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataFormat::wxDataFormat( wxDataType type )
|
wxDataFormat::wxDataFormat( wxDataFormatId type )
|
||||||
{
|
{
|
||||||
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
||||||
SetType( type );
|
SetType( type );
|
||||||
@@ -69,9 +69,9 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
{
|
{
|
||||||
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
||||||
m_hasAtom = TRUE;
|
m_hasAtom = TRUE;
|
||||||
|
|
||||||
m_atom = atom;
|
m_atom = atom;
|
||||||
|
|
||||||
if (m_atom == g_textAtom)
|
if (m_atom == g_textAtom)
|
||||||
{
|
{
|
||||||
m_type = wxDF_TEXT;
|
m_type = wxDF_TEXT;
|
||||||
@@ -83,7 +83,7 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
{
|
{
|
||||||
m_type = wxDF_PRIVATE;
|
m_type = wxDF_PRIVATE;
|
||||||
m_id = gdk_atom_name( m_atom );
|
m_id = gdk_atom_name( m_atom );
|
||||||
|
|
||||||
if (m_id == _T("file:ALL"))
|
if (m_id == _T("file:ALL"))
|
||||||
{
|
{
|
||||||
m_type = wxDF_FILENAME;
|
m_type = wxDF_FILENAME;
|
||||||
@@ -91,19 +91,19 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataFormat::SetType( wxDataType type )
|
void wxDataFormat::SetType( wxDataFormatId type )
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
||||||
if (m_type == wxDF_TEXT)
|
if (m_type == wxDF_TEXT)
|
||||||
{
|
{
|
||||||
m_id = _T("STRING");
|
m_id = _T("STRING");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_BITMAP)
|
if (m_type == wxDF_BITMAP)
|
||||||
{
|
{
|
||||||
m_id = _T("BITMAP");
|
m_id = _T("BITMAP");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_FILENAME)
|
if (m_type == wxDF_FILENAME)
|
||||||
{
|
{
|
||||||
@@ -113,11 +113,11 @@ void wxDataFormat::SetType( wxDataType type )
|
|||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("invalid dataformat") );
|
wxFAIL_MSG( _T("invalid dataformat") );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hasAtom = FALSE;
|
m_hasAtom = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataType wxDataFormat::GetType() const
|
wxDataFormatId wxDataFormat::GetType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
if (!m_hasAtom)
|
if (!m_hasAtom)
|
||||||
{
|
{
|
||||||
m_hasAtom = TRUE;
|
m_hasAtom = TRUE;
|
||||||
|
|
||||||
if (m_type == wxDF_TEXT)
|
if (m_type == wxDF_TEXT)
|
||||||
{
|
{
|
||||||
m_atom = g_textAtom;
|
m_atom = g_textAtom;
|
||||||
@@ -148,24 +148,24 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
if (m_type == wxDF_BITMAP)
|
if (m_type == wxDF_BITMAP)
|
||||||
{
|
{
|
||||||
m_atom = GDK_TARGET_BITMAP;
|
m_atom = GDK_TARGET_BITMAP;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_PRIVATE)
|
if (m_type == wxDF_PRIVATE)
|
||||||
{
|
{
|
||||||
m_atom = gdk_atom_intern( MBSTRINGCAST m_id.mbc_str(), FALSE );
|
m_atom = gdk_atom_intern( MBSTRINGCAST m_id.mbc_str(), FALSE );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_FILENAME)
|
if (m_type == wxDF_FILENAME)
|
||||||
{
|
{
|
||||||
m_atom = gdk_atom_intern( "file:ALL", FALSE );
|
m_atom = gdk_atom_intern( "file:ALL", FALSE );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_hasAtom = FALSE;
|
m_hasAtom = FALSE;
|
||||||
m_atom = (GdkAtom) 0;
|
m_atom = (GdkAtom) 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_atom;
|
return m_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,93 +175,93 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(wxDataBroker,wxObject)
|
IMPLEMENT_CLASS(wxDataBroker,wxObject)
|
||||||
|
|
||||||
wxDataBroker::wxDataBroker()
|
wxDataBroker::wxDataBroker()
|
||||||
{
|
{
|
||||||
m_dataObjects.DeleteContents(TRUE);
|
m_dataObjects.DeleteContents(TRUE);
|
||||||
m_preferred = 0;
|
m_preferred = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
|
void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
|
||||||
{
|
{
|
||||||
if (preferred) m_preferred = m_dataObjects.GetCount();
|
if (preferred) m_preferred = m_dataObjects.GetCount();
|
||||||
m_dataObjects.Append( dataObject );
|
m_dataObjects.Append( dataObject );
|
||||||
}
|
|
||||||
|
|
||||||
size_t wxDataBroker::GetFormatCount() const
|
|
||||||
{
|
|
||||||
return m_dataObjects.GetCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t wxDataBroker::GetFormatCount() const
|
||||||
|
{
|
||||||
|
return m_dataObjects.GetCount();
|
||||||
|
}
|
||||||
|
|
||||||
wxDataFormat &wxDataBroker::GetPreferredFormat() const
|
wxDataFormat &wxDataBroker::GetPreferredFormat() const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.Nth( m_preferred );
|
wxNode *node = m_dataObjects.Nth( m_preferred );
|
||||||
|
|
||||||
wxASSERT( node );
|
wxASSERT( node );
|
||||||
|
|
||||||
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
return data_obj->GetFormat();
|
return data_obj->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
|
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.Nth( nth );
|
wxNode *node = m_dataObjects.Nth( nth );
|
||||||
|
|
||||||
wxASSERT( node );
|
wxASSERT( node );
|
||||||
|
|
||||||
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
return data_obj->GetFormat();
|
return data_obj->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
|
bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxDataBroker::GetSize( wxDataFormat& format ) const
|
size_t wxDataBroker::GetSize( wxDataFormat& format ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
return dobj->GetSize();
|
return dobj->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
|
void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
dobj->WriteData( dest );
|
dobj->WriteData( dest );
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject )
|
|||||||
wxDataObject::wxDataObject()
|
wxDataObject::wxDataObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataObject::~wxDataObject()
|
wxDataObject::~wxDataObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ wxDataFormat &wxDataObject::GetFormat()
|
|||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataType wxDataObject::GetFormatType() const
|
wxDataFormatId wxDataObject::GetFormatType() const
|
||||||
{
|
{
|
||||||
return m_format.GetType();
|
return m_format.GetType();
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ GdkAtom wxDataObject::GetFormatAtom() const
|
|||||||
{
|
{
|
||||||
GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom();
|
GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxTextDataObject
|
// wxTextDataObject
|
||||||
@@ -315,11 +315,11 @@ wxTextDataObject::wxTextDataObject()
|
|||||||
wxTextDataObject::wxTextDataObject( const wxString& data )
|
wxTextDataObject::wxTextDataObject( const wxString& data )
|
||||||
{
|
{
|
||||||
m_format.SetType( wxDF_TEXT );
|
m_format.SetType( wxDF_TEXT );
|
||||||
|
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextDataObject::SetText( const wxString& data )
|
void wxTextDataObject::SetText( const wxString& data )
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ void wxTextDataObject::WriteString( const wxString &str, void *dest ) const
|
|||||||
{
|
{
|
||||||
memcpy( dest, str.mb_str(), str.Len()+1 );
|
memcpy( dest, str.mb_str(), str.Len()+1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFileDataObject
|
// wxFileDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -356,26 +356,26 @@ wxFileDataObject::wxFileDataObject()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDataObject::AddFile( const wxString &file )
|
void wxFileDataObject::AddFile( const wxString &file )
|
||||||
{
|
{
|
||||||
m_files += file;
|
m_files += file;
|
||||||
m_files += (wxChar)0;
|
m_files += (wxChar)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFileDataObject::GetFiles() const
|
wxString wxFileDataObject::GetFiles() const
|
||||||
{
|
{
|
||||||
return m_files;
|
return m_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDataObject::WriteData( void *dest ) const
|
void wxFileDataObject::WriteData( void *dest ) const
|
||||||
{
|
{
|
||||||
memcpy( dest, m_files.mbc_str(), GetSize() );
|
memcpy( dest, m_files.mbc_str(), GetSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxFileDataObject::GetSize() const
|
size_t wxFileDataObject::GetSize() const
|
||||||
{
|
{
|
||||||
return m_files.Len() + 1;
|
return m_files.Len() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxBitmapDataObject
|
// wxBitmapDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -390,7 +390,7 @@ wxBitmapDataObject::wxBitmapDataObject()
|
|||||||
wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
|
wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
|
||||||
{
|
{
|
||||||
m_format.SetType( wxDF_BITMAP );
|
m_format.SetType( wxDF_BITMAP );
|
||||||
|
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,54 +418,38 @@ void wxBitmapDataObject::WriteBitmap( const wxBitmap &bitmap, void *dest ) const
|
|||||||
{
|
{
|
||||||
memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
|
memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxPrivateDataObject
|
// wxPrivateDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject )
|
IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject )
|
||||||
|
|
||||||
wxPrivateDataObject::wxPrivateDataObject()
|
void wxPrivateDataObject::Free()
|
||||||
{
|
{
|
||||||
m_id = _T("application/");
|
if ( m_data )
|
||||||
m_id += wxTheApp->GetAppName();
|
free(m_data);
|
||||||
|
|
||||||
m_format.SetId( m_id );
|
|
||||||
|
|
||||||
m_size = 0;
|
|
||||||
m_data = (char*) NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrivateDataObject::~wxPrivateDataObject()
|
|
||||||
{
|
|
||||||
if (m_data) delete[] m_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxPrivateDataObject::SetId( const wxString& id )
|
|
||||||
{
|
|
||||||
m_id = id;
|
|
||||||
m_format.SetId( m_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxPrivateDataObject::GetId() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::SetData( const char *data, size_t size )
|
wxPrivateDataObject::wxPrivateDataObject()
|
||||||
{
|
{
|
||||||
|
wxString id = _T("application/");
|
||||||
|
id += wxTheApp->GetAppName();
|
||||||
|
|
||||||
|
m_format.SetId( id );
|
||||||
|
|
||||||
|
m_size = 0;
|
||||||
|
m_data = (void *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::SetData( const void *data, size_t size )
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
m_data = malloc(size);
|
||||||
if (m_data) delete[] m_data;
|
|
||||||
|
|
||||||
m_data = new char[size];
|
|
||||||
|
|
||||||
memcpy( m_data, data, size );
|
memcpy( m_data, data, size );
|
||||||
}
|
|
||||||
|
|
||||||
char* wxPrivateDataObject::GetData() const
|
|
||||||
{
|
|
||||||
return m_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::WriteData( void *dest ) const
|
void wxPrivateDataObject::WriteData( void *dest ) const
|
||||||
@@ -475,10 +459,10 @@ void wxPrivateDataObject::WriteData( void *dest ) const
|
|||||||
|
|
||||||
size_t wxPrivateDataObject::GetSize() const
|
size_t wxPrivateDataObject::GetSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::WriteData( const char *data, void *dest ) const
|
void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
|
||||||
{
|
{
|
||||||
memcpy( dest, data, GetSize() );
|
memcpy( dest, data, GetSize() );
|
||||||
}
|
}
|
||||||
|
@@ -4,11 +4,11 @@
|
|||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Id: $Id$
|
// Id: $Id$
|
||||||
// Copyright: (c) 1998 Robert Roebling
|
// Copyright: (c) 1998 Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "dataobj.h"
|
#pragma implementation "dataobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
@@ -38,7 +38,7 @@ wxDataFormat::wxDataFormat()
|
|||||||
m_atom = (GdkAtom) 0;
|
m_atom = (GdkAtom) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataFormat::wxDataFormat( wxDataType type )
|
wxDataFormat::wxDataFormat( wxDataFormatId type )
|
||||||
{
|
{
|
||||||
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
||||||
SetType( type );
|
SetType( type );
|
||||||
@@ -69,9 +69,9 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
{
|
{
|
||||||
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
|
||||||
m_hasAtom = TRUE;
|
m_hasAtom = TRUE;
|
||||||
|
|
||||||
m_atom = atom;
|
m_atom = atom;
|
||||||
|
|
||||||
if (m_atom == g_textAtom)
|
if (m_atom == g_textAtom)
|
||||||
{
|
{
|
||||||
m_type = wxDF_TEXT;
|
m_type = wxDF_TEXT;
|
||||||
@@ -83,7 +83,7 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
{
|
{
|
||||||
m_type = wxDF_PRIVATE;
|
m_type = wxDF_PRIVATE;
|
||||||
m_id = gdk_atom_name( m_atom );
|
m_id = gdk_atom_name( m_atom );
|
||||||
|
|
||||||
if (m_id == _T("file:ALL"))
|
if (m_id == _T("file:ALL"))
|
||||||
{
|
{
|
||||||
m_type = wxDF_FILENAME;
|
m_type = wxDF_FILENAME;
|
||||||
@@ -91,19 +91,19 @@ wxDataFormat::wxDataFormat( const GdkAtom atom )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataFormat::SetType( wxDataType type )
|
void wxDataFormat::SetType( wxDataFormatId type )
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
||||||
if (m_type == wxDF_TEXT)
|
if (m_type == wxDF_TEXT)
|
||||||
{
|
{
|
||||||
m_id = _T("STRING");
|
m_id = _T("STRING");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_BITMAP)
|
if (m_type == wxDF_BITMAP)
|
||||||
{
|
{
|
||||||
m_id = _T("BITMAP");
|
m_id = _T("BITMAP");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_FILENAME)
|
if (m_type == wxDF_FILENAME)
|
||||||
{
|
{
|
||||||
@@ -113,11 +113,11 @@ void wxDataFormat::SetType( wxDataType type )
|
|||||||
{
|
{
|
||||||
wxFAIL_MSG( _T("invalid dataformat") );
|
wxFAIL_MSG( _T("invalid dataformat") );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hasAtom = FALSE;
|
m_hasAtom = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataType wxDataFormat::GetType() const
|
wxDataFormatId wxDataFormat::GetType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
if (!m_hasAtom)
|
if (!m_hasAtom)
|
||||||
{
|
{
|
||||||
m_hasAtom = TRUE;
|
m_hasAtom = TRUE;
|
||||||
|
|
||||||
if (m_type == wxDF_TEXT)
|
if (m_type == wxDF_TEXT)
|
||||||
{
|
{
|
||||||
m_atom = g_textAtom;
|
m_atom = g_textAtom;
|
||||||
@@ -148,24 +148,24 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
if (m_type == wxDF_BITMAP)
|
if (m_type == wxDF_BITMAP)
|
||||||
{
|
{
|
||||||
m_atom = GDK_TARGET_BITMAP;
|
m_atom = GDK_TARGET_BITMAP;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_PRIVATE)
|
if (m_type == wxDF_PRIVATE)
|
||||||
{
|
{
|
||||||
m_atom = gdk_atom_intern( MBSTRINGCAST m_id.mbc_str(), FALSE );
|
m_atom = gdk_atom_intern( MBSTRINGCAST m_id.mbc_str(), FALSE );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (m_type == wxDF_FILENAME)
|
if (m_type == wxDF_FILENAME)
|
||||||
{
|
{
|
||||||
m_atom = gdk_atom_intern( "file:ALL", FALSE );
|
m_atom = gdk_atom_intern( "file:ALL", FALSE );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_hasAtom = FALSE;
|
m_hasAtom = FALSE;
|
||||||
m_atom = (GdkAtom) 0;
|
m_atom = (GdkAtom) 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_atom;
|
return m_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,93 +175,93 @@ GdkAtom wxDataFormat::GetAtom()
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(wxDataBroker,wxObject)
|
IMPLEMENT_CLASS(wxDataBroker,wxObject)
|
||||||
|
|
||||||
wxDataBroker::wxDataBroker()
|
wxDataBroker::wxDataBroker()
|
||||||
{
|
{
|
||||||
m_dataObjects.DeleteContents(TRUE);
|
m_dataObjects.DeleteContents(TRUE);
|
||||||
m_preferred = 0;
|
m_preferred = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
|
void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
|
||||||
{
|
{
|
||||||
if (preferred) m_preferred = m_dataObjects.GetCount();
|
if (preferred) m_preferred = m_dataObjects.GetCount();
|
||||||
m_dataObjects.Append( dataObject );
|
m_dataObjects.Append( dataObject );
|
||||||
}
|
|
||||||
|
|
||||||
size_t wxDataBroker::GetFormatCount() const
|
|
||||||
{
|
|
||||||
return m_dataObjects.GetCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t wxDataBroker::GetFormatCount() const
|
||||||
|
{
|
||||||
|
return m_dataObjects.GetCount();
|
||||||
|
}
|
||||||
|
|
||||||
wxDataFormat &wxDataBroker::GetPreferredFormat() const
|
wxDataFormat &wxDataBroker::GetPreferredFormat() const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.Nth( m_preferred );
|
wxNode *node = m_dataObjects.Nth( m_preferred );
|
||||||
|
|
||||||
wxASSERT( node );
|
wxASSERT( node );
|
||||||
|
|
||||||
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
return data_obj->GetFormat();
|
return data_obj->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
|
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.Nth( nth );
|
wxNode *node = m_dataObjects.Nth( nth );
|
||||||
|
|
||||||
wxASSERT( node );
|
wxASSERT( node );
|
||||||
|
|
||||||
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
wxDataObject* data_obj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
return data_obj->GetFormat();
|
return data_obj->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
|
bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxDataBroker::GetSize( wxDataFormat& format ) const
|
size_t wxDataBroker::GetSize( wxDataFormat& format ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
return dobj->GetSize();
|
return dobj->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
|
void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_dataObjects.First();
|
wxNode *node = m_dataObjects.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxDataObject *dobj = (wxDataObject*)node->Data();
|
wxDataObject *dobj = (wxDataObject*)node->Data();
|
||||||
|
|
||||||
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
if (dobj->GetFormat().GetAtom() == format.GetAtom())
|
||||||
{
|
{
|
||||||
dobj->WriteData( dest );
|
dobj->WriteData( dest );
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject )
|
|||||||
wxDataObject::wxDataObject()
|
wxDataObject::wxDataObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataObject::~wxDataObject()
|
wxDataObject::~wxDataObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ wxDataFormat &wxDataObject::GetFormat()
|
|||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataType wxDataObject::GetFormatType() const
|
wxDataFormatId wxDataObject::GetFormatType() const
|
||||||
{
|
{
|
||||||
return m_format.GetType();
|
return m_format.GetType();
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ GdkAtom wxDataObject::GetFormatAtom() const
|
|||||||
{
|
{
|
||||||
GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom();
|
GdkAtom ret = ((wxDataObject*) this)->m_format.GetAtom();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxTextDataObject
|
// wxTextDataObject
|
||||||
@@ -315,11 +315,11 @@ wxTextDataObject::wxTextDataObject()
|
|||||||
wxTextDataObject::wxTextDataObject( const wxString& data )
|
wxTextDataObject::wxTextDataObject( const wxString& data )
|
||||||
{
|
{
|
||||||
m_format.SetType( wxDF_TEXT );
|
m_format.SetType( wxDF_TEXT );
|
||||||
|
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextDataObject::SetText( const wxString& data )
|
void wxTextDataObject::SetText( const wxString& data )
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ void wxTextDataObject::WriteString( const wxString &str, void *dest ) const
|
|||||||
{
|
{
|
||||||
memcpy( dest, str.mb_str(), str.Len()+1 );
|
memcpy( dest, str.mb_str(), str.Len()+1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFileDataObject
|
// wxFileDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -356,26 +356,26 @@ wxFileDataObject::wxFileDataObject()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDataObject::AddFile( const wxString &file )
|
void wxFileDataObject::AddFile( const wxString &file )
|
||||||
{
|
{
|
||||||
m_files += file;
|
m_files += file;
|
||||||
m_files += (wxChar)0;
|
m_files += (wxChar)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFileDataObject::GetFiles() const
|
wxString wxFileDataObject::GetFiles() const
|
||||||
{
|
{
|
||||||
return m_files;
|
return m_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDataObject::WriteData( void *dest ) const
|
void wxFileDataObject::WriteData( void *dest ) const
|
||||||
{
|
{
|
||||||
memcpy( dest, m_files.mbc_str(), GetSize() );
|
memcpy( dest, m_files.mbc_str(), GetSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxFileDataObject::GetSize() const
|
size_t wxFileDataObject::GetSize() const
|
||||||
{
|
{
|
||||||
return m_files.Len() + 1;
|
return m_files.Len() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxBitmapDataObject
|
// wxBitmapDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -390,7 +390,7 @@ wxBitmapDataObject::wxBitmapDataObject()
|
|||||||
wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
|
wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
|
||||||
{
|
{
|
||||||
m_format.SetType( wxDF_BITMAP );
|
m_format.SetType( wxDF_BITMAP );
|
||||||
|
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,54 +418,38 @@ void wxBitmapDataObject::WriteBitmap( const wxBitmap &bitmap, void *dest ) const
|
|||||||
{
|
{
|
||||||
memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
|
memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxPrivateDataObject
|
// wxPrivateDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject )
|
IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject )
|
||||||
|
|
||||||
wxPrivateDataObject::wxPrivateDataObject()
|
void wxPrivateDataObject::Free()
|
||||||
{
|
{
|
||||||
m_id = _T("application/");
|
if ( m_data )
|
||||||
m_id += wxTheApp->GetAppName();
|
free(m_data);
|
||||||
|
|
||||||
m_format.SetId( m_id );
|
|
||||||
|
|
||||||
m_size = 0;
|
|
||||||
m_data = (char*) NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrivateDataObject::~wxPrivateDataObject()
|
|
||||||
{
|
|
||||||
if (m_data) delete[] m_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxPrivateDataObject::SetId( const wxString& id )
|
|
||||||
{
|
|
||||||
m_id = id;
|
|
||||||
m_format.SetId( m_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxPrivateDataObject::GetId() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::SetData( const char *data, size_t size )
|
wxPrivateDataObject::wxPrivateDataObject()
|
||||||
{
|
{
|
||||||
|
wxString id = _T("application/");
|
||||||
|
id += wxTheApp->GetAppName();
|
||||||
|
|
||||||
|
m_format.SetId( id );
|
||||||
|
|
||||||
|
m_size = 0;
|
||||||
|
m_data = (void *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::SetData( const void *data, size_t size )
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
m_data = malloc(size);
|
||||||
if (m_data) delete[] m_data;
|
|
||||||
|
|
||||||
m_data = new char[size];
|
|
||||||
|
|
||||||
memcpy( m_data, data, size );
|
memcpy( m_data, data, size );
|
||||||
}
|
|
||||||
|
|
||||||
char* wxPrivateDataObject::GetData() const
|
|
||||||
{
|
|
||||||
return m_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::WriteData( void *dest ) const
|
void wxPrivateDataObject::WriteData( void *dest ) const
|
||||||
@@ -475,10 +459,10 @@ void wxPrivateDataObject::WriteData( void *dest ) const
|
|||||||
|
|
||||||
size_t wxPrivateDataObject::GetSize() const
|
size_t wxPrivateDataObject::GetSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrivateDataObject::WriteData( const char *data, void *dest ) const
|
void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
|
||||||
{
|
{
|
||||||
memcpy( dest, data, GetSize() );
|
memcpy( dest, data, GetSize() );
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/clipbrd.h"
|
#include "wx/clipbrd.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
@@ -59,9 +60,13 @@
|
|||||||
// therefore so is wxClipboard :-(
|
// therefore so is wxClipboard :-(
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
|
|
||||||
|
static bool wxSetClipboardData(wxDataObject *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#ifdef __WIN16__
|
||||||
|
#define memcpy hmemcpy
|
||||||
|
#endif
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -133,6 +138,38 @@ bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
|
|||||||
return ::IsClipboardFormatAvailable(dataFormat) != 0;
|
return ::IsClipboardFormatAvailable(dataFormat) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
static bool wxSetClipboardData(wxDataObject *data)
|
||||||
|
{
|
||||||
|
size_t size = data->GetDataSize();
|
||||||
|
HANDLE hGlobal = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size);
|
||||||
|
if ( !hGlobal )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Failed to allocate %dKb of memory for clipboard "
|
||||||
|
"transfer."), size / 1024);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPVOID lpGlobalMemory = ::GlobalLock(hGlobal);
|
||||||
|
|
||||||
|
data->GetDataHere(lpGlobalMemory);
|
||||||
|
|
||||||
|
GlobalUnlock(hGlobal);
|
||||||
|
|
||||||
|
wxDataFormat format = data->GetPreferredFormat();
|
||||||
|
if ( !::SetClipboardData(format, hGlobal) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Failed to set clipboard data in format %s"),
|
||||||
|
wxDataObject::GetFormatName(format));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
bool wxSetClipboardData(wxDataFormat dataFormat,
|
bool wxSetClipboardData(wxDataFormat dataFormat,
|
||||||
const void *data,
|
const void *data,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
@@ -194,11 +231,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
|
|||||||
{
|
{
|
||||||
wxMetafile *wxMF = (wxMetafile *)data;
|
wxMetafile *wxMF = (wxMetafile *)data;
|
||||||
HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1);
|
HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1);
|
||||||
#ifdef __WINDOWS_386__
|
|
||||||
METAFILEPICT *mf = (METAFILEPICT *)MK_FP32(GlobalLock(data));
|
|
||||||
#else
|
|
||||||
METAFILEPICT *mf = (METAFILEPICT *)GlobalLock(data);
|
METAFILEPICT *mf = (METAFILEPICT *)GlobalLock(data);
|
||||||
#endif
|
|
||||||
|
|
||||||
mf->mm = wxMF->GetWindowsMappingMode();
|
mf->mm = wxMF->GetWindowsMappingMode();
|
||||||
mf->xExt = width;
|
mf->xExt = width;
|
||||||
@@ -235,19 +268,9 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
|
|||||||
HANDLE hGlobalMemory = GlobalAlloc(GHND, l);
|
HANDLE hGlobalMemory = GlobalAlloc(GHND, l);
|
||||||
if ( hGlobalMemory )
|
if ( hGlobalMemory )
|
||||||
{
|
{
|
||||||
#ifdef __WINDOWS_386__
|
|
||||||
LPSTR lpGlobalMemory = (LPSTR)MK_FP32(GlobalLock(hGlobalMemory));
|
|
||||||
#else
|
|
||||||
LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory);
|
LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
memcpy(lpGlobalMemory, s, l);
|
memcpy(lpGlobalMemory, s, l);
|
||||||
#elif defined(__WATCOMC__) && defined(__WINDOWS_386__)
|
|
||||||
memcpy(lpGlobalMemory, s, l);
|
|
||||||
#else
|
|
||||||
hmemcpy(lpGlobalMemory, s, l);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GlobalUnlock(hGlobalMemory);
|
GlobalUnlock(hGlobalMemory);
|
||||||
}
|
}
|
||||||
@@ -325,7 +348,6 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
|||||||
case CF_TIFF:
|
case CF_TIFF:
|
||||||
case CF_PALETTE:
|
case CF_PALETTE:
|
||||||
case wxDF_DIB:
|
case wxDF_DIB:
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
wxLogError(_("Unsupported clipboard format."));
|
wxLogError(_("Unsupported clipboard format."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -349,25 +371,39 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
|||||||
if (!s)
|
if (!s)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef __WINDOWS_386__
|
|
||||||
LPSTR lpGlobalMemory = (LPSTR)MK_FP32(GlobalLock(hGlobalMemory));
|
|
||||||
#else
|
|
||||||
LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory);
|
LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
memcpy(s, lpGlobalMemory, hsize);
|
memcpy(s, lpGlobalMemory, hsize);
|
||||||
#elif __WATCOMC__ && defined(__WINDOWS_386__)
|
|
||||||
memcpy(s, lpGlobalMemory, hsize);
|
|
||||||
#else
|
|
||||||
hmemcpy(s, lpGlobalMemory, hsize);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
::GlobalUnlock(hGlobalMemory);
|
::GlobalUnlock(hGlobalMemory);
|
||||||
|
|
||||||
retval = s;
|
retval = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
HANDLE hGlobalMemory = ::GetClipboardData(dataFormat);
|
||||||
|
if ( !hGlobalMemory )
|
||||||
|
break;
|
||||||
|
|
||||||
|
DWORD size = ::GlobalSize(hGlobalMemory);
|
||||||
|
if ( len )
|
||||||
|
*len = size;
|
||||||
|
|
||||||
|
void *buf = malloc(size);
|
||||||
|
if ( !buf )
|
||||||
|
break;
|
||||||
|
|
||||||
|
LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory);
|
||||||
|
|
||||||
|
memcpy(buf, lpGlobalMemory, size);
|
||||||
|
|
||||||
|
::GlobalUnlock(hGlobalMemory);
|
||||||
|
|
||||||
|
retval = buf;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !retval )
|
if ( !retval )
|
||||||
@@ -378,9 +414,9 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
|
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
|
||||||
{
|
{
|
||||||
return (wxDataFormat)::EnumClipboardFormats(dataFormat);
|
return ::EnumClipboardFormats(dataFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxRegisterClipboardFormat(char *formatName)
|
int wxRegisterClipboardFormat(char *formatName)
|
||||||
@@ -471,16 +507,11 @@ bool wxClipboard::AddData( wxDataObject *data )
|
|||||||
#endif // wxUSE_METAFILE
|
#endif // wxUSE_METAFILE
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxLogError(_("Can not put data in format '%s' on clipboard."),
|
return wxSetClipboardData(data);
|
||||||
wxDataObject::GetFormatName(format));
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
#else // !wxUSE_DRAG_AND_DROP
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
#endif // wxUSE_DRAG_AND_DROP/!wxUSE_DRAG_AND_DROP
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClipboard::Close()
|
void wxClipboard::Close()
|
||||||
@@ -546,8 +577,18 @@ bool wxClipboard::GetData( wxDataObject *data )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
wxLogError(_("Can not get data in format '%s' from clipboard."),
|
{
|
||||||
wxDataObject::GetFormatName(format));
|
long len;
|
||||||
|
void *buf = wxGetClipboardData(format, &len);
|
||||||
|
if ( buf )
|
||||||
|
{
|
||||||
|
// FIXME this is for testing only!!
|
||||||
|
((wxPrivateDataObject *)data)->SetData(buf, len);
|
||||||
|
free(buf);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -28,12 +28,12 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/defs.h>
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#if defined(__WIN32__) && !defined(__GNUWIN32__)
|
#if defined(__WIN32__) && !defined(__GNUWIN32__)
|
||||||
|
|
||||||
#include <wx/log.h>
|
#include "wx/log.h"
|
||||||
#include <wx/msw/ole/dataobj.h>
|
#include "wx/dataobj.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <oleauto.h>
|
#include <oleauto.h>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <olestd.h>
|
#include <olestd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/msw/ole/oleutils.h>
|
#include "wx/msw/ole/oleutils.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// functions
|
// functions
|
||||||
@@ -101,6 +101,39 @@ private:
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDataFormat
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxDataFormat::SetId(const wxChar *format)
|
||||||
|
{
|
||||||
|
m_format = ::RegisterClipboardFormat(format);
|
||||||
|
if ( !m_format )
|
||||||
|
{
|
||||||
|
wxLogError(_("Couldn't register clipboard format '%s'."), format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDataFormat::GetId() const
|
||||||
|
{
|
||||||
|
static const int max = 256;
|
||||||
|
|
||||||
|
wxString s;
|
||||||
|
|
||||||
|
wxCHECK_MSG( !IsStandard(), s,
|
||||||
|
_T("name of predefined format cannot be retrieved") );
|
||||||
|
|
||||||
|
int len = ::GetClipboardFormatName(m_format, s.GetWriteBuf(max), max);
|
||||||
|
s.UngetWriteBuf();
|
||||||
|
|
||||||
|
if ( !len )
|
||||||
|
{
|
||||||
|
wxLogError(_("The clipboard format '%d' doesn't exist."), m_format);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxIEnumFORMATETC
|
// wxIEnumFORMATETC
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -284,14 +317,14 @@ STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and now check the type of data requested
|
// and now check the type of data requested
|
||||||
if ( m_pDataObject->IsSupportedFormat((wxDataFormat) pformatetc->cfFormat) ) {
|
if ( m_pDataObject->IsSupportedFormat((wxDataFormatId)pformatetc->cfFormat) ) {
|
||||||
wxLogTrace("wxIDataObject::QueryGetData: %s ok",
|
wxLogTrace("wxIDataObject::QueryGetData: %s ok",
|
||||||
wxDataObject::GetFormatName((wxDataFormat) pformatetc->cfFormat));
|
wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxLogTrace("wxIDataObject::QueryGetData: %s unsupported",
|
wxLogTrace("wxIDataObject::QueryGetData: %s unsupported",
|
||||||
wxDataObject::GetFormatName((wxDataFormat) pformatetc->cfFormat));
|
wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
|
||||||
return DV_E_FORMATETC;
|
return DV_E_FORMATETC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,6 +432,47 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
|
|||||||
#endif // Debug
|
#endif // Debug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxPrivateDataObject
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxPrivateDataObject::wxPrivateDataObject()
|
||||||
|
{
|
||||||
|
m_size = 0;
|
||||||
|
m_data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::Free()
|
||||||
|
{
|
||||||
|
if ( m_data )
|
||||||
|
free(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::SetData( const void *data, size_t size )
|
||||||
|
{
|
||||||
|
Free();
|
||||||
|
|
||||||
|
m_size = size;
|
||||||
|
m_data = malloc(size);
|
||||||
|
|
||||||
|
memcpy( m_data, data, size );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::WriteData( void *dest ) const
|
||||||
|
{
|
||||||
|
WriteData( m_data, dest );
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxPrivateDataObject::GetSize() const
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
|
||||||
|
{
|
||||||
|
memcpy( dest, data, GetSize() );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
// Name: msw/ole/dropsrc.cpp
|
// Name: msw/ole/dropsrc.cpp
|
||||||
// Purpose: implementation of wxIDropSource and wxDropSource
|
// Purpose: implementation of wxIDropSource and wxDropSource
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 10.05.98
|
// Created: 10.05.98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/setup.h>
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
#include <wx/log.h>
|
#include "wx/log.h"
|
||||||
#include <wx/msw/ole/dataobj.h>
|
#include "wx/dataobj.h"
|
||||||
#include <wx/msw/ole/dropsrc.h>
|
#include "wx/msw/ole/dropsrc.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
#include <oleauto.h>
|
#include <oleauto.h>
|
||||||
|
|
||||||
#include <wx/msw/ole/oleutils.h>
|
#include "wx/msw/ole/oleutils.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxIDropSource implementation of IDropSource interface
|
// wxIDropSource implementation of IDropSource interface
|
||||||
@@ -121,7 +121,7 @@ STDMETHODIMP wxIDropSource::QueryContinueDrag(BOOL fEscapePressed,
|
|||||||
|
|
||||||
// Name : wxIDropSource::GiveFeedback
|
// Name : wxIDropSource::GiveFeedback
|
||||||
// Purpose : give UI feedback according to current state of operation
|
// Purpose : give UI feedback according to current state of operation
|
||||||
// Returns : STDMETHODIMP
|
// Returns : STDMETHODIMP
|
||||||
// Params : [in] DWORD dwEffect - what would happen if we dropped now
|
// Params : [in] DWORD dwEffect - what would happen if we dropped now
|
||||||
// Notes : default implementation is ok in more than 99% of cases
|
// Notes : default implementation is ok in more than 99% of cases
|
||||||
STDMETHODIMP wxIDropSource::GiveFeedback(DWORD dwEffect)
|
STDMETHODIMP wxIDropSource::GiveFeedback(DWORD dwEffect)
|
||||||
@@ -186,8 +186,8 @@ wxDragResult wxDropSource::DoDragDrop(bool bAllowMove)
|
|||||||
wxCHECK_MSG( m_pData != NULL, wxDragNone, "No data in wxDropSource!" );
|
wxCHECK_MSG( m_pData != NULL, wxDragNone, "No data in wxDropSource!" );
|
||||||
|
|
||||||
DWORD dwEffect;
|
DWORD dwEffect;
|
||||||
HRESULT hr = ::DoDragDrop(m_pData->GetInterface(),
|
HRESULT hr = ::DoDragDrop(m_pData->GetInterface(),
|
||||||
m_pIDropSource,
|
m_pIDropSource,
|
||||||
bAllowMove ? DROPEFFECT_COPY | DROPEFFECT_MOVE
|
bAllowMove ? DROPEFFECT_COPY | DROPEFFECT_MOVE
|
||||||
: DROPEFFECT_COPY,
|
: DROPEFFECT_COPY,
|
||||||
&dwEffect);
|
&dwEffect);
|
||||||
@@ -229,7 +229,7 @@ wxDragResult wxDropSource::DoDragDrop(bool bAllowMove)
|
|||||||
// Purpose : visually inform the user about d&d operation state
|
// Purpose : visually inform the user about d&d operation state
|
||||||
// Returns : bool: true if we do all ourselves or false for default feedback
|
// Returns : bool: true if we do all ourselves or false for default feedback
|
||||||
// Params : [in] DragResult effect - what would happen if we dropped now
|
// Params : [in] DragResult effect - what would happen if we dropped now
|
||||||
// [in] bool bScrolling - true if target is scrolling
|
// [in] bool bScrolling - true if target is scrolling
|
||||||
// Notes : here we just leave this stuff for default implementation
|
// Notes : here we just leave this stuff for default implementation
|
||||||
bool wxDropSource::GiveFeedback(wxDragResult effect, bool bScrolling)
|
bool wxDropSource::GiveFeedback(wxDragResult effect, bool bScrolling)
|
||||||
{
|
{
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
// Name: ole/droptgt.cpp
|
// Name: ole/droptgt.cpp
|
||||||
// Purpose: wxDropTarget implementation
|
// Purpose: wxDropTarget implementation
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created:
|
// Created:
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
@@ -28,28 +28,29 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/setup.h>
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
#include <wx/log.h>
|
#include "wx/log.h"
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#ifndef __GNUWIN32__
|
#ifndef __GNUWIN32__
|
||||||
#include <shlobj.h> // for DROPFILES structure
|
#include <shlobj.h> // for DROPFILES structure
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/msw/ole/droptgt.h>
|
#include "wx/dataobj.h"
|
||||||
|
#include "wx/msw/ole/droptgt.h"
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <ole2.h>
|
#include <ole2.h>
|
||||||
#include <olestd.h>
|
#include <olestd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/msw/ole/oleutils.h>
|
#include "wx/msw/ole/oleutils.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// IDropTarget interface: forward all interesting things to wxDropTarget
|
// IDropTarget interface: forward all interesting things to wxDropTarget
|
||||||
@@ -69,9 +70,9 @@ public:
|
|||||||
STDMETHODIMP DragLeave(void);
|
STDMETHODIMP DragLeave(void);
|
||||||
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
|
||||||
|
|
||||||
// @@ we assume that if QueryGetData() returns S_OK, than we can really
|
// we assume that if QueryGetData() returns S_OK, than we can really get data
|
||||||
// get data in this format, so we remember here the format for which
|
// in this format, so we remember here the format for which QueryGetData()
|
||||||
// QueryGetData() succeeded
|
// succeeded
|
||||||
void SetSupportedFormat(wxDataFormat cfFormat) { m_cfFormat = cfFormat; }
|
void SetSupportedFormat(wxDataFormat cfFormat) { m_cfFormat = cfFormat; }
|
||||||
|
|
||||||
DECLARE_IUNKNOWN_METHODS;
|
DECLARE_IUNKNOWN_METHODS;
|
||||||
@@ -92,11 +93,11 @@ private:
|
|||||||
|
|
||||||
// Name : static wxDropTarget::GetDropEffect
|
// Name : static wxDropTarget::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
|
||||||
// IDropTarget methods
|
// IDropTarget methods
|
||||||
// Notes : We do "move" normally and "copy" if <Ctrl> is pressed,
|
// Notes : We do "move" normally and "copy" if <Ctrl> is pressed,
|
||||||
// which is the standard behaviour (currently there is no
|
// which is the standard behaviour (currently there is no
|
||||||
// way to redefine it)
|
// way to redefine it)
|
||||||
DWORD wxIDropTarget::GetDropEffect(DWORD flags)
|
DWORD wxIDropTarget::GetDropEffect(DWORD flags)
|
||||||
{
|
{
|
||||||
@@ -104,15 +105,15 @@ DWORD wxIDropTarget::GetDropEffect(DWORD flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxIDropTarget::wxIDropTarget(wxDropTarget *pTarget)
|
wxIDropTarget::wxIDropTarget(wxDropTarget *pTarget)
|
||||||
{
|
{
|
||||||
m_cRef = 0;
|
m_cRef = 0;
|
||||||
m_pTarget = pTarget;
|
m_pTarget = pTarget;
|
||||||
m_cfFormat = (wxDataFormat) 0;
|
m_cfFormat = wxDF_INVALID;
|
||||||
m_pIDataObject = NULL;
|
m_pIDataObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIDropTarget::~wxIDropTarget()
|
wxIDropTarget::~wxIDropTarget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_IID_TABLE(wxIDropTarget)
|
BEGIN_IID_TABLE(wxIDropTarget)
|
||||||
@@ -129,7 +130,7 @@ IMPLEMENT_IUNKNOWN_METHODS(wxIDropTarget)
|
|||||||
// [in] DWORD grfKeyState : kbd & mouse state
|
// [in] DWORD grfKeyState : kbd & mouse state
|
||||||
// [in] POINTL pt : mouse coordinates
|
// [in] POINTL pt : mouse coordinates
|
||||||
// [out]DWORD *pdwEffect : effect flag
|
// [out]DWORD *pdwEffect : effect flag
|
||||||
// Notes :
|
// Notes :
|
||||||
STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
||||||
DWORD grfKeyState,
|
DWORD grfKeyState,
|
||||||
POINTL pt,
|
POINTL pt,
|
||||||
@@ -146,8 +147,8 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @@ should check the point also?
|
// TODO should check the point also?
|
||||||
|
|
||||||
*pdwEffect = GetDropEffect(grfKeyState);
|
*pdwEffect = GetDropEffect(grfKeyState);
|
||||||
|
|
||||||
// get hold of the data object
|
// get hold of the data object
|
||||||
@@ -167,7 +168,7 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
|||||||
// Params : [in] DWORD grfKeyState kbd & mouse state
|
// Params : [in] DWORD grfKeyState kbd & mouse state
|
||||||
// [in] POINTL pt mouse coordinates
|
// [in] POINTL pt mouse coordinates
|
||||||
// [out]LPDWORD pdwEffect effect flag
|
// [out]LPDWORD pdwEffect effect flag
|
||||||
// Notes : We're called on every WM_MOUSEMOVE, so this function should be
|
// Notes : We're called on every WM_MOUSEMOVE, so this function should be
|
||||||
// very efficient.
|
// very efficient.
|
||||||
STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
||||||
POINTL pt,
|
POINTL pt,
|
||||||
@@ -175,7 +176,7 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
|||||||
{
|
{
|
||||||
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
|
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
|
||||||
|
|
||||||
*pdwEffect = m_pIDataObject == NULL ? DROPEFFECT_NONE
|
*pdwEffect = m_pIDataObject == NULL ? DROPEFFECT_NONE
|
||||||
: GetDropEffect(grfKeyState);
|
: GetDropEffect(grfKeyState);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -193,42 +194,42 @@ STDMETHODIMP wxIDropTarget::DragLeave()
|
|||||||
|
|
||||||
// release the held object
|
// release the held object
|
||||||
RELEASE_AND_NULL(m_pIDataObject);
|
RELEASE_AND_NULL(m_pIDataObject);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name : wxIDropTarget::Drop
|
// Name : wxIDropTarget::Drop
|
||||||
// Purpose : Instructs the drop target to paste data that was just now
|
// Purpose : Instructs the drop target to paste data that was just now
|
||||||
// dropped on it.
|
// dropped on it.
|
||||||
// Returns : S_OK
|
// Returns : S_OK
|
||||||
// Params : [in] IDataObject *pIDataSource the data to paste
|
// Params : [in] IDataObject *pIDataSource the data to paste
|
||||||
// [in] DWORD grfKeyState kbd & mouse state
|
// [in] DWORD grfKeyState kbd & mouse state
|
||||||
// [in] POINTL pt where the drop occured?
|
// [in] POINTL pt where the drop occured?
|
||||||
// [ouy]DWORD *pdwEffect operation effect
|
// [ouy]DWORD *pdwEffect operation effect
|
||||||
// Notes :
|
// Notes :
|
||||||
STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
||||||
DWORD grfKeyState,
|
DWORD grfKeyState,
|
||||||
POINTL pt,
|
POINTL pt,
|
||||||
DWORD *pdwEffect)
|
DWORD *pdwEffect)
|
||||||
{
|
{
|
||||||
wxLogDebug("IDropTarget::Drop");
|
wxLogDebug("IDropTarget::Drop");
|
||||||
|
|
||||||
// @@ I don't know why there is this parameter, but so far I assume
|
// TODO I don't know why there is this parameter, but so far I assume
|
||||||
// that it's the same we've already got in DragEnter
|
// that it's the same we've already got in DragEnter
|
||||||
wxASSERT( m_pIDataObject == pIDataSource );
|
wxASSERT( m_pIDataObject == pIDataSource );
|
||||||
|
|
||||||
STGMEDIUM stm;
|
STGMEDIUM stm;
|
||||||
*pdwEffect = DROPEFFECT_NONE;
|
*pdwEffect = DROPEFFECT_NONE;
|
||||||
|
|
||||||
// should be set by SetSupportedFormat() call
|
// should be set by SetSupportedFormat() call
|
||||||
wxASSERT( m_cfFormat != 0 );
|
wxASSERT( m_cfFormat != wxDF_INVALID );
|
||||||
|
|
||||||
FORMATETC fmtMemory;
|
FORMATETC fmtMemory;
|
||||||
fmtMemory.cfFormat = m_cfFormat;
|
fmtMemory.cfFormat = m_cfFormat;
|
||||||
fmtMemory.ptd = NULL;
|
fmtMemory.ptd = NULL;
|
||||||
fmtMemory.dwAspect = DVASPECT_CONTENT;
|
fmtMemory.dwAspect = DVASPECT_CONTENT;
|
||||||
fmtMemory.lindex = -1;
|
fmtMemory.lindex = -1;
|
||||||
fmtMemory.tymed = TYMED_HGLOBAL; // @@@@ to add other media
|
fmtMemory.tymed = TYMED_HGLOBAL; // TODO to add other media
|
||||||
|
|
||||||
HRESULT hr = pIDataSource->GetData(&fmtMemory, &stm);
|
HRESULT hr = pIDataSource->GetData(&fmtMemory, &stm);
|
||||||
if ( SUCCEEDED(hr) ) {
|
if ( SUCCEEDED(hr) ) {
|
||||||
@@ -262,7 +263,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
|||||||
|
|
||||||
wxDropTarget::wxDropTarget()
|
wxDropTarget::wxDropTarget()
|
||||||
{
|
{
|
||||||
// create an IDropTarget implementation which will notify us about
|
// create an IDropTarget implementation which will notify us about
|
||||||
// d&d operations.
|
// d&d operations.
|
||||||
m_pIDropTarget = new wxIDropTarget(this);
|
m_pIDropTarget = new wxIDropTarget(this);
|
||||||
m_pIDropTarget->AddRef();
|
m_pIDropTarget->AddRef();
|
||||||
@@ -314,22 +315,22 @@ bool wxDropTarget::IsAcceptedData(IDataObject *pIDataSource) const
|
|||||||
{
|
{
|
||||||
// this strucutre describes a data of any type (first field will be
|
// this strucutre describes a data of any type (first field will be
|
||||||
// changing) being passed through global memory block.
|
// changing) being passed through global memory block.
|
||||||
static FORMATETC s_fmtMemory = {
|
static FORMATETC s_fmtMemory = {
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
DVASPECT_CONTENT,
|
DVASPECT_CONTENT,
|
||||||
-1,
|
-1,
|
||||||
TYMED_HGLOBAL
|
TYMED_HGLOBAL
|
||||||
};
|
};
|
||||||
|
|
||||||
// cycle thorugh all supported formats
|
// cycle thorugh all supported formats
|
||||||
for ( size_t n = 0; n < GetFormatCount(); n++ ) {
|
for ( size_t n = 0; n < GetFormatCount(); n++ ) {
|
||||||
s_fmtMemory.cfFormat = GetFormat(n);
|
s_fmtMemory.cfFormat = GetFormat(n);
|
||||||
// @ don't use SUCCEEDED macro here: QueryGetData returns 1 (whatever it
|
// NB: don't use SUCCEEDED macro here: QueryGetData returns 1 (whatever it
|
||||||
// means) for file drag and drop
|
// means) for file drag and drop
|
||||||
if ( pIDataSource->QueryGetData(&s_fmtMemory) == S_OK ) {
|
if ( pIDataSource->QueryGetData(&s_fmtMemory) == S_OK ) {
|
||||||
// remember this format: we'll later ask for data in it
|
// remember this format: we'll later ask for data in it
|
||||||
m_pIDropTarget->SetSupportedFormat((wxDataFormat) s_fmtMemory.cfFormat);
|
m_pIDropTarget->SetSupportedFormat((unsigned int)s_fmtMemory.cfFormat);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,16 +364,16 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
|||||||
bool wxFileDropTarget::OnDrop(long x, long y, const void *pData)
|
bool wxFileDropTarget::OnDrop(long x, long y, const void *pData)
|
||||||
{
|
{
|
||||||
// the documentation states that the first member of DROPFILES structure
|
// the documentation states that the first member of DROPFILES structure
|
||||||
// is a "DWORD offset of double NUL terminated file list". What they mean by
|
// is a "DWORD offset of double NUL terminated file list". What they mean by
|
||||||
// this (I wonder if you see it immediately) is that the list starts at
|
// this (I wonder if you see it immediately) is that the list starts at
|
||||||
// ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised to
|
// ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised to
|
||||||
// use DragQueryFile to work with this structure, but not told where and how
|
// use DragQueryFile to work with this structure, but not told where and how
|
||||||
// to get HDROP.
|
// to get HDROP.
|
||||||
HDROP hdrop = (HDROP)pData; // @@ it works, but I'm not sure about it
|
HDROP hdrop = (HDROP)pData; // NB: it works, but I'm not sure about it
|
||||||
|
|
||||||
// get number of files (magic value -1)
|
// get number of files (magic value -1)
|
||||||
UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
|
UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
|
||||||
|
|
||||||
// for each file get the length, allocate memory and then get the name
|
// for each file get the length, allocate memory and then get the name
|
||||||
char **aszFiles = new char *[nFiles];
|
char **aszFiles = new char *[nFiles];
|
||||||
UINT len, n;
|
UINT len, n;
|
||||||
|
@@ -51,6 +51,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
#include "wx/dataobj.h"
|
||||||
#include "wx/msw/ole/droptgt.h"
|
#include "wx/msw/ole/droptgt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user