X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/36ca94a260b93ca35c5d5a09edfb8e104be0d694..e77138c0e2871600956d3186ce046454a6fbce21:/contrib/samples/ogl/ogledit/doc.cpp diff --git a/contrib/samples/ogl/ogledit/doc.cpp b/contrib/samples/ogl/ogledit/doc.cpp index 9c1f91e3b8..5d67e7e068 100644 --- a/contrib/samples/ogl/ogledit/doc.cpp +++ b/contrib/samples/ogl/ogledit/doc.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -// #pragma implementation -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -24,6 +20,8 @@ #include #endif +#include + #if !wxUSE_DOC_VIEW_ARCHITECTURE #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! #endif @@ -32,10 +30,6 @@ #include "doc.h" #include "view.h" -#if wxUSE_STD_IOSTREAM -#include -#endif - IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument) DiagramDocument::DiagramDocument(void) @@ -48,40 +42,48 @@ DiagramDocument::~DiagramDocument(void) bool DiagramDocument::OnCloseDocument(void) { - diagram.DeleteAllShapes(); - return true; + diagram.DeleteAllShapes(); + return true; } #if wxUSE_STD_IOSTREAM wxSTD ostream& DiagramDocument::SaveObject(wxSTD ostream& stream) { - wxDocument::SaveObject(stream); - - char buf[400]; - (void) wxGetTempFileName("diag", buf); +#if wxUSE_PROLOGIO + + wxDocument::SaveObject(stream); + + char buf[400]; + (void) wxGetTempFileName("diag", buf); - diagram.SaveFile(buf); - wxTransferFileToStream(buf, stream); + diagram.SaveFile(buf); + wxTransferFileToStream(buf, stream); - wxRemoveFile(buf); - - return stream; + wxRemoveFile(buf); + +#endif + + return stream; } wxSTD istream& DiagramDocument::LoadObject(wxSTD istream& stream) { - wxDocument::LoadObject(stream); +#if wxUSE_PROLOGIO + + wxDocument::LoadObject(stream); - char buf[400]; - (void) wxGetTempFileName("diag", buf); + char buf[400]; + (void) wxGetTempFileName("diag", buf); - wxTransferStreamToFile(stream, buf); + wxTransferStreamToFile(stream, buf); - diagram.DeleteAllShapes(); - diagram.LoadFile(buf); - wxRemoveFile(buf); + diagram.DeleteAllShapes(); + diagram.LoadFile(buf); + wxRemoveFile(buf); - return stream; +#endif + + return stream; } #else @@ -89,37 +91,37 @@ wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream) { #if wxUSE_PROLOGIO - wxDocument::SaveObject(stream); - wxChar buf[400]; - (void) wxGetTempFileName(_T("diag"), buf); + wxDocument::SaveObject(stream); + wxChar buf[400]; + (void) wxGetTempFileName(_T("diag"), buf); - diagram.SaveFile(buf); + diagram.SaveFile(buf); - wxTransferFileToStream(buf, stream); + wxTransferFileToStream(buf, stream); - wxRemoveFile(buf); + wxRemoveFile(buf); #endif - return stream; + return stream; } wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream) { #if wxUSE_PROLOGIO - wxDocument::LoadObject(stream); + wxDocument::LoadObject(stream); - wxChar buf[400]; - (void) wxGetTempFileName(_T("diag"), buf); + wxChar buf[400]; + (void) wxGetTempFileName(_T("diag"), buf); - wxTransferStreamToFile(stream, buf); + wxTransferStreamToFile(stream, buf); - diagram.DeleteAllShapes(); - diagram.LoadFile(buf); - wxRemoveFile(buf); + diagram.DeleteAllShapes(); + diagram.LoadFile(buf); + wxRemoveFile(buf); #endif - return stream; + return stream; } #endif @@ -129,56 +131,56 @@ wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream) */ DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double yy, - bool sel, wxShape *theShape, wxShape *fs, wxShape *ts): - wxCommand(true, name) + bool sel, wxShape *theShape, wxShape *fs, wxShape *ts) + :wxCommand(true, name) { - doc = ddoc; - cmd = command; - shape = theShape; - fromShape = fs; - toShape = ts; - shapeInfo = info; - shapeBrush = NULL; - shapePen = NULL; - x = xx; - y = yy; - selected = sel; - deleteShape = false; + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = fs; + toShape = ts; + shapeInfo = info; + shapeBrush = NULL; + shapePen = NULL; + x = xx; + y = yy; + selected = sel; + deleteShape = false; } -DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape): - wxCommand(true, name) +DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape) + :wxCommand(true, name) { - doc = ddoc; - cmd = command; - shape = theShape; - fromShape = NULL; - toShape = NULL; - shapeInfo = NULL; - x = 0.0; - y = 0.0; - selected = false; - deleteShape = false; - shapeBrush = backgroundColour; - shapePen = NULL; + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = NULL; + toShape = NULL; + shapeInfo = NULL; + x = 0.0; + y = 0.0; + selected = false; + deleteShape = false; + shapeBrush = backgroundColour; + shapePen = NULL; } -DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape): - wxCommand(true, name) +DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape) + :wxCommand(true, name) { - doc = ddoc; - cmd = command; - shape = theShape; - fromShape = NULL; - toShape = NULL; - shapeInfo = NULL; - x = 0.0; - y = 0.0; - selected = false; - deleteShape = false; - shapeBrush = NULL; - shapePen = NULL; - shapeLabel = lab; + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = NULL; + toShape = NULL; + shapeInfo = NULL; + x = 0.0; + y = 0.0; + selected = false; + deleteShape = false; + shapeBrush = NULL; + shapePen = NULL; + shapeLabel = lab; } DiagramCommand::~DiagramCommand(void) @@ -194,17 +196,17 @@ bool DiagramCommand::Do(void) { switch (cmd) { - case OGLEDIT_CUT: + case wxID_CUT: { if (shape) { deleteShape = true; - + shape->Select(false); - + // Generate commands to explicitly remove each connected line. RemoveLines(shape); - + doc->GetDiagram()->RemoveShape(shape); if (shape->IsKindOf(CLASSINFO(wxLineShape))) { @@ -213,7 +215,7 @@ bool DiagramCommand::Do(void) toShape = lineShape->GetTo(); } shape->Unlink(); - + doc->Modify(true); doc->UpdateAllViews(); } @@ -233,7 +235,7 @@ bool DiagramCommand::Do(void) theShape->SetCentreResize(false); theShape->SetPen(wxBLACK_PEN); theShape->SetBrush(wxCYAN_BRUSH); - + theShape->SetSize(60, 60); } doc->GetDiagram()->AddShape(theShape); @@ -243,7 +245,7 @@ bool DiagramCommand::Do(void) theShape->GetCanvas()->PrepareDC(dc); theShape->Move(dc, x, y); - + shape = theShape; deleteShape = false; @@ -271,11 +273,11 @@ bool DiagramCommand::Do(void) lineShape->MakeLineControlPoints(2); lineShape->AddArrow(ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, _T("Normal arrowhead")); } - + doc->GetDiagram()->AddShape(theShape); - + fromShape->AddLine((wxLineShape *)theShape, toShape); - + theShape->Show(true); wxClientDC dc(theShape->GetCanvas()); @@ -285,7 +287,7 @@ bool DiagramCommand::Do(void) // connected images fromShape->Move(dc, fromShape->GetX(), fromShape->GetY()); toShape->Move(dc, toShape->GetX(), toShape->GetY()); - + shape = theShape; deleteShape = false; @@ -304,7 +306,7 @@ bool DiagramCommand::Do(void) shape->SetBrush(shapeBrush); shapeBrush = oldBrush; shape->Draw(dc); - + doc->Modify(true); doc->UpdateAllViews(); } @@ -325,7 +327,7 @@ bool DiagramCommand::Do(void) shape->FormatText(dc, /* (char*) (const char*) */ myHandler->label); shape->Draw(dc); - + doc->Modify(true); doc->UpdateAllViews(); } @@ -340,7 +342,7 @@ bool DiagramCommand::Undo(void) { switch (cmd) { - case OGLEDIT_CUT: + case wxID_CUT: { if (shape) { @@ -390,7 +392,7 @@ bool DiagramCommand::Undo(void) shape->SetBrush(shapeBrush); shapeBrush = oldBrush; shape->Draw(dc); - + doc->Modify(true); doc->UpdateAllViews(); } @@ -410,7 +412,7 @@ bool DiagramCommand::Undo(void) shape->FormatText(dc, /* (char*) (const char*) */ myHandler->label); shape->Draw(dc); - + doc->Modify(true); doc->UpdateAllViews(); } @@ -428,8 +430,8 @@ void DiagramCommand::RemoveLines(wxShape *shape) while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); - doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line)); - + doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), wxID_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line)); + node = shape->GetLines().GetFirst(); } } @@ -437,7 +439,7 @@ void DiagramCommand::RemoveLines(wxShape *shape) /* * MyEvtHandler: an event handler class for all shapes */ - + void MyEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment)) { wxClientDC dc(GetShape()->GetCanvas()); @@ -495,11 +497,11 @@ void MyEvtHandler::OnBeginDragRight(double x, double y, int WXUNUSED(keys), int // Force attachment to be zero for now. Eventually we can deal with // the actual attachment point, e.g. a rectangle side if attachment mode is on. attachment = 0; - + 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; @@ -516,7 +518,7 @@ void MyEvtHandler::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; @@ -532,7 +534,7 @@ void MyEvtHandler::OnEndDragRight(double x, double y, int WXUNUSED(keys), int WX // 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))) { canvas->view->GetDocument()->GetCommandProcessor()->Submit( @@ -554,7 +556,7 @@ void MyEvtHandler::OnEndSize(double WXUNUSED(x), double WXUNUSED(y)) */ #if wxUSE_PROLOGIO - + bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr) { wxDiagram::OnShapeSave(db, shape, expr); @@ -570,7 +572,7 @@ bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr) expr.AssignAttributeValue(_T("label"), &label); MyEvtHandler *handler = new MyEvtHandler(&shape, &shape, wxString(label)); shape.SetEventHandler(handler); - + if (label) delete[] label; return true; @@ -602,7 +604,7 @@ wxDiamondShape::wxDiamondShape(double w, double h): w = 60.0; if (h == 0.0) h = 60.0; - + wxList *thePoints = new wxList; wxRealPoint *point = new wxRealPoint(0.0, (-h/2.0)); thePoints->Append((wxObject*) point);