wxMotif compilation fixes for wxDataObject and PROCESS_EVENTS (wxSocket)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4122 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a64a02efae
commit
12db77cab1
@ -412,7 +412,7 @@ private:
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/ole/dataobj2.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dataobj2.h"
|
||||
// #include "wx/motif/dataobj2.h" -- not yet
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dataobj2.h"
|
||||
#endif
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
// implementation
|
||||
|
||||
GdkAtom GetMatchingPair();
|
||||
|
||||
void RegisterWidget( GtkWidget *widget );
|
||||
void UnregisterWidget( GtkWidget *widget );
|
||||
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
// implementation
|
||||
|
||||
GdkAtom GetMatchingPair();
|
||||
|
||||
void RegisterWidget( GtkWidget *widget );
|
||||
void UnregisterWidget( GtkWidget *widget );
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: clipbrd.h
|
||||
// Purpose: Clipboard functionality.
|
||||
// Note: this functionality is under review, and
|
||||
// is derived from wxWindows 1.xx code. Please contact
|
||||
// the wxWindows developers for further information.
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 17/09/98
|
||||
@ -16,14 +13,12 @@
|
||||
#define _WX_CLIPBRD_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "clipbrd.h"
|
||||
#pragma interface "clipbrd.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_CLIPBOARD
|
||||
|
||||
#include "wx/dataobj.h"
|
||||
|
||||
#include "wx/module.h"
|
||||
#include "wx/list.h"
|
||||
|
||||
bool WXDLLEXPORT wxOpenClipboard();
|
||||
bool WXDLLEXPORT wxClipboardOpen();
|
||||
@ -52,19 +47,27 @@ public:
|
||||
// close the clipboard after SetData() and GetData()
|
||||
virtual void Close();
|
||||
|
||||
// can be called several times
|
||||
// opened?
|
||||
virtual bool IsOpened() const { return m_open; }
|
||||
|
||||
// replaces the data on the clipboard with data
|
||||
virtual bool SetData( wxDataObject *data );
|
||||
|
||||
// adds data to the clipboard
|
||||
virtual bool AddData( wxDataObject *data );
|
||||
|
||||
// format available on the clipboard ?
|
||||
// supply ID if private format, the same as wxPrivateDataObject::SetId()
|
||||
virtual bool IsSupported( wxDataFormat format );
|
||||
virtual bool IsSupported( const wxDataFormat& format );
|
||||
|
||||
// fill data with data on the clipboard (if available)
|
||||
virtual bool GetData( wxDataObject *data );
|
||||
virtual bool GetData( wxDataObject& data );
|
||||
|
||||
// clears wxTheClipboard and the system's clipboard if possible
|
||||
virtual void Clear();
|
||||
|
||||
virtual void UsePrimarySelection(bool primary = TRUE)
|
||||
{ m_usePrimary = primary; }
|
||||
|
||||
// implementation from now on
|
||||
|
||||
bool m_open;
|
||||
@ -75,9 +78,6 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxClipboard)
|
||||
};
|
||||
|
||||
/* The clipboard */
|
||||
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
|
||||
|
||||
#endif // wxUSE_CLIPBOARD
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,8 @@
|
||||
class wxDataFormat
|
||||
{
|
||||
public:
|
||||
typedef unsigned long /* Atom */ NativeFormat;
|
||||
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataFormatId type );
|
||||
wxDataFormat( const wxString &id );
|
||||
@ -23,7 +25,7 @@ public:
|
||||
wxDataFormat( const Atom atom );
|
||||
|
||||
void SetType( wxDataFormatId type );
|
||||
wxDataFormatId GetType() const;
|
||||
NativeFormat GetType() const { return m_type; }
|
||||
|
||||
/* the string Id identifies the format of clipboard or DnD data. a word
|
||||
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
|
||||
@ -31,20 +33,20 @@ public:
|
||||
* image manipulation program would put a wxBitmapDataObject and a
|
||||
* wxPrivateDataObject to the clipboard - the latter with "image/png". */
|
||||
|
||||
wxString GetId() const;
|
||||
wxString GetId() const { return m_id; }
|
||||
void SetId( const wxChar *id );
|
||||
|
||||
Atom GetAtom();
|
||||
void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
||||
|
||||
// implicit conversion to wxDataFormatId
|
||||
operator wxDataFormatId() const { return m_type; }
|
||||
operator NativeFormat() const { return m_type; }
|
||||
|
||||
bool operator==(wxDataFormatId type) const { return m_type == type; }
|
||||
bool operator!=(wxDataFormatId type) const { return m_type != type; }
|
||||
bool operator==(NativeFormat type) const { return m_type == type; }
|
||||
bool operator!=(NativeFormat type) const { return m_type != type; }
|
||||
|
||||
private:
|
||||
wxDataFormatId m_type;
|
||||
NativeFormat m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
Atom m_atom;
|
||||
|
@ -1,149 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dataobj.h
|
||||
// Purpose: declaration of the wxDataObject class
|
||||
// Name: wx/motif/dataobj.h
|
||||
// Purpose: declaration of the wxDataObject class for Motif
|
||||
// Author: Julian Smart
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DATAOBJ_H_
|
||||
#define _WX_DATAOBJ_H_
|
||||
#ifndef _WX_MOTIF_DATAOBJ_H_
|
||||
#define _WX_MOTIF_DATAOBJ_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dataobj.h"
|
||||
#pragma interface "dataobj.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/bitmap.h"
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDataObject is the same as wxDataObjectBase under wxMotif
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// classes
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class wxDataFormat;
|
||||
class wxDataObject;
|
||||
class wxTextDataObject;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataFormat
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class wxDataFormat : public wxObject
|
||||
class wxDataObject : public wxDataObjectBase
|
||||
{
|
||||
DECLARE_CLASS( wxDataFormat )
|
||||
|
||||
public:
|
||||
wxDataFormat();
|
||||
wxDataFormat( wxDataFormatId type );
|
||||
wxDataFormat( const wxString &id );
|
||||
wxDataFormat( const wxChar *id );
|
||||
wxDataFormat( const wxDataFormat &format );
|
||||
wxDataFormat( const Atom 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 );
|
||||
|
||||
Atom GetAtom();
|
||||
void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; }
|
||||
|
||||
// implicit conversion to wxDataFormatId
|
||||
operator wxDataFormatId() const { return m_type; }
|
||||
|
||||
bool operator==(wxDataFormatId type) const { return m_type == type; }
|
||||
bool operator!=(wxDataFormatId type) const { return m_type != type; }
|
||||
|
||||
private:
|
||||
wxDataFormatId m_type;
|
||||
wxString m_id;
|
||||
bool m_hasAtom;
|
||||
Atom m_atom;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// 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 */
|
||||
|
||||
wxDataFormat &GetFormat();
|
||||
|
||||
wxDataFormatId GetFormatType() const;
|
||||
wxString GetFormatId() const;
|
||||
Atom GetFormatAtom() const;
|
||||
|
||||
wxDataFormat m_format;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxTextDataObject is a specialization of wxDataObject for text data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class wxTextDataObject : public wxDataObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxTextDataObject )
|
||||
|
||||
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 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;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
//_WX_DATAOBJ_H_
|
||||
#endif //_WX_MOTIF_DATAOBJ_H_
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/clipbrd.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// wxClipboardBase
|
||||
|
@ -45,11 +45,11 @@
|
||||
#include "wx/socket.h"
|
||||
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
||||
#define PROCESS_EVENTS() wxYield()
|
||||
#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMOTIF__)
|
||||
#define PROCESS_EVENTS() wxYield()
|
||||
#elif defined(__WXGTK__)
|
||||
#include <gtk/gtk.h>
|
||||
#define PROCESS_EVENTS() gtk_main_iteration()
|
||||
#include <gtk/gtk.h>
|
||||
#define PROCESS_EVENTS() gtk_main_iteration()
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -275,30 +275,36 @@ bool wxClipboard::SetData( wxDataObject *data )
|
||||
wxCHECK_MSG( data, FALSE, "data is invalid" );
|
||||
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
|
||||
|
||||
switch (data->GetFormat())
|
||||
Clear();
|
||||
|
||||
return AddData( data );
|
||||
}
|
||||
|
||||
bool wxClipboard::AddData( wxDataObject *data )
|
||||
{
|
||||
wxCHECK_MSG( data, FALSE, "data is invalid" );
|
||||
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
|
||||
|
||||
wxDataFormat::NativeFormat format = data->GetPreferredFormat().GetType();
|
||||
switch ( format )
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
case wxDF_OEMTEXT:
|
||||
{
|
||||
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
|
||||
wxString str(textDataObject->GetText());
|
||||
return wxSetClipboardData(data->GetFormat(), (wxObject*) (const char*) str);
|
||||
break;
|
||||
return wxSetClipboardData(format, (wxObject*) (const char*) str);
|
||||
}
|
||||
/*
|
||||
#if 0
|
||||
case wxDF_BITMAP:
|
||||
case wxDF_DIB:
|
||||
{
|
||||
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||
wxBitmap bitmap(bitmapDataObject->GetBitmap());
|
||||
return wxSetClipboardData(data->GetFormat(), & bitmap);
|
||||
return wxSetClipboardData(data->GetType(), & bitmap);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
default:
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -312,25 +318,26 @@ void wxClipboard::Close()
|
||||
wxCloseClipboard();
|
||||
}
|
||||
|
||||
bool wxClipboard::IsSupported( wxDataFormat format)
|
||||
bool wxClipboard::IsSupported( const wxDataFormat& format)
|
||||
{
|
||||
return wxIsClipboardFormatAvailable(format);
|
||||
}
|
||||
|
||||
bool wxClipboard::GetData( wxDataObject *data )
|
||||
bool wxClipboard::GetData( wxDataObject& data )
|
||||
{
|
||||
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
|
||||
|
||||
switch (data->GetFormat())
|
||||
wxDataFormat::NativeFormat format = data.GetPreferredFormat().GetType();
|
||||
switch ( format )
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
case wxDF_OEMTEXT:
|
||||
{
|
||||
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
|
||||
char* s = (char*) wxGetClipboardData(data->GetFormat());
|
||||
wxTextDataObject& textDataObject = (wxTextDataObject &) data;
|
||||
char* s = (char*) wxGetClipboardData(format);
|
||||
if (s)
|
||||
{
|
||||
textDataObject->SetText(s);
|
||||
textDataObject.SetText(s);
|
||||
delete[] s;
|
||||
return TRUE;
|
||||
}
|
||||
@ -343,7 +350,7 @@ bool wxClipboard::GetData( wxDataObject *data )
|
||||
case wxDF_DIB:
|
||||
{
|
||||
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||
wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetFormat());
|
||||
wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetType());
|
||||
if (bitmap)
|
||||
{
|
||||
bitmapDataObject->SetBitmap(* bitmap);
|
||||
|
@ -25,14 +25,12 @@
|
||||
// global data
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
Atom g_textAtom = 0;
|
||||
Atom g_textAtom = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataFormat
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxDataFormat, wxObject)
|
||||
|
||||
wxDataFormat::wxDataFormat()
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
@ -122,16 +120,6 @@ void wxDataFormat::SetType( wxDataFormatId type )
|
||||
m_hasAtom = FALSE;
|
||||
}
|
||||
|
||||
wxDataFormatId wxDataFormat::GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
wxString wxDataFormat::GetId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId( const wxChar *id )
|
||||
{
|
||||
m_type = wxDF_PRIVATE;
|
||||
@ -176,83 +164,7 @@ Atom wxDataFormat::GetAtom()
|
||||
return m_atom;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataObject
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject )
|
||||
|
||||
wxDataObject::wxDataObject()
|
||||
{
|
||||
}
|
||||
|
||||
wxDataObject::~wxDataObject()
|
||||
{
|
||||
}
|
||||
|
||||
wxDataFormat &wxDataObject::GetFormat()
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
wxDataFormatId wxDataObject::GetFormatType() const
|
||||
{
|
||||
return m_format.GetType();
|
||||
}
|
||||
|
||||
wxString wxDataObject::GetFormatId() const
|
||||
{
|
||||
return m_format.GetId();
|
||||
}
|
||||
|
||||
Atom wxDataObject::GetFormatAtom() const
|
||||
{
|
||||
Atom ret = ((wxDataObject*) this)->m_format.GetAtom();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextDataObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( wxTextDataObject, wxDataObject )
|
||||
|
||||
wxTextDataObject::wxTextDataObject()
|
||||
{
|
||||
m_format.SetType( wxDF_TEXT );
|
||||
}
|
||||
|
||||
wxTextDataObject::wxTextDataObject( const wxString& data )
|
||||
{
|
||||
m_format.SetType( wxDF_TEXT );
|
||||
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void wxTextDataObject::SetText( const wxString& data )
|
||||
{
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
wxString wxTextDataObject::GetText() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void wxTextDataObject::WriteData( void *dest ) const
|
||||
{
|
||||
WriteString( m_data, dest );
|
||||
}
|
||||
|
||||
size_t wxTextDataObject::GetSize() const
|
||||
{
|
||||
return m_data.Len() + 1;
|
||||
}
|
||||
|
||||
void wxTextDataObject::WriteString( const wxString &str, void *dest ) const
|
||||
{
|
||||
memcpy( dest, str.mb_str(), str.Len()+1 );
|
||||
}
|
||||
#if 0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPrivateDataObject
|
||||
@ -302,4 +214,6 @@ void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
|
||||
memcpy( dest, data, GetSize() );
|
||||
}
|
||||
|
||||
#endif // 0
|
||||
|
||||
#endif // wxUSE_CLIPBOARD
|
||||
|
Loading…
Reference in New Issue
Block a user