]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/image/image.cpp
Remove wxRTTI macro for wxComboBox from Motif port.
[wxWidgets.git] / samples / image / image.cpp
index b18a797ac681e90305cb642ea3c31f20d173031d..e9de0eecc743c5c21025daae76689ffb22ce532c 100644 (file)
@@ -7,7 +7,7 @@
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998-2005 Robert Roebling
 //              (c) 2005-2009 Vadim Zeitlin
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998-2005 Robert Roebling
 //              (c) 2005-2009 Vadim Zeitlin
-// License:     wxWindows licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
 ///////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/image.h"
 #include "wx/file.h"
 #include "wx/filename.h"
 #include "wx/image.h"
 #include "wx/file.h"
 #include "wx/filename.h"
+#include "wx/graphics.h"
 #include "wx/mstream.h"
 #include "wx/wfstream.h"
 #include "wx/quantize.h"
 #include "wx/mstream.h"
 #include "wx/wfstream.h"
 #include "wx/quantize.h"
+#include "wx/scopedptr.h"
 #include "wx/stopwatch.h"
 #include "wx/stopwatch.h"
+#include "wx/versioninfo.h"
 
 #if wxUSE_CLIPBOARD
     #include "wx/dataobj.h"
 
 #if wxUSE_CLIPBOARD
     #include "wx/dataobj.h"
@@ -47,7 +50,7 @@
 
 #include "canvas.h"
 
 
 #include "canvas.h"
 
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
     #include "../sample.xpm"
 #endif
 
@@ -82,6 +85,9 @@ public:
 #ifdef wxHAVE_RAW_BITMAP
     void OnTestRawBitmap( wxCommandEvent &event );
 #endif // wxHAVE_RAW_BITMAP
 #ifdef wxHAVE_RAW_BITMAP
     void OnTestRawBitmap( wxCommandEvent &event );
 #endif // wxHAVE_RAW_BITMAP
+#if wxUSE_GRAPHICS_CONTEXT
+    void OnTestGraphics(wxCommandEvent& event);
+#endif // wxUSE_GRAPHICS_CONTEXT
     void OnQuit( wxCommandEvent &event );
 
 #if wxUSE_CLIPBOARD
     void OnQuit( wxCommandEvent &event );
 
 #if wxUSE_CLIPBOARD
