Hello,
I've got a window with a wxNotebook over the entire width with 5 tabs (fixed). The content of the tabs is adjusting to the window size. The size of the window is the minimal size using SetSizeHints. Unfortunately the window is set to the minimal size to fit the tab content, but not the tab header. I do not want tab scrolling, all 5 tab headers should fit in the window. I could not find any solution, any idea how to do that?
Best regards
Stefan
wxNotebook: Set size of window to fit all tabs
Re: wxNotebook: Set size of window to fit all tabs
If the wxNotebook is inside any kind of sizer, this should happen automatically. Can you show some code?
Use the source, Luke!
Re: wxNotebook: Set size of window to fit all tabs
This is the relevant code from the constructor (wxDialaog is the base class) I removed all the parts where widgets get added to the panels):
The use of a wxGridBagSizer for the top window is caused by the widgets now arranged in tabs used to be all in the window
Code: Select all
m_win_sizer = new wxGridSizer( 1,1,0,0 );
wxNotebook *notebook = new wxNotebook(this,ID_Notebook,wxDefaultPosition,wxDefaultSize,wxNB_TOP);
wxPanel *osmosdr_panel = new wxPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
wxPanel *demod_panel = new wxPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
wxPanel *csv_panel = new wxPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
wxPanel *debug_panel = new wxPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
wxPanel *appearance_panel = new wxPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
wxGridBagSizer *top_sizer = new wxGridBagSizer(5,5);
osmosdr_panel->SetSizerAndFit(osmosdr_sizer);
demod_panel->SetSizerAndFit(demodulator_sizer);
csv_panel->SetSizerAndFit(import_sizer);
appearance_panel->SetSizerAndFit(design_sizer);
debug_panel->SetSizerAndFit(debug_sizer);
notebook->AddPage(osmosdr_panel,_T("OsmoSDR"));
notebook->AddPage(demod_panel,_T("Demodulation"));
notebook->AddPage(csv_panel,_T("CSV import"));
notebook->AddPage(appearance_panel,_T("Appearance"));
notebook->AddPage(debug_panel,_T("Debug"));
top_sizer->Add(notebook,wxGBPosition(0,0),wxGBSpan(1,2),wxEXPAND | wxALL);
top_sizer->Add(button_sizer,wxGBPosition(1,0),wxGBSpan(1,2), wxALL | wxALIGN_CENTER);
top_sizer->AddGrowableCol(0,1);
top_sizer->AddGrowableCol(1,1);
top_sizer->AddGrowableRow(0,1);
m_win_sizer->Add(top_sizer,0,wxEXPAND | wxALL,5);
SetSizer(m_win_sizer);
m_win_sizer->SetSizeHints(this);
Re: wxNotebook: Set size of window to fit all tabs
I called notebook->GetBestFittingSize().GetWidth() to find out what is considered the best size:
Before adding pages: 6
After adding pages: 256
This is to fit the contents of the tabs, not the tab headers. I can use SetBestFittingSize to increase the width and it works, but how do I get the precise value to fit the tab headers?
Before adding pages: 6
After adding pages: 256
This is to fit the contents of the tabs, not the tab headers. I can use SetBestFittingSize to increase the width and it works, but how do I get the precise value to fit the tab headers?
Re: wxNotebook: Set size of window to fit all tabs
As i can't test this easily, my guess is that the wxGrid* sizers are at fault. Can you make a test with just a wxBoxSizer and the notebook, nothing else?
Use the source, Luke!
Re: wxNotebook: Set size of window to fit all tabs
Sorry for the late answer. I removed the wxGridSizer, no difference. I tested on wxGTK and wxMSW, the same issue. Any idea?
I'll try to make an minimal example to show the problem.
I'll try to make an minimal example to show the problem.