cleanup mac

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2007-11-20 07:35:13 +00:00
parent 09b632b21a
commit e1673e527f
29 changed files with 144 additions and 5783 deletions

View File

@@ -43,15 +43,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
// under Quartz then content is transformed into a CGImageRef representing the same data // 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 // which can be transferred to the GPU by the OS for fast rendering
#if wxMAC_USE_CORE_GRAPHICS
#define wxMAC_USE_PREMULTIPLIED_ALPHA 1 #define wxMAC_USE_PREMULTIPLIED_ALPHA 1
static const int kBestByteAlignement = 16; static const int kBestByteAlignement = 16;
static const int kMaskBytesPerPixel = 1; static const int kMaskBytesPerPixel = 1;
#else
#define wxMAC_USE_PREMULTIPLIED_ALPHA 0
static const int kBestByteAlignement = 4;
static const int kMaskBytesPerPixel = 4;
#endif
static int GetBestBytesPerRow( int rawBytes ) static int GetBestBytesPerRow( int rawBytes )
{ {
@@ -71,18 +65,8 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
if ( forceType == 0 ) 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; forceType = kControlContentCGImageRef;
} }
else if ( bmap->HasNativeSize() )
{
forceType = kControlContentIconRef;
}
}
if ( forceType == kControlContentIconRef ) if ( forceType == kControlContentIconRef )
{ {
@@ -172,10 +156,6 @@ void wxBitmapRefData::Init()
m_iconRef = NULL ; m_iconRef = NULL ;
m_pictHandle = NULL ; m_pictHandle = NULL ;
m_hBitmap = NULL ; m_hBitmap = NULL ;
#if! wxMAC_USE_CORE_GRAPHICS
m_hMaskBitmap = NULL;
m_maskBytesPerRow = 0 ;
#endif
m_rawAccessCount = 0 ; m_rawAccessCount = 0 ;
m_hasAlpha = false; m_hasAlpha = false;
@@ -221,17 +201,11 @@ bool wxBitmapRefData::Create( int w , int h , int d )
m_memBuf.UngetWriteBuf( size ) ; m_memBuf.UngetWriteBuf( size ) ;
m_hBitmap = NULL ; 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 ); m_hBitmap = CGBitmapContextCreate((char*) data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst );
wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ; wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
CGContextTranslateCTM( m_hBitmap, 0, m_height ); CGContextTranslateCTM( m_hBitmap, 0, m_height );
CGContextScaleCTM( m_hBitmap, 1, -1 ); CGContextScaleCTM( m_hBitmap, 1, -1 );
#endif
m_ok = ( m_hBitmap != NULL ) ; m_ok = ( m_hBitmap != NULL ) ;
return m_ok ; return m_ok ;
@@ -243,43 +217,12 @@ void wxBitmapRefData::UseAlpha( bool use )
return ; return ;
m_hasAlpha = use ; m_hasAlpha = use ;
#if wxMAC_USE_CORE_GRAPHICS
CGContextRelease( m_hBitmap ); CGContextRelease( m_hBitmap );
m_hBitmap = CGBitmapContextCreate((char*) m_memBuf.GetData(), m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), m_hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst ); 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") ) ; wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
CGContextTranslateCTM( m_hBitmap, 0, m_height ); CGContextTranslateCTM( m_hBitmap, 0, m_height );
CGContextScaleCTM( m_hBitmap, 1, -1 ); 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 void *wxBitmapRefData::GetRawAccess() const
@@ -314,10 +257,6 @@ void wxBitmapRefData::EndRawAccess()
wxASSERT( m_rawAccessCount == 1 ) ; wxASSERT( m_rawAccessCount == 1 ) ;
--m_rawAccessCount ; --m_rawAccessCount ;
#if !wxMAC_USE_CORE_GRAPHICS
UpdateAlphaMask() ;
#endif
} }
bool wxBitmapRefData::HasNativeSize() bool wxBitmapRefData::HasNativeSize()
@@ -335,18 +274,7 @@ IconRef wxBitmapRefData::GetIconRef()
{ {
// Create Icon Family Handle // Create Icon Family Handle
IconFamilyHandle iconFamily = NULL ; IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle( 0 );
if ( UMAGetSystemVersion() < 0x1040 )
{
iconFamily = (IconFamilyHandle) NewHandle( 8 ) ;
(**iconFamily).resourceType = kIconFamilyType ;
(**iconFamily).resourceSize = sizeof(OSType) + sizeof(Size);
}
else
{
iconFamily = (IconFamilyHandle) NewHandle( 0 ) ;
}
int w = GetWidth() ; int w = GetWidth() ;
int h = GetHeight() ; int h = GetHeight() ;
@@ -358,7 +286,7 @@ IconRef wxBitmapRefData::GetIconRef()
switch (sz) switch (sz)
{ {
case 128: 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 ) if ( UMAGetSystemVersion() >= 0x1050 )
{ {
dataType = kIconServices128PixelDataARGB ; dataType = kIconServices128PixelDataARGB ;
@@ -372,7 +300,7 @@ IconRef wxBitmapRefData::GetIconRef()
break; break;
case 48: 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 ) if ( UMAGetSystemVersion() >= 0x1050 )
{ {
dataType = kIconServices48PixelDataARGB ; dataType = kIconServices48PixelDataARGB ;
@@ -386,7 +314,7 @@ IconRef wxBitmapRefData::GetIconRef()
break; break;
case 32: 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 ) if ( UMAGetSystemVersion() >= 0x1050 )
{ {
dataType = kIconServices32PixelDataARGB ; dataType = kIconServices32PixelDataARGB ;
@@ -400,7 +328,7 @@ IconRef wxBitmapRefData::GetIconRef()
break; break;
case 16: 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 ) if ( UMAGetSystemVersion() >= 0x1050 )
{ {
dataType = kIconServices16PixelDataARGB ; dataType = kIconServices16PixelDataARGB ;
@@ -419,7 +347,7 @@ IconRef wxBitmapRefData::GetIconRef()
if ( dataType != 0 ) 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 ) if ( maskType == 0 && UMAGetSystemVersion() >= 0x1050 )
{ {
size_t datasize = sz * sz * 4 ; size_t datasize = sz * sz * 4 ;
@@ -525,14 +453,7 @@ IconRef wxBitmapRefData::GetIconRef()
*dest++ = b ; *dest++ = b ;
if ( mask ) if ( mask )
{
*maskdest++ = 0xFF - *masksource++ ; *maskdest++ = 0xFF - *masksource++ ;
#if !wxMAC_USE_CORE_GRAPHICS
masksource++ ;
masksource++ ;
masksource++ ;
#endif
}
else if ( hasAlpha ) else if ( hasAlpha )
*maskdest++ = a ; *maskdest++ = a ;
else else
@@ -574,77 +495,6 @@ PicHandle wxBitmapRefData::GetPictHandle()
{ {
if ( m_pictHandle == NULL ) 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__ #ifndef __LP64__
GraphicsExportComponent exporter = 0; GraphicsExportComponent exporter = 0;
OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &exporter); OSStatus err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &exporter);
@@ -671,7 +521,6 @@ PicHandle wxBitmapRefData::GetPictHandle()
} }
CloseComponent( exporter ); CloseComponent( exporter );
} }
#endif
#endif #endif
} }
@@ -694,8 +543,7 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
CGImageRef image ; CGImageRef image ;
if ( m_rawAccessCount > 0 || m_cgImageRef == NULL ) if ( m_rawAccessCount > 0 || m_cgImageRef == NULL )
{ {
#if wxMAC_USE_CORE_GRAPHICS if ( m_depth != 1 && m_bitmapMask == NULL )
if ( UMAGetSystemVersion() >= 0x1040 && m_depth != 1 && m_bitmapMask == NULL )
{ {
if ( m_bitmapMask ) if ( m_bitmapMask )
{ {
@@ -709,7 +557,6 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
image = CGBitmapContextCreateImage( m_hBitmap ); image = CGBitmapContextCreateImage( m_hBitmap );
} }
else else
#endif
{ {
size_t imageSize = m_height * m_bytesPerRow ; size_t imageSize = m_height * m_bytesPerRow ;
void * dataBuffer = m_memBuf.GetData() ; void * dataBuffer = m_memBuf.GetData() ;
@@ -800,61 +647,10 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
return image ; return image ;
} }
#if wxMAC_USE_CORE_GRAPHICS
CGContextRef wxBitmapRefData::GetBitmapContext() const CGContextRef wxBitmapRefData::GetBitmapContext() const
{ {
return m_hBitmap; 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() void wxBitmapRefData::Free()
{ {
@@ -882,21 +678,10 @@ void wxBitmapRefData::Free()
if ( m_hBitmap ) if ( m_hBitmap )
{ {
#if !wxMAC_USE_CORE_GRAPHICS
DisposeGWorld( MAC_WXHBITMAP(m_hBitmap) ) ;
#else
CGContextRelease(m_hBitmap); CGContextRelease(m_hBitmap);
#endif
m_hBitmap = NULL ; m_hBitmap = NULL ;
} }
#if !wxMAC_USE_CORE_GRAPHICS
if ( m_hMaskBitmap )
{
DisposeGWorld( MAC_WXHBITMAP(m_hMaskBitmap) ) ;
m_hMaskBitmap = NULL ;
}
#endif
if (m_bitmapMask) if (m_bitmapMask)
{ {
delete m_bitmapMask; delete m_bitmapMask;
@@ -1394,11 +1179,6 @@ wxImage wxBitmap::ConvertToImage() const
} }
else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE )
b = MASK_BLUE_REPLACEMENT ; b = MASK_BLUE_REPLACEMENT ;
#if !wxMAC_USE_CORE_GRAPHICS
maskp++ ;
maskp++ ;
maskp++ ;
#endif
} }
else if ( hasAlpha ) else if ( hasAlpha )
{ {
@@ -1544,13 +1324,9 @@ void wxBitmap::SetMask(wxMask *mask)
WXHBITMAP wxBitmap::GetHBITMAP(WXHBITMAP* mask) const WXHBITMAP wxBitmap::GetHBITMAP(WXHBITMAP* mask) const
{ {
#if !wxMAC_USE_CORE_GRAPHICS
return WXHBITMAP(M_BITMAPDATA->GetHBITMAP((GWorldPtr*)mask));
#else
wxUnusedVar(mask); wxUnusedVar(mask);
return WXHBITMAP(M_BITMAPDATA->GetBitmapContext()); return WXHBITMAP(M_BITMAPDATA->GetBitmapContext());
#endif
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1605,11 +1381,7 @@ wxMask::~wxMask()
{ {
if ( m_maskBitmap ) if ( m_maskBitmap )
{ {
#if wxMAC_USE_CORE_GRAPHICS
CGContextRelease( (CGContextRef) m_maskBitmap ); CGContextRelease( (CGContextRef) m_maskBitmap );
#else
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
#endif
m_maskBitmap = NULL ; m_maskBitmap = NULL ;
} }
} }
@@ -1632,15 +1404,10 @@ void wxMask::RealizeNative()
{ {
if ( m_maskBitmap ) if ( m_maskBitmap )
{ {
#if wxMAC_USE_CORE_GRAPHICS
CGContextRelease( (CGContextRef) m_maskBitmap ); CGContextRelease( (CGContextRef) m_maskBitmap );
#else
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
#endif
m_maskBitmap = NULL ; m_maskBitmap = NULL ;
} }
#if wxMAC_USE_CORE_GRAPHICS
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
// from MouseTracking sample : // from MouseTracking sample :
// Ironically, due to a bug in CGImageCreateWithMask, you cannot use // Ironically, due to a bug in CGImageCreateWithMask, you cannot use
@@ -1650,14 +1417,6 @@ void wxMask::RealizeNative()
kCGImageAlphaNone ); kCGImageAlphaNone );
CGColorSpaceRelease( colorspace ); CGColorSpaceRelease( colorspace );
wxASSERT_MSG( m_maskBitmap , wxT("Unable to create CGBitmapContext context") ) ; 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). // Create a mask from a mono bitmap (copies the bitmap).
@@ -1703,23 +1462,9 @@ bool wxMask::Create(const wxBitmap& bitmap)
b = *srcdata++ ; b = *srcdata++ ;
if ( ( r + g + b ) > 0x10 ) if ( ( r + g + b ) > 0x10 )
{
*destdata++ = 0xFF ; *destdata++ = 0xFF ;
#if !wxMAC_USE_CORE_GRAPHICS
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
#endif
}
else else
{
*destdata++ = 0x00 ; *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++ ; b = *srcdata++ ;
if ( colour == wxColour( r , g , b ) ) if ( colour == wxColour( r , g , b ) )
{
*destdata++ = 0xFF ; *destdata++ = 0xFF ;
#if !wxMAC_USE_CORE_GRAPHICS
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
#endif
}
else else
{
*destdata++ = 0x00 ; *destdata++ = 0x00 ;
#if !wxMAC_USE_CORE_GRAPHICS
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
#endif
}
} }
} }

View File

@@ -166,23 +166,11 @@ wxSize wxButton::DoGetBestSize() const
else else
#endif #endif
{ {
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxButton*>(this)); wxClientDC dc(const_cast<wxButton*>(this));
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( m_label , &width, &height); dc.GetTextExtent( m_label , &width, &height);
bounds.h = width; bounds.h = width;
bounds.v = height; 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; wBtn = bounds.h + sz.y;

View File

@@ -274,62 +274,28 @@ wxSize wxChoice::DoGetBestSize() const
lbHeight = metric ; lbHeight = metric ;
{ {
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxChoice*>(this)); 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 // Find the widest line
for(unsigned int i = 0; i < GetCount(); i++) for(unsigned int i = 0; i < GetCount(); i++)
{ {
wxString str(GetString(i)); wxString str(GetString(i));
#if wxMAC_USE_CORE_GRAPHICS
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( str , &width, &height); dc.GetTextExtent( str , &width, &height);
wLine = width ; 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 ) ; lbWidth = wxMax( lbWidth, wLine ) ;
} }
// Add room for the popup arrow // Add room for the popup arrow
lbWidth += 2 * lbHeight ; lbWidth += 2 * lbHeight ;
#if wxMAC_USE_CORE_GRAPHICS
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( wxT("X"), &width, &height); dc.GetTextExtent( wxT("X"), &width, &height);
int cx = width ; int cx = width ;
lbHeight += 4; lbHeight += 4;
#else
// And just a bit more
int cx = ::TextWidth( "X" , 0 , 1 ) ;
#endif
lbWidth += cx ; lbWidth += cx ;
} }

View File

@@ -144,6 +144,9 @@ void wxClipboard::Close()
bool wxClipboard::IsSupported( const wxDataFormat &dataFormat ) bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
{ {
wxLogTrace(TRACE_CLIPBOARD, wxT("Checking if format %s is available"),
dataFormat.GetId().c_str());
if ( m_data ) if ( m_data )
return m_data->IsSupported( dataFormat ); return m_data->IsSupported( dataFormat );
return wxDataObject::IsFormatInPasteboard( m_pasteboard, dataFormat ); return wxDataObject::IsFormatInPasteboard( m_pasteboard, dataFormat );

View File

@@ -92,11 +92,7 @@ wxMacDataBrowserTableViewControl::wxMacDataBrowserTableViewControl(wxWindow* pee
if (gDataBrowserTableViewItemNotificationUPP == NULL) if (gDataBrowserTableViewItemNotificationUPP == NULL)
{ {
gDataBrowserTableViewItemNotificationUPP = gDataBrowserTableViewItemNotificationUPP =
#if TARGET_API_MAC_OSX
(DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc); (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
#else
NewDataBrowserItemNotificationUPP(wxMacDataBrowserTableViewControl::DataBrowserItemNotificationProc);
#endif
} }
DataBrowserCallbacks callbacks; DataBrowserCallbacks callbacks;

View File

@@ -129,18 +129,10 @@ void wxDataFormat::SetType( wxDataFormatId dataType )
break; break;
case wxDF_BITMAP: case wxDF_BITMAP:
#if wxMAC_USE_CORE_GRAPHICS
m_format = (long) CFStringCreateCopy( NULL, CFSTR("public.tiff") ); m_format = (long) CFStringCreateCopy( NULL, CFSTR("public.tiff") );
#else
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.apple.pict") );
#endif
break; break;
case wxDF_METAFILE: case wxDF_METAFILE:
#if wxMAC_USE_CORE_GRAPHICS
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.adobe.pdf") ); m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.adobe.pdf") );
#else
m_format = (long) CFStringCreateCopy( NULL, CFSTR("com.apple.pict") );
#endif
break; break;
case wxDF_FILENAME: case wxDF_FILENAME:
@@ -177,7 +169,6 @@ void wxDataFormat::SetId( NativeFormat format )
{ {
m_type = wxDF_TEXT; m_type = wxDF_TEXT;
} }
#if wxMAC_USE_CORE_GRAPHICS
else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("public.tiff") ) ) else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("public.tiff") ) )
{ {
m_type = wxDF_BITMAP; m_type = wxDF_BITMAP;
@@ -186,12 +177,6 @@ void wxDataFormat::SetId( NativeFormat format )
{ {
m_type = wxDF_METAFILE; 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") ) ) else if ( UTTypeConformsTo( (CFStringRef)format, CFSTR("public.file-url") ) )
{ {
m_type = wxDF_FILENAME; m_type = wxDF_FILENAME;
@@ -647,12 +632,7 @@ wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& rBitmap )
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
#if wxMAC_USE_CORE_GRAPHICS
SetBitmap( rBitmap ); SetBitmap( rBitmap );
#else
m_pictHandle = m_bitmap.GetBitmapData()->GetPictHandle();
m_pictCreated = false;
#endif
} }
} }
@@ -667,11 +647,8 @@ void wxBitmapDataObject::SetBitmap( const wxBitmap& rBitmap )
wxBitmapDataObjectBase::SetBitmap( rBitmap ); wxBitmapDataObjectBase::SetBitmap( rBitmap );
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
#if wxMAC_USE_CORE_GRAPHICS
CGImageRef cgImageRef = (CGImageRef) m_bitmap.CGImageCreate(); 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); CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGImageDestinationRef destination = CGImageDestinationCreateWithData( data , kUTTypeTIFF , 1 , NULL ); CGImageDestinationRef destination = CGImageDestinationCreateWithData( data , kUTTypeTIFF , 1 , NULL );
if ( destination ) if ( destination )
@@ -686,32 +663,8 @@ void wxBitmapDataObject::SetBitmap( const wxBitmap& rBitmap )
memcpy( *(Handle)m_pictHandle, (const char *)CFDataGetBytePtr(data), CFDataGetLength(data) ); memcpy( *(Handle)m_pictHandle, (const char *)CFDataGetBytePtr(data), CFDataGetLength(data) );
} }
CFRelease( data ); CFRelease( data );
}
else
#endif
#ifndef __LP64__
{
// 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 );
}
}
#endif
CGImageRelease(cgImageRef); 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 (m_pictHandle != NULL)
{ {
#if wxMAC_USE_CORE_GRAPHICS
DisposeHandle( (Handle) m_pictHandle ); DisposeHandle( (Handle) m_pictHandle );
#else
if (m_pictCreated)
KillPicture( (PicHandle)m_pictHandle );
#endif
m_pictHandle = NULL; m_pictHandle = NULL;
} }
m_pictCreated = false; m_pictCreated = false;
@@ -778,14 +726,11 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
if ((pBuf == NULL) || (nSize == 0)) if ((pBuf == NULL) || (nSize == 0))
return false; return false;
#if wxMAC_USE_CORE_GRAPHICS
Handle picHandle = NewHandle( nSize ); Handle picHandle = NewHandle( nSize );
memcpy( *picHandle, pBuf, nSize ); memcpy( *picHandle, pBuf, nSize );
m_pictHandle = picHandle; m_pictHandle = picHandle;
CGImageRef cgImageRef = 0; 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); CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull);
CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL ); CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL );
if ( source ) if ( source )
@@ -794,30 +739,7 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
} }
CFRelease( source ); CFRelease( source );
CFRelease( data ); CFRelease( data );
}
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
if ( cgImageRef ) if ( cgImageRef )
{ {
m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) ); m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
@@ -827,28 +749,6 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
CGImageRelease(cgImageRef); CGImageRelease(cgImageRef);
cgImageRef = NULL; 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(); return m_bitmap.Ok();
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -51,70 +51,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
static wxBrush MacGetBackgroundBrush( wxWindow* window ) static wxBrush MacGetBackgroundBrush( wxWindow* window )
{ {
wxBrush bkdBrush = window->MacGetBackgroundBrush() ; 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 ; return bkdBrush ;
} }
wxWindowDC::wxWindowDC() wxWindowDC::wxWindowDC()
{ {
m_window = NULL ; m_window = NULL ;
#if wxMAC_USE_CORE_GRAPHICS
m_release = false; m_release = false;
#endif
} }
wxWindowDC::wxWindowDC(wxWindow *window) wxWindowDC::wxWindowDC(wxWindow *window)
@@ -126,7 +69,6 @@ wxWindowDC::wxWindowDC(wxWindow *window)
m_ok = true ; m_ok = true ;
#if wxMAC_USE_CORE_GRAPHICS
m_window->GetSize( &m_width , &m_height); m_window->GetSize( &m_width , &m_height);
CGContextRef cg = (CGContextRef) window->MacGetCGContextRef(); CGContextRef cg = (CGContextRef) window->MacGetCGContextRef();
m_release = false; m_release = false;
@@ -146,18 +88,7 @@ wxWindowDC::wxWindowDC(wxWindow *window)
SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
} }
SetClippingRegion( 0 , 0 , m_width , m_height ) ; 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)); SetBackground(MacGetBackgroundBrush(window));
SetFont( window->GetFont() ) ; SetFont( window->GetFont() ) ;
@@ -165,7 +96,6 @@ wxWindowDC::wxWindowDC(wxWindow *window)
wxWindowDC::~wxWindowDC() wxWindowDC::~wxWindowDC()
{ {
#if wxMAC_USE_CORE_GRAPHICS
if ( m_release ) if ( m_release )
{ {
// this must not necessarily be the current context, we must restore the state of the // 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(); CGContextRef cg = (CGContextRef) m_window->MacGetCGContextRef();
CGContextRestoreGState(cg); CGContextRestoreGState(cg);
} }
#endif
} }
void wxWindowDC::DoGetSize( int* width, int* height ) const void wxWindowDC::DoGetSize( int* width, int* height ) const
{ {
#if wxMAC_USE_CORE_GRAPHICS
if ( width ) if ( width )
*width = m_width; *width = m_width;
if ( height ) if ( height )
*height = m_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 wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const
@@ -253,7 +177,6 @@ wxClientDC::wxClientDC()
m_window = NULL ; m_window = NULL ;
} }
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC::wxClientDC(wxWindow *window) : wxClientDC::wxClientDC(wxWindow *window) :
wxWindowDC( window ) wxWindowDC( window )
{ {
@@ -263,51 +186,11 @@ wxClientDC::wxClientDC(wxWindow *window) :
SetDeviceOrigin( origin.x, origin.y ); SetDeviceOrigin( origin.x, origin.y );
SetClippingRegion( 0 , 0 , m_width , m_height ) ; 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() 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 * wxPaintDC
*/ */
@@ -317,7 +200,6 @@ wxPaintDC::wxPaintDC()
m_window = NULL ; m_window = NULL ;
} }
#if wxMAC_USE_CORE_GRAPHICS
wxPaintDC::wxPaintDC(wxWindow *window) : wxPaintDC::wxPaintDC(wxWindow *window) :
wxWindowDC( window ) wxWindowDC( window )
{ {
@@ -326,61 +208,7 @@ wxPaintDC::wxPaintDC(wxWindow *window) :
SetDeviceOrigin( origin.x, origin.y ); SetDeviceOrigin( origin.x, origin.y );
SetClippingRegion( 0 , 0 , m_width , m_height ) ; 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() 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

View File

@@ -42,13 +42,9 @@ wxMemoryDC::~wxMemoryDC()
{ {
if ( m_selected.Ok() ) if ( m_selected.Ok() )
{ {
#if wxMAC_USE_CORE_GRAPHICS
m_selected.EndRawAccess() ; m_selected.EndRawAccess() ;
delete m_graphicContext ; delete m_graphicContext ;
m_graphicContext = NULL ; 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 ( m_selected.Ok() )
{ {
#if wxMAC_USE_CORE_GRAPHICS
m_selected.EndRawAccess() ; m_selected.EndRawAccess() ;
delete m_graphicContext ; delete m_graphicContext ;
m_graphicContext = NULL ; m_graphicContext = NULL ;
#else
// TODO: UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
#endif
} }
m_selected = bitmap; m_selected = bitmap;
if (m_selected.Ok()) if (m_selected.Ok())
{ {
#if wxMAC_USE_CORE_GRAPHICS
if ( m_selected.GetDepth() != 1 ) if ( m_selected.GetDepth() != 1 )
m_selected.UseAlpha() ; m_selected.UseAlpha() ;
m_selected.BeginRawAccess() ; m_selected.BeginRawAccess() ;
@@ -84,17 +75,6 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) );
} }
m_ok = (m_graphicContext != NULL) ; 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 else
{ {

View File

@@ -63,9 +63,6 @@ public :
virtual void GetSize( int *w , int *h) const ; virtual void GetSize( int *w , int *h) const ;
virtual wxSize GetPPI() const ; virtual wxSize GetPPI() const ;
private : private :
#if !wxMAC_USE_CORE_GRAPHICS
GrafPtr m_macPrintFormerPort ;
#endif
wxCoord m_maxX ; wxCoord m_maxX ;
wxCoord m_maxY ; wxCoord m_maxY ;
wxSize m_ppi ; wxSize m_ppi ;
@@ -74,9 +71,6 @@ private :
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data ) wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
{ {
#if !wxMAC_USE_CORE_GRAPHICS
::GetPort( & m_macPrintFormerPort ) ;
#endif
m_err = noErr ; m_err = noErr ;
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->GetNativeData() ; wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->GetNativeData() ;
@@ -101,10 +95,6 @@ wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
wxMacCarbonPrinterDC::~wxMacCarbonPrinterDC() 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) wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
@@ -119,24 +109,9 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().GetNativeData() ; 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, m_err = PMSessionBeginCGDocument(native->m_macPrintSession,
native->m_macPrintSettings, native->m_macPrintSettings,
native->m_macPageFormat); native->m_macPageFormat);
#else
m_err = PMSessionBeginDocument(native->m_macPrintSession,
native->m_macPrintSettings,
native->m_macPageFormat);
#endif
if ( m_err != noErr ) if ( m_err != noErr )
return false; return false;
@@ -182,26 +157,12 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
native->m_macPageFormat, native->m_macPageFormat,
nil); nil);
#if wxMAC_USE_CORE_GRAPHICS
CGContextRef pageContext; CGContextRef pageContext;
#endif
if ( m_err == noErr ) 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, m_err = PMSessionGetCGGraphicsContext(native->m_macPrintSession,
&pageContext ); &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 ) if ( m_err != noErr )
@@ -216,23 +177,17 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage); m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
if ( !m_err ) if ( !m_err )
{ {
#if wxMAC_USE_CORE_GRAPHICS
PMRect paperRect ; PMRect paperRect ;
PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ; PMGetAdjustedPaperRect( native->m_macPageFormat , &paperRect ) ;
// make sure (0,0) is at the upper left of the printable area (wx conventions) // 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 // Core Graphics initially has the lower left of the paper as 0,0
CGContextTranslateCTM( pageContext , -paperRect.left , paperRect.bottom ) ; CGContextTranslateCTM( pageContext , -paperRect.left , paperRect.bottom ) ;
CGContextScaleCTM( pageContext , 1 , -1 ) ; 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 // since this is a non-critical error, we set the flag back
m_err = noErr ; m_err = noErr ;
} }
#if wxMAC_USE_CORE_GRAPHICS
dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) ); dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) );
#endif
} }
void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc ) void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
@@ -247,10 +202,8 @@ void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
{ {
PMSessionEndDocument(native->m_macPrintSession); 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 // the cg context we got when starting the page isn't valid anymore, so replace it
dc->SetGraphicsContext( wxGraphicsContext::Create() ); dc->SetGraphicsContext( wxGraphicsContext::Create() );
#endif
} }
void wxMacCarbonPrinterDC::GetSize( int *w , int *h) const 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_x = mm2inches * sz.x;
m_mm_to_pix_y = mm2inches * sz.y; 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 // we need at least a measuring context because people start measuring before a page
// gets printed at all // gets printed at all
SetGraphicsContext( wxGraphicsContext::Create() ); SetGraphicsContext( wxGraphicsContext::Create() );
#endif
} }
} }
@@ -380,11 +331,6 @@ void wxPrinterDC::StartPage(void)
m_font = *wxNORMAL_FONT; m_font = *wxNORMAL_FONT;
m_brush = *wxTRANSPARENT_BRUSH; m_brush = *wxTRANSPARENT_BRUSH;
m_backgroundBrush = *wxWHITE_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_nativePrinterDC->StartPage(this) ;
m_ok = m_nativePrinterDC->Ok() ; m_ok = m_nativePrinterDC->Ok() ;