@@ -135,7 +141,7 @@ private:
                 int numImages = 1)
     {
         if ( !wxFrame::Create(parent, wxID_ANY,
                 int numImages = 1)
     {
         if ( !wxFrame::Create(parent, wxID_ANY,
-                              wxString::Format(_T("Image from %s"), desc),
+                              wxString::Format(wxT("Image from %s"), desc),
                               wxDefaultPosition, wxDefaultSize,
                               wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE) )
             return false;
                               wxDefaultPosition, wxDefaultSize,
                               wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE) )
             return false;
@@ -144,21 +150,21 @@ 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->AppendSeparator();
-        menu->AppendCheckItem(ID_PAINT_BG, _T("&Paint background"),
+        menu->AppendCheckItem(ID_PAINT_BG, wxT("&Paint background"),
                               "Uncheck this for transparent images");
         menu->AppendSeparator();
                               "Uncheck this for transparent images");
         menu->AppendSeparator();
-        menu->Append(ID_RESIZE, _T("&Fit to window\tCtrl-F"));
+        menu->Append(ID_RESIZE, wxT("&Fit to window\tCtrl-F"));
         menu->Append(wxID_ZOOM_IN, "Zoom &in\tCtrl-+");
         menu->Append(wxID_ZOOM_OUT, "Zoom &out\tCtrl--");
         menu->Append(wxID_ZOOM_100, "Reset zoom to &100%\tCtrl-1");
         menu->AppendSeparator();
         menu->Append(wxID_ZOOM_IN, "Zoom &in\tCtrl-+");
         menu->Append(wxID_ZOOM_OUT, "Zoom &out\tCtrl--");
         menu->Append(wxID_ZOOM_100, "Reset zoom to &100%\tCtrl-1");
         menu->AppendSeparator();
-        menu->Append(ID_ROTATE_LEFT, _T("Rotate &left\tCtrl-L"));
-        menu->Append(ID_ROTATE_RIGHT, _T("Rotate &right\tCtrl-R"));
+        menu->Append(ID_ROTATE_LEFT, wxT("Rotate &left\tCtrl-L"));
+        menu->Append(ID_ROTATE_RIGHT, wxT("Rotate &right\tCtrl-R"));
 
         wxMenuBar *mbar = new wxMenuBar;
 
         wxMenuBar *mbar = new wxMenuBar;
-        mbar->Append(menu, _T("&Image"));
+        mbar->Append(menu, wxT("&Image"));
         SetMenuBar(mbar);
 
         mbar->Check(ID_PAINT_BG, true);
         SetMenuBar(mbar);
 
         mbar->Check(ID_PAINT_BG, true);
@@ -186,7 +192,7 @@ private:
         wxPaintDC dc(this);
 
         if ( GetMenuBar()->IsChecked(ID_PAINT_BG) )
         wxPaintDC dc(this);
 
         if ( GetMenuBar()->IsChecked(ID_PAINT_BG) )
-            ClearBackground();
+            dc.Clear();
 
         dc.SetUserScale(m_zoom, m_zoom);
 
 
         dc.SetUserScale(m_zoom, m_zoom);
 
@@ -208,16 +214,29 @@ 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|")
                                                 wxT("BMP files (*.bmp)|*.bmp|")
+#if wxUSE_LIBPNG
                                                 wxT("PNG files (*.png)|*.png|")
                                                 wxT("PNG files (*.png)|*.png|")
+#endif
+#if wxUSE_LIBJPEG
                                                 wxT("JPEG files (*.jpg)|*.jpg|")
                                                 wxT("JPEG files (*.jpg)|*.jpg|")
+#endif
+#if wxUSE_GIF
                                                 wxT("GIF files (*.gif)|*.gif|")
                                                 wxT("GIF files (*.gif)|*.gif|")
+#endif
+#if wxUSE_LIBTIFF
                                                 wxT("TIFF files (*.tif)|*.tif|")
                                                 wxT("TIFF files (*.tif)|*.tif|")
+#endif
+#if wxUSE_PCX
                                                 wxT("PCX files (*.pcx)|*.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"),
                                                 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() )
@@ -227,7 +246,7 @@ private:
         wxFileName::SplitPath(savefilename, NULL, NULL, &extension);
 
         bool saved = false;
         wxFileName::SplitPath(savefilename, NULL, NULL, &extension);
 
         bool saved = false;
-        if ( extension == _T("bmp") )
+        if ( extension == wxT("bmp") )
         {
             static const int bppvalues[] =
             {
         {
             static const int bppvalues[] =
             {
@@ -243,18 +262,18 @@ private:
 
             const wxString bppchoices[] =
             {
 
             const wxString bppchoices[] =
             {
-                _T("1 bpp color"),
-                _T("1 bpp B&W"),
-                _T("4 bpp color"),
-                _T("8 bpp color"),
-                _T("8 bpp greyscale"),
-                _T("8 bpp red"),
-                _T("8 bpp own palette"),
-                _T("24 bpp")
+                wxT("1 bpp color"),
+                wxT("1 bpp B&W"),
+                wxT("4 bpp color"),
+                wxT("8 bpp color"),
+                wxT("8 bpp greyscale"),
+                wxT("8 bpp red"),
+                wxT("8 bpp own palette"),
+                wxT("24 bpp")
             };
 
             };
 
-            int bppselection = wxGetSingleChoiceIndex(_T("Set BMP BPP"),
-                                                    _T("Image sample: save file"),
+            int bppselection = wxGetSingleChoiceIndex(wxT("Set BMP BPP"),
+                                                    wxT("Image sample: save file"),
                                                     WXSIZEOF(bppchoices),
                                                     bppchoices,
                                                     this);
                                                     WXSIZEOF(bppchoices),
                                                     bppchoices,
                                                     this);
@@ -274,7 +293,8 @@ private:
                 }
             }
         }
                 }
             }
         }
