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_
|
||||
#define _WX_DATAOBJ_H_BASE_
|
||||
|
||||
#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__)
|
||||
#include "wx/motif/dataobj.h"
|
||||
#include "wx/motif/dataobj.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dataobj.h"
|
||||
#include "wx/gtk/dataobj.h"
|
||||
#elif defined(__WXQT__)
|
||||
#include "wx/qt/dnd.h"
|
||||
#include "wx/qt/dnd.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dnd.h"
|
||||
#include "wx/mac/dnd.h"
|
||||
#elif defined(__WXSTUBS__)
|
||||
#include "wx/stubs/dnd.h"
|
||||
#include "wx/stubs/dnd.h"
|
||||
#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
|
||||
// _WX_DATAOBJ_H_BASE_
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
// Currently Only MS-Windows/NT, XView and Motif are supported
|
||||
//
|
||||
#if defined(__HPUX__) && !defined(__WXGTK__)
|
||||
#ifndef __WXMOTIF__
|
||||
#ifndef __WXMOTIF__
|
||||
#define __WXMOTIF__
|
||||
#endif // __WXMOTIF__
|
||||
#endif
|
||||
@@ -408,7 +408,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
|
||||
#define wxMINIMIZE wxICONIZE
|
||||
#define wxMAXIMIZE 0x2000
|
||||
#define wxTHICK_FRAME 0x1000
|
||||
#define wxSYSTEM_MENU 0x0800
|
||||
#define wxSYSTEM_MENU 0x0800
|
||||
#define wxMINIMIZE_BOX 0x0400
|
||||
#define wxMAXIMIZE_BOX 0x0200
|
||||
#define wxTINY_CAPTION_HORIZ 0x0100
|
||||
@@ -432,7 +432,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&);
|
||||
#else
|
||||
// Under Unix, the dialogs don't have a system menu. Specifying
|
||||
// wxSYSTEM_MENU here, will make a close button appear.
|
||||
# define wxDEFAULT_DIALOG_STYLE (wxCAPTION)
|
||||
# define wxDEFAULT_DIALOG_STYLE (wxCAPTION)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -778,9 +778,7 @@ typedef enum
|
||||
// Don't do parent client adjustments (for implementation only)
|
||||
#define wxSIZE_NO_ADJUSTMENTS 0x0008
|
||||
|
||||
#ifndef __WXGTK__
|
||||
|
||||
enum wxDataFormat
|
||||
enum wxDataFormatId
|
||||
{
|
||||
wxDF_INVALID = 0,
|
||||
wxDF_TEXT = 1, /* CF_TEXT */
|
||||
@@ -799,11 +797,10 @@ enum wxDataFormat
|
||||
wxDF_ENHMETAFILE = 14,
|
||||
wxDF_FILENAME = 15, /* CF_HDROP */
|
||||
wxDF_LOCALE = 16,
|
||||
wxDF_PRIVATE = 20
|
||||
wxDF_PRIVATE = 20,
|
||||
wxDF_MAX
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* Virtual keycodes */
|
||||
|
||||
enum wxKeyCode
|
||||
@@ -884,7 +881,7 @@ enum wxKeyCode
|
||||
WXK_SCROLL,
|
||||
WXK_PAGEUP,
|
||||
WXK_PAGEDOWN,
|
||||
|
||||
|
||||
WXK_NUMPAD_SPACE,
|
||||
WXK_NUMPAD_TAB,
|
||||
WXK_NUMPAD_ENTER,
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#define _WX_DND_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/msw/ole/dropsrc.h"
|
||||
#include "wx/msw/ole/droptgt.h"
|
||||
#include "wx/msw/ole/dataobj.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dnd.h"
|
||||
#elif defined(__WXGTK__)
|
||||
|
||||
@@ -31,63 +31,42 @@ class wxBitmapDataObject;
|
||||
class wxPrivateDataObject;
|
||||
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)
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class wxDataFormat : public wxObject
|
||||
{
|
||||
DECLARE_CLASS( wxDataFormat )
|
||||
|
||||
DECLARE_CLASS( wxDataFormat )
|
||||
|
||||
public:
|
||||
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataType type );
|
||||
wxDataFormat( const wxString &id );
|
||||
wxDataFormat( const wxChar *id );
|
||||
wxDataFormat( wxDataFormat &format );
|
||||
wxDataFormat( const GdkAtom atom );
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataFormatId type );
|
||||
wxDataFormat( const wxString &id );
|
||||
wxDataFormat( const wxChar *id );
|
||||
wxDataFormat( wxDataFormat &format );
|
||||
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:
|
||||
|
||||
wxDataType m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
GdkAtom m_atom;
|
||||
wxDataFormatId m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
GdkAtom m_atom;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -102,36 +81,36 @@ public:
|
||||
|
||||
/* constructor */
|
||||
wxDataBroker();
|
||||
|
||||
|
||||
/* add data object */
|
||||
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* OLE implementation, the methods don't need to be overridden */
|
||||
|
||||
|
||||
/* get number of supported formats */
|
||||
virtual size_t GetFormatCount() const;
|
||||
|
||||
/* return nth supported format */
|
||||
|
||||
/* return nth supported format */
|
||||
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
||||
|
||||
/* return preferrd/best supported format */
|
||||
|
||||
/* return preferrd/best supported format */
|
||||
virtual wxDataFormat &GetPreferredFormat() const;
|
||||
|
||||
|
||||
/* search through m_dataObjects, return TRUE if found */
|
||||
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
||||
|
||||
|
||||
/* search through m_dataObjects and call child's GetSize() */
|
||||
virtual size_t GetSize( wxDataFormat& format ) const;
|
||||
|
||||
|
||||
/* search through m_dataObjects and call child's WriteData(dest) */
|
||||
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
public:
|
||||
|
||||
|
||||
wxList m_dataObjects;
|
||||
size_t m_preferred;
|
||||
};
|
||||
@@ -143,29 +122,29 @@ public:
|
||||
class wxDataObject : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/* constructor */
|
||||
wxDataObject();
|
||||
|
||||
|
||||
/* destructor */
|
||||
~wxDataObject();
|
||||
|
||||
/* write data to dest */
|
||||
|
||||
/* write data to dest */
|
||||
virtual void WriteData( void *dest ) const = 0;
|
||||
|
||||
/* get size of data */
|
||||
|
||||
/* get size of data */
|
||||
virtual size_t GetSize() const = 0;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
|
||||
wxDataFormat &GetFormat();
|
||||
|
||||
wxDataType GetFormatType() const;
|
||||
|
||||
wxDataFormatId GetFormatType() const;
|
||||
wxString GetFormatId() const;
|
||||
GdkAtom GetFormatAtom() const;
|
||||
|
||||
|
||||
wxDataFormat m_format;
|
||||
};
|
||||
|
||||
@@ -182,27 +161,27 @@ public:
|
||||
/* default constructor. call SetText() later or override
|
||||
WriteData() and GetSize() for working on-demand */
|
||||
wxTextDataObject();
|
||||
|
||||
|
||||
/* constructor */
|
||||
wxTextDataObject( const wxString& data );
|
||||
|
||||
|
||||
/* set current text data */
|
||||
void SetText( const wxString& data );
|
||||
|
||||
|
||||
/* get current text data */
|
||||
wxString GetText() const;
|
||||
|
||||
/* by default calls WriteString() with string set by constructor or
|
||||
by SetText(). can be overridden for working on-demand */
|
||||
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 */
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
/* write string to dest */
|
||||
void WriteString( const wxString &str, void *dest ) const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
wxString m_data;
|
||||
@@ -220,20 +199,20 @@ public:
|
||||
|
||||
/* default constructor */
|
||||
wxFileDataObject();
|
||||
|
||||
|
||||
/* add file name to list */
|
||||
void AddFile( const wxString &file );
|
||||
|
||||
|
||||
/* get all filename as one string. each file name is 0 terminated,
|
||||
the list is double zero terminated */
|
||||
wxString GetFiles() const;
|
||||
|
||||
|
||||
/* write list of filenames */
|
||||
virtual void WriteData( void *dest ) const;
|
||||
|
||||
/* return length of list of filenames */
|
||||
/* return length of list of filenames */
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
wxString m_files;
|
||||
@@ -253,66 +232,21 @@ public:
|
||||
|
||||
wxBitmapDataObject();
|
||||
wxBitmapDataObject( const wxBitmap& bitmap );
|
||||
|
||||
|
||||
void SetBitmap( const wxBitmap &bitmap );
|
||||
wxBitmap GetBitmap() const;
|
||||
|
||||
|
||||
virtual void WriteData( void *dest ) const;
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
||||
|
||||
|
||||
// implementation
|
||||
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
#endif
|
||||
//__GTKDNDH__
|
||||
|
||||
|
||||
@@ -31,63 +31,42 @@ class wxBitmapDataObject;
|
||||
class wxPrivateDataObject;
|
||||
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)
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class wxDataFormat : public wxObject
|
||||
{
|
||||
DECLARE_CLASS( wxDataFormat )
|
||||
|
||||
DECLARE_CLASS( wxDataFormat )
|
||||
|
||||
public:
|
||||
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataType type );
|
||||
wxDataFormat( const wxString &id );
|
||||
wxDataFormat( const wxChar *id );
|
||||
wxDataFormat( wxDataFormat &format );
|
||||
wxDataFormat( const GdkAtom atom );
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataFormatId type );
|
||||
wxDataFormat( const wxString &id );
|
||||
wxDataFormat( const wxChar *id );
|
||||
wxDataFormat( wxDataFormat &format );
|
||||
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:
|
||||
|
||||
wxDataType m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
GdkAtom m_atom;
|
||||
wxDataFormatId m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
GdkAtom m_atom;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -102,36 +81,36 @@ public:
|
||||
|
||||
/* constructor */
|
||||
wxDataBroker();
|
||||
|
||||
|
||||
/* add data object */
|
||||
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* OLE implementation, the methods don't need to be overridden */
|
||||
|
||||
|
||||
/* get number of supported formats */
|
||||
virtual size_t GetFormatCount() const;
|
||||
|
||||
/* return nth supported format */
|
||||
|
||||
/* return nth supported format */
|
||||
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
||||
|
||||
/* return preferrd/best supported format */
|
||||
|
||||
/* return preferrd/best supported format */
|
||||
virtual wxDataFormat &GetPreferredFormat() const;
|
||||
|
||||
|
||||
/* search through m_dataObjects, return TRUE if found */
|
||||
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
|
||||
|
||||
|
||||
/* search through m_dataObjects and call child's GetSize() */
|
||||
virtual size_t GetSize( wxDataFormat& format ) const;
|
||||
|
||||
|
||||
/* search through m_dataObjects and call child's WriteData(dest) */
|
||||
virtual void WriteData( wxDataFormat& format, void *dest ) const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
public:
|
||||
|
||||
|
||||
wxList m_dataObjects;
|
||||
size_t m_preferred;
|
||||
};
|
||||
@@ -143,29 +122,29 @@ public:
|
||||
class wxDataObject : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/* constructor */
|
||||
wxDataObject();
|
||||
|
||||
|
||||
/* destructor */
|
||||
~wxDataObject();
|
||||
|
||||
/* write data to dest */
|
||||
|
||||
/* write data to dest */
|
||||
virtual void WriteData( void *dest ) const = 0;
|
||||
|
||||
/* get size of data */
|
||||
|
||||
/* get size of data */
|
||||
virtual size_t GetSize() const = 0;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
|
||||
wxDataFormat &GetFormat();
|
||||
|
||||
wxDataType GetFormatType() const;
|
||||
|
||||
wxDataFormatId GetFormatType() const;
|
||||
wxString GetFormatId() const;
|
||||
GdkAtom GetFormatAtom() const;
|
||||
|
||||
|
||||
wxDataFormat m_format;
|
||||
};
|
||||
|
||||
@@ -182,27 +161,27 @@ public:
|
||||
/* default constructor. call SetText() later or override
|
||||
WriteData() and GetSize() for working on-demand */
|
||||
wxTextDataObject();
|
||||
|
||||
|
||||
/* constructor */
|
||||
wxTextDataObject( const wxString& data );
|
||||
|
||||
|
||||
/* set current text data */
|
||||
void SetText( const wxString& data );
|
||||
|
||||
|
||||
/* get current text data */
|
||||
wxString GetText() const;
|
||||
|
||||
/* by default calls WriteString() with string set by constructor or
|
||||
by SetText(). can be overridden for working on-demand */
|
||||
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 */
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
/* write string to dest */
|
||||
void WriteString( const wxString &str, void *dest ) const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
wxString m_data;
|
||||
@@ -220,20 +199,20 @@ public:
|
||||
|
||||
/* default constructor */
|
||||
wxFileDataObject();
|
||||
|
||||
|
||||
/* add file name to list */
|
||||
void AddFile( const wxString &file );
|
||||
|
||||
|
||||
/* get all filename as one string. each file name is 0 terminated,
|
||||
the list is double zero terminated */
|
||||
wxString GetFiles() const;
|
||||
|
||||
|
||||
/* write list of filenames */
|
||||
virtual void WriteData( void *dest ) const;
|
||||
|
||||
/* return length of list of filenames */
|
||||
/* return length of list of filenames */
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
/* implementation */
|
||||
|
||||
wxString m_files;
|
||||
@@ -253,66 +232,21 @@ public:
|
||||
|
||||
wxBitmapDataObject();
|
||||
wxBitmapDataObject( const wxBitmap& bitmap );
|
||||
|
||||
|
||||
void SetBitmap( const wxBitmap &bitmap );
|
||||
wxBitmap GetBitmap() const;
|
||||
|
||||
|
||||
virtual void WriteData( void *dest ) const;
|
||||
virtual size_t GetSize() const;
|
||||
|
||||
|
||||
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
||||
|
||||
|
||||
// implementation
|
||||
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// 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
|
||||
#endif
|
||||
//__GTKDNDH__
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/module.h"
|
||||
#include "wx/dataobj.h" // for wxDataFormat
|
||||
|
||||
// These functions superceded by wxClipboard, but retained in order to
|
||||
// implement wxClipboard, and for compatibility.
|
||||
|
||||
@@ -20,37 +20,14 @@ struct IDataObject;
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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
|
||||
// SetData. We don't support all advise functions neither (but it's easy to
|
||||
// do if we really want them)
|
||||
// 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
|
||||
// do if we really want them)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDataObject
|
||||
{
|
||||
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)
|
||||
static const char *GetFormatName(wxDataFormat format);
|
||||
|
||||
@@ -62,7 +39,7 @@ public:
|
||||
// get the best suited format for our data
|
||||
virtual wxDataFormat GetPreferredFormat() const = 0;
|
||||
// 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;
|
||||
// get the (total) size of data
|
||||
virtual size_t GetDataSize() const = 0;
|
||||
@@ -93,9 +70,9 @@ public:
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual wxDataFormat GetPreferredFormat() const
|
||||
{ return (wxDataFormat) wxDataObject::Text; }
|
||||
{ return wxDF_TEXT; }
|
||||
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
|
||||
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
|
||||
virtual void GetDataHere(void *pBuf) const
|
||||
@@ -133,9 +110,9 @@ public:
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual wxDataFormat GetPreferredFormat() const
|
||||
{ return (wxDataFormat) wxDataObject::Bitmap; }
|
||||
{ return wxDF_BITMAP; }
|
||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||
{ return format == wxDataObject::Bitmap; }
|
||||
{ return format == wxDF_BITMAP; }
|
||||
virtual size_t GetDataSize() const
|
||||
{ wxASSERT(false); return 0; } // BEMIMP
|
||||
virtual void GetDataHere(void *pBuf) const
|
||||
|
||||
Reference in New Issue
Block a user