From 9c3c58491844c139aed733a654cdd823bd1e9c5f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 9 Feb 2003 08:15:35 +0000 Subject: [PATCH] clipboard git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/clipbrd.cpp | 56 +++++++++++++++++++------------------- src/mac/carbon/uma.cpp | 22 ++++++++++++++- src/mac/clipbrd.cpp | 56 +++++++++++++++++++------------------- src/mac/uma.cpp | 22 ++++++++++++++- 4 files changed, 98 insertions(+), 58 deletions(-) diff --git a/src/mac/carbon/clipbrd.cpp b/src/mac/carbon/clipbrd.cpp index 7059fae3c2..997be2fb36 100644 --- a/src/mac/carbon/clipbrd.cpp +++ b/src/mac/carbon/clipbrd.cpp @@ -23,10 +23,10 @@ #include "wx/intl.h" #include "wx/log.h" -#include "wx/mac/private.h" #ifndef __DARWIN__ #include #endif +#include "wx/mac/uma.h" #define wxUSE_DATAOBJ 1 @@ -55,6 +55,9 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) case wxDF_TEXT: break; + case wxDF_BITMAP : + case wxDF_METAFILE : + break ; default: { wxLogError(_("Unsupported clipboard format.")); @@ -240,43 +243,38 @@ bool wxClipboard::AddData( wxDataObject *data ) { mac = textDataObject->GetText() ; } - #if !TARGET_CARBON - err = PutScrap( mac.Length() , 'TEXT' , mac.c_str() ) ; - #else - ScrapRef scrap; - err = GetCurrentScrap (&scrap); - if ( !err ) - { - err = PutScrapFlavor (scrap, 'TEXT', 0, mac.Length(), mac.c_str()); - } - #endif + err = UMAPutScrap( mac.Length() , 'TEXT' , (void*) mac.c_str() ) ; } break ; #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { - wxMetafileDataObject* metaFileDataObject = + wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data; - wxMetafile metaFile = metaFileDataObject->GetMetafile(); - PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; - HLock( (Handle) pict ) ; - #if !TARGET_CARBON - err = PutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - #else - ScrapRef scrap; - err = GetCurrentScrap (&scrap); - if ( !err ) - { - err = PutScrapFlavor (scrap, 'PICT', 0, GetHandleSize((Handle) pict), *pict); - } - #endif - HUnlock( (Handle) pict ) ; + wxMetafile metaFile = metaFileDataObject->GetMetafile(); + PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; } break ; #endif case wxDF_BITMAP: case wxDF_DIB: + { + bool created = false ; + PicHandle pict = NULL ; + + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; + pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; + + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; + if ( created ) + KillPicture( pict ) ; + } default: break ; } @@ -375,8 +373,10 @@ bool wxClipboard::GetData( wxDataObject& data ) switch ( format.GetType() ) { - case wxDF_TEXT: - case wxDF_OEMTEXT: + case wxDF_TEXT : + case wxDF_OEMTEXT : + case wxDF_BITMAP : + case wxDF_METAFILE : { long len ; char* s = (char*)wxGetClipboardData(format, &len ); diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 5485a9eb19..43e9cf7e44 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -1,6 +1,5 @@ #include "wx/defs.h" #include "wx/dc.h" -#include "wx/mac/uma.h" #include #ifndef __DARWIN__ @@ -15,6 +14,11 @@ # endif #endif +#ifndef __DARWIN__ +#include +#endif +#include "wx/mac/uma.h" + // since we have decided that we only support 8.6 upwards we are // checking for these minimum requirements in the startup code of // the application so all wxWindows code can safely assume that appearance 1.1 @@ -829,3 +833,19 @@ wxMacPortStateHelper::~wxMacPortStateHelper() } } +OSStatus UMAPutScrap( Size size , OSType type , void *data ) +{ + OSStatus err = noErr ; +#if !TARGET_CARBON + err = PutScrap( size , type , data ) ; +#else + ScrapRef scrap; + err = GetCurrentScrap (&scrap); + if ( !err ) + { + err = PutScrapFlavor (scrap, type , 0, size, data); + } +#endif + return err ; +} + diff --git a/src/mac/clipbrd.cpp b/src/mac/clipbrd.cpp index 7059fae3c2..997be2fb36 100644 --- a/src/mac/clipbrd.cpp +++ b/src/mac/clipbrd.cpp @@ -23,10 +23,10 @@ #include "wx/intl.h" #include "wx/log.h" -#include "wx/mac/private.h" #ifndef __DARWIN__ #include #endif +#include "wx/mac/uma.h" #define wxUSE_DATAOBJ 1 @@ -55,6 +55,9 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) case wxDF_TEXT: break; + case wxDF_BITMAP : + case wxDF_METAFILE : + break ; default: { wxLogError(_("Unsupported clipboard format.")); @@ -240,43 +243,38 @@ bool wxClipboard::AddData( wxDataObject *data ) { mac = textDataObject->GetText() ; } - #if !TARGET_CARBON - err = PutScrap( mac.Length() , 'TEXT' , mac.c_str() ) ; - #else - ScrapRef scrap; - err = GetCurrentScrap (&scrap); - if ( !err ) - { - err = PutScrapFlavor (scrap, 'TEXT', 0, mac.Length(), mac.c_str()); - } - #endif + err = UMAPutScrap( mac.Length() , 'TEXT' , (void*) mac.c_str() ) ; } break ; #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { - wxMetafileDataObject* metaFileDataObject = + wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data; - wxMetafile metaFile = metaFileDataObject->GetMetafile(); - PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; - HLock( (Handle) pict ) ; - #if !TARGET_CARBON - err = PutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - #else - ScrapRef scrap; - err = GetCurrentScrap (&scrap); - if ( !err ) - { - err = PutScrapFlavor (scrap, 'PICT', 0, GetHandleSize((Handle) pict), *pict); - } - #endif - HUnlock( (Handle) pict ) ; + wxMetafile metaFile = metaFileDataObject->GetMetafile(); + PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; } break ; #endif case wxDF_BITMAP: case wxDF_DIB: + { + bool created = false ; + PicHandle pict = NULL ; + + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; + pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; + + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; + if ( created ) + KillPicture( pict ) ; + } default: break ; } @@ -375,8 +373,10 @@ bool wxClipboard::GetData( wxDataObject& data ) switch ( format.GetType() ) { - case wxDF_TEXT: - case wxDF_OEMTEXT: + case wxDF_TEXT : + case wxDF_OEMTEXT : + case wxDF_BITMAP : + case wxDF_METAFILE : { long len ; char* s = (char*)wxGetClipboardData(format, &len ); diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 5485a9eb19..43e9cf7e44 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -1,6 +1,5 @@ #include "wx/defs.h" #include "wx/dc.h" -#include "wx/mac/uma.h" #include #ifndef __DARWIN__ @@ -15,6 +14,11 @@ # endif #endif +#ifndef __DARWIN__ +#include +#endif +#include "wx/mac/uma.h" + // since we have decided that we only support 8.6 upwards we are // checking for these minimum requirements in the startup code of // the application so all wxWindows code can safely assume that appearance 1.1 @@ -829,3 +833,19 @@ wxMacPortStateHelper::~wxMacPortStateHelper() } } +OSStatus UMAPutScrap( Size size , OSType type , void *data ) +{ + OSStatus err = noErr ; +#if !TARGET_CARBON + err = PutScrap( size , type , data ) ; +#else + ScrapRef scrap; + err = GetCurrentScrap (&scrap); + if ( !err ) + { + err = PutScrapFlavor (scrap, type , 0, size, data); + } +#endif + return err ; +} + -- 2.47.2