]> git.saurik.com Git - wxWidgets.git/commitdiff
Adding wxDC::GetHandle for wxOSX-cocoa and wxOSX-carbon
authorRobin Dunn <robin@alldunn.com>
Sat, 28 Jul 2012 19:31:03 +0000 (19:31 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 28 Jul 2012 19:31:03 +0000 (19:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72224 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dc.h
include/wx/dcgraph.h
include/wx/dcmirror.h
include/wx/dcsvg.h
include/wx/generic/dcpsg.h
interface/wx/dc.h
src/common/dcgraph.cpp

index b519785afa63fcede71bc88eab1f84e55c7df09f..9c6748a920ac15e1af242f1027c403b3aa9a99cf 100644 (file)
@@ -283,6 +283,8 @@ public:
         return NULL;
     }
 
+    virtual void* GetHandle() const = 0;
+    
     // query dimension, colour deps, resolution
 
     virtual void DoGetSize(int *width, int *height) const = 0;
@@ -787,6 +789,9 @@ public:
     wxWindow *GetWindow() const
         { return m_pimpl->GetWindow(); }
 
+    void *GetHandle() const
+        { return m_pimpl->GetHandle(); }
+
     bool IsOk() const
         { return m_pimpl && m_pimpl->IsOk(); }
 
index 9f6c178fd367cbbc1da94de03b1d5ac443080a89..d010b63ae405804ebf4c11102a3f0aa1ada049cf 100644 (file)
@@ -109,6 +109,8 @@ public:
     wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; }
     virtual void SetGraphicsContext( wxGraphicsContext* ctx );
 
+    virtual void* GetHandle() const;
+
     // the true implementations
     virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
                              wxFloodFillStyle style = wxFLOOD_SURFACE);
index 98858240b650f42e93fb9f7355fd7d2fe91cfb89..ee6d5c1b8a11eba7d529d2f0f7510f72114b6774 100644 (file)
@@ -66,6 +66,9 @@ public:
     virtual void SetLogicalFunction(wxRasterOperationMode function)
         { m_dc.SetLogicalFunction(function); }
 
+    virtual void* GetHandle() const
+        { return m_dc.GetHandle(); }
+
 protected:
     // returns x and y if not mirroring or y and x if mirroring
     wxCoord GetX(wxCoord x, wxCoord y) const { return m_mirror ? y : x; }
index cf492e7938160134cacd958cc386ebce052358bf..cae6308db4f3f2ec9dc2085cc51efa1c55c76a19 100644 (file)
@@ -96,6 +96,8 @@ public:
     virtual void SetFont(const wxFont& font);
     virtual void SetPen(const wxPen& pen);
 
+    virtual void* GetHandle() const { return NULL; }
+
 private:
    virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const
    {
index afda6f29227ce78552ae29fbf32ae9028a3fcf18..65e36cbce87bfe0dc28555e1892372d3b17dc4fd 100644 (file)
@@ -94,6 +94,8 @@ public:
     virtual int GetResolution() const;
     virtual wxRect GetPaperRect() const;
 
+    virtual void* GetHandle() const { return NULL; }
+    
 protected:
     bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col,
                      wxFloodFillStyle style = wxFLOOD_SURFACE);
index e8e54c4526b5ed802068857c390996dff24d4248..54b005360264b0b65eb278509bbe59ab9aad1a90 100644 (file)
@@ -1535,6 +1535,22 @@ public:
     //@}
 
 
+    /**
+       Returns a value that can be used as a handle to the native drawing
+       context, if this wxDC has something that could be thought of in that
+       way.  (Not all of them do.)
+
+       For example, on Windows the return value is an HDC, on OSX it is a
+       CGContextRef and on wxGTK it will be a GdkDrawable.  If the DC is a
+       wxGCDC then the return value will be the value returned from
+       wxGraphicsContext::GetNativeContext.  A value of NULL is returned if
+       the DC does not have anything that fits the handle concept.
+       
+       @since 2.9.5
+     */
+    void* GetHandle() const;
+    
+
     void SetLogicalScale(double x, double y);
     void GetLogicalScale(double *x, double *y) const;
     void SetLogicalOrigin(wxCoord x, wxCoord y);
index 3b49dce031cac84073b59f4d6c920eba148ad99b..5f79c36eb73c0dedf4c1ec7914b25f61cc144520 100644 (file)
@@ -433,6 +433,16 @@ void wxGCDCImpl::ComputeScaleAndOrigin()
     }
 }
 
+void* wxGCDCImpl::GetHandle() const
+{
+    void* cgctx = NULL;
+    wxGraphicsContext* gc = GetGraphicsContext();
+    if (gc) {
+        cgctx = gc->GetNativeContext();
+    }
+    return cgctx;
+}
+
 void wxGCDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) )
 {