-        else if ( extension == _T("png") )
+#if wxUSE_LIBPNG
+        else if ( extension == wxT("png") )
         {
             static const int pngvalues[] =
             {
         {
             static const int pngvalues[] =
             {
@@ -288,16 +308,16 @@ private:
 
             const wxString pngchoices[] =
             {
 
             const wxString pngchoices[] =
             {
-                _T("Colour 8bpp"),
-                _T("Colour 16bpp"),
-                _T("Grey 8bpp"),
-                _T("Grey 16bpp"),
-                _T("Grey red 8bpp"),
-                _T("Grey red 16bpp"),
+                wxT("Colour 8bpp"),
+                wxT("Colour 16bpp"),
+                wxT("Grey 8bpp"),
+                wxT("Grey 16bpp"),
+                wxT("Grey red 8bpp"),
+                wxT("Grey red 16bpp"),
             };
 
             };
 
-            int sel = wxGetSingleChoiceIndex(_T("Set PNG format"),
-                                            _T("Image sample: save file"),
+            int sel = wxGetSingleChoiceIndex(wxT("Set PNG format"),
+                                            wxT("Image sample: save file"),
                                             WXSIZEOF(pngchoices),
                                             pngchoices,
                                             this);
                                             WXSIZEOF(pngchoices),
                                             pngchoices,
                                             this);
@@ -309,22 +329,22 @@ private:
                 // these values are taken from OptiPNG with -o3 switch
                 const wxString compressionChoices[] =
                 {
                 // these values are taken from OptiPNG with -o3 switch
                 const wxString compressionChoices[] =
                 {
-                    _T("compression = 9, memory = 8, strategy = 0, filter = 0"),
-                    _T("compression = 9, memory = 9, strategy = 0, filter = 0"),
-                    _T("compression = 9, memory = 8, strategy = 1, filter = 0"),
-                    _T("compression = 9, memory = 9, strategy = 1, filter = 0"),
-                    _T("compression = 1, memory = 8, strategy = 2, filter = 0"),
-                    _T("compression = 1, memory = 9, strategy = 2, filter = 0"),
-                    _T("compression = 9, memory = 8, strategy = 0, filter = 5"),
-                    _T("compression = 9, memory = 9, strategy = 0, filter = 5"),
-                    _T("compression = 9, memory = 8, strategy = 1, filter = 5"),
-                    _T("compression = 9, memory = 9, strategy = 1, filter = 5"),
-                    _T("compression = 1, memory = 8, strategy = 2, filter = 5"),
-                    _T("compression = 1, memory = 9, strategy = 2, filter = 5"),
+                    wxT("compression = 9, memory = 8, strategy = 0, filter = 0"),
+                    wxT("compression = 9, memory = 9, strategy = 0, filter = 0"),
+                    wxT("compression = 9, memory = 8, strategy = 1, filter = 0"),
+                    wxT("compression = 9, memory = 9, strategy = 1, filter = 0"),
+                    wxT("compression = 1, memory = 8, strategy = 2, filter = 0"),
+                    wxT("compression = 1, memory = 9, strategy = 2, filter = 0"),
+                    wxT("compression = 9, memory = 8, strategy = 0, filter = 5"),
+                    wxT("compression = 9, memory = 9, strategy = 0, filter = 5"),
+                    wxT("compression = 9, memory = 8, strategy = 1, filter = 5"),
+                    wxT("compression = 9, memory = 9, strategy = 1, filter = 5"),
+                    wxT("compression = 1, memory = 8, strategy = 2, filter = 5"),
+                    wxT("compression = 1, memory = 9, strategy = 2, filter = 5"),
                 };
 
                 };
 
-                int sel = wxGetSingleChoiceIndex(_T("Select compression option (Cancel to use default)\n"),
-                                                 _T("PNG Compression Options"),
+                int sel = wxGetSingleChoiceIndex(wxT("Select compression option (Cancel to use default)\n"),
+                                                 wxT("PNG Compression Options"),
                                                  WXSIZEOF(compressionChoices),
                                                  compressionChoices,
                                                  this);
                                                  WXSIZEOF(compressionChoices),
                                                  compressionChoices,
                                                  this);
@@ -344,7 +364,8 @@ private:
                 }
             }
         }
                 }
             }
         }
