]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/clipbrd.cpp
Fix crash in wxDC::GetMultiLineTextExtent() after last commit.
[wxWidgets.git] / src / motif / clipbrd.cpp
index 4af95a45ad40e73fbfca02cd8345d6c7477e67cb..6a383909435d4c22d8952223db9571747e082bb0 100644 (file)
@@ -1,19 +1,14 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// 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
 // 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"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #define XtDisplay XTDISPLAY
 #endif
 
 #define XtDisplay XTDISPLAY
 #endif
 
-#include "wx/defs.h"
-
 #if wxUSE_CLIPBOARD
 
 #if wxUSE_CLIPBOARD
 
-#include "wx/app.h"
-#include "wx/bitmap.h"
-#include "wx/utils.h"
 #include "wx/clipbrd.h"
 #include "wx/clipbrd.h"
-#include "wx/dataobj.h"
-#include "wx/ptr_scpd.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/bitmap.h"
+    #include "wx/dataobj.h"
+#endif
+
+#include "wx/scopedarray.h"
+
+typedef wxScopedArray<wxDataFormat> wxDataFormatScopedArray;
 
 #ifdef __VMS__
 #pragma message disable nosimpint
 
 #ifdef __VMS__
 #pragma message disable nosimpint
@@ -72,7 +71,7 @@ bool wxClipboardOpen()
     return wxTheClipboard->IsOpened();
 }
 
     return wxTheClipboard->IsOpened();
 }
 
-bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
+bool wxIsClipboardFormatAvailable(const wxDataFormat& dataFormat)
 {
     return wxTheClipboard->IsSupported( dataFormat );
 }
 {
     return wxTheClipboard->IsSupported( dataFormat );
 }
@@ -134,7 +133,7 @@ wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
     return NULL; // just in case...
 }
 
     return NULL; // just in case...
 }
 
-wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
+wxDataFormat wxEnumClipboardFormats(const wxDataFormat& dataFormat)
 {
     // Only wxDF_TEXT supported
     if (dataFormat == wxDF_TEXT)
 {
     // Only wxDF_TEXT supported
     if (dataFormat == wxDF_TEXT)
@@ -149,10 +148,10 @@ wxDataFormat wxRegisterClipboardFormat(char *WXUNUSED(formatName))
     return wxDF_INVALID;
 }
 
     return wxDF_INVALID;
 }
 
-bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName,
+bool wxGetClipboardFormatName(const wxDataFormat& dataFormat, char *formatName,
                               int maxCount)
 {
                               int maxCount)
 {
-    wxStrncpy( formatName, dataFormat.GetId().c_str(), maxCount );
+    wxStrlcpy( formatName, dataFormat.GetId().c_str(), maxCount );
 
     return true;
 }
 
     return true;
 }
@@ -173,16 +172,19 @@ struct wxDataIdToDataObject
 
 #include "wx/listimpl.cpp"
 
 
 #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 );
 #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 );
 static void wxClipboardCallback( Widget widget, long* data_id,
                                  long* priv, int* reason );
-#endif
+#endif // Less/Motif
+}
 
 IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
 
@@ -193,7 +195,7 @@ wxClipboard::wxClipboard()
 
 wxClipboard::~wxClipboard()
 {
 
 wxClipboard::~wxClipboard()
 {
-    Clear();  
+    Clear();
 }
 
 void wxClipboard::Clear()
 }
 
 void wxClipboard::Clear()
@@ -208,14 +210,16 @@ void wxClipboard::Clear()
 
     for( wxDataIdToDataObjectList::compatibility_iterator node2 = m_idToObject.GetFirst();
          node2; node2 = node2->GetNext() )
 
     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_idToObject.Clear();
 }
 
 bool wxClipboard::Open()
 {
     wxCHECK_MSG( !m_open, false, "clipboard already open" );
-  
+
     m_open = true;
 
     return true;
     m_open = true;
 
     return true;
@@ -231,15 +235,12 @@ bool wxClipboard::SetData( wxDataObject *data )
     return AddData( data );
 }
 
     return AddData( data );
 }
 
-wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
-wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
-
 #if wxCHECK_LESSTIF()
 void wxClipboardCallback( Widget xwidget, int* data_id,
 #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,
 #else
 void wxClipboardCallback( Widget xwidget, long* data_id,
-                          long* priv, int* reason )
+                          long* priv, int* WXUNUSED(reason) )
 #endif
 {
     Display* xdisplay = XtDisplay( xwidget );
 #endif
 {
     Display* xdisplay = XtDisplay( xwidget );
@@ -285,7 +286,7 @@ bool wxClipboard::AddData( wxDataObject *data )
     Display* xdisplay = wxGlobalDisplay();
     Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
     Window xwindow = XtWindow( xwidget );
     Display* xdisplay = wxGlobalDisplay();
     Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
     Window xwindow = XtWindow( xwidget );
-    wxXmString label( wxTheApp->GetAppName() );
+    wxXmString label( wxTheApp->GetAppDisplayName() );
     Time timestamp = XtLastTimestampProcessed( xdisplay );
     long itemId;
 
     Time timestamp = XtLastTimestampProcessed( xdisplay );
     long itemId;
 
@@ -310,7 +311,7 @@ bool wxClipboard::AddData( wxDataObject *data )
         wxString id = dfarr[i].GetId();
 
         while( ( retval = XmClipboardCopy( xdisplay, xwindow, itemId,
         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 );
 
                                            NULL, size, i, &data_id ) )
                == XmClipboardLocked );
 
@@ -326,7 +327,7 @@ bool wxClipboard::AddData( wxDataObject *data )
 void wxClipboard::Close()
 {
     wxCHECK_RET( m_open, "clipboard not open" );
 void wxClipboard::Close()
 {
     wxCHECK_RET( m_open, "clipboard not open" );
-    
+
     m_open = false;
 }
 
     m_open = false;
 }
 
@@ -415,7 +416,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     size_t dfcount = data.GetFormatCount( wxDataObject::Set );
     wxDataFormatScopedArray dfarr( new wxDataFormat[dfcount] );
     data.GetAllFormats( dfarr.get(), wxDataObject::Set );
     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 )
     {
     if( XmClipboardInquireCount( xdisplay, xwindow, &count, &max_name_length )
         == XmClipboardSuccess )
     {
@@ -459,7 +460,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     wxString id = chosenFormat.GetId();
 
     while( ( retval = XmClipboardInquireLength( xdisplay, xwindow,
     wxString id = chosenFormat.GetId();
 
     while( ( retval = XmClipboardInquireLength( xdisplay, xwindow,
-                                                wxConstCast(id.c_str(), char),
+                                                id.char_str(),
                                                 &length ) )
            == XmClipboardLocked );
     if( retval != XmClipboardSuccess )
                                                 &length ) )
            == XmClipboardLocked );
     if( retval != XmClipboardSuccess )
@@ -468,7 +469,7 @@ bool wxClipboard::GetData( wxDataObject& data )
     wxCharBuffer buf(length);
 
     while( ( retval = XmClipboardRetrieve( xdisplay, xwindow,
     wxCharBuffer buf(length);
 
     while( ( retval = XmClipboardRetrieve( xdisplay, xwindow,
-                                           wxConstCast(id.c_str(), char),
+                                           id.char_str(),
                                            (XtPointer)buf.data(),
                                            length, &dummy1, &dummy2 ) )
            == XmClipboardLocked );
                                            (XtPointer)buf.data(),
                                            length, &dummy1, &dummy2 ) )
            == XmClipboardLocked );