+
+ // 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;
+}
+
+// ----------------------------------------------------------------------------
+// ImageCanvas implementation
+// ----------------------------------------------------------------------------
+
+// Define a constructor for my canvas
+ImageCanvas::ImageCanvas(wxView* view, wxWindow* parent)
+ : wxScrolledWindow(parent, wxID_ANY, wxPoint(0, 0), parent->GetClientSize())
+{
+ SetScrollRate( 10, 10 );
+
+ m_view = view;
+}
+
+// Define the repainting behaviour
+void ImageCanvas::OnDraw(wxDC& dc)
+{
+ if ( m_view )
+ m_view->OnDraw(& dc);
+}
+
+// ----------------------------------------------------------------------------
+// ImageView implementation
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(ImageView, wxView)
+
+ImageDocument* ImageView::GetDocument()
+{
+ return wxStaticCast(wxView::GetDocument(), ImageDocument);
+}
+
+bool ImageView::OnCreate(wxDocument* doc, long WXUNUSED(flags))
+{
+ m_frame = wxGetApp().CreateChildFrame(doc, this, false);
+ m_frame->SetTitle("Image View");
+ m_canvas = new ImageCanvas(this, m_frame);
+ m_frame->Show(true);
+ Activate(true);
+ return true;
+}
+
+void ImageView::OnUpdate(wxView* sender, wxObject* hint)
+{
+ wxView::OnUpdate(sender, hint);
+ wxImage image = GetDocument()->GetImage();
+ if ( image.IsOk() )