Mac Core Graphics Implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -65,12 +65,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
}
|
||||
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
wxBitmapRefData * bmap = NULL ;
|
||||
|
||||
if ( m_bmpNormal.Ok() )
|
||||
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
||||
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
|
||||
@@ -80,7 +75,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevel : kControlBevelButtonNormalBevel ) ,
|
||||
kControlBehaviorOffsetContents , &info , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
|
||||
|
||||
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
wxASSERT_MSG( m_peer != NULL && m_peer->Ok() , wxT("No valid mac control") ) ;
|
||||
|
||||
MacPostControlCreate(pos,size) ;
|
||||
@@ -99,6 +94,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_peer->SetData( kControlButtonPart , kControlBevelButtonContentTag , info ) ;
|
||||
}
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -27,6 +27,27 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
||||
{
|
||||
DECLARE_NO_COPY_CLASS(wxCursorRefData)
|
||||
|
||||
friend class WXDLLEXPORT wxBitmap;
|
||||
friend class WXDLLEXPORT wxCursor;
|
||||
public:
|
||||
wxCursorRefData();
|
||||
~wxCursorRefData();
|
||||
|
||||
protected:
|
||||
WXHCURSOR m_hCursor;
|
||||
bool m_disposeHandle;
|
||||
bool m_releaseHandle;
|
||||
bool m_isColorCursor ;
|
||||
long m_themeCursor ;
|
||||
};
|
||||
|
||||
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
||||
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
|
||||
|
||||
const short kwxCursorBullseye = 0 ;
|
||||
const short kwxCursorBlank = 1 ;
|
||||
const short kwxCursorPencil = 2 ;
|
||||
@@ -181,8 +202,8 @@ CursHandle wxGetStockCursor( int number )
|
||||
|
||||
wxCursorRefData::wxCursorRefData()
|
||||
{
|
||||
m_width = 16;
|
||||
m_height = 16;
|
||||
SetWidth( 16 );
|
||||
SetHeight( 16 );
|
||||
m_hCursor = NULL ;
|
||||
m_disposeHandle = false ;
|
||||
m_releaseHandle = false ;
|
||||
@@ -242,6 +263,16 @@ bool wxCursor::CreateFromXpm(const char **bits)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WXHCURSOR wxCursor::GetHCURSOR() const
|
||||
{
|
||||
return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0);
|
||||
}
|
||||
|
||||
bool wxCursor::Ok() const
|
||||
{
|
||||
return (m_refData != NULL && ( M_CURSORDATA->m_hCursor != NULL || M_CURSORDATA->m_themeCursor != -1 ) ) ;
|
||||
}
|
||||
|
||||
short GetCTabIndex( CTabHandle colors , RGBColor *col )
|
||||
{
|
||||
short retval = 0 ;
|
||||
|
@@ -250,7 +250,9 @@ wxBitmapDataObject::wxBitmapDataObject(
|
||||
Init();
|
||||
if ( m_bitmap.Ok() )
|
||||
{
|
||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
||||
/*
|
||||
m_pictHandle = m_bitmap.GetBitmapData()->GetPict( &m_pictCreated ) ;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +269,9 @@ void wxBitmapDataObject::SetBitmap(
|
||||
wxBitmapDataObjectBase::SetBitmap(rBitmap);
|
||||
if ( m_bitmap.Ok() )
|
||||
{
|
||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
||||
/*
|
||||
m_pictHandle = m_bitmap.GetBitmapData()->GetPict( &m_pictCreated ) ;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,11 +317,13 @@ bool wxBitmapDataObject::SetData(
|
||||
PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
|
||||
memcpy( *picHandle , pBuf , nSize ) ;
|
||||
m_pictHandle = picHandle ;
|
||||
// ownership is transferred to the bitmap
|
||||
m_pictCreated = false ;
|
||||
Rect frame = (**picHandle).picFrame ;
|
||||
|
||||
m_bitmap.SetPict( picHandle ) ;
|
||||
/*
|
||||
m_bitmap.GetBitmapData()->SetPict( (WXHMETAFILE) picHandle ) ;
|
||||
m_bitmap.SetWidth( frame.right - frame.left ) ;
|
||||
m_bitmap.SetHeight( frame.bottom - frame.top ) ;
|
||||
*/
|
||||
return m_bitmap.Ok();
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/dc.h"
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
#include "wx/app.h"
|
||||
#include "wx/mac/uma.h"
|
||||
#include "wx/dcmemory.h"
|
||||
@@ -285,11 +287,6 @@ wxDC::~wxDC(void)
|
||||
DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
}
|
||||
|
||||
void wxDC::MacSetupGraphicContext()
|
||||
{
|
||||
// no-op for QuickDraw
|
||||
}
|
||||
|
||||
void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
@@ -360,62 +357,51 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
||||
//m_logicalFunction == wxSRC_OR ? srcOr :
|
||||
//m_logicalFunction == wxSRC_AND ? SRCAND :
|
||||
srcCopy );
|
||||
if ( bmp.GetBitmapType() == kMacBitmapTypePict ) {
|
||||
Rect bitmaprect = { 0 , 0 , hh, ww };
|
||||
::OffsetRect( &bitmaprect, xx, yy ) ;
|
||||
::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ;
|
||||
}
|
||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() );
|
||||
PixMapHandle bmappixels ;
|
||||
// Set foreground and background colours (for bitmaps depth = 1)
|
||||
if(bmp.GetDepth() == 1)
|
||||
{
|
||||
RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
|
||||
RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
|
||||
RGBForeColor(&fore);
|
||||
RGBBackColor(&back);
|
||||
}
|
||||
else
|
||||
{
|
||||
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
||||
RGBColor black = { 0,0,0} ;
|
||||
RGBForeColor( &black ) ;
|
||||
RGBBackColor( &white ) ;
|
||||
}
|
||||
bmappixels = GetGWorldPixMap( bmapworld ) ;
|
||||
wxCHECK_RET(LockPixels(bmappixels),
|
||||
wxT("DoDrawBitmap: Unable to lock pixels"));
|
||||
Rect source = { 0, 0, h, w };
|
||||
Rect dest = { yy, xx, yy + hh, xx + ww };
|
||||
if ( useMask && bmp.GetMask() )
|
||||
{
|
||||
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))))
|
||||
{
|
||||
CopyDeepMask
|
||||
(
|
||||
GetPortBitMapForCopyBits(bmapworld),
|
||||
GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())),
|
||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||
&source, &source, &dest, mode, NULL
|
||||
);
|
||||
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())));
|
||||
}
|
||||
}
|
||||
else {
|
||||
CopyBits( GetPortBitMapForCopyBits( bmapworld ),
|
||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||
&source, &dest, mode, NULL ) ;
|
||||
}
|
||||
UnlockPixels( bmappixels ) ;
|
||||
|
||||
GWorldPtr maskworld = NULL ;
|
||||
GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP((WXHBITMAP*)&maskworld) );
|
||||
PixMapHandle bmappixels ;
|
||||
// Set foreground and background colours (for bitmaps depth = 1)
|
||||
if(bmp.GetDepth() == 1)
|
||||
{
|
||||
RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
|
||||
RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
|
||||
RGBForeColor(&fore);
|
||||
RGBBackColor(&back);
|
||||
}
|
||||
else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon )
|
||||
else
|
||||
{
|
||||
Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ;
|
||||
OffsetRect( &bitmaprect, xx, yy ) ;
|
||||
PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ;
|
||||
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
|
||||
RGBColor black = { 0,0,0} ;
|
||||
RGBForeColor( &black ) ;
|
||||
RGBBackColor( &white ) ;
|
||||
}
|
||||
bmappixels = GetGWorldPixMap( bmapworld ) ;
|
||||
wxCHECK_RET(LockPixels(bmappixels),
|
||||
wxT("DoDrawBitmap: Unable to lock pixels"));
|
||||
Rect source = { 0, 0, h, w };
|
||||
Rect dest = { yy, xx, yy + hh, xx + ww };
|
||||
if ( useMask && maskworld )
|
||||
{
|
||||
if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld))))
|
||||
{
|
||||
CopyDeepMask
|
||||
(
|
||||
GetPortBitMapForCopyBits(bmapworld),
|
||||
GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld)),
|
||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||
&source, &source, &dest, mode, NULL
|
||||
);
|
||||
UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
CopyBits( GetPortBitMapForCopyBits( bmapworld ),
|
||||
GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
|
||||
&source, &dest, mode, NULL ) ;
|
||||
}
|
||||
UnlockPixels( bmappixels ) ;
|
||||
|
||||
m_macPenInstalled = false ;
|
||||
m_macBrushInstalled = false ;
|
||||
m_macFontInstalled = false ;
|
||||
@@ -425,7 +411,13 @@ void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
{
|
||||
wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
|
||||
wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
|
||||
DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ;
|
||||
wxMacFastPortSetter helper(this) ;
|
||||
|
||||
wxCoord xx = XLOG2DEVMAC(x);
|
||||
wxCoord yy = YLOG2DEVMAC(y);
|
||||
|
||||
Rect r = { yy , xx, yy + 32 , xx + 32 } ;
|
||||
PlotIconRef( &r , kAlignNone , kTransformNone , kPlotIconRefNormalFlags , MAC_WXHICON( icon.GetHICON() ) ) ;
|
||||
}
|
||||
|
||||
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
|
||||
@@ -1942,9 +1934,9 @@ void wxDC::MacInstallBrush() const
|
||||
int height = bitmap->GetHeight() ;
|
||||
GWorldPtr gw = NULL ;
|
||||
if ( m_brush.GetStyle() == wxSTIPPLE )
|
||||
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ;
|
||||
gw = MAC_WXHBITMAP(bitmap->GetHBITMAP(NULL)) ;
|
||||
else
|
||||
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ;
|
||||
gw = MAC_WXHBITMAP(bitmap->GetMask()->GetHBITMAP()) ;
|
||||
PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
|
||||
LockPixels( gwpixmaphandle ) ;
|
||||
bool isMonochrome = !IsPortColor( gw ) ;
|
||||
@@ -2098,3 +2090,5 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
|
||||
{
|
||||
return ((wxDC *)this)->YLOG2DEVREL(y);
|
||||
}
|
||||
|
||||
#endif // !wxMAC_USE_CORE_GRAPHICS
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -109,9 +109,20 @@ wxWindowDC::wxWindowDC()
|
||||
wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
#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 ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
}
|
||||
else
|
||||
m_graphicContext = NULL ;
|
||||
// there is no out-of-order drawing on OSX
|
||||
#else
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
|
||||
int x , y ;
|
||||
x = y = 0 ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
@@ -121,9 +132,10 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
#endif
|
||||
m_ok = TRUE ;
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
@@ -149,6 +161,41 @@ wxClientDC::wxClientDC()
|
||||
wxClientDC::wxClientDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_graphicContext = NULL ;
|
||||
if ( window->MacGetCGContextRef() )
|
||||
{
|
||||
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||
m_graphicContext->SetPen( m_pen ) ;
|
||||
m_graphicContext->SetBrush( m_brush ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
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_macLocalOrigin.x = x ;
|
||||
m_macLocalOrigin.y = y ;
|
||||
CGrafPtr port = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_graphicContext = new wxMacCGContext( port ) ;
|
||||
m_graphicContext->SetPen( m_pen ) ;
|
||||
m_graphicContext->SetBrush( m_brush ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
m_ok = TRUE ;
|
||||
*/
|
||||
}
|
||||
m_ok = TRUE ;
|
||||
#else
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
if (!rootwindow)
|
||||
return;
|
||||
@@ -167,9 +214,8 @@ wxClientDC::wxClientDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
#endif
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
@@ -198,6 +244,23 @@ wxPaintDC::wxPaintDC()
|
||||
wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
#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 ) ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
m_ok = TRUE ;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug(wxT("You cannot create a wxPaintDC outside an OS-draw event") ) ;
|
||||
m_graphicContext = NULL ;
|
||||
m_ok = TRUE ;
|
||||
}
|
||||
// there is no out-of-order drawing on OSX
|
||||
#else
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
@@ -215,10 +278,9 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
MacSetupGraphicContext() ;
|
||||
SetBackground(MacGetBackgroundBrush(window));
|
||||
m_ok = TRUE ;
|
||||
#endif
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ wxMemoryDC::wxMemoryDC(void)
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
SetFont(*wxNORMAL_FONT) ;
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
@@ -41,6 +42,7 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
SetFont(*wxNORMAL_FONT) ;
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
@@ -48,7 +50,15 @@ wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_selected.EndRawAccess() ;
|
||||
CGContextRef bmCtx = dynamic_cast<wxMacCGContext*>(m_graphicContext)->GetNativeContext() ;
|
||||
delete m_graphicContext ;
|
||||
m_graphicContext = NULL ;
|
||||
CGContextRelease( bmCtx ) ;
|
||||
#else
|
||||
// TODO UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,20 +66,55 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_selected.EndRawAccess() ;
|
||||
CGContextRef bmCtx = dynamic_cast<wxMacCGContext*>(m_graphicContext)->GetNativeContext() ;
|
||||
delete m_graphicContext ;
|
||||
m_graphicContext = NULL ;
|
||||
CGContextRelease( bmCtx ) ;
|
||||
#else
|
||||
// TODO UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
#endif
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
if ( m_selected.GetHBITMAP() )
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_selected.UseAlpha() ;
|
||||
void * data = m_selected.BeginRawAccess() ;
|
||||
|
||||
int bitsPerComp = 8 ;
|
||||
int bytesPerPixel = 4 ;
|
||||
int w = bitmap.GetWidth() ;
|
||||
int h = bitmap.GetHeight() ;
|
||||
CGImageAlphaInfo a = kCGImageAlphaNoneSkipFirst ;
|
||||
CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace();
|
||||
CGContextRef bmCtx = CGBitmapContextCreate(data , w, h, bitsPerComp , bytesPerPixel * w , genericColorSpace, a);
|
||||
wxASSERT_MSG( bmCtx , wxT("Unable to create bitmap context") ) ;
|
||||
|
||||
CGContextSetFillColorSpace(bmCtx, genericColorSpace);
|
||||
CGContextSetStrokeColorSpace(bmCtx, genericColorSpace);
|
||||
|
||||
if( bmCtx )
|
||||
{
|
||||
CGContextTranslateCTM( bmCtx , 0 , m_selected.GetHeight() ) ;
|
||||
CGContextScaleCTM( bmCtx , 1 , -1 ) ;
|
||||
m_graphicContext = new wxMacCGContext( bmCtx ) ;
|
||||
m_graphicContext->SetPen( m_pen ) ;
|
||||
m_graphicContext->SetBrush( m_brush ) ;
|
||||
}
|
||||
m_ok = (m_graphicContext != NULL) ;
|
||||
#else
|
||||
if ( ( m_macPort = m_selected.GetHBITMAP( &m_macMask ) ) != NULL )
|
||||
{
|
||||
m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
/*
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
{
|
||||
m_macMask = mask->GetMaskBitmap() ;
|
||||
m_macMask = mask->GetHBITMAP() ;
|
||||
}
|
||||
*/
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_ok = TRUE ;
|
||||
@@ -78,6 +123,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
m_ok = FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -106,6 +106,15 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
#if 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
|
||||
|
||||
m_err = PMSessionBeginDocument(native->m_macPrintSession,
|
||||
native->m_macPrintSettings,
|
||||
native->m_macPageFormat);
|
||||
@@ -143,11 +152,21 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
native->m_macPageFormat,
|
||||
nil);
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef pageContext;
|
||||
#endif
|
||||
if ( m_err == noErr )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||
nil,
|
||||
kPMGraphicsContextCoreGraphics,
|
||||
(void**) &pageContext );
|
||||
dc->MacSetCGContext(pageContext) ;
|
||||
#else
|
||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||
kPMGraphicsContextQuickdraw,
|
||||
(void**) &dc->m_macPort );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_err != noErr )
|
||||
@@ -162,8 +181,13 @@ void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
if ( !m_err )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextTranslateCTM( pageContext , 0 , rPage.bottom - rPage.top ) ;
|
||||
CGContextScaleCTM( pageContext , 1 , -1 ) ;
|
||||
#else
|
||||
dc->m_macLocalOrigin.x = (int) rPage.left;
|
||||
dc->m_macLocalOrigin.y = (int) rPage.top;
|
||||
#endif
|
||||
}
|
||||
// since this is a non-critical error, we set the flag back
|
||||
m_err = noErr ;
|
||||
@@ -313,7 +337,6 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
if ( m_nativePrinterDC )
|
||||
{
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
||||
if ( !m_ok )
|
||||
{
|
||||
wxString message ;
|
||||
@@ -321,6 +344,10 @@ wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||
dialog.ShowModal();
|
||||
}
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
// the cgContext will only be handed over page by page
|
||||
m_graphicContext = new wxMacCGContext() ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +356,14 @@ wxPrinterDC::~wxPrinterDC(void)
|
||||
delete m_nativePrinterDC ;
|
||||
}
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
void wxPrinterDC::MacSetCGContext( void * cg )
|
||||
{
|
||||
dynamic_cast<wxMacCGContext*>(m_graphicContext)->SetNativeContext( (CGContextRef) cg ) ;
|
||||
m_graphicContext->SetPen( m_pen ) ;
|
||||
m_graphicContext->SetBrush( m_brush ) ;
|
||||
}
|
||||
#endif
|
||||
bool wxPrinterDC::StartDoc( const wxString& message )
|
||||
{
|
||||
wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
|
||||
@@ -384,10 +419,11 @@ void wxPrinterDC::StartPage(void)
|
||||
m_font = *wxNORMAL_FONT;
|
||||
m_brush = *wxTRANSPARENT_BRUSH;
|
||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||
|
||||
#if !wxMAC_USE_CORE_GRAPHICS
|
||||
m_macFontInstalled = false ;
|
||||
m_macBrushInstalled = false ;
|
||||
m_macPenInstalled = false ;
|
||||
#endif
|
||||
|
||||
m_nativePrinterDC->StartPage(this) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
@@ -25,7 +25,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
m_macPort = CreateNewPort() ;
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
@@ -35,31 +36,29 @@ wxScreenDC::wxScreenDC()
|
||||
SetPort( port ) ;
|
||||
m_macLocalOrigin.x = -pt.h ;
|
||||
m_macLocalOrigin.y = -pt.v ;
|
||||
#else
|
||||
m_macPort = LMGetWMgrPort() ;
|
||||
m_macLocalOrigin.x = 0 ;
|
||||
m_macLocalOrigin.y = 0 ;
|
||||
#endif
|
||||
|
||||
m_ok = TRUE ;
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
m_minX = screenBits.bounds.left ;
|
||||
#if TARGET_CARBON
|
||||
|
||||
SInt16 height ;
|
||||
GetThemeMenuBarHeight( &height ) ;
|
||||
m_minY = screenBits.bounds.top + height ;
|
||||
#else
|
||||
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
|
||||
#endif
|
||||
|
||||
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_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxScreenDC::~wxScreenDC()
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
DisposePort( (CGrafPtr) m_macPort ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,176 @@
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXMAC_OSX__
|
||||
|
||||
class wxDisplayMacPriv
|
||||
{
|
||||
public:
|
||||
CGDirectDisplayID m_id;
|
||||
};
|
||||
|
||||
size_t wxDisplayBase::GetCount()
|
||||
{
|
||||
CGDisplayCount count;
|
||||
#ifdef __WXDEBUG__
|
||||
CGDisplayErr err =
|
||||
#endif
|
||||
CGGetActiveDisplayList(0, NULL, &count);
|
||||
|
||||
wxASSERT(err == CGDisplayNoErr);
|
||||
return count;
|
||||
}
|
||||
|
||||
int wxDisplayBase::GetFromPoint(const wxPoint &p)
|
||||
{
|
||||
CGPoint thePoint = {(float)p.x, (float)p.y};
|
||||
CGDirectDisplayID theID;
|
||||
CGDisplayCount theCount;
|
||||
CGDisplayErr err = CGGetDisplaysWithPoint(thePoint, 1, &theID, &theCount);
|
||||
wxASSERT(err == CGDisplayNoErr);
|
||||
int nWhich = -1;
|
||||
|
||||
if (theCount)
|
||||
{
|
||||
theCount = GetCount();
|
||||
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
||||
err = CGGetActiveDisplayList(theCount, theIDs, &theCount);
|
||||
wxASSERT(err == CGDisplayNoErr);
|
||||
|
||||
for(nWhich = 0; nWhich < (int) theCount; ++nWhich)
|
||||
{
|
||||
if(theIDs[nWhich] == theID)
|
||||
break;
|
||||
}
|
||||
|
||||
delete[] theIDs;
|
||||
|
||||
if(nWhich == (int) theCount)
|
||||
{
|
||||
wxFAIL_MSG(wxT("Failed to find display in display list"));
|
||||
nWhich = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return nWhich;
|
||||
}//CFUserNotification[NSBundle bundleForClass:[self class]]
|
||||
|
||||
wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ) ,
|
||||
m_priv ( new wxDisplayMacPriv() )
|
||||
{
|
||||
CGDisplayCount theCount = GetCount();
|
||||
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
||||
#ifdef __WXDEBUG__
|
||||
CGDisplayErr err =
|
||||
#endif
|
||||
CGGetActiveDisplayList(theCount, theIDs, &theCount);
|
||||
|
||||
wxASSERT(err == CGDisplayNoErr);
|
||||
wxASSERT(index < theCount);
|
||||
|
||||
m_priv->m_id = theIDs[index];
|
||||
|
||||
delete[] theIDs;
|
||||
}
|
||||
|
||||
wxRect wxDisplay::GetGeometry() const
|
||||
{
|
||||
CGRect theRect = CGDisplayBounds(m_priv->m_id);
|
||||
return wxRect( (int)theRect.origin.x,
|
||||
(int)theRect.origin.y,
|
||||
(int)theRect.size.width,
|
||||
(int)theRect.size.height ); //floats
|
||||
}
|
||||
|
||||
int wxDisplay::GetDepth() const
|
||||
{
|
||||
return (int) CGDisplayBitsPerPixel(m_priv->m_id); //size_t
|
||||
}
|
||||
|
||||
wxString wxDisplay::GetName() const
|
||||
{
|
||||
// Macs don't name their displays...
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
static int wxCFDictKeyToInt( CFDictionaryRef desc, CFStringRef key )
|
||||
{
|
||||
CFNumberRef value;
|
||||
int num = 0;
|
||||
|
||||
if ( (value = (CFNumberRef) CFDictionaryGetValue(desc, key)) == NULL )
|
||||
return 0;
|
||||
CFNumberGetValue(value, kCFNumberIntType, &num);
|
||||
return num;
|
||||
}
|
||||
|
||||
wxArrayVideoModes
|
||||
wxDisplay::GetModes(const wxVideoMode& mode) const
|
||||
{
|
||||
wxArrayVideoModes Modes;
|
||||
|
||||
CFArrayRef theArray = CGDisplayAvailableModes(m_priv->m_id);
|
||||
|
||||
for(CFIndex i = 0; i < CFArrayGetCount(theArray); ++i)
|
||||
{
|
||||
CFDictionaryRef theValue = (CFDictionaryRef) CFArrayGetValueAtIndex(theArray, i);
|
||||
|
||||
wxVideoMode theMode(wxCFDictKeyToInt(theValue, kCGDisplayWidth),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayHeight),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayBitsPerPixel),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayRefreshRate));
|
||||
|
||||
if (theMode.Matches(mode))
|
||||
Modes.Add(theMode);
|
||||
}
|
||||
|
||||
return Modes;
|
||||
}
|
||||
|
||||
wxVideoMode wxDisplay::GetCurrentMode() const
|
||||
{
|
||||
CFDictionaryRef theValue = CGDisplayCurrentMode (m_priv->m_id);
|
||||
|
||||
return wxVideoMode(wxCFDictKeyToInt(theValue, kCGDisplayWidth),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayHeight),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayBitsPerPixel),
|
||||
wxCFDictKeyToInt(theValue, kCGDisplayRefreshRate));
|
||||
}
|
||||
|
||||
bool wxDisplay::ChangeMode(const wxVideoMode& mode)
|
||||
{
|
||||
//Changing to default mode (wxDefualtVideoMode) doesn't
|
||||
//work because we don't have access to the system's 'scrn'
|
||||
//resource which holds the user's mode which the system
|
||||
//will return to after this app is done
|
||||
boolean_t bExactMatch;
|
||||
CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate (
|
||||
m_priv->m_id,
|
||||
(size_t)mode.bpp,
|
||||
(size_t)mode.w,
|
||||
(size_t)mode.h,
|
||||
(double)mode.refresh,
|
||||
&bExactMatch);
|
||||
|
||||
bool bOK = bExactMatch;
|
||||
|
||||
if(bOK)
|
||||
bOK = CGDisplaySwitchToMode(m_priv->m_id, theCGMode) == CGDisplayNoErr;
|
||||
|
||||
return bOK;
|
||||
}
|
||||
|
||||
wxDisplay::~wxDisplay()
|
||||
{
|
||||
if ( m_priv )
|
||||
{
|
||||
delete m_priv;
|
||||
m_priv = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
class wxDisplayMacPriv
|
||||
{
|
||||
public:
|
||||
@@ -460,4 +630,6 @@ wxDisplay::~wxDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !OSX
|
||||
|
||||
#endif // wxUSE_DISPLAY
|
||||
|
@@ -33,20 +33,22 @@ wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
||||
wxBitmap(bits, width, height)
|
||||
wxIcon::wxIcon(const char bits[], int width, int height)
|
||||
{
|
||||
|
||||
wxBitmap bmp(bits,width,height) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits ) :
|
||||
wxBitmap(bits)
|
||||
wxIcon::wxIcon( const char **bits )
|
||||
{
|
||||
wxBitmap bmp(bits) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( char **bits ) :
|
||||
wxBitmap(bits)
|
||||
wxIcon::wxIcon( char **bits )
|
||||
{
|
||||
wxBitmap bmp(bits) ;
|
||||
CopyFromBitmap( bmp ) ;
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
||||
@@ -59,42 +61,135 @@ wxIcon::~wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
WXHICON wxIcon::GetHICON() const
|
||||
{
|
||||
wxASSERT( Ok() ) ;
|
||||
return (WXHICON) ((wxIconRefData*)m_refData)->GetHICON() ;
|
||||
}
|
||||
|
||||
int wxIcon::GetWidth() const
|
||||
{
|
||||
return 32 ;
|
||||
}
|
||||
|
||||
int wxIcon::GetHeight() const
|
||||
{
|
||||
return 32 ;
|
||||
}
|
||||
|
||||
bool wxIcon::Ok() const
|
||||
{
|
||||
return m_refData != NULL ;
|
||||
}
|
||||
|
||||
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
|
||||
{
|
||||
m_refData = new wxBitmapRefData;
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight );
|
||||
OSType theId = 0 ;
|
||||
if ( filename == wxT("wxICON_INFORMATION") )
|
||||
{
|
||||
theId = kAlertNoteIcon ;
|
||||
}
|
||||
else if ( filename == wxT("wxICON_QUESTION") )
|
||||
{
|
||||
theId = kAlertCautionIcon ;
|
||||
}
|
||||
else if ( filename == wxT("wxICON_WARNING") )
|
||||
{
|
||||
theId = kAlertCautionIcon ;
|
||||
}
|
||||
else if ( filename == wxT("wxICON_ERROR") )
|
||||
{
|
||||
theId = kAlertStopIcon ;
|
||||
}
|
||||
else
|
||||
{/*
|
||||
Str255 theName ;
|
||||
OSType theType ;
|
||||
wxMacStringToPascal( name , theName ) ;
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
}
|
||||
*/
|
||||
}
|
||||
if ( theId != 0 )
|
||||
{
|
||||
IconRef iconRef = NULL ;
|
||||
verify_noerr(GetIconRef(kOnSystemDisk,kSystemIconsCreator,theId, &iconRef)) ;
|
||||
if ( iconRef )
|
||||
{
|
||||
m_refData = new wxIconRefData( (WXHICON) iconRef ) ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxImage loadimage(filename, type);
|
||||
if (loadimage.Ok())
|
||||
wxBitmapHandler *handler = wxBitmap::FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
{
|
||||
if ( desiredWidth == -1 )
|
||||
desiredWidth = loadimage.GetWidth() ;
|
||||
if ( desiredHeight == -1 )
|
||||
desiredHeight = loadimage.GetHeight() ;
|
||||
if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
|
||||
loadimage.Rescale( desiredWidth , desiredHeight ) ;
|
||||
wxBitmap bmp( loadimage );
|
||||
wxIcon *icon = (wxIcon*)(&bmp);
|
||||
*this = *icon;
|
||||
return true;
|
||||
wxBitmap bmp ;
|
||||
if ( handler->LoadFile(&bmp , filename, type, desiredWidth, desiredHeight ))
|
||||
{
|
||||
CopyFromBitmap( bmp ) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxImage loadimage(filename, type);
|
||||
if (loadimage.Ok())
|
||||
{
|
||||
if ( desiredWidth == -1 )
|
||||
desiredWidth = loadimage.GetWidth() ;
|
||||
if ( desiredHeight == -1 )
|
||||
desiredHeight = loadimage.GetHeight() ;
|
||||
if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
|
||||
loadimage.Rescale( desiredWidth , desiredHeight ) ;
|
||||
wxBitmap bmp( loadimage );
|
||||
CopyFromBitmap( bmp ) ;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||
{
|
||||
wxIcon *icon = (wxIcon*)(&bmp);
|
||||
*this = *icon;
|
||||
UnRef() ;
|
||||
|
||||
m_refData = new wxIconRefData( (WXHICON) wxMacCreateIconRef( bmp ) ) ;
|
||||
}
|
||||
|
||||
wxIconRefData::wxIconRefData( WXHICON icon )
|
||||
{
|
||||
m_iconRef = MAC_WXHICON( icon ) ;
|
||||
}
|
||||
|
||||
void wxIconRefData::Init()
|
||||
{
|
||||
m_iconRef = NULL ;
|
||||
}
|
||||
|
||||
void wxIconRefData::Free()
|
||||
{
|
||||
if ( m_iconRef )
|
||||
{
|
||||
ReleaseIconRef( m_iconRef ) ;
|
||||
m_iconRef = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
@@ -102,51 +197,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
short theId = -1 ;
|
||||
if ( name == wxT("wxICON_INFORMATION") )
|
||||
{
|
||||
theId = kNoteIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_QUESTION") )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_WARNING") )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_ERROR") )
|
||||
{
|
||||
theId = kStopIcon ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Str255 theName ;
|
||||
OSType theType ;
|
||||
wxMacStringToPascal( name , theName ) ;
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
}
|
||||
}
|
||||
if ( theId != -1 )
|
||||
{
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
{
|
||||
M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_BITMAPHANDLERDATA->m_width = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_height = 32 ;
|
||||
|
||||
M_BITMAPHANDLERDATA->m_depth = 8 ;
|
||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||
M_BITMAPHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
wxIcon icon ;
|
||||
icon.LoadFile( name , wxBITMAP_TYPE_ICON_RESOURCE , desiredWidth , desiredHeight ) ;
|
||||
bitmap->CopyFromIcon( icon ) ;
|
||||
return bitmap->Ok() ;
|
||||
}
|
||||
|
@@ -609,7 +609,6 @@ int wxListBox::GetCount() const
|
||||
void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
|
||||
{
|
||||
wxControl::Refresh( eraseBack , rect ) ;
|
||||
// MacRedrawControl() ;
|
||||
}
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
|
@@ -118,7 +118,11 @@ public:
|
||||
void FinishLoad();
|
||||
|
||||
wxSize m_bestSize; //Original movie size
|
||||
#ifdef __WXMAC_OSX__
|
||||
struct MovieType** m_movie; //QT Movie handle/instance
|
||||
#else
|
||||
Movie m_movie ;
|
||||
#endif
|
||||
wxControl* m_ctrl; //Parent control
|
||||
bool m_bVideo; //Whether or not we have video
|
||||
class _wxQTTimer* m_timer; //Timer for streaming the movie
|
||||
|
@@ -94,6 +94,7 @@ void wxMenuItem::UpdateItemBitmap()
|
||||
SetMenuItemIconHandle( mhandle , index ,
|
||||
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||
}
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -121,9 +121,12 @@ bool wxMetaFile::Play(wxDC *dc)
|
||||
return FALSE;
|
||||
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxMacPortSetter helper( dc ) ;
|
||||
PicHandle pict = (PicHandle) GetHMETAFILE() ;
|
||||
DrawPicture( pict , &(**pict).picFrame ) ;
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -158,15 +161,17 @@ wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
|
||||
wxASSERT_MSG( filename.IsEmpty() , _T("no file based metafile support yet")) ;
|
||||
|
||||
m_metaFile = new wxMetaFile(filename) ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
Rect r={0,0,height,width} ;
|
||||
|
||||
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
|
||||
m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
|
||||
m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
|
||||
::GetPort( (GrafPtr*) &m_macPort ) ;
|
||||
m_ok = TRUE ;
|
||||
|
||||
#endif
|
||||
SetMapMode(wxMM_TEXT);
|
||||
}
|
||||
|
||||
@@ -207,7 +212,7 @@ bool wxMetafileDataObject::SetData(size_t len, const void *buf)
|
||||
Handle handle = NewHandle( len ) ;
|
||||
SetHandleSize( handle , len ) ;
|
||||
memcpy( *handle , buf , len ) ;
|
||||
m_metafile.SetHMETAFILE( handle ) ;
|
||||
m_metafile.SetHMETAFILE( (WXHMETAFILE) handle ) ;
|
||||
return true ;
|
||||
}
|
||||
#endif
|
||||
|
@@ -346,46 +346,21 @@ void wxNotebook::MacSetupTabs()
|
||||
wxMacStringToPascal( page->GetLabel() , info.name ) ;
|
||||
m_peer->SetData<ControlTabInfoRec>( ii+1, kControlTabInfoTag, &info ) ;
|
||||
m_peer->SetTabEnabled( ii + 1 , true ) ;
|
||||
#if TARGET_CARBON
|
||||
|
||||
if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
|
||||
{
|
||||
// tab controls only support very specific types of images, therefore we are doing an odyssee
|
||||
// accross the icon worlds (even Apple DTS did not find a shorter path)
|
||||
// in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately
|
||||
// afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we
|
||||
// unregister it) in case this will ever lead to having the same icon everywhere add some kind
|
||||
// of static counter
|
||||
const wxBitmap* bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ;
|
||||
if ( bmap )
|
||||
{
|
||||
wxBitmap scaledBitmap ;
|
||||
if ( bmap->GetWidth() != 16 || bmap->GetHeight() != 16 )
|
||||
{
|
||||
scaledBitmap = wxBitmap( bmap->ConvertToImage().Scale(16,16) ) ;
|
||||
bmap = &scaledBitmap ;
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , *bmap , kControlContentPictHandle) ;
|
||||
IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
|
||||
OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
|
||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
||||
IconRef iconRef ;
|
||||
err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1, iconFamily, &iconRef ) ;
|
||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
||||
info.contentType = kControlContentIconRef ;
|
||||
info.u.iconRef = iconRef ;
|
||||
m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info );
|
||||
|
||||
wxMacCreateBitmapButton( &info , *bmap ) ;
|
||||
OSStatus err = m_peer->SetData<ControlButtonContentInfo>( ii+1,kControlTabImageContentTag, &info );
|
||||
wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
|
||||
if ( UMAGetSystemVersion() < 0x1030 )
|
||||
{
|
||||
UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
|
||||
}
|
||||
|
||||
ReleaseIconRef( iconRef ) ;
|
||||
DisposeHandle( (Handle) iconFamily ) ;
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
Rect bounds;
|
||||
m_peer->GetRectInWindowCoords( &bounds ) ;
|
||||
|
@@ -21,7 +21,7 @@
|
||||
# pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_LIBPNG
|
||||
#if 0 // wxUSE_LIBPNG
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@@ -75,21 +75,22 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
void wxRadioButton::SetValue(bool val)
|
||||
{
|
||||
wxRadioButton *cycle;
|
||||
if ( m_peer->GetValue() == val )
|
||||
if ( m_peer->GetValue() == val )
|
||||
return ;
|
||||
|
||||
m_peer->SetValue( val ) ;
|
||||
if (val)
|
||||
{
|
||||
cycle=this->NextInCycle();
|
||||
if (cycle!=NULL) {
|
||||
while (cycle!=this) {
|
||||
cycle->SetValue(false);
|
||||
cycle=cycle->NextInCycle();
|
||||
}
|
||||
}
|
||||
m_peer->SetValue( val ) ;
|
||||
if (val)
|
||||
{
|
||||
cycle=this->NextInCycle();
|
||||
if (cycle!=NULL)
|
||||
{
|
||||
while (cycle!=this)
|
||||
{
|
||||
cycle->SetValue(false);
|
||||
cycle=cycle->NextInCycle();
|
||||
}
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool wxRadioButton::GetValue() const
|
||||
|
@@ -399,6 +399,40 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
|
||||
/*!
|
||||
* Reset iterator for a new /e region.
|
||||
*/
|
||||
|
||||
OSStatus wxMacRegionToRectsCounterCallback (
|
||||
UInt16 message, RgnHandle region, const Rect *rect, void *data)
|
||||
{
|
||||
long *m_numRects = (long*) data ;
|
||||
if ( message == kQDRegionToRectsMsgInit )
|
||||
{
|
||||
(*m_numRects) = 0 ;
|
||||
}
|
||||
else if (message == kQDRegionToRectsMsgParse)
|
||||
{
|
||||
(*m_numRects) += 1 ;
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
class RegionToRectsCallbackData
|
||||
{
|
||||
public :
|
||||
wxRect* m_rects ;
|
||||
long m_current ;
|
||||
} ;
|
||||
|
||||
OSStatus wxMacRegionToRectsSetterCallback (
|
||||
UInt16 message, RgnHandle region, const Rect *rect, void *data)
|
||||
{
|
||||
if (message == kQDRegionToRectsMsgParse)
|
||||
{
|
||||
RegionToRectsCallbackData *cb = (RegionToRectsCallbackData*) data ;
|
||||
cb->m_rects[cb->m_current] = wxRect( rect->left , rect->top , rect->right - rect->left , rect->bottom - rect->top ) ;
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
void wxRegionIterator::Reset(const wxRegion& region)
|
||||
{
|
||||
m_current = 0;
|
||||
@@ -413,15 +447,25 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
||||
m_numRects = 0;
|
||||
else
|
||||
{
|
||||
// we cannot dissolve it into rects on mac
|
||||
m_rects = new wxRect[1];
|
||||
Rect rect ;
|
||||
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
|
||||
m_rects[0].x = rect.left;
|
||||
m_rects[0].y = rect.top;
|
||||
m_rects[0].width = rect.right - rect.left;
|
||||
m_rects[0].height = rect.bottom - rect.top;
|
||||
m_numRects = 1;
|
||||
RegionToRectsUPP proc = NewRegionToRectsUPP (wxMacRegionToRectsCounterCallback);
|
||||
|
||||
OSStatus err = noErr;
|
||||
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
|
||||
if (err == noErr)
|
||||
{
|
||||
DisposeRegionToRectsUPP (proc);
|
||||
proc = NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
|
||||
m_rects = new wxRect[m_numRects];
|
||||
RegionToRectsCallbackData data ;
|
||||
data.m_rects = m_rects ;
|
||||
data.m_current = 0 ;
|
||||
QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&data);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_numRects = 0 ;
|
||||
}
|
||||
DisposeRegionToRectsUPP (proc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -270,6 +270,8 @@ wxRendererMac::DrawSplitterSash(wxWindow *win,
|
||||
}
|
||||
else
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
CGContextRef cgContext ;
|
||||
Rect bounds ;
|
||||
GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
|
||||
@@ -285,6 +287,7 @@ wxRendererMac::DrawSplitterSash(wxWindow *win,
|
||||
HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -84,9 +84,6 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
|
||||
m_peer->SetMinimum( 0 ) ;
|
||||
m_peer->SetValue( position ) ;
|
||||
m_peer->SetViewSize( m_viewSize ) ;
|
||||
|
||||
if ( refresh )
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -176,39 +176,45 @@ wxMenu* wxTaskBarIcon::DoCreatePopupMenu()
|
||||
// Operations:
|
||||
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||
{
|
||||
wxMask* mask = icon.GetMask();
|
||||
wxBitmap bmp( icon ) ;
|
||||
OSStatus err = noErr ;
|
||||
|
||||
CGImageRef pImage;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
pImage = bmp.CGImageCreate() ;
|
||||
#else
|
||||
wxMask* mask = bmp.GetMask();
|
||||
if (!mask)
|
||||
{
|
||||
// Make a mask with no transparent pixels
|
||||
wxBitmap bmp(icon.GetWidth(), icon.GetHeight());
|
||||
wxBitmap mbmp(icon.GetWidth(), icon.GetHeight());
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bmp);
|
||||
dc.SelectObject(mbmp);
|
||||
dc.SetBackground(*wxBLACK_BRUSH);
|
||||
dc.Clear();
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
mask = new wxMask(bmp, *wxWHITE);
|
||||
bmp.SetMask( new wxMask(mbmp, *wxWHITE) ) ;
|
||||
}
|
||||
|
||||
CGImageRef pImage;
|
||||
|
||||
//create the icon from the bitmap and mask bitmap contained within
|
||||
OSStatus err = CreateCGImageFromPixMaps(
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())),
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(mask->GetMaskBitmap())),
|
||||
&pImage
|
||||
);
|
||||
|
||||
WXHBITMAP iconport ;
|
||||
WXHBITMAP maskport ;
|
||||
iconport = bmp.GetHBITMAP( &maskport ) ;
|
||||
err = CreateCGImageFromPixMaps(
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(iconport)),
|
||||
GetGWorldPixMap(MAC_WXHBITMAP(maskport)),
|
||||
&pImage
|
||||
);
|
||||
wxASSERT(err == 0);
|
||||
|
||||
#endif
|
||||
wxASSERT(pImage != NULL );
|
||||
err = SetApplicationDockTileImage(pImage);
|
||||
|
||||
|
||||
wxASSERT(err == 0);
|
||||
|
||||
if (pImage != NULL)
|
||||
CGImageRelease(pImage);
|
||||
|
||||
if (!icon.GetMask())
|
||||
delete mask;
|
||||
|
||||
return m_iconAdded = err == noErr;
|
||||
}
|
||||
|
@@ -967,7 +967,7 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
// user pane implementation
|
||||
|
||||
void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part)
|
||||
@@ -1005,7 +1005,7 @@ wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action)
|
||||
void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation base class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -260,6 +260,8 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
|
||||
CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
|
||||
0 , 0 , 0 , &m_controlHandle ) ;
|
||||
|
||||
wxMacReleaseBitmapButton( &info ) ;
|
||||
|
||||
InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this,NULL);
|
||||
|
||||
@@ -555,6 +557,8 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
|
||||
void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this) ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
int w, h ;
|
||||
GetSize( &w , &h ) ;
|
||||
@@ -575,33 +579,35 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
|
||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||
{
|
||||
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 ) ;
|
||||
|
||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||
{
|
||||
HIThemeBackgroundDrawInfo drawInfo ;
|
||||
drawInfo.version = 0 ;
|
||||
drawInfo.state = kThemeStateActive ;
|
||||
drawInfo.kind = kThemeBackgroundMetal ;
|
||||
HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ;
|
||||
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) ;
|
||||
}
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||
}
|
||||
QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
{
|
||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||
}
|
||||
{
|
||||
UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
event.Skip() ;
|
||||
}
|
||||
|
||||
|
@@ -218,9 +218,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
#if 0
|
||||
// in case we would need a coregraphics compliant background erase first
|
||||
// now usable to track redraws
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
if ( thisWindow->MacIsUserPane() )
|
||||
{
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
static float color = 0.5 ;
|
||||
static channel = 0 ;
|
||||
HIRect bounds;
|
||||
@@ -237,9 +237,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
channel = 0 ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
|
||||
thisWindow->MacSetCGContextRef( cgContext ) ;
|
||||
#endif
|
||||
if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
|
||||
result = noErr ;
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
thisWindow->MacSetCGContextRef( NULL ) ;
|
||||
#endif
|
||||
if ( allocatedRgn )
|
||||
DisposeRgn( allocatedRgn ) ;
|
||||
}
|
||||
@@ -406,6 +413,8 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UserPane events for non OSX builds
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -517,6 +526,8 @@ ControlUserPaneActivateUPP gControlUserPaneActivateUPP = NULL ;
|
||||
ControlUserPaneFocusUPP gControlUserPaneFocusUPP = NULL ;
|
||||
ControlUserPaneBackgroundUPP gControlUserPaneBackgroundUPP = NULL ;
|
||||
|
||||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
@@ -690,9 +701,12 @@ void wxWindowMac::Init()
|
||||
m_macBackgroundBrush = wxNullBrush ;
|
||||
|
||||
m_macIsUserPane = TRUE;
|
||||
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
m_cgContextRef = NULL ;
|
||||
#endif
|
||||
// make sure all proc ptrs are available
|
||||
|
||||
#if !TARGET_API_MAC_OSX
|
||||
if ( gControlUserPaneDrawUPP == NULL )
|
||||
{
|
||||
gControlUserPaneDrawUPP = NewControlUserPaneDrawUPP( wxMacControlUserPaneDrawProc ) ;
|
||||
@@ -704,6 +718,7 @@ void wxWindowMac::Init()
|
||||
gControlUserPaneFocusUPP = NewControlUserPaneFocusUPP( wxMacControlUserPaneFocusProc ) ;
|
||||
gControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundUPP( wxMacControlUserPaneBackgroundProc ) ;
|
||||
}
|
||||
#endif
|
||||
if ( wxMacLiveScrollbarActionUPP == NULL )
|
||||
{
|
||||
wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
|
||||
@@ -2210,24 +2225,6 @@ void wxWindowMac::Thaw()
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowMac::MacRedrawControl()
|
||||
{
|
||||
/*
|
||||
if ( *m_peer && MacGetTopLevelWindowRef() && m_peer->IsVisible())
|
||||
{
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Update() ;
|
||||
#else
|
||||
wxClientDC dc(this) ;
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
wxMacWindowClipper clipper(this) ;
|
||||
wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
|
||||
UMADrawControl( *m_peer ) ;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* TODO
|
||||
void wxWindowMac::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
@@ -2482,8 +2479,29 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
||||
SectRect( &scrollrect , &r , &scrollrect ) ;
|
||||
}
|
||||
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
|
||||
|
||||
// now scroll the former update region as well and add the new update region
|
||||
|
||||
WindowRef rootWindow = (WindowRef) MacGetTopLevelWindowRef() ;
|
||||
RgnHandle formerUpdateRgn = NewRgn() ;
|
||||
RgnHandle scrollRgn = NewRgn() ;
|
||||
RectRgn( scrollRgn , &scrollrect ) ;
|
||||
GetWindowUpdateRgn( rootWindow , formerUpdateRgn ) ;
|
||||
Point pt = {0,0} ;
|
||||
LocalToGlobal( &pt ) ;
|
||||
OffsetRgn( formerUpdateRgn , -pt.h , -pt.v ) ;
|
||||
SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
|
||||
if ( !EmptyRgn( formerUpdateRgn ) )
|
||||
{
|
||||
MacOffsetRgn( formerUpdateRgn , dx , dy ) ;
|
||||
SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
|
||||
InvalWindowRgn(rootWindow , formerUpdateRgn ) ;
|
||||
}
|
||||
InvalWindowRgn(rootWindow , updateRgn ) ;
|
||||
DisposeRgn( updateRgn ) ;
|
||||
DisposeRgn( formerUpdateRgn ) ;
|
||||
DisposeRgn( scrollRgn ) ;
|
||||
}
|
||||
// ScrollWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &scrollrect , dx , dy , kScrollWindowInvalidate, updateRgn ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2819,6 +2837,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
bool handled = false ;
|
||||
Rect updatebounds ;
|
||||
GetRegionBounds( updatergn , &updatebounds ) ;
|
||||
|
||||
// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
||||
if ( !EmptyRgn(updatergn) )
|
||||
{
|
||||
@@ -2886,6 +2905,8 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
{
|
||||
if ( RectInRgn( &childRect , updatergn ) )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
// paint custom borders
|
||||
wxNcPaintEvent eventNc( child->GetId() );
|
||||
eventNc.SetEventObject( child );
|
||||
@@ -2896,54 +2917,26 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
|
||||
{
|
||||
#if wxMAC_USE_CORE_GRAPHICS
|
||||
#else
|
||||
wxWindowDC dc(this) ;
|
||||
dc.SetClippingRegion(wxRegion(updatergn));
|
||||
wxMacPortSetter helper(&dc) ;
|
||||
Rect r = childRect ;
|
||||
OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
|
||||
DrawThemeFocusRect( &r , true ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
return handled ;
|
||||
}
|
||||
|
||||
void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
|
||||
{
|
||||
RgnHandle updatergn = (RgnHandle) updatergnr ;
|
||||
// updatergn is always already clipped to our boundaries
|
||||
// if we are in compositing mode then it is in relative to the upper left of the control
|
||||
// if we are in non-compositing, then it is relatvie to the uppder left of the content area
|
||||
// of the toplevel window
|
||||
// it is in window coordinates, not in client coordinates
|
||||
|
||||
// ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
|
||||
RgnHandle ownUpdateRgn = NewRgn() ;
|
||||
CopyRgn( updatergn , ownUpdateRgn ) ;
|
||||
|
||||
if ( MacGetTopLevelWindow()->MacUsesCompositing() == false )
|
||||
{
|
||||
Rect bounds;
|
||||
m_peer->GetRectInWindowCoords( &bounds );
|
||||
RgnHandle controlRgn = NewRgn();
|
||||
RectRgn( controlRgn, &bounds );
|
||||
//KO: This sets the ownUpdateRgn to the area of this control that is inside
|
||||
// the window update region
|
||||
SectRgn( ownUpdateRgn, controlRgn, ownUpdateRgn );
|
||||
DisposeRgn( controlRgn );
|
||||
|
||||
//KO: convert ownUpdateRgn to local coordinates
|
||||
OffsetRgn( ownUpdateRgn, -bounds.left, -bounds.top );
|
||||
}
|
||||
|
||||
MacDoRedraw( ownUpdateRgn , time ) ;
|
||||
DisposeRgn( ownUpdateRgn ) ;
|
||||
|
||||
}
|
||||
|
||||
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
|
||||
{
|
||||
|
Reference in New Issue
Block a user