Zooming buttons / menu options automatically disabled when needed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia 2000-02-09 20:52:12 +00:00
parent 4ac99f4bbe
commit a9cf40974a

View File

@ -240,11 +240,19 @@ void LifeFrame::UpdateInfoText()
// way to do this. // way to do this.
void LifeFrame::UpdateUI() void LifeFrame::UpdateUI()
{ {
// start / stop
GetToolBar()->EnableTool(ID_START, !m_running); GetToolBar()->EnableTool(ID_START, !m_running);
GetToolBar()->EnableTool(ID_STOP, m_running); GetToolBar()->EnableTool(ID_STOP, m_running);
GetMenuBar()->GetMenu(1)->Enable(ID_START, !m_running); GetMenuBar()->GetMenu(1)->Enable(ID_START, !m_running);
GetMenuBar()->GetMenu(1)->Enable(ID_STEP, !m_running); GetMenuBar()->GetMenu(1)->Enable(ID_STEP, !m_running);
GetMenuBar()->GetMenu(1)->Enable(ID_STOP, m_running); GetMenuBar()->GetMenu(1)->Enable(ID_STOP, m_running);
// zooming
int cellsize = m_canvas->GetCellSize();
GetToolBar()->EnableTool(ID_ZOOMIN, cellsize < 32);
GetToolBar()->EnableTool(ID_ZOOMOUT, cellsize > 1);
GetMenuBar()->GetMenu(1)->Enable(ID_ZOOMIN, cellsize < 32);
GetMenuBar()->GetMenu(1)->Enable(ID_ZOOMOUT, cellsize > 1);
} }
// event handlers // event handlers
@ -260,14 +268,20 @@ void LifeFrame::OnMenu(wxCommandEvent& event)
{ {
int cellsize = m_canvas->GetCellSize(); int cellsize = m_canvas->GetCellSize();
if (cellsize < 32) if (cellsize < 32)
{
m_canvas->SetCellSize(cellsize * 2); m_canvas->SetCellSize(cellsize * 2);
UpdateUI();
}
break; break;
} }
case ID_ZOOMOUT : case ID_ZOOMOUT :
{ {
int cellsize = m_canvas->GetCellSize(); int cellsize = m_canvas->GetCellSize();
if (cellsize > 1) if (cellsize > 1)
{
m_canvas->SetCellSize(cellsize / 2); m_canvas->SetCellSize(cellsize / 2);
UpdateUI();
}
break; break;
} }
case ID_TOPSPEED: case ID_TOPSPEED: