+
+ // is this the start of a new segment?
+ if ( m_lastMousePos != wxDefaultPosition && event.Dragging() )
+ {
+ if ( !m_currentSegment )
+ m_currentSegment = new DoodleSegment;
+
+ m_currentSegment->AddLine(m_lastMousePos, pt);
+
+ dc.DrawLine(m_lastMousePos, pt);
+ }
+
+ m_lastMousePos = pt;
+}
+
+// ----------------------------------------------------------------------------
+// wxImageCanvas implementation
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxImageCanvas, wxScrolledWindow)
+END_EVENT_TABLE()
+
+// Define a constructor for my canvas
+wxImageCanvas::wxImageCanvas(wxView* view, wxWindow* parent)
+ : wxScrolledWindow(parent, wxID_ANY, wxPoint(0, 0), parent->GetClientSize())
+{
+ m_view = view;
+}
+
+// Define the repainting behaviour
+void wxImageCanvas::OnDraw(wxDC& dc)
+{
+ if ( m_view )
+ m_view->OnDraw(& dc);
+}
+
+// ----------------------------------------------------------------------------
+// wxImageView implementation
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxImageView, wxView)
+
+BEGIN_EVENT_TABLE(wxImageView, wxView)
+END_EVENT_TABLE()
+
+wxImageDocument* wxImageView::GetDocument()
+{
+ return wxStaticCast(wxView::GetDocument(), wxImageDocument);
+}
+
+bool wxImageView::OnCreate(wxDocument* doc, long WXUNUSED(flags))
+{
+ m_frame = wxGetApp().CreateChildFrame(doc, this, false);
+ m_frame->SetTitle("Image View");
+ m_canvas = new wxImageCanvas(this, m_frame);
+ m_frame->Show(true);
+ Activate(true);
+ return true;
+}
+
+void wxImageView::OnUpdate(wxView* sender, wxObject* hint)
+{
+ wxView::OnUpdate(sender, hint);
+ const wxImage* image = GetDocument()->GetImage();
+ if (image->IsOk())