Shapes will now draw the right background color when erased if the

canvas is not white.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12715 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-11-27 00:35:36 +00:00
parent fd008b87e3
commit 67d54b58cb
6 changed files with 62 additions and 69 deletions

View File

@@ -515,6 +515,11 @@ class wxShape: public wxShapeEvtHandler
// Clears points from a list of wxRealPoints
void ClearPointList(wxList& list);
// Return pen or brush of the right colour for the background
wxPen GetBackgroundPen();
wxBrush GetBackgroundBrush();
private:
wxObject* m_clientData;

View File

@@ -99,7 +99,6 @@ extern wxPen* g_oglWhiteBackgroundPen;
extern wxPen* g_oglTransparentPen;
extern wxBrush* g_oglWhiteBackgroundBrush;
extern wxPen* g_oglBlackForegroundPen;
extern wxCursor* g_oglBullseyeCursor;
extern wxFont* oglMatchFont(int point_size);

View File

@@ -997,8 +997,9 @@ void wxShape::OnEraseContents(wxDC& dc)
if (m_pen)
penWidth = m_pen->GetWidth();
dc.SetPen(* g_oglWhiteBackgroundPen);
dc.SetBrush(* g_oglWhiteBackgroundBrush);
dc.SetPen(GetBackgroundPen());
dc.SetBrush(GetBackgroundBrush());
dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth),
WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0));
}
@@ -3281,3 +3282,25 @@ void wxShape::Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta)
}
}
wxPen wxShape::GetBackgroundPen()
{
if (GetCanvas())
{
wxColour c = GetCanvas()->GetBackgroundColour();
return wxPen(c, 1, wxSOLID);
}
return * g_oglWhiteBackgroundPen;
}
wxBrush wxShape::GetBackgroundBrush()
{
if (GetCanvas())
{
wxColour c = GetCanvas()->GetBackgroundColour();
return wxBrush(c, wxSOLID);
}
return * g_oglWhiteBackgroundBrush;
}

View File

@@ -61,8 +61,6 @@
#define CONTROL_POINT_ENDPOINT_FROM 5
#define CONTROL_POINT_LINE 6
extern wxCursor *g_oglBullseyeCursor;
IMPLEMENT_DYNAMIC_CLASS(wxShapeCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(wxShapeCanvas, wxScrolledWindow)

View File

@@ -288,8 +288,8 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y
// First, clear a rectangle for the text IF there is any
if (region->GetFormattedText().Number() > 0)
{
dc.SetPen(* g_oglWhiteBackgroundPen);
dc.SetBrush(* g_oglWhiteBackgroundBrush);
dc.SetPen(GetBackgroundPen());
dc.SetBrush(GetBackgroundBrush());
// Now draw the text
if (region->GetFont()) dc.SetFont(* region->GetFont());
@@ -300,7 +300,7 @@ void wxLineShape::DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y
dc.SetTextForeground(* region->GetActualColourObject());
#ifdef __WXMSW__
dc.SetTextBackground(g_oglWhiteBackgroundBrush->GetColour());
dc.SetTextBackground(GetBackgroundBrush().GetColour());
#endif
oglDrawFormattedText(dc, &(region->GetFormattedText()), xp, yp, w, h, region->GetFormatMode());
@@ -324,8 +324,8 @@ void wxLineShape::EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double
if (region->GetFormattedText().Number() > 0)
{
dc.SetPen(* g_oglWhiteBackgroundPen);
dc.SetBrush(* g_oglWhiteBackgroundBrush);
dc.SetPen(GetBackgroundPen());
dc.SetBrush(GetBackgroundBrush());
dc.DrawRectangle((long)(xp - w/2.0), (long)(yp - h/2.0), (long)w, (long)h);
}
@@ -853,8 +853,10 @@ void wxLineShape::OnErase(wxDC& dc)
{
wxPen *old_pen = m_pen;
wxBrush *old_brush = m_brush;
SetPen(g_oglWhiteBackgroundPen);
SetBrush(g_oglWhiteBackgroundBrush);
wxPen bg_pen = GetBackgroundPen();
wxBrush bg_brush = GetBackgroundBrush();
SetPen(&bg_pen);
SetBrush(&bg_brush);
double bound_x, bound_y;
GetBoundingBoxMax(&bound_x, &bound_y);
@@ -874,8 +876,8 @@ void wxLineShape::OnErase(wxDC& dc)
}
// Undraw line
dc.SetPen(* g_oglWhiteBackgroundPen);
dc.SetBrush(* g_oglWhiteBackgroundBrush);
dc.SetPen(GetBackgroundPen());
dc.SetBrush(GetBackgroundBrush());
// Drawing over the line only seems to work if the line has a thickness
// of 1.
@@ -1817,7 +1819,7 @@ void wxLineShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y,
if (lpt->m_type == CONTROL_POINT_ENDPOINT_FROM || lpt->m_type == CONTROL_POINT_ENDPOINT_TO)
{
m_canvas->SetCursor(* g_oglBullseyeCursor);
m_canvas->SetCursor(wxCursor(wxCURSOR_BULLSEYE));
lpt->m_oldCursor = wxSTANDARD_CURSOR;
}
}
@@ -1933,7 +1935,7 @@ void wxLineControlPoint::OnBeginDragRight(double x, double y, int keys, int atta
lineShape->GetTo()->GetEventHandler()->OnDraw(dc);
lineShape->GetTo()->GetEventHandler()->OnDrawContents(dc);
}
m_canvas->SetCursor(g_oglBullseyeCursor);
m_canvas->SetCursor(wxCursor(wxCURSOR_BULLSEYE));
m_oldCursor = wxSTANDARD_CURSOR;
}
}

View File

@@ -49,11 +49,10 @@
wxFont* g_oglNormalFont;
wxPen* g_oglBlackPen;
wxPen* g_oglWhiteBackgroundPen;
wxPen* g_oglTransparentPen;
wxBrush* g_oglWhiteBackgroundBrush;
wxPen* g_oglBlackForegroundPen;
wxCursor* g_oglBullseyeCursor = NULL;
wxPen* g_oglWhiteBackgroundPen;
wxBrush* g_oglWhiteBackgroundBrush;
char* oglBuffer = NULL;
@@ -63,16 +62,12 @@ wxList oglObjectCopyMapping(wxKEY_INTEGER);
void wxOGLInitialize()
{
g_oglBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
g_oglNormalFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
g_oglBlackPen = new wxPen("BLACK", 1, wxSOLID);
g_oglWhiteBackgroundPen = new wxPen("WHITE", 1, wxSOLID);
g_oglTransparentPen = new wxPen("WHITE", 1, wxTRANSPARENT);
g_oglWhiteBackgroundBrush = new wxBrush("WHITE", wxSOLID);
g_oglBlackForegroundPen = new wxPen("BLACK", 1, wxSOLID);
g_oglNormalFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
g_oglBlackPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
g_oglTransparentPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxTRANSPARENT);
g_oglBlackForegroundPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
g_oglWhiteBackgroundPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxSOLID);
g_oglWhiteBackgroundBrush = wxTheBrushList->FindOrCreateBrush("WHITE", wxSOLID);
OGLInitializeConstraintTypes();
@@ -89,42 +84,13 @@ void wxOGLCleanUp()
oglBuffer = NULL;
}
oglBuffer = NULL;
if (g_oglBullseyeCursor)
{
delete g_oglBullseyeCursor;
g_oglBullseyeCursor = NULL;
}
if (g_oglNormalFont)
{
delete g_oglNormalFont;
g_oglNormalFont = NULL;
}
if (g_oglBlackPen)
{
delete g_oglBlackPen;
g_oglNormalFont = NULL; // These will be cleaned up by their GDI list
g_oglBlackPen = NULL;
}
if (g_oglWhiteBackgroundPen)
{
delete g_oglWhiteBackgroundPen;
g_oglWhiteBackgroundPen = NULL;
}
if (g_oglTransparentPen)
{
delete g_oglTransparentPen;
g_oglTransparentPen = NULL;
}
if (g_oglWhiteBackgroundBrush)
{
delete g_oglWhiteBackgroundBrush;
g_oglWhiteBackgroundBrush = NULL;
}
if (g_oglBlackForegroundPen)
{
delete g_oglBlackForegroundPen;
g_oglBlackForegroundPen = NULL;
}
g_oglWhiteBackgroundPen = NULL;
g_oglWhiteBackgroundBrush = NULL;
OGLCleanUpConstraintTypes();
}