]> git.saurik.com Git - wxWidgets.git/commitdiff
clipboard
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 9 Feb 2003 08:15:35 +0000 (08:15 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 9 Feb 2003 08:15:35 +0000 (08:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19151 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/clipbrd.cpp
src/mac/carbon/uma.cpp
src/mac/clipbrd.cpp
src/mac/uma.cpp

index 7059fae3c20bace9124e955fa1738c9f5443834b..997be2fb36718254a57c315f74b83a0b6b99d5f8 100644 (file)
 #include "wx/intl.h"
 #include "wx/log.h"
 
-#include "wx/mac/private.h"
 #ifndef __DARWIN__
 #include <Scrap.h>
 #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 );
index 5485a9eb19ab75b1367647e8b24967d33ad97046..43e9cf7e4427dff94e993c1dd3e1d284c64092b8 100644 (file)
@@ -1,6 +1,5 @@
 #include "wx/defs.h"
 #include "wx/dc.h"
-#include "wx/mac/uma.h"
 #include <MacTextEditor.h>
 
 #ifndef __DARWIN__
 #  endif
 #endif
 
+#ifndef __DARWIN__
+#include <Scrap.h>
+#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 ;
+}
+
index 7059fae3c20bace9124e955fa1738c9f5443834b..997be2fb36718254a57c315f74b83a0b6b99d5f8 100644 (file)
 #include "wx/intl.h"
 #include "wx/log.h"
 
-#include "wx/mac/private.h"
 #ifndef __DARWIN__
 #include <Scrap.h>
 #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 );
index 5485a9eb19ab75b1367647e8b24967d33ad97046..43e9cf7e4427dff94e993c1dd3e1d284c64092b8 100644 (file)
@@ -1,6 +1,5 @@
 #include "wx/defs.h"
 #include "wx/dc.h"
-#include "wx/mac/uma.h"
 #include <MacTextEditor.h>
 
 #ifndef __DARWIN__
 #  endif
 #endif
 
+#ifndef __DARWIN__
+#include <Scrap.h>
+#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 ;
+}
+