Replace wxGTKCairoDCImpl::m_{width,height} with m_size
This allows to avoid initializing the variables to 0 in all the overloaded ctors: wxSize default ctor already does it. It's also more convenient to use GetScaledSize() rather than assigning m_width and m_height separately, even if the rest of the code is broadly unchanged.
This commit is contained in:
@@ -34,10 +34,10 @@ public:
|
|||||||
virtual wxSize GetPPI() const wxOVERRIDE;
|
virtual wxSize GetPPI() const wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Set m_width and m_height from the given (valid) GdkWindow.
|
// Set m_size from the given (valid) GdkWindow.
|
||||||
void InitSize(GdkWindow* window);
|
void InitSize(GdkWindow* window);
|
||||||
|
|
||||||
int m_width, m_height;
|
wxSize m_size;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDCImpl);
|
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDCImpl);
|
||||||
};
|
};
|
||||||
|
@@ -24,24 +24,17 @@
|
|||||||
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner)
|
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner)
|
||||||
: wxGCDCImpl(owner)
|
: wxGCDCImpl(owner)
|
||||||
{
|
{
|
||||||
m_width = 0;
|
|
||||||
m_height = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, double scaleFactor)
|
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, double scaleFactor)
|
||||||
: wxGCDCImpl(owner, 0)
|
: wxGCDCImpl(owner, 0)
|
||||||
{
|
{
|
||||||
m_width = 0;
|
|
||||||
m_height = 0;
|
|
||||||
m_contentScaleFactor = scaleFactor;
|
m_contentScaleFactor = scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
|
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
|
||||||
: wxGCDCImpl(owner, 0)
|
: wxGCDCImpl(owner, 0)
|
||||||
{
|
{
|
||||||
m_width = 0;
|
|
||||||
m_height = 0;
|
|
||||||
|
|
||||||
if ( window )
|
if ( window )
|
||||||
{
|
{
|
||||||
m_window = window;
|
m_window = window;
|
||||||
@@ -54,8 +47,8 @@ wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
|
|||||||
|
|
||||||
void wxGTKCairoDCImpl::InitSize(GdkWindow* window)
|
void wxGTKCairoDCImpl::InitSize(GdkWindow* window)
|
||||||
{
|
{
|
||||||
m_width = gdk_window_get_width(window);
|
m_size.x = gdk_window_get_width(window);
|
||||||
m_height = gdk_window_get_height(window);
|
m_size.y = gdk_window_get_height(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGTKCairoDCImpl::DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask)
|
void wxGTKCairoDCImpl::DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask)
|
||||||
@@ -122,9 +115,9 @@ bool wxGTKCairoDCImpl::DoGetPixel(int x, int y, wxColour* col) const
|
|||||||
void wxGTKCairoDCImpl::DoGetSize(int* width, int* height) const
|
void wxGTKCairoDCImpl::DoGetSize(int* width, int* height) const
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = m_width;
|
*width = m_size.x;
|
||||||
if (height)
|
if (height)
|
||||||
*height = m_height;
|
*height = m_size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGTKCairoDCImpl::DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask)
|
bool wxGTKCairoDCImpl::DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask)
|
||||||
@@ -279,15 +272,15 @@ wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
|
|||||||
int x, y;
|
int x, y;
|
||||||
if (gtk_widget_get_has_window(widget))
|
if (gtk_widget_get_has_window(widget))
|
||||||
{
|
{
|
||||||
m_width = gdk_window_get_width(gdkWindow);
|
m_size.x = gdk_window_get_width(gdkWindow);
|
||||||
m_height = gdk_window_get_height(gdkWindow);
|
m_size.y = gdk_window_get_height(gdkWindow);
|
||||||
x = m_width - a.width;
|
x = m_size.x - a.width;
|
||||||
y = m_height - a.height;
|
y = m_size.y - a.height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_width = a.width;
|
m_size.x = a.width;
|
||||||
m_height = a.height;
|
m_size.y = a.height;
|
||||||
x = a.x;
|
x = a.x;
|
||||||
y = a.y;
|
y = a.y;
|
||||||
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
|
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
|
||||||
@@ -322,15 +315,15 @@ wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
|
|||||||
SetGraphicsContext(gc);
|
SetGraphicsContext(gc);
|
||||||
if (gtk_widget_get_has_window(widget))
|
if (gtk_widget_get_has_window(widget))
|
||||||
{
|
{
|
||||||
m_width = gdk_window_get_width(gdkWindow);
|
m_size.x = gdk_window_get_width(gdkWindow);
|
||||||
m_height = gdk_window_get_height(gdkWindow);
|
m_size.y = gdk_window_get_height(gdkWindow);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkAllocation a;
|
GtkAllocation a;
|
||||||
gtk_widget_get_allocation(widget, &a);
|
gtk_widget_get_allocation(widget, &a);
|
||||||
m_width = a.width;
|
m_size.x = a.width;
|
||||||
m_height = a.height;
|
m_size.y = a.height;
|
||||||
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
|
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
|
||||||
cairo_clip(cr);
|
cairo_clip(cr);
|
||||||
SetDeviceLocalOrigin(a.x, a.y);
|
SetDeviceLocalOrigin(a.x, a.y);
|
||||||
@@ -419,8 +412,7 @@ void wxMemoryDCImpl::Setup()
|
|||||||
m_ok = m_bitmap.IsOk();
|
m_ok = m_bitmap.IsOk();
|
||||||
if (m_ok)
|
if (m_ok)
|
||||||
{
|
{
|
||||||
m_width = int(m_bitmap.GetScaledWidth());
|
m_size = m_bitmap.GetScaledSize();
|
||||||
m_height = int(m_bitmap.GetScaledHeight());
|
|
||||||
m_contentScaleFactor = m_bitmap.GetScaleFactor();
|
m_contentScaleFactor = m_bitmap.GetScaleFactor();
|
||||||
cairo_t* cr = m_bitmap.CairoCreate();
|
cairo_t* cr = m_bitmap.CairoCreate();
|
||||||
gc = wxGraphicsContext::CreateFromNative(cr);
|
gc = wxGraphicsContext::CreateFromNative(cr);
|
||||||
|
Reference in New Issue
Block a user