]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
wxSpinButton::GetValue() returns correct result now
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index 939efa6cb8ee6c040880f83c1f2d6d96004d9026..75fb99d93d9ae192ff4af65d227b1572062b9611 100644 (file)
@@ -31,7 +31,9 @@
 #include <wx/fontdlg.h>
 #include <wx/choicdlg.h>
 
-#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW
+#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
+
+#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
 #include <wx/generic/colrdlgg.h>
 #include <wx/generic/fontdlgg.h>
 #endif
 
 IMPLEMENT_APP(MyApp)
 
-MyCanvas *myCanvas = NULL;
-
-// A macro needed for some compilers (AIX) that need 'main' to be defined
-// in the application itself.
-IMPLEMENT_WXWIN_MAIN
+MyCanvas *myCanvas = (MyCanvas *) NULL;
 
 // `Main program' equivalent, creating windows and returning main app frame
 bool MyApp::OnInit(void)
 {
+#if defined(__WXGTK__) && defined(wxUSE_UNICODE)
+  wxConvCurrent = &wxConvLibc;
+#endif
+
   m_canvasTextColour = wxColour("BLACK");
   m_canvasFont = *wxNORMAL_FONT;
 
   // Create the main frame window
-  MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300));
+  MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300));
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
 
   file_menu->Append(DIALOGS_CHOOSE_COLOUR, "&Choose colour");
 
-#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW
+#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
   file_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, "Choose colour (&generic)");
 #endif
 
   file_menu->AppendSeparator();
   file_menu->Append(DIALOGS_CHOOSE_FONT, "Choose &font");
 
-#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW
+#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
   file_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, "Choose f&ont (generic)");
 
 #endif
@@ -103,7 +105,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, co
   wxFrame(parent, -1, title, pos, size)
 {}
 
-void MyFrame::ChooseColour(wxCommandEvent& event)
+void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
 {
       wxColourData data;
       data.SetChooseFull(TRUE);
@@ -123,10 +125,10 @@ void MyFrame::ChooseColour(wxCommandEvent& event)
         myCanvas->Clear();
         myCanvas->Refresh();
       }
-      dialog->Close();
+      dialog->Destroy();
 }
 
-void MyFrame::ChooseFont(wxCommandEvent& event)
+void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
 {
       wxFontData data;
       data.SetInitialFont(wxGetApp().m_canvasFont);
@@ -140,11 +142,11 @@ void MyFrame::ChooseFont(wxCommandEvent& event)
         wxGetApp().m_canvasTextColour = retData.GetColour();
         myCanvas->Refresh();
       }
-      dialog->Close();
+      dialog->Destroy();
 }
 
-#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW
-void MyFrame::ChooseColourGeneric(wxCommandEvent& event)
+#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
+void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
 {
       wxColourData data;
       data.SetChooseFull(TRUE);
@@ -164,10 +166,10 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& event)
         myCanvas->Clear();
         myCanvas->Refresh();
       }
-      dialog->Close();
+      dialog->Destroy();
 }
 
-void MyFrame::ChooseFontGeneric(wxCommandEvent& event)
+void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
 {
       wxFontData data;
       data.SetInitialFont(wxGetApp().m_canvasFont);
@@ -181,19 +183,22 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& event)
         wxGetApp().m_canvasTextColour = retData.GetColour();
         myCanvas->Refresh();
       }
-      dialog->Close();
+      dialog->Destroy();
 }
 #endif
 
-void MyFrame::MessageBox(wxCommandEvent& event)
+void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
 {
-  wxMessageDialog dialog(this, "This is a message box\nA long, long string to test out the message box properly",
+  wxMessageDialog dialog(NULL, "This is a message box\nA long, long string to test out the message box properly",
        "Message box text", wxYES_NO|wxCANCEL);
 
   dialog.ShowModal();
+  
+ ::wxMessageBox("MsgBox with a really long long string", 
+    "this is the text", wxYES_NO|wxICON_EXCLAMATION);
 }
 
-void MyFrame::TextEntry(wxCommandEvent& event)
+void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event) )
 {
   wxTextEntryDialog dialog(this, "This is a small sample\nA long, long string to test out the text entrybox",
        "Please enter a string", "Default value", wxOK|wxCANCEL);
@@ -205,7 +210,7 @@ void MyFrame::TextEntry(wxCommandEvent& event)
   }
 }
 
-void MyFrame::SingleChoice(wxCommandEvent& event)
+void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
 {
     const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ;
     int n = 5;
@@ -222,18 +227,25 @@ void MyFrame::SingleChoice(wxCommandEvent& event)
     }
 }
 
-void MyFrame::FileOpen(wxCommandEvent& event)
+void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
 {
        wxFileDialog dialog(this, "Testing open file dialog", "", "", "*.txt", 0);
 
        if (dialog.ShowModal() == wxID_OK)
        {
-               wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path");
+        wxString info;
+        info.Printf(_T("Full file name: %s\n")
+                    _T("Path: %s\n")
+                    _T("Name: %s"),
+                    dialog.GetPath().c_str(),
+                    dialog.GetDirectory().c_str(),
+                    dialog.GetFilename().c_str());
+               wxMessageDialog dialog2(this, info, "Selected file");
                dialog2.ShowModal();
        }
 }
 
-void MyFrame::FileSave(wxCommandEvent& event)
+void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
 {
        wxFileDialog dialog(this, "Testing save file dialog", "", "",
                "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
@@ -241,14 +253,14 @@ void MyFrame::FileSave(wxCommandEvent& event)
 
        if (dialog.ShowModal() == wxID_OK)
        {
-               char buf[400];
-               sprintf(buf, "%s, filter %d", (const char *)dialog.GetPath(), dialog.GetFilterIndex());
+               wxChar buf[400];
+               wxSprintf(buf, _T("%s, filter %d"), (const wxChar*)dialog.GetPath(), dialog.GetFilterIndex());
                wxMessageDialog dialog2(this, wxString(buf), "Selected path");
                dialog2.ShowModal();
        }
 }
 
-void MyFrame::DirChoose(wxCommandEvent& event)
+void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
 {
        wxDirDialog dialog(this, "Testing directory picker", "");
 
@@ -259,12 +271,12 @@ void MyFrame::DirChoose(wxCommandEvent& event)
        }
 }
 
-void MyFrame::OnExit(wxCommandEvent& event)
+void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
 {
        Close(TRUE);
 }
 
-void MyCanvas::OnPaint(wxPaintEvent& event)
+void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
 {
        wxPaintDC dc(this);
     dc.SetFont(wxGetApp().m_canvasFont);
@@ -286,7 +298,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
        EVT_MENU(DIALOGS_FILE_OPEN,                                     MyFrame::FileOpen)
        EVT_MENU(DIALOGS_FILE_SAVE,                                     MyFrame::FileSave)
        EVT_MENU(DIALOGS_DIR_CHOOSE,                            MyFrame::DirChoose)
-#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW
+#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
        EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC,         MyFrame::ChooseColourGeneric)
        EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC,           MyFrame::ChooseFontGeneric)
 #endif