X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e00cf2c4c82171dec8298d7324504e96114efbc..ec75509f94fb11322c1c69056d1ec2af8f041fe2:/contrib/samples/ogl/ogledit/view.cpp diff --git a/contrib/samples/ogl/ogledit/view.cpp b/contrib/samples/ogl/ogledit/view.cpp index 7552a02271..a23020a93d 100644 --- a/contrib/samples/ogl/ogledit/view.cpp +++ b/contrib/samples/ogl/ogledit/view.cpp @@ -6,7 +6,7 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -38,21 +38,21 @@ IMPLEMENT_DYNAMIC_CLASS(DiagramView, wxView) BEGIN_EVENT_TABLE(DiagramView, wxView) - EVT_MENU(OGLEDIT_CUT, DiagramView::OnCut) + EVT_MENU(wxID_CUT, DiagramView::OnCut) EVT_MENU(OGLEDIT_CHANGE_BACKGROUND_COLOUR, DiagramView::OnChangeBackgroundColour) EVT_MENU(OGLEDIT_EDIT_LABEL, DiagramView::OnEditLabel) END_EVENT_TABLE() // What to do when a view is created. Creates actual // windows for displaying the view. -bool DiagramView::OnCreate(wxDocument *doc, long flags) +bool DiagramView::OnCreate(wxDocument *doc, long WXUNUSED(flags)) { frame = GetMainFrame(); canvas = GetMainFrame()->canvas; canvas->view = this; SetFrame(frame); - Activate(TRUE); + Activate(true); // Initialize the edit menu Undo and Redo items doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu); @@ -63,10 +63,10 @@ bool DiagramView::OnCreate(wxDocument *doc, long flags) shapeCanvas->SetDiagram(diagramDoc->GetDiagram()); diagramDoc->GetDiagram()->SetCanvas(shapeCanvas); - return TRUE; + return true; } -#define CENTER FALSE // Place the drawing to the center of the page +#define CENTER false // Place the drawing to the center of the page // Sneakily gets used for default print/preview @@ -105,16 +105,15 @@ void DiagramView::OnDraw(wxDC *dc) float posX, posY; // Calculate the position on the DC for centring the graphic - if (CENTER == TRUE) // center the drawing - { + #if 0 + // center the drawing posX = (float) ((w - (200 * actualScale)) / 2.0); posY = (float) ((h - (200 * actualScale)) / 2.0); - } - else // Use defined presets - { + #else + // Use defined presets posX = 10; posY = 35; - } + #endif // Set the scale and origin @@ -127,33 +126,33 @@ void DiagramView::OnDraw(wxDC *dc) wxDiagram *diagram_p=((DiagramDocument*)GetDocument())->GetDiagram(); // Get the current diagram if (diagram_p->GetShapeList()) { - wxCursor *old_cursor = NULL; - wxNode *current = diagram_p->GetShapeList()->First(); + /* wxCursor *old_cursor = NULL; */ + wxObjectList::compatibility_iterator current = diagram_p->GetShapeList()->GetFirst(); while (current) // Loop through the entire list of shapes { - wxShape *object = (wxShape *)current->Data(); + wxShape *object = (wxShape *)current->GetData(); if (!object->GetParent()) { object->Draw(* dc); // Draw the shape onto our printing dc } - current = current->Next(); // Procede to the next shape in the list + current = current->GetNext(); // Procede to the next shape in the list } } dc->EndDrawing(); // Allows optimization of drawing code under MS Windows. } -void DiagramView::OnUpdate(wxView *sender, wxObject *hint) +void DiagramView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) { if (canvas) canvas->Refresh(); } // Clean up windows used for displaying the view. -bool DiagramView::OnClose(bool deleteWindow) +bool DiagramView::OnClose(bool WXUNUSED(deleteWindow)) { if (!GetDocument()->Close()) - return FALSE; + return false; DiagramDocument *diagramDoc = (DiagramDocument *)GetDocument(); diagramDoc->GetDiagram()->SetCanvas(NULL); @@ -169,39 +168,37 @@ bool DiagramView::OnClose(bool deleteWindow) SetFrame(NULL); - Activate(FALSE); + Activate(false); - return TRUE; + return true; } wxShape *DiagramView::FindSelectedShape(void) { DiagramDocument *doc = (DiagramDocument *)GetDocument(); - wxShape *theShape = NULL; - wxNode *node = doc->GetDiagram()->GetShapeList()->First(); + wxObjectList::compatibility_iterator node = doc->GetDiagram()->GetShapeList()->GetFirst(); while (node) { - wxShape *eachShape = (wxShape *)node->Data(); + wxShape *eachShape = (wxShape *)node->GetData(); if ((eachShape->GetParent() == NULL) && eachShape->Selected()) { - theShape = eachShape; - node = NULL; + return eachShape; } - else node = node->Next(); + else node = node->GetNext(); } - return theShape; + return NULL; } -void DiagramView::OnCut(wxCommandEvent& event) +void DiagramView::OnCut(wxCommandEvent& WXUNUSED(event)) { DiagramDocument *doc = (DiagramDocument *)GetDocument(); wxShape *theShape = FindSelectedShape(); if (theShape) - doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, TRUE, theShape)); + doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), wxID_CUT, doc, NULL, 0.0, 0.0, true, theShape)); } -void DiagramView::OnChangeBackgroundColour(wxCommandEvent& event) +void DiagramView::OnChangeBackgroundColour(wxCommandEvent& WXUNUSED(event)) { DiagramDocument *doc = (DiagramDocument *)GetDocument(); @@ -209,7 +206,7 @@ void DiagramView::OnChangeBackgroundColour(wxCommandEvent& event) if (theShape) { wxColourData data; - data.SetChooseFull(TRUE); + data.SetChooseFull(true); data.SetColour(theShape->GetBrush()->GetColour()); wxColourDialog *dialog = new wxColourDialog(frame, &data); @@ -223,18 +220,18 @@ void DiagramView::OnChangeBackgroundColour(wxCommandEvent& event) dialog->Close(); if (theBrush) - doc->GetCommandProcessor()->Submit(new DiagramCommand("Change colour", OGLEDIT_CHANGE_BACKGROUND_COLOUR, doc, + doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Change colour"), OGLEDIT_CHANGE_BACKGROUND_COLOUR, doc, theBrush, theShape)); } } -void DiagramView::OnEditLabel(wxCommandEvent& event) +void DiagramView::OnEditLabel(wxCommandEvent& WXUNUSED(event)) { wxShape *theShape = FindSelectedShape(); if (theShape) { - wxString newLabel = wxGetTextFromUser("Enter new label", "Shape Label", ((MyEvtHandler *)theShape->GetEventHandler())->label); - GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand("Edit label", OGLEDIT_EDIT_LABEL, (DiagramDocument*) GetDocument(), newLabel, theShape)); + wxString newLabel = wxGetTextFromUser(_T("Enter new label"), _T("Shape Label"), ((MyEvtHandler *)theShape->GetEventHandler())->label); + GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand(_T("Edit label"), OGLEDIT_EDIT_LABEL, (DiagramDocument*) GetDocument(), newLabel, theShape)); } } @@ -261,7 +258,7 @@ MyCanvas::~MyCanvas(void) { } -void MyCanvas::OnLeftClick(double x, double y, int keys) +void MyCanvas::OnLeftClick(double x, double y, int WXUNUSED(keys)) { EditorToolPalette *palette = wxGetApp().frame->palette; wxClassInfo *info = NULL; @@ -293,36 +290,36 @@ void MyCanvas::OnLeftClick(double x, double y, int keys) if (info) { view->GetDocument()->GetCommandProcessor()->Submit( - new DiagramCommand((char*) info->GetClassName(), OGLEDIT_ADD_SHAPE, (DiagramDocument *)view->GetDocument(), info, + new DiagramCommand( info->GetClassName(), OGLEDIT_ADD_SHAPE, (DiagramDocument *)view->GetDocument(), info, x, y)); } } -void MyCanvas::OnRightClick(double x, double y, int keys) +void MyCanvas::OnRightClick(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnDragLeft(bool draw, double x, double y, int keys) +void MyCanvas::OnDragLeft(bool WXUNUSED(draw), double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnBeginDragLeft(double x, double y, int keys) +void MyCanvas::OnBeginDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnEndDragLeft(double x, double y, int keys) +void MyCanvas::OnEndDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnDragRight(bool draw, double x, double y, int keys) +void MyCanvas::OnDragRight(bool WXUNUSED(draw), double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnBeginDragRight(double x, double y, int keys) +void MyCanvas::OnBeginDragRight(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void MyCanvas::OnEndDragRight(double x, double y, int keys) +void MyCanvas::OnEndDragRight(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { }