Make wxCocoa compile with new pImpl wxDC.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2007-12-04 04:22:16 +00:00
parent 9b3b7f5556
commit 938156b255
11 changed files with 203 additions and 168 deletions

View File

@@ -14,22 +14,24 @@
DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
class WXDLLIMPEXP_FWD_CORE wxDC;
WX_DECLARE_LIST(wxDC, wxCocoaDCStack);
#include "wx/dc.h"
class WXDLLIMPEXP_FWD_CORE wxCocoaDCImpl;
WX_DECLARE_LIST(wxCocoaDCImpl, wxCocoaDCStack);
//=========================================================================
// wxDC
//=========================================================================
class WXDLLEXPORT wxDC: public wxDCBase
class WXDLLIMPEXP_CORE wxCocoaDCImpl: public wxDCImpl
{
DECLARE_DYNAMIC_CLASS(wxDC)
DECLARE_NO_COPY_CLASS(wxDC)
DECLARE_ABSTRACT_CLASS(wxCocoaDCImpl)
DECLARE_NO_COPY_CLASS(wxCocoaDCImpl)
//-------------------------------------------------------------------------
// Initialization
//-------------------------------------------------------------------------
public:
wxDC();
virtual ~wxDC();
wxCocoaDCImpl(wxDC *owner);
virtual ~wxCocoaDCImpl();
//-------------------------------------------------------------------------
// wxCocoa specifics

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcclient.h
// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
// Purpose: wxClientDCImpl, wxPaintDCImpl and wxWindowDCImpl classes
// Author: David Elliott
// Modified by:
// Created: 2003/04/01
@@ -12,20 +12,20 @@
#ifndef __WX_COCOA_DCCLIENT_H__
#define __WX_COCOA_DCCLIENT_H__
#include "wx/dc.h"
#include "wx/cocoa/dc.h"
// DFE: A while ago I stumbled upon the fact that retrieving the parent
// NSView of the content view seems to return the entire window rectangle
// (including decorations). Of course, that is not at all part of the
// Cocoa or OpenStep APIs, but it might be a neat hack.
class WXDLLIMPEXP_CORE wxWindowDC: public wxDC
class WXDLLIMPEXP_CORE wxWindowDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxWindowDC)
DECLARE_DYNAMIC_CLASS(wxWindowDCImpl)
public:
wxWindowDC(void);
wxWindowDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxWindowDC(wxWindow *win);
virtual ~wxWindowDC(void);
wxWindowDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxWindowDCImpl(void);
protected:
wxWindow *m_window;
@@ -38,28 +38,28 @@ protected:
virtual bool CocoaGetBounds(void *rectData);
};
class WXDLLIMPEXP_CORE wxClientDC: public wxWindowDC
class WXDLLIMPEXP_CORE wxClientDCImpl: public wxWindowDCImpl
{
DECLARE_DYNAMIC_CLASS(wxClientDC)
DECLARE_DYNAMIC_CLASS(wxClientDCImpl)
public:
wxClientDC(void);
wxClientDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxClientDC(wxWindow *win);
virtual ~wxClientDC(void);
wxClientDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxClientDCImpl(void);
protected:
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
};
class WXDLLIMPEXP_CORE wxPaintDC: public wxWindowDC
class WXDLLIMPEXP_CORE wxPaintDCImpl: public wxWindowDCImpl
{
DECLARE_DYNAMIC_CLASS(wxPaintDC)
DECLARE_DYNAMIC_CLASS(wxPaintDCImpl)
public:
wxPaintDC(void);
wxPaintDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxPaintDC(wxWindow *win);
virtual ~wxPaintDC(void);
wxPaintDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxPaintDCImpl(void);
protected:
// DC stack
virtual bool CocoaLockFocus();

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcmemory.h
// Purpose: wxMemoryDC class
// Purpose: wxMemoryDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
@@ -12,17 +12,25 @@
#ifndef __WX_COCOA_DCMEMORY_H__
#define __WX_COCOA_DCMEMORY_H__
#include "wx/dc.h"
#include "wx/cocoa/dc.h"
class WXDLLEXPORT wxMemoryDC: public wxDC, public wxMemoryDCBase
#include "wx/dcmemory.h"
class WXDLLEXPORT wxMemoryDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
DECLARE_DYNAMIC_CLASS(wxMemoryDCImpl)
public:
wxMemoryDC() { Init(); }
wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void);
wxMemoryDCImpl(wxMemoryDC *owner)
: wxCocoaDCImpl(owner)
{ Init(); }
wxMemoryDCImpl(wxMemoryDC *owner, wxBitmap& bitmap)
: wxCocoaDCImpl(owner)
{ Init();
owner->SelectObject(bitmap);
}
wxMemoryDCImpl(wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDCImpl(void);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoSelect(const wxBitmap& bitmap);

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcscreen.h
// Purpose: wxScreenDC class
// Purpose: wxScreenDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
@@ -12,15 +12,16 @@
#ifndef __WX_COCOA_DCSCREEN_H__
#define __WX_COCOA_DCSCREEN_H__
#include "wx/dcclient.h"
#include "wx/dcscreen.h"
#include "wx/cocoa/dc.h"
class WXDLLEXPORT wxScreenDC: public wxDC
class WXDLLEXPORT wxScreenDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxScreenDC)
DECLARE_DYNAMIC_CLASS(wxScreenDCImpl)
public:
wxScreenDC(void);
wxScreenDC( wxDC *dc ); // Create compatible DC
virtual ~wxScreenDC(void);
wxScreenDCImpl(wxScreenDC *owner);
wxScreenDCImpl(wxScreenDC *owner, wxDC *dc ); // Create compatible DC
virtual ~wxScreenDCImpl(void);
// Compatibility with X's requirements for drawing on top of all windows
static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return true; }