-        else if ( extension == _T("cur") )
+#endif // wxUSE_LIBPNG
+        else if ( extension == wxT("cur") )
         {
             image.Rescale(32,32);
             image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 0);
         {
             image.Rescale(32,32);
             image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 0);
@@ -394,9 +415,9 @@ private:
 
         wxImage img(m_bitmap.ConvertToImage());
         img = img.Rotate(angle, wxPoint(img.GetWidth() / 2, img.GetHeight() / 2));
 
         wxImage img(m_bitmap.ConvertToImage());
         img = img.Rotate(angle, wxPoint(img.GetWidth() / 2, img.GetHeight() / 2));
-        if ( !img.Ok() )
+        if ( !img.IsOk() )
         {
         {
-            wxLogWarning(_T("Rotation failed"));
+            wxLogWarning(wxT("Rotation failed"));
             return;
         }
 
             return;
         }
 
@@ -407,7 +428,7 @@ private:
 
     void UpdateStatusBar()
     {
 
     void UpdateStatusBar()
     {
-        wxLogStatus(this, _T("Image size: (%d, %d), zoom %.2f"),
+        wxLogStatus(this, wxT("Image size: (%d, %d), zoom %.2f"),
                     m_bitmap.GetWidth(),
                     m_bitmap.GetHeight(),
                     m_zoom);
                     m_bitmap.GetWidth(),
                     m_bitmap.GetHeight(),
                     m_zoom);
@@ -435,7 +456,7 @@ public:
     };
 
     MyRawBitmapFrame(wxFrame *parent)
     };
 
     MyRawBitmapFrame(wxFrame *parent)
-        : wxFrame(parent, wxID_ANY, _T("Raw bitmaps (how exciting)")),
+        : wxFrame(parent, wxID_ANY, wxT("Raw bitmaps (how exciting)")),
         m_bitmap(SIZE, SIZE, 24),
         m_alphaBitmap(SIZE, SIZE, 32)
     {
         m_bitmap(SIZE, SIZE, 24),
         m_alphaBitmap(SIZE, SIZE, 32)
     {
@@ -453,7 +474,7 @@ public:
             wxAlphaPixelData data( m_alphaBitmap, wxPoint(0,0), wxSize(SIZE, SIZE) );
             if ( !data )
             {
             wxAlphaPixelData data( m_alphaBitmap, wxPoint(0,0), wxSize(SIZE, SIZE) );
             if ( !data )
             {
-                wxLogError(_T("Failed to gain raw access to bitmap data"));
+                wxLogError(wxT("Failed to gain raw access to bitmap data"));
                 return;
             }
             wxAlphaPixelData::Iterator p(data);
                 return;
             }
             wxAlphaPixelData::Iterator p(data);
@@ -475,7 +496,7 @@ public:
                             wxSize(REAL_SIZE, REAL_SIZE));
         if ( !data )
         {
                             wxSize(REAL_SIZE, REAL_SIZE));
         if ( !data )
         {
-            wxLogError(_T("Failed to gain raw access to bitmap data"));
+            wxLogError(wxT("Failed to gain raw access to bitmap data"));
             return;
         }
 
             return;
         }
 
