Enable/disable controls into one method
This commit is contained in:
parent
c849b906cb
commit
d0db1a0d7f
@ -26,7 +26,7 @@ MainFrame::MainFrame(wxFrame *frame, const wxString& title)
|
|||||||
base_sizer->SetContainingWindow(this);
|
base_sizer->SetContainingWindow(this);
|
||||||
base_sizer->SetMinSize(800,600);
|
base_sizer->SetMinSize(800,600);
|
||||||
|
|
||||||
this->DisableEditControls();
|
this->EnableEditControls(false);
|
||||||
this->BindEvents();
|
this->BindEvents();
|
||||||
|
|
||||||
// Do the layout
|
// Do the layout
|
||||||
@ -79,7 +79,7 @@ void MainFrame::SetupToolbar()
|
|||||||
toolBar->AddTool(wxID_NEW, "New", new_file_icon, "New file");
|
toolBar->AddTool(wxID_NEW, "New", new_file_icon, "New file");
|
||||||
toolBar->AddTool(wxID_OPEN, "Open", open_file_icon, "Open file");
|
toolBar->AddTool(wxID_OPEN, "Open", open_file_icon, "Open file");
|
||||||
toolBar->AddTool(wxID_SAVE, "Save", save_file_icon, "Save file");
|
toolBar->AddTool(wxID_SAVE, "Save", save_file_icon, "Save file");
|
||||||
#ifndef __WXWIN__
|
#ifndef WIN32
|
||||||
toolBar->AddTool(wxID_CLOSE, "Close", close_file_icon, "Close file");
|
toolBar->AddTool(wxID_CLOSE, "Close", close_file_icon, "Close file");
|
||||||
#endif
|
#endif
|
||||||
toolBar->AddSeparator();
|
toolBar->AddSeparator();
|
||||||
@ -215,7 +215,7 @@ void MainFrame::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
if (notebook->GetPageCount() == 0)
|
if (notebook->GetPageCount() == 0)
|
||||||
{
|
{
|
||||||
this->DisableEditControls();
|
this->EnableEditControls(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,46 +328,22 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
|||||||
wxAboutBox(info);
|
wxAboutBox(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void MainFrame::EnableEditControls(bool enable)
|
||||||
* Enable file-specific controls
|
|
||||||
*/
|
|
||||||
void MainFrame::EnableEditControls()
|
|
||||||
{
|
{
|
||||||
fileMenu->Enable(wxID_SAVE, true);
|
fileMenu->Enable(wxID_SAVE, enable);
|
||||||
fileMenu->Enable(wxID_SAVEAS, true);
|
fileMenu->Enable(wxID_SAVEAS, enable);
|
||||||
|
fileMenu->Enable(wxID_CLOSE, enable);
|
||||||
|
|
||||||
editMenu->Enable(wxID_CUT, true);
|
editMenu->Enable(wxID_CUT, enable);
|
||||||
editMenu->Enable(wxID_COPY, true);
|
editMenu->Enable(wxID_COPY, enable);
|
||||||
editMenu->Enable(wxID_PASTE, true);
|
editMenu->Enable(wxID_PASTE, enable);
|
||||||
editMenu->Enable(wxID_CLEAR, true);
|
editMenu->Enable(wxID_CLEAR, enable);
|
||||||
editMenu->Enable(wxID_FIND, true);
|
editMenu->Enable(wxID_FIND, enable);
|
||||||
editMenu->Enable(wxID_SELECTALL, true);
|
editMenu->Enable(wxID_SELECTALL, enable);
|
||||||
|
|
||||||
toolBar->EnableTool(wxID_SAVE, true);
|
toolBar->EnableTool(wxID_SAVE, enable);
|
||||||
toolBar->EnableTool(wxID_CLOSE, true);
|
toolBar->EnableTool(wxID_CLOSE, enable);
|
||||||
toolBar->EnableTool(wxID_COPY, true);
|
toolBar->EnableTool(wxID_COPY, enable);
|
||||||
toolBar->EnableTool(wxID_CUT, true);
|
toolBar->EnableTool(wxID_CUT, enable);
|
||||||
toolBar->EnableTool(wxID_PASTE, true);
|
toolBar->EnableTool(wxID_PASTE, enable);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables file-specific controls
|
|
||||||
*/
|
|
||||||
void MainFrame::DisableEditControls()
|
|
||||||
{
|
|
||||||
fileMenu->Enable(wxID_SAVE, false);
|
|
||||||
fileMenu->Enable(wxID_SAVEAS, false);
|
|
||||||
|
|
||||||
editMenu->Enable(wxID_CUT, false);
|
|
||||||
editMenu->Enable(wxID_COPY, false);
|
|
||||||
editMenu->Enable(wxID_PASTE, false);
|
|
||||||
editMenu->Enable(wxID_CLEAR, false);
|
|
||||||
editMenu->Enable(wxID_FIND, false);
|
|
||||||
editMenu->Enable(wxID_SELECTALL, false);
|
|
||||||
|
|
||||||
toolBar->EnableTool(wxID_SAVE, false);
|
|
||||||
toolBar->EnableTool(wxID_CLOSE, false);
|
|
||||||
toolBar->EnableTool(wxID_COPY, false);
|
|
||||||
toolBar->EnableTool(wxID_CUT, false);
|
|
||||||
toolBar->EnableTool(wxID_PASTE, false);
|
|
||||||
}
|
}
|
@ -38,8 +38,7 @@ class MainFrame: public wxFrame
|
|||||||
void SetupToolbar();
|
void SetupToolbar();
|
||||||
void SetupStatusBar();
|
void SetupStatusBar();
|
||||||
void BindEvents();
|
void BindEvents();
|
||||||
void EnableEditControls();
|
void EnableEditControls(bool enable=true);
|
||||||
void DisableEditControls();
|
|
||||||
void OnNew(wxCommandEvent &event);
|
void OnNew(wxCommandEvent &event);
|
||||||
void OnOpen(wxCommandEvent &event);
|
void OnOpen(wxCommandEvent &event);
|
||||||
void OnClose(wxAuiNotebookEvent &event);
|
void OnClose(wxAuiNotebookEvent &event);
|
||||||
|
Loading…
Reference in New Issue
Block a user