From 9f339b18beaebcc81d5cb959367d0963985f2943 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 23 Oct 2006 08:53:47 +0000 Subject: [PATCH] adding new constructors git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42267 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/graphics.cpp | 86 +++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index d47a26a9e1..59b44659a6 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -137,7 +137,6 @@ static GDILoader gGDILoader; class WXDLLEXPORT wxGDIPlusPath : public wxGraphicsPath { - DECLARE_NO_COPY_CLASS(wxGDIPlusPath) public : wxGDIPlusPath(); ~wxGDIPlusPath(); @@ -186,19 +185,21 @@ public : virtual void * GetNativePath() const { return m_path; } // give the native path returned by GetNativePath() back (there might be some deallocations necessary) - virtual void UnGetNativePath(void *p) {} + virtual void UnGetNativePath(void * WXUNUSED(path)) {} private : GraphicsPath* m_path; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusPath) }; class WXDLLEXPORT wxGDIPlusContext : public wxGraphicsContext { - DECLARE_NO_COPY_CLASS(wxGDIPlusContext) - public: - wxGDIPlusContext( WXHDC hdc ); + wxGDIPlusContext( HDC hdc ); + wxGDIPlusContext( HWND hwnd ); + wxGDIPlusContext( Graphics* gr); wxGDIPlusContext(); + virtual ~wxGDIPlusContext(); virtual void Clip( const wxRegion ®ion ); @@ -237,6 +238,9 @@ public: virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const; private: + void Init(); + void SetDefaults(); + Graphics* m_context; vector m_stateStack; GraphicsState m_state1; @@ -256,8 +260,11 @@ private: Font* m_font; // wxPen m_pen; // wxBrush m_brush; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusContext) }; +IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusPath,wxGraphicsPath) + wxGDIPlusPath::wxGDIPlusPath() { m_path = new GraphicsPath(); @@ -336,30 +343,59 @@ void wxGDIPlusPath::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h m_path->AddRectangle(RectF(x,y,w,h)); } -// -// -// -/* -// closes the current subpath -void wxGDIPlusPath::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) +//----------------------------------------------------------------------------- +// wxGDIPlusContext implementation +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusContext,wxGraphicsContext) + +wxGDIPlusContext::wxGDIPlusContext( HDC hdc ) { -// CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r); + Init(); + m_context = new Graphics( hdc); + SetDefaults(); } -*/ +wxGDIPlusContext::wxGDIPlusContext( HWND hwnd ) +{ + Init(); + m_context = new Graphics( hwnd); + SetDefaults(); +} -//----------------------------------------------------------------------------- -// wxGDIPlusContext implementation -//----------------------------------------------------------------------------- +wxGDIPlusContext::wxGDIPlusContext( Graphics* gr ) +{ + Init(); + m_context = gr; + SetDefaults(); +} -wxGDIPlusContext::wxGDIPlusContext( WXHDC hdc ) +void wxGDIPlusContext::Init() { gGDILoader.EnsureIsLoaded(); - m_context = new Graphics( (HDC) hdc); + m_context = NULL; + m_state1 = 0; + m_state2= 0; + + m_pen = NULL; + m_penTransparent = true; + m_penImage = NULL; + m_penBrush = NULL; + + m_brush = NULL; + m_brushTransparent = true; + m_brushImage = NULL; + m_brushPath = NULL; + + m_textBrush = NULL; + m_font = NULL; +} + +void wxGDIPlusContext::SetDefaults() +{ m_context->SetSmoothingMode(SmoothingModeHighQuality); m_state1 = m_context->Save(); m_state2 = m_context->Save(); - // set defaults m_penTransparent = false; @@ -394,19 +430,19 @@ wxGDIPlusContext::~wxGDIPlusContext() } -void wxGDIPlusContext::Clip( const wxRegion & WXUNUSED(region) ) +void wxGDIPlusContext::Clip( const wxRegion ®ion ) { -// TODO + m_context->SetClip((HRGN)region.GetHRGN(),CombineModeIntersect); } void wxGDIPlusContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) { -// TODO + m_context->SetClip(RectF(x,y,w,h),CombineModeIntersect); } void wxGDIPlusContext::ResetClip() { -// TODO + m_context->ResetClip(); } void wxGDIPlusContext::StrokePath( const wxGraphicsPath *path ) @@ -955,12 +991,12 @@ wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc) wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window ) { - return NULL; // TODO + return new wxGDIPlusContext( (HWND) window->GetHWND() ); } wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context ) { - return NULL; // TODO + return new wxGDIPlusContext( (Graphics*) context ); } -- 2.45.2