r3877: Auto commit for Debian build
[ctsim.git] / src / views.cpp
index 7636f07ede17d1fd0d3f3e3e79cae45c300108c6..88e5f042fc7dc22b2a030fec80d9713b98c7b42f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.161 2002/06/06 22:50:24 kevin Exp $
+**  $Id: views.cpp,v 1.167 2003/01/29 07:18:38 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -184,7 +184,7 @@ ImageFileCanvas::OnChar (wxKeyEvent& event)
     if (m_pView)
       m_pView->OnUpdate (NULL);
   } else
-    wxScrolledWindow::OnChar (event);
+    event.Skip();
 }
 
 wxSize
@@ -268,9 +268,9 @@ EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram)
 END_EVENT_TABLE()
 
 ImageFileView::ImageFileView() 
-: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0), m_pFilterMenu(0), 
-  m_bMinSpecified(false), m_bMaxSpecified(false), 
-  m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG)
+  :  wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0),
+     m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false),
+     m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG)
 {}
 
 ImageFileView::~ImageFileView()
@@ -329,6 +329,7 @@ ImageFileView::OnScaleAuto (wxCommandEvent& event)
       m_dMinPixel = dMin;
       m_dMaxPixel = dMax;
       m_dAutoScaleFactor = dialogAutoScale.getAutoScaleFactor();
+      OnUpdate(this, NULL);
       GetDocument()->UpdateAllViews (this);
     }
   }
@@ -908,11 +909,9 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
@@ -1062,8 +1061,10 @@ ImageFileView::setInitialClientSize ()
 void 
 ImageFileView::OnDraw (wxDC* dc)
 {
-  if (m_bitmap.Ok())
-    dc->DrawBitmap(m_bitmap, 0, 0, false);
+  if (m_pBitmap && m_pBitmap->Ok()) {
+    *theApp->getLog() << "Drawing bitmap";
+    dc->DrawBitmap(*m_pBitmap, 0, 0, false);
+  }
   
   int xCursor, yCursor;
   if (m_pCanvas->GetCurrentCursor (xCursor, yCursor))
@@ -1113,7 +1114,12 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
       }
     }
     wxImage image (nx, ny, imageData, true);
-    m_bitmap = image.ConvertToBitmap();
+    if (m_pBitmap) {
+      delete m_pBitmap;
+      m_pBitmap = NULL;
+    }
+    *theApp->getLog() << "Making new bitmap bitmap";
+    m_pBitmap = new wxBitmap (image);
     delete imageData;
     m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20);
     m_pCanvas->SetBackgroundColour(*wxWHITE);
@@ -1154,8 +1160,9 @@ void
 ImageFileView::OnEditCopy (wxCommandEvent& event)
 {
   wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject;
-  
-  pBitmapObject->SetBitmap (m_bitmap);
+
+  if (m_pBitmap)
+    pBitmapObject->SetBitmap (*m_pBitmap);
   
   if (wxTheClipboard->Open()) {
     wxTheClipboard->SetData (pBitmapObject);
@@ -1198,7 +1205,7 @@ ImageFileView::OnEditPaste (wxCommandEvent& event)
     bool bMonochrome = false;
 
     if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) {
-      wxImage image (bitmap);
+      wxImage image (bitmap.ConvertToImage());
       double dScale3 = 3 * 255;
       unsigned char* pixels = image.GetData();
       ImageFileArray v = rIF.getArray();
@@ -2299,11 +2306,9 @@ PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
@@ -2465,7 +2470,7 @@ END_EVENT_TABLE()
 
 
 ProjectionFileView::ProjectionFileView() 
-: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
+  : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
 {
 #ifdef DEBUG
   m_iDefaultNX = 115;
@@ -3020,11 +3025,9 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
@@ -3100,8 +3103,8 @@ ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 void 
 ProjectionFileView::OnDraw (wxDC* dc)
 {
-  if (m_bitmap.Ok())
-    dc->DrawBitmap (m_bitmap, 0, 0, false);
+  if (m_pBitmap && m_pBitmap->Ok())
+    dc->DrawBitmap (*m_pBitmap, 0, 0, false);
 }
 
 
@@ -3156,7 +3159,11 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)
       }
     }
     wxImage image (nDet, nView, imageData, true);
-    m_bitmap = image.ConvertToBitmap();
+    if (m_pBitmap) {
+      delete m_pBitmap;
+      m_pBitmap = NULL;
+    }
+    m_pBitmap = new wxBitmap (image);
     delete imageData;
   }
   
@@ -3371,11 +3378,9 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);
   
@@ -3630,11 +3635,9 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append(MAINMENU_IMPORT, "&Import...\tCtrl-M");
-#ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
   m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
-#endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
   GetDocumentManager()->FileHistoryUseMenu(m_pFileMenu);