Remove dead code. Factor out duplicated code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// fwd declarations
|
// fwd declarations
|
||||||
// -----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxWindowDC;
|
class WXDLLEXPORT wxWindowDC;
|
||||||
class WXDLLEXPORT wxWindow;
|
class WXDLLEXPORT wxWindow;
|
||||||
@@ -141,11 +141,17 @@ protected:
|
|||||||
wxCoord xoffset, wxCoord yoffset,
|
wxCoord xoffset, wxCoord yoffset,
|
||||||
int fillStyle = wxODDEVEN_RULE);
|
int fillStyle = wxODDEVEN_RULE);
|
||||||
|
|
||||||
|
void DoGetSize( int *width, int *height ) const;
|
||||||
|
|
||||||
|
// common part of constructors
|
||||||
|
void Init();
|
||||||
|
|
||||||
WXGC m_gc;
|
WXGC m_gc;
|
||||||
WXGC m_gcBacking;
|
WXGC m_gcBacking;
|
||||||
WXDisplay* m_display;
|
WXDisplay* m_display;
|
||||||
wxWindow* m_window;
|
wxWindow* m_window;
|
||||||
WXRegion m_currentRegion; // Current clipping region (incl. paint clip region)
|
// Current clipping region (incl. paint clip region)
|
||||||
|
WXRegion m_currentRegion;
|
||||||
WXRegion m_userRegion; // User-defined clipping region
|
WXRegion m_userRegion; // User-defined clipping region
|
||||||
WXPixmap m_pixmap; // Pixmap for drawing on
|
WXPixmap m_pixmap; // Pixmap for drawing on
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ static int roundmin(double a, double b)
|
|||||||
// wxWindowDC
|
// wxWindowDC
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxWindowDC::wxWindowDC()
|
void wxWindowDC::Init()
|
||||||
{
|
{
|
||||||
m_gc = (WXGC) 0;
|
m_gc = (WXGC) 0;
|
||||||
m_gcBacking = (WXGC) 0;
|
m_gcBacking = (WXGC) 0;
|
||||||
@@ -138,7 +138,6 @@ wxWindowDC::wxWindowDC()
|
|||||||
m_currentPenDash = (wxX11Dash*) NULL;
|
m_currentPenDash = (wxX11Dash*) NULL;
|
||||||
m_currentStyle = -1;
|
m_currentStyle = -1;
|
||||||
m_currentFill = -1;
|
m_currentFill = -1;
|
||||||
// m_currentBkMode = wxTRANSPARENT;
|
|
||||||
m_colour = wxColourDisplay();
|
m_colour = wxColourDisplay();
|
||||||
m_display = (WXDisplay*) NULL;
|
m_display = (WXDisplay*) NULL;
|
||||||
m_currentRegion = (WXRegion) 0;
|
m_currentRegion = (WXRegion) 0;
|
||||||
@@ -146,29 +145,23 @@ wxWindowDC::wxWindowDC()
|
|||||||
m_pixmap = (WXPixmap) 0;
|
m_pixmap = (WXPixmap) 0;
|
||||||
m_autoSetting = 0;
|
m_autoSetting = 0;
|
||||||
m_oldFont = (WXFont) 0;
|
m_oldFont = (WXFont) 0;
|
||||||
|
m_ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWindowDC::wxWindowDC()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowDC::wxWindowDC( wxWindow *window )
|
wxWindowDC::wxWindowDC( wxWindow *window )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." );
|
wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." );
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
m_window = window;
|
m_window = window;
|
||||||
m_font = window->GetFont();
|
m_font = window->GetFont();
|
||||||
m_gc = (WXGC) 0;
|
|
||||||
m_gcBacking = (WXGC) 0;
|
|
||||||
m_backgroundPixel = -1;
|
|
||||||
m_currentPenWidth = 1;
|
|
||||||
m_currentPenJoin = -1;
|
|
||||||
m_currentPenDashCount = -1;
|
|
||||||
m_currentPenDash = (wxX11Dash*) NULL;
|
|
||||||
m_currentStyle = -1;
|
|
||||||
m_currentFill = -1;
|
|
||||||
// m_currentBkMode = wxTRANSPARENT;
|
|
||||||
m_colour = wxColourDisplay();
|
|
||||||
m_currentRegion = (WXRegion) 0;
|
|
||||||
m_userRegion = (WXRegion) 0;
|
|
||||||
m_ok = TRUE;
|
m_ok = TRUE;
|
||||||
m_autoSetting = 0;
|
|
||||||
|
|
||||||
m_display = window->GetXDisplay();
|
m_display = window->GetXDisplay();
|
||||||
m_pixmap = window->GetXWindow();
|
m_pixmap = window->GetXWindow();
|
||||||
@@ -260,8 +253,6 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
|||||||
|
|
||||||
int x1d, y1d, x2d, y2d;
|
int x1d, y1d, x2d, y2d;
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
x1d = XLOG2DEV(x1);
|
x1d = XLOG2DEV(x1);
|
||||||
y1d = YLOG2DEV(y1);
|
y1d = YLOG2DEV(y1);
|
||||||
x2d = XLOG2DEV(x2);
|
x2d = XLOG2DEV(x2);
|
||||||
@@ -314,8 +305,6 @@ void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCo
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
int xx1 = XLOG2DEV (x1);
|
int xx1 = XLOG2DEV (x1);
|
||||||
int yy1 = YLOG2DEV (y1);
|
int yy1 = YLOG2DEV (y1);
|
||||||
int xx2 = XLOG2DEV (x2);
|
int xx2 = XLOG2DEV (x2);
|
||||||
@@ -442,8 +431,6 @@ void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
if (m_pen.Ok() && m_autoSetting)
|
if (m_pen.Ok() && m_autoSetting)
|
||||||
SetPen (m_pen);
|
SetPen (m_pen);
|
||||||
|
|
||||||
@@ -458,8 +445,6 @@ void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
|
if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
if (m_autoSetting)
|
if (m_autoSetting)
|
||||||
@@ -493,8 +478,6 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[],
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
XPoint *xpoints1 = new XPoint[n + 1];
|
XPoint *xpoints1 = new XPoint[n + 1];
|
||||||
XPoint *xpoints2 = new XPoint[n + 1];
|
XPoint *xpoints2 = new XPoint[n + 1];
|
||||||
int i;
|
int i;
|
||||||
@@ -546,8 +529,6 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
int xd, yd, wfd, hfd, wd, hd;
|
int xd, yd, wfd, hfd, wd, hd;
|
||||||
|
|
||||||
xd = XLOG2DEV(x);
|
xd = XLOG2DEV(x);
|
||||||
@@ -591,8 +572,6 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
// If radius is negative, it's a proportion of the smaller dimension.
|
// If radius is negative, it's a proportion of the smaller dimension.
|
||||||
|
|
||||||
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
||||||
@@ -747,8 +726,6 @@ void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wx
|
|||||||
}
|
}
|
||||||
CalcBoundingBox (x, y);
|
CalcBoundingBox (x, y);
|
||||||
CalcBoundingBox (x + width, y + height);
|
CalcBoundingBox (x + width, y + height);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
|
void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
|
||||||
@@ -768,8 +745,6 @@ void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord hei
|
|||||||
width = - width ;
|
width = - width ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
static const int angle = 23040;
|
static const int angle = 23040;
|
||||||
|
|
||||||
int xd, yd, wd, hd;
|
int xd, yd, wd, hd;
|
||||||
@@ -813,66 +788,6 @@ bool wxWindowDC::CanDrawBitmap() const
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
|
|
||||||
{
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
// Be sure that foreground pixels (1) of
|
|
||||||
// the Icon will be painted with pen colour. [m_pen.SetColour()]
|
|
||||||
// Background pixels (0) will be painted with
|
|
||||||
// last selected background color. [::SetBackground]
|
|
||||||
if (m_pen.Ok() && m_autoSetting)
|
|
||||||
SetPen (m_pen);
|
|
||||||
|
|
||||||
int width, height;
|
|
||||||
Pixmap iconPixmap = (Pixmap) icon.GetDrawable();
|
|
||||||
width = icon.GetWidth();
|
|
||||||
height = icon.GetHeight();
|
|
||||||
if (icon.GetDisplay() == m_display)
|
|
||||||
{
|
|
||||||
if (icon.GetDepth() <= 1)
|
|
||||||
{
|
|
||||||
XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
|
|
||||||
0, 0, width, height,
|
|
||||||
(int) XLOG2DEV (x), (int) YLOG2DEV (y), 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
|
|
||||||
0, 0, width, height,
|
|
||||||
(int) XLOG2DEV (x), (int) YLOG2DEV (y));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (m_window && m_window->GetBackingPixmap())
|
|
||||||
{
|
|
||||||
if (icon.GetDepth() <= 1)
|
|
||||||
{
|
|
||||||
XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
|
|
||||||
0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
|
|
||||||
0, 0, width, height,
|
|
||||||
(int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { /* Remote copy (different (Display*) m_displays) */
|
|
||||||
XImage *cache = NULL;
|
|
||||||
if (m_window && m_window->GetBackingPixmap())
|
|
||||||
XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),
|
|
||||||
(GC) m_gcBacking, 0, 0, width, height,
|
|
||||||
(int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache);
|
|
||||||
XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
|
|
||||||
0, 0, width, height,
|
|
||||||
(int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
|
|
||||||
}
|
|
||||||
CalcBoundingBox (x, y);
|
|
||||||
}
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
|
// TODO: use scaled Blit e.g. as per John Price's implementation in Contrib/Utilities
|
||||||
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
||||||
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
|
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
|
||||||
@@ -884,8 +799,6 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
|||||||
|
|
||||||
wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." );
|
wxASSERT_MSG( sourceDC, "Blit source DC must be wxWindowDC or derived class." );
|
||||||
|
|
||||||
// FreeGetPixelCache();
|
|
||||||
|
|
||||||
// Be sure that foreground pixels (1) of the Icon will be painted with
|
// Be sure that foreground pixels (1) of the Icon will be painted with
|
||||||
// foreground colour. [m_textForegroundColour] Background pixels (0)
|
// foreground colour. [m_textForegroundColour] Background pixels (0)
|
||||||
// will be painted with backgound colour (m_textBackgroundColour)
|
// will be painted with backgound colour (m_textBackgroundColour)
|
||||||
@@ -1482,42 +1395,31 @@ wxCoord wxWindowDC::GetCharHeight() const
|
|||||||
return XDEV2LOGREL(ascent + descent);
|
return XDEV2LOGREL(ascent + descent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::Clear()
|
void wxWindowDC::DoGetSize( int *width, int *height ) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
int w = 0, h = 0;
|
||||||
|
|
||||||
int w, h;
|
|
||||||
if( m_window )
|
if( m_window )
|
||||||
{
|
{
|
||||||
m_window->GetSize(&w, &h);
|
if( m_window->GetBackingPixmap() )
|
||||||
|
|
||||||
if (m_window && m_window->GetBackingPixmap())
|
|
||||||
{
|
{
|
||||||
w = m_window->GetPixmapWidth();
|
w = m_window->GetPixmapWidth();
|
||||||
h = m_window->GetPixmapHeight();
|
h = m_window->GetPixmapHeight();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
m_window->GetSize( &w, &h );
|
||||||
if (this->IsKindOf(CLASSINFO(wxMemoryDC)))
|
|
||||||
{
|
|
||||||
wxMemoryDC* memDC = (wxMemoryDC*) this;
|
|
||||||
w = memDC->GetBitmap().GetWidth();
|
|
||||||
h = memDC->GetBitmap().GetHeight();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush saveBrush = m_brush;
|
if( width ) *width = w;
|
||||||
SetBrush (m_backgroundBrush);
|
if( height ) *height = h;
|
||||||
|
}
|
||||||
|
|
||||||
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h);
|
void wxWindowDC::Clear()
|
||||||
|
{
|
||||||
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
if (m_window && m_window->GetBackingPixmap())
|
wxRect rect( wxPoint( 0, 0 ), GetSize() );
|
||||||
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h);
|
Clear( rect );
|
||||||
|
|
||||||
m_brush = saveBrush;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::Clear(const wxRect& rect)
|
void wxWindowDC::Clear(const wxRect& rect)
|
||||||
@@ -1530,10 +1432,13 @@ void wxWindowDC::Clear(const wxRect& rect)
|
|||||||
wxBrush saveBrush = m_brush;
|
wxBrush saveBrush = m_brush;
|
||||||
SetBrush (m_backgroundBrush);
|
SetBrush (m_backgroundBrush);
|
||||||
|
|
||||||
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h);
|
XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
|
||||||
|
x, y, w, h);
|
||||||
|
|
||||||
if (m_window && m_window->GetBackingPixmap())
|
if (m_window && m_window->GetBackingPixmap())
|
||||||
XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h);
|
XFillRectangle ((Display*) m_display,
|
||||||
|
(Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
|
||||||
|
x, y, w, h);
|
||||||
|
|
||||||
m_brush = saveBrush;
|
m_brush = saveBrush;
|
||||||
}
|
}
|
||||||
@@ -2055,14 +1960,6 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
|
|||||||
|
|
||||||
m_backgroundPixel = m_backgroundBrush.GetColour().AllocColour(m_display);
|
m_backgroundPixel = m_backgroundBrush.GetColour().AllocColour(m_display);
|
||||||
|
|
||||||
// New behaviour, 10/2/99: setting the background brush of a DC
|
|
||||||
// doesn't affect the window background colour.
|
|
||||||
/*
|
|
||||||
// XSetWindowBackground doesn't work for non-Window pixmaps
|
|
||||||
if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
|
|
||||||
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
|
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
|
||||||
// And Blit,... (Any fct that use XCopyPlane, in fact.)
|
// And Blit,... (Any fct that use XCopyPlane, in fact.)
|
||||||
XSetBackground ((Display*) m_display, (GC) m_gc, m_backgroundPixel);
|
XSetBackground ((Display*) m_display, (GC) m_gc, m_backgroundPixel);
|
||||||
@@ -2150,23 +2047,14 @@ void wxWindowDC::SetTextForeground( const wxColour &col )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
if (m_textForegroundColour == col)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_textForegroundColour = col;
|
m_textForegroundColour = col;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::SetTextBackground( const wxColour &col )
|
void wxWindowDC::SetTextBackground( const wxColour &col )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid dc" );
|
wxCHECK_RET( Ok(), "invalid dc" );
|
||||||
|
|
||||||
if (m_textBackgroundColour == col)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_textBackgroundColour = col;
|
m_textBackgroundColour = col;
|
||||||
if (!m_textBackgroundColour.Ok())
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::SetBackgroundMode( int mode )
|
void wxWindowDC::SetBackgroundMode( int mode )
|
||||||
|
|||||||
Reference in New Issue
Block a user