]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/clipbrd.cpp
deprecate wxDC::SetClippingRegion(wxRegion) overload and replace it with SetDeviceCli...
[wxWidgets.git] / src / motif / clipbrd.cpp
index 275c02fd53dcb1743168c2ac876b9e3bbc3ae1aa..79b013563b77f5fe07a5fc95d9097343fcc74bd0 100644 (file)
@@ -1,18 +1,16 @@
 /////////////////////////////////////////////////////////////////////////////
-// 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
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#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"
 #define XtDisplay XTDISPLAY
 #endif
 
-#include "wx/defs.h"
-
 #if wxUSE_CLIPBOARD
 
-#include "wx/app.h"
-#include "wx/bitmap.h"
-#include "wx/utils.h"
 #include "wx/clipbrd.h"
-#include "wx/dataobj.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/bitmap.h"
+    #include "wx/dataobj.h"
+#endif
+
 #include "wx/ptr_scpd.h"
 
 #ifdef __VMS__
@@ -69,7 +69,7 @@ bool wxClipboardOpen()
     return wxTheClipboard->IsOpened();
 }
 
-bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
+bool wxIsClipboardFormatAvailable(const wxDataFormat& dataFormat)
 {
     return wxTheClipboard->IsSupported( dataFormat );
 }
@@ -131,7 +131,7 @@ wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
     return NULL; // just in case...
 }
 
-wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
+wxDataFormat wxEnumClipboardFormats(const wxDataFormat& dataFormat)
 {
     // Only wxDF_TEXT supported
     if (dataFormat == wxDF_TEXT)
@@ -146,7 +146,7 @@ wxDataFormat wxRegisterClipboardFormat(char *WXUNUSED(formatName))
     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 );
@@ -170,16 +170,19 @@ struct wxDataIdToDataObject
 
 #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)
 
@@ -190,12 +193,12 @@ wxClipboard::wxClipboard()
 
 wxClipboard::~wxClipboard()
 {
-    Clear();  
+    Clear();
 }
 
 void wxClipboard::Clear()
 {
-    wxDataObjectList::Node* node = m_data.GetFirst();
+    wxDataObjectList::compatibility_iterator node = m_data.GetFirst();
     while (node)
     {
         delete node->GetData();
@@ -203,16 +206,18 @@ void wxClipboard::Clear()
     }
     m_data.Clear();
 
-    for( wxDataIdToDataObjectList::Node* node2 = m_idToObject.GetFirst();
+    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;
@@ -228,15 +233,15 @@ bool wxClipboard::SetData( wxDataObject *data )
     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 );
@@ -244,7 +249,7 @@ void wxClipboardCallback( Widget xwidget, long* data_id,
     wxDataObject* dobj = NULL;
     size_t size = 0;
 
-    for( wxDataIdToDataObjectList::Node* node2 =
+    for( wxDataIdToDataObjectList::compatibility_iterator node2 =
              wxTheClipboard->m_idToObject.GetFirst();
          node2; node2 = node2->GetNext() )
     {
@@ -280,9 +285,9 @@ bool wxClipboard::AddData( wxDataObject *data )
     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() );
+    wxXmString label( wxTheApp->GetAppDisplayName() );
     Time timestamp = XtLastTimestampProcessed( xdisplay );
     long itemId;
 
@@ -307,7 +312,7 @@ bool wxClipboard::AddData( wxDataObject *data )
         wxString id = dfarr[i].GetId();
 
         while( ( retval = XmClipboardCopy( xdisplay, xwindow, itemId,
-                                           wxConstCast(id.c_str(), char),
+                                           id.char_str(),
                                            NULL, size, i, &data_id ) )
                == XmClipboardLocked );
 
@@ -323,14 +328,14 @@ bool wxClipboard::AddData( wxDataObject *data )
 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;
@@ -390,7 +395,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     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;
@@ -412,7 +417,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     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 )
     {
@@ -456,7 +461,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     wxString id = chosenFormat.GetId();
 
     while( ( retval = XmClipboardInquireLength( xdisplay, xwindow,
-                                                wxConstCast(id.c_str(), char),
+                                                id.char_str(),
                                                 &length ) )
            == XmClipboardLocked );
     if( retval != XmClipboardSuccess )
@@ -465,7 +470,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     wxCharBuffer buf(length);
 
     while( ( retval = XmClipboardRetrieve( xdisplay, xwindow,
-                                           wxConstCast(id.c_str(), char),
+                                           id.char_str(),
                                            (XtPointer)buf.data(),
                                            length, &dummy1, &dummy2 ) )
            == XmClipboardLocked );