lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thursday 18 December 2003 09:22, W.Razik@bp.com.pl wrote:
> >> sizerV:AddWindow(sizerH, 0, wx.wxALL, 5)
> [...]
> Are there special rules for placing sizers within sizers?

Yes, you have to use AddSizer instead of AddWindow. Some overloaded wxLua 
functions are different from what appears in wxWindows documentation; when in 
doubt look at the classes.txt file included in wxLua.

Here is a wxLua example using sizers within sizers:
http://www.erix.it/progutil.html#gpeddler2
(see below for the layout building function from the above program)

  Enrico


-- 
-- Build frame layout using sizers
--
function MainFrame:SetupLayout()
  -- sizers for the two solvers
  local vSizer1 = wx.wxStaticBoxSizer(self.box1, wx.wxVERTICAL)
  vSizer1:AddWindow(self.area1, 1, wx.wxALL + wx.wxGROW, 10)
  vSizer1:AddWindow(self.stat1, 0, wx.wxALL, 10)
  local vSizer2 = wx.wxStaticBoxSizer(self.box2, wx.wxVERTICAL)
  vSizer2:AddWindow(self.area2, 1, wx.wxALL + wx.wxGROW, 10)
  vSizer2:AddWindow(self.stat2, 0, wx.wxALL, 10)
  -- sizer to keep both solvers side-to-side
  local hSizer = wx.wxBoxSizer(wx.wxHORIZONTAL)
  hSizer:AddSizer(vSizer1, 1, wx.wxGROW);
  hSizer:Add(10, 0, 0) -- spacing
  hSizer:AddSizer(vSizer2, 1, wx.wxGROW, 10);
  -- sizer for the buttons
  local bSizer = wx.wxBoxSizer(wx.wxHORIZONTAL)
  bSizer:Add(1, 1, 1) -- center buttons using stretchable space
  bSizer:AddWindow(self.startButton, 0, wx.wxLEFT + wx.wxRIGHT, 10)
  bSizer:AddWindow(self.stopButton, 0, wx.wxLEFT + wx.wxRIGHT, 10)
  bSizer:AddWindow(self.newRouteButton, 0, wx.wxLEFT + wx.wxRIGHT, 10)
  bSizer:AddWindow(self.optionsButton, 0, wx.wxLEFT + wx.wxRIGHT, 10)
  bSizer:Add(1, 1, 1)
  -- sizer to hold it all
  local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL)
  mainSizer:AddSizer(hSizer, 1, wx.wxALL + wx.wxGROW, 10);
  mainSizer:AddSizer(bSizer, 0, wx.wxALL - wx.wxTOP + wx.wxGROW, 10);
  -- make layout work
  self.window:SetSizer(mainSizer)
  mainSizer:SetSizeHints(self.window)
  mainSizer:Fit(self.window)
end