Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29684 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// Name: wxedit.cpp
|
||||
// Author: Robert Roebling
|
||||
// Created: 04/07/02
|
||||
// Copyright:
|
||||
// Copyright:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
@@ -34,20 +34,20 @@
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
|
||||
|
||||
|
||||
EVT_MENU(ID_NEW, MyFrame::OnNew)
|
||||
EVT_MENU(ID_OPEN, MyFrame::OnOpen)
|
||||
EVT_MENU(ID_SAVE, MyFrame::OnSave)
|
||||
EVT_MENU(ID_SAVEAS, MyFrame::OnSaveAs)
|
||||
EVT_MENU(ID_QUIT, MyFrame::OnQuit)
|
||||
|
||||
|
||||
EVT_MENU(ID_COPY, MyFrame::OnCopy)
|
||||
EVT_MENU(ID_CUT, MyFrame::OnCut)
|
||||
EVT_MENU(ID_PASTE, MyFrame::OnPaste)
|
||||
EVT_MENU(ID_DELETE, MyFrame::OnDelete)
|
||||
|
||||
|
||||
EVT_MENU_RANGE(ID_LAST_1, ID_LAST_3, MyFrame::OnLastFiles)
|
||||
|
||||
|
||||
EVT_CLOSE(MyFrame::OnCloseWindow)
|
||||
EVT_UPDATE_UI(wxID_ANY,MyFrame::OnUpdateUI)
|
||||
END_EVENT_TABLE()
|
||||
@@ -62,26 +62,26 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
CreateStatusBar(1);
|
||||
SetStatusText( _T("Welcome to wxEdit!") );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
|
||||
// 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 );
|
||||
|
||||
|
||||
// Read .ini file for file history etc.
|
||||
wxConfig *conf = (wxConfig*) wxConfig::Get();
|
||||
|
||||
int entries = 0;
|
||||
int entries = 0;
|
||||
conf->Read( _T("/History/Count"), &entries );
|
||||
|
||||
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
wxString tmp;
|
||||
tmp.Printf( _T("/History/File%d"), (int)i );
|
||||
|
||||
|
||||
wxString res;
|
||||
conf->Read( tmp, &res );
|
||||
|
||||
|
||||
if (!res.empty())
|
||||
AddToHistory( res );
|
||||
}
|
||||
@@ -90,19 +90,19 @@ MyFrame::MyFrame( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
void MyFrame::MakeHistory()
|
||||
{
|
||||
wxMenuBar *mb = GetMenuBar();
|
||||
|
||||
|
||||
wxASSERT( mb );
|
||||
|
||||
int max = m_history.GetCount();
|
||||
if (max > HISTORY_ENTRIES)
|
||||
max = HISTORY_ENTRIES;
|
||||
|
||||
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
wxMenu *menu = NULL;
|
||||
mb->FindItem( ID_LAST_1 + i, &menu );
|
||||
wxASSERT( menu );
|
||||
|
||||
|
||||
wxFileName fname( m_history[(size_t)i] );
|
||||
menu->SetLabel( ID_LAST_1 + i, fname.GetFullName() );
|
||||
}
|
||||
@@ -112,12 +112,12 @@ void MyFrame::AddToHistory( const wxString &fname )
|
||||
{
|
||||
// Fill menu with history index
|
||||
int index = m_history.Index( fname );
|
||||
|
||||
|
||||
if (index != wxNOT_FOUND)
|
||||
m_history.RemoveAt( (size_t) index );
|
||||
|
||||
|
||||
m_history.Insert( fname, 0 );
|
||||
|
||||
|
||||
// Update menu
|
||||
MakeHistory();
|
||||
}
|
||||
@@ -140,17 +140,17 @@ void MyFrame::CreateMyMenuBar()
|
||||
edit_menu->Append( ID_PASTE, _T("Paste") );
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append( ID_DELETE, _T("Delete") );
|
||||
|
||||
|
||||
wxMenu *history_menu = new wxMenu;
|
||||
history_menu->Append( ID_LAST_1, _T("No file.") );
|
||||
history_menu->Append( ID_LAST_2, _T("No file.") );
|
||||
history_menu->Append( ID_LAST_3, _T("No file.") );
|
||||
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar();
|
||||
menu_bar->Append( file_menu, _T("&File") );
|
||||
menu_bar->Append( edit_menu, _T("&Edit") );
|
||||
menu_bar->Append( history_menu, _T("&History") );
|
||||
|
||||
|
||||
SetMenuBar( menu_bar );
|
||||
}
|
||||
|
||||
@@ -176,16 +176,16 @@ void MyFrame::OnLastFiles( wxCommandEvent &event )
|
||||
|
||||
if (!m_filename.empty())
|
||||
AddToHistory( m_filename );
|
||||
|
||||
|
||||
size_t index = event.GetId() - ID_LAST_1;
|
||||
|
||||
|
||||
if( index < m_history.GetCount() )
|
||||
{
|
||||
m_filename = m_history[index];
|
||||
|
||||
|
||||
m_text->Clear();
|
||||
m_text->LoadFile( m_filename );
|
||||
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText( m_filename );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
@@ -206,12 +206,12 @@ void MyFrame::OnNew( wxCommandEvent& WXUNUSED(event) )
|
||||
if (!Discard()) return;
|
||||
|
||||
m_text->Clear();
|
||||
|
||||
|
||||
if (!m_filename.empty())
|
||||
AddToHistory( m_filename );
|
||||
|
||||
|
||||
m_filename = wxEmptyString;
|
||||
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText( _T("") );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
@@ -257,7 +257,7 @@ void MyFrame::OnOpen( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
m_filename = dialog.GetPath();
|
||||
m_text->LoadFile( m_filename );
|
||||
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText( m_filename );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
@@ -278,7 +278,7 @@ void MyFrame::OnSaveAs( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
m_filename = dialog.GetPath();
|
||||
m_text->SaveFile( m_filename );
|
||||
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
SetStatusText( m_filename );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
@@ -300,12 +300,12 @@ void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
|
||||
bool MyFrame::Save()
|
||||
{
|
||||
wxCommandEvent event;
|
||||
|
||||
|
||||
if (m_filename.empty())
|
||||
OnSaveAs( event );
|
||||
else
|
||||
m_text->SaveFile( m_filename );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -315,19 +315,19 @@ bool MyFrame::Discard()
|
||||
{
|
||||
wxMessageDialog dialog( this, _T("Text has been\nmodified! Save?"),
|
||||
_T("wxEdit"), wxYES_NO|wxCANCEL|wxICON_EXCLAMATION );
|
||||
|
||||
|
||||
int ret = dialog.ShowModal();
|
||||
|
||||
|
||||
if (ret == wxID_CANCEL)
|
||||
return false;
|
||||
|
||||
|
||||
if (ret == wxID_YES)
|
||||
{
|
||||
if (!Save())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ void MyFrame::OnUpdateUI( wxUpdateUIEvent &event )
|
||||
m_text->GetSelection(& selFrom, & selTo);
|
||||
event.Enable( selFrom != selTo );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -363,29 +363,29 @@ void MyFrame::OnUpdateUI( wxUpdateUIEvent &event )
|
||||
void MyFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
|
||||
{
|
||||
// Save changes?
|
||||
if (!Discard()) return;
|
||||
|
||||
if (!Discard()) return;
|
||||
|
||||
// Add current to history
|
||||
if (!m_filename.empty())
|
||||
AddToHistory( m_filename );
|
||||
|
||||
// Write .ini file
|
||||
// Write .ini file
|
||||
wxConfig *conf = (wxConfig*) wxConfig::Get();
|
||||
|
||||
|
||||
int max = HISTORY_ENTRIES;
|
||||
if (m_history.GetCount() < (size_t)max)
|
||||
max = m_history.GetCount();
|
||||
|
||||
|
||||
conf->Write( _T("/History/Count"), max );
|
||||
|
||||
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
wxString tmp;
|
||||
tmp.Printf( _T("/History/File%d"), (int)i );
|
||||
|
||||
|
||||
conf->Write( tmp, m_history[(size_t)i] );
|
||||
}
|
||||
|
||||
|
||||
// Flush and delete config
|
||||
delete wxConfig::Set( NULL );
|
||||
|
||||
@@ -399,18 +399,14 @@ void MyFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
MyApp::MyApp()
|
||||
{
|
||||
}
|
||||
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
SetVendorName(_T("Free world"));
|
||||
SetAppName(_T("wxEdit"));
|
||||
|
||||
|
||||
MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("wxEdit"), wxPoint(20,20), wxSize(500,340) );
|
||||
frame->Show( true );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user