X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0a2c03984a3c4d2b9e432db24eb4338ed797b933..d1f4723592a86208a941bd486a9c1f18f43b5f51:/contrib/src/ogl/basic2.cpp diff --git a/contrib/src/ogl/basic2.cpp b/contrib/src/ogl/basic2.cpp index d5eba29248..35c591720c 100644 --- a/contrib/src/ogl/basic2.cpp +++ b/contrib/src/ogl/basic2.cpp @@ -24,7 +24,9 @@ #include #endif +#if wxUSE_PROLOGIO #include +#endif #ifdef new #undef new @@ -34,13 +36,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include "wx/ogl/ogl.h" + // Control point types // Rectangle and most other shapes @@ -66,23 +63,31 @@ void wxPolygonShape::Create(wxList *the_points) { ClearPoints(); - m_originalPoints = the_points; - - // Duplicate the list of points - m_points = new wxList; - - wxNode *node = the_points->GetFirst(); - while (node) + if (!the_points) { - wxRealPoint *point = (wxRealPoint *)node->GetData(); - wxRealPoint *new_point = new wxRealPoint(point->x, point->y); - m_points->Append((wxObject*) new_point); - node = node->GetNext(); + m_originalPoints = new wxList; + m_points = new wxList; + } + else + { + m_originalPoints = the_points; + + // Duplicate the list of points + m_points = new wxList; + + wxNode *node = the_points->GetFirst(); + while (node) + { + wxRealPoint *point = (wxRealPoint *)node->GetData(); + wxRealPoint *new_point = new wxRealPoint(point->x, point->y); + m_points->Append((wxObject*) new_point); + node = node->GetNext(); + } + CalculateBoundingBox(); + m_originalWidth = m_boundWidth; + m_originalHeight = m_boundHeight; + SetDefaultRegionSize(); } - CalculateBoundingBox(); - m_originalWidth = m_boundWidth; - m_originalHeight = m_boundHeight; - SetDefaultRegionSize(); } wxPolygonShape::~wxPolygonShape() @@ -206,15 +211,12 @@ bool PolylineHitTest(double n, double xvec[], double yvec[], double line_ratio; double other_ratio; -// char buf[300]; for (i = 1; i < n; i++) { oglCheckLineIntersection(x1, y1, x2, y2, lastx, lasty, xvec[i], yvec[i], &line_ratio, &other_ratio); if (line_ratio != 1.0) isAHit = TRUE; -// sprintf(buf, "Line ratio = %.2f, other ratio = %.2f\n", line_ratio, other_ratio); -// ClipsErrorFunction(buf); lastx = xvec[i]; lasty = yvec[i]; @@ -229,13 +231,8 @@ bool PolylineHitTest(double n, double xvec[], double yvec[], &line_ratio, &other_ratio); if (line_ratio != 1.0) isAHit = TRUE; -// sprintf(buf, "Line ratio = %.2f, other ratio = %.2f\n", line_ratio, other_ratio); -// ClipsErrorFunction(buf); - if (line_ratio < min_ratio) - min_ratio = line_ratio; } -// ClipsErrorFunction("\n"); return isAHit; } @@ -323,7 +320,7 @@ bool wxPolygonShape::HitTest(double x, double y, int *attachment, double *distan // Really need to be able to reset the shape! Otherwise, if the // points ever go to zero, we've lost it, and can't resize. -void wxPolygonShape::SetSize(double new_width, double new_height, bool recursive) +void wxPolygonShape::SetSize(double new_width, double new_height, bool WXUNUSED(recursive)) { SetAttachmentSize(new_width, new_height); @@ -394,7 +391,7 @@ void wxPolygonShape::AddPolygonPoint(int pos) double y = (double)((secondPoint->y - firstPoint->y)/2.0 + firstPoint->y); wxRealPoint *point = new wxRealPoint(x, y); - if (pos >= (m_points->GetCount() - 1)) + if (pos >= (int) (m_points->GetCount() - 1)) m_points->Append((wxObject*) point); else m_points->Insert(node2, (wxObject*) point); @@ -782,7 +779,7 @@ int wxPolygonShape::GetNumberOfAttachments() const bool wxPolygonShape::GetAttachmentPosition(int attachment, double *x, double *y, int nth, int no_arcs, wxLineShape *line) { - if ((m_attachmentMode == ATTACHMENT_MODE_EDGE) && m_points && attachment < m_points->GetCount()) + if ((m_attachmentMode == ATTACHMENT_MODE_EDGE) && m_points && attachment < (int) m_points->GetCount()) { wxRealPoint *point = (wxRealPoint *)m_points->Item(attachment)->GetData(); *x = point->x + m_xpos; @@ -798,7 +795,7 @@ bool wxPolygonShape::AttachmentIsValid(int attachment) const if (!m_points) return FALSE; - if ((attachment >= 0) && (attachment < m_points->GetCount())) + if ((attachment >= 0) && (attachment < (int) m_points->GetCount())) return TRUE; wxNode *node = m_attachmentPoints.GetFirst(); @@ -909,7 +906,7 @@ void wxRectangleShape::GetBoundingBoxMin(double *the_width, double *the_height) *the_height = m_height; } -void wxRectangleShape::SetSize(double x, double y, bool recursive) +void wxRectangleShape::SetSize(double x, double y, bool WXUNUSED(recursive)) { SetAttachmentSize(x, y); m_width = (double)wxMax(x, 1.0); @@ -923,7 +920,7 @@ void wxRectangleShape::SetCornerRadius(double rad) } // Assume (x1, y1) is centre of box (most generally, line end at box) -bool wxRectangleShape::GetPerimeterPoint(double x1, double y1, +bool wxRectangleShape::GetPerimeterPoint(double WXUNUSED(x1), double WXUNUSED(y1), double x2, double y2, double *x3, double *y3) { @@ -998,7 +995,7 @@ wxTextShape::wxTextShape(double width, double height): { } -void wxTextShape::OnDraw(wxDC& dc) +void wxTextShape::OnDraw(wxDC& WXUNUSED(dc)) { } @@ -1066,7 +1063,7 @@ void wxEllipseShape::OnDraw(wxDC& dc) dc.DrawEllipse((long) (m_xpos - GetWidth()/2), (long) (m_ypos - GetHeight()/2), (long) GetWidth(), (long) GetHeight()); } -void wxEllipseShape::SetSize(double x, double y, bool recursive) +void wxEllipseShape::SetSize(double x, double y, bool WXUNUSED(recursive)) { SetAttachmentSize(x, y); m_width = x; @@ -1178,7 +1175,6 @@ bool wxEllipseShape::GetAttachmentPosition(int attachment, double *x, double *y, default: { return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs, line); - break; } } return TRUE; @@ -1201,7 +1197,7 @@ void wxCircleShape::Copy(wxShape& copy) wxEllipseShape::Copy(copy); } -bool wxCircleShape::GetPerimeterPoint(double x1, double y1, +bool wxCircleShape::GetPerimeterPoint(double WXUNUSED(x1), double WXUNUSED(y1), double x2, double y2, double *x3, double *y3) { @@ -1245,7 +1241,7 @@ wxControlPoint::~wxControlPoint() } // Don't even attempt to draw any text - waste of time! -void wxControlPoint::OnDrawContents(wxDC& dc) +void wxControlPoint::OnDrawContents(wxDC& WXUNUSED(dc)) { } @@ -1282,8 +1278,8 @@ int wxControlPoint::GetNumberOfAttachments() const return 1; } -bool wxControlPoint::GetAttachmentPosition(int attachment, double *x, double *y, - int nth, int no_arcs, wxLineShape *line) +bool wxControlPoint::GetAttachmentPosition(int WXUNUSED(attachment), double *x, double *y, + int WXUNUSED(nth), int WXUNUSED(no_arcs), wxLineShape *WXUNUSED(line)) { *x = m_xpos; *y = m_ypos; return TRUE; @@ -1291,7 +1287,7 @@ bool wxControlPoint::GetAttachmentPosition(int attachment, double *x, double *y, // Control points ('handles') redirect control to the actual shape, to make it easier // to override sizing behaviour. -void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment) +void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool WXUNUSED(draw), double x, double y, int keys, int WXUNUSED(attachment)) { double bound_x; double bound_y; @@ -1398,7 +1394,7 @@ void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y } } -void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) +void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int WXUNUSED(attachment)) { m_canvas->CaptureMouse(); @@ -1530,7 +1526,7 @@ void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int } } -void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) +void wxShape::OnSizingEndDragLeft(wxControlPoint* pt, double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys), int WXUNUSED(attachment)) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); @@ -1627,7 +1623,7 @@ void wxPolygonControlPoint::OnEndDragLeft(double x, double y, int keys, int atta // Control points ('handles') redirect control to the actual shape, to make it easier // to override sizing behaviour. -void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment) +void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt; @@ -1640,7 +1636,7 @@ void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, d dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); - if (0) // keys & KEY_CTRL) + #if 0 // keys & KEY_CTRL) { // TODO: mend this code. Currently we rely on altering the // actual points, but we should assume we're not, as per @@ -1655,16 +1651,17 @@ void wxPolygonShape::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, d ((wxPolygonShape *)this)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculatePolygonCentre(); } - else + #else { ppt->CalculateNewSize(x, y); } + #endif this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), ppt->GetNewSize().x, ppt->GetNewSize().y); } -void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) +void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt; @@ -1691,7 +1688,7 @@ void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); - if (0) // keys & KEY_CTRL) + #if 0 // keys & KEY_CTRL) { // TODO: mend this code. Currently we rely on altering the // actual points, but we should assume we're not, as per @@ -1706,10 +1703,11 @@ void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double ((wxPolygonShape *)this)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculatePolygonCentre(); } - else + #else { ppt->CalculateNewSize(x, y); } + #endif this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), ppt->GetNewSize().x, ppt->GetNewSize().y); @@ -1717,7 +1715,7 @@ void wxPolygonShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double m_canvas->CaptureMouse(); } -void wxPolygonShape::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) +void wxPolygonShape::OnSizingEndDragLeft(wxControlPoint* pt, double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment)) { wxPolygonControlPoint* ppt = (wxPolygonControlPoint*) pt; @@ -1771,7 +1769,7 @@ wxShapeRegion::wxShapeRegion() m_textColour = wxT("BLACK"); m_penColour = wxT("BLACK"); m_penStyle = wxSOLID; - m_actualColourObject = NULL; + m_actualColourObject = wxTheColourDatabase->Find(wxT("BLACK")); m_actualPenObject = NULL; } @@ -1792,7 +1790,7 @@ wxShapeRegion::wxShapeRegion(wxShapeRegion& region) m_regionProportionX = region.m_regionProportionX; m_regionProportionY = region.m_regionProportionY; m_formatMode = region.m_formatMode; - m_actualColourObject = NULL; + m_actualColourObject = region.m_actualColourObject; m_actualPenObject = NULL; m_penStyle = region.m_penStyle; m_penColour = region.m_penColour; @@ -1864,15 +1862,12 @@ void wxShapeRegion::SetFormatMode(int mode) void wxShapeRegion::SetColour(const wxString& col) { m_textColour = col; - m_actualColourObject = NULL; + m_actualColourObject = col; } -wxColour *wxShapeRegion::GetActualColourObject() +wxColour wxShapeRegion::GetActualColourObject() { - if (!m_actualColourObject) - m_actualColourObject = wxTheColourDatabase->FindColour(GetColour()); - if (!m_actualColourObject) - m_actualColourObject = wxBLACK; + m_actualColourObject = wxTheColourDatabase->Find(GetColour()); return m_actualColourObject; }