View File

@@ -25,7 +25,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
// Create a DC representing the whole screen // Create a DC representing the whole screen
wxScreenDC::wxScreenDC() wxScreenDC::wxScreenDC()
{ {
#if wxMAC_USE_CORE_GRAPHICS
CGRect cgbounds ; CGRect cgbounds ;
cgbounds = CGDisplayBounds(CGMainDisplayID()); cgbounds = CGDisplayBounds(CGMainDisplayID());
Rect bounds; Rect bounds;
@@ -39,43 +38,12 @@ wxScreenDC::wxScreenDC()
SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) ); SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );
m_width = (wxCoord)cgbounds.size.width; m_width = (wxCoord)cgbounds.size.width;
m_height = (wxCoord)cgbounds.size.height; 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 ; m_ok = true ;
} }
wxScreenDC::~wxScreenDC() wxScreenDC::~wxScreenDC()
{ {
#if wxMAC_USE_CORE_GRAPHICS
delete m_graphicContext; delete m_graphicContext;
m_graphicContext = NULL; m_graphicContext = NULL;
DisposeWindow((WindowRef) m_overlayWindow ); DisposeWindow((WindowRef) m_overlayWindow );
#else
if ( m_macPort )
DisposePort( (CGrafPtr) m_macPort ) ;
#endif
} }

