/////////////////////////////////////////////////////////////////////////////
-// Name: clipbrd.cpp
+// Name: src/motif/clipbrd.cpp
// Purpose: Clipboard functionality
// Author: Julian Smart
// Modified by: Mattia Barbon (added support for generic wxDataObjects)
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation
-#pragma implementation "clipbrd.h"
-#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
#ifdef __VMS
#include "wx/vms_x_fix.h"
return wxTheClipboard->IsOpened();
}
-bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
+bool wxIsClipboardFormatAvailable(const wxDataFormat& dataFormat)
{
return wxTheClipboard->IsSupported( dataFormat );
}
return NULL; // just in case...
}
-wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
+wxDataFormat wxEnumClipboardFormats(const wxDataFormat& dataFormat)
{
// Only wxDF_TEXT supported
if (dataFormat == wxDF_TEXT)
return wxDF_INVALID;
}
-bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName,
+bool wxGetClipboardFormatName(const wxDataFormat& dataFormat, char *formatName,
int maxCount)
{
wxStrncpy( formatName, dataFormat.GetId().c_str(), maxCount );
#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxDataObjectList);
-WX_DEFINE_LIST(wxDataIdToDataObjectList);
+WX_DEFINE_LIST(wxDataObjectList)
+WX_DEFINE_LIST(wxDataIdToDataObjectList)
+extern "C"
+{
#if wxCHECK_LESSTIF()
static void wxClipboardCallback( Widget widget, int* data_id,
int* priv, int* reason );
-#else
+#else // Motif
static void wxClipboardCallback( Widget widget, long* data_id,
long* priv, int* reason );
-#endif
+#endif // Less/Motif
+}
IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
wxClipboard::~wxClipboard()
{
- Clear();
+ Clear();
}
void wxClipboard::Clear()
for( wxDataIdToDataObjectList::compatibility_iterator node2 = m_idToObject.GetFirst();
node2; node2 = node2->GetNext() )
- delete node->GetData();
+ {
+ delete node2->GetData();
+ }
m_idToObject.Clear();
}
bool wxClipboard::Open()
{
wxCHECK_MSG( !m_open, false, "clipboard already open" );
-
+
m_open = true;
return true;
return AddData( data );
}
-wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
-wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
+wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray )
+wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray )
#if wxCHECK_LESSTIF()
void wxClipboardCallback( Widget xwidget, int* data_id,
- int* priv, int* reason )
+ int* priv, int* WXUNUSED(reason) )
#else
void wxClipboardCallback( Widget xwidget, long* data_id,
- long* priv, int* reason )
+ long* priv, int* WXUNUSED(reason) )
#endif
{
Display* xdisplay = XtDisplay( xwidget );
m_data.Append( data );
Display* xdisplay = wxGlobalDisplay();
- Widget xwidget = (Widget)wxTheApp->GetTopLevelWidget();
+ Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
Window xwindow = XtWindow( xwidget );
wxXmString label( wxTheApp->GetAppName() );
Time timestamp = XtLastTimestampProcessed( xdisplay );
void wxClipboard::Close()
{
wxCHECK_RET( m_open, "clipboard not open" );
-
+
m_open = false;
}
bool wxClipboard::IsSupported(const wxDataFormat& format)
{
Display* xdisplay = wxGlobalDisplay();
- Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelWidget() );
+ Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelRealizedWidget() );
bool isSupported = false;
int retval, count;
unsigned long max_name_length;
wxCHECK_MSG( m_open, false, "clipboard not open" );
Display* xdisplay = wxGlobalDisplay();
- Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelWidget() );
+ Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelRealizedWidget() );
Time timestamp = XtLastTimestampProcessed( xdisplay );
wxDataFormat chosenFormat;
size_t dfcount = data.GetFormatCount( wxDataObject::Set );
wxDataFormatScopedArray dfarr( new wxDataFormat[dfcount] );
data.GetAllFormats( dfarr.get(), wxDataObject::Set );
-
+
if( XmClipboardInquireCount( xdisplay, xwindow, &count, &max_name_length )
== XmClipboardSuccess )
{