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:
Vadim Zeitlin
1999-10-21 20:16:53 +00:00
parent a64a02efae
commit 12db77cab1
10 changed files with 68 additions and 265 deletions

View File

@@ -412,7 +412,7 @@ private:
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/ole/dataobj2.h" #include "wx/msw/ole/dataobj2.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/dataobj2.h" // #include "wx/motif/dataobj2.h" -- not yet
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk/dataobj2.h" #include "wx/gtk/dataobj2.h"
#endif #endif

View File

@@ -53,6 +53,7 @@ public:
// implementation // implementation
GdkAtom GetMatchingPair(); GdkAtom GetMatchingPair();
void RegisterWidget( GtkWidget *widget ); void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget ); void UnregisterWidget( GtkWidget *widget );

View File

@@ -53,6 +53,7 @@ public:
// implementation // implementation
GdkAtom GetMatchingPair(); GdkAtom GetMatchingPair();
void RegisterWidget( GtkWidget *widget ); void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget ); void UnregisterWidget( GtkWidget *widget );

View File

@@ -1,9 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.h // Name: clipbrd.h
// Purpose: Clipboard functionality. // 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 // Author: Julian Smart
// Modified by: // Modified by:
// Created: 17/09/98 // Created: 17/09/98
@@ -16,14 +13,12 @@
#define _WX_CLIPBRD_H_ #define _WX_CLIPBRD_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "clipbrd.h" #pragma interface "clipbrd.h"
#endif #endif
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
#include "wx/dataobj.h" #include "wx/list.h"
#include "wx/module.h"
bool WXDLLEXPORT wxOpenClipboard(); bool WXDLLEXPORT wxOpenClipboard();
bool WXDLLEXPORT wxClipboardOpen(); bool WXDLLEXPORT wxClipboardOpen();
@@ -52,19 +47,27 @@ public:
// close the clipboard after SetData() and GetData() // close the clipboard after SetData() and GetData()
virtual void Close(); 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 ); virtual bool SetData( wxDataObject *data );
// adds data to the clipboard
virtual bool AddData( wxDataObject *data );
// format available on the clipboard ? // format available on the clipboard ?
// supply ID if private format, the same as wxPrivateDataObject::SetId() virtual bool IsSupported( const wxDataFormat& format );
virtual bool IsSupported( wxDataFormat format );
// fill data with data on the clipboard (if available) // 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 // clears wxTheClipboard and the system's clipboard if possible
virtual void Clear(); virtual void Clear();
virtual void UsePrimarySelection(bool primary = TRUE)
{ m_usePrimary = primary; }
// implementation from now on // implementation from now on
bool m_open; bool m_open;
@@ -75,9 +78,6 @@ private:
DECLARE_DYNAMIC_CLASS(wxClipboard) DECLARE_DYNAMIC_CLASS(wxClipboard)
}; };
/* The clipboard */
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD
#endif #endif

View File

@@ -15,6 +15,8 @@
class wxDataFormat class wxDataFormat
{ {
public: public:
typedef unsigned long /* Atom */ NativeFormat;
wxDataFormat(); wxDataFormat();
wxDataFormat( wxDataFormatId type ); wxDataFormat( wxDataFormatId type );
wxDataFormat( const wxString &id ); wxDataFormat( const wxString &id );
@@ -23,7 +25,7 @@ public:
wxDataFormat( const Atom atom ); wxDataFormat( const Atom atom );
void SetType( wxDataFormatId type ); 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 /* the string Id identifies the format of clipboard or DnD data. a word
* processor would e.g. add a wxTextDataObject and a wxPrivateDataObject * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
@@ -31,20 +33,20 @@ public:
* image manipulation program would put a wxBitmapDataObject and a * image manipulation program would put a wxBitmapDataObject and a
* wxPrivateDataObject to the clipboard - the latter with "image/png". */ * wxPrivateDataObject to the clipboard - the latter with "image/png". */
wxString GetId() const; wxString GetId() const { return m_id; }
void SetId( const wxChar *id ); void SetId( const wxChar *id );
Atom GetAtom(); Atom GetAtom();
void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; } void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; }
// implicit conversion to wxDataFormatId // 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==(NativeFormat type) const { return m_type == type; }
bool operator!=(wxDataFormatId type) const { return m_type != type; } bool operator!=(NativeFormat type) const { return m_type != type; }
private: private:
wxDataFormatId m_type; NativeFormat m_type;
wxString m_id; wxString m_id;
bool m_hasAtom; bool m_hasAtom;
Atom m_atom; Atom m_atom;

View File

@@ -1,149 +1,26 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: dataobj.h // Name: wx/motif/dataobj.h
// Purpose: declaration of the wxDataObject class // Purpose: declaration of the wxDataObject class for Motif
// Author: Julian Smart // Author: Julian Smart
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAOBJ_H_ #ifndef _WX_MOTIF_DATAOBJ_H_
#define _WX_DATAOBJ_H_ #define _WX_MOTIF_DATAOBJ_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "dataobj.h" #pragma interface "dataobj.h"
#endif #endif
#include "wx/defs.h" // ----------------------------------------------------------------------------
#include "wx/object.h" // wxDataObject is the same as wxDataObjectBase under wxMotif
#include "wx/string.h" // ----------------------------------------------------------------------------
#include "wx/bitmap.h"
//------------------------------------------------------------------------- class wxDataObject : public wxDataObjectBase
// classes
//-------------------------------------------------------------------------
class wxDataFormat;
class wxDataObject;
class wxTextDataObject;
//-------------------------------------------------------------------------
// wxDataFormat
//-------------------------------------------------------------------------
class wxDataFormat : public wxObject
{ {
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;
}; };
//---------------------------------------------------------------------------- #endif //_WX_MOTIF_DATAOBJ_H_
// 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_