View File

@@ -341,10 +341,8 @@ int wxFileDialog::ShowModal()
if (numFilters < 2) if (numFilters < 2)
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension; dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
#if TARGET_API_MAC_OSX
if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT)) if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT))
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement; dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
#endif
err = ::NavCreatePutFileDialog( err = ::NavCreatePutFileDialog(
&dialogCreateOptions, &dialogCreateOptions,

View File

@@ -11,8 +11,6 @@
#include "wx/wxprec.h" #include "wx/wxprec.h"
#if wxUSE_GRAPHICS_CONTEXT && wxMAC_USE_CORE_GRAPHICS
#include "wx/graphics.h" #include "wx/graphics.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
@@ -36,16 +34,9 @@
#include "wx/mac/private.h" #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; typedef float CGFloat;
#endif #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 // constants
@@ -168,24 +159,9 @@ public :
} }
void StrokeLineSegments( CGContextRef ctxRef , const CGPoint pts[] , size_t count ) 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 ); 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);
}
}
virtual void Render( CGContextRef ctxRef ) virtual void Render( CGContextRef ctxRef )
{ {
@@ -531,38 +507,11 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush )
{ {
if ( brush.MacGetBrushKind() == kwxMacBrushTheme ) if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if ( UMAGetSystemVersion() >= 0x1040 )
{
CGColorRef color ; CGColorRef color ;
HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color ); HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
m_color.Set( color ) ; m_color.Set( color ) ;
} }
else 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 ) ) ;
}
}
}
else
{ {
CGFloat components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , CGFloat components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ; brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ;
@@ -897,25 +846,9 @@ void wxMacCoreGraphicsMatrixData::Invert()
// returns true if the elements of the transformation matrix are equal ? // returns true if the elements of the transformation matrix are equal ?
bool wxMacCoreGraphicsMatrixData::IsEqual( const wxGraphicsMatrixData* t) const 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())); 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 true if this is the identity matrix // return true if this is the identity matrix
bool wxMacCoreGraphicsMatrixData::IsIdentity() const bool wxMacCoreGraphicsMatrixData::IsIdentity() const
@@ -1152,20 +1085,9 @@ void wxMacCoreGraphicsPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wx
} }
bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, int fillStyle) const 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 ); 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;
}
}
// //
// Graphics Context // Graphics Context
@@ -1471,26 +1393,15 @@ bool wxMacCoreGraphicsContext::SetLogicalFunction( int function )
if ( function == wxCOPY ) if ( function == wxCOPY )
{ {
retval = true; retval = true;
#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
if ( CGContextSetBlendMode != NULL )
{
CGContextSetBlendMode( m_cgContext, kCGBlendModeNormal ); CGContextSetBlendMode( m_cgContext, kCGBlendModeNormal );
CGContextSetShouldAntialias( m_cgContext, true );
}
#endif
} }
else if ( function == wxINVERT || function == wxXOR ) else if ( function == wxINVERT || function == wxXOR )
{
#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
if ( CGContextSetBlendMode != NULL )
{ {
// change color to white // change color to white
CGContextSetBlendMode( m_cgContext, kCGBlendModeExclusion ); CGContextSetBlendMode( m_cgContext, kCGBlendModeExclusion );
CGContextSetShouldAntialias( m_cgContext, false ); CGContextSetShouldAntialias( m_cgContext, false );
retval = true; retval = true;
} }
#endif
}
if (retval) if (retval)
m_logicalFunction = function; m_logicalFunction = function;
@@ -2253,6 +2164,3 @@ wxGraphicsFont wxMacCoreGraphicsRenderer::CreateFont( const wxFont &font , const
return wxNullGraphicsFont; return wxNullGraphicsFont;
} }
#endif // wxMAC_USE_CORE_GRAPHICS