@@ -512,7 +533,7 @@ public:
         wxNativePixelData data(m_bitmap);
         if ( !data )
         {
         wxNativePixelData data(m_bitmap);
         if ( !data )
         {
-            wxLogError(_T("Failed to gain raw access to bitmap data"));
+            wxLogError(wxT("Failed to gain raw access to bitmap data"));
             return;
         }
 
             return;
         }
 
@@ -541,12 +562,12 @@ public:
     void OnPaint(wxPaintEvent& WXUNUSED(event))
     {
         wxPaintDC dc( this );
     void OnPaint(wxPaintEvent& WXUNUSED(event))
     {
         wxPaintDC dc( this );
-        dc.DrawText(_T("This is alpha and raw bitmap test"), 0, BORDER);
-        dc.DrawText(_T("This is alpha and raw bitmap test"), 0, SIZE/2 - BORDER);
-        dc.DrawText(_T("This is alpha and raw bitmap test"), 0, SIZE - 2*BORDER);
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, BORDER);
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, SIZE/2 - BORDER);
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, SIZE - 2*BORDER);
         dc.DrawBitmap( m_alphaBitmap, 0, 0, true /* use mask */ );
 
         dc.DrawBitmap( m_alphaBitmap, 0, 0, true /* use mask */ );
 
-        dc.DrawText(_T("Raw bitmap access without alpha"), 0, SIZE+5);
+        dc.DrawText(wxT("Raw bitmap access without alpha"), 0, SIZE+5);
         dc.DrawBitmap( m_bitmap, 0, SIZE+5+dc.GetCharHeight());
     }
 
         dc.DrawBitmap( m_bitmap, 0, SIZE+5+dc.GetCharHeight());
     }
 
@@ -572,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)
 
@@ -604,6 +625,7 @@ enum
     ID_NEW = 100,
     ID_INFO,
     ID_SHOWRAW,
     ID_NEW = 100,
     ID_INFO,
     ID_SHOWRAW,
+    ID_GRAPHICS,
     ID_SHOWTHUMBNAIL
 };
 
     ID_SHOWTHUMBNAIL
 };
 
@@ -617,6 +639,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 #ifdef wxHAVE_RAW_BITMAP
     EVT_MENU    (ID_SHOWRAW, MyFrame::OnTestRawBitmap)
 #endif
 #ifdef wxHAVE_RAW_BITMAP
     EVT_MENU    (ID_SHOWRAW, MyFrame::OnTestRawBitmap)
 #endif
+#if wxUSE_GRAPHICS_CONTEXT
+    EVT_MENU    (ID_GRAPHICS, MyFrame::OnTestGraphics)
+#endif // wxUSE_GRAPHICS_CONTEXT
 #if wxUSE_CLIPBOARD
     EVT_MENU(wxID_COPY, MyFrame::OnCopy)
     EVT_MENU(wxID_PASTE, MyFrame::OnPaste)
 #if wxUSE_CLIPBOARD
     EVT_MENU(wxID_COPY, MyFrame::OnCopy)
     EVT_MENU(wxID_PASTE, MyFrame::OnPaste)
@@ -624,7 +649,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 END_EVENT_TABLE()
 
 MyFrame::MyFrame()
 END_EVENT_TABLE()
 
 MyFrame::MyFrame()
