]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
string conversion
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index 27f7e946403509cfa74aa227e2851e6aeb099239..25e42ae0b58a5f637fab721229972a912afc8e2d 100644 (file)
@@ -122,7 +122,7 @@ bool MyApp::OnInit()
   wxConvCurrent = &wxConvLibc;
 #endif
 
-  m_canvasTextColour = wxColour("BLACK");
+  m_canvasTextColour = wxColour(_T("BLACK"));
   m_canvasFont = *wxNORMAL_FONT;
 
   // Create the main frame window
@@ -170,12 +170,12 @@ bool MyApp::OnInit()
   file_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B"));
 #endif // wxUSE_BUSYINFO
 #if wxUSE_FINDREPLDLG
-  file_menu->Append(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"), "", TRUE);
-  file_menu->Append(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"), "", TRUE);
+  file_menu->Append(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"), _T(""), TRUE);
+  file_menu->Append(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"), _T(""), TRUE);
 #endif // wxUSE_FINDREPLDLG
   file_menu->AppendSeparator();
   file_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W"));
-  file_menu->Append(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z"), "", TRUE);
+  file_menu->Append(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z"), _T(""), TRUE);
   file_menu->AppendSeparator();
   file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
   wxMenuBar *menu_bar = new wxMenuBar;
@@ -226,7 +226,7 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
     }
 
     wxColourDialog dialog(this, &data);
-    dialog.SetTitle("Choose the background colour");
+    dialog.SetTitle(_T("Choose the background colour"));
     if (dialog.ShowModal() == wxID_OK)
     {
         wxColourData retData = dialog.GetColourData();
@@ -375,7 +375,7 @@ void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
 {
     wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
                                          _T("Password entry dialog"),
-                                         "",
+                                         _T(""),
                                          this);
     if ( !!pwd )
     {
@@ -457,9 +457,15 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
                     _T("Testing open file dialog"),
                     _T(""),
                     _T(""),
+#ifdef __WXMOTIF__
+                    _T("C++ files (*.cpp)|*.cpp")
+#else
                     _T("C++ files (*.h;*.cpp)|*.h;*.cpp")
+#endif
                  );
 
+    dialog.SetDirectory(wxGetHomeDir());
+
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString info;
@@ -532,16 +538,16 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
     wxFileDialog dialog(this,
                         _T("Testing save file dialog"),
                         _T(""),
-                        _T("myletter.txt"),
+                        _T("myletter.doc"),
                         _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
                         wxSAVE|wxOVERWRITE_PROMPT);
 
+    dialog.SetFilterIndex(1);
+
     if (dialog.ShowModal() == wxID_OK)
     {
-        wxChar buf[400];
-        wxSprintf(buf, _T("%s, filter %d"), (const wxChar*)dialog.GetPath(), dialog.GetFilterIndex());
-        wxMessageDialog dialog2(this, wxString(buf), _T("Selected path"));
-        dialog2.ShowModal();
+        wxLogMessage(_T("%s, filter %d"),
+                     dialog.GetPath().c_str(), dialog.GetFilterIndex());
     }
 }
 
@@ -555,8 +561,7 @@ void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
 
     if (dialog.ShowModal() == wxID_OK)
     {
-        wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
-        dialog2.ShowModal();
+        wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
     }
 }
 
@@ -655,6 +660,7 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
                             this,   // parent
                             wxPD_CAN_ABORT |
                             wxPD_APP_MODAL |
+                            // wxPD_AUTO_HIDE | -- try this as well
                             wxPD_ELAPSED_TIME |
                             wxPD_ESTIMATED_TIME |
                             wxPD_REMAINING_TIME);
@@ -705,13 +711,16 @@ void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
 {
     wxWindowDisabler disableAll;
 
-    wxBusyInfo info("Working, please wait...", this);
+    wxBusyInfo info(_T("Working, please wait..."), this);
 
-    for ( int i = 0; i < 30; i++ )
+    for ( int i = 0; i < 18; i++ )
     {
-        wxUsleep(100);
+        //wxUsleep(100);
         wxTheApp->Yield();
     }
+
+    wxSleep(2);
+    //wxWakeUpIdle();
 }
 
 #endif // wxUSE_BUSYINFO
@@ -779,7 +788,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
     if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
     {
         wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_NEXT ? _T("next ") : "",
+                     type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
                      event.GetFindString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
     }
@@ -787,7 +796,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
                 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
     {
         wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : "",
+                     type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
                      event.GetFindString().c_str(),
                      event.GetReplaceString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
@@ -796,25 +805,34 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
     {
         wxFindReplaceDialog *dlg = event.GetDialog();
 
+        int idMenu;
         const wxChar *txt;
         if ( dlg == m_dlgFind )
         {
             txt = _T("Find");
+            idMenu = DIALOGS_FIND;
             m_dlgFind = NULL;
         }
         else if ( dlg == m_dlgReplace )
         {
             txt = _T("Replace");
+            idMenu = DIALOGS_REPLACE;
             m_dlgReplace = NULL;
         }
         else
         {
             txt = _T("Unknown");
+            idMenu = -1;
 
             wxFAIL_MSG( _T("unexpected event") );
         }
 
-        wxLogMessage(wxT("%s dialog is being closed."), txt),
+        wxLogMessage(wxT("%s dialog is being closed."), txt);
+
+        if ( idMenu != -1 )
+        {
+            GetMenuBar()->Check(idMenu, FALSE);
+        }
 
         dlg->Destroy();
     }
@@ -836,7 +854,7 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
     dc.SetFont(wxGetApp().m_canvasFont);
     dc.SetTextForeground(wxGetApp().m_canvasTextColour);
     dc.SetBackgroundMode(wxTRANSPARENT);
-    dc.DrawText("wxWindows common dialogs test application", 10, 10);
+    dc.DrawText(_T("wxWindows common dialogs test application"), 10, 10);
 }
 
 // ----------------------------------------------------------------------------
@@ -844,7 +862,7 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
 // ----------------------------------------------------------------------------
 
 MyModelessDialog::MyModelessDialog(wxWindow *parent)
-                : wxDialog(parent, -1, wxString("Modeless dialog"))
+                : wxDialog(parent, -1, wxString(_T("Modeless dialog")))
 {
     wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);