View File

@@ -218,52 +218,17 @@ wxSize wxListBox::DoGetBestSize() const
int wLine; int wLine;
{ {
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxListBox*>(this)); wxClientDC dc(const_cast<wxListBox*>(this));
dc.SetFont(GetFont()); 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 // Find the widest line
for (unsigned int i = 0; i < GetCount(); i++) for (unsigned int i = 0; i < GetCount(); i++)
{ {
wxString str( GetString( i ) ); wxString str( GetString( i ) );
#if wxMAC_USE_CORE_GRAPHICS
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( str , &width, &height); dc.GetTextExtent( str , &width, &height);
wLine = width ; 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 ); lbWidth = wxMax( lbWidth, wLine );
} }
@@ -272,13 +237,10 @@ wxSize wxListBox::DoGetBestSize() const
// And just a bit more // And just a bit more
int cy = 12; int cy = 12;
#if wxMAC_USE_CORE_GRAPHICS
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( wxT("XX") , &width, &height); dc.GetTextExtent( wxT("XX") , &width, &height);
int cx = width ; int cx = width ;
#else
int cx = ::TextWidth( "XX", 0, 1 );
#endif
lbWidth += cx; lbWidth += cx;
// don't make the listbox too tall (limit height to around 10 items) // don't make the listbox too tall (limit height to around 10 items)

