// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <wx/wx.h>
#endif
-#include <wx/wxexpr.h>
+#if wxUSE_PROLOGIO
+#include <wx/deprecated/wxexpr.h>
+#endif
+
+#include "wx/ogl/ogl.h"
-#include <wx/ogl/basic.h>
-#include <wx/ogl/basicp.h>
-#include <wx/ogl/constrnt.h>
-#include <wx/ogl/composit.h>
-#include <wx/ogl/misc.h>
-#include <wx/ogl/canvas.h>
#if wxUSE_PROLOGIO
// Sometimes, objects need to access the whole database to
wxCompositeShape::wxCompositeShape(): wxRectangleShape(10.0, 10.0)
{
-// selectable = FALSE;
+// selectable = false;
m_oldX = m_xpos;
m_oldY = m_ypos;
}
node = node->GetNext();
}
- return TRUE;
+ return true;
}
void wxCompositeShape::OnErase(wxDC& dc)
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;
// 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;
// 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);
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.
// 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);
while (node)
{
wxShape *object = (wxShape *)node->GetData();
- wxShape *newObject = object->CreateNewCopy(FALSE, FALSE);
+ wxShape *newObject = object->CreateNewCopy(false, false);
if (newObject->GetId() == 0)
newObject->SetId(wxNewId());
bool wxCompositeShape::Recompute()
{
int noIterations = 0;
- bool changed = TRUE;
+ bool changed = true;
while (changed && (noIterations < 500))
{
changed = Constrain();
{
CalculateSize();
- bool changed = FALSE;
+ bool changed = false;
wxNode *node = m_children.GetFirst();
while (node)
{
wxShape *object = (wxShape *)node->GetData();
if (object->Constrain())
- changed = TRUE;
+ changed = true;
node = node->GetNext();
}
while (node)
{
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
- if (constraint->Evaluate()) changed = TRUE;
+ if (constraint->Evaluate()) changed = true;
node = node->GetNext();
}
return changed;
// Output constraints as constraint1 = (...), constraint2 = (...), etc.
int constraintNo = 1;
- char m_constraintNameBuf[20];
+ wxChar m_constraintNameBuf[20];
wxNode *node = m_constraints.GetFirst();
while (node)
{
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
- sprintf(m_constraintNameBuf, "constraint%d", constraintNo);
+ wxSprintf(m_constraintNameBuf, _T("constraint%d"), constraintNo);
// Each constraint is stored in the form
// (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList)
childrenExpr->Append(new wxExpr(child->GetId()));
node = node->GetNext();
}
- clause->AddAttributeValue("children", childrenExpr);
+ clause->AddAttributeValue(_T("children"), childrenExpr);
// Write the ids of all the division images
if (m_divisions.GetCount() > 0)
divisionsExpr->Append(new wxExpr(child->GetId()));
node = node->GetNext();
}
- clause->AddAttributeValue("divisions", divisionsExpr);
+ clause->AddAttributeValue(_T("divisions"), divisionsExpr);
}
}
{
// 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;
// Each constraint is stored in the form
// (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList)
- wxExpr *typeExpr = constraintExpr->Item(0);
- wxExpr *nameExpr = constraintExpr->Item(1);
- wxExpr *idExpr = constraintExpr->Item(2);
- wxExpr *xExpr = constraintExpr->Item(3);
- wxExpr *yExpr = constraintExpr->Item(4);
- wxExpr *constrainingExpr = constraintExpr->Item(5);
- wxExpr *constrainedExpr = constraintExpr->Item(6);
-
- cType = (int)typeExpr->IntegerValue();
- cXSpacing = xExpr->RealValue();
- cYSpacing = yExpr->RealValue();
+ wxExpr *typeExpr = constraintExpr->Nth(0);
+ wxExpr *nameExpr = constraintExpr->Nth(1);
+ wxExpr *idExpr = constraintExpr->Nth(2);
+ wxExpr *xExpr = constraintExpr->Nth(3);
+ wxExpr *yExpr = constraintExpr->Nth(4);
+ wxExpr *constrainingExpr = constraintExpr->Nth(5);
+ wxExpr *constrainedExpr = constraintExpr->Nth(6);
+
+ 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
wxLogFatalError(wxT("Object graphics error: Couldn't find constraining image of composite."));
int i = 0;
- wxExpr *currentIdExpr = constrainedExpr->Item(i);
+ 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());
}
i ++;
- currentIdExpr = constrainedExpr->Item(i);
+ currentIdExpr = constrainedExpr->Nth(i);
}
wxOGLConstraint *newConstraint = AddConstraint(cType, m_constrainingObject, m_constrainedObjects);
newConstraint->SetSpacing(cXSpacing, cYSpacing);
division->Move(dc, GetX(), GetY());
Recompute();
- division->Show(TRUE);
+ division->Show(true);
}
wxDivisionShape *wxCompositeShape::OnCreateDivision()
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;
+ return true;
wxNode *node = m_children.GetFirst();
while (node)
{
{
bool ans = ((wxCompositeShape *)child)->ContainsDivision(division);
if (ans)
- return TRUE;
+ return true;
}
node = node->GetNext();
}
- return FALSE;
+ return false;
}
/*
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;
object->Move(dc, object->GetX() + diffX, object->GetY() + diffY, display);
node = node->GetNext();
}
- return TRUE;
+ return true;
}
void wxDivisionShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
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
{
if (Selected())
{
- Select(FALSE);
+ Select(false);
GetParent()->Draw(dc);
}
else
- Select(TRUE);
+ Select(true);
}
}
*/
double oldWidth = GetWidth();
double oldHeight = GetHeight();
if (Selected())
- Select(FALSE);
+ Select(false);
wxClientDC dc(GetCanvas());
GetCanvas()->PrepareDC(dc);
double newXPos2 = GetX();
double newYPos2 = (double)(y1 + (3.0*GetHeight()/4.0));
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
- newDivision->Show(TRUE);
+ newDivision->Show(true);
Erase(dc);
double newXPos2 = (double)(x1 + (3.0*GetWidth()/4.0));
double newYPos2 = GetY();
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
- newDivision->Show(TRUE);
+ newDivision->Show(true);
Erase(dc);
compositeParent->MakeMandatoryControlPoints();
}
compositeParent->Draw(dc);
- return TRUE;
+ return true;
}
// Make one control point for every visible line
double maxX, maxY;
GetBoundingBoxMax(&maxX, &maxY);
- double x, y;
- int direction;
+ double x = 0.0 , y = 0.0;
+ int direction = 0;
/*
if (m_leftSide)
{
}
}
-// 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);
Move(dc, newX, GetY());
- return TRUE;
+ return true;
}
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);
Move(dc, GetX(), newY);
- return TRUE;
+ return true;
}
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);
Move(dc, newX, GetY());
- return TRUE;
+ return true;
}
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);
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()
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;
}
{
bool success = division->AdjustRight(newPos, test);
if (!success && test)
- return FALSE;
+ return false;
}
break;
}
{
bool success = division->AdjustBottom(newPos, test);
if (!success && test)
- return FALSE;
+ return false;
}
break;
}
{
bool success = division->AdjustLeft(newPos, test);
if (!success && test)
- return FALSE;
+ return false;
}
break;
}
{
bool success = division->AdjustTop(newPos, test);
if (!success && test)
- return FALSE;
+ return false;
}
break;
}
node = node->GetNext();
}
- return TRUE;
+ return true;
}
/*
};
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()
}
}
-void wxDivisionShape::EditEdge(int side)
+void wxDivisionShape::EditEdge(int WXUNUSED(side))
{
wxMessageBox(wxT("EditEdge() not implemented"), wxT("OGL"), wxOK);
dialog->Centre(wxBOTH);
wxEndBusyCursor();
- dialog->Show(TRUE);
+ dialog->Show(true);
int lineStyle = wxSOLID;
if (*pStyle)
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);