]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/image/image.cpp
Fix a crash in wxExecute() in wxMSW too.
[wxWidgets.git] / samples / image / image.cpp
index 5daf5736b6cf8b29aceaed2f184a7c3d6293be7b..e9de0eecc743c5c21025daae76689ffb22ce532c 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "canvas.h"
 
 
 #include "canvas.h"
 
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
     #include "../sample.xpm"
 #endif
 
@@ -150,7 +150,7 @@ private:
         m_zoom = 1.;
 
         wxMenu *menu = new wxMenu;
         m_zoom = 1.;
 
         wxMenu *menu = new wxMenu;
-        menu->Append(wxID_SAVE);
+        menu->Append(wxID_SAVEAS);
         menu->AppendSeparator();
         menu->AppendCheckItem(ID_PAINT_BG, wxT("&Paint background"),
                               "Uncheck this for transparent images");
         menu->AppendSeparator();
         menu->AppendCheckItem(ID_PAINT_BG, wxT("&Paint background"),
                               "Uncheck this for transparent images");
@@ -214,7 +214,7 @@ private:
         wxString savefilename = wxFileSelector( wxT("Save Image"),
                                                 wxEmptyString,
                                                 wxEmptyString,
         wxString savefilename = wxFileSelector( wxT("Save Image"),
                                                 wxEmptyString,
                                                 wxEmptyString,
-                                                (const wxChar *)NULL,
+                                                wxEmptyString,
                                                 wxT("BMP files (*.bmp)|*.bmp|")
 #if wxUSE_LIBPNG
                                                 wxT("PNG files (*.png)|*.png|")
                                                 wxT("BMP files (*.bmp)|*.bmp|")
 #if wxUSE_LIBPNG
                                                 wxT("PNG files (*.png)|*.png|")
@@ -230,10 +230,13 @@ private:
 #endif
 #if wxUSE_PCX
                                                 wxT("PCX files (*.pcx)|*.pcx|")
 #endif
 #if wxUSE_PCX
                                                 wxT("PCX files (*.pcx)|*.pcx|")
+#endif
+#if wxUSE_XPM
+                                                wxT("X PixMap files (*.xpm)|*.xpm|")
 #endif
                                                 wxT("ICO files (*.ico)|*.ico|")
                                                 wxT("CUR files (*.cur)|*.cur"),
 #endif
                                                 wxT("ICO files (*.ico)|*.ico|")
                                                 wxT("CUR files (*.cur)|*.cur"),
-                                                wxFD_SAVE,
+                                                wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
                                                 this);
 
         if ( savefilename.empty() )
                                                 this);
 
         if ( savefilename.empty() )
@@ -590,7 +593,7 @@ BEGIN_EVENT_TABLE(MyImageFrame, wxFrame)
     EVT_ERASE_BACKGROUND(MyImageFrame::OnEraseBackground)
     EVT_PAINT(MyImageFrame::OnPaint)
 
     EVT_ERASE_BACKGROUND(MyImageFrame::OnEraseBackground)
     EVT_PAINT(MyImageFrame::OnPaint)
 
-    EVT_MENU(wxID_SAVE, MyImageFrame::OnSave)
+    EVT_MENU(wxID_SAVEAS, MyImageFrame::OnSave)
     EVT_MENU_RANGE(ID_ROTATE_LEFT, ID_ROTATE_RIGHT, MyImageFrame::OnRotate)
     EVT_MENU(ID_RESIZE, MyImageFrame::OnResize)
 
     EVT_MENU_RANGE(ID_ROTATE_LEFT, ID_ROTATE_RIGHT, MyImageFrame::OnRotate)
     EVT_MENU(ID_RESIZE, MyImageFrame::OnResize)
 
@@ -668,7 +671,7 @@ MyFrame::MyFrame()
     menuImage->Append( ID_SHOWTHUMBNAIL, wxT("Test &thumbnail...\tCtrl-T"),
                         "Test scaling the image during load (try with JPEG)");
     menuImage->AppendSeparator();
     menuImage->Append( ID_SHOWTHUMBNAIL, wxT("Test &thumbnail...\tCtrl-T"),
                         "Test scaling the image during load (try with JPEG)");
     menuImage->AppendSeparator();
-    menuImage->Append( ID_ABOUT, wxT("&About...\tF1"));
+    menuImage->Append( ID_ABOUT, wxT("&About\tF1"));
     menuImage->AppendSeparator();
     menuImage->Append( ID_QUIT, wxT("E&xit\tCtrl-Q"));
     menu_bar->Append(menuImage, wxT("&Image"));
     menuImage->AppendSeparator();
     menuImage->Append( ID_QUIT, wxT("E&xit\tCtrl-Q"));
     menu_bar->Append(menuImage, wxT("&Image"));
@@ -944,10 +947,14 @@ void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
         return;
     }
 
         return;
     }
 
+    int origWidth = image.GetOptionInt( wxIMAGE_OPTION_ORIGINAL_WIDTH );
+    int origHeight = image.GetOptionInt( wxIMAGE_OPTION_ORIGINAL_HEIGHT );
+
     const long loadTime = sw.Time();
 
     MyImageFrame * const frame = new MyImageFrame(this, filename, image);
     const long loadTime = sw.Time();
 
     MyImageFrame * const frame = new MyImageFrame(this, filename, image);
-    wxLogStatus(frame, "Loaded \"%s\" in %ldms", filename, loadTime);
+    wxLogStatus(frame, "Loaded \"%s\" in %ldms; original size was (%d, %d)",
+                filename, loadTime, origWidth, origHeight);
 #else
     wxLogError( wxT("Couldn't create file selector dialog") );
     return;
 #else
     wxLogError( wxT("Couldn't create file selector dialog") );
     return;