View File

@@ -2510,9 +2510,7 @@ wxMacDataBrowserListCtrlControl::wxMacDataBrowserListCtrlControl( wxWindow *peer
if ( style & wxLC_VRULES ) if ( style & wxLC_VRULES )
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
verify_noerr( DataBrowserChangeAttributes(m_controlRef, kDataBrowserAttributeListViewDrawColumnDividers, kDataBrowserAttributeNone) ); verify_noerr( DataBrowserChangeAttributes(m_controlRef, kDataBrowserAttributeListViewDrawColumnDividers, kDataBrowserAttributeNone) );
#endif
} }
verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) ); verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );

View File

@@ -711,12 +711,7 @@ void wxMenuBar::MacInstallMenuBar()
MenuBarHandle menubar = NULL ; MenuBarHandle menubar = NULL ;
#if TARGET_API_MAC_OSX
menubar = NewHandleClear( 6 /* sizeof( MenuBarHeader ) */ ) ; menubar = NewHandleClear( 6 /* sizeof( MenuBarHeader ) */ ) ;
#else
menubar = NewHandleClear( 12 ) ;
(*menubar)[3] = 0x0a ;
#endif
::SetMenuBar( menubar ) ; ::SetMenuBar( menubar ) ;
DisposeMenuBar( menubar ) ; DisposeMenuBar( menubar ) ;
@@ -728,10 +723,8 @@ void wxMenuBar::MacInstallMenuBar()
// Add About/Preferences separator only on OS X // Add About/Preferences separator only on OS X
// KH/RN: Separator is always present on 10.3 but not on 10.2 // 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 // However, the change from 10.2 to 10.3 suggests it is preferred
#if TARGET_API_MAC_OSX
InsertMenuItemTextWithCFString( appleMenu, InsertMenuItemTextWithCFString( appleMenu,
CFSTR(""), 0, kMenuItemAttrSeparator, 0); CFSTR(""), 0, kMenuItemAttrSeparator, 0);
#endif
InsertMenuItemTextWithCFString( appleMenu, InsertMenuItemTextWithCFString( appleMenu,
CFSTR("About..."), 0, 0, 0); CFSTR("About..."), 0, 0, 0);
MacInsertMenu( appleMenu , 0 ) ; MacInsertMenu( appleMenu , 0 ) ;

View File