View File

@@ -15,7 +15,6 @@
#include "wx/app.h"
#ifndef WX_PRECOMP
#include "wx/dc.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/module.h"
@@ -26,6 +25,8 @@
#include "wx/cocoa/mbarman.h"
#include "wx/cocoa/NSApplication.h"
#include "wx/cocoa/dc.h"
#import <AppKit/NSApplication.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSThread.h>
@@ -162,7 +163,7 @@ void wxApp::CleanUp()
{
wxAutoNSAutoreleasePool pool;
wxDC::CocoaShutdownTextSystem();
wxCocoaDCImpl::CocoaShutdownTextSystem();
wxMenuBarManager::DestroyInstance();
[[NSNotificationCenter defaultCenter] removeObserver:sg_cocoaAppObserver];
@@ -257,7 +258,7 @@ bool wxApp::OnInitGui()
if(!sm_isEmbedded)
wxMenuBarManager::CreateInstance();
wxDC::CocoaInitializeTextSystem();
wxCocoaDCImpl::CocoaInitializeTextSystem();
return true;
}

View File

@@ -11,7 +11,7 @@
#include "wx/wxprec.h"
#include "wx/dc.h"
#include "wx/cocoa/dc.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
@@ -34,11 +34,12 @@
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxCocoaDCStack);
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
WX_NSTextStorage wxDC::sm_cocoaNSTextStorage = nil;
WX_NSLayoutManager wxDC::sm_cocoaNSLayoutManager = nil;
WX_NSTextContainer wxDC::sm_cocoaNSTextContainer = nil;
wxCocoaDCStack wxDC::sm_cocoaDCStack;
IMPLEMENT_ABSTRACT_CLASS(wxCocoaDCImpl, wxDCImpl)
WX_NSTextStorage wxCocoaDCImpl::sm_cocoaNSTextStorage = nil;
WX_NSLayoutManager wxCocoaDCImpl::sm_cocoaNSLayoutManager = nil;
WX_NSTextContainer wxCocoaDCImpl::sm_cocoaNSTextContainer = nil;
wxCocoaDCStack wxCocoaDCImpl::sm_cocoaDCStack;
inline void CocoaSetPenForNSBezierPath(wxPen &pen, NSBezierPath *bezpath)
{
@@ -72,7 +73,7 @@ inline void CocoaSetPenForNSBezierPath(wxPen &pen, NSBezierPath *bezpath)
}
}
void wxDC::CocoaInitializeTextSystem()
void wxCocoaDCImpl::CocoaInitializeTextSystem()
{
wxASSERT_MSG(!sm_cocoaNSTextStorage && !sm_cocoaNSLayoutManager && !sm_cocoaNSTextContainer,wxT("Text system already initalized! BAD PROGRAMMER!"));
@@ -92,14 +93,14 @@ void wxDC::CocoaInitializeTextSystem()
// [sm_cocoaNSTextContainer release]; [sm_cocoaNSTextContainer retain];
}
void wxDC::CocoaShutdownTextSystem()
void wxCocoaDCImpl::CocoaShutdownTextSystem()
{
[sm_cocoaNSTextContainer release]; sm_cocoaNSTextContainer = nil;
[sm_cocoaNSLayoutManager release]; sm_cocoaNSLayoutManager = nil;
[sm_cocoaNSTextStorage release]; sm_cocoaNSTextStorage = nil;
}
void wxDC::CocoaUnwindStackAndLoseFocus()
void wxCocoaDCImpl::CocoaUnwindStackAndLoseFocus()
{
wxCocoaDCStack::compatibility_iterator ourNode=sm_cocoaDCStack.Find(this);
if(ourNode)
@@ -107,7 +108,7 @@ void wxDC::CocoaUnwindStackAndLoseFocus()
wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
for(;node!=ourNode; node=sm_cocoaDCStack.GetFirst())
{
wxDC *dc = node->GetData();
wxCocoaDCImpl *dc = node->GetData();
wxASSERT(dc);
wxASSERT(dc!=this);
if(!dc->CocoaUnlockFocus())
@@ -123,12 +124,12 @@ void wxDC::CocoaUnwindStackAndLoseFocus()
}
}
bool wxDC::CocoaUnwindStackAndTakeFocus()
bool wxCocoaDCImpl::CocoaUnwindStackAndTakeFocus()
{
wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
for(;node;node = sm_cocoaDCStack.GetFirst())
{
wxDC *dc = node->GetData();
wxCocoaDCImpl *dc = node->GetData();
wxASSERT(dc);
// If we're on the stack, then it's unwound enough and we have focus
if(dc==this)
@@ -141,28 +142,29 @@ bool wxDC::CocoaUnwindStackAndTakeFocus()
return CocoaLockFocus();
}
wxDC::wxDC(void)
wxCocoaDCImpl::wxCocoaDCImpl(wxDC *owner)
: wxDCImpl(owner)
{
m_cocoaWxToBoundsTransform = nil;
m_pen = *wxBLACK_PEN;
}
wxDC::~wxDC(void)
wxCocoaDCImpl::~wxDC(void)
{
[m_cocoaWxToBoundsTransform release];
}
bool wxDC::CocoaLockFocus()
bool wxCocoaDCImpl::CocoaLockFocus()
{
return false;
}
bool wxDC::CocoaUnlockFocus()
bool wxCocoaDCImpl::CocoaUnlockFocus()
{
return false;
}
/*static*/ WX_NSAffineTransform wxDC::CocoaGetWxToBoundsTransform(bool isFlipped, float height)
/*static*/ WX_NSAffineTransform wxCocoaDCImpl::CocoaGetWxToBoundsTransform(bool isFlipped, float height)
{
NSAffineTransform *transform = nil;
// This transform flips the graphics since wxDC uses top-left origin
@@ -183,13 +185,13 @@ bool wxDC::CocoaUnlockFocus()
return transform;
}
void wxDC::CocoaApplyTransformations()
void wxCocoaDCImpl::CocoaApplyTransformations()
{
[m_cocoaWxToBoundsTransform concat];
// TODO: Apply device/logical/user position/scaling transformations
}
void wxDC::CocoaUnapplyTransformations()
void wxCocoaDCImpl::CocoaUnapplyTransformations()
{
// NOTE: You *must* call this with focus held.
// Undo all transforms so we're back in true Cocoa coords with
@@ -201,13 +203,13 @@ void wxDC::CocoaUnapplyTransformations()
[invertTransform release];
}
bool wxDC::CocoaGetBounds(void *rectData)
bool wxCocoaDCImpl::CocoaGetBounds(void *rectData)
{
// We don't know what we are so we can't return anything.
return false;
}
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxCocoaDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
wxAutoNSAutoreleasePool pool;
if(!CocoaTakeFocus()) return;
@@ -218,7 +220,7 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
[bezpath fill];
}
void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
void wxCocoaDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
wxAutoNSAutoreleasePool pool;
if(!CocoaTakeFocus()) return;
@@ -230,7 +232,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
[bezpath stroke];
}
void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont) const
void wxCocoaDCImpl::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont) const
{
wxAutoNSAutoreleasePool pool;
// FIXME: Cache this so it can be used for DoDrawText
@@ -252,7 +254,7 @@ void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord
*externalLeading=0;
}
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
void wxCocoaDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
wxAutoNSAutoreleasePool pool;
if(!CocoaTakeFocus()) return;
@@ -345,105 +347,105 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
// wxDC
//-----------------------------------------------------------------------------
void wxDC::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) )
void wxCocoaDCImpl::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) )
{
};
void wxDC::DoDrawPoint( int x, int y )
void wxCocoaDCImpl::DoDrawPoint( int x, int y )
{
};
void wxDC::DoDrawPolygon( int, wxPoint *, int, int, int)
void wxCocoaDCImpl::DoDrawPolygon( int, wxPoint *, int, int, int)
{
};
void wxDC::DoDrawLines( int, wxPoint *, int, int )
void wxCocoaDCImpl::DoDrawLines( int, wxPoint *, int, int )
{
}
int wxDC::GetDepth() const
int wxCocoaDCImpl::GetDepth() const
{
return 0;
}
wxSize wxDC::GetPPI() const
wxSize wxCocoaDCImpl::GetPPI() const
{
return wxSize(0,0);
}
bool wxDC::CanGetTextExtent() const
bool wxCocoaDCImpl::CanGetTextExtent() const
{
return false;
}
wxCoord wxDC::GetCharHeight() const
wxCoord wxCocoaDCImpl::GetCharHeight() const
{
return 0;
}
wxCoord wxDC::GetCharWidth() const
wxCoord wxCocoaDCImpl::GetCharWidth() const
{
return 0;
}
bool wxDC::CanDrawBitmap() const
bool wxCocoaDCImpl::CanDrawBitmap() const
{
return true;
}
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
bool wxCocoaDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
{
return false;
}
void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
void wxCocoaDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
{
}
void wxDC::SetFont(const wxFont& font)
void wxCocoaDCImpl::SetFont(const wxFont& font)
{
m_font = font;
}
void wxDC::SetPen(const wxPen& pen)
void wxCocoaDCImpl::SetPen(const wxPen& pen)
{
m_pen = pen;
}
void wxDC::SetBrush(const wxBrush& brush)
void wxCocoaDCImpl::SetBrush(const wxBrush& brush)
{
m_brush = brush;
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxCocoaDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
{
}
void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxCocoaDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
}
void wxDC::DestroyClippingRegion()
void wxCocoaDCImpl::DestroyClippingRegion()
{
}
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
void wxCocoaDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
{
}
void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
void wxCocoaDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
{
}
void wxDC::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea)
void wxCocoaDCImpl::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea)
{
}
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxCocoaDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
}
void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
void wxCocoaDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
{
wxAutoNSAutoreleasePool pool;
if(!CocoaTakeFocus()) return;
@@ -490,57 +492,58 @@ void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
[context restoreGraphicsState];
}
bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
bool wxCocoaDCImpl::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
{
return false;
}
void wxDC::DoCrossHair(wxCoord x, wxCoord y)
void wxCocoaDCImpl::DoCrossHair(wxCoord x, wxCoord y)
{
}
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
bool wxCocoaDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
{
if(!CocoaTakeFocus()) return false;
if(!source) return false;
return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
wxCocoaDCImpl *sourceImpl = static_cast<wxCocoaDCImpl*>(source->GetImpl());
return sourceImpl->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
}
bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
bool wxCocoaDCImpl::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
{
return false;
}
void wxDC::DoGetSize( int* width, int* height ) const
void wxCocoaDCImpl::DoGetSize( int* width, int* height ) const
{
*width = m_maxX-m_minX;
*height = m_maxY-m_minY;
};
void wxDC::DoGetSizeMM( int* width, int* height ) const
void wxCocoaDCImpl::DoGetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
GetSize( &w, &h );
DoGetSize( &w, &h );
};
void wxDC::SetTextForeground( const wxColour &col )
void wxCocoaDCImpl::SetTextForeground( const wxColour &col )
{
if (!Ok()) return;
// if (!Ok()) return;
m_textForegroundColour = col;
};
void wxDC::SetTextBackground( const wxColour &col )
void wxCocoaDCImpl::SetTextBackground( const wxColour &col )
{
if (!Ok()) return;
// if (!Ok()) return;
m_textBackgroundColour = col;
};
void wxDC::Clear()
void wxCocoaDCImpl::Clear()
{
if(!CocoaTakeFocus()) return;
@@ -560,21 +563,21 @@ void wxDC::Clear()
[context restoreGraphicsState];
}
void wxDC::SetBackground(const wxBrush& brush)
void wxCocoaDCImpl::SetBackground(const wxBrush& brush)
{
m_backgroundBrush = brush;
}
void wxDC::SetPalette(const wxPalette&)
void wxCocoaDCImpl::SetPalette(const wxPalette&)
{
}
void wxDC::SetLogicalFunction(int)
void wxCocoaDCImpl::SetLogicalFunction(int)
{
}
void wxDC::SetMapMode( int mode )
void wxCocoaDCImpl::SetMapMode( int mode )
{
switch (mode)
{
@@ -596,7 +599,7 @@ void wxDC::SetMapMode( int mode )
};
};
void wxDC::SetUserScale( double x, double y )
void wxCocoaDCImpl::SetUserScale( double x, double y )
{
// allow negative ? -> no
m_userScaleX = x;
@@ -604,7 +607,7 @@ void wxDC::SetUserScale( double x, double y )
ComputeScaleAndOrigin();
};
void wxDC::SetLogicalScale( double x, double y )
void wxCocoaDCImpl::SetLogicalScale( double x, double y )
{
// allow negative ?
m_logicalScaleX = x;
@@ -612,26 +615,26 @@ void wxDC::SetLogicalScale( double x, double y )
ComputeScaleAndOrigin();
};
void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
void wxCocoaDCImpl::SetLogicalOrigin( wxCoord x, wxCoord y )
{
m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin();
};
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
void wxCocoaDCImpl::SetDeviceOrigin( wxCoord x, wxCoord y )
{
ComputeScaleAndOrigin();
};
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
void wxCocoaDCImpl::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? -1 : 1);
ComputeScaleAndOrigin();
};
void wxDC::ComputeScaleAndOrigin(void)
void wxCocoaDCImpl::ComputeScaleAndOrigin(void)
{
// CMB: copy scale to see if it changes
double origScaleX = m_scaleX;
@@ -643,11 +646,13 @@ void wxDC::ComputeScaleAndOrigin(void)
// CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{
#if 0
// this is a bit artificial, but we need to force wxDC to think
// the pen has changed
const wxPen* pen = & GetPen();
wxPen tempPen;
m_pen = tempPen;
SetPen(* pen);
#endif
}
};

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/cocoa/dcclient.mm
// Purpose: wxWindowDC, wxPaintDC, and wxClientDC classes
// Purpose: wxWindowDCImpl, wxPaintDCImpl, and wxClientDCImpl classes
// Author: David Elliott
// Modified by:
// Created: 2003/04/01
@@ -13,9 +13,10 @@
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/window.h"
#include "wx/dcclient.h"
#endif //WX_PRECOMP
#include "wx/cocoa/dcclient.h"
#import <AppKit/NSView.h>
#import <AppKit/NSAffineTransform.h>
#import <AppKit/NSColor.h>
@@ -24,29 +25,31 @@
#import <AppKit/NSWindow.h>
/*
* wxWindowDC
* wxWindowDCImpl
*/
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxCocoaDCImpl)
wxWindowDC::wxWindowDC(void)
: m_window(NULL)
wxWindowDCImpl::wxWindowDCImpl(wxDC *owner)
: wxCocoaDCImpl(owner)
, m_window(NULL)
, m_lockedNSView(NULL)
{
};
wxWindowDC::wxWindowDC( wxWindow *window )
: m_window(window)
wxWindowDCImpl::wxWindowDCImpl(wxDC *owner, wxWindow *window)
: wxCocoaDCImpl(owner)
, m_window(window)
, m_lockedNSView(NULL)
{
wxLogDebug(wxT("non-client window DC's are not supported, oh well"));
};
wxWindowDC::~wxWindowDC(void)
wxWindowDCImpl::~wxWindowDCImpl(void)
{
CocoaUnwindStackAndLoseFocus();
};
bool wxWindowDC::CocoaLockFocusOnNSView(WX_NSView nsview)
bool wxWindowDCImpl::CocoaLockFocusOnNSView(WX_NSView nsview)
{
if([nsview lockFocusIfCanDraw])
{
@@ -59,7 +62,7 @@ bool wxWindowDC::CocoaLockFocusOnNSView(WX_NSView nsview)
return false;
}
bool wxWindowDC::CocoaUnlockFocusOnNSView()
bool wxWindowDCImpl::CocoaUnlockFocusOnNSView()
{
[[m_lockedNSView window] flushWindow];
[m_lockedNSView unlockFocus];
@@ -67,9 +70,9 @@ bool wxWindowDC::CocoaUnlockFocusOnNSView()
return true;
}
bool wxWindowDC::CocoaLockFocus()
bool wxWindowDCImpl::CocoaLockFocus()
{
wxLogTrace(wxTRACE_COCOA,wxT("Locking focus on wxWindowDC=%p, NSView=%p"),this, m_window->GetNonClientNSView());
wxLogTrace(wxTRACE_COCOA,wxT("Locking focus on wxWindowDCImpl=%p, NSView=%p"),this, m_window->GetNonClientNSView());
NSAffineTransform *newTransform = CocoaGetWxToBoundsTransform([m_window->GetNonClientNSView() isFlipped], [m_window->GetNonClientNSView() bounds].size.height);
[newTransform retain];
[m_cocoaWxToBoundsTransform release];
@@ -77,13 +80,13 @@ bool wxWindowDC::CocoaLockFocus()
return CocoaLockFocusOnNSView(m_window->GetNonClientNSView());
}
bool wxWindowDC::CocoaUnlockFocus()
bool wxWindowDCImpl::CocoaUnlockFocus()
{
wxLogTrace(wxTRACE_COCOA,wxT("Unlocking focus on wxWindowDC=%p, NSView=%p"),this, m_window->GetNonClientNSView());
wxLogTrace(wxTRACE_COCOA,wxT("Unlocking focus on wxWindowDCImpl=%p, NSView=%p"),this, m_window->GetNonClientNSView());
return CocoaUnlockFocusOnNSView();
}
bool wxWindowDC::CocoaGetBounds(void *rectData)
bool wxWindowDCImpl::CocoaGetBounds(void *rectData)
{
if(!rectData)
return false;
@@ -95,27 +98,29 @@ bool wxWindowDC::CocoaGetBounds(void *rectData)
}
/*
* wxClientDC
* wxClientDCImpl
*/
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
IMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl)
wxClientDC::wxClientDC(void)
wxClientDCImpl::wxClientDCImpl(wxDC *owner)
: wxWindowDCImpl(owner)
{
};
wxClientDC::wxClientDC( wxWindow *window )
wxClientDCImpl::wxClientDCImpl(wxDC *owner, wxWindow *window)
: wxWindowDCImpl(owner)
{
m_window = window;
};
wxClientDC::~wxClientDC(void)
wxClientDCImpl::~wxClientDCImpl(void)
{
CocoaUnwindStackAndLoseFocus();
};
bool wxClientDC::CocoaLockFocus()
bool wxClientDCImpl::CocoaLockFocus()
{
wxLogTrace(wxTRACE_COCOA,wxT("Locking focus on wxClientDC=%p, NSView=%p"),this, m_window->GetNSView());
wxLogTrace(wxTRACE_COCOA,wxT("Locking focus on wxClientDCImpl=%p, NSView=%p"),this, m_window->GetNSView());
NSAffineTransform *newTransform = m_window->CocoaGetWxToBoundsTransform();
[newTransform retain];
[m_cocoaWxToBoundsTransform release];
@@ -123,25 +128,27 @@ bool wxClientDC::CocoaLockFocus()
return CocoaLockFocusOnNSView(m_window->GetNSView());
}
bool wxClientDC::CocoaUnlockFocus()
bool wxClientDCImpl::CocoaUnlockFocus()
{
wxLogTrace(wxTRACE_COCOA,wxT("Unlocking focus on wxClientDC=%p, NSView=%p"),this, m_window->GetNSView());
wxLogTrace(wxTRACE_COCOA,wxT("Unlocking focus on wxClientDCImpl=%p, NSView=%p"),this, m_window->GetNSView());
return CocoaUnlockFocusOnNSView();
}
/*
* wxPaintDC
* wxPaintDCImpl
*/
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
IMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxWindowDCImpl)
wxPaintDC::wxPaintDC(void)
wxPaintDCImpl::wxPaintDCImpl(wxDC *owner)
: wxWindowDCImpl(owner)
{
};
wxPaintDC::wxPaintDC( wxWindow *window )
wxPaintDCImpl::wxPaintDCImpl(wxDC *owner, wxWindow *window)
: wxWindowDCImpl(owner)
{
m_window = window;
wxASSERT_MSG([NSView focusView]==window->GetNSView(), wxT("PaintDC's NSView does not have focus. Please use wxPaintDC only as the first DC created in a paint handler"));
wxASSERT_MSG([NSView focusView]==window->GetNSView(), wxT("PaintDC's NSView does not have focus. Please use wxPaintDCImpl only as the first DC created in a paint handler"));
sm_cocoaDCStack.Insert(this);
m_lockedNSView = window->GetNSView();
NSAffineTransform *newTransform = window->CocoaGetWxToBoundsTransform();
@@ -151,20 +158,20 @@ wxPaintDC::wxPaintDC( wxWindow *window )
CocoaApplyTransformations();
};
wxPaintDC::~wxPaintDC(void)
wxPaintDCImpl::~wxPaintDCImpl(void)
{
CocoaUnwindStackAndLoseFocus();
};
bool wxPaintDC::CocoaLockFocus()
bool wxPaintDCImpl::CocoaLockFocus()
{
wxFAIL_MSG(wxT("wxPaintDC cannot be asked to lock focus!"));
wxFAIL_MSG(wxT("wxPaintDCImpl cannot be asked to lock focus!"));
return false;
}
bool wxPaintDC::CocoaUnlockFocus()
bool wxPaintDCImpl::CocoaUnlockFocus()
{
// wxPaintDC focus can never be unlocked.
// wxPaintDCImpl focus can never be unlocked.
return false;
}

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/cocoa/dcmemory.mm
// Purpose: wxMemoryDC class
// Purpose: wxMemoryDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
@@ -13,9 +13,9 @@
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/dcmemory.h"
#endif //WX_PRECOMP
#include "wx/cocoa/dcmemory.h"
#include "wx/cocoa/autorelease.h"
#import <AppKit/NSImage.h>
@@ -25,29 +25,30 @@
#import <AppKit/NSBezierPath.h>
//-----------------------------------------------------------------------------
// wxMemoryDC
// wxMemoryDCImpl
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxCocoaDCImpl)
void wxMemoryDC::Init()
void wxMemoryDCImpl::Init()
{
m_cocoaNSImage = NULL;
m_ok = false;
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC *WXUNUSED(dc))
: wxCocoaDCImpl(owner)
{
Init();
}
wxMemoryDC::~wxMemoryDC(void)
wxMemoryDCImpl::~wxMemoryDCImpl(void)
{
CocoaUnwindStackAndLoseFocus();
[m_cocoaNSImage release];
}
bool wxMemoryDC::CocoaLockFocus()
bool wxMemoryDCImpl::CocoaLockFocus()
{
if(m_cocoaNSImage)
{
@@ -63,7 +64,7 @@ bool wxMemoryDC::CocoaLockFocus()
return false;
}
bool wxMemoryDC::CocoaUnlockFocus()
bool wxMemoryDCImpl::CocoaUnlockFocus()
{
[m_cocoaNSImage unlockFocus];
return true;
@@ -71,7 +72,7 @@ bool wxMemoryDC::CocoaUnlockFocus()
// NOTE: The AppKit is unable to draw onto an NSBitmapImageRep so we must
// instead copy the data to an offscreen window, then copy it back
void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
{
wxAutoNSAutoreleasePool pool;
if(m_selectedBitmap.Ok())
@@ -124,7 +125,7 @@ void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
}
}
void wxMemoryDC::DoGetSize( int *width, int *height ) const
void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
{
if(width)
*width = m_selectedBitmap.GetWidth();
@@ -132,7 +133,7 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const
*height = m_selectedBitmap.GetHeight();
}
bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
bool wxMemoryDCImpl::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
{
@@ -204,7 +205,7 @@ bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
return false;
}
bool wxMemoryDC::CocoaGetBounds(void *rectData)
bool wxMemoryDCImpl::CocoaGetBounds(void *rectData)
{
if(!rectData)
return false;

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/cocoa/dcscreen.cpp
// Purpose: wxScreenDC class
// Purpose: wxScreenDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
@@ -11,7 +11,7 @@
#include "wx/wxprec.h"
#include "wx/dcscreen.h"
#include "wx/cocoa/dcscreen.h"
#ifndef WX_PRECOMP
#endif //WX_PRECOMP
@@ -20,18 +20,20 @@
// wxMemoryDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxDC)
IMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl,wxCocoaDCImpl)
wxScreenDC::wxScreenDC(void)
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC *owner)
: wxCocoaDCImpl(owner)
{
m_ok = false;
}
wxScreenDC::wxScreenDC( wxDC *WXUNUSED(dc) )
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC *owner, wxDC *WXUNUSED(dc) )
: wxCocoaDCImpl(owner)
{
m_ok = false;
}
wxScreenDC::~wxScreenDC(void)
wxScreenDCImpl::~wxScreenDCImpl(void)
{
}

