X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fc25a89ac1e6c5208db24bfc0abc8666b791dc6..59455c67d444c12f6d6a59e0c16528554c8b4c30:/contrib/samples/ogl/ogledit/doc.cpp diff --git a/contrib/samples/ogl/ogledit/doc.cpp b/contrib/samples/ogl/ogledit/doc.cpp index 3557696662..88a17da9ec 100644 --- a/contrib/samples/ogl/ogledit/doc.cpp +++ b/contrib/samples/ogl/ogledit/doc.cpp @@ -14,7 +14,7 @@ #endif // For compilers that support precompilation, includes "wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -28,13 +28,12 @@ #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! #endif -#include #include "ogledit.h" #include "doc.h" #include "view.h" #if wxUSE_STD_IOSTREAM -#include +#include #endif IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument) @@ -54,7 +53,7 @@ bool DiagramDocument::OnCloseDocument(void) } #if wxUSE_STD_IOSTREAM -ostream& DiagramDocument::SaveObject(ostream& stream) +wxSTD ostream& DiagramDocument::SaveObject(wxSTD ostream& stream) { wxDocument::SaveObject(stream); @@ -69,7 +68,7 @@ ostream& DiagramDocument::SaveObject(ostream& stream) return stream; } -istream& DiagramDocument::LoadObject(istream& stream) +wxSTD istream& DiagramDocument::LoadObject(wxSTD istream& stream) { wxDocument::LoadObject(stream); @@ -88,33 +87,37 @@ istream& DiagramDocument::LoadObject(istream& stream) wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream) { +#if wxUSE_PROLOGIO + wxDocument::SaveObject(stream); - char buf[400]; - (void) wxGetTempFileName("diag", buf); + wxChar buf[400]; + (void) wxGetTempFileName(_T("diag"), buf); diagram.SaveFile(buf); wxTransferFileToStream(buf, stream); wxRemoveFile(buf); - + +#endif return stream; } wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream) { +#if wxUSE_PROLOGIO wxDocument::LoadObject(stream); - - char buf[400]; - (void) wxGetTempFileName("diag", buf); + wxChar buf[400]; + (void) wxGetTempFileName(_T("diag"), buf); wxTransferStreamToFile(stream, buf); diagram.DeleteAllShapes(); diagram.LoadFile(buf); wxRemoveFile(buf); +#endif return stream; } @@ -125,7 +128,7 @@ wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream) * Implementation of drawing command */ -DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double yy, +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) { @@ -143,7 +146,7 @@ DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, w deleteShape = FALSE; } -DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape): +DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape): wxCommand(TRUE, name) { doc = ddoc; @@ -160,7 +163,7 @@ DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, w shapePen = NULL; } -DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape): +DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape): wxCommand(TRUE, name) { doc = ddoc; @@ -219,14 +222,14 @@ bool DiagramCommand::Do(void) } case OGLEDIT_ADD_SHAPE: { - wxShape *theShape = NULL; + wxShape *theShape; if (shape) theShape = shape; // Saved from undoing the shape else { theShape = (wxShape *)shapeInfo->CreateObject(); theShape->AssignNewIds(); - theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString(""))); + theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxEmptyString)); theShape->SetCentreResize(FALSE); theShape->SetPen(wxBLACK_PEN); theShape->SetBrush(wxCYAN_BRUSH); @@ -250,14 +253,14 @@ bool DiagramCommand::Do(void) } case OGLEDIT_ADD_LINE: { - wxShape *theShape = NULL; + wxShape *theShape; if (shape) theShape = shape; // Saved from undoing the line else { theShape = (wxShape *)shapeInfo->CreateObject(); theShape->AssignNewIds(); - theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString(""))); + theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxEmptyString)); theShape->SetPen(wxBLACK_PEN); theShape->SetBrush(wxRED_BRUSH); @@ -266,7 +269,7 @@ bool DiagramCommand::Do(void) // Yes, you can have more than 2 control points, in which case // it becomes a multi-segment line. lineShape->MakeLineControlPoints(2); - lineShape->AddArrow(ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, "Normal arrowhead"); + lineShape->AddArrow(ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, _T("Normal arrowhead")); } doc->GetDiagram()->AddShape(theShape); @@ -320,7 +323,7 @@ bool DiagramCommand::Do(void) wxClientDC dc(shape->GetCanvas()); shape->GetCanvas()->PrepareDC(dc); - shape->FormatText(dc, (char*) (const char*) myHandler->label); + shape->FormatText(dc, /* (char*) (const char*) */ myHandler->label); shape->Draw(dc); doc->Modify(TRUE); @@ -405,7 +408,7 @@ bool DiagramCommand::Undo(void) wxClientDC dc(shape->GetCanvas()); shape->GetCanvas()->PrepareDC(dc); - shape->FormatText(dc, (char*) (const char*) myHandler->label); + shape->FormatText(dc, /* (char*) (const char*) */ myHandler->label); shape->Draw(dc); doc->Modify(TRUE); @@ -421,13 +424,13 @@ bool DiagramCommand::Undo(void) // Remove each individual line connected to a shape by sending a command. void DiagramCommand::RemoveLines(wxShape *shape) { - wxNode *node = shape->GetLines().First(); + wxNode *node = shape->GetLines().GetFirst(); while (node) { - wxLineShape *line = (wxLineShape *)node->Data(); - doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line)); + wxLineShape *line = (wxLineShape *)node->GetData(); + doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line)); - node = shape->GetLines().First(); + node = shape->GetLines().GetFirst(); } } @@ -435,7 +438,7 @@ void DiagramCommand::RemoveLines(wxShape *shape) * MyEvtHandler: an event handler class for all shapes */ -void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment) +void MyEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment)) { wxClientDC dc(GetShape()->GetCanvas()); GetShape()->GetCanvas()->PrepareDC(dc); @@ -452,10 +455,10 @@ void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment) { // Ensure no other shape is selected, to simplify Undo/Redo code bool redraw = FALSE; - wxNode *node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->First(); + wxNode *node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst(); while (node) { - wxShape *eachShape = (wxShape *)node->Data(); + wxShape *eachShape = (wxShape *)node->GetData(); if (eachShape->GetParent() == NULL) { if (eachShape->Selected()) @@ -464,7 +467,7 @@ void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment) redraw = TRUE; } } - node = node->Next(); + node = node->GetNext(); } GetShape()->Select(TRUE, &dc); if (redraw) @@ -485,7 +488,7 @@ void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment) * Implement connection of two shapes by right-dragging between them. */ -void MyEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment) +void MyEvtHandler::OnBeginDragRight(double x, double y, int WXUNUSED(keys), int attachment) { // 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. @@ -503,7 +506,7 @@ void MyEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment GetShape()->GetCanvas()->CaptureMouse(); } -void MyEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int attachment) +void MyEvtHandler::OnDragRight(bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int attachment) { // Force attachment to be zero for now attachment = 0; @@ -519,7 +522,7 @@ void MyEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int atta dc.DrawLine((long) xp, (long) yp, (long) x, (long) y); } -void MyEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment) +void MyEvtHandler::OnEndDragRight(double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { GetShape()->GetCanvas()->ReleaseMouse(); MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas(); @@ -531,36 +534,38 @@ void MyEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment) if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape))) { canvas->view->GetDocument()->GetCommandProcessor()->Submit( - new DiagramCommand("wxLineShape", OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape), + new DiagramCommand(_T("wxLineShape"), OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape), 0.0, 0.0, FALSE, NULL, GetShape(), otherShape)); } } -void MyEvtHandler::OnEndSize(double x, double y) +void MyEvtHandler::OnEndSize(double WXUNUSED(x), double WXUNUSED(y)) { wxClientDC dc(GetShape()->GetCanvas()); GetShape()->GetCanvas()->PrepareDC(dc); - GetShape()->FormatText(dc, (char*) (const char*) label); + GetShape()->FormatText(dc, /* (char*) (const char*) */ label); } /* * Diagram */ + +#if wxUSE_PROLOGIO bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr) { wxDiagram::OnShapeSave(db, shape, expr); MyEvtHandler *handler = (MyEvtHandler *)shape.GetEventHandler(); - expr.AddAttributeValueString("label", handler->label); + expr.AddAttributeValueString(_T("label"), handler->label); return TRUE; } bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr) { wxDiagram::OnShapeLoad(db, shape, expr); - char *label = NULL; - expr.AssignAttributeValue("label", &label); + wxChar *label = NULL; + expr.AssignAttributeValue(_T("label"), &label); MyEvtHandler *handler = new MyEvtHandler(&shape, &shape, wxString(label)); shape.SetEventHandler(handler); @@ -569,6 +574,8 @@ bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr) return TRUE; } +#endif + /* * New shapes */