After much trawling through the wxWidgets source code... :-p ... it seems that a wxGridSizer is doesn't care if you are showing an item or not.
Instead, try using a wxFlexGridSizer, which is a subclass of wxGridSizer. You also need to call Fit() on your window to get it to recalculate itself.
Example :
hidden.bmx
hiddengen.bmx
:o)
Instead, try using a wxFlexGridSizer, which is a subclass of wxGridSizer. You also need to call Fit() on your window to get it to recalculate itself.
Example :
hidden.bmx
' ' Example application stub generated by wxCodeGen v1.10 : 01 Sep 2008 10:44:15 ' SuperStrict Framework wx.wxApp Import "hiddengen.bmx" New MyApp.run() Type MyApp Extends wxApp Method OnInit:Int() Local frame:MyFrame1 = MyFrame1(New MyFrame1.Create()) frame.Centre() frame.Show() Return True End Method End Type Type MyFrame1 Extends MyFrame1Base Field flag:Int = False Method OnInit() Super.OnInit() ' hide some buttons gSizer1.Show(m_button2, False) gSizer1.Show(m_button3, False) gSizer1.Show(m_button4, False) gSizer1.Show(m_button5, False) gSizer1.Show(m_button6, False) gSizer1.Show(m_button7, False) gSizer1.Show(m_button8, False) gSizer1.Show(m_button9, False) gSizer1.Layout() ' snap to fit... Fit() End Method Method OnShowHide(event:wxCommandEvent) flag = Not flag gSizer1.Show(m_button9 , flag) gSizer1.Layout() ' snap to fit... Fit() End Method End Type
hiddengen.bmx
' ' BlitzMax code generated with wxCodeGen v1.10 : 01 Sep 2008 11:53:49 ' ' ' PLEASE DO "NOT" EDIT THIS FILE! ' SuperStrict Import wx.wxButton Import wx.wxFrame Import wx.wxWindow Type MyFrame1Base Extends wxFrame Field m_button10:wxButton Field gSizer1:wxFlexGridSizer Field m_button1:wxButton Field m_button2:wxButton Field m_button3:wxButton Field m_button4:wxButton Field m_button5:wxButton Field m_button6:wxButton Field m_button7:wxButton Field m_button8:wxButton Field m_button9:wxButton Method Create:MyFrame1Base(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = -1, h:Int = -1, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL) return MyFrame1Base(Super.Create(parent, id, title, x, y, w, h, style)) End Method Method OnInit() Local bSizer1:wxBoxSizer bSizer1 = new wxBoxSizer.Create(wxHORIZONTAL) Local bSizer2:wxBoxSizer bSizer2 = new wxBoxSizer.Create(wxVERTICAL) m_button10 = new wxButton.Create(Self, wxID_ANY, "Click to toggle") bSizer2.Add(m_button10, 0, wxALL, 5) bSizer1.AddSizer(bSizer2, 0, wxEXPAND, 5) gSizer1 = new wxFlexGridSizer.CreateRC(3, 3, 0, 0) gSizer1.SetFlexibleDirection( wxBOTH ) gSizer1.SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ) m_button1 = new wxButton.Create(Self, wxID_ANY, "1,1") gSizer1.Add(m_button1, 0, wxALL, 5) m_button2 = new wxButton.Create(Self, wxID_ANY, "2,1") gSizer1.Add(m_button2, 0, wxALL, 5) m_button3 = new wxButton.Create(Self, wxID_ANY, "3,1") gSizer1.Add(m_button3, 0, wxALL, 5) m_button4 = new wxButton.Create(Self, wxID_ANY, "1,2") gSizer1.Add(m_button4, 0, wxALL, 5) m_button5 = new wxButton.Create(Self, wxID_ANY, "2,2") gSizer1.Add(m_button5, 0, wxALL, 5) m_button6 = new wxButton.Create(Self, wxID_ANY, "3,2") gSizer1.Add(m_button6, 0, wxALL, 5) m_button7 = new wxButton.Create(Self, wxID_ANY, "1,3") gSizer1.Add(m_button7, 0, wxALL, 5) m_button8 = new wxButton.Create(Self, wxID_ANY, "2,3") gSizer1.Add(m_button8, 0, wxALL, 5) m_button9 = new wxButton.Create(Self, wxID_ANY, "3,3") gSizer1.Add(m_button9, 0, wxALL, 5) bSizer1.AddSizer(gSizer1, 1, wxEXPAND, 5) SetSizer(bSizer1) Layout() bSizer1.Fit(Self) m_button10.ConnectAny(wxEVT_COMMAND_BUTTON_CLICKED, _OnShowHide, Null, Self) End Method Function _OnShowHide(event:wxEvent) MyFrame1Base(event.sink).OnShowHide(wxCommandEvent(event)) End Function Method OnShowHide(event:wxCommandEvent) DebugLog "Please override MyFrame1.OnShowHide()" event.Skip() End Method End Type
:o)