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 // Clears points from a list of wxRealPoints
void ClearPointList(wxList& list); void ClearPointList(wxList& list);
// Return pen or brush of the right colour for the background
wxPen GetBackgroundPen();
wxBrush GetBackgroundBrush();
private: private:
wxObject* m_clientData; wxObject* m_clientData;

View File

@@ -53,20 +53,20 @@ void oglDrawFormattedText(wxDC& context, wxList *text_list,
// Give it a list of points, finds the centre. // Give it a list of points, finds the centre.
void oglFindPolylineCentroid(wxList *points, double *x, double *y); void oglFindPolylineCentroid(wxList *points, double *x, double *y);
void oglCheckLineIntersection(double x1, double y1, double x2, double y2, void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4, double x3, double y3, double x4, double y4,
double *ratio1, double *ratio2); double *ratio1, double *ratio2);
void oglFindEndForPolyline(double n, double xvec[], double yvec[], void oglFindEndForPolyline(double n, double xvec[], double yvec[],
double x1, double y1, double x2, double y2, double *x3, double *y3); double x1, double y1, double x2, double y2, double *x3, double *y3);
void oglFindEndForBox(double width, double height, void oglFindEndForBox(double width, double height,
double x1, double y1, // Centre of box (possibly) double x1, double y1, // Centre of box (possibly)
double x2, double y2, // other end of line double x2, double y2, // other end of line
double *x3, double *y3); // End on box edge double *x3, double *y3); // End on box edge
void oglFindEndForCircle(double radius, void oglFindEndForCircle(double radius,
double x1, double y1, // Centre of circle double x1, double y1, // Centre of circle
double x2, double y2, // Other end of line double x2, double y2, // Other end of line
double *x3, double *y3); double *x3, double *y3);
@@ -83,7 +83,7 @@ void oglGetArrowPoints(double x1, double y1, double x2, double y2,
* This function assumes that the centre of the ellipse is at x1, y1, and the * This function assumes that the centre of the ellipse is at x1, y1, and the
* ellipse has a width of a1 and a height of b1. It also assumes you are * ellipse has a width of a1 and a height of b1. It also assumes you are
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3. * wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
* This function calculates the x,y coordinates of the intersection point of * This function calculates the x,y coordinates of the intersection point of
* the arc with the ellipse. * the arc with the ellipse.
* Author: Ian Harrison * Author: Ian Harrison
*/ */
@@ -99,7 +99,6 @@ extern wxPen* g_oglWhiteBackgroundPen;
extern wxPen* g_oglTransparentPen; extern wxPen* g_oglTransparentPen;
extern wxBrush* g_oglWhiteBackgroundBrush; extern wxBrush* g_oglWhiteBackgroundBrush;
extern wxPen* g_oglBlackForegroundPen; extern wxPen* g_oglBlackForegroundPen;
extern wxCursor* g_oglBullseyeCursor;
extern wxFont* oglMatchFont(int point_size); extern wxFont* oglMatchFont(int point_size);

View File

@@ -997,8 +997,9 @@ void wxShape::OnEraseContents(wxDC& dc)
if (m_pen) if (m_pen)
penWidth = m_pen->GetWidth(); penWidth = m_pen->GetWidth();
dc.SetPen(* g_oglWhiteBackgroundPen); dc.SetPen(GetBackgroundPen());
dc.SetBrush(* g_oglWhiteBackgroundBrush); dc.SetBrush(GetBackgroundBrush());
dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth), dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth),
WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0)); 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_ENDPOINT_FROM 5
#define CONTROL_POINT_LINE 6 #define CONTROL_POINT_LINE 6
extern wxCursor *g_oglBullseyeCursor;
IMPLEMENT_DYNAMIC_CLASS(wxShapeCanvas, wxScrolledWindow) IMPLEMENT_DYNAMIC_CLASS(wxShapeCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(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 // First, clear a rectangle for the text IF there is any
if (region->GetFormattedText().Number() > 0) if (region->GetFormattedText().Number() > 0)
{ {
dc.SetPen(* g_oglWhiteBackgroundPen); dc.SetPen(GetBackgroundPen());
dc.SetBrush(* g_oglWhiteBackgroundBrush); dc.SetBrush(GetBackgroundBrush());
// Now draw the text // Now draw the text
if (region->GetFont()) dc.SetFont(* region->GetFont()); 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()); dc.SetTextForeground(* region->GetActualColourObject());
#ifdef __WXMSW__ #ifdef __WXMSW__
dc.SetTextBackground(g_oglWhiteBackgroundBrush->GetColour()); dc.SetTextBackground(GetBackgroundBrush().GetColour());
#endif #endif
oglDrawFormattedText(dc, &(region->GetFormattedText()), xp, yp, w, h, region->GetFormatMode()); 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) if (region->GetFormattedText().Number() > 0)
{ {
dc.SetPen(* g_oglWhiteBackgroundPen); dc.SetPen(GetBackgroundPen());
dc.SetBrush(* g_oglWhiteBackgroundBrush); dc.SetBrush(GetBackgroundBrush());
dc.DrawRectangle((long)(xp - w/2.0), (long)(yp - h/2.0), (long)w, (long)h); 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; wxPen *old_pen = m_pen;
wxBrush *old_brush = m_brush; wxBrush *old_brush = m_brush;
SetPen(g_oglWhiteBackgroundPen); wxPen bg_pen = GetBackgroundPen();
SetBrush(g_oglWhiteBackgroundBrush); wxBrush bg_brush = GetBackgroundBrush();
SetPen(&bg_pen);
SetBrush(&bg_brush);
double bound_x, bound_y; double bound_x, bound_y;
GetBoundingBoxMax(&bound_x, &bound_y); GetBoundingBoxMax(&bound_x, &bound_y);
@@ -874,8 +876,8 @@ void wxLineShape::OnErase(wxDC& dc)
} }
// Undraw line // Undraw line
dc.SetPen(* g_oglWhiteBackgroundPen); dc.SetPen(GetBackgroundPen());
dc.SetBrush(* g_oglWhiteBackgroundBrush); dc.SetBrush(GetBackgroundBrush());
// Drawing over the line only seems to work if the line has a thickness // Drawing over the line only seems to work if the line has a thickness
// of 1. // 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) 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; 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()->OnDraw(dc);
lineShape->GetTo()->GetEventHandler()->OnDrawContents(dc); lineShape->GetTo()->GetEventHandler()->OnDrawContents(dc);
} }
m_canvas->SetCursor(g_oglBullseyeCursor); m_canvas->SetCursor(wxCursor(wxCURSOR_BULLSEYE));
m_oldCursor = wxSTANDARD_CURSOR; m_oldCursor = wxSTANDARD_CURSOR;
} }
} }

View File

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