// 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;
// Give it a list of points, finds the centre.
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 *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);
-void oglFindEndForBox(double width, double height,
+void oglFindEndForBox(double width, double height,
double x1, double y1, // Centre of box (possibly)
double x2, double y2, // other end of line
double *x3, double *y3); // End on box edge
-void oglFindEndForCircle(double radius,
+void oglFindEndForCircle(double radius,
double x1, double y1, // Centre of circle
double x2, double y2, // Other end of line
double *x3, double *y3);
* 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
* 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.
* Author: Ian Harrison
*/
extern wxPen* g_oglTransparentPen;
extern wxBrush* g_oglWhiteBackgroundBrush;
extern wxPen* g_oglBlackForegroundPen;
-extern wxCursor* g_oglBullseyeCursor;
extern wxFont* oglMatchFont(int point_size);
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));
}
}
}
+
+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;
+}
+
#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)
// 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());
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());
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);
}
{
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);
}
// 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.
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;
}
}
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;
}
}
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;
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();
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_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_oglNormalFont = NULL; // These will be cleaned up by their GDI list
+ g_oglBlackPen = NULL;
+ g_oglTransparentPen = NULL;
+ g_oglBlackForegroundPen = NULL;
+ g_oglWhiteBackgroundPen = NULL;
+ g_oglWhiteBackgroundBrush = NULL;
OGLCleanUpConstraintTypes();
}