@@ -103,7 +103,6 @@ int wxMessageDialog::ShowModal()
} }
#if TARGET_API_MAC_OSX
if ( !wxIsMainThread() ) if ( !wxIsMainThread() )
{ {
CFStringRef defaultButtonTitle = NULL; CFStringRef defaultButtonTitle = NULL;
@@ -163,7 +162,6 @@ int wxMessageDialog::ShowModal()
resultbutton = buttonId[exitButton]; resultbutton = buttonId[exitButton];
} }
else else
#endif
{ {
short result; short result;

View File

@@ -326,7 +326,6 @@ int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
{ {
int resultV = wxNOT_FOUND; int resultV = wxNOT_FOUND;
#if TARGET_API_MAC_OSX
const int countPages = GetPageCount(); const int countPages = GetPageCount();
// we have to convert from Client to Window relative coordinates // 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 ) if ( outPart >= 1 && outPart <= countPages )
resultV = outPart - 1 ; resultV = outPart - 1 ;
#endif // TARGET_API_MAC_OSX
if (flags != NULL) if (flags != NULL)
{ {
@@ -424,13 +422,7 @@ void wxNotebook::MacSetupTabs()
m_peer->SetTabEnabled( ii + 1, true ) ; m_peer->SetTabEnabled( ii + 1, true ) ;
} }
#if wxMAC_USE_CORE_GRAPHICS
Refresh(); Refresh();
#else
Rect bounds;
m_peer->GetRectInWindowCoords( &bounds ) ;
InvalWindowRect( (WindowRef)MacGetTopLevelWindowRef(), &bounds );
#endif
} }
wxRect wxNotebook::GetPageRect() const wxRect wxNotebook::GetPageRect() const

View File

@@ -154,9 +154,6 @@ bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data )
PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ; PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
#endif #endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if ( PMSetDuplex!=NULL )
{
PMDuplexMode mode = 0 ; PMDuplexMode mode = 0 ;
switch( data.GetDuplex() ) switch( data.GetDuplex() )
{ {
@@ -172,8 +169,7 @@ bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data )
break ; break ;
} }
PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ; PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ;
}
#endif
// PMQualityMode not yet accessible via API // PMQualityMode not yet accessible via API
// todo paperSize // todo paperSize
@@ -240,9 +236,6 @@ bool wxMacCarbonPrintData::TransferTo( wxPrintData &data )
if ( err == noErr ) if ( err == noErr )
data.SetColour( !(color == kPMBlackAndWhite) ) ; data.SetColour( !(color == kPMBlackAndWhite) ) ;
#endif #endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if ( PMGetDuplex!=NULL )
{
PMDuplexMode mode = 0 ; PMDuplexMode mode = 0 ;
PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ; PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ;
switch( mode ) switch( mode )
@@ -258,8 +251,6 @@ bool wxMacCarbonPrintData::TransferTo( wxPrintData &data )
data.SetDuplex(wxDUPLEX_SIMPLEX); data.SetDuplex(wxDUPLEX_SIMPLEX);
break ; break ;
} }
}
#endif
// PMQualityMode not yet accessible via API // PMQualityMode not yet accessible via API
PMPaper paper ; PMPaper paper ;
@@ -509,14 +500,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
} }
else else
{ {
#if !wxMAC_USE_CORE_GRAPHICS
GrafPtr thePort ;
GetPort( &thePort ) ;
#endif
wxSafeYield(win,true); wxSafeYield(win,true);
#if !wxMAC_USE_CORE_GRAPHICS
SetPort( thePort ) ;
#endif
dc->StartPage(); dc->StartPage();
keepGoing = printout->OnPrintPage(pn); keepGoing = printout->OnPrintPage(pn);
dc->EndPage(); dc->EndPage();

View File

@@ -111,18 +111,10 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
wxHeaderSortIconType sortArrow, wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params ) 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 x = rect.x;
const wxCoord y = rect.y; const wxCoord y = rect.y;
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
#endif
dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.SetBrush( *wxTRANSPARENT_BRUSH );
@@ -145,26 +137,7 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
{ {
CGContextRef cgContext; CGContextRef cgContext;
#if wxMAC_USE_CORE_GRAPHICS
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); 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; HIThemeButtonDrawInfo drawInfo;
@@ -195,11 +168,6 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
CGContextRestoreGState( cgContext ); 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 // 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, const wxRect& rect,
int flags ) 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 // now the wxGCDC is using native transformations
const wxCoord x = rect.x; const wxCoord x = rect.x;
const wxCoord y = rect.y; const wxCoord y = rect.y;
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
#endif
dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.SetBrush( *wxTRANSPARENT_BRUSH );
@@ -268,23 +229,8 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
{ {
CGContextRef cgContext; CGContextRef cgContext;
#if wxMAC_USE_CORE_GRAPHICS
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); 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 );
HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
CGContextClip( cgContext );
HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
#endif
{
HIThemeButtonDrawInfo drawInfo; HIThemeButtonDrawInfo drawInfo;
HIRect labelRect; HIRect labelRect;
@@ -298,13 +244,6 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
drawInfo.adornment = kThemeAdornmentNone; drawInfo.adornment = kThemeAdornmentNone;
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect ); HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
}
#if wxMAC_USE_CORE_GRAPHICS
#else
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
#endif
} }
} }
@@ -324,13 +263,6 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
else else
splitterRect = CGRectMake( 0, position, size.x, height ); 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 // 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 // strange redraw errors occur if we don't do this
@@ -353,26 +285,13 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
{ {
CGContextRef cgContext; CGContextRef cgContext;
#if wxMAC_USE_CORE_GRAPHICS
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); 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; HIThemeSplitterDrawInfo drawInfo;
drawInfo.version = 0; drawInfo.version = 0;
drawInfo.state = kThemeStateActive; drawInfo.state = kThemeStateActive;
drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone; drawInfo.adornment = hasMetal ? kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
HIThemeDrawPaneSplitter( &splitterRect, &drawInfo, cgContext, kHIThemeOrientationNormal ); 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 kind,
int adornment) 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 // now the wxGCDC is using native transformations
const wxCoord x = rect.x; const wxCoord x = rect.x;
const wxCoord y = rect.y; const wxCoord y = rect.y;
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
#endif
dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.SetBrush( *wxTRANSPARENT_BRUSH );
@@ -446,24 +358,8 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
else else
{ {
CGContextRef cgContext; CGContextRef cgContext;
#if wxMAC_USE_CORE_GRAPHICS
cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext(); 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 );
HIShapeReplacePathInCGContext( HIShapeCreateWithQDRgn( (RgnHandle) dc.m_macCurrentClipRgn ), cgContext );
CGContextClip( cgContext );
HIViewConvertRect( &headerRect, (HIViewRef) win->GetHandle(), (HIViewRef) win->MacGetTopLevelWindow()->GetHandle() );
#endif
{
HIThemeButtonDrawInfo drawInfo; HIThemeButtonDrawInfo drawInfo;
HIRect labelRect; HIRect labelRect;
@@ -478,12 +374,6 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect ); HIThemeDrawButton( &headerRect, &drawInfo, cgContext, kHIThemeOrientationNormal, &labelRect );
} }
#if wxMAC_USE_CORE_GRAPHICS
#else
QDEndCGContext( (CGrafPtr) dc.m_macPort, &cgContext );
#endif
}
} }
void void
@@ -545,8 +435,6 @@ wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int fl
return; 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 ; HIThemeFrameDrawInfo info ;
@@ -562,21 +450,4 @@ wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int fl
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ; 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
}

View File

@@ -40,9 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
static const EventTypeSpec eventList[] = static const EventTypeSpec eventList[] =
{ {
{ kEventClassSearchField, kEventSearchFieldCancelClicked } , { kEventClassSearchField, kEventSearchFieldCancelClicked } ,
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
{ kEventClassSearchField, kEventSearchFieldSearchClicked } , { kEventClassSearchField, kEventSearchFieldSearchClicked } ,
#endif
}; };
class wxMacSearchFieldControl : public wxMacUnicodeTextControl class wxMacSearchFieldControl : public wxMacUnicodeTextControl
@@ -80,13 +78,8 @@ void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
const Rect* bounds, const Rect* bounds,
CFStringRef WXUNUSED(crf)) CFStringRef WXUNUSED(crf))
{ {
OptionBits attributes = 0; OptionBits attributes = kHISearchFieldAttributesSearchIcon;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if ( UMAGetSystemVersion() >= 0x1040 )
{
attributes = kHISearchFieldAttributesSearchIcon;
}
#endif
HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } }; HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } };
verify_noerr( HISearchFieldCreate( verify_noerr( HISearchFieldCreate(
&hibounds, &hibounds,
@@ -100,9 +93,6 @@ void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
// search field options // search field options
void wxMacSearchFieldControl::ShowSearchButton( bool show ) 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 set = 0;
OptionBits clear = 0; OptionBits clear = 0;
@@ -116,18 +106,12 @@ void wxMacSearchFieldControl::ShowSearchButton( bool show )
} }
HISearchFieldChangeAttributes( m_controlRef, set, clear ); HISearchFieldChangeAttributes( m_controlRef, set, clear );
} }
#endif
}
bool wxMacSearchFieldControl::IsSearchButtonVisible() const bool wxMacSearchFieldControl::IsSearchButtonVisible() const
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
OptionBits attributes = 0; OptionBits attributes = 0;
verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) ); verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) );
return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0; return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0;
#else
return false;
#endif
} }
void wxMacSearchFieldControl::ShowCancelButton( bool show ) void wxMacSearchFieldControl::ShowCancelButton( bool show )
@@ -211,11 +195,9 @@ static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handl
case kEventSearchFieldCancelClicked : case kEventSearchFieldCancelClicked :
thisWindow->MacSearchFieldCancelHit( handler , event ) ; thisWindow->MacSearchFieldCancelHit( handler , event ) ;
break ; break ;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
case kEventSearchFieldSearchClicked : case kEventSearchFieldSearchClicked :
thisWindow->MacSearchFieldSearchHit( handler , event ) ; thisWindow->MacSearchFieldSearchHit( handler , event ) ;
break ; break ;
#endif
} }
return result ; return result ;

