// Name: src/mac/carbon/clipbrd.cpp
// Purpose: Clipboard functionality
// Author: Stefan Csomor;
-// Generalized clipboard implementation by Matthew Flatt
+// Generalized clipboard implementation by Matthew Flatt
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
#if wxUSE_CLIPBOARD
-#include "wx/app.h"
-#include "wx/frame.h"
-#include "wx/bitmap.h"
-#include "wx/utils.h"
-#include "wx/metafile.h"
#include "wx/clipbrd.h"
-#include "wx/intl.h"
-#include "wx/log.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/frame.h"
+ #include "wx/bitmap.h"
+#endif
+
+#include "wx/metafile.h"
#ifndef __DARWIN__
#include <Scrap.h>
return NULL;
}
- if ( dataFormat.GetType() == wxDF_TEXT )
+ if (dataFormat.GetType() == wxDF_TEXT)
wxMacConvertNewlines10To13( (char*)data );
return data;
wxClipboard::~wxClipboard()
{
- if (m_data)
+ if (m_data != NULL)
{
delete m_data;
- m_data = (wxDataObject*)NULL;
+ m_data = NULL;
}
}
void wxClipboard::Clear()
{
- if (m_data)
+ if (m_data != NULL)
{
delete m_data;
- m_data = (wxDataObject*)NULL;
+ m_data = NULL;
}
#if TARGET_CARBON
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
{
- wxLogTrace( TRACE_CLIPBOARD,
- wxT("wxClipboard now supports atom %s"),
- array[i].GetId().c_str() );
+ if (array[i].IsStandard())
+ {
+ wxLogTrace( TRACE_CLIPBOARD,
+ wxT("wxClipboard now supports standard atom type %d"),
+ array[i].GetType() );
+ }
+ else
+ {
+ wxLogTrace( TRACE_CLIPBOARD,
+ wxT("wxClipboard now supports atom %s"),
+ array[i].GetId().c_str() );
+ }
size_t sz = data->GetDataSize( array[ i ] );
void* buf = malloc( sz + 1 );
- if ( buf )
+ if ( buf != NULL )
{
// empty the buffer because in some case GetDataHere does not fill buf
- memset(buf, 0, sz + 1);
- data->GetDataHere( array[ i ] , buf );
+ memset( buf, 0, sz + 1 );
+ data->GetDataHere( array[ i ], buf );
OSType mactype = 0;
switch ( array[i].GetType() )
{
break;
default:
- mactype = (OSType)(array[i].GetFormatId());
+ mactype = (OSType)(array[ i ].GetFormatId());
break;
}
if ( m_data )
return m_data->IsSupported( dataFormat );
+ bool hasData = false;
+
#if TARGET_CARBON
OSStatus err = noErr;
ScrapRef scrapRef;
{
err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount );
if (err == noErr)
- return true;
+ hasData = true;
+ }
+ else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ {
+ err = GetScrapFlavorFlags( scrapRef, 'TEXT', &flavorFlags );
+ if (err == noErr)
+ {
+ err = GetScrapFlavorSize( scrapRef, 'TEXT', &byteCount );
+ if (err == noErr)
+ hasData = true;
+ }
}
}
- return false;
-
#else
- long offset;
+
+ long offset = 0;
Handle datahandle = NewHandle( 0 );
HLock( datahandle );
GetScrap( datahandle, dataFormat.GetFormatId(), &offset );
HUnlock( datahandle );
- bool hasData = GetHandleSize( datahandle ) > 0;
+ hasData = GetHandleSize( datahandle ) > 0;
DisposeHandle( datahandle );
+#endif
return hasData;
-#endif
}
bool wxClipboard::GetData( wxDataObject& data )
else
{
char *d = new char[ dataSize ];
- m_data->GetDataHere( format, (void*) d );
+ m_data->GetDataHere( format, (void*)d );
data.SetData( format, dataSize, d );
delete [] d;
}
}
delete [] array;
+
return transferred;
}