From 71307412f5aef70603636992a512d2c133361512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C5=82odzimierz=20Skiba?= Date: Wed, 24 Aug 2005 17:47:11 +0000 Subject: [PATCH] Missing wxUSE_... flags and source cleaning. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35304 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/samples/stc/edit.cpp | 19 +++++-- samples/exec/exec.cpp | 27 +++++---- samples/font/font.cpp | 9 ++- samples/html/test/test.cpp | 4 +- samples/image/image.cpp | 9 ++- samples/mobile/wxedit/wxedit.cpp | 13 +++-- samples/png/pngdemo.cpp | 98 ++++++++++++++++---------------- samples/sound/sound.cpp | 6 +- samples/stc/edit.cpp | 19 +++++-- 9 files changed, 124 insertions(+), 80 deletions(-) diff --git a/contrib/samples/stc/edit.cpp b/contrib/samples/stc/edit.cpp index 9618eb8992..a3b7d7c236 100644 --- a/contrib/samples/stc/edit.cpp +++ b/contrib/samples/stc/edit.cpp @@ -502,8 +502,9 @@ bool Edit::InitializePrefs (const wxString &name) { return true; } -bool Edit::LoadFile () { - +bool Edit::LoadFile () +{ +#if wxUSE_FILEDLG // get filname if (!m_filename) { wxFileDialog dlg (this, _T("Open file"), wxEmptyString, wxEmptyString, @@ -514,6 +515,9 @@ bool Edit::LoadFile () { // load file return LoadFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::LoadFile (const wxString &filename) { @@ -544,8 +548,9 @@ bool Edit::LoadFile (const wxString &filename) { return true; } -bool Edit::SaveFile () { - +bool Edit::SaveFile () +{ +#if wxUSE_FILEDLG // return if no change if (!Modified()) return true; @@ -559,6 +564,9 @@ bool Edit::SaveFile () { // save file return SaveFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::SaveFile (const wxString &filename) { @@ -695,6 +703,8 @@ EditProperties::EditProperties (Edit *edit, ShowModal(); } +#if wxUSE_PRINTING_ARCHITECTURE + //---------------------------------------------------------------------------- // EditPrint //---------------------------------------------------------------------------- @@ -821,3 +831,4 @@ bool EditPrint::PrintScaling (wxDC *dc){ return true; } +#endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index 5ecdb7744d..4ab8cdd22c 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -423,7 +423,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) #endif // create a menu bar - wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF); + wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF); menuFile->Append(Exec_Kill, _T("&Kill process...\tCtrl-K"), _T("Kill a process by PID")); menuFile->AppendSeparator(); @@ -456,7 +456,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) execMenu->Append(Exec_DDERequest, _T("Send DDE &request...\tCtrl-R")); #endif - wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF); + wxMenu *helpMenu = new wxMenu(wxEmptyString, wxMENU_TEAROFF); helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog")); // now append the freshly created menu to the menu bar... @@ -800,8 +800,13 @@ void MyFrame::OnFileExec(wxCommandEvent& WXUNUSED(event)) { static wxString s_filename; - wxString filename = wxLoadFileSelector(_T(""), _T(""), s_filename); - if ( !filename ) + wxString filename; + +#if wxUSE_FILEDLG + filename = wxLoadFileSelector(wxEmptyString, wxEmptyString, s_filename); +#endif // wxUSE_FILEDLG + + if ( filename.empty() ) return; s_filename = filename; @@ -817,7 +822,7 @@ void MyFrame::OnFileExec(wxCommandEvent& WXUNUSED(event)) wxString cmd; bool ok = ft->GetOpenCommand(&cmd, - wxFileType::MessageParameters(filename, _T(""))); + wxFileType::MessageParameters(filename)); delete ft; if ( !ok ) { @@ -865,7 +870,7 @@ void MyFrame::OnDDEExec(wxCommandEvent& WXUNUSED(event)) return; wxDDEClient client; - wxConnectionBase *conn = client.MakeConnection(_T(""), m_server, m_topic); + wxConnectionBase *conn = client.MakeConnection(wxEmptyString, m_server, m_topic); if ( !conn ) { wxLogError(_T("Failed to connect to the DDE server '%s'."), @@ -891,7 +896,7 @@ void MyFrame::OnDDERequest(wxCommandEvent& WXUNUSED(event)) return; wxDDEClient client; - wxConnectionBase *conn = client.MakeConnection(_T(""), m_server, m_topic); + wxConnectionBase *conn = client.MakeConnection(wxEmptyString, m_server, m_topic); if ( !conn ) { wxLogError(_T("Failed to connect to the DDE server '%s'."), @@ -1061,14 +1066,14 @@ MyPipeFrame::MyPipeFrame(wxFrame *parent, wxPanel *panel = new wxPanel(this, wxID_ANY); - m_textOut = new wxTextCtrl(panel, wxID_ANY, _T(""), + m_textOut = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); - m_textIn = new wxTextCtrl(panel, wxID_ANY, _T(""), + m_textIn = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH); m_textIn->SetEditable(false); - m_textErr = new wxTextCtrl(panel, wxID_ANY, _T(""), + m_textErr = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH); m_textErr->SetEditable(false); @@ -1098,6 +1103,7 @@ MyPipeFrame::MyPipeFrame(wxFrame *parent, void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxFileDialog filedlg(this, _T("Select file to send")); if ( filedlg.ShowModal() != wxID_OK ) return; @@ -1125,6 +1131,7 @@ void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event)) DoGet(); } +#endif // wxUSE_FILEDLG } void MyPipeFrame::DoGet() diff --git a/samples/font/font.cpp b/samples/font/font.cpp index 5e2f27962e..8203a16d64 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -237,7 +237,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) m_fontSize = 12; SetIcon(wxIcon(sample_xpm)); - + // create a menu bar wxMenu *menuFile = new wxMenu; @@ -386,6 +386,7 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, } wxString facename; + if ( silent ) { // choose the first @@ -408,7 +409,7 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, delete [] facenames; } - if ( !facename.IsEmpty() ) + if ( !facename.empty() ) { wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, facename, encoding); @@ -471,7 +472,7 @@ void MyFrame::OnCheckNativeToFromString(wxCommandEvent& WXUNUSED(event)) { wxString fontInfo = m_canvas->GetTextFont().GetNativeFontInfoDesc(); - if ( fontInfo.IsEmpty() ) + if ( fontInfo.empty() ) { wxLogError(wxT("Native font info string is empty!")); } @@ -585,6 +586,7 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG // first, choose the file static wxString s_dir, s_file; wxFileDialog dialog(this, wxT("Open an email message file"), @@ -696,6 +698,7 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) wxFontMapper::GetEncodingDescription(fontenc).c_str()); } } +#endif // wxUSE_FILEDLG } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/html/test/test.cpp b/samples/html/test/test.cpp index 6bde933e55..672b33a70f 100644 --- a/samples/html/test/test.cpp +++ b/samples/html/test/test.cpp @@ -232,11 +232,13 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnPageOpen(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxString p = wxFileSelector(_("Open HTML document"), wxEmptyString, wxEmptyString, wxEmptyString, wxT("HTML files|*.htm")); - if (p != wxEmptyString) + if (!p.empty()) m_Html->LoadPage(p); +#endif // wxUSE_FILEDLG } void MyFrame::OnBack(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 98e0142667..04e04cd670 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -151,11 +151,12 @@ public: void OnSave(wxMouseEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxImage image = m_bitmap.ConvertToImage(); wxString savefilename = wxFileSelector( wxT("Save Image"), - wxT(""), - wxT(""), + wxEmptyString, + wxEmptyString, (const wxChar *)NULL, wxT("BMP files (*.bmp)|*.bmp|") wxT("PNG files (*.png)|*.png|") @@ -271,6 +272,7 @@ public: // (it may fail if the extension is not recognized): image.SaveFile(savefilename); } +#endif // wxUSE_FILEDLG } private: @@ -992,6 +994,7 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) ) { +#if wxUSE_FILEDLG wxString filename = wxFileSelector(_T("Select image file")); if ( !filename ) return; @@ -1005,6 +1008,7 @@ void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) ) } (new MyImageFrame(this, wxBitmap(image)))->Show(); +#endif // wxUSE_FILEDLG } #ifdef wxHAVE_RAW_BITMAP @@ -1096,4 +1100,3 @@ bool MyApp::OnInit() return true; } - diff --git a/samples/mobile/wxedit/wxedit.cpp b/samples/mobile/wxedit/wxedit.cpp index 491b8c333d..277f376ed8 100644 --- a/samples/mobile/wxedit/wxedit.cpp +++ b/samples/mobile/wxedit/wxedit.cpp @@ -66,7 +66,7 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title, // Create edit control. Since it is the only // control in the frame, it will be resized // to file it out. - m_text = new wxTextCtrl( this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + m_text = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); // Read .ini file for file history etc. wxConfig *conf = (wxConfig*) wxConfig::Get(); @@ -213,15 +213,16 @@ void MyFrame::OnNew( wxCommandEvent& WXUNUSED(event) ) m_filename = wxEmptyString; #if wxUSE_STATUSBAR - SetStatusText( _T("") ); + SetStatusText( wxEmptyString ); #endif // wxUSE_STATUSBAR } void MyFrame::OnOpen( wxCommandEvent& WXUNUSED(event) ) { +#if wxUSE_FILEDLG if (!Discard()) return; - wxFileDialog dialog( this, _T("Open text"), _T(""), _T(""), + wxFileDialog dialog( this, _T("Open text"), wxEmptyString, wxEmptyString, _T("Text file (*.txt)|*.txt|Any file (*)|*"), wxOPEN|wxFILE_MUST_EXIST ); if (dialog.ShowModal() == wxID_OK) @@ -265,6 +266,7 @@ void MyFrame::OnOpen( wxCommandEvent& WXUNUSED(event) ) SetStatusText( m_filename ); #endif // wxUSE_STATUSBAR } +#endif // wxUSE_FILEDLG } void MyFrame::OnSave( wxCommandEvent& WXUNUSED(event) ) @@ -274,7 +276,8 @@ void MyFrame::OnSave( wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnSaveAs( wxCommandEvent& WXUNUSED(event) ) { - wxFileDialog dialog( this, _T("Open text"), _T(""), _T(""), +#if wxUSE_FILEDLG + wxFileDialog dialog( this, _T("Open text"), wxEmptyString, wxEmptyString, _T("Text file (*.txt)|*.txt|Any file (*)|*"), wxSAVE|wxOVERWRITE_PROMPT ); if (dialog.ShowModal() == wxID_OK) @@ -286,6 +289,7 @@ void MyFrame::OnSaveAs( wxCommandEvent& WXUNUSED(event) ) SetStatusText( m_filename ); #endif // wxUSE_STATUSBAR } +#endif // wxUSE_FILEDLG } void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) @@ -417,4 +421,3 @@ int MyApp::OnExit() { return 0; } - diff --git a/samples/png/pngdemo.cpp b/samples/png/pngdemo.cpp index 5ae070ba07..ba275d9c09 100644 --- a/samples/png/pngdemo.cpp +++ b/samples/png/pngdemo.cpp @@ -110,40 +110,43 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSaveFile(wxCommandEvent& WXUNUSED(event)) { - wxString f = wxFileSelector( wxT("Save Image"), (const wxChar *)NULL, - (const wxChar *)NULL, - wxT("png"), wxT("PNG files (*.png)|*.png") ); +#if wxUSE_FILEDLG + wxString f = wxFileSelector( wxT("Save Image"), (const wxChar *)NULL, + (const wxChar *)NULL, + wxT("png"), wxT("PNG files (*.png)|*.png") ); - if (f == _T("")) return; + if (f.empty()) return; - wxBitmap *backstore = new wxBitmap( 150, 150 ); + wxBitmap *backstore = new wxBitmap( 150, 150 ); - wxMemoryDC memDC; - memDC.SelectObject( *backstore ); - memDC.Clear(); - memDC.SetBrush( *wxBLACK_BRUSH ); - memDC.SetPen( *wxWHITE_PEN ); - memDC.DrawRectangle( 0, 0, 150, 150 ); - memDC.SetPen( *wxBLACK_PEN ); - memDC.DrawLine( 0, 0, 0, 10 ); - memDC.SetTextForeground( *wxWHITE ); - memDC.DrawText( _T("This is a memory dc."), 10, 10 ); + wxMemoryDC memDC; + memDC.SelectObject( *backstore ); + memDC.Clear(); + memDC.SetBrush( *wxBLACK_BRUSH ); + memDC.SetPen( *wxWHITE_PEN ); + memDC.DrawRectangle( 0, 0, 150, 150 ); + memDC.SetPen( *wxBLACK_PEN ); + memDC.DrawLine( 0, 0, 0, 10 ); + memDC.SetTextForeground( *wxWHITE ); + memDC.DrawText( _T("This is a memory dc."), 10, 10 ); - memDC.SelectObject( wxNullBitmap ); + memDC.SelectObject( wxNullBitmap ); - backstore->SaveFile( f, wxBITMAP_TYPE_PNG, (wxPalette*)NULL ); + backstore->SaveFile( f, wxBITMAP_TYPE_PNG, (wxPalette*)NULL ); - delete backstore; + delete backstore; +#endif // wxUSE_FILEDLG } void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG // Show file selector. wxString f = wxFileSelector(wxT("Open Image"), (const wxChar *) NULL, (const wxChar *) NULL, wxT("png"), wxT("PNG files (*.png)|*.png")); - if (f == _T("")) + if (f.empty()) return; if ( g_TestBitmap ) @@ -157,6 +160,7 @@ void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event)) } canvas->Refresh(); +#endif // wxUSE_FILEDLG } BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) @@ -172,41 +176,39 @@ MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size): // Define the repainting behaviour void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { - wxPaintDC dc(this); - dc.SetPen(* wxRED_PEN); + wxPaintDC dc(this); + dc.SetPen(* wxRED_PEN); - int i; - for ( i = 0; i < 500; i += 10) - { - dc.DrawLine(0, i, 800, i); - } - if ( g_TestBitmap && g_TestBitmap->Ok() ) - { - wxMemoryDC memDC; - if ( g_TestBitmap->GetPalette() ) + int i; + for ( i = 0; i < 500; i += 10) { - memDC.SetPalette(* g_TestBitmap->GetPalette()); - dc.SetPalette(* g_TestBitmap->GetPalette()); + dc.DrawLine(0, i, 800, i); } - memDC.SelectObject(* g_TestBitmap); + if ( g_TestBitmap && g_TestBitmap->Ok() ) + { + wxMemoryDC memDC; + if ( g_TestBitmap->GetPalette() ) + { + memDC.SetPalette(* g_TestBitmap->GetPalette()); + dc.SetPalette(* g_TestBitmap->GetPalette()); + } + memDC.SelectObject(* g_TestBitmap); - // Normal, non-transparent blitting - dc.Blit(20, 20, g_TestBitmap->GetWidth(), g_TestBitmap->GetHeight(), & memDC, 0, 0, wxCOPY, false); + // Normal, non-transparent blitting + dc.Blit(20, 20, g_TestBitmap->GetWidth(), g_TestBitmap->GetHeight(), & memDC, 0, 0, wxCOPY, false); - memDC.SelectObject(wxNullBitmap); - } + memDC.SelectObject(wxNullBitmap); + } - if ( g_TestBitmap && g_TestBitmap->Ok() ) - { - wxMemoryDC memDC; - memDC.SelectObject(* g_TestBitmap); + if ( g_TestBitmap && g_TestBitmap->Ok() ) + { + wxMemoryDC memDC; + memDC.SelectObject(* g_TestBitmap); - // Transparent blitting if there's a mask in the bitmap - dc.Blit(20 + g_TestBitmap->GetWidth() + 20, 20, g_TestBitmap->GetWidth(), g_TestBitmap->GetHeight(), & memDC, - 0, 0, wxCOPY, true); + // Transparent blitting if there's a mask in the bitmap + dc.Blit(20 + g_TestBitmap->GetWidth() + 20, 20, g_TestBitmap->GetWidth(), g_TestBitmap->GetHeight(), & memDC, + 0, 0, wxCOPY, true); - memDC.SelectObject(wxNullBitmap); - } + memDC.SelectObject(wxNullBitmap); + } } - - diff --git a/samples/sound/sound.cpp b/samples/sound/sound.cpp index 8273867d7c..22be97508f 100644 --- a/samples/sound/sound.cpp +++ b/samples/sound/sound.cpp @@ -77,7 +77,7 @@ public: void OnAbout(wxCommandEvent& event); void NotifyUsingFile(const wxString& name); - + private: bool CreateSound(wxSound& snd) const; @@ -90,7 +90,7 @@ private: bool m_useMemory; wxTextCtrl* m_tc; - + // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() }; @@ -981,6 +981,7 @@ void MyFrame::NotifyUsingFile(const wxString& name) void MyFrame::OnSelectFile(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_FILEDLG wxFileDialog dlg(this, _T("Choose a sound file"), wxEmptyString, wxEmptyString, _T("WAV files (*.wav)|*.wav"), wxOPEN|wxCHANGE_DIR); @@ -996,6 +997,7 @@ void MyFrame::OnSelectFile(wxCommandEvent& WXUNUSED(event)) m_sound = NULL; NotifyUsingFile(m_soundFile); } +#endif // wxUSE_FILEDLG } #ifdef __WXMSW__ diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index 9618eb8992..a3b7d7c236 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -502,8 +502,9 @@ bool Edit::InitializePrefs (const wxString &name) { return true; } -bool Edit::LoadFile () { - +bool Edit::LoadFile () +{ +#if wxUSE_FILEDLG // get filname if (!m_filename) { wxFileDialog dlg (this, _T("Open file"), wxEmptyString, wxEmptyString, @@ -514,6 +515,9 @@ bool Edit::LoadFile () { // load file return LoadFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::LoadFile (const wxString &filename) { @@ -544,8 +548,9 @@ bool Edit::LoadFile (const wxString &filename) { return true; } -bool Edit::SaveFile () { - +bool Edit::SaveFile () +{ +#if wxUSE_FILEDLG // return if no change if (!Modified()) return true; @@ -559,6 +564,9 @@ bool Edit::SaveFile () { // save file return SaveFile (m_filename); +#else + return false; +#endif // wxUSE_FILEDLG } bool Edit::SaveFile (const wxString &filename) { @@ -695,6 +703,8 @@ EditProperties::EditProperties (Edit *edit, ShowModal(); } +#if wxUSE_PRINTING_ARCHITECTURE + //---------------------------------------------------------------------------- // EditPrint //---------------------------------------------------------------------------- @@ -821,3 +831,4 @@ bool EditPrint::PrintScaling (wxDC *dc){ return true; } +#endif // wxUSE_PRINTING_ARCHITECTURE