X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/67d54b58cb92e83364b39c7534079c3699b9b6ea..582ca3535a3680817ec4448141437eb2812df090:/contrib/src/ogl/canvas.cpp diff --git a/contrib/src/ogl/canvas.cpp b/contrib/src/ogl/canvas.cpp index aa04b2d01c..3d9ec3d366 100644 --- a/contrib/src/ogl/canvas.cpp +++ b/contrib/src/ogl/canvas.cpp @@ -6,13 +6,9 @@ // Created: 12/07/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "canvas.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -21,32 +17,22 @@ #endif #ifndef WX_PRECOMP -#include +#include "wx/wx.h" #endif -#include +#if wxUSE_PROLOGIO +#include "wx/deprecated/wxexpr.h" +#endif #ifdef new #undef new #endif -#if wxUSE_IOSTREAMH -#include -#else -#include -#endif - #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include "wx/ogl/ogl.h" #define CONTROL_POINT_SIZE 6 @@ -68,9 +54,15 @@ BEGIN_EVENT_TABLE(wxShapeCanvas, wxScrolledWindow) EVT_MOUSE_EVENTS(wxShapeCanvas::OnMouseEvent) END_EVENT_TABLE() +const wxChar* wxShapeCanvasNameStr = wxT("shapeCanvas"); + // Object canvas -wxShapeCanvas::wxShapeCanvas(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style): - wxScrolledWindow(parent, id, pos, size, style) +wxShapeCanvas::wxShapeCanvas(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name): + wxScrolledWindow(parent, id, pos, size, style, name) { m_shapeDiagram = NULL; m_dragState = NoDragging; @@ -79,23 +71,24 @@ wxShapeCanvas::wxShapeCanvas(wxWindow *parent, wxWindowID id, const wxPoint& pos m_oldDragY = 0; m_firstDragX = 0; m_firstDragY = 0; - m_checkTolerance = TRUE; + m_checkTolerance = true; } wxShapeCanvas::~wxShapeCanvas() { } -void wxShapeCanvas::OnPaint(wxPaintEvent& event) +void wxShapeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); PrepareDC(dc); + dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); dc.Clear(); - if (GetDiagram()) - GetDiagram()->Redraw(dc); + if (GetDiagram()) + GetDiagram()->Redraw(dc); } void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) @@ -132,7 +125,7 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) // If we've ignored the tolerance once, then ALWAYS ignore // tolerance in this drag, even if we come back within // the tolerance range. - m_checkTolerance = FALSE; + m_checkTolerance = false; } // Dragging - note that the effect of dragging is left entirely up @@ -156,16 +149,16 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) else if (dragging && m_draggedShape && m_dragState == ContinueDraggingLeft) { // Continue dragging - m_draggedShape->GetEventHandler()->OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); - m_draggedShape->GetEventHandler()->OnDragLeft(TRUE, (double)x, (double)y, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragLeft(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragLeft(true, (double)x, (double)y, keys, m_draggedAttachment); m_oldDragX = x; m_oldDragY = y; } else if (event.LeftUp() && m_draggedShape && m_dragState == ContinueDraggingLeft) { m_dragState = NoDragging; - m_checkTolerance = TRUE; + m_checkTolerance = true; - m_draggedShape->GetEventHandler()->OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragLeft(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); m_draggedShape->GetEventHandler()->OnEndDragLeft((double)x, (double)y, keys, m_draggedAttachment); m_draggedShape = NULL; @@ -186,16 +179,16 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) else if (dragging && m_draggedShape && m_dragState == ContinueDraggingRight) { // Continue dragging - m_draggedShape->GetEventHandler()->OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); - m_draggedShape->GetEventHandler()->OnDragRight(TRUE, (double)x, (double)y, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragRight(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragRight(true, (double)x, (double)y, keys, m_draggedAttachment); m_oldDragX = x; m_oldDragY = y; } else if (event.RightUp() && m_draggedShape && m_dragState == ContinueDraggingRight) { m_dragState = NoDragging; - m_checkTolerance = TRUE; + m_checkTolerance = true; - m_draggedShape->GetEventHandler()->OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); + m_draggedShape->GetEventHandler()->OnDragRight(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment); m_draggedShape->GetEventHandler()->OnEndDragRight((double)x, (double)y, keys, m_draggedAttachment); m_draggedShape = NULL; @@ -211,16 +204,16 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingLeft) { // Continue dragging - OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys); - OnDragLeft(TRUE, (double)x, (double)y, keys); + OnDragLeft(false, m_oldDragX, m_oldDragY, keys); + OnDragLeft(true, (double)x, (double)y, keys); m_oldDragX = x; m_oldDragY = y; } else if (event.LeftUp() && !m_draggedShape && m_dragState == ContinueDraggingLeft) { m_dragState = NoDragging; - m_checkTolerance = TRUE; + m_checkTolerance = true; - OnDragLeft(FALSE, m_oldDragX, m_oldDragY, keys); + OnDragLeft(false, m_oldDragX, m_oldDragY, keys); OnEndDragLeft((double)x, (double)y, keys); m_draggedShape = NULL; } @@ -233,16 +226,16 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingRight) { // Continue dragging - OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys); - OnDragRight(TRUE, (double)x, (double)y, keys); + OnDragRight(false, m_oldDragX, m_oldDragY, keys); + OnDragRight(true, (double)x, (double)y, keys); m_oldDragX = x; m_oldDragY = y; } else if (event.RightUp() && !m_draggedShape && m_dragState == ContinueDraggingRight) { m_dragState = NoDragging; - m_checkTolerance = TRUE; + m_checkTolerance = true; - OnDragRight(FALSE, m_oldDragX, m_oldDragY, keys); + OnDragRight(false, m_oldDragX, m_oldDragY, keys); OnEndDragRight((double)x, (double)y, keys); m_draggedShape = NULL; } @@ -250,7 +243,7 @@ void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event) // Non-dragging events else if (event.IsButton()) { - m_checkTolerance = TRUE; + m_checkTolerance = true; // Find the nearest object int attachment = 0; @@ -361,7 +354,7 @@ wxShape *wxShapeCanvas::FindFirstSensitiveShape1(wxShape *image, int op) return NULL; } -// Helper function: TRUE if 'contains' wholly contains 'contained'. +// Helper function: true if 'contains' wholly contains 'contained'. static bool WhollyContains(wxShape *contains, wxShape *contained) { double xp1, yp1, xp2, yp2; @@ -396,10 +389,10 @@ wxShape *wxShapeCanvas::FindShape(double x, double y, int *attachment, wxClassIn // the other objects // (b) to find the control points FIRST if they exist - wxNode *current = GetDiagram()->GetShapeList()->Last(); + wxObjectList::compatibility_iterator current = GetDiagram()->GetShapeList()->GetLast(); while (current) { - wxShape *object = (wxShape *)current->Data(); + wxShape *object = (wxShape *)current->GetData(); double dist; int temp_attachment; @@ -429,13 +422,13 @@ wxShape *wxShapeCanvas::FindShape(double x, double y, int *attachment, wxClassIn } } if (current) - current = current->Previous(); + current = current->GetPrevious(); } - current = GetDiagram()->GetShapeList()->Last(); + current = GetDiagram()->GetShapeList()->GetLast(); while (current) { - wxShape *object = (wxShape *)current->Data(); + wxShape *object = (wxShape *)current->GetData(); double dist; int temp_attachment; @@ -452,15 +445,14 @@ wxShape *wxShapeCanvas::FindShape(double x, double y, int *attachment, wxClassIn // Check for division in case line straddles divisions (i.e. is not wholly contained). if (!nearest_object || !(object->IsKindOf(CLASSINFO(wxDivisionShape)) || WhollyContains(object, nearest_object))) { - nearest = dist; nearest_object = object; nearest_attachment = temp_attachment; - current = NULL; + current = GetDiagram()->GetShapeList()->GetFirst()->GetPrevious(); // finish loop } } } if (current) - current = current->Previous(); + current = current->GetPrevious(); } *attachment = nearest_attachment; @@ -472,35 +464,35 @@ wxShape *wxShapeCanvas::FindShape(double x, double y, int *attachment, wxClassIn * */ -void wxShapeCanvas::OnLeftClick(double x, double y, int keys) +void wxShapeCanvas::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnRightClick(double x, double y, int keys) +void wxShapeCanvas::OnRightClick(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnDragLeft(bool draw, double x, double y, int keys) +void wxShapeCanvas::OnDragLeft(bool WXUNUSED(draw), double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnBeginDragLeft(double x, double y, int keys) +void wxShapeCanvas::OnBeginDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnEndDragLeft(double x, double y, int keys) +void wxShapeCanvas::OnEndDragLeft(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnDragRight(bool draw, double x, double y, int keys) +void wxShapeCanvas::OnDragRight(bool WXUNUSED(draw), double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnBeginDragRight(double x, double y, int keys) +void wxShapeCanvas::OnBeginDragRight(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { } -void wxShapeCanvas::OnEndDragRight(double x, double y, int keys) +void wxShapeCanvas::OnEndDragRight(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys)) { }