X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2ba06d5a8ccf8c224fcfbd52fa01a55abf7befbd..ae200bfcb537c475708959cb034be66eb0f5dcd4:/contrib/samples/ogl/studio/shapes.cpp?ds=sidebyside diff --git a/contrib/samples/ogl/studio/shapes.cpp b/contrib/samples/ogl/studio/shapes.cpp index 2c2e7e7249..e7125a4a24 100644 --- a/contrib/samples/ogl/studio/shapes.cpp +++ b/contrib/samples/ogl/studio/shapes.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: shapes.cpp +// Name: contrib/samples/ogl/studio/shapes.cpp // Purpose: Implements Studio shapes // Author: Julian Smart // Modified by: @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -// #pragma implementation -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -21,22 +17,19 @@ #endif #ifndef WX_PRECOMP -#include +#include "wx/wx.h" #endif #if !wxUSE_DOC_VIEW_ARCHITECTURE #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! #endif -#include -#include +#include "wx/ogl/ogl.h" // base header of OGL, includes and adjusts wx/deprecated/setup.h #include "studio.h" #include "doc.h" #include "shapes.h" #include "view.h" -#include -#include #include "cspalette.h" #include "dialogs.h" @@ -83,7 +76,7 @@ void csEvtHandler::CopyData(wxShapeEvtHandler& copy) csEvtHandler& csCopy = (csEvtHandler&) copy; csCopy.m_label = m_label; } - + void csEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment)) { wxClientDC dc(GetShape()->GetCanvas()); @@ -159,7 +152,9 @@ void csEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, } else { +#if wxUSE_STATUSBAR ((wxFrame*)wxGetApp().GetTopWindow())->SetStatusText(m_label); +#endif // wxUSE_STATUSBAR } } @@ -194,7 +189,7 @@ void csEvtHandler::OnBeginDragRight(double x, double y, int WXUNUSED(keys), int wxClientDC dc(GetShape()->GetCanvas()); GetShape()->GetCanvas()->PrepareDC(dc); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetLogicalFunction(OGLRBLF); dc.SetPen(dottedPen); double xp, yp; @@ -208,7 +203,7 @@ void csEvtHandler::OnDragRight(bool WXUNUSED(draw), double x, double y, int WXUN wxClientDC dc(GetShape()->GetCanvas()); GetShape()->GetCanvas()->PrepareDC(dc); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetLogicalFunction(OGLRBLF); dc.SetPen(dottedPen); double xp, yp; @@ -224,7 +219,7 @@ void csEvtHandler::OnEndDragRight(double x, double y, int WXUNUSED(keys), int at // Check if we're on an object int new_attachment; wxShape *otherShape = canvas->FindFirstSensitiveShape(x, y, &new_attachment, OP_DRAG_RIGHT); - + if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape))) { wxLineShape* theShape = new csLineShape; @@ -280,7 +275,7 @@ void csEvtHandler::OnDragLeft(bool draw, double x, double y, int keys, int attac dc.SetLogicalFunction(OGLRBLF); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush(* wxTRANSPARENT_BRUSH); @@ -299,7 +294,7 @@ void csEvtHandler::OnDragLeft(bool draw, double x, double y, int keys, int attac GetShape()->GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h); // Draw bounding box for other selected shapes - wxNode* node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); + wxObjectList::compatibility_iterator node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); while (node) { wxShape* shape = (wxShape*) node->GetData(); @@ -349,7 +344,7 @@ void csEvtHandler::OnBeginDragLeft(double x, double y, int keys, int attachment) dc.SetLogicalFunction(OGLRBLF); - wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + wxPen dottedPen(*wxBLACK, 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); @@ -358,7 +353,7 @@ void csEvtHandler::OnBeginDragLeft(double x, double y, int keys, int attachment) GetShape()->GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h); // Draw bounding box for other selected shapes - wxNode* node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); + wxObjectList::compatibility_iterator node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); while (node) { wxShape* shape = (wxShape*) node->GetData(); @@ -413,7 +408,7 @@ void csEvtHandler::OnEndDragLeft(double x, double y, int keys, int attachment) new csCommandState(ID_CS_MOVE, newShape, GetShape())); // Move line points - wxNode* node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); + wxObjectList::compatibility_iterator node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); while (node) { wxShape* shape = (wxShape*) node->GetData(); @@ -427,7 +422,7 @@ void csEvtHandler::OnEndDragLeft(double x, double y, int keys, int attachment) { wxLineShape* newLineShape = (wxLineShape*) lineShape->CreateNewCopy(); - wxNode *node1 = newLineShape->GetLineControlPoints()->GetFirst(); + wxObjectList::compatibility_iterator node1 = newLineShape->GetLineControlPoints()->GetFirst(); while (node1) { wxRealPoint *point = (wxRealPoint *)node1->GetData(); @@ -680,6 +675,9 @@ bool csEvtHandler::EditProperties() return false; } + wxString newLabel(m_label); + +#if wxUSE_WX_RESOURCES csShapePropertiesDialog* dialog = new csShapePropertiesDialog(shape->GetCanvas()->GetParent(), title, attributeDialog, attributeDialogName); dialog->GetGeneralPropertiesDialog()->SetShapeLabel(m_label); if (dialog->ShowModal() == wxID_CANCEL) @@ -688,8 +686,11 @@ bool csEvtHandler::EditProperties() return false; } - wxString newLabel = dialog->GetGeneralPropertiesDialog()->GetShapeLabel(); + newLabel = dialog->GetGeneralPropertiesDialog()->GetShapeLabel(); dialog->Destroy(); +#else + wxUnusedVar(attributeDialog); +#endif // wxUSE_WX_RESOURCES wxShape* newShape = shape->CreateNewCopy(); @@ -705,7 +706,8 @@ bool csEvtHandler::EditProperties() /* * Diagram */ - + +#if wxUSE_PROLOGIO bool csDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr) { wxDiagram::OnShapeSave(db, shape, expr); @@ -721,9 +723,10 @@ bool csDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr) expr.GetAttributeValue(_T("label"), label); csEvtHandler *handler = new csEvtHandler(&shape, &shape, label); shape.SetEventHandler(handler); - + return true; } +#endif // wxUSE_PROLOGIO IMPLEMENT_DYNAMIC_CLASS(csThinRectangleShape, wxDrawnShape) @@ -1153,7 +1156,7 @@ void studioShapeEditProc(wxMenu& menu, wxCommandEvent& event) break; double theta = shape->GetRotation(); - const double myPi = 3.1415926535897932384626433832795 ; + const double myPi = M_PI; double ninetyDegrees = myPi/2.0; wxString opStr; @@ -1192,4 +1195,3 @@ void ShapeEditMenu::OnCommand(wxCommandEvent& event) { studioShapeEditProc(*this, event); } -