X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/257ed895d539d3dc6a11058c337ba1a58c5b7036..1721a8c028d3b6a553634c632117fbfac102a30e:/contrib/src/ogl/composit.cpp diff --git a/contrib/src/ogl/composit.cpp b/contrib/src/ogl/composit.cpp index 6dbc6190a7..da0e212d71 100644 --- a/contrib/src/ogl/composit.cpp +++ b/contrib/src/ogl/composit.cpp @@ -6,7 +6,7 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -14,7 +14,7 @@ #endif // For compilers that support precompilation, includes "wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -24,19 +24,18 @@ #include #endif -#include +#if wxUSE_PROLOGIO +#include +#endif + +#include "wx/ogl/ogl.h" -#include -#include -#include -#include -#include -#include +#if wxUSE_PROLOGIO // Sometimes, objects need to access the whole database to // construct themselves. wxExprDatabase *GlobalwxExprDatabase = NULL; - +#endif /* * Division control point @@ -66,25 +65,25 @@ IMPLEMENT_DYNAMIC_CLASS(wxCompositeShape, wxRectangleShape) wxCompositeShape::wxCompositeShape(): wxRectangleShape(10.0, 10.0) { -// selectable = FALSE; +// selectable = false; m_oldX = m_xpos; m_oldY = m_ypos; } wxCompositeShape::~wxCompositeShape() { - wxNode *node = m_constraints.First(); + wxNode *node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); delete constraint; - node = node->Next(); + node = node->GetNext(); } - node = m_children.First(); + node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); - wxNode *next = node->Next(); + wxShape *object = (wxShape *)node->GetData(); + wxNode *next = node->GetNext(); object->Unlink(); delete object; node = next; @@ -112,13 +111,13 @@ void wxCompositeShape::OnDraw(wxDC& dc) void wxCompositeShape::OnDrawContents(wxDC& dc) { - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); object->Draw(dc); object->DrawLinks(dc); - node = node->Next(); + node = node->GetNext(); } wxShape::OnDrawContents(dc); } @@ -127,35 +126,35 @@ bool wxCompositeShape::OnMovePre(wxDC& dc, double x, double y, double oldx, doub { double diffX = x - oldx; double diffY = y - oldy; - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); object->Erase(dc); object->Move(dc, object->GetX() + diffX, object->GetY() + diffY, display); - node = node->Next(); + node = node->GetNext(); } - return TRUE; + return true; } void wxCompositeShape::OnErase(wxDC& dc) { wxRectangleShape::OnErase(dc); - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); object->Erase(dc); - node = node->Next(); + node = node->GetNext(); } } static double objectStartX = 0.0; static double objectStartY = 0.0; -void wxCompositeShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment) +void wxCompositeShape::OnDragLeft(bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { double xx = x; double yy = y; @@ -175,7 +174,7 @@ void wxCompositeShape::OnDragLeft(bool draw, double x, double y, int keys, int a // wxShape::OnDragLeft(draw, x, y, keys, attachment); } -void wxCompositeShape::OnBeginDragLeft(double x, double y, int keys, int attachment) +void wxCompositeShape::OnBeginDragLeft(double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { objectStartX = x; objectStartY = y; @@ -203,7 +202,7 @@ void wxCompositeShape::OnBeginDragLeft(double x, double y, int keys, int attachm // wxShape::OnBeginDragLeft(x, y, keys, attachment); } -void wxCompositeShape::OnEndDragLeft(double x, double y, int keys, int attachment) +void wxCompositeShape::OnEndDragLeft(double x, double y, int keys, int WXUNUSED(attachment)) { // wxShape::OnEndDragLeft(x, y, keys, attachment); @@ -230,17 +229,17 @@ void wxCompositeShape::OnEndDragLeft(double x, double y, int keys, int attachmen if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc); } -void wxCompositeShape::OnRightClick(double x, double y, int keys, int attachment) +void wxCompositeShape::OnRightClick(double x, double y, int keys, int WXUNUSED(attachment)) { // If we get a ctrl-right click, this means send the message to // the division, so we can invoke a user interface for dealing with regions. if (keys & KEY_CTRL) { - wxNode *node = m_divisions.First(); + wxNode *node = m_divisions.GetFirst(); while (node) { - wxDivisionShape *division = (wxDivisionShape *)node->Data(); - wxNode *next = node->Next(); + wxDivisionShape *division = (wxDivisionShape *)node->GetData(); + wxNode *next = node->GetNext(); int attach = 0; double dist = 0.0; if (division->HitTest(x, y, &attach, &dist)) @@ -266,7 +265,7 @@ void wxCompositeShape::SetSize(double w, double h, bool recursive) if (!recursive) return; - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); @@ -274,21 +273,21 @@ void wxCompositeShape::SetSize(double w, double h, bool recursive) double xBound, yBound; while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); // Scale the position first double newX = (double)(((object->GetX() - GetX())*xScale) + GetX()); double newY = (double)(((object->GetY() - GetY())*yScale) + GetY()); - object->Show(FALSE); + object->Show(false); object->Move(dc, newX, newY); - object->Show(TRUE); + object->Show(true); // Now set the scaled size object->GetBoundingBoxMin(&xBound, &yBound); object->SetSize(object->GetFixedWidth() ? xBound : xScale*xBound, object->GetFixedHeight() ? yBound : yScale*yBound); - node = node->Next(); + node = node->GetNext(); } SetDefaultRegionSize(); } @@ -316,11 +315,11 @@ void wxCompositeShape::RemoveChild(wxShape *child) void wxCompositeShape::DeleteConstraintsInvolvingChild(wxShape *child) { - wxNode *node = m_constraints.First(); + wxNode *node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); - wxNode *nextNode = node->Next(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); + wxNode *nextNode = node->GetNext(); if ((constraint->m_constrainingObject == child) || constraint->m_constrainedObjects.Member(child)) @@ -334,11 +333,11 @@ void wxCompositeShape::DeleteConstraintsInvolvingChild(wxShape *child) void wxCompositeShape::RemoveChildFromConstraints(wxShape *child) { - wxNode *node = m_constraints.First(); + wxNode *node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); - wxNode *nextNode = node->Next(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); + wxNode *nextNode = node->GetNext(); if (constraint->m_constrainedObjects.Member(child)) constraint->m_constrainedObjects.DeleteObject(child); @@ -368,11 +367,11 @@ void wxCompositeShape::Copy(wxShape& copy) oglObjectCopyMapping.Append((long)this, &compositeCopy); // Copy the children - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); - wxShape *newObject = object->CreateNewCopy(FALSE, FALSE); + wxShape *object = (wxShape *)node->GetData(); + wxShape *newObject = object->CreateNewCopy(false, false); if (newObject->GetId() == 0) newObject->SetId(wxNewId()); @@ -385,25 +384,25 @@ void wxCompositeShape::Copy(wxShape& copy) oglObjectCopyMapping.Append((long)object, newObject); - node = node->Next(); + node = node->GetNext(); } // Copy the constraints - node = m_constraints.First(); + node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); - wxShape *newConstraining = (wxShape *)(oglObjectCopyMapping.Find((long)constraint->m_constrainingObject)->Data()); + wxShape *newConstraining = (wxShape *)(oglObjectCopyMapping.Find((long)constraint->m_constrainingObject)->GetData()); wxList newConstrainedList; - wxNode *node2 = constraint->m_constrainedObjects.First(); + wxNode *node2 = constraint->m_constrainedObjects.GetFirst(); while (node2) { - wxShape *constrainedObject = (wxShape *)node2->Data(); - wxShape *newConstrained = (wxShape *)(oglObjectCopyMapping.Find((long)constrainedObject)->Data()); + wxShape *constrainedObject = (wxShape *)node2->GetData(); + wxShape *newConstrained = (wxShape *)(oglObjectCopyMapping.Find((long)constrainedObject)->GetData()); newConstrainedList.Append(newConstrained); - node2 = node2->Next(); + node2 = node2->GetNext(); } wxOGLConstraint *newConstraint = new wxOGLConstraint(constraint->m_constraintType, newConstraining, @@ -416,14 +415,14 @@ void wxCompositeShape::Copy(wxShape& copy) newConstraint->SetSpacing(constraint->m_xSpacing, constraint->m_ySpacing); compositeCopy.m_constraints.Append(newConstraint); - node = node->Next(); + node = node->GetNext(); } // Now compositeCopy the division geometry - node = m_divisions.First(); + node = m_divisions.GetFirst(); while (node) { - wxDivisionShape *division = (wxDivisionShape *)node->Data(); + wxDivisionShape *division = (wxDivisionShape *)node->GetData(); wxNode *node1 = oglObjectCopyMapping.Find((long)division); wxNode *leftNode = NULL; wxNode *topNode = NULL; @@ -439,17 +438,17 @@ void wxCompositeShape::Copy(wxShape& copy) bottomNode = oglObjectCopyMapping.Find((long)division->GetBottomSide()); if (node1) { - wxDivisionShape *newDivision = (wxDivisionShape *)node1->Data(); + wxDivisionShape *newDivision = (wxDivisionShape *)node1->GetData(); if (leftNode) - newDivision->SetLeftSide((wxDivisionShape *)leftNode->Data()); + newDivision->SetLeftSide((wxDivisionShape *)leftNode->GetData()); if (topNode) - newDivision->SetTopSide((wxDivisionShape *)topNode->Data()); + newDivision->SetTopSide((wxDivisionShape *)topNode->GetData()); if (rightNode) - newDivision->SetRightSide((wxDivisionShape *)rightNode->Data()); + newDivision->SetRightSide((wxDivisionShape *)rightNode->GetData()); if (bottomNode) - newDivision->SetBottomSide((wxDivisionShape *)bottomNode->Data()); + newDivision->SetBottomSide((wxDivisionShape *)bottomNode->GetData()); } - node = node->Next(); + node = node->GetNext(); } } @@ -483,23 +482,23 @@ wxOGLConstraint *wxCompositeShape::AddConstraint(int type, wxShape *constraining wxOGLConstraint *wxCompositeShape::FindConstraint(long cId, wxCompositeShape **actualComposite) { - wxNode *node = m_constraints.First(); + wxNode *node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); if (constraint->m_constraintId == cId) { if (actualComposite) *actualComposite = this; return constraint; } - node = node->Next(); + node = node->GetNext(); } // If not found, try children. - node = m_children.First(); + node = m_children.GetFirst(); while (node) { - wxShape *child = (wxShape *)node->Data(); + wxShape *child = (wxShape *)node->GetData(); if (child->IsKindOf(CLASSINFO(wxCompositeShape))) { wxOGLConstraint *constraint = ((wxCompositeShape *)child)->FindConstraint(cId, actualComposite); @@ -510,7 +509,7 @@ wxOGLConstraint *wxCompositeShape::FindConstraint(long cId, wxCompositeShape **a return constraint; } } - node = node->Next(); + node = node->GetNext(); } return NULL; } @@ -529,10 +528,10 @@ void wxCompositeShape::CalculateSize() double minY = (double) 999999.9; double w, h; - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); // Recalculate size of composite objects because may not conform // to size it was set to - depends on the children. @@ -548,7 +547,7 @@ void wxCompositeShape::CalculateSize() if ((object->GetY() - (h/2.0)) < minY) minY = (double)(object->GetY() - (h/2.0)); - node = node->Next(); + node = node->GetNext(); } m_width = maxX - minX; m_height = maxY - minY; @@ -559,7 +558,7 @@ void wxCompositeShape::CalculateSize() bool wxCompositeShape::Recompute() { int noIterations = 0; - bool changed = TRUE; + bool changed = true; while (changed && (noIterations < 500)) { changed = Constrain(); @@ -578,27 +577,27 @@ bool wxCompositeShape::Constrain() { CalculateSize(); - bool changed = FALSE; - wxNode *node = m_children.First(); + bool changed = false; + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); if (object->Constrain()) - changed = TRUE; - node = node->Next(); + changed = true; + node = node->GetNext(); } - node = m_constraints.First(); + node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); - if (constraint->Evaluate()) changed = TRUE; - node = node->Next(); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); + if (constraint->Evaluate()) changed = true; + node = node->GetNext(); } return changed; } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO void wxCompositeShape::WriteAttributes(wxExpr *clause) { wxRectangleShape::WriteAttributes(clause); @@ -607,12 +606,12 @@ void wxCompositeShape::WriteAttributes(wxExpr *clause) // Output constraints as constraint1 = (...), constraint2 = (...), etc. int constraintNo = 1; - char m_constraintNameBuf[20]; - wxNode *node = m_constraints.First(); + wxChar m_constraintNameBuf[20]; + wxNode *node = m_constraints.GetFirst(); while (node) { - wxOGLConstraint *constraint = (wxOGLConstraint *)node->Data(); - sprintf(m_constraintNameBuf, "constraint%d", constraintNo); + wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); + wxSprintf(m_constraintNameBuf, _T("constraint%d"), constraintNo); // Each constraint is stored in the form // (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList) @@ -625,44 +624,44 @@ void wxCompositeShape::WriteAttributes(wxExpr *clause) constraintExpr->Append(new wxExpr(constraint->m_constrainingObject->GetId())); wxExpr *objectList = new wxExpr(wxExprList); - wxNode *node1 = constraint->m_constrainedObjects.First(); + wxNode *node1 = constraint->m_constrainedObjects.GetFirst(); while (node1) { - wxShape *obj = (wxShape *)node1->Data(); + wxShape *obj = (wxShape *)node1->GetData(); objectList->Append(new wxExpr(obj->GetId())); - node1 = node1->Next(); + node1 = node1->GetNext(); } constraintExpr->Append(objectList); clause->AddAttributeValue(m_constraintNameBuf, constraintExpr); - node = node->Next(); + node = node->GetNext(); constraintNo ++; } // Write the ids of all the child images wxExpr *childrenExpr = new wxExpr(wxExprList); - node = m_children.First(); + node = m_children.GetFirst(); while (node) { - wxShape *child = (wxShape *)node->Data(); + wxShape *child = (wxShape *)node->GetData(); childrenExpr->Append(new wxExpr(child->GetId())); - node = node->Next(); + node = node->GetNext(); } - clause->AddAttributeValue("children", childrenExpr); + clause->AddAttributeValue(_T("children"), childrenExpr); // Write the ids of all the division images - if (m_divisions.Number() > 0) + if (m_divisions.GetCount() > 0) { wxExpr *divisionsExpr = new wxExpr(wxExprList); - node = m_divisions.First(); + node = m_divisions.GetFirst(); while (node) { - wxShape *child = (wxShape *)node->Data(); + wxShape *child = (wxShape *)node->GetData(); divisionsExpr->Append(new wxExpr(child->GetId())); - node = node->Next(); + node = node->GetNext(); } - clause->AddAttributeValue("divisions", divisionsExpr); + clause->AddAttributeValue(_T("divisions"), divisionsExpr); } } @@ -681,24 +680,20 @@ void wxCompositeShape::ReadConstraints(wxExpr *clause, wxExprDatabase *database) { // Constraints are output as constraint1 = (...), constraint2 = (...), etc. int constraintNo = 1; - char m_constraintNameBuf[20]; - bool haveConstraints = TRUE; + wxChar m_constraintNameBuf[20]; + bool haveConstraints = true; while (haveConstraints) { - sprintf(m_constraintNameBuf, "constraint%d", constraintNo); + wxSprintf(m_constraintNameBuf, _T("constraint%d"), constraintNo); wxExpr *constraintExpr = NULL; clause->GetAttributeValue(m_constraintNameBuf, &constraintExpr); if (!constraintExpr) { - haveConstraints = FALSE; + haveConstraints = false; break; } - int cType = 0; - double cXSpacing = 0.0; - double cYSpacing = 0.0; - wxString cName(""); - long cId = 0; + wxString cName = wxEmptyString; wxShape *m_constrainingObject = NULL; wxList m_constrainedObjects; @@ -713,31 +708,31 @@ void wxCompositeShape::ReadConstraints(wxExpr *clause, wxExprDatabase *database) wxExpr *constrainingExpr = constraintExpr->Nth(5); wxExpr *constrainedExpr = constraintExpr->Nth(6); - cType = (int)typeExpr->IntegerValue(); - cXSpacing = xExpr->RealValue(); - cYSpacing = yExpr->RealValue(); + int cType = (int)typeExpr->IntegerValue(); + double cXSpacing = xExpr->RealValue(); + double cYSpacing = yExpr->RealValue(); cName = nameExpr->StringValue(); - cId = idExpr->IntegerValue(); + long cId = idExpr->IntegerValue(); - wxExpr *objExpr1 = database->HashFind("node_image", constrainingExpr->IntegerValue()); + wxExpr *objExpr1 = database->HashFind(_T("node_image"), constrainingExpr->IntegerValue()); if (objExpr1 && objExpr1->GetClientData()) m_constrainingObject = (wxShape *)objExpr1->GetClientData(); else - wxFatalError("Couldn't find constraining image of composite.", "Object graphics error"); + wxLogFatalError(wxT("Object graphics error: Couldn't find constraining image of composite.")); int i = 0; wxExpr *currentIdExpr = constrainedExpr->Nth(i); while (currentIdExpr) { long currentId = currentIdExpr->IntegerValue(); - wxExpr *objExpr2 = database->HashFind("node_image", currentId); + wxExpr *objExpr2 = database->HashFind(_T("node_image"), currentId); if (objExpr2 && objExpr2->GetClientData()) { m_constrainedObjects.Append((wxShape *)objExpr2->GetClientData()); } else { - wxFatalError("Couldn't find constrained image of composite.", "Object graphics error"); + wxLogFatalError(wxT("Object graphics error: Couldn't find constrained image of composite.")); } i ++; @@ -746,7 +741,7 @@ void wxCompositeShape::ReadConstraints(wxExpr *clause, wxExprDatabase *database) wxOGLConstraint *newConstraint = AddConstraint(cType, m_constrainingObject, m_constrainedObjects); newConstraint->SetSpacing(cXSpacing, cYSpacing); newConstraint->m_constraintId = cId; - newConstraint->m_constraintName = (const char*) cName; + newConstraint->m_constraintName = cName; constraintNo ++; } } @@ -766,7 +761,7 @@ void wxCompositeShape::MakeContainer() division->Move(dc, GetX(), GetY()); Recompute(); - division->Show(TRUE); + division->Show(true); } wxDivisionShape *wxCompositeShape::OnCreateDivision() @@ -776,35 +771,35 @@ wxDivisionShape *wxCompositeShape::OnCreateDivision() wxShape *wxCompositeShape::FindContainerImage() { - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *child = (wxShape *)node->Data(); + wxShape *child = (wxShape *)node->GetData(); if (!m_divisions.Member(child)) return child; - node = node->Next(); + node = node->GetNext(); } return NULL; } -// Returns TRUE if division is a descendant of this container +// Returns true if division is a descendant of this container bool wxCompositeShape::ContainsDivision(wxDivisionShape *division) { if (m_divisions.Member(division)) - return TRUE; - wxNode *node = m_children.First(); + return true; + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *child = (wxShape *)node->Data(); + wxShape *child = (wxShape *)node->GetData(); if (child->IsKindOf(CLASSINFO(wxCompositeShape))) { bool ans = ((wxCompositeShape *)child)->ContainsDivision(division); if (ans) - return TRUE; + return true; } - node = node->Next(); + node = node->GetNext(); } - return FALSE; + return false; } /* @@ -817,8 +812,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxDivisionShape, wxCompositeShape) wxDivisionShape::wxDivisionShape() { SetSensitivityFilter(OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_RIGHT); - SetCentreResize(FALSE); - SetAttachmentMode(TRUE); + SetCentreResize(false); + SetAttachmentMode(true); m_leftSide = NULL; m_rightSide = NULL; m_topSide = NULL; @@ -826,10 +821,10 @@ wxDivisionShape::wxDivisionShape() m_handleSide = DIVISION_SIDE_NONE; m_leftSidePen = wxBLACK_PEN; m_topSidePen = wxBLACK_PEN; - m_leftSideColour = "BLACK"; - m_topSideColour = "BLACK"; - m_leftSideStyle = "Solid"; - m_topSideStyle = "Solid"; + m_leftSideColour = wxT("BLACK"); + m_topSideColour = wxT("BLACK"); + m_leftSideStyle = wxT("Solid"); + m_topSideStyle = wxT("Solid"); ClearRegions(); } @@ -878,15 +873,15 @@ bool wxDivisionShape::OnMovePre(wxDC& dc, double x, double y, double oldx, doubl { double diffX = x - oldx; double diffY = y - oldy; - wxNode *node = m_children.First(); + wxNode *node = m_children.GetFirst(); while (node) { - wxShape *object = (wxShape *)node->Data(); + wxShape *object = (wxShape *)node->GetData(); object->Erase(dc); object->Move(dc, object->GetX() + diffX, object->GetY() + diffY, display); - node = node->Next(); + node = node->GetNext(); } - return TRUE; + return true; } void wxDivisionShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment) @@ -984,36 +979,36 @@ void wxDivisionShape::Copy(wxShape& copy) // Division geometry copying is handled at the wxCompositeShape level. } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO void wxDivisionShape::WriteAttributes(wxExpr *clause) { wxCompositeShape::WriteAttributes(clause); if (m_leftSide) - clause->AddAttributeValue("left_side", (long)m_leftSide->GetId()); + clause->AddAttributeValue(_T("left_side"), (long)m_leftSide->GetId()); if (m_topSide) - clause->AddAttributeValue("top_side", (long)m_topSide->GetId()); + clause->AddAttributeValue(_T("top_side"), (long)m_topSide->GetId()); if (m_rightSide) - clause->AddAttributeValue("right_side", (long)m_rightSide->GetId()); + clause->AddAttributeValue(_T("right_side"), (long)m_rightSide->GetId()); if (m_bottomSide) - clause->AddAttributeValue("bottom_side", (long)m_bottomSide->GetId()); + clause->AddAttributeValue(_T("bottom_side"), (long)m_bottomSide->GetId()); - clause->AddAttributeValue("handle_side", (long)m_handleSide); - clause->AddAttributeValueString("left_colour", m_leftSideColour); - clause->AddAttributeValueString("top_colour", m_topSideColour); - clause->AddAttributeValueString("left_style", m_leftSideStyle); - clause->AddAttributeValueString("top_style", m_topSideStyle); + clause->AddAttributeValue(_T("handle_side"), (long)m_handleSide); + clause->AddAttributeValueString(_T("left_colour"), m_leftSideColour); + clause->AddAttributeValueString(_T("top_colour"), m_topSideColour); + clause->AddAttributeValueString(_T("left_style"), m_leftSideStyle); + clause->AddAttributeValueString(_T("top_style"), m_topSideStyle); } void wxDivisionShape::ReadAttributes(wxExpr *clause) { wxCompositeShape::ReadAttributes(clause); - clause->GetAttributeValue("handle_side", m_handleSide); - clause->GetAttributeValue("left_colour", m_leftSideColour); - clause->GetAttributeValue("top_colour", m_topSideColour); - clause->GetAttributeValue("left_style", m_leftSideStyle); - clause->GetAttributeValue("top_style", m_topSideStyle); + clause->GetAttributeValue(_T("handle_side"), m_handleSide); + clause->GetAttributeValue(_T("left_colour"), m_leftSideColour); + clause->GetAttributeValue(_T("top_colour"), m_topSideColour); + clause->GetAttributeValue(_T("left_style"), m_leftSideStyle); + clause->GetAttributeValue(_T("top_style"), m_topSideStyle); } #endif @@ -1031,11 +1026,11 @@ void wxDivisionShape::OnRightClick(double x, double y, int keys, int attachment) { if (Selected()) { - Select(FALSE); + Select(false); GetParent()->Draw(dc); } else - Select(TRUE); + Select(true); } } */ @@ -1063,7 +1058,7 @@ bool wxDivisionShape::Divide(int direction) double oldWidth = GetWidth(); double oldHeight = GetHeight(); if (Selected()) - Select(FALSE); + Select(false); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); @@ -1077,19 +1072,19 @@ bool wxDivisionShape::Divide(int direction) double newXPos2 = GetX(); double newYPos2 = (double)(y1 + (3.0*GetHeight()/4.0)); wxDivisionShape *newDivision = compositeParent->OnCreateDivision(); - newDivision->Show(TRUE); + newDivision->Show(true); Erase(dc); // Anything adjoining the bottom of this division now adjoins the // bottom of the new division. - wxNode *node = compositeParent->GetDivisions().First(); + wxNode *node = compositeParent->GetDivisions().GetFirst(); while (node) { - wxDivisionShape *obj = (wxDivisionShape *)node->Data(); + wxDivisionShape *obj = (wxDivisionShape *)node->GetData(); if (obj->GetTopSide() == this) obj->SetTopSide(newDivision); - node = node->Next(); + node = node->GetNext(); } newDivision->SetTopSide(this); newDivision->SetBottomSide(m_bottomSide); @@ -1128,19 +1123,19 @@ bool wxDivisionShape::Divide(int direction) double newXPos2 = (double)(x1 + (3.0*GetWidth()/4.0)); double newYPos2 = GetY(); wxDivisionShape *newDivision = compositeParent->OnCreateDivision(); - newDivision->Show(TRUE); + newDivision->Show(true); Erase(dc); // Anything adjoining the left of this division now adjoins the // left of the new division. - wxNode *node = compositeParent->GetDivisions().First(); + wxNode *node = compositeParent->GetDivisions().GetFirst(); while (node) { - wxDivisionShape *obj = (wxDivisionShape *)node->Data(); + wxDivisionShape *obj = (wxDivisionShape *)node->GetData(); if (obj->GetLeftSide() == this) obj->SetLeftSide(newDivision); - node = node->Next(); + node = node->GetNext(); } newDivision->SetTopSide(m_topSide); newDivision->SetBottomSide(m_bottomSide); @@ -1167,7 +1162,7 @@ bool wxDivisionShape::Divide(int direction) compositeParent->MakeMandatoryControlPoints(); } compositeParent->Draw(dc); - return TRUE; + return true; } // Make one control point for every visible line @@ -1181,8 +1176,8 @@ void wxDivisionShape::MakeMandatoryControlPoints() double maxX, maxY; GetBoundingBoxMax(&maxX, &maxY); - double x, y; - int direction; + double x = 0.0 , y = 0.0; + int direction = 0; /* if (m_leftSide) { @@ -1252,17 +1247,17 @@ void wxDivisionShape::ResetControlPoints() void wxDivisionShape::ResetMandatoryControlPoints() { - if (m_controlPoints.Number() < 1) + if (m_controlPoints.GetCount() < 1) return; double maxX, maxY; GetBoundingBoxMax(&maxX, &maxY); /* - wxNode *node = m_controlPoints.First(); + wxNode *node = m_controlPoints.GetFirst(); while (node) { - wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data(); + wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData(); if (control->type == CONTROL_POINT_HORIZONTAL) { control->xoffset = (double)(-maxX/2.0); control->m_yoffset = 0.0; @@ -1271,44 +1266,44 @@ void wxDivisionShape::ResetMandatoryControlPoints() { control->xoffset = 0.0; control->m_yoffset = (double)(-maxY/2.0); } - node = node->Next(); + node = node->GetNext(); } */ - wxNode *node = m_controlPoints.First(); + wxNode *node = m_controlPoints.GetFirst(); if ((m_handleSide == DIVISION_SIDE_LEFT) && node) { - wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data(); + wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData(); control->m_xoffset = (double)(-maxX/2.0); control->m_yoffset = 0.0; } if ((m_handleSide == DIVISION_SIDE_TOP) && node) { - wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data(); + wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData(); control->m_xoffset = 0.0; control->m_yoffset = (double)(-maxY/2.0); } if ((m_handleSide == DIVISION_SIDE_RIGHT) && node) { - wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data(); + wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData(); control->m_xoffset = (double)(maxX/2.0); control->m_yoffset = 0.0; } if ((m_handleSide == DIVISION_SIDE_BOTTOM) && node) { - wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->Data(); + wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData(); control->m_xoffset = 0.0; control->m_yoffset = (double)(maxY/2.0); } } -// Adjust a side, returning FALSE if it's not physically possible. +// Adjust a side, returning false if it's not physically possible. bool wxDivisionShape::AdjustLeft(double left, bool test) { double x2 = (double)(GetX() + (GetWidth()/2.0)); if (left >= x2) - return FALSE; + return false; if (test) - return TRUE; + return true; double newW = x2 - left; double newX = (double)(left + newW/2.0); @@ -1319,7 +1314,7 @@ bool wxDivisionShape::AdjustLeft(double left, bool test) Move(dc, newX, GetY()); - return TRUE; + return true; } bool wxDivisionShape::AdjustTop(double top, bool test) @@ -1327,9 +1322,9 @@ bool wxDivisionShape::AdjustTop(double top, bool test) double y2 = (double)(GetY() + (GetHeight()/2.0)); if (top >= y2) - return FALSE; + return false; if (test) - return TRUE; + return true; double newH = y2 - top; double newY = (double)(top + newH/2.0); @@ -1340,7 +1335,7 @@ bool wxDivisionShape::AdjustTop(double top, bool test) Move(dc, GetX(), newY); - return TRUE; + return true; } bool wxDivisionShape::AdjustRight(double right, bool test) @@ -1348,9 +1343,9 @@ bool wxDivisionShape::AdjustRight(double right, bool test) double x1 = (double)(GetX() - (GetWidth()/2.0)); if (right <= x1) - return FALSE; + return false; if (test) - return TRUE; + return true; double newW = right - x1; double newX = (double)(x1 + newW/2.0); @@ -1361,7 +1356,7 @@ bool wxDivisionShape::AdjustRight(double right, bool test) Move(dc, newX, GetY()); - return TRUE; + return true; } bool wxDivisionShape::AdjustBottom(double bottom, bool test) @@ -1369,9 +1364,9 @@ bool wxDivisionShape::AdjustBottom(double bottom, bool test) double y1 = (double)(GetY() - (GetHeight()/2.0)); if (bottom <= y1) - return FALSE; + return false; if (test) - return TRUE; + return true; double newH = bottom - y1; double newY = (double)(y1 + newH/2.0); @@ -1382,13 +1377,13 @@ bool wxDivisionShape::AdjustBottom(double bottom, bool test) Move(dc, GetX(), newY); - return TRUE; + return true; } wxDivisionControlPoint::wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type): wxControlPoint(the_canvas, object, size, the_xoffset, the_yoffset, the_type) { - SetEraseObject(FALSE); + SetEraseObject(false); } wxDivisionControlPoint::~wxDivisionControlPoint() @@ -1439,51 +1434,51 @@ void wxDivisionControlPoint::OnEndDragLeft(double x, double y, int keys, int att double dx2 = (double)(division->GetX() + (division->GetWidth()/2.0)); double dy2 = (double)(division->GetY() + (division->GetHeight()/2.0)); - bool success = TRUE; + bool success = true; switch (division->GetHandleSide()) { case DIVISION_SIDE_LEFT: { if ((x <= x1) || (x >= x2) || (x >= dx2)) - success = FALSE; + success = false; // Try it out first... - else if (!division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, TRUE)) - success = FALSE; + else if (!division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, true)) + success = false; else - division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, FALSE); + division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, false); break; } case DIVISION_SIDE_TOP: { if ((y <= y1) || (y >= y2) || (y >= dy2)) - success = FALSE; - else if (!division->ResizeAdjoining(DIVISION_SIDE_TOP, y, TRUE)) - success = FALSE; + success = false; + else if (!division->ResizeAdjoining(DIVISION_SIDE_TOP, y, true)) + success = false; else - division->ResizeAdjoining(DIVISION_SIDE_TOP, y, FALSE); + division->ResizeAdjoining(DIVISION_SIDE_TOP, y, false); break; } case DIVISION_SIDE_RIGHT: { if ((x <= x1) || (x >= x2) || (x <= dx1)) - success = FALSE; - else if (!division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, TRUE)) - success = FALSE; + success = false; + else if (!division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, true)) + success = false; else - division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, FALSE); + division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, false); break; } case DIVISION_SIDE_BOTTOM: { if ((y <= y1) || (y >= y2) || (y <= dy1)) - success = FALSE; - else if (!division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, TRUE)) - success = FALSE; + success = false; + else if (!division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, true)) + success = false; else - division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, FALSE); + division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, false); break; } @@ -1511,10 +1506,10 @@ void wxDivisionControlPoint::OnEndDragLeft(double x, double y, int keys, int att bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) { wxCompositeShape *divisionParent = (wxCompositeShape *)GetParent(); - wxNode *node = divisionParent->GetDivisions().First(); + wxNode *node = divisionParent->GetDivisions().GetFirst(); while (node) { - wxDivisionShape *division = (wxDivisionShape *)node->Data(); + wxDivisionShape *division = (wxDivisionShape *)node->GetData(); switch (side) { case DIVISION_SIDE_LEFT: @@ -1523,7 +1518,7 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) { bool success = division->AdjustRight(newPos, test); if (!success && test) - return FALSE; + return false; } break; } @@ -1533,7 +1528,7 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) { bool success = division->AdjustBottom(newPos, test); if (!success && test) - return FALSE; + return false; } break; } @@ -1543,7 +1538,7 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) { bool success = division->AdjustLeft(newPos, test); if (!success && test) - return FALSE; + return false; } break; } @@ -1553,17 +1548,17 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) { bool success = division->AdjustTop(newPos, test); if (!success && test) - return FALSE; + return false; } break; } default: break; } - node = node->Next(); + node = node->GetNext(); } - return TRUE; + return true; } /* @@ -1573,11 +1568,11 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test) class OGLPopupDivisionMenu : public wxMenu { public: OGLPopupDivisionMenu() : wxMenu() { - Append(DIVISION_MENU_SPLIT_HORIZONTALLY, "Split horizontally"); - Append(DIVISION_MENU_SPLIT_VERTICALLY, "Split vertically"); + Append(DIVISION_MENU_SPLIT_HORIZONTALLY, wxT("Split horizontally")); + Append(DIVISION_MENU_SPLIT_VERTICALLY, wxT("Split vertically")); AppendSeparator(); - Append(DIVISION_MENU_EDIT_LEFT_EDGE, "Edit left edge"); - Append(DIVISION_MENU_EDIT_TOP_EDGE, "Edit top edge"); + Append(DIVISION_MENU_EDIT_LEFT_EDGE, wxT("Edit left edge")); + Append(DIVISION_MENU_EDIT_TOP_EDGE, wxT("Edit top edge")); } void OnMenu(wxCommandEvent& event); @@ -1586,8 +1581,7 @@ public: }; BEGIN_EVENT_TABLE(OGLPopupDivisionMenu, wxMenu) - EVT_CUSTOM_RANGE(wxEVT_COMMAND_MENU_SELECTED, - DIVISION_MENU_SPLIT_HORIZONTALLY, + EVT_MENU_RANGE(DIVISION_MENU_SPLIT_HORIZONTALLY, DIVISION_MENU_EDIT_BOTTOM_EDGE, OGLPopupDivisionMenu::OnMenu) END_EVENT_TABLE() @@ -1623,9 +1617,9 @@ void OGLPopupDivisionMenu::OnMenu(wxCommandEvent& event) } } -void wxDivisionShape::EditEdge(int side) +void wxDivisionShape::EditEdge(int WXUNUSED(side)) { - wxMessageBox("EditEdge() not implemented", "OGL", wxOK); + wxMessageBox(wxT("EditEdge() not implemented"), wxT("OGL"), wxOK); #if 0 wxBeginBusyCursor(); @@ -1700,7 +1694,7 @@ void wxDivisionShape::EditEdge(int side) dialog->Centre(wxBOTH); wxEndBusyCursor(); - dialog->Show(TRUE); + dialog->Show(true); int lineStyle = wxSOLID; if (*pStyle) @@ -1738,13 +1732,13 @@ void wxDivisionShape::PopupMenu(double x, double y) oglPopupDivisionMenu->SetClientData((void *)this); if (m_leftSide) - oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, TRUE); + oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, true); else - oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, FALSE); + oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, false); if (m_topSide) - oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, TRUE); + oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, true); else - oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, FALSE); + oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, false); int x1, y1; m_canvas->GetViewStart(&x1, &y1);