X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/92a19c2e7757ba742846f83e56356de0a607bdc2..e6b1317b7903e4802f4bab2b7540600340361061:/contrib/src/ogl/divided.cpp?ds=sidebyside diff --git a/contrib/src/ogl/divided.cpp b/contrib/src/ogl/divided.cpp index 16cbc34878..a84d56973e 100644 --- a/contrib/src/ogl/divided.cpp +++ b/contrib/src/ogl/divided.cpp @@ -6,13 +6,9 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "divided.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -21,17 +17,15 @@ #endif #ifndef WX_PRECOMP -#include +#include "wx/wx.h" #endif -#include +#if wxUSE_PROLOGIO +#include "wx/deprecated/wxexpr.h" +#endif + +#include "wx/ogl/ogl.h" -#include -#include -#include -#include -#include -#include class wxDividedShapeControlPoint: public wxControlPoint { @@ -74,7 +68,7 @@ void wxDividedShape::OnDraw(wxDC& dc) void wxDividedShape::OnDrawContents(wxDC& dc) { - double defaultProportion = (double)(GetRegions().Number() > 0 ? (1.0/((double)(GetRegions().Number()))) : 0.0); + double defaultProportion = (double)(GetRegions().GetCount() > 0 ? (1.0/((double)(GetRegions().GetCount()))) : 0.0); double currentY = (double)(m_ypos - (m_height / 2.0)); double maxY = (double)(m_ypos + (m_height / 2.0)); @@ -83,7 +77,7 @@ void wxDividedShape::OnDrawContents(wxDC& dc) if (m_pen) dc.SetPen(* m_pen); - if (m_textColour) dc.SetTextForeground(* m_textColour); + dc.SetTextForeground(m_textColour); #ifdef __WXMSW__ // For efficiency, don't do this under X - doesn't make @@ -95,7 +89,7 @@ void wxDividedShape::OnDrawContents(wxDC& dc) if (!formatted) { FormatRegionText(); - formatted = TRUE; + formatted = true; } */ if (GetDisableLabel()) return; @@ -104,12 +98,12 @@ void wxDividedShape::OnDrawContents(wxDC& dc) double yMargin = 2; dc.SetBackgroundMode(wxTRANSPARENT); - wxNode *node = GetRegions().First(); + wxObjectList::compatibility_iterator node = GetRegions().GetFirst(); while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); dc.SetFont(* region->GetFont()); - dc.SetTextForeground(* region->GetActualColourObject()); + dc.SetTextForeground(region->GetActualColourObject()); double proportion = region->m_regionProportionY < 0.0 ? defaultProportion : region->m_regionProportionY; @@ -123,7 +117,7 @@ void wxDividedShape::OnDrawContents(wxDC& dc) oglDrawFormattedText(dc, ®ion->m_formattedText, (double)(centreX), (double)(centreY), (double)(m_width-2*xMargin), (double)(actualY - currentY - 2*yMargin), region->m_formatMode); - if ((y <= maxY) && (node->Next())) + if ((y <= maxY) && (node->GetNext())) { wxPen *regionPen = region->GetActualPen(); if (regionPen) @@ -135,11 +129,11 @@ void wxDividedShape::OnDrawContents(wxDC& dc) currentY = actualY; - node = node->Next(); + node = node->GetNext(); } } -void wxDividedShape::SetSize(double w, double h, bool recursive) +void wxDividedShape::SetSize(double w, double h, bool WXUNUSED(recursive)) { SetAttachmentSize(w, h); m_width = w; @@ -149,20 +143,20 @@ void wxDividedShape::SetSize(double w, double h, bool recursive) void wxDividedShape::SetRegionSizes() { - if (GetRegions().Number() == 0) + if (GetRegions().GetCount() == 0) return; - double defaultProportion = (double)(GetRegions().Number() > 0 ? (1.0/((double)(GetRegions().Number()))) : 0.0); + double defaultProportion = (double)(GetRegions().GetCount() > 0 ? (1.0/((double)(GetRegions().GetCount()))) : 0.0); double currentY = (double)(m_ypos - (m_height / 2.0)); double maxY = (double)(m_ypos + (m_height / 2.0)); // double leftX = (double)(m_xpos - (m_width / 2.0)); // double rightX = (double)(m_xpos + (m_width / 2.0)); - wxNode *node = GetRegions().First(); + wxObjectList::compatibility_iterator node = GetRegions().GetFirst(); while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); double proportion = region->m_regionProportionY <= 0.0 ? defaultProportion : region->m_regionProportionY; @@ -175,7 +169,7 @@ void wxDividedShape::SetRegionSizes() region->SetSize(m_width, sizeY); region->SetPosition(0.0, (double)(centreY - m_ypos)); currentY = actualY; - node = node->Next(); + node = node->GetNext(); } } @@ -183,13 +177,13 @@ void wxDividedShape::SetRegionSizes() bool wxDividedShape::GetAttachmentPosition(int attachment, double *x, double *y, int nth, int no_arcs, wxLineShape *line) { - int totalNumberAttachments = (GetRegions().Number() * 2) + 2; + int totalNumberAttachments = (GetRegions().GetCount() * 2) + 2; if ((GetAttachmentMode() == ATTACHMENT_MODE_NONE) || (attachment >= totalNumberAttachments)) { return wxShape::GetAttachmentPosition(attachment, x, y, nth, no_arcs); } - int n = GetRegions().Number(); + int n = GetRegions().GetCount(); bool isEnd = (line && line->IsEnd(this)); double left = (double)(m_xpos - m_width/2.0); @@ -245,22 +239,12 @@ bool wxDividedShape::GetAttachmentPosition(int attachment, double *x, double *y, // Left or right. else { - int i = 0; - bool isLeft = FALSE; - if (attachment < (n+1)) - { - i = attachment-1; - isLeft = FALSE; - } - else - { - i = (totalNumberAttachments - attachment - 1); - isLeft = TRUE; - } - wxNode *node = GetRegions().Nth(i); + bool isLeft = !(attachment < (n+1)); + int i = (isLeft) ? (totalNumberAttachments - attachment - 1) : (attachment-1); + wxObjectList::compatibility_iterator node = GetRegions().Item(i); if (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); if (isLeft) *x = left; @@ -297,41 +281,41 @@ bool wxDividedShape::GetAttachmentPosition(int attachment, double *x, double *y, { *x = m_xpos; *y = m_ypos; - return FALSE; + return false; } } - return TRUE; + return true; } int wxDividedShape::GetNumberOfAttachments() const { // There are two attachments for each region (left and right), // plus one on the top and one on the bottom. - int n = (GetRegions().Number() * 2) + 2; + int n = (GetRegions().GetCount() * 2) + 2; int maxN = n - 1; - wxNode *node = m_attachmentPoints.First(); + wxObjectList::compatibility_iterator node = m_attachmentPoints.GetFirst(); while (node) { - wxAttachmentPoint *point = (wxAttachmentPoint *)node->Data(); + wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); if (point->m_id > maxN) maxN = point->m_id; - node = node->Next(); + node = node->GetNext(); } return maxN + 1; } -bool wxDividedShape::AttachmentIsValid(int attachment) +bool wxDividedShape::AttachmentIsValid(int attachment) const { - int totalNumberAttachments = (GetRegions().Number() * 2) + 2; + int totalNumberAttachments = (GetRegions().GetCount() * 2) + 2; if (attachment >= totalNumberAttachments) { return wxShape::AttachmentIsValid(attachment); } else if (attachment >= 0) - return TRUE; + return true; else - return FALSE; + return false; } void wxDividedShape::Copy(wxShape& copy) @@ -353,18 +337,18 @@ void wxDividedShape::MakeMandatoryControlPoints() double currentY = (double)(GetY() - (m_height / 2.0)); double maxY = (double)(GetY() + (m_height / 2.0)); - wxNode *node = GetRegions().First(); + wxObjectList::compatibility_iterator node = GetRegions().GetFirst(); int i = 0; while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); double proportion = region->m_regionProportionY; double y = currentY + m_height*proportion; double actualY = (double)(maxY < y ? maxY : y); - if (node->Next()) + if (node->GetNext()) { wxDividedShapeControlPoint *controlPoint = new wxDividedShapeControlPoint(m_canvas, this, i, CONTROL_POINT_SIZE, 0.0, (double)(actualY - GetY()), 0); @@ -373,14 +357,14 @@ void wxDividedShape::MakeMandatoryControlPoints() } currentY = actualY; i ++; - node = node->Next(); + node = node->GetNext(); } } void wxDividedShape::ResetControlPoints() { // May only have the region handles, (n - 1) of them. - if (m_controlPoints.Number() > (GetRegions().Number() - 1)) + if (m_controlPoints.GetCount() > (GetRegions().GetCount() - 1)) wxRectangleShape::ResetControlPoints(); ResetMandatoryControlPoints(); @@ -391,15 +375,15 @@ void wxDividedShape::ResetMandatoryControlPoints() double currentY = (double)(GetY() - (m_height / 2.0)); double maxY = (double)(GetY() + (m_height / 2.0)); - wxNode *node = m_controlPoints.First(); + wxObjectList::compatibility_iterator node = m_controlPoints.GetFirst(); int i = 0; while (node) { - wxControlPoint *controlPoint = (wxControlPoint *)node->Data(); + wxControlPoint *controlPoint = (wxControlPoint *)node->GetData(); if (controlPoint->IsKindOf(CLASSINFO(wxDividedShapeControlPoint))) { - wxNode *node1 = GetRegions().Nth(i); - wxShapeRegion *region = (wxShapeRegion *)node1->Data(); + wxObjectList::compatibility_iterator node1 = GetRegions().Item(i); + wxShapeRegion *region = (wxShapeRegion *)node1->GetData(); double proportion = region->m_regionProportionY; @@ -411,11 +395,11 @@ void wxDividedShape::ResetMandatoryControlPoints() currentY = actualY; i ++; } - node = node->Next(); + node = node->GetNext(); } } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO void wxDividedShape::WriteAttributes(wxExpr *clause) { wxRectangleShape::WriteAttributes(clause); @@ -434,11 +418,11 @@ void wxDividedShape::ReadAttributes(wxExpr *clause) void wxDividedShape::EditRegions() { - wxMessageBox("EditRegions() is unimplemented.", "OGL", wxOK); + wxMessageBox(wxT("EditRegions() is unimplemented."), wxT("OGL"), wxOK); // TODO #if 0 - if (GetRegions().Number() < 2) + if (GetRegions().GetCount() < 2) return; wxBeginBusyCursor(); @@ -446,15 +430,15 @@ void wxDividedShape::EditRegions() GraphicsForm *form = new GraphicsForm("Divided nodes"); // Need an array to store all the style strings, // since they need to be converted to integers - char **styleStrings = new char *[GetRegions().Number()]; - for (int j = 0; j < GetRegions().Number(); j++) + char **styleStrings = new char *[GetRegions().GetCount()]; + for (int j = 0; j < GetRegions().GetCount(); j++) styleStrings[j] = NULL; int i = 0; - wxNode *node = GetRegions().First(); - while (node && node->Next()) + wxNode *node = GetRegions().GetFirst(); + while (node && node->GetNext()) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); char buf[50]; sprintf(buf, "Region %d", (i+1)); form->Add(wxMakeFormMessage(buf)); @@ -518,9 +502,9 @@ void wxDividedShape::EditRegions() "Dot Dash" , NULL), NULL), NULL, wxVERTICAL, 100)); - node = node->Next(); + node = node->GetNext(); i ++; - if (node && node->Next()) + if (node && node->GetNext()) form->Add(wxMakeFormNewLine()); } wxDialogBox *dialog = new wxDialogBox(m_canvas->GetParent(), "Divided object properties", 10, 10, 500, 500); @@ -536,13 +520,13 @@ void wxDividedShape::EditRegions() wxEndBusyCursor(); - dialog->Show(TRUE); + dialog->Show(true); - node = GetRegions().First(); + node = GetRegions().GetFirst(); i = 0; while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); if (styleStrings[i]) { @@ -559,7 +543,7 @@ void wxDividedShape::EditRegions() delete[] styleStrings[i]; } region->m_actualPenObject = NULL; - node = node->Next(); + node = node->GetNext(); i ++; } delete[] styleStrings; @@ -591,13 +575,13 @@ wxDividedShapeControlPoint::~wxDividedShapeControlPoint() } // Implement resizing of divided object division -void wxDividedShapeControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment) +void wxDividedShapeControlPoint::OnDragLeft(bool WXUNUSED(draw), double WXUNUSED(x), double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(OGLRBLF); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); @@ -609,14 +593,14 @@ void wxDividedShapeControlPoint::OnDragLeft(bool draw, double x, double y, int k dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y2)); } -void wxDividedShapeControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment) +void wxDividedShapeControlPoint::OnBeginDragLeft(double WXUNUSED(x), double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); wxDividedShape *dividedObject = (wxDividedShape *)m_shape; dc.SetLogicalFunction(OGLRBLF); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); @@ -628,17 +612,17 @@ void wxDividedShapeControlPoint::OnBeginDragLeft(double x, double y, int keys, i m_canvas->CaptureMouse(); } -void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment) +void wxDividedShapeControlPoint::OnEndDragLeft(double WXUNUSED(x), double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); wxDividedShape *dividedObject = (wxDividedShape *)m_shape; - wxNode *node = dividedObject->GetRegions().Nth(regionId); + wxObjectList::compatibility_iterator node = dividedObject->GetRegions().Item(regionId); if (!node) return; - wxShapeRegion *thisRegion = (wxShapeRegion *)node->Data(); + wxShapeRegion *thisRegion = (wxShapeRegion *)node->GetData(); wxShapeRegion *nextRegion = NULL; // Region below this one dc.SetLogicalFunction(wxCOPY); @@ -654,13 +638,12 @@ void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int // Save values double thisRegionTop = 0.0; - double thisRegionBottom = 0.0; double nextRegionBottom = 0.0; - node = dividedObject->GetRegions().First(); + node = dividedObject->GetRegions().GetFirst(); while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); double proportion = region->m_regionProportionY; double yy = currentY + (dividedObject->GetHeight()*proportion); @@ -669,9 +652,8 @@ void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int if (region == thisRegion) { thisRegionTop = currentY; - thisRegionBottom = actualY; - if (node->Next()) - nextRegion = (wxShapeRegion *)node->Next()->Data(); + if (node->GetNext()) + nextRegion = (wxShapeRegion *)node->GetNext()->GetData(); } if (region == nextRegion) { @@ -679,7 +661,7 @@ void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int } currentY = actualY; - node = node->Next(); + node = node->GetNext(); } if (!nextRegion) return; @@ -700,17 +682,16 @@ void wxDividedShapeControlPoint::OnEndDragLeft(double x, double y, int keys, int // Now reformat text int i = 0; - node = dividedObject->GetRegions().First(); + node = dividedObject->GetRegions().GetFirst(); while (node) { - wxShapeRegion *region = (wxShapeRegion *)node->Data(); + wxShapeRegion *region = (wxShapeRegion *)node->GetData(); if (region->GetText()) { - char *s = copystring(region->GetText()); - dividedObject->FormatText(dc, s, i); - delete[] s; + wxString s(region->GetText()); + dividedObject->FormatText(dc, s.c_str(), i); } - node = node->Next(); + node = node->GetNext(); i++; } dividedObject->SetRegionSizes();