-    : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxImage sample"),
+    : wxFrame( (wxFrame *)NULL, wxID_ANY, wxT("wxImage sample"),
                 wxPoint(20, 20), wxSize(950, 700) )
 {
     SetIcon(wxICON(sample));
                 wxPoint(20, 20), wxSize(950, 700) )
 {
     SetIcon(wxICON(sample));
@@ -632,26 +657,30 @@ MyFrame::MyFrame()
     wxMenuBar *menu_bar = new wxMenuBar();
 
     wxMenu *menuImage = new wxMenu;
     wxMenuBar *menu_bar = new wxMenuBar();
 
     wxMenu *menuImage = new wxMenu;
-    menuImage->Append( ID_NEW, _T("&Show any image...\tCtrl-O"));
-    menuImage->Append( ID_INFO, _T("Show image &information...\tCtrl-I"));
+    menuImage->Append( ID_NEW, wxT("&Show any image...\tCtrl-O"));
+    menuImage->Append( ID_INFO, wxT("Show image &information...\tCtrl-I"));
 #ifdef wxHAVE_RAW_BITMAP
     menuImage->AppendSeparator();
 #ifdef wxHAVE_RAW_BITMAP
     menuImage->AppendSeparator();
-    menuImage->Append( ID_SHOWRAW, _T("Test &raw bitmap...\tCtrl-R"));
+    menuImage->Append( ID_SHOWRAW, wxT("Test &raw bitmap...\tCtrl-R"));
 #endif
 #endif
+#if wxUSE_GRAPHICS_CONTEXT
     menuImage->AppendSeparator();
     menuImage->AppendSeparator();
-    menuImage->Append( ID_SHOWTHUMBNAIL, _T("Test &thumbnail...\tCtrl-T"),
+    menuImage->Append(ID_GRAPHICS, "Test &graphics context...\tCtrl-G");
+#endif // wxUSE_GRAPHICS_CONTEXT
+    menuImage->AppendSeparator();
+    menuImage->Append( ID_SHOWTHUMBNAIL, wxT("Test &thumbnail...\tCtrl-T"),
                         "Test scaling the image during load (try with JPEG)");
     menuImage->AppendSeparator();
                         "Test scaling the image during load (try with JPEG)");
     menuImage->AppendSeparator();
-    menuImage->Append( ID_ABOUT, _T("&About..."));
+    menuImage->Append( ID_ABOUT, wxT("&About\tF1"));
     menuImage->AppendSeparator();
     menuImage->AppendSeparator();
-    menuImage->Append( ID_QUIT, _T("E&xit\tCtrl-Q"));
-    menu_bar->Append(menuImage, _T("&Image"));
+    menuImage->Append( ID_QUIT, wxT("E&xit\tCtrl-Q"));
+    menu_bar->Append(menuImage, wxT("&Image"));
 
 #if wxUSE_CLIPBOARD
     wxMenu *menuClipboard = new wxMenu;
 
 #if wxUSE_CLIPBOARD
     wxMenu *menuClipboard = new wxMenu;
-    menuClipboard->Append(wxID_COPY, _T("&Copy test image\tCtrl-C"));
-    menuClipboard->Append(wxID_PASTE, _T("&Paste image\tCtrl-V"));
-    menu_bar->Append(menuClipboard, _T("&Clipboard"));
+    menuClipboard->Append(wxID_COPY, wxT("&Copy test image\tCtrl-C"));
+    menuClipboard->Append(wxID_PASTE, wxT("&Paste image\tCtrl-V"));
+    menu_bar->Append(menuClipboard, wxT("&Clipboard"));
 #endif // wxUSE_CLIPBOARD
 
     SetMenuBar( menu_bar );
 #endif // wxUSE_CLIPBOARD
 
     SetMenuBar( menu_bar );
@@ -666,6 +695,7 @@ MyFrame::MyFrame()
 
     // 500 width * 2750 height
     m_canvas->SetScrollbars( 10, 10, 50, 275 );
 
     // 500 width * 2750 height
     m_canvas->SetScrollbars( 10, 10, 50, 275 );
+    m_canvas->SetCursor(wxImage("cursor.png"));
 }
 
 void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
 }
 
 void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
@@ -673,11 +703,35 @@ void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
     Close( true );
 }
 
     Close( true );
 }
 
