cleanup mac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
09b632b21a
commit
e1673e527f
@ -43,15 +43,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||
// under Quartz then content is transformed into a CGImageRef representing the same data
|
||||
// which can be transferred to the GPU by the OS for fast rendering
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#define wxMAC_USE_PREMULTIPLIED_ALPHA 1
|
||||
static const int kBestByteAlignement = 16;
|
||||
static const int kMaskBytesPerPixel = 1;
|
||||
#else
|
||||
#define wxMAC_USE_PREMULTIPLIED_ALPHA 0
|
||||
static const int kBestByteAlignement = 4;
|
||||
static const int kMaskBytesPerPixel = 4;
|
||||
#endif
|
||||
#define wxMAC_USE_PREMULTIPLIED_ALPHA 1
|
||||
static const int kBestByteAlignement = 16;
|
||||
static const int kMaskBytesPerPixel = 1;
|
||||
|
||||
static int GetBestBytesPerRow( int rawBytes )
|
||||
{
|
||||
@ -71,17 +65,7 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
|
||||
|
||||
if ( forceType == 0 )
|
||||
{
|
||||
// NOTE : For testing Panther behaviour under higher
|
||||
// Systems make this always be false
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
{
|
||||
// as soon as it is supported, it's a better default
|
||||
forceType = kControlContentCGImageRef;
|
||||
}
|
||||
else if ( bmap->HasNativeSize() )
|
||||
{
|
||||
forceType = kControlContentIconRef;
|
||||
}
|
||||
forceType = kControlContentCGImageRef;
|
||||
}
|
||||
|
||||
if ( forceType == kControlContentIconRef )
|
||||
@ -172,10 +156,6 @@ void wxBitmapRefData::Init()
|
||||
m_iconRef = NULL ;
|
||||
m_pictHandle = NULL ;
|
||||
m_hBitmap = NULL ;
|
||||
#if! wxMAC_USE_CORE_GRAPHICS
|
||||
m_hMaskBitmap = NULL;
|
||||
m_maskBytesPerRow = 0 ;
|
||||
#endif
|
||||
|
||||
m_rawAccessCount = 0 ;
|
||||
m_hasAlpha = false;
|
||||
@ -221,17 +201,11 @@ bool wxBitmapRefData::Create( int w , int h , int d )
|
||||
m_memBuf.UngetWriteBuf( size ) ;
|
||||
|
||||
m_hBitmap = NULL ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
Rect rect = { 0 , 0 , m_height , m_width } ;
|
||||
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||
(char*) data , m_bytesPerRow ) ) ;
|
||||
wxASSERT_MSG( m_hBitmap , wxT("Unable to create GWorld context") ) ;
|
||||
#else
|
||||
m_hBitmap = CGBitmapContextCreate((char*) data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst );
|
||||
wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
|
||||
CGContextTranslateCTM( m_hBitmap, 0, m_height );
|
||||
CGContextScaleCTM( m_hBitmap, 1, -1 );
|
||||
#endif
|
||||
|
||||
m_ok = ( m_hBitmap != NULL ) ;
|
||||
|
||||
return m_ok ;
|
||||
@ -243,43 +217,12 @@ void wxBitmapRefData::UseAlpha( bool use )
|
||||
return ;
|
||||
|
||||
m_hasAlpha = use ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
CGContextRelease( m_hBitmap );
|
||||
m_hBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), m_hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst );
|
||||
wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
|
||||
CGContextTranslateCTM( m_hBitmap, 0, m_height );
|
||||
CGContextScaleCTM( m_hBitmap, 1, -1 );
|
||||
#else
|
||||
if ( m_hasAlpha )
|
||||
{
|
||||
wxASSERT( m_hMaskBitmap == NULL ) ;
|
||||
|
||||
int width = GetWidth() ;
|
||||
int height = GetHeight() ;
|
||||
m_maskBytesPerRow = GetBestBytesPerRow( width * kMaskBytesPerPixel );
|
||||
size_t size = height * m_maskBytesPerRow ;
|
||||
unsigned char * data = (unsigned char * ) m_maskMemBuf.GetWriteBuf( size ) ;
|
||||
wxASSERT( data != NULL ) ;
|
||||
|
||||
memset( data , 0 , size ) ;
|
||||
Rect rect = { 0 , 0 , height , width } ;
|
||||
|
||||
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hMaskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||
(char*) data , m_maskBytesPerRow ) ) ;
|
||||
wxASSERT_MSG( m_hMaskBitmap , wxT("Unable to create GWorld context for alpha mask") ) ;
|
||||
|
||||
m_maskMemBuf.UngetWriteBuf(size) ;
|
||||
|
||||
|
||||
UpdateAlphaMask() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisposeGWorld( m_hMaskBitmap ) ;
|
||||
m_hMaskBitmap = NULL ;
|
||||
m_maskBytesPerRow = 0 ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void *wxBitmapRefData::GetRawAccess() const
|
||||
@ -314,10 +257,6 @@ void wxBitmapRefData::EndRawAccess()
|
||||
wxASSERT( m_rawAccessCount == 1 ) ;
|
||||
|
||||
--m_rawAccessCount ;
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
UpdateAlphaMask() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxBitmapRefData::HasNativeSize()
|
||||
@ -335,18 +274,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
{
|
||||
// Create Icon Family Handle
|
||||
|
||||
IconFamilyHandle iconFamily = NULL ;
|
||||
|
||||
if ( UMAGetSystemVersion() < 0x1040 )
|
||||
{
|
||||
iconFamily = (IconFamilyHandle) NewHandle( 8 ) ;
|
||||
(**iconFamily).resourceType = kIconFamilyType ;
|
||||
(**iconFamily).resourceSize = sizeof(OSType) + sizeof(Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
iconFamily = (IconFamilyHandle) NewHandle( 0 ) ;
|
||||
}
|
||||
IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle( 0 );
|
||||
|
||||
int w = GetWidth() ;
|
||||
int h = GetHeight() ;
|
||||
@ -358,7 +286,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
switch (sz)
|
||||
{
|
||||
case 128:
|
||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||
{
|
||||
dataType = kIconServices128PixelDataARGB ;
|
||||
@ -372,7 +300,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
break;
|
||||
|
||||
case 48:
|
||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||
{
|
||||
dataType = kIconServices48PixelDataARGB ;
|
||||
@ -386,7 +314,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
break;
|
||||
|
||||
case 32:
|
||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||
{
|
||||
dataType = kIconServices32PixelDataARGB ;
|
||||
@ -400,7 +328,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
break;
|
||||
|
||||
case 16:
|
||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||
{
|
||||
dataType = kIconServices16PixelDataARGB ;
|
||||
@ -419,7 +347,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
|
||||
if ( dataType != 0 )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if ( maskType == 0 && UMAGetSystemVersion() >= 0x1050 )
|
||||
{
|
||||
size_t datasize = sz * sz * 4 ;
|
||||
@ -525,14 +453,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
||||
*dest++ = b ;
|
||||
|
||||
if ( mask )
|
||||
{
|
||||
*maskdest++ = 0xFF - *masksource++ ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
masksource++ ;
|
||||
masksource++ ;
|
||||
masksource++ ;
|
||||
#endif
|
||||
}
|
||||
else if ( hasAlpha )
|
||||
*maskdest++ = a ;
|
||||
else
|
||||
@ -574,77 +495,6 @@ PicHandle wxBitmapRefData::GetPictHandle()
|
||||
{
|
||||
if ( m_pictHandle == NULL )
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
CGrafPtr origPort = NULL ;
|
||||
GDHandle origDev = NULL ;
|
||||
GWorldPtr wp = NULL ;
|
||||
GWorldPtr mask = NULL ;
|
||||
int height = GetHeight() ;
|
||||
int width = GetWidth() ;
|
||||
|
||||
Rect rect = { 0 , 0 , height , width } ;
|
||||
RgnHandle clipRgn = NULL ;
|
||||
|
||||
GetGWorld( &origPort , &origDev ) ;
|
||||
wp = GetHBITMAP( &mask ) ;
|
||||
|
||||
if ( mask )
|
||||
{
|
||||
GWorldPtr monoworld ;
|
||||
clipRgn = NewRgn() ;
|
||||
OSStatus err = NewGWorld( &monoworld , 1 , &rect , NULL , NULL , 0 ) ;
|
||||
verify_noerr(err) ;
|
||||
LockPixels( GetGWorldPixMap( monoworld ) ) ;
|
||||
LockPixels( GetGWorldPixMap( mask ) ) ;
|
||||
SetGWorld( monoworld , NULL ) ;
|
||||
|
||||
RGBColor white = { 0xffff , 0xffff , 0xffff } ;
|
||||
RGBColor black = { 0x0000 , 0x0000 , 0x0000 } ;
|
||||
RGBForeColor( &black ) ;
|
||||
RGBBackColor( &white ) ;
|
||||
|
||||
CopyBits(GetPortBitMapForCopyBits(mask),
|
||||
GetPortBitMapForCopyBits(monoworld),
|
||||
&rect,
|
||||
&rect,
|
||||
srcCopy, NULL);
|
||||
BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( monoworld ) ) ;
|
||||
|
||||
UnlockPixels( GetGWorldPixMap( monoworld ) ) ;
|
||||
UnlockPixels( GetGWorldPixMap( mask ) ) ;
|
||||
DisposeGWorld( monoworld ) ;
|
||||
}
|
||||
|
||||
SetGWorld( wp , NULL ) ;
|
||||
Rect portRect ;
|
||||
GetPortBounds( wp , &portRect ) ;
|
||||
m_pictHandle = OpenPicture(&portRect);
|
||||
|
||||
if (m_pictHandle)
|
||||
{
|
||||
RGBColor white = { 0xffff , 0xffff , 0xffff } ;
|
||||
RGBColor black = { 0x0000 , 0x0000 , 0x0000 } ;
|
||||
|
||||
RGBForeColor( &black ) ;
|
||||
RGBBackColor( &white ) ;
|
||||
|
||||
if ( clipRgn )
|
||||
SetClip( clipRgn ) ;
|
||||
|
||||
LockPixels( GetGWorldPixMap( wp ) ) ;
|
||||
CopyBits(GetPortBitMapForCopyBits(wp),
|
||||
GetPortBitMapForCopyBits(wp),
|
||||
&portRect,
|
||||
&portRect,
|
||||
srcCopy,clipRgn);
|
||||
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
||||
ClosePicture();
|
||||
}
|
||||
|
||||
SetGWorld( origPort , origDev ) ;
|
||||
if ( clipRgn )
|
||||
DisposeRgn( clipRgn ) ;
|
||||
#else
|
||||
#ifndef __LP64__
|
||||
GraphicsExportComponent exporter = 0;
|
||||
OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &exporter);
|
||||
@ -671,7 +521,6 @@ PicHandle wxBitmapRefData::GetPictHandle()
|
||||
}
|
||||
CloseComponent( exporter );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -694,8 +543,7 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
||||
CGImageRef image ;
|
||||
if ( m_rawAccessCount > 0 || m_cgImageRef == NULL )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( UMAGetSystemVersion() >= 0x1040 && m_depth != 1 && m_bitmapMask == NULL )
|
||||
if ( m_depth != 1 && m_bitmapMask == NULL )
|
||||
{
|
||||
if ( m_bitmapMask )
|
||||
{
|
||||
@ -709,7 +557,6 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
||||
image = CGBitmapContextCreateImage( m_hBitmap );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
size_t imageSize = m_height * m_bytesPerRow ;
|
||||
void * dataBuffer = m_memBuf.GetData() ;
|
||||
@ -800,61 +647,10 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
||||
return image ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef wxBitmapRefData::GetBitmapContext() const
|
||||
{
|
||||
return m_hBitmap;
|
||||
}
|
||||
#else
|
||||
GWorldPtr wxBitmapRefData::GetHBITMAP(GWorldPtr* mask) const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
|
||||
if ( mask )
|
||||
{
|
||||
*mask = NULL ;
|
||||
if ( m_bitmapMask )
|
||||
{
|
||||
*mask = (GWorldPtr) m_bitmapMask->GetHBITMAP() ;
|
||||
}
|
||||
else if ( m_hasAlpha )
|
||||
{
|
||||
if ( m_rawAccessCount > 0 )
|
||||
UpdateAlphaMask() ;
|
||||
*mask = m_hMaskBitmap ;
|
||||
}
|
||||
}
|
||||
|
||||
return m_hBitmap ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
void wxBitmapRefData::UpdateAlphaMask() const
|
||||
{
|
||||
if ( m_hasAlpha )
|
||||
{
|
||||
unsigned char *sourcemask = (unsigned char *) GetRawAccess() ;
|
||||
unsigned char *destalphabase = (unsigned char *) m_maskMemBuf.GetData() ;
|
||||
|
||||
int h = GetHeight() ;
|
||||
int w = GetWidth() ;
|
||||
|
||||
for ( int y = 0 ; y < h ; ++y , destalphabase += m_maskBytesPerRow )
|
||||
{
|
||||
unsigned char* destalpha = destalphabase ;
|
||||
|
||||
for ( int x = 0 ; x < w ; ++x , sourcemask += 4 )
|
||||
{
|
||||
// we must have 24 bit depth for non quartz smooth alpha
|
||||
*destalpha++ = 255 ;
|
||||
*destalpha++ = 255 - *sourcemask ;
|
||||
*destalpha++ = 255 - *sourcemask ;
|
||||
*destalpha++ = 255 - *sourcemask ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxBitmapRefData::Free()
|
||||
{
|
||||
@ -882,21 +678,10 @@ void wxBitmapRefData::Free()
|
||||
|
||||
if ( m_hBitmap )
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
DisposeGWorld( MAC_WXHBITMAP(m_hBitmap) ) ;
|
||||
#else
|
||||
CGContextRelease(m_hBitmap);
|
||||
#endif
|
||||
m_hBitmap = NULL ;
|
||||
}
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
if ( m_hMaskBitmap )
|
||||
{
|
||||
DisposeGWorld( MAC_WXHBITMAP(m_hMaskBitmap) ) ;
|
||||
m_hMaskBitmap = NULL ;
|
||||
}
|
||||
#endif
|
||||
if (m_bitmapMask)
|
||||
{
|
||||
delete m_bitmapMask;
|
||||
@ -1394,11 +1179,6 @@ wxImage wxBitmap::ConvertToImage() const
|
||||
}
|
||||
else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE )
|
||||
b = MASK_BLUE_REPLACEMENT ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
maskp++ ;
|
||||
maskp++ ;
|
||||
maskp++ ;
|
||||
#endif
|
||||
}
|
||||
else if ( hasAlpha )
|
||||
{
|
||||
@ -1544,13 +1324,9 @@ void wxBitmap::SetMask(wxMask *mask)
|
||||
|
||||
WXHBITMAP wxBitmap::GetHBITMAP(WXHBITMAP* mask) const
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
return WXHBITMAP(M_BITMAPDATA->GetHBITMAP((GWorldPtr*)mask));
|
||||
#else
|
||||
wxUnusedVar(mask);
|
||||
|
||||
return WXHBITMAP(M_BITMAPDATA->GetBitmapContext());
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1605,11 +1381,7 @@ wxMask::~wxMask()
|
||||
{
|
||||
if ( m_maskBitmap )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRelease( (CGContextRef) m_maskBitmap );
|
||||
#else
|
||||
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
|
||||
#endif
|
||||
m_maskBitmap = NULL ;
|
||||
}
|
||||
}
|
||||
@ -1632,15 +1404,10 @@ void wxMask::RealizeNative()
|
||||
{
|
||||
if ( m_maskBitmap )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRelease( (CGContextRef) m_maskBitmap );
|
||||
#else
|
||||
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
|
||||
#endif
|
||||
m_maskBitmap = NULL ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
|
||||
// from MouseTracking sample :
|
||||
// Ironically, due to a bug in CGImageCreateWithMask, you cannot use
|
||||
@ -1650,14 +1417,6 @@ void wxMask::RealizeNative()
|
||||
kCGImageAlphaNone );
|
||||
CGColorSpaceRelease( colorspace );
|
||||
wxASSERT_MSG( m_maskBitmap , wxT("Unable to create CGBitmapContext context") ) ;
|
||||
#else
|
||||
Rect rect = { 0 , 0 , m_height , m_width } ;
|
||||
|
||||
OSStatus err = NewGWorldFromPtr(
|
||||
(GWorldPtr*) &m_maskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||
(char*) m_memBuf.GetData() , m_bytesPerRow ) ;
|
||||
verify_noerr( err ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create a mask from a mono bitmap (copies the bitmap).
|
||||
@ -1703,23 +1462,9 @@ bool wxMask::Create(const wxBitmap& bitmap)
|
||||
b = *srcdata++ ;
|
||||
|
||||
if ( ( r + g + b ) > 0x10 )
|
||||
{
|
||||
*destdata++ = 0xFF ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
*destdata++ = 0xFF ;
|
||||
*destdata++ = 0xFF ;
|
||||
*destdata++ = 0xFF ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
*destdata++ = 0x00 ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
*destdata++ = 0x00 ;
|
||||
*destdata++ = 0x00 ;
|
||||
*destdata++ = 0x00 ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1759,23 +1504,9 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||
b = *srcdata++ ;
|
||||
|
||||
if ( colour == wxColour( r , g , b ) )
|
||||
{
|
||||
*destdata++ = 0xFF ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
*destdata++ = 0xFF ;
|
||||
*destdata++ = 0xFF ;
|
||||
*destdata++ = 0xFF ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
*destdata++ = 0x00 ;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
*destdata++ = 0x00 ;
|
||||
*destdata++ = 0x00 ;
|
||||
*destdata++ = 0x00 ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,23 +166,11 @@ wxSize wxButton::DoGetBestSize() const
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxClientDC dc(const_cast<wxButton*>(this));
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( m_label , &width, &height);
|
||||
bounds.h = width;
|
||||
bounds.v = height;
|
||||
#else
|
||||
wxMacWindowStateSaver sv( this );
|
||||
::TextFont( m_font.MacGetFontNum() );
|
||||
::TextSize( (short)(m_font.MacGetFontSize()) );
|
||||
::TextFace( m_font.MacGetFontStyle() );
|
||||
|
||||
err = GetThemeTextDimensions(
|
||||
(!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
|
||||
kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline );
|
||||
verify_noerr( err );
|
||||
#endif
|
||||
}
|
||||
|
||||
wBtn = bounds.h + sz.y;
|
||||
|
@ -274,62 +274,28 @@ wxSize wxChoice::DoGetBestSize() const
|
||||
lbHeight = metric ;
|
||||
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxClientDC dc(const_cast<wxChoice*>(this));
|
||||
#else
|
||||
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ;
|
||||
if ( m_font.Ok() )
|
||||
{
|
||||
::TextFont( m_font.MacGetFontNum() ) ;
|
||||
::TextSize( m_font.MacGetFontSize() ) ;
|
||||
::TextFace( m_font.MacGetFontStyle() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
::TextFont( kFontIDMonaco ) ;
|
||||
::TextSize( 9 ) ;
|
||||
::TextFace( 0 ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find the widest line
|
||||
for(unsigned int i = 0; i < GetCount(); i++)
|
||||
{
|
||||
wxString str(GetString(i));
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( str , &width, &height);
|
||||
wLine = width ;
|
||||
#else
|
||||
#if wxUSE_UNICODE
|
||||
Point bounds = { 0, 0 } ;
|
||||
SInt16 baseline ;
|
||||
|
||||
::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) ,
|
||||
kThemeCurrentPortFont,
|
||||
kThemeStateActive,
|
||||
false,
|
||||
&bounds,
|
||||
&baseline );
|
||||
|
||||
wLine = bounds.h ;
|
||||
#else
|
||||
wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
|
||||
#endif
|
||||
#endif
|
||||
lbWidth = wxMax( lbWidth, wLine ) ;
|
||||
}
|
||||
|
||||
// Add room for the popup arrow
|
||||
lbWidth += 2 * lbHeight ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( wxT("X"), &width, &height);
|
||||
int cx = width ;
|
||||
lbHeight += 4;
|
||||
#else
|
||||
// And just a bit more
|
||||
int cx = ::TextWidth( "X" , 0 , 1 ) ;
|
||||
#endif
|
||||
|
||||
lbWidth += cx ;
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,9 @@ void wxClipboard::Close()
|
||||
|
||||
bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
|
||||
{
|
||||
wxLogTrace(TRACE_CLIPBOARD, wxT("Checking if format %s is available"),
|
||||
dataFormat.GetId().c_str());
|
||||
|
||||
if ( m_data )
|
||||
return m_data->IsSupported( dataFormat );
|
||||
return wxDataObject::IsFormatInPasteboard( m_pasteboard, dataFormat );
|
||||
|
@ -92,11 +92,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
|
||||
if (gDataBrowserTableViewItemNotificationUPP == NULL)
|
||||
{
|
||||
gDataBrowserTableViewItemNotificationUPP =
|
||||
#if TARGET_API_MAC_OSX
|
||||
(DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
|
||||
#else
|
||||
NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
|
||||
#endif
|
||||
}
|
||||
|
||||
DataBrowserCallbacks callbacks;
|
||||
|
@ -129,18 +129,10 @@ void wxDataFormat::SetType( wxDataFormatId dataType )
|
||||
break;
|
||||
|
||||
case wxDF_BITMAP:
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_format = (long) CFStringCreateCopy( NULL, CFSTR("public.tiff") );
|
||||
#else
|
||||
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.apple.pict") );
|
||||
#endif
|
||||
break;
|
||||
case wxDF_METAFILE:
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.adobe.pdf") );
|
||||
#else
|
||||
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.apple.pict") );
|
||||
#endif
|
||||
break;
|
||||
|
||||
case wxDF_FILENAME:
|
||||
@ -177,7 +169,6 @@ void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
m_type = wxDF_TEXT;
|
||||
}
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("public.tiff") ) )
|
||||
{
|
||||
m_type = wxDF_BITMAP;
|
||||
@ -186,12 +177,6 @@ void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
m_type = wxDF_METAFILE;
|
||||
}
|
||||
#else
|
||||
else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("com.apple.pict") ) )
|
||||
{
|
||||
m_type = wxDF_METAFILE;
|
||||
}
|
||||
#endif
|
||||
else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("public.file-url") ) )
|
||||
{
|
||||
m_type = wxDF_FILENAME;
|
||||
@ -647,12 +632,7 @@ wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& rBitmap )
|
||||
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
SetBitmap( rBitmap );
|
||||
#else
|
||||
m_pictHandle = m_bitmap.GetBitmapData()->GetPictHandle();
|
||||
m_pictCreated = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,51 +647,24 @@ void wxBitmapDataObject::SetBitmap( const wxBitmap& rBitmap )
|
||||
wxBitmapDataObjectBase::SetBitmap( rBitmap );
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGImageRef cgImageRef = (CGImageRef) m_bitmap.CGImageCreate();
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
|
||||
CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, 0);
|
||||
CGImageDestinationRef destination = CGImageDestinationCreateWithData( data , kUTTypeTIFF , 1 , NULL );
|
||||
if ( destination )
|
||||
{
|
||||
CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, 0);
|
||||
CGImageDestinationRef destination = CGImageDestinationCreateWithData( data , kUTTypeTIFF , 1 , NULL );
|
||||
if ( destination )
|
||||
{
|
||||
CGImageDestinationAddImage( destination, cgImageRef, NULL );
|
||||
CGImageDestinationFinalize( destination );
|
||||
CFRelease( destination );
|
||||
}
|
||||
m_pictHandle = NewHandle(CFDataGetLength(data));
|
||||
if ( m_pictHandle )
|
||||
{
|
||||
memcpy( *(Handle)m_pictHandle, (const char *)CFDataGetBytePtr(data), CFDataGetLength(data) );
|
||||
}
|
||||
CFRelease( data );
|
||||
CGImageDestinationAddImage( destination, cgImageRef, NULL );
|
||||
CGImageDestinationFinalize( destination );
|
||||
CFRelease( destination );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifndef __LP64__
|
||||
m_pictHandle = NewHandle(CFDataGetLength(data));
|
||||
if ( m_pictHandle )
|
||||
{
|
||||
// export as TIFF
|
||||
GraphicsExportComponent exporter = 0;
|
||||
OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeTIFF, &exporter);
|
||||
if (noErr == err)
|
||||
{
|
||||
m_pictHandle = NewHandle(0);
|
||||
if ( m_pictHandle )
|
||||
{
|
||||
err = GraphicsExportSetInputCGImage( exporter, cgImageRef);
|
||||
err = GraphicsExportSetOutputHandle(exporter, (Handle)m_pictHandle);
|
||||
err = GraphicsExportDoExport(exporter, NULL);
|
||||
}
|
||||
CloseComponent( exporter );
|
||||
}
|
||||
memcpy( *(Handle)m_pictHandle, (const char *)CFDataGetBytePtr(data), CFDataGetLength(data) );
|
||||
}
|
||||
#endif
|
||||
CFRelease( data );
|
||||
|
||||
CGImageRelease(cgImageRef);
|
||||
#else
|
||||
m_pictHandle = m_bitmap.GetBitmapData()->GetPictHandle();
|
||||
m_pictCreated = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,12 +678,7 @@ void wxBitmapDataObject::Clear()
|
||||
{
|
||||
if (m_pictHandle != NULL)
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
DisposeHandle( (Handle) m_pictHandle );
|
||||
#else
|
||||
if (m_pictCreated)
|
||||
KillPicture( (PicHandle)m_pictHandle );
|
||||
#endif
|
||||
m_pictHandle = NULL;
|
||||
}
|
||||
m_pictCreated = false;
|
||||
@ -778,46 +726,20 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
|
||||
if ((pBuf == NULL) || (nSize == 0))
|
||||
return false;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
Handle picHandle = NewHandle( nSize );
|
||||
memcpy( *picHandle, pBuf, nSize );
|
||||
m_pictHandle = picHandle;
|
||||
CGImageRef cgImageRef = 0;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
|
||||
CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull);
|
||||
CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL );
|
||||
if ( source )
|
||||
{
|
||||
CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull);
|
||||
CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL );
|
||||
if ( source )
|
||||
{
|
||||
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
||||
}
|
||||
CFRelease( source );
|
||||
CFRelease( data );
|
||||
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifndef __LP64__
|
||||
{
|
||||
// import from TIFF
|
||||
GraphicsImportComponent importer = 0;
|
||||
OSStatus err = OpenADefaultComponent(GraphicsImporterComponentType, kQTFileTypeTIFF, &importer);
|
||||
if (noErr == err)
|
||||
{
|
||||
if ( picHandle )
|
||||
{
|
||||
ComponentResult result = GraphicsImportSetDataHandle(importer, picHandle);
|
||||
if ( result == noErr )
|
||||
{
|
||||
Rect frame;
|
||||
GraphicsImportGetNaturalBounds( importer, &frame );
|
||||
GraphicsImportCreateCGImage( importer, &cgImageRef, kGraphicsImportCreateCGImageUsingCurrentSettings );
|
||||
}
|
||||
}
|
||||
CloseComponent( importer );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CFRelease( source );
|
||||
CFRelease( data );
|
||||
|
||||
if ( cgImageRef )
|
||||
{
|
||||
m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
|
||||
@ -827,28 +749,6 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
|
||||
CGImageRelease(cgImageRef);
|
||||
cgImageRef = NULL;
|
||||
}
|
||||
#else
|
||||
PicHandle picHandle = (PicHandle)NewHandle( nSize );
|
||||
memcpy( *picHandle, pBuf, nSize );
|
||||
m_pictHandle = picHandle;
|
||||
// ownership is transferred to the bitmap
|
||||
m_pictCreated = false;
|
||||
#ifndef __LP64__
|
||||
Rect frame;
|
||||
wxMacGetPictureBounds( picHandle, &frame );
|
||||
#if wxUSE_METAFILE
|
||||
wxMetafile mf;
|
||||
mf.SetHMETAFILE( (WXHMETAFILE)m_pictHandle );
|
||||
#endif
|
||||
wxMemoryDC mdc;
|
||||
m_bitmap.Create( frame.right - frame.left, frame.bottom - frame.top );
|
||||
mdc.SelectObject( m_bitmap );
|
||||
#if wxUSE_METAFILE
|
||||
mf.Play( &mdc );
|
||||
#endif
|
||||
mdc.SelectObject( wxNullBitmap );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return m_bitmap.Ok();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -51,70 +51,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
static wxBrush MacGetBackgroundBrush( wxWindow* window )
|
||||
{
|
||||
wxBrush bkdBrush = window->MacGetBackgroundBrush() ;
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
// transparency cannot be handled by the OS when not using composited windows
|
||||
wxWindow* parent = window->GetParent() ;
|
||||
|
||||
// if we have some 'pseudo' transparency
|
||||
if ( ! bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT || window->GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
|
||||
{
|
||||
// walk up until we find something
|
||||
while ( parent != NULL )
|
||||
{
|
||||
if ( parent->GetBackgroundColour() != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
|
||||
{
|
||||
// if we have any other colours in the hierarchy
|
||||
bkdBrush.SetColour( parent->GetBackgroundColour() ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( parent->IsKindOf( CLASSINFO(wxTopLevelWindow) ) )
|
||||
{
|
||||
bkdBrush = parent->MacGetBackgroundBrush() ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) )
|
||||
#if wxUSE_TAB_DIALOG
|
||||
|| parent->IsKindOf( CLASSINFO( wxTabCtrl ) )
|
||||
#endif // wxUSE_TAB_DIALOG
|
||||
)
|
||||
{
|
||||
Rect extent = { 0 , 0 , 0 , 0 } ;
|
||||
int x , y ;
|
||||
x = y = 0 ;
|
||||
wxSize size = parent->GetSize() ;
|
||||
parent->MacClientToRootWindow( &x , &y ) ;
|
||||
extent.left = x ;
|
||||
extent.top = y ;
|
||||
extent.top-- ;
|
||||
extent.right = x + size.x ;
|
||||
extent.bottom = y + size.y ;
|
||||
bkdBrush.MacSetThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
parent = parent->GetParent() ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT )
|
||||
{
|
||||
// if we did not find something, use a default
|
||||
bkdBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return bkdBrush ;
|
||||
}
|
||||
|
||||
wxWindowDC::wxWindowDC()
|
||||
{
|
||||
m_window = NULL ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_release = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
@ -126,7 +69,6 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
|
||||
m_ok = true ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_window->GetSize( &m_width , &m_height);
|
||||
CGContextRef cg = (CGContextRef) window->MacGetCGContextRef();
|
||||
m_release = false;
|
||||
@ -146,18 +88,7 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
|
||||
}
|
||||
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||
#else
|
||||
int x , y ;
|
||||
x = y = 0 ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_deviceLocalOriginX = x;
|
||||
m_deviceLocalOriginY = y;
|
||||
m_macPort = UMAGetWindowPort( (WindowRef) rootwindow->MacGetWindowRef() ) ;
|
||||
|
||||
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
#endif
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
|
||||
SetFont( window->GetFont() ) ;
|
||||
@ -165,7 +96,6 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( m_release )
|
||||
{
|
||||
// this must not necessarily be the current context, we must restore the state of the
|
||||
@ -173,20 +103,14 @@ wxWindowDC::~wxWindowDC()
|
||||
CGContextRef cg = (CGContextRef) m_window->MacGetCGContextRef();
|
||||
CGContextRestoreGState(cg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowDC::DoGetSize( int* width, int* height ) const
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( width )
|
||||
*width = m_width;
|
||||
if ( height )
|
||||
*height = m_height;
|
||||
#else
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
m_window->GetSize(width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const
|
||||
@ -253,7 +177,6 @@ wxClientDC::wxClientDC()
|
||||
m_window = NULL ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxClientDC::wxClientDC(wxWindow *window) :
|
||||
wxWindowDC( window )
|
||||
{
|
||||
@ -263,51 +186,11 @@ wxClientDC::wxClientDC(wxWindow *window) :
|
||||
SetDeviceOrigin( origin.x, origin.y );
|
||||
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||
}
|
||||
#else
|
||||
wxClientDC::wxClientDC(wxWindow *window)
|
||||
{
|
||||
wxCHECK_RET( window, _T("invalid window in wxClientDC") );
|
||||
m_window = window ;
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
if (!rootwindow)
|
||||
return;
|
||||
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
wxSize size = window->GetClientSize() ;
|
||||
int x , y ;
|
||||
x = origin.x ;
|
||||
y = origin.y ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_ok = true ;
|
||||
|
||||
m_deviceLocalOriginX = x ;
|
||||
m_deviceLocalOriginY = y ;
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
void wxClientDC::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
|
||||
m_window->GetClientSize( width, height );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxPaintDC
|
||||
*/
|
||||
@ -317,7 +200,6 @@ wxPaintDC::wxPaintDC()
|
||||
m_window = NULL ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxPaintDC::wxPaintDC(wxWindow *window) :
|
||||
wxWindowDC( window )
|
||||
{
|
||||
@ -326,61 +208,7 @@ wxPaintDC::wxPaintDC(wxWindow *window) :
|
||||
SetDeviceOrigin( origin.x, origin.y );
|
||||
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||
}
|
||||
#else
|
||||
wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
wxSize size = window->GetClientSize() ;
|
||||
int x , y ;
|
||||
x = origin.x ;
|
||||
y = origin.y ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_ok = true ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( window->MacGetCGContextRef() )
|
||||
{
|
||||
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||
m_graphicContext->SetPen( m_pen ) ;
|
||||
m_graphicContext->SetBrush( m_brush ) ;
|
||||
SetClippingRegion( 0 , 0 , size.x , size.y ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("You cannot create a wxPaintDC outside an OS-draw event") ) ;
|
||||
m_graphicContext = NULL ;
|
||||
}
|
||||
// there is no out-of-order drawing on OSX
|
||||
#else
|
||||
m_deviceLocalOriginX = x ;
|
||||
m_deviceLocalOriginY = y ;
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
#endif
|
||||
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
wxPaintDC::~wxPaintDC()
|
||||
{
|
||||
}
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
void wxPaintDC::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
|
||||
m_window->GetClientSize( width, height );
|
||||
}
|
||||
#endif
|
||||
|
@ -42,13 +42,9 @@ wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_selected.EndRawAccess() ;
|
||||
delete m_graphicContext ;
|
||||
m_graphicContext = NULL ;
|
||||
#else
|
||||
// TODO: UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,19 +52,14 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_selected.EndRawAccess() ;
|
||||
delete m_graphicContext ;
|
||||
m_graphicContext = NULL ;
|
||||
#else
|
||||
// TODO: UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#endif
|
||||
}
|
||||
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( m_selected.GetDepth() != 1 )
|
||||
m_selected.UseAlpha() ;
|
||||
m_selected.BeginRawAccess() ;
|
||||
@ -84,17 +75,6 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
|
||||
SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) );
|
||||
}
|
||||
m_ok = (m_graphicContext != NULL) ;
|
||||
|
||||
#else
|
||||
m_macPort = m_selected.GetHBITMAP( &m_macMask ) ;
|
||||
m_ok = (m_macPort != NULL) ;
|
||||
if (m_ok)
|
||||
{
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -63,9 +63,6 @@ public :
|
||||
virtual void GetSize( int *w , int *h) const ;
|
||||
virtual wxSize GetPPI() const ;
|
||||
private :
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
GrafPtr m_macPrintFormerPort ;
|
||||
#endif
|
||||
wxCoord m_maxX ;
|
||||
wxCoord m_maxY ;
|
||||
wxSize m_ppi ;
|
||||
@ -74,9 +71,6 @@ private :
|
||||
|
||||
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
::GetPort( & m_macPrintFormerPort ) ;
|
||||
#endif
|
||||
m_err = noErr ;
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->GetNativeData() ;
|
||||
|
||||
@ -101,10 +95,6 @@ wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
|
||||
|
||||
wxMacCarbonPrinterDC::~wxMacCarbonPrinterDC()
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
// nothing to release from print data, as wxPrinterDC has all data in its wxPrintData member
|
||||
::SetPort( m_macPrintFormerPort ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
|
||||
@ -119,24 +109,9 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 && wxMAC_USE_CORE_GRAPHICS
|
||||
{
|
||||
CFStringRef s[1] = { kPMGraphicsContextCoreGraphics };
|
||||
CFArrayRef graphicsContextsArray = CFArrayCreate(NULL, (const void**)s, 1, &kCFTypeArrayCallBacks);
|
||||
PMSessionSetDocumentFormatGeneration(native->m_macPrintSession, kPMDocumentFormatPDF, graphicsContextsArray, NULL);
|
||||
CFRelease(graphicsContextsArray);
|
||||
}
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 && wxMAC_USE_CORE_GRAPHICS
|
||||
m_err = PMSessionBeginCGDocument(native->m_macPrintSession,
|
||||
native->m_macPrintSettings,
|
||||
native->m_macPageFormat);
|
||||
#else
|
||||
m_err = PMSessionBeginDocument(native->m_macPrintSession,
|
||||
native->m_macPrintSettings,
|
||||
native->m_macPageFormat);
|
||||
|
||||
#endif
|
||||
|
||||
if ( m_err != noErr )
|
||||
return false;
|
||||
@ -182,26 +157,12 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
native->m_macPageFormat,
|
||||
nil);
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef pageContext;
|
||||
#endif
|
||||
|
||||
if ( m_err == noErr )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||
m_err = PMSessionGetCGGraphicsContext(native->m_macPrintSession,
|
||||
&pageContext );
|
||||
|
||||
#else
|
||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||
kPMGraphicsContextCoreGraphics,
|
||||
(void**) &pageContext );
|
||||
#endif
|
||||
#else
|
||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||
kPMGraphicsContextQuickdraw,
|
||||
(void**) &dc->m_macPort );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_err != noErr )
|
||||
@ -216,23 +177,17 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
if ( !m_err )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
PMRect paperRect ;
|
||||
PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ;
|
||||
// make sure (0,0) is at the upper left of the printable area (wx conventions)
|
||||
// Core Graphics initially has the lower left of the paper as 0,0
|
||||
CGContextTranslateCTM( pageContext , -paperRect.left , paperRect.bottom ) ;
|
||||
CGContextScaleCTM( pageContext , 1 , -1 ) ;
|
||||
#else
|
||||
dc->SetDeviceLocalOrigin( (wxCoord) rPage.left, (wxCoord) rPage.top );
|
||||
#endif
|
||||
}
|
||||
// since this is a non-critical error, we set the flag back
|
||||
m_err = noErr ;
|
||||
}
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
|
||||
@ -247,10 +202,8 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
|
||||
{
|
||||
PMSessionEndDocument(native->m_macPrintSession);
|
||||
}
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
// the cg context we got when starting the page isn't valid anymore, so replace it
|
||||
dc->SetGraphicsContext( wxGraphicsContext::Create() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxMacCarbonPrinterDC::GetSize( int *w , int *h) const
|
||||
@ -292,11 +245,9 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
m_mm_to_pix_x = mm2inches * sz.x;
|
||||
m_mm_to_pix_y = mm2inches * sz.y;
|
||||
}
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
// we need at least a measuring context because people start measuring before a page
|
||||
// gets printed at all
|
||||
SetGraphicsContext( wxGraphicsContext::Create() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,11 +331,6 @@ void wxPrinterDC::StartPage(void)
|
||||
m_font = *wxNORMAL_FONT;
|
||||
m_brush = *wxTRANSPARENT_BRUSH;
|
||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
m_macFontInstalled = false ;
|
||||
m_macBrushInstalled = false ;
|
||||
m_macPenInstalled = false ;
|
||||
#endif
|
||||
|
||||
m_nativePrinterDC->StartPage(this) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
@ -25,7 +25,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGRect cgbounds ;
|
||||
cgbounds = CGDisplayBounds(CGMainDisplayID());
|
||||
Rect bounds;
|
||||
@ -39,43 +38,12 @@ wxScreenDC::wxScreenDC()
|
||||
SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
|
||||
m_width = (wxCoord)cgbounds.size.width;
|
||||
m_height = (wxCoord)cgbounds.size.height;
|
||||
#else
|
||||
m_macPort = CreateNewPort() ;
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
SetPort( (GrafPtr) m_macPort ) ;
|
||||
Point pt = { 0,0 } ;
|
||||
LocalToGlobal( &pt ) ;
|
||||
SetPort( port ) ;
|
||||
m_deviceLocalOriginX = -pt.h ;
|
||||
m_deviceLocalOriginY = -pt.v ;
|
||||
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
m_minX = screenBits.bounds.left ;
|
||||
|
||||
SInt16 height ;
|
||||
GetThemeMenuBarHeight( &height ) ;
|
||||
m_minY = screenBits.bounds.top + height ;
|
||||
|
||||
m_maxX = screenBits.bounds.right ;
|
||||
m_maxY = screenBits.bounds.bottom ;
|
||||
|
||||
MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_deviceLocalOriginX , m_deviceLocalOriginY ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
#endif
|
||||
m_ok = true ;
|
||||
}
|
||||
|
||||
wxScreenDC::~wxScreenDC()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
delete m_graphicContext;
|
||||
m_graphicContext = NULL;
|
||||
DisposeWindow((WindowRef) m_overlayWindow );
|
||||
#else
|
||||
if ( m_macPort )
|
||||
DisposePort( (CGrafPtr) m_macPort ) ;
|
||||
#endif
|
||||
}
|
||||
|
@ -341,10 +341,8 @@ int wxFileDialog::ShowModal()
|
||||
if (numFilters < 2)
|
||||
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT))
|
||||
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
|
||||
#endif
|
||||
|
||||
err = ::NavCreatePutFileDialog(
|
||||
&dialogCreateOptions,
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if wxUSE_GRAPHICS_CONTEXT && wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
#include "wx/graphics.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
@ -36,16 +34,9 @@
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
|
||||
typedef float CGFloat;
|
||||
#endif
|
||||
#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
#define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 1
|
||||
#else
|
||||
#define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constants
|
||||
@ -169,22 +160,7 @@ public :
|
||||
|
||||
void StrokeLineSegments( CGContextRef ctxRef , const CGPoint pts[] , size_t count )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( CGContextStrokeLineSegments!=NULL )
|
||||
{
|
||||
CGContextStrokeLineSegments( ctxRef , pts , count );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CGContextBeginPath( ctxRef );
|
||||
for (size_t i = 0; i < count; i += 2)
|
||||
{
|
||||
CGContextMoveToPoint(ctxRef, pts[i].x, pts[i].y);
|
||||
CGContextAddLineToPoint(ctxRef, pts[i+1].x, pts[i+1].y);
|
||||
}
|
||||
CGContextStrokePath(ctxRef);
|
||||
}
|
||||
CGContextStrokeLineSegments( ctxRef , pts , count );
|
||||
}
|
||||
|
||||
virtual void Render( CGContextRef ctxRef )
|
||||
@ -531,36 +507,9 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush )
|
||||
{
|
||||
if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
{
|
||||
CGColorRef color ;
|
||||
HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
|
||||
m_color.Set( color ) ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( brush.MacGetTheme() == kThemeBrushDialogBackgroundActive )
|
||||
{
|
||||
// striped background is a pattern, we have to emulate it
|
||||
|
||||
m_isPattern = true;
|
||||
m_patternColorComponents = new CGFloat[1] ;
|
||||
m_patternColorComponents[0] = 1.0;
|
||||
m_colorSpace.Set( CGColorSpaceCreatePattern( NULL ) );
|
||||
m_pattern.Set( *( new ImagePattern( &gs_stripedback_bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// as close as we can get, unfortunately < 10.4 things get difficult
|
||||
RGBColor color;
|
||||
GetThemeBrushAsColor( brush.MacGetTheme(), 32, true, &color );
|
||||
CGFloat components[4] = { (CGFloat) color.red / 65536,
|
||||
(CGFloat) color.green / 65536, (CGFloat) color.blue / 65536, 1 } ;
|
||||
m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
|
||||
}
|
||||
}
|
||||
CGColorRef color ;
|
||||
HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
|
||||
m_color.Set( color ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -898,23 +847,7 @@ void wxMacCoreGraphicsMatrixData::Invert()
|
||||
// returns true if the elements of the transformation matrix are equal ?
|
||||
bool wxMacCoreGraphicsMatrixData::IsEqual( const wxGraphicsMatrixData* t) const
|
||||
{
|
||||
const CGAffineTransform* tm = (CGAffineTransform*) t->GetNativeMatrix();
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( CGAffineTransformEqualToTransform!=NULL )
|
||||
{
|
||||
return CGAffineTransformEqualToTransform(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix()));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return (
|
||||
m_matrix.a == tm->a &&
|
||||
m_matrix.b == tm->b &&
|
||||
m_matrix.c == tm->c &&
|
||||
m_matrix.d == tm->d &&
|
||||
m_matrix.tx == tm->tx &&
|
||||
m_matrix.ty == tm->ty ) ;
|
||||
}
|
||||
return CGAffineTransformEqualToTransform(m_matrix, *((CGAffineTransform*) t->GetNativeMatrix()));
|
||||
}
|
||||
|
||||
// return true if this is the identity matrix
|
||||
@ -1153,18 +1086,7 @@ void wxMacCoreGraphicsPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wx
|
||||
|
||||
bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, int fillStyle) const
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( CGPathContainsPoint!=NULL )
|
||||
{
|
||||
return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// TODO : implementation for 10.3
|
||||
CGRect bounds = CGPathGetBoundingBox( m_path ) ;
|
||||
return CGRectContainsPoint( bounds, CGPointMake(x,y) ) == 1;
|
||||
}
|
||||
return CGPathContainsPoint( m_path, NULL, CGPointMake(x,y), fillStyle == wxODDEVEN_RULE );
|
||||
}
|
||||
|
||||
//
|
||||
@ -1471,25 +1393,14 @@ bool wxMacCoreGraphicsContext::SetLogicalFunction( int function )
|
||||
if ( function == wxCOPY )
|
||||
{
|
||||
retval = true;
|
||||
#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
||||
if ( CGContextSetBlendMode != NULL )
|
||||
{
|
||||
CGContextSetBlendMode( m_cgContext, kCGBlendModeNormal );
|
||||
CGContextSetShouldAntialias( m_cgContext, true );
|
||||
}
|
||||
#endif
|
||||
CGContextSetBlendMode( m_cgContext, kCGBlendModeNormal );
|
||||
}
|
||||
else if ( function == wxINVERT || function == wxXOR )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
||||
if ( CGContextSetBlendMode != NULL )
|
||||
{
|
||||
// change color to white
|
||||
CGContextSetBlendMode( m_cgContext, kCGBlendModeExclusion );
|
||||
CGContextSetShouldAntialias( m_cgContext, false );
|
||||
retval = true;
|
||||
}
|
||||
#endif
|
||||
// change color to white
|
||||
CGContextSetBlendMode( m_cgContext, kCGBlendModeExclusion );
|
||||
CGContextSetShouldAntialias( m_cgContext, false );
|
||||
retval = true;
|
||||
}
|
||||
|
||||
if (retval)
|
||||
@ -2253,6 +2164,3 @@ wxGraphicsFont wxMacCoreGraphicsRenderer::CreateFont( const wxFont &font , const
|
||||
return wxNullGraphicsFont;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // wxMAC_USE_CORE_GRAPHICS
|
||||
|
@ -218,52 +218,17 @@ wxSize wxListBox::DoGetBestSize() const
|
||||
int wLine;
|
||||
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxClientDC dc(const_cast<wxListBox*>(this));
|
||||
dc.SetFont(GetFont());
|
||||
#else
|
||||
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) );
|
||||
|
||||
// TODO: clean this up
|
||||
if ( m_font.Ok() )
|
||||
{
|
||||
::TextFont( m_font.MacGetFontNum() );
|
||||
::TextSize( m_font.MacGetFontSize() );
|
||||
::TextFace( m_font.MacGetFontStyle() );
|
||||
}
|
||||
else
|
||||
{
|
||||
::TextFont( kFontIDMonaco );
|
||||
::TextSize( 9 );
|
||||
::TextFace( 0 );
|
||||
}
|
||||
#endif
|
||||
// Find the widest line
|
||||
for (unsigned int i = 0; i < GetCount(); i++)
|
||||
{
|
||||
wxString str( GetString( i ) );
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( str , &width, &height);
|
||||
wLine = width ;
|
||||
#else
|
||||
#if wxUSE_UNICODE
|
||||
Point bounds = {0, 0};
|
||||
SInt16 baseline;
|
||||
|
||||
// NB: what if m_font.Ok() == false ???
|
||||
::GetThemeTextDimensions(
|
||||
wxMacCFStringHolder( str, m_font.GetEncoding() ),
|
||||
kThemeCurrentPortFont,
|
||||
kThemeStateActive,
|
||||
false,
|
||||
&bounds,
|
||||
&baseline );
|
||||
wLine = bounds.h;
|
||||
#else
|
||||
wLine = ::TextWidth( str.c_str(), 0, str.length() );
|
||||
#endif
|
||||
#endif
|
||||
lbWidth = wxMax( lbWidth, wLine );
|
||||
}
|
||||
|
||||
@ -272,13 +237,10 @@ wxSize wxListBox::DoGetBestSize() const
|
||||
|
||||
// And just a bit more
|
||||
int cy = 12;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( wxT("XX") , &width, &height);
|
||||
int cx = width ;
|
||||
#else
|
||||
int cx = ::TextWidth( "XX", 0, 1 );
|
||||
#endif
|
||||
lbWidth += cx;
|
||||
|
||||
// don't make the listbox too tall (limit height to around 10 items)
|
||||
|
@ -2510,9 +2510,7 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer
|
||||
|
||||
if ( style & wxLC_VRULES )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
verify_noerr( DataBrowserChangeAttributes(m_controlRef, kDataBrowserAttributeListViewDrawColumnDividers, kDataBrowserAttributeNone) );
|
||||
#endif
|
||||
}
|
||||
|
||||
verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );
|
||||
|
@ -711,12 +711,7 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
|
||||
MenuBarHandle menubar = NULL ;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
menubar = NewHandleClear( 6 /* sizeof( MenuBarHeader ) */ ) ;
|
||||
#else
|
||||
menubar = NewHandleClear( 12 ) ;
|
||||
(*menubar)[3] = 0x0a ;
|
||||
#endif
|
||||
|
||||
::SetMenuBar( menubar ) ;
|
||||
DisposeMenuBar( menubar ) ;
|
||||
@ -728,10 +723,8 @@ void wxMenuBar::MacInstallMenuBar()
|
||||
// Add About/Preferences separator only on OS X
|
||||
// KH/RN: Separator is always present on 10.3 but not on 10.2
|
||||
// However, the change from 10.2 to 10.3 suggests it is preferred
|
||||
#if TARGET_API_MAC_OSX
|
||||
InsertMenuItemTextWithCFString( appleMenu,
|
||||
CFSTR(""), 0, kMenuItemAttrSeparator, 0);
|
||||
#endif
|
||||
InsertMenuItemTextWithCFString( appleMenu,
|
||||
CFSTR("About..."), 0, 0, 0);
|
||||
MacInsertMenu( appleMenu , 0 ) ;
|
||||
|
@ -103,7 +103,6 @@ int wxMessageDialog::ShowModal()
|
||||
}
|
||||
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( !wxIsMainThread() )
|
||||
{
|
||||
CFStringRef defaultButtonTitle = NULL;
|
||||
@ -163,7 +162,6 @@ int wxMessageDialog::ShowModal()
|
||||
resultbutton = buttonId[exitButton];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
short result;
|
||||
|
||||
|
@ -326,7 +326,6 @@ int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
|
||||
{
|
||||
int resultV = wxNOT_FOUND;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
const int countPages = GetPageCount();
|
||||
|
||||
// we have to convert from Client to Window relative coordinates
|
||||
@ -367,7 +366,6 @@ int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
|
||||
|
||||
if ( outPart >= 1 && outPart <= countPages )
|
||||
resultV = outPart - 1 ;
|
||||
#endif // TARGET_API_MAC_OSX
|
||||
|
||||
if (flags != NULL)
|
||||
{
|
||||
@ -424,13 +422,7 @@ void wxNotebook::MacSetupTabs()
|
||||
m_peer->SetTabEnabled( ii + 1, true ) ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
Refresh();
|
||||
#else
|
||||
Rect bounds;
|
||||
m_peer->GetRectInWindowCoords( &bounds ) ;
|
||||
InvalWindowRect( (WindowRef)MacGetTopLevelWindowRef(), &bounds );
|
||||
#endif
|
||||
}
|
||||
|
||||
wxRect wxNotebook::GetPageRect() const
|
||||
|
@ -154,26 +154,22 @@ bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data )
|
||||
PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( PMSetDuplex!=NULL )
|
||||
PMDuplexMode mode = 0 ;
|
||||
switch( data.GetDuplex() )
|
||||
{
|
||||
PMDuplexMode mode = 0 ;
|
||||
switch( data.GetDuplex() )
|
||||
{
|
||||
case wxDUPLEX_HORIZONTAL :
|
||||
mode = kPMDuplexNoTumble ;
|
||||
break ;
|
||||
case wxDUPLEX_VERTICAL :
|
||||
mode = kPMDuplexTumble ;
|
||||
break ;
|
||||
case wxDUPLEX_SIMPLEX :
|
||||
default :
|
||||
mode = kPMDuplexNone ;
|
||||
break ;
|
||||
}
|
||||
PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ;
|
||||
case wxDUPLEX_HORIZONTAL :
|
||||
mode = kPMDuplexNoTumble ;
|
||||
break ;
|
||||
case wxDUPLEX_VERTICAL :
|
||||
mode = kPMDuplexTumble ;
|
||||
break ;
|
||||
case wxDUPLEX_SIMPLEX :
|
||||
default :
|
||||
mode = kPMDuplexNone ;
|
||||
break ;
|
||||
}
|
||||
#endif
|
||||
PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ;
|
||||
|
||||
// PMQualityMode not yet accessible via API
|
||||
// todo paperSize
|
||||
|
||||
@ -240,26 +236,21 @@ bool wxMacCarbonPrintData::TransferTo( wxPrintData &data )
|
||||
if ( err == noErr )
|
||||
data.SetColour( !(color == kPMBlackAndWhite) ) ;
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( PMGetDuplex!=NULL )
|
||||
PMDuplexMode mode = 0 ;
|
||||
PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ;
|
||||
switch( mode )
|
||||
{
|
||||
PMDuplexMode mode = 0 ;
|
||||
PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ;
|
||||
switch( mode )
|
||||
{
|
||||
case kPMDuplexNoTumble :
|
||||
data.SetDuplex(wxDUPLEX_HORIZONTAL);
|
||||
break ;
|
||||
case kPMDuplexTumble :
|
||||
data.SetDuplex(wxDUPLEX_VERTICAL);
|
||||
break ;
|
||||
case kPMDuplexNone :
|
||||
default :
|
||||
data.SetDuplex(wxDUPLEX_SIMPLEX);
|
||||
break ;
|
||||
}
|
||||
case kPMDuplexNoTumble :
|
||||
data.SetDuplex(wxDUPLEX_HORIZONTAL);
|
||||
break ;
|
||||
case kPMDuplexTumble :
|
||||
data.SetDuplex(wxDUPLEX_VERTICAL);
|
||||
break ;
|
||||
case kPMDuplexNone :
|
||||
default :
|
||||
data.SetDuplex(wxDUPLEX_SIMPLEX);
|
||||
break ;
|
||||
}
|
||||
#endif
|
||||
// PMQualityMode not yet accessible via API
|
||||
|
||||
PMPaper paper ;
|
||||
@ -509,14 +500,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
GrafPtr thePort ;
|
||||
GetPort( &thePort ) ;
|
||||
#endif
|
||||
wxSafeYield(win,true);
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
SetPort( thePort ) ;
|
||||
#endif
|
||||
dc->StartPage();
|
||||
keepGoing = printout->OnPrintPage(pn);
|
||||
dc->EndPage();
|
||||
|
@ -111,18 +111,10 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
|
||||
wxHeaderSortIconType sortArrow,
|
||||
wxHeaderButtonParams* params )
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
const wxCoord x = dc.LogicalToDeviceX(rect.x);
|
||||
const wxCoord y = dc.LogicalToDeviceY(rect.y);
|
||||
const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
|
||||
const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
|
||||
#else
|
||||
// now the wxGCDC is using native transformations
|
||||
const wxCoord x = rect.x;
|
||||
const wxCoord y = rect.y;
|
||||
const wxCoord w = rect.width;
|
||||
const wxCoord h = rect.height;
|
||||
#endif
|
||||
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
|
||||
@ -145,26 +137,7 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
|
||||
{
|
||||
CGContextRef cgContext;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
|
||||
#else
|
||||
Rect bounds;
|
||||
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
|
||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
|
||||
CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
|
||||
CGContextScaleCTM( cgContext, 1, -1 );
|
||||
|
||||
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn );
|
||||
if ( shape != 0 )
|
||||
{
|
||||
HIShapeReplacePathInCGContext( shape , cgContext );
|
||||
CFRelease( shape );
|
||||
CGContextClip( cgContext );
|
||||
}
|
||||
HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
|
||||
#endif
|
||||
|
||||
{
|
||||
HIThemeButtonDrawInfo drawInfo;
|
||||
@ -195,11 +168,6 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
|
||||
CGContextRestoreGState( cgContext );
|
||||
}
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reserve room for the arrows before writing the label, and turn off the
|
||||
@ -234,18 +202,11 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
|
||||
const wxRect& rect,
|
||||
int flags )
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
const wxCoord x = dc.LogicalToDeviceX(rect.x);
|
||||
const wxCoord y = dc.LogicalToDeviceY(rect.y);
|
||||
const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
|
||||
const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
|
||||
#else
|
||||
// now the wxGCDC is using native transformations
|
||||
const wxCoord x = rect.x;
|
||||
const wxCoord y = rect.y;
|
||||
const wxCoord w = rect.width;
|
||||
const wxCoord h = rect.height;
|
||||
#endif
|
||||
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
|
||||
@ -268,43 +229,21 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
|
||||
{
|
||||
CGContextRef cgContext;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
|
||||
#else
|
||||
Rect bounds;
|
||||
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
|
||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
HIThemeButtonDrawInfo drawInfo;
|
||||
HIRect labelRect;
|
||||
|
||||
CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
|
||||
CGContextScaleCTM( cgContext, 1, -1 );
|
||||
memset( &drawInfo, 0, sizeof(drawInfo) );
|
||||
drawInfo.version = 0;
|
||||
drawInfo.kind = kThemeDisclosureButton;
|
||||
drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
|
||||
// Apple mailing list posts say to use the arrow adornment constants, but those don't work.
|
||||
// We need to set the value using the 'old' DrawThemeButton constants instead.
|
||||
drawInfo.value = (flags & wxCONTROL_EXPANDED) ? kThemeDisclosureDown : kThemeDisclosureRight;
|
||||
drawInfo.adornment = kThemeAdornmentNone;
|
||||
|
||||
HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
|
||||
CGContextClip( cgContext );
|
||||
HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
|
||||
#endif
|
||||
|
||||
{
|
||||
HIThemeButtonDrawInfo drawInfo;
|
||||
HIRect labelRect;
|
||||
|
||||
memset( &drawInfo, 0, sizeof(drawInfo) );
|
||||
drawInfo.version = 0;
|
||||
drawInfo.kind = kThemeDisclosureButton;
|
||||
drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
|
||||
// Apple mailing list posts say to use the arrow adornment constants, but those don't work.
|
||||
// We need to set the value using the 'old' DrawThemeButton constants instead.
|
||||
drawInfo.value = (flags & wxCONTROL_EXPANDED) ? kThemeDisclosureDown : kThemeDisclosureRight;
|
||||
drawInfo.adornment = kThemeAdornmentNone;
|
||||
|
||||
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
|
||||
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
#endif
|
||||
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,13 +263,6 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
|
||||
else
|
||||
splitterRect = CGRectMake( 0, position, size.x, height );
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
HIViewConvertRect(
|
||||
&splitterRect,
|
||||
(HIViewRef) win->GetHandle(),
|
||||
(HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
|
||||
#endif
|
||||
|
||||
// under compositing we should only draw when called by the OS, otherwise just issue a redraw command
|
||||
// strange redraw errors occur if we don't do this
|
||||
|
||||
@ -353,26 +285,13 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
|
||||
{
|
||||
CGContextRef cgContext;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
|
||||
#else
|
||||
Rect bounds;
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
|
||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
|
||||
CGContextScaleCTM( cgContext, 1, -1 );
|
||||
#endif
|
||||
|
||||
HIThemeSplitterDrawInfo drawInfo;
|
||||
drawInfo.version = 0;
|
||||
drawInfo.state = kThemeStateActive;
|
||||
drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
|
||||
HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal );
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,18 +332,11 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
|
||||
int kind,
|
||||
int adornment)
|
||||
{
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
const wxCoord x = dc.LogicalToDeviceX(rect.x);
|
||||
const wxCoord y = dc.LogicalToDeviceY(rect.y);
|
||||
const wxCoord w = dc.LogicalToDeviceXRel(rect.width);
|
||||
const wxCoord h = dc.LogicalToDeviceYRel(rect.height);
|
||||
#else
|
||||
// now the wxGCDC is using native transformations
|
||||
const wxCoord x = rect.x;
|
||||
const wxCoord y = rect.y;
|
||||
const wxCoord w = rect.width;
|
||||
const wxCoord h = rect.height;
|
||||
#endif
|
||||
|
||||
dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||
|
||||
@ -446,43 +358,21 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
|
||||
else
|
||||
{
|
||||
CGContextRef cgContext;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
|
||||
#else
|
||||
Rect bounds;
|
||||
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
|
||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
HIThemeButtonDrawInfo drawInfo;
|
||||
HIRect labelRect;
|
||||
|
||||
CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
|
||||
CGContextScaleCTM( cgContext, 1, -1 );
|
||||
memset( &drawInfo, 0, sizeof(drawInfo) );
|
||||
drawInfo.version = 0;
|
||||
drawInfo.kind = kind;
|
||||
drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
|
||||
drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
|
||||
if (flags & wxCONTROL_UNDETERMINED)
|
||||
drawInfo.value = kThemeButtonMixed;
|
||||
drawInfo.adornment = adornment;
|
||||
|
||||
HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
|
||||
CGContextClip( cgContext );
|
||||
HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
|
||||
#endif
|
||||
|
||||
{
|
||||
HIThemeButtonDrawInfo drawInfo;
|
||||
HIRect labelRect;
|
||||
|
||||
memset( &drawInfo, 0, sizeof(drawInfo) );
|
||||
drawInfo.version = 0;
|
||||
drawInfo.kind = kind;
|
||||
drawInfo.state = (flags & wxCONTROL_DISABLED) ? kThemeStateInactive : kThemeStateActive;
|
||||
drawInfo.value = (flags & wxCONTROL_SELECTED) ? kThemeButtonOn : kThemeButtonOff;
|
||||
if (flags & wxCONTROL_UNDETERMINED)
|
||||
drawInfo.value = kThemeButtonMixed;
|
||||
drawInfo.adornment = adornment;
|
||||
|
||||
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
#endif
|
||||
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,38 +435,19 @@ wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int fl
|
||||
return;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
{
|
||||
CGRect cgrect = CGRectMake( rect.x , rect.y , rect.width, rect.height ) ;
|
||||
CGRect cgrect = CGRectMake( rect.x , rect.y , rect.width, rect.height ) ;
|
||||
|
||||
HIThemeFrameDrawInfo info ;
|
||||
memset( &info, 0 , sizeof(info) ) ;
|
||||
HIThemeFrameDrawInfo info ;
|
||||
memset( &info, 0 , sizeof(info) ) ;
|
||||
|
||||
info.version = 0 ;
|
||||
info.kind = 0 ;
|
||||
info.state = kThemeStateActive;
|
||||
info.isFocused = true ;
|
||||
info.version = 0 ;
|
||||
info.kind = 0 ;
|
||||
info.state = kThemeStateActive;
|
||||
info.isFocused = true ;
|
||||
|
||||
CGContextRef cgContext = (CGContextRef) win->MacGetCGContextRef() ;
|
||||
wxASSERT( cgContext ) ;
|
||||
CGContextRef cgContext = (CGContextRef) win->MacGetCGContextRef() ;
|
||||
wxASSERT( cgContext ) ;
|
||||
|
||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
#else
|
||||
// FIXME: not yet working for !wxMAC_USE_CORE_GRAPHICS
|
||||
{
|
||||
Rect r;
|
||||
r.left = rect.x; r.top = rect.y; r.right = rect.GetRight(); r.bottom = rect.GetBottom();
|
||||
wxTopLevelWindowMac* top = win->MacGetTopLevelWindow();
|
||||
if ( top )
|
||||
{
|
||||
wxPoint pt(0, 0) ;
|
||||
wxMacControl::Convert( &pt , win->GetPeer() , top->GetPeer() ) ;
|
||||
OffsetRect( &r , pt.x , pt.y ) ;
|
||||
}
|
||||
|
||||
DrawThemeFocusRect( &r , true ) ;
|
||||
}
|
||||
#endif
|
||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
|
||||
static const EventTypeSpec eventList[] =
|
||||
{
|
||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
||||
#endif
|
||||
};
|
||||
|
||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl
|
||||
@ -80,13 +78,8 @@ void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
||||
const Rect* bounds,
|
||||
CFStringRef WXUNUSED(crf))
|
||||
{
|
||||
OptionBits attributes = 0;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
{
|
||||
attributes = kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
#endif
|
||||
OptionBits attributes = kHISearchFieldAttributesSearchIcon;
|
||||
|
||||
HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } };
|
||||
verify_noerr( HISearchFieldCreate(
|
||||
&hibounds,
|
||||
@ -101,33 +94,24 @@ void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
||||
// search field options
|
||||
void wxMacSearchFieldControl::ShowSearchButton( bool show )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
OptionBits set = 0;
|
||||
OptionBits clear = 0;
|
||||
if ( show )
|
||||
{
|
||||
OptionBits set = 0;
|
||||
OptionBits clear = 0;
|
||||
if ( show )
|
||||
{
|
||||
set |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
clear |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
HISearchFieldChangeAttributes( m_controlRef, set, clear );
|
||||
set |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
clear |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
HISearchFieldChangeAttributes( m_controlRef, set, clear );
|
||||
}
|
||||
|
||||
bool wxMacSearchFieldControl::IsSearchButtonVisible() const
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
OptionBits attributes = 0;
|
||||
verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) );
|
||||
return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxMacSearchFieldControl::ShowCancelButton( bool show )
|
||||
@ -211,11 +195,9 @@ static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handl
|
||||
case kEventSearchFieldCancelClicked :
|
||||
thisWindow->MacSearchFieldCancelHit( handler , event ) ;
|
||||
break ;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
case kEventSearchFieldSearchClicked :
|
||||
thisWindow->MacSearchFieldSearchHit( handler , event ) ;
|
||||
break ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return result ;
|
||||
|
@ -106,23 +106,11 @@ wxSize wxStaticText::DoGetBestSize() const
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
wxClientDC dc(const_cast<wxStaticText*>(this));
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( m_label , &width, &height);
|
||||
bounds.h = width;
|
||||
bounds.v = height;
|
||||
#else
|
||||
wxMacWindowStateSaver sv( this );
|
||||
::TextFont( m_font.MacGetFontNum() );
|
||||
::TextSize( (short)(m_font.MacGetFontSize()) );
|
||||
::TextFace( m_font.MacGetFontStyle() );
|
||||
|
||||
err = GetThemeTextDimensions(
|
||||
(!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
|
||||
kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline );
|
||||
verify_noerr( err );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_label.empty() )
|
||||
|
@ -133,15 +133,9 @@ void wxCriticalSection::Leave()
|
||||
// wxMutex implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
#define wxUSE_MAC_SEMAPHORE_MUTEX 0
|
||||
#define wxUSE_MAC_CRITICAL_REGION_MUTEX 1
|
||||
#define wxUSE_MAC_PTHREADS_MUTEX 0
|
||||
#else
|
||||
#define wxUSE_MAC_SEMAPHORE_MUTEX 0
|
||||
#define wxUSE_MAC_CRITICAL_REGION_MUTEX 1
|
||||
#define wxUSE_MAC_PTHREADS_MUTEX 0
|
||||
#endif
|
||||
|
||||
#if wxUSE_MAC_PTHREADS_MUTEX
|
||||
|
||||
@ -1252,9 +1246,7 @@ bool wxThread::IsMain()
|
||||
|
||||
void wxThread::Yield()
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ;
|
||||
#endif
|
||||
|
||||
MPYield();
|
||||
}
|
||||
|
@ -383,17 +383,10 @@ bool wxToolBarTool::DoEnable( bool enable )
|
||||
|
||||
if ( m_controlHandle != NULL )
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( enable )
|
||||
EnableControl( m_controlHandle );
|
||||
else
|
||||
DisableControl( m_controlHandle );
|
||||
#else
|
||||
if ( enable )
|
||||
ActivateControl( m_controlHandle );
|
||||
else
|
||||
DeactivateControl( m_controlHandle );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1719,7 +1712,6 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
|
||||
bool drawMetalTheme = MacGetTopLevelWindow()->MacGetMetalAppearance();
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( !drawMetalTheme )
|
||||
{
|
||||
HIThemePlacardDrawInfo info;
|
||||
@ -1736,57 +1728,6 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
// leave the background as it is (striped or metal)
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const bool drawBorder = true;
|
||||
|
||||
if (drawBorder)
|
||||
{
|
||||
wxMacPortSetter helper( &dc );
|
||||
|
||||
if ( !drawMetalTheme )
|
||||
{
|
||||
Rect toolbarrect = { dc.YLOG2DEVMAC(0), dc.XLOG2DEVMAC(0),
|
||||
dc.YLOG2DEVMAC(h), dc.XLOG2DEVMAC(w) };
|
||||
|
||||
#if 0
|
||||
if ( toolbarrect.left < 0 )
|
||||
toolbarrect.left = 0;
|
||||
if ( toolbarrect.top < 0 )
|
||||
toolbarrect.top = 0;
|
||||
#endif
|
||||
|
||||
UMADrawThemePlacard( &toolbarrect, IsEnabled() ? kThemeStateActive : kThemeStateInactive );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
HIRect hiToolbarrect = CGRectMake(
|
||||
dc.YLOG2DEVMAC(0), dc.XLOG2DEVMAC(0),
|
||||
dc.YLOG2DEVREL(h), dc.XLOG2DEVREL(w) );
|
||||
CGContextRef cgContext;
|
||||
Rect bounds;
|
||||
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort, &bounds );
|
||||
QDBeginCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
|
||||
CGContextTranslateCTM( cgContext, 0, bounds.bottom - bounds.top );
|
||||
CGContextScaleCTM( cgContext, 1, -1 );
|
||||
|
||||
HIThemeBackgroundDrawInfo drawInfo;
|
||||
drawInfo.version = 0;
|
||||
drawInfo.state = kThemeStateActive;
|
||||
drawInfo.kind = kThemeBackgroundMetal;
|
||||
HIThemeApplyBackground( &hiToolbarrect, &drawInfo, cgContext, kHIThemeOrientationNormal );
|
||||
|
||||
#ifndef __LP64__
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
@ -658,14 +658,13 @@ wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
|
||||
{
|
||||
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
|
||||
Point clickLocation = windowMouseLocation ;
|
||||
#if TARGET_API_MAC_OSX
|
||||
|
||||
HIPoint hiPoint ;
|
||||
hiPoint.x = clickLocation.h ;
|
||||
hiPoint.y = clickLocation.v ;
|
||||
HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
|
||||
clickLocation.h = (int)hiPoint.x ;
|
||||
clickLocation.v = (int)hiPoint.y ;
|
||||
#endif // TARGET_API_MAC_OSX
|
||||
|
||||
HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ;
|
||||
result = noErr ;
|
||||
@ -1301,12 +1300,10 @@ void wxTopLevelWindowMac::DoMacCreateRealWindow(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( m_macWindow != NULL )
|
||||
{
|
||||
MacSetUnifiedAppearance( true ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
HIViewRef growBoxRef = 0 ;
|
||||
err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
|
||||
@ -1519,7 +1516,6 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle)
|
||||
|
||||
wxTopLevelWindowBase::SetExtraStyle( exStyle ) ;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( m_macWindow != NULL )
|
||||
{
|
||||
bool metal = GetExtraStyle() & wxFRAME_EX_METAL ;
|
||||
@ -1532,7 +1528,6 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle)
|
||||
MacSetMetalAppearance( metal ) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
|
||||
@ -1621,53 +1616,37 @@ void wxTopLevelWindowMac::DoCentre(int dir)
|
||||
|
||||
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( MacGetUnifiedAppearance() )
|
||||
MacSetUnifiedAppearance( false ) ;
|
||||
|
||||
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
|
||||
set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMac::MacGetMetalAppearance() const
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
return MacGetWindowAttributes() & kWindowMetalAttribute ;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set )
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
{
|
||||
if ( MacGetMetalAppearance() )
|
||||
MacSetMetalAppearance( false ) ;
|
||||
if ( MacGetMetalAppearance() )
|
||||
MacSetMetalAppearance( false ) ;
|
||||
|
||||
MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
|
||||
set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
|
||||
MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
|
||||
set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
|
||||
|
||||
// For some reason, Tiger uses white as the background color for this appearance,
|
||||
// while most apps using it use the typical striped background. Restore that behavior
|
||||
// for wx.
|
||||
// TODO: Determine if we need this on Leopard as well. (should be harmless either way,
|
||||
// though)
|
||||
SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ;
|
||||
}
|
||||
#endif
|
||||
// For some reason, Tiger uses white as the background color for this appearance,
|
||||
// while most apps using it use the typical striped background. Restore that behavior
|
||||
// for wx.
|
||||
// TODO: Determine if we need this on Leopard as well. (should be harmless either way,
|
||||
// though)
|
||||
SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
|
||||
else
|
||||
#endif
|
||||
return false;
|
||||
return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
|
||||
|
@ -558,7 +558,6 @@ Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
|
||||
{
|
||||
GetControlBounds( theControl , bounds ) ;
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
WindowRef tlwref = GetControlOwner( theControl ) ;
|
||||
|
||||
wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
|
||||
@ -569,7 +568,6 @@ Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
|
||||
HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
|
||||
OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return bounds ;
|
||||
}
|
||||
@ -603,21 +601,7 @@ CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data )
|
||||
if ( data == NULL )
|
||||
return NULL;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if( &CGDataProviderCreateWithCFData != NULL )
|
||||
{
|
||||
return CGDataProviderCreateWithCFData( data );
|
||||
}
|
||||
#endif
|
||||
|
||||
// make sure we keep it until done
|
||||
CFRetain( data );
|
||||
CGDataProviderRef provider = CGDataProviderCreateWithData( (void*) data , CFDataGetBytePtr( data ) ,
|
||||
CFDataGetLength( data ), UMAReleaseCFDataProviderCallback );
|
||||
// if provider couldn't be created, release the data again
|
||||
if ( provider == NULL )
|
||||
CFRelease( data );
|
||||
return provider;
|
||||
return CGDataProviderCreateWithCFData( data );
|
||||
}
|
||||
|
||||
CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
|
||||
@ -625,22 +609,7 @@ CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
|
||||
if ( data == NULL )
|
||||
return NULL;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
if( &CGDataConsumerCreateWithCFData != NULL )
|
||||
{
|
||||
return CGDataConsumerCreateWithCFData( data );
|
||||
}
|
||||
#endif
|
||||
// make sure we keep it until done
|
||||
CFRetain( data );
|
||||
CGDataConsumerCallbacks callbacks;
|
||||
callbacks.putBytes = UMAPutBytesCFRefCallback;
|
||||
callbacks.releaseConsumer = UMAReleaseCFDataConsumerCallback;
|
||||
CGDataConsumerRef consumer = CGDataConsumerCreate( data , &callbacks );
|
||||
// if consumer couldn't be created, release the data again
|
||||
if ( consumer == NULL )
|
||||
CFRelease( data );
|
||||
return consumer;
|
||||
return CGDataConsumerCreateWithCFData( data );
|
||||
}
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
|
@ -43,22 +43,9 @@
|
||||
#endif
|
||||
|
||||
#if wxUSE_GUI
|
||||
#if TARGET_API_MAC_OSX
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#else
|
||||
#include <DriverServices.h>
|
||||
#include <Multiprocessing.h>
|
||||
#endif
|
||||
|
||||
#ifdef __DARWIN__
|
||||
#include <Carbon/Carbon.h>
|
||||
#else
|
||||
#include <ATSUnicode.h>
|
||||
#include <TextCommon.h>
|
||||
#include <TextEncodingConverter.h>
|
||||
#endif
|
||||
|
||||
#include "wx/mac/private/timer.h"
|
||||
#include "wx/mac/private/timer.h"
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
@ -203,12 +190,7 @@ bool wxCheckForInterrupt(wxWindow *WXUNUSED(wnd))
|
||||
void wxGetMousePosition( int* x, int* y )
|
||||
{
|
||||
Point pt;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
GetGlobalMouse(&pt);
|
||||
#else
|
||||
GetMouse( &pt );
|
||||
LocalToGlobal( &pt );
|
||||
#endif
|
||||
*x = pt.h;
|
||||
*y = pt.v;
|
||||
};
|
||||
@ -222,10 +204,7 @@ bool wxColourDisplay()
|
||||
// Returns depth of screen
|
||||
int wxDisplayDepth()
|
||||
{
|
||||
int theDepth = 8;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
|
||||
#else
|
||||
int theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
|
||||
Rect globRect;
|
||||
SetRect(&globRect, -32760, -32760, 32760, 32760);
|
||||
GDHandle theMaxDevice;
|
||||
@ -233,30 +212,19 @@ int wxDisplayDepth()
|
||||
theMaxDevice = GetMaxDevice(&globRect);
|
||||
if (theMaxDevice != NULL)
|
||||
theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
|
||||
#endif
|
||||
|
||||
return theDepth;
|
||||
}
|
||||
|
||||
// Get size of display
|
||||
void wxDisplaySize(int *width, int *height)
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
// TODO adapt for multi-displays
|
||||
CGRect bounds = CGDisplayBounds(CGMainDisplayID());
|
||||
if ( width )
|
||||
*width = (int)bounds.size.width ;
|
||||
if ( height )
|
||||
*height = (int)bounds.size.height;
|
||||
#else
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
|
||||
if (width != NULL)
|
||||
*width = screenBits.bounds.right - screenBits.bounds.left;
|
||||
|
||||
if (height != NULL)
|
||||
*height = screenBits.bounds.bottom - screenBits.bounds.top;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxDisplaySizeMM(int *width, int *height)
|
||||
@ -564,13 +532,8 @@ OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size
|
||||
|
||||
OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions )
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
return SendEventToEventTargetWithOptions( event,
|
||||
HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions );
|
||||
#else
|
||||
#pragma unused(inOptions)
|
||||
return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions )
|
||||
@ -1623,9 +1586,7 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp
|
||||
columnDesc.propertyDesc.propertyType = colType;
|
||||
columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
|
||||
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
|
||||
#endif
|
||||
|
||||
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
|
||||
|
||||
@ -1981,24 +1942,7 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
|
||||
|
||||
if (genericRGBColorSpace == NULL)
|
||||
{
|
||||
if ( UMAGetSystemVersion() >= 0x1040 )
|
||||
{
|
||||
genericRGBColorSpace.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
CMProfileRef genericRGBProfile = wxMacOpenGenericProfile();
|
||||
|
||||
if (genericRGBProfile)
|
||||
{
|
||||
genericRGBColorSpace.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile) );
|
||||
|
||||
wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") );
|
||||
|
||||
// we opened the profile so it is up to us to close it
|
||||
CMCloseProfile(genericRGBProfile);
|
||||
}
|
||||
}
|
||||
genericRGBColorSpace.Set( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) );
|
||||
}
|
||||
|
||||
return genericRGBColorSpace;
|
||||
@ -2020,7 +1964,6 @@ wxMacPortSaver::~wxMacPortSaver()
|
||||
|
||||
void wxMacGlobalToLocal( WindowRef window , Point*pt )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||
HIPoint p = CGPointMake( pt->h, pt->v );
|
||||
HIViewRef contentView ;
|
||||
// TODO check toolbar offset
|
||||
@ -2028,14 +1971,10 @@ void wxMacGlobalToLocal( WindowRef window , Point*pt )
|
||||
HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView );
|
||||
pt->h = p.x;
|
||||
pt->v = p.y;
|
||||
#else
|
||||
QDGlobalToLocalPoint( GetWindowPort(window), pt ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxMacLocalToGlobal( WindowRef window , Point*pt )
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||
HIPoint p = CGPointMake( pt->h, pt->v );
|
||||
HIViewRef contentView ;
|
||||
// TODO check toolbar offset
|
||||
@ -2043,9 +1982,6 @@ void wxMacLocalToGlobal( WindowRef window , Point*pt )
|
||||
HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL );
|
||||
pt->h = p.x;
|
||||
pt->v = p.y;
|
||||
#else
|
||||
QDLocalToGlobalPoint( GetWindowPort(window), pt ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
@ -248,7 +248,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
#endif
|
||||
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
bool created = false ;
|
||||
CGContextRef cgContext = NULL ;
|
||||
OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
|
||||
@ -278,18 +277,14 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
CGContextClearRect( cgContext, bounds );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
||||
result = noErr ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
thisWindow->MacSetCGContextRef( NULL ) ;
|
||||
}
|
||||
|
||||
if ( created )
|
||||
CGContextRelease( cgContext ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( allocatedRgn )
|
||||
@ -919,10 +914,7 @@ void wxWindowMac::Init()
|
||||
m_peer = NULL ;
|
||||
m_frozenness = 0 ;
|
||||
m_macAlpha = 255 ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_cgContextRef = NULL ;
|
||||
#endif
|
||||
|
||||
// as all windows are created with WS_VISIBLE style...
|
||||
m_isShown = true;
|
||||
@ -2435,7 +2427,6 @@ void wxWindowMac::MacPaintGrowBox()
|
||||
if ( IsTopLevel() )
|
||||
return ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
if ( MacHasScrollBarCorner() )
|
||||
{
|
||||
Rect rect ;
|
||||
@ -2462,7 +2453,6 @@ void wxWindowMac::MacPaintGrowBox()
|
||||
CGContextFillRect( cgContext, cgrect );
|
||||
CGContextRestoreGState( cgContext );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) )
|
||||
@ -2477,7 +2467,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
||||
m_peer->GetRect( &rect ) ;
|
||||
InsetRect( &rect, -1 , -1 ) ;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
{
|
||||
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
|
||||
rect.bottom - rect.top ) ;
|
||||
@ -2527,33 +2516,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
{
|
||||
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
|
||||
if ( top )
|
||||
{
|
||||
wxPoint pt(0, 0) ;
|
||||
wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
|
||||
OffsetRect( &rect , pt.x , pt.y ) ;
|
||||
}
|
||||
|
||||
if ( HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
||||
DrawThemeEditTextFrame( &rect, IsEnabled() ? kThemeStateActive : kThemeStateInactive ) ;
|
||||
else if ( HasFlag(wxSIMPLE_BORDER) )
|
||||
DrawThemeListBoxFrame( &rect, IsEnabled() ? kThemeStateActive : kThemeStateInactive ) ;
|
||||
|
||||
if ( hasFocus )
|
||||
DrawThemeFocusRect( &rect , true ) ;
|
||||
// TODO REMOVE
|
||||
/*
|
||||
if ( hasBothScrollbars ) // hasBothScrollbars is not declared
|
||||
{
|
||||
// GetThemeStandaloneGrowBoxBounds
|
||||
// DrawThemeStandaloneNoGrowBox
|
||||
}
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowMac::RemoveChild( wxWindowBase *child )
|
||||
@ -2736,9 +2698,7 @@ void wxWindowMac::OnSetFocus( wxFocusEvent& event )
|
||||
|
||||
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
GetParent()->Refresh() ;
|
||||
#else
|
||||
wxMacWindowStateSaver sv( this ) ;
|
||||
Rect rect ;
|
||||
|
||||
@ -2766,7 +2726,6 @@ void wxWindowMac::OnSetFocus( wxFocusEvent& event )
|
||||
// we have to invalidate things, we cannot simple redraw
|
||||
MacInvalidateBorders() ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
@ -3086,16 +3045,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
eventNc.SetEventObject( child );
|
||||
if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
child->MacPaintBorders(0, 0) ;
|
||||
#else
|
||||
{
|
||||
wxWindowDC dc(this) ;
|
||||
dc.SetClippingRegion(wxRegion(updatergn));
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
child->MacPaintBorders(0, 0) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3485,7 +3435,6 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
|
||||
|
||||
bool wxWindowMac::SetTransparent(wxByte alpha)
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
|
||||
|
||||
if ( alpha != m_macAlpha )
|
||||
@ -3494,19 +3443,12 @@ bool wxWindowMac::SetTransparent(wxByte alpha)
|
||||
Refresh() ;
|
||||
}
|
||||
return true ;
|
||||
#else
|
||||
return false ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool wxWindowMac::CanSetTransparent()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
return true ;
|
||||
#else
|
||||
return false ;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxByte wxWindowMac::GetTransparent() const
|
||||
|
Loading…
Reference in New Issue
Block a user