1998-12-14 16:13:49 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dataobj.h
|
|
|
|
// Purpose: declaration of the wxDataObject class
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
|
|
|
|
// Licence: wxWindows license
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GTKDATAOBJECTH__
|
|
|
|
#define __GTKDATAOBJECTH__
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
class wxDataFormat;
|
|
|
|
class wxDataBroker;
|
1998-12-14 16:13:49 +00:00
|
|
|
class wxDataObject;
|
|
|
|
class wxTextDataObject;
|
|
|
|
class wxBitmapDataObject;
|
|
|
|
class wxPrivateDataObject;
|
|
|
|
class wxFileDataObject;
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
1999-01-30 00:15:17 +00:00
|
|
|
// wxDataType (internal)
|
1998-12-14 16:13:49 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
enum wxDataType
|
1998-12-14 16:13:49 +00:00
|
|
|
{
|
1999-01-19 16:33:16 +00:00
|
|
|
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
|
|
|
|
};
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-30 00:15:17 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// wxDataFormat (internal)
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
class wxDataFormat : public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_CLASS( wxDataFormat )
|
|
|
|
|
1998-12-14 16:13:49 +00:00
|
|
|
public:
|
1999-01-19 16:33:16 +00:00
|
|
|
|
1999-01-22 10:52:42 +00:00
|
|
|
wxDataFormat();
|
1999-01-19 16:33:16 +00:00
|
|
|
wxDataFormat( wxDataType type );
|
|
|
|
wxDataFormat( const wxString &id );
|
|
|
|
wxDataFormat( wxDataFormat &format );
|
|
|
|
wxDataFormat( const GdkAtom atom );
|
1999-01-22 10:52:42 +00:00
|
|
|
|
|
|
|
void SetType( wxDataType type );
|
|
|
|
wxDataType GetType() const;
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
wxString GetId() const;
|
|
|
|
void SetId( const wxString &id );
|
1999-01-22 10:52:42 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
GdkAtom GetAtom();
|
|
|
|
|
|
|
|
private:
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-22 10:52:42 +00:00
|
|
|
wxDataType m_type;
|
|
|
|
wxString m_id;
|
|
|
|
bool m_hasAtom;
|
|
|
|
GdkAtom m_atom;
|
1999-01-19 16:33:16 +00:00
|
|
|
};
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
//-------------------------------------------------------------------------
|
1999-01-30 00:15:17 +00:00
|
|
|
// wxDataBroker (internal)
|
1999-01-19 16:33:16 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataBroker : public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_CLASS( wxDataBroker )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* constructor */
|
|
|
|
wxDataBroker();
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* add data object */
|
|
|
|
void Add( wxDataObject *dataObject, bool preferred = FALSE );
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/* OLE implementation, the methods don't need to be overridden */
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* get number of supported formats */
|
|
|
|
virtual size_t GetFormatCount() const;
|
|
|
|
|
|
|
|
/* return nth supported format */
|
|
|
|
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
|
|
|
|
|
|
|
|
/* 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;
|
1998-12-14 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxDataObject to be placed in wxDataBroker
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDataObject : public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( wxDataObject )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* constructor */
|
|
|
|
wxDataObject();
|
|
|
|
|
|
|
|
/* destructor */
|
|
|
|
~wxDataObject();
|
|
|
|
|
|
|
|
/* write data to dest */
|
|
|
|
virtual void WriteData( void *dest ) const = 0;
|
|
|
|
|
|
|
|
/* get size of data */
|
|
|
|
virtual size_t GetSize() const = 0;
|
|
|
|
|
|
|
|
/* implementation */
|
|
|
|
|
1999-01-22 10:52:42 +00:00
|
|
|
wxDataFormat &GetFormat();
|
|
|
|
|
|
|
|
wxDataType GetFormatType() const;
|
|
|
|
wxString GetFormatId() const;
|
|
|
|
GdkAtom GetFormatAtom() const;
|
1999-01-19 16:33:16 +00:00
|
|
|
|
1999-01-22 10:52:42 +00:00
|
|
|
wxDataFormat m_format;
|
1999-01-19 16:33:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
// wxTextDataObject is a specialization of wxDataObject for text data
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
|
|
|
|
class wxTextDataObject : public wxDataObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( wxTextDataObject )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* default constructor. call SetText() later or override
|
|
|
|
WriteData() and GetSize() for working on-demand */
|
|
|
|
wxTextDataObject();
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* constructor */
|
|
|
|
wxTextDataObject( const wxString& data );
|
|
|
|
|
|
|
|
/* set current text data */
|
|
|
|
void SetText( const wxString& data );
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* get current text data */
|
|
|
|
wxString GetText() const;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* 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 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 */
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
wxString m_data;
|
1998-12-14 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
// wxFileDataObject is a specialization of wxDataObject for file names
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
|
|
|
|
class wxFileDataObject : public wxDataObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( wxFileDataObject )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* default constructor */
|
|
|
|
wxFileDataObject();
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* add file name to list */
|
|
|
|
void AddFile( const wxString &file );
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* get all filename as one string. each file name is 0 terminated,
|
|
|
|
the list is double zero terminated */
|
|
|
|
wxString GetFiles() const;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* write list of filenames */
|
|
|
|
virtual void WriteData( void *dest ) const;
|
|
|
|
|
|
|
|
/* return length of list of filenames */
|
|
|
|
virtual size_t GetSize() const;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* implementation */
|
|
|
|
|
|
|
|
wxString m_files;
|
1998-12-14 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
|
|
|
|
class wxBitmapDataObject : public wxDataObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( wxBitmapDataObject )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* see wxTextDataObject for explanation */
|
|
|
|
|
|
|
|
wxBitmapDataObject();
|
|
|
|
wxBitmapDataObject( const wxBitmap& bitmap );
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
void SetBitmap( const wxBitmap &bitmap );
|
|
|
|
wxBitmap GetBitmap() const;
|
1999-01-15 01:12:01 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
virtual void WriteData( void *dest ) const;
|
|
|
|
virtual size_t GetSize() const;
|
|
|
|
|
|
|
|
void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
// implementation
|
|
|
|
|
1998-12-14 16:13:49 +00:00
|
|
|
wxBitmap m_bitmap;
|
1999-01-19 16:33:16 +00:00
|
|
|
|
1998-12-14 16:13:49 +00:00
|
|
|
};
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
// wxPrivateDataObject is a specialization of wxDataObject for app specific data
|
1999-01-19 16:33:16 +00:00
|
|
|
//----------------------------------------------------------------------------
|
1998-12-14 16:13:49 +00:00
|
|
|
|
|
|
|
class wxPrivateDataObject : public wxDataObject
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* see wxTextDataObject for explanation of functions */
|
|
|
|
|
1999-01-14 00:24:03 +00:00
|
|
|
wxPrivateDataObject();
|
|
|
|
~wxPrivateDataObject();
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* 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". */
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
void SetId( const wxString& id );
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* get id */
|
|
|
|
wxString GetId() const;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* set data. will make internal copy. */
|
1998-12-14 16:13:49 +00:00
|
|
|
void SetData( const char *data, size_t size );
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
/* 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;
|
1998-12-14 16:13:49 +00:00
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
// implementation
|
|
|
|
|
1998-12-14 16:13:49 +00:00
|
|
|
size_t m_size;
|
|
|
|
char* m_data;
|
|
|
|
wxString m_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
//__GTKDNDH__
|
|
|
|
|