From ca9eebc34612c8bc3cdb8530ea355caf3eff5df0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 26 Jan 2011 16:15:39 +0000 Subject: [PATCH] artmac extended for cocoa git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/artprov.h | 2 +- include/wx/osx/cocoa/private.h | 1 + include/wx/osx/iphone/private.h | 1 + src/osx/artmac.cpp | 16 ++++++++++++++-- src/osx/carbon/utilscocoa.mm | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/include/wx/artprov.h b/include/wx/artprov.h index fcc93518f6..2dbf51a23a 100644 --- a/include/wx/artprov.h +++ b/include/wx/artprov.h @@ -253,7 +253,7 @@ private: #if !defined(__WXUNIVERSAL__) && \ ((defined(__WXGTK__) && defined(__WXGTK20__)) || defined(__WXMSW__) || \ - (defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON)) + defined(__WXMAC__)) // *some* (partial) native implementation of wxArtProvider exists; this is // not the same as wxArtProvider::HasNativeProvider()! #define wxHAS_NATIVE_ART_PROVIDER_IMPL diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 6b6bef8e82..139eb57823 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -41,6 +41,7 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( CGImageRef inImage) ; WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image ); CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage ); +wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); class WXDLLIMPEXP_FWD_CORE wxDialog; diff --git a/include/wx/osx/iphone/private.h b/include/wx/osx/iphone/private.h index fd9c022af2..fca0be2880 100644 --- a/include/wx/osx/iphone/private.h +++ b/include/wx/osx/iphone/private.h @@ -26,6 +26,7 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( CGImageRef inImage) ; WX_UIImage WXDLLIMPEXP_CORE wxOSXGetUIImageFromCGImage( CGImageRef image ); +wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size); class WXDLLIMPEXP_CORE wxWidgetIPhoneImpl : public wxWidgetImpl { diff --git a/src/osx/artmac.cpp b/src/osx/artmac.cpp index 04acf5caf4..267516cb7a 100644 --- a/src/osx/artmac.cpp +++ b/src/osx/artmac.cpp @@ -25,7 +25,7 @@ #include "wx/image.h" #endif -#if wxOSX_USE_COCOA_OR_CARBON +#include "wx/osx/private.h" // ---------------------------------------------------------------------------- // wxMacArtProvider @@ -34,8 +34,18 @@ class wxMacArtProvider : public wxArtProvider { protected: +#if wxOSX_USE_COCOA_OR_CARBON virtual wxIconBundle CreateIconBundle(const wxArtID& id, const wxArtClient& client); +#endif +#if wxOSX_USE_COCOA_OR_IPHONE + virtual wxBitmap CreateBitmap(const wxArtID& id, + const wxArtClient& client, + const wxSize& size) + { + return wxOSXCreateSystemBitmap(id, client, size); + } +#endif }; /* static */ void wxArtProvider::InitNativeProvider() @@ -43,6 +53,8 @@ protected: wxArtProvider::Push(new wxMacArtProvider); } +#if wxOSX_USE_COCOA_OR_CARBON + // ---------------------------------------------------------------------------- // helper macros // ---------------------------------------------------------------------------- @@ -103,6 +115,7 @@ wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtCl return wxMacArtProvider_CreateIconBundle(id); } +#endif // ---------------------------------------------------------------------------- // wxArtProvider::GetNativeSizeHint() @@ -129,4 +142,3 @@ wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client) return wxDefaultSize; } -#endif // wxOSX_USE_COCOA_CARBON diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index 49fc2247d0..41bda29155 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -353,10 +353,28 @@ WX_UIImage wxOSXGetUIImageFromCGImage( CGImageRef image ) return( newImage ); } +wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &client, const wxSize& size) +{ +#if 0 + // unfortunately this only accesses images in the app bundle, not the system wide globals + wxCFStringRef cfname(name); + return wxBitmap( [[UIImage imageNamed:cfname.AsNSString()] CGImage] ); +#else + return wxBitmap(); +#endif +} + #endif #if wxOSX_USE_COCOA +wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &client, const wxSize& size) +{ + wxCFStringRef cfname(name); + wxCFRef image( wxOSXCreateCGImageFromNSImage([NSImage imageNamed:cfname.AsNSString()]) ); + return wxBitmap( image ); +} + // From "Cocoa Drawing Guide:Working with Images" WX_NSImage wxOSXGetNSImageFromCGImage( CGImageRef image ) { -- 2.45.2