Add wxGraphicsContext::GetWindow()

This method allows to retrieve the window this context is associated
with, if any.

Add "wxWindow*" argument to wxGraphicsContext ctor and provide the
window pointer to it when available, i.e. when creating the context from
a wxWindow directly or from wxWindowDC, which is also associated with a
window, in platform-specific code.

No real changes yet.
This commit is contained in:
Vadim Zeitlin
2018-11-06 03:17:49 +01:00
parent 81c67c3686
commit 5e53b22bd4
8 changed files with 96 additions and 45 deletions

View File

@@ -452,7 +452,7 @@ private:
class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject
{
public:
wxGraphicsContext(wxGraphicsRenderer* renderer);
wxGraphicsContext(wxGraphicsRenderer* renderer, wxWindow* window = NULL);
virtual ~wxGraphicsContext();
@@ -490,6 +490,9 @@ public:
// create a context that can be used for measuring texts only, no drawing allowed
static wxGraphicsContext * Create();
// Return the window this context is associated with, if any.
wxWindow* GetWindow() const { return m_window; }
// begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown
virtual bool StartDoc( const wxString& message );
@@ -788,6 +791,12 @@ protected:
wxDouble angle,
const wxGraphicsBrush& backgroundBrush);
private:
// The associated window, if any, i.e. if one was passed directly to
// Create() or the associated window of the wxDC this context was created
// from.
wxWindow* const m_window;
wxDECLARE_NO_COPY_CLASS(wxGraphicsContext);
wxDECLARE_ABSTRACT_CLASS(wxGraphicsContext);
};