+// ----------------------------------------------------------------------------
+// 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())
+ {
+ m_canvas->SetScrollbars( 1, 1, image->GetWidth(), image->GetHeight() );
+ }
+}
+
+void wxImageView::OnDraw(wxDC* dc)
+{
+ const wxImage* image = GetDocument()->GetImage();
+ if (image->IsOk())
+ {
+ dc->DrawBitmap(wxBitmap(*image), 0, 0);
+ }
+}
+
+bool wxImageView::OnClose(bool deleteWindow)
+{
+ if ( !GetDocument()->Close() )
+ return false;
+
+ Activate(false);
+
+ if ( wxGetApp().GetMode() == MyApp::Mode_Single )
+ {
+ GetDocument()->DeleteContents();
+ }
+ else // not single window mode
+ {
+ if ( deleteWindow )
+ wxDELETE(m_frame);
+ }
+ return true;
+}