]> git.saurik.com Git - wxWidgets.git/commitdiff
Zooming buttons / menu options automatically disabled when needed
authorGuillermo Rodriguez Garcia <guille@iies.es>
Wed, 9 Feb 2000 20:52:12 +0000 (20:52 +0000)
committerGuillermo Rodriguez Garcia <guille@iies.es>
Wed, 9 Feb 2000 20:52:12 +0000 (20:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

demos/life/life.cpp

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