+#if wxUSE_ZLIB && wxUSE_STREAMS
+#include "wx/zstream.h"
+#endif
+
 void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
 {
 void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
 {
-    (void)wxMessageBox( "wxImage demo\n"
-                        "(c) Robert Roebling 1998-2005"
-                        "(c) Vadim Zeitlin 2005-2009",
+    wxArrayString array;
+
+    array.Add("wxImage demo");
+    array.Add("(c) Robert Roebling 1998-2005");
+    array.Add("(c) Vadim Zeitlin 2005-2009");
+
+    array.Add(wxEmptyString);
+    array.Add("Version of the libraries used:");
+
+#if wxUSE_LIBPNG
+    array.Add(wxPNGHandler::GetLibraryVersionInfo().ToString());
+#endif
+#if wxUSE_LIBJPEG
+    array.Add(wxJPEGHandler::GetLibraryVersionInfo().ToString());
+#endif
+#if wxUSE_LIBTIFF
+    array.Add(wxTIFFHandler::GetLibraryVersionInfo().ToString());
+#endif
+#if wxUSE_ZLIB && wxUSE_STREAMS
+    // zlib is used by libpng
+    array.Add(wxGetZlibVersionInfo().ToString());
+#endif
+    (void)wxMessageBox( wxJoin(array, '\n'),
                         "About wxImage Demo",
                         wxICON_INFORMATION | wxOK );
 }
                         "About wxImage Demo",
                         wxICON_INFORMATION | wxOK );
 }
@@ -687,12 +741,12 @@ wxString MyFrame::LoadUserImage(wxImage& image)
     wxString filename;
 
 #if wxUSE_FILEDLG
     wxString filename;
 
 #if wxUSE_FILEDLG
-    filename = wxFileSelector(_T("Select image file"));
+    filename = wxLoadFileSelector(wxT("image"), wxEmptyString);
     if ( !filename.empty() )
     {
         if ( !image.LoadFile(filename) )
         {
     if ( !filename.empty() )
     {
         if ( !image.LoadFile(filename) )
         {
-            wxLogError(_T("Couldn't load image from '%s'."), filename.c_str());
+            wxLogError(wxT("Couldn't load image from '%s'."), filename.c_str());
 
             return wxEmptyString;
         }
 
             return wxEmptyString;
         }
@@ -758,6 +812,85 @@ void MyFrame::OnTestRawBitmap( wxCommandEvent &WXUNUSED(event) )
 
 #endif // wxHAVE_RAW_BITMAP
 
 
 #endif // wxHAVE_RAW_BITMAP
 
+#if wxUSE_GRAPHICS_CONTEXT
+
+class MyGraphicsFrame : public wxFrame
+{
+public:
+    enum
+    {
+        WIDTH = 256,
+        HEIGHT = 90
+    };
+
+    MyGraphicsFrame(wxWindow* parent) :
+        wxFrame(parent, wxID_ANY, "Graphics context test"),
+        m_image(WIDTH, HEIGHT, false)
+    {
+        // Create a test image: it has 3 horizontal primary colour bands with
+        // alpha increasing from left to right.
+        m_image.SetAlpha();
+        unsigned char* alpha = m_image.GetAlpha();
+        unsigned char* data = m_image.GetData();
+
+        for ( int y = 0; y < HEIGHT; y++ )
+        {
+            unsigned char r = 0,
+                          g = 0,
+                          b = 0;
+            if ( y < HEIGHT/3 )
+                r = 0xff;
+            else if ( y < (2*HEIGHT)/3 )
+                g = 0xff;
+            else
+                b = 0xff;
+
+            for ( int x = 0; x < WIDTH; x++ )
+            {
+                *alpha++ = x;
+                *data++ = r;
+                *data++ = g;
+                *data++ = b;
+            }
+        }
+
+        m_bitmap = wxBitmap(m_image);
+
+        Connect(wxEVT_PAINT, wxPaintEventHandler(MyGraphicsFrame::OnPaint));
+
+        Show();
+    }
+
+private:
+    void OnPaint(wxPaintEvent& WXUNUSED(event))
+    {
+        wxPaintDC dc(this);
+        wxScopedPtr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
+        wxGraphicsBitmap gb(gc->CreateBitmapFromImage(m_image));
+
+        gc->SetFont(*wxNORMAL_FONT, *wxBLACK);
+        gc->DrawText("Bitmap", 0, HEIGHT/2);
+        gc->DrawBitmap(m_bitmap, 0, 0, WIDTH, HEIGHT);
+
+        wxGraphicsFont gf = gc->CreateFont(wxNORMAL_FONT->GetPixelSize().y, "");
+        gc->SetFont(gf);
+        gc->DrawText("Graphics bitmap", 0, (3*HEIGHT)/2);
+        gc->DrawBitmap(gb, 0, HEIGHT, WIDTH, HEIGHT);
+    }
+
+    wxImage m_image;
+    wxBitmap m_bitmap;
+
+    wxDECLARE_NO_COPY_CLASS(MyGraphicsFrame);
+};
+
+void MyFrame::OnTestGraphics(wxCommandEvent& WXUNUSED(event))
+{
+    new MyGraphicsFrame(this);
+}
+
+#endif // wxUSE_GRAPHICS_CONTEXT
+
 #if wxUSE_CLIPBOARD
 
 void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
 #if wxUSE_CLIPBOARD
 
 void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
@@ -769,7 +902,7 @@ void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
 
     if ( !wxTheClipboard->SetData(dobjBmp) )
     {
 
     if ( !wxTheClipboard->SetData(dobjBmp) )
     {
-        wxLogError(_T("Failed to copy bitmap to clipboard"));
+        wxLogError(wxT("Failed to copy bitmap to clipboard"));
     }
 
     wxTheClipboard->Close();
     }
 
     wxTheClipboard->Close();
@@ -782,11 +915,11 @@ void MyFrame::OnPaste(wxCommandEvent& WXUNUSED(event))
     wxTheClipboard->Open();
     if ( !wxTheClipboard->GetData(dobjBmp) )
     {
     wxTheClipboard->Open();
     if ( !wxTheClipboard->GetData(dobjBmp) )
     {
-        wxLogMessage(_T("No bitmap data in the clipboard"));
+        wxLogMessage(wxT("No bitmap data in the clipboard"));
     }
     else
     {
     }
     else
     {
-        new MyImageFrame(this, _T("Clipboard"), dobjBmp.GetBitmap());
+        new MyImageFrame(this, wxT("Clipboard"), dobjBmp.GetBitmap());
     }
     wxTheClipboard->Close();
 }
     }
     wxTheClipboard->Close();
 }
@@ -796,7 +929,7 @@ void MyFrame::OnPaste(wxCommandEvent& WXUNUSED(event))
 void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
 {
 #if wxUSE_FILEDLG
 void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
 {
 #if wxUSE_FILEDLG
-    wxString filename = wxFileSelector(_T("Select image file"));
+    wxString filename = wxLoadFileSelector(wxT("image"), wxEmptyString, wxEmptyString, this);
     if ( filename.empty() )
         return;
 
     if ( filename.empty() )
         return;
 
@@ -810,16 +943,20 @@ void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
     wxStopWatch sw;
     if ( !image.LoadFile(filename) )
     {
     wxStopWatch sw;
     if ( !image.LoadFile(filename) )
     {
-        wxLogError(_T("Couldn't load image from '%s'."), filename.c_str());
+        wxLogError(wxT("Couldn't load image from '%s'."), filename.c_str());
         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
 #else
-    wxLogError( _T("Couldn't create file selector dialog") );
+    wxLogError( wxT("Couldn't create file selector dialog") );
     return;
 #endif // wxUSE_FILEDLG
 }
     return;
 #endif // wxUSE_FILEDLG
 }