Getting (maximal) size of wxToolbook

Volker Bartheld dr_versaeg at freenet.de
Thu Sep 27 10:21:04 PDT 2007


Hi!

> VB> Unfortunately, I failed in querying the wxToolbook for its size that
> VB> included the extent of the toolbook buttons. [...]
> VB> How can I solve this issue?

>  Apparently the control didn't lay out itself correctly as otherwise I
> don't understand how can it return the wrong size. If this is indeed the
> case, calling Layout() on its parent might help...

After studying the wxNotebook sources (mainly src\generic\toolbkg.cpp,
src\common\bookctrl.cpp), I came to the conclusion that there is no built
in code that will take into account the wxToolBar member's dimension.

In my case, the following lines did the trick:

    m_pToolbook->ChangeSelection(0);
    m_pToolbook->Fit();
    wxSize
      sBar=m_pToolbook->GetToolBar()->GetToolSize(),
      sBook=m_pToolbook->GetSize();
    m_pToolbook->SetMinSize(wxSize(
      std::max<int>(sBook.GetWidth(), sBar.GetWidth()),
      std::max<int>(sBook.GetHeight(), sBar.GetHeight()*m_pToolbook->GetPageCount())
      ));
    pMainSizer->Add(m_pToolbook);

    pMainSizer->SetSizeHints(this);
    Layout();

Of course, this is not very generic (only works for wxNB_LEFT) and also
kinda clumsy, but maybe people who know the wxToolbook/wxNotebook interna
better than me can implement something likewise in one of the next releases.

HTH,
Volker

-- 
mailto:  V B A R T H E L D at G M X dot D E






More information about the wx-users mailing list