View File

@@ -106,23 +106,11 @@ wxSize wxStaticText::DoGetBestSize() const
else else
#endif #endif
{ {
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxStaticText*>(this)); wxClientDC dc(const_cast<wxStaticText*>(this));
wxCoord width, height ; wxCoord width, height ;
dc.GetTextExtent( m_label , &width, &height); dc.GetTextExtent( m_label , &width, &height);
bounds.h = width; bounds.h = width;
bounds.v = height; 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() ) if ( m_label.empty() )

View File

@@ -133,15 +133,9 @@ void wxCriticalSection::Leave()
// wxMutex implementation // wxMutex implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if TARGET_API_MAC_OSX
#define wxUSE_MAC_SEMAPHORE_MUTEX 0 #define wxUSE_MAC_SEMAPHORE_MUTEX 0
#define wxUSE_MAC_CRITICAL_REGION_MUTEX 1 #define wxUSE_MAC_CRITICAL_REGION_MUTEX 1
#define wxUSE_MAC_PTHREADS_MUTEX 0 #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 #if wxUSE_MAC_PTHREADS_MUTEX
@@ -1252,9 +1246,7 @@ bool wxThread::IsMain()
void wxThread::Yield() void wxThread::Yield()
{ {
#if TARGET_API_MAC_OSX
CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ; CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ;
#endif
MPYield(); MPYield();
} }

View File

@@ -383,17 +383,10 @@ bool wxToolBarTool::DoEnable( bool enable )
if ( m_controlHandle != NULL ) if ( m_controlHandle != NULL )
{ {
#if TARGET_API_MAC_OSX
if ( enable ) if ( enable )
EnableControl( m_controlHandle ); EnableControl( m_controlHandle );
else else
DisableControl( m_controlHandle ); 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(); bool drawMetalTheme = MacGetTopLevelWindow()->MacGetMetalAppearance();
#if wxMAC_USE_CORE_GRAPHICS
if ( !drawMetalTheme ) if ( !drawMetalTheme )
{ {
HIThemePlacardDrawInfo info; HIThemePlacardDrawInfo info;
@@ -1736,57 +1728,6 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
// leave the background as it is (striped or metal) // 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(); event.Skip();
} }

View File

@@ -658,14 +658,13 @@ wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
{ {
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ; EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
Point clickLocation = windowMouseLocation ; Point clickLocation = windowMouseLocation ;
#if TARGET_API_MAC_OSX
HIPoint hiPoint ; HIPoint hiPoint ;
hiPoint.x = clickLocation.h ; hiPoint.x = clickLocation.h ;
hiPoint.y = clickLocation.v ; hiPoint.y = clickLocation.v ;
HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ; HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
clickLocation.h = (int)hiPoint.x ; clickLocation.h = (int)hiPoint.x ;
clickLocation.v = (int)hiPoint.y ; clickLocation.v = (int)hiPoint.y ;
#endif // TARGET_API_MAC_OSX
HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ;
result = noErr ; result = noErr ;
@@ -1301,12 +1300,10 @@ void wxTopLevelWindowMac::DoMacCreateRealWindow(
} }
#endif #endif
#if TARGET_API_MAC_OSX
if ( m_macWindow != NULL ) if ( m_macWindow != NULL )
{ {
MacSetUnifiedAppearance( true ) ; MacSetUnifiedAppearance( true ) ;
} }
#endif
HIViewRef growBoxRef = 0 ; HIViewRef growBoxRef = 0 ;
err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef ); err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
@@ -1519,7 +1516,6 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle)
wxTopLevelWindowBase::SetExtraStyle( exStyle ) ; wxTopLevelWindowBase::SetExtraStyle( exStyle ) ;
#if TARGET_API_MAC_OSX
if ( m_macWindow != NULL ) if ( m_macWindow != NULL )
{ {
bool metal = GetExtraStyle() & wxFRAME_EX_METAL ; bool metal = GetExtraStyle() & wxFRAME_EX_METAL ;
@@ -1532,7 +1528,6 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle)
MacSetMetalAppearance( metal ) ; MacSetMetalAppearance( metal ) ;
} }
} }
#endif
} }
bool wxTopLevelWindowMac::SetBackgroundStyle(wxBackgroundStyle style) bool wxTopLevelWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
@@ -1621,28 +1616,19 @@ void wxTopLevelWindowMac::DoCentre(int dir)
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set ) void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
{ {
#if TARGET_API_MAC_OSX
if ( MacGetUnifiedAppearance() ) if ( MacGetUnifiedAppearance() )
MacSetUnifiedAppearance( false ) ; MacSetUnifiedAppearance( false ) ;
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes , MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
set ? kWindowNoAttributes : kWindowMetalAttribute ) ; set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
#endif
} }
bool wxTopLevelWindowMac::MacGetMetalAppearance() const bool wxTopLevelWindowMac::MacGetMetalAppearance() const
{ {
#if TARGET_API_MAC_OSX
return MacGetWindowAttributes() & kWindowMetalAttribute ; return MacGetWindowAttributes() & kWindowMetalAttribute ;
#else
return false;
#endif
} }
void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set ) void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set )
{
#if TARGET_API_MAC_OSX
if ( UMAGetSystemVersion() >= 0x1040 )
{ {
if ( MacGetMetalAppearance() ) if ( MacGetMetalAppearance() )
MacSetMetalAppearance( false ) ; MacSetMetalAppearance( false ) ;
@@ -1657,17 +1643,10 @@ void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set )
// though) // though)
SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ; SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ;
} }
#endif
}
bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const
{ {
#if TARGET_API_MAC_OSX
if ( UMAGetSystemVersion() >= 0x1040 )
return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ; return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
else
#endif
return false;
} }
void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )

View File