View File

@@ -29,6 +29,7 @@
#endif #endif
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/module.h"
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// wxClipboardBase // wxClipboardBase

View File

@@ -45,11 +45,11 @@
#include "wx/socket.h" #include "wx/socket.h"
#if defined(__WXMSW__) || defined(__WXPM__) #if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMOTIF__)
#define PROCESS_EVENTS() wxYield() #define PROCESS_EVENTS() wxYield()
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define PROCESS_EVENTS() gtk_main_iteration() #define PROCESS_EVENTS() gtk_main_iteration()
#endif #endif

View File

@@ -275,30 +275,36 @@ bool wxClipboard::SetData( wxDataObject *data )
wxCHECK_MSG( data, FALSE, "data is invalid" ); wxCHECK_MSG( data, FALSE, "data is invalid" );
wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); 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_TEXT:
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
{ {
wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxTextDataObject* textDataObject = (wxTextDataObject*) data;
wxString str(textDataObject->GetText()); wxString str(textDataObject->GetText());
return wxSetClipboardData(data->GetFormat(), (wxObject*) (const char*) str); return wxSetClipboardData(format, (wxObject*) (const char*) str);
break;
} }
/* #if 0
case wxDF_BITMAP: case wxDF_BITMAP:
case wxDF_DIB: case wxDF_DIB:
{ {
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap bitmap(bitmapDataObject->GetBitmap()); wxBitmap bitmap(bitmapDataObject->GetBitmap());
return wxSetClipboardData(data->GetFormat(), & bitmap); return wxSetClipboardData(data->GetType(), & bitmap);
break; break;
} }
*/ #endif // 0
default:
{
return FALSE;
}
} }
return FALSE; return FALSE;
@@ -312,25 +318,26 @@ void wxClipboard::Close()
wxCloseClipboard(); wxCloseClipboard();
} }
bool wxClipboard::IsSupported( wxDataFormat format) bool wxClipboard::IsSupported( const wxDataFormat& format)
{ {
return wxIsClipboardFormatAvailable(format); return wxIsClipboardFormatAvailable(format);
} }
bool wxClipboard::GetData( wxDataObject *data ) bool wxClipboard::GetData( wxDataObject& data )
{ {
wxCHECK_MSG( m_open, FALSE, "clipboard not open" ); wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
switch (data->GetFormat()) wxDataFormat::NativeFormat format = data.GetPreferredFormat().GetType();
switch ( format )
{ {
case wxDF_TEXT: case wxDF_TEXT:
case wxDF_OEMTEXT: case wxDF_OEMTEXT:
{ {
wxTextDataObject* textDataObject = (wxTextDataObject*) data; wxTextDataObject& textDataObject = (wxTextDataObject &) data;
char* s = (char*) wxGetClipboardData(data->GetFormat()); char* s = (char*) wxGetClipboardData(format);
if (s) if (s)
{ {
textDataObject->SetText(s); textDataObject.SetText(s);
delete[] s; delete[] s;
return TRUE; return TRUE;
} }
@@ -343,7 +350,7 @@ bool wxClipboard::GetData( wxDataObject *data )
case wxDF_DIB: case wxDF_DIB:
{ {
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data; wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetFormat()); wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetType());
if (bitmap) if (bitmap)
{ {
bitmapDataObject->SetBitmap(* bitmap); bitmapDataObject->SetBitmap(* bitmap);

View File

@@ -25,14 +25,12 @@
// global data // global data
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
Atom g_textAtom = 0; Atom g_textAtom = 0;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDataFormat // wxDataFormat
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
IMPLEMENT_CLASS(wxDataFormat, wxObject)
wxDataFormat::wxDataFormat() wxDataFormat::wxDataFormat()
{ {
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE ); if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
@@ -122,16 +120,6 @@ void wxDataFormat::SetType( wxDataFormatId type )
m_hasAtom = FALSE; m_hasAtom = FALSE;
} }
wxDataFormatId wxDataFormat::GetType() const
{
return m_type;
}
wxString wxDataFormat::GetId() const
{
return m_id;
}
void wxDataFormat::SetId( const wxChar *id ) void wxDataFormat::SetId( const wxChar *id )
{ {
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
@@ -176,83 +164,7 @@ Atom wxDataFormat::GetAtom()
return m_atom; return m_atom;
} }
//------------------------------------------------------------------------- #if 0
// 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 );
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxPrivateDataObject // wxPrivateDataObject
@@ -302,4 +214,6 @@ void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
memcpy( dest, data, GetSize() ); memcpy( dest, data, GetSize() );
} }
#endif // 0
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD