Implemented a simple modality under X11.
Filled wxDataFormat and wxDataObject etc. Added skeleton for X11 clipboard. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,84 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: clipbrd.h
|
||||
// Purpose: Clipboard functionality.
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Author: Robert Roebling
|
||||
// Created: 17/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CLIPBRD_H_
|
||||
#define _WX_CLIPBRD_H_
|
||||
#ifndef __X11CLIPBOARDH__
|
||||
#define __X11CLIPBOARDH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "clipbrd.h"
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#if wxUSE_CLIPBOARD
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
bool WXDLLEXPORT wxOpenClipboard();
|
||||
bool WXDLLEXPORT wxClipboardOpen();
|
||||
bool WXDLLEXPORT wxCloseClipboard();
|
||||
bool WXDLLEXPORT wxEmptyClipboard();
|
||||
bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
|
||||
bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
|
||||
wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
|
||||
wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat);
|
||||
wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
|
||||
bool WXDLLEXPORT wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxClipboard
|
||||
//-----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxClipboard : public wxClipboardBase
|
||||
{
|
||||
public:
|
||||
wxClipboard();
|
||||
~wxClipboard();
|
||||
|
||||
|
||||
// open the clipboard before SetData() and GetData()
|
||||
virtual bool Open();
|
||||
|
||||
|
||||
// close the clipboard after SetData() and GetData()
|
||||
virtual void Close();
|
||||
|
||||
// opened?
|
||||
virtual bool IsOpened() const { return m_open; }
|
||||
|
||||
// replaces the data on the clipboard with data
|
||||
|
||||
// query whether the clipboard is opened
|
||||
virtual bool IsOpened() const;
|
||||
|
||||
// set the clipboard data. all other formats will be deleted.
|
||||
virtual bool SetData( wxDataObject *data );
|
||||
|
||||
// adds data to the clipboard
|
||||
|
||||
// add to the clipboard data.
|
||||
virtual bool AddData( wxDataObject *data );
|
||||
|
||||
// format available on the clipboard ?
|
||||
|
||||
// ask if data in correct format is available
|
||||
virtual bool IsSupported( const wxDataFormat& format );
|
||||
|
||||
|
||||
// fill data with data on the clipboard (if available)
|
||||
virtual bool GetData( wxDataObject& data );
|
||||
|
||||
|
||||
// clears wxTheClipboard and the system's clipboard if possible
|
||||
virtual void Clear();
|
||||
|
||||
|
||||
// If primary == TRUE, use primary selection in all further ops,
|
||||
// primary == FALSE resets it.
|
||||
virtual void UsePrimarySelection(bool primary = TRUE)
|
||||
{ m_usePrimary = primary; }
|
||||
{ m_usePrimary = primary; }
|
||||
|
||||
// implementation from now on
|
||||
|
||||
bool m_open;
|
||||
wxList m_data;
|
||||
bool m_ownsClipboard;
|
||||
bool m_ownsPrimarySelection;
|
||||
wxDataObject *m_data;
|
||||
|
||||
WXWindow m_clipboardWidget; /* for getting and offering data */
|
||||
WXWindow m_targetsWidget; /* for getting list of supported formats */
|
||||
bool m_waiting; /* querying data or formats is asynchronous */
|
||||
|
||||
bool m_formatSupported;
|
||||
Atom m_targetRequested;
|
||||
bool m_usePrimary;
|
||||
|
||||
wxDataObject *m_receivedData;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxClipboard)
|
||||
};
|
||||
|
||||
#endif // wxUSE_CLIPBOARD
|
||||
#endif
|
||||
// wxUSE_CLIPBOARD
|
||||
|
||||
#endif
|
||||
// _WX_CLIPBRD_H_
|
||||
// __X11CLIPBOARDH__
|
||||
|
@@ -9,8 +9,8 @@
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MOTIF_DATAFORM_H
|
||||
#define _WX_MOTIF_DATAFORM_H
|
||||
#ifndef _WX_X11_DATAFORM_H
|
||||
#define _WX_X11_DATAFORM_H
|
||||
|
||||
class wxDataFormat
|
||||
{
|
||||
@@ -25,17 +25,17 @@ public:
|
||||
wxDataFormat( NativeFormat format );
|
||||
|
||||
wxDataFormat& operator=(NativeFormat format)
|
||||
{ SetId(format); return *this; }
|
||||
{ SetId(format); return *this; }
|
||||
|
||||
// comparison (must have both versions)
|
||||
bool operator==(NativeFormat format) const
|
||||
{ return m_format == (NativeFormat)format; }
|
||||
{ return m_format == (NativeFormat)format; }
|
||||
bool operator!=(NativeFormat format) const
|
||||
{ return m_format != (NativeFormat)format; }
|
||||
{ return m_format != (NativeFormat)format; }
|
||||
bool operator==(wxDataFormatId format) const
|
||||
{ return m_type == (wxDataFormatId)format; }
|
||||
{ return m_type == (wxDataFormatId)format; }
|
||||
bool operator!=(wxDataFormatId format) const
|
||||
{ return m_type != (wxDataFormatId)format; }
|
||||
{ return m_type != (wxDataFormatId)format; }
|
||||
|
||||
// explicit and implicit conversions to NativeFormat which is one of
|
||||
// standard data types (implicit conversion is useful for preserving the
|
||||
@@ -62,5 +62,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_MOTIF_DATAFORM_H
|
||||
#endif // _WX_X11_DATAFORM_H
|
||||
|
||||
|
@@ -3,12 +3,12 @@
|
||||
// Purpose: declaration of the wxDataObject class for Motif
|
||||
// Author: Julian Smart
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Copyright: (c) 1998 Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MOTIF_DATAOBJ_H_
|
||||
#define _WX_MOTIF_DATAOBJ_H_
|
||||
#ifndef _WX_X11_DATAOBJ_H_
|
||||
#define _WX_X11_DATAOBJ_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dataobj.h"
|
||||
@@ -21,10 +21,14 @@
|
||||
class wxDataObject : public wxDataObjectBase
|
||||
{
|
||||
public:
|
||||
wxDataObject();
|
||||
|
||||
#ifdef __DARWIN__
|
||||
~wxDataObject() { }
|
||||
#endif
|
||||
|
||||
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
|
||||
};
|
||||
|
||||
#endif //_WX_MOTIF_DATAOBJ_H_
|
||||
#endif //_WX_X11_DATAOBJ_H_
|
||||
|
||||
|
89
include/wx/x11/dataobj2.h
Normal file
89
include/wx/x11/dataobj2.h
Normal file
@@ -0,0 +1,89 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gtk/dataobj2.h
|
||||
// Purpose: declaration of standard wxDataObjectSimple-derived classes
|
||||
// Author: Robert Roebling
|
||||
// Created: 19.10.99 (extracted from gtk/dataobj.h)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_X11_DATAOBJ2_H_
|
||||
#define _WX_X11_DATAOBJ2_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dataobj.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxBitmapDataObject : public wxBitmapDataObjectBase
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxBitmapDataObject();
|
||||
wxBitmapDataObject(const wxBitmap& bitmap);
|
||||
|
||||
// destr
|
||||
~wxBitmapDataObject();
|
||||
|
||||
// override base class virtual to update PNG data too
|
||||
virtual void SetBitmap(const wxBitmap& bitmap);
|
||||
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
virtual size_t GetDataSize() const { return m_pngSize; }
|
||||
virtual bool GetDataHere(void *buf) const;
|
||||
virtual bool SetData(size_t len, const void *buf);
|
||||
|
||||
protected:
|
||||
void Init() { m_pngData = (void *)NULL; m_pngSize = 0; }
|
||||
void Clear() { free(m_pngData); }
|
||||
void ClearAll() { Clear(); Init(); }
|
||||
|
||||
size_t m_pngSize;
|
||||
void *m_pngData;
|
||||
|
||||
void DoConvertToPng();
|
||||
|
||||
private:
|
||||
// virtual function hiding supression
|
||||
size_t GetDataSize(const wxDataFormat& format) const
|
||||
{ return(wxDataObjectSimple::GetDataSize(format)); }
|
||||
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
|
||||
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
|
||||
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileDataObject is a specialization of wxDataObject for file names
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxFileDataObject : public wxFileDataObjectBase
|
||||
{
|
||||
public:
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
void AddFile( const wxString &filename );
|
||||
|
||||
virtual size_t GetDataSize() const;
|
||||
virtual bool GetDataHere(void *buf) const;
|
||||
virtual bool SetData(size_t len, const void *buf);
|
||||
|
||||
private:
|
||||
// virtual function hiding supression
|
||||
size_t GetDataSize(const wxDataFormat& format) const
|
||||
{ return(wxDataObjectSimple::GetDataSize(format)); }
|
||||
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
|
||||
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
|
||||
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
|
||||
};
|
||||
|
||||
#endif // _WX_X11_DATAOBJ2_H_
|
||||
|
Reference in New Issue
Block a user