View File

@@ -15,11 +15,13 @@
#include "wx/log.h"
#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
#endif //WX_PRECOMP
#include "wx/tooltip.h"
#include "wx/cocoa/dc.h"
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
#include "wx/cocoa/trackingrectmanager.h"
@@ -1157,7 +1159,7 @@ NSRect wxWindowCocoa::CocoaTransformWxToBounds(NSRect rectWx)
WX_NSAffineTransform wxWindowCocoa::CocoaGetWxToBoundsTransform()
{
// TODO: Handle scrolling offset
NSAffineTransform *transform = wxDC::CocoaGetWxToBoundsTransform([GetNSView() isFlipped], [GetNSView() bounds].size.height);
NSAffineTransform *transform = wxCocoaDCImpl::CocoaGetWxToBoundsTransform([GetNSView() isFlipped], [GetNSView() bounds].size.height);
return transform;
}
@@ -1782,7 +1784,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *outX, int *outY,
// transformations. However, it's better than nothing.
// We don't create a wxClientDC because we don't want to accidently be able to use
// it for drawing.
wxDC tmpdc;
wxClientDC tmpdc(const_cast<wxWindow*>(this));
return tmpdc.GetTextExtent(string, outX, outY, outDescent, outExternalLeading, inFont);
}

View File

@@ -54,6 +54,12 @@
#include "wx/mac/dcscreen.h"
#endif
#ifdef __WXCOCOA__
#include "wx/cocoa/dcclient.h"
#include "wx/cocoa/dcmemory.h"
#include "wx/cocoa/dcscreen.h"
#endif
#ifdef __WXX11__
#include "wx/x11/dcclient.h"
#include "wx/x11/dcmemory.h"