@@ -558,7 +558,6 @@ Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
{ {
GetControlBounds( theControl , bounds ) ; GetControlBounds( theControl , bounds ) ;
#if TARGET_API_MAC_OSX
WindowRef tlwref = GetControlOwner( theControl ) ; WindowRef tlwref = GetControlOwner( theControl ) ;
wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ; wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
@@ -569,7 +568,6 @@ Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ; HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ; OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ;
} }
#endif
return bounds ; return bounds ;
} }
@@ -603,45 +601,16 @@ CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data )
if ( data == NULL ) if ( data == NULL )
return NULL; return NULL;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if( &CGDataProviderCreateWithCFData != NULL )
{
return CGDataProviderCreateWithCFData( data ); 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;
}
CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data ) CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
{ {
if ( data == NULL ) if ( data == NULL )
return NULL; return NULL;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if( &CGDataConsumerCreateWithCFData != NULL )
{
return CGDataConsumerCreateWithCFData( data ); 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;
}
#endif // wxUSE_GUI #endif // wxUSE_GUI
#if wxUSE_BASE #if wxUSE_BASE

View File

@@ -43,21 +43,8 @@
#endif #endif
#if wxUSE_GUI #if wxUSE_GUI
#if TARGET_API_MAC_OSX
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#else
#include <DriverServices.h>
#include <Multiprocessing.h>
#endif
#ifdef __DARWIN__
#include <Carbon/Carbon.h> #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 #endif // wxUSE_GUI
@@ -203,12 +190,7 @@ bool wxCheckForInterrupt(wxWindow *WXUNUSED(wnd))
void wxGetMousePosition( int* x, int* y ) void wxGetMousePosition( int* x, int* y )
{ {
Point pt; Point pt;
#if wxMAC_USE_CORE_GRAPHICS
GetGlobalMouse(&pt); GetGlobalMouse(&pt);
#else
GetMouse( &pt );
LocalToGlobal( &pt );
#endif
*x = pt.h; *x = pt.h;
*y = pt.v; *y = pt.v;
}; };
@@ -222,10 +204,7 @@ bool wxColourDisplay()
// Returns depth of screen // Returns depth of screen
int wxDisplayDepth() int wxDisplayDepth()
{ {
int theDepth = 8; int theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
#if wxMAC_USE_CORE_GRAPHICS
theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
#else
Rect globRect; Rect globRect;
SetRect(&globRect, -32760, -32760, 32760, 32760); SetRect(&globRect, -32760, -32760, 32760, 32760);
GDHandle theMaxDevice; GDHandle theMaxDevice;
@@ -233,30 +212,19 @@ int wxDisplayDepth()
theMaxDevice = GetMaxDevice(&globRect); theMaxDevice = GetMaxDevice(&globRect);
if (theMaxDevice != NULL) if (theMaxDevice != NULL)
theDepth = (**(**theMaxDevice).gdPMap).pixelSize; theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
#endif
return theDepth; return theDepth;
} }
// Get size of display // Get size of display
void wxDisplaySize(int *width, int *height) void wxDisplaySize(int *width, int *height)
{ {
#if wxMAC_USE_CORE_GRAPHICS
// TODO adapt for multi-displays // TODO adapt for multi-displays
CGRect bounds = CGDisplayBounds(CGMainDisplayID()); CGRect bounds = CGDisplayBounds(CGMainDisplayID());
if ( width ) if ( width )
*width = (int)bounds.size.width ; *width = (int)bounds.size.width ;
if ( height ) if ( height )
*height = (int)bounds.size.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) 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 ) OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions )
{ {
#if TARGET_API_MAC_OSX
return SendEventToEventTargetWithOptions( event, return SendEventToEventTargetWithOptions( event,
HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions ); HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions );
#else
#pragma unused(inOptions)
return SendEventToEventTarget(event,GetControlEventTarget( m_controlRef ) );
#endif
} }
OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions ) OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions )
@@ -1623,9 +1586,7 @@ void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyTyp
columnDesc.propertyDesc.propertyType = colType; columnDesc.propertyDesc.propertyType = colType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn; columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
#endif
verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) ); verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
@@ -1981,24 +1942,7 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
if (genericRGBColorSpace == NULL) if (genericRGBColorSpace == NULL)
{ {
if ( UMAGetSystemVersion() >= 0x1040 ) genericRGBColorSpace.Set( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) );
{
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);
}
}
} }
return genericRGBColorSpace; return genericRGBColorSpace;
@@ -2020,7 +1964,6 @@ wxMacPortSaver::~wxMacPortSaver()
void wxMacGlobalToLocal( WindowRef window , Point*pt ) 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 ); HIPoint p = CGPointMake( pt->h, pt->v );
HIViewRef contentView ; HIViewRef contentView ;
// TODO check toolbar offset // TODO check toolbar offset
@@ -2028,14 +1971,10 @@ void wxMacGlobalToLocal( WindowRef window , Point*pt )
HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView ); HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView );
pt->h = p.x; pt->h = p.x;
pt->v = p.y; pt->v = p.y;
#else
QDGlobalToLocalPoint( GetWindowPort(window), pt ) ;
#endif
} }
void wxMacLocalToGlobal( WindowRef window , Point*pt ) 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 ); HIPoint p = CGPointMake( pt->h, pt->v );
HIViewRef contentView ; HIViewRef contentView ;
// TODO check toolbar offset // TODO check toolbar offset
@@ -2043,9 +1982,6 @@ void wxMacLocalToGlobal( WindowRef window , Point*pt )
HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL ); HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL );
pt->h = p.x; pt->h = p.x;
pt->v = p.y; pt->v = p.y;
#else
QDLocalToGlobalPoint( GetWindowPort(window), pt ) ;
#endif
} }
#endif // wxUSE_GUI #endif // wxUSE_GUI

View File

@@ -248,7 +248,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
#endif #endif
{ {
#if wxMAC_USE_CORE_GRAPHICS
bool created = false ; bool created = false ;
CGContextRef cgContext = NULL ; CGContextRef cgContext = NULL ;
OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ; OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
@@ -278,18 +277,14 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
CGContextClearRect( cgContext, bounds ); CGContextClearRect( cgContext, bounds );
} }
#endif
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
result = noErr ; result = noErr ;
#if wxMAC_USE_CORE_GRAPHICS
thisWindow->MacSetCGContextRef( NULL ) ; thisWindow->MacSetCGContextRef( NULL ) ;
} }
if ( created ) if ( created )
CGContextRelease( cgContext ) ; CGContextRelease( cgContext ) ;
#endif
} }
if ( allocatedRgn ) if ( allocatedRgn )
@@ -919,10 +914,7 @@ void wxWindowMac::Init()
m_peer = NULL ; m_peer = NULL ;
m_frozenness = 0 ; m_frozenness = 0 ;
m_macAlpha = 255 ; m_macAlpha = 255 ;
#if wxMAC_USE_CORE_GRAPHICS
m_cgContextRef = NULL ; m_cgContextRef = NULL ;
#endif
// as all windows are created with WS_VISIBLE style... // as all windows are created with WS_VISIBLE style...
m_isShown = true; m_isShown = true;
@@ -2435,7 +2427,6 @@ void wxWindowMac::MacPaintGrowBox()
if ( IsTopLevel() ) if ( IsTopLevel() )
return ; return ;
#if wxMAC_USE_CORE_GRAPHICS
if ( MacHasScrollBarCorner() ) if ( MacHasScrollBarCorner() )
{ {
Rect rect ; Rect rect ;
@@ -2462,7 +2453,6 @@ void wxWindowMac::MacPaintGrowBox()
CGContextFillRect( cgContext, cgrect ); CGContextFillRect( cgContext, cgrect );
CGContextRestoreGState( cgContext ); CGContextRestoreGState( cgContext );
} }
#endif
} }
void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(rightOrigin) ) 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 ) ; m_peer->GetRect( &rect ) ;
InsetRect( &rect, -1 , -1 ) ; InsetRect( &rect, -1 , -1 ) ;
#if wxMAC_USE_CORE_GRAPHICS
{ {
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left , CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
rect.bottom - rect.top ) ; rect.bottom - rect.top ) ;
@@ -2527,33 +2516,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
} }
#endif #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 ) void wxWindowMac::RemoveChild( wxWindowBase *child )
@@ -2736,9 +2698,7 @@ void wxWindowMac::OnSetFocus( wxFocusEvent& event )
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
{ {
#if wxMAC_USE_CORE_GRAPHICS
GetParent()->Refresh() ; GetParent()->Refresh() ;
#else
wxMacWindowStateSaver sv( this ) ; wxMacWindowStateSaver sv( this ) ;
Rect rect ; Rect rect ;
@@ -2766,7 +2726,6 @@ void wxWindowMac::OnSetFocus( wxFocusEvent& event )
// we have to invalidate things, we cannot simple redraw // we have to invalidate things, we cannot simple redraw
MacInvalidateBorders() ; MacInvalidateBorders() ;
} }
#endif
} }
event.Skip(); event.Skip();
@@ -3086,16 +3045,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
eventNc.SetEventObject( child ); eventNc.SetEventObject( child );
if ( !child->GetEventHandler()->ProcessEvent( eventNc ) ) if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
{ {
#if wxMAC_USE_CORE_GRAPHICS
child->MacPaintBorders(0, 0) ; 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) bool wxWindowMac::SetTransparent(wxByte alpha)
{ {
#if wxMAC_USE_CORE_GRAPHICS
SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
if ( alpha != m_macAlpha ) if ( alpha != m_macAlpha )
@@ -3494,19 +3443,12 @@ bool wxWindowMac::SetTransparent(wxByte alpha)
Refresh() ; Refresh() ;
} }
return true ; return true ;
#else
return false ;
#endif
} }
bool wxWindowMac::CanSetTransparent() bool wxWindowMac::CanSetTransparent()
{ {
#if wxMAC_USE_CORE_GRAPHICS
return true ; return true ;
#else
return false ;
#endif
} }
wxByte wxWindowMac::GetTransparent() const wxByte wxWindowMac::GetTransparent() const