WxWidget multi-line notebook - no 2nd line visible

This code works fine

myNotebook = new wxNotebook( this, IDC_NOTEBOOK, wxDefaultPosition, wxSize(500, 500) );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 1" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 2" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 3" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 4" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 5" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 6" );

      

However, the tab names are so long and plentiful that they need to be scrolled horizontally.

Using wxNB_MULTILINE style does not work as expected: second row of tabs is hidden and unreadable

myNotebook = new wxNotebook( this, IDC_NOTEBOOK, wxDefaultPosition, wxSize(500, 500), wxNB_MULTILINE );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 1" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 2" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 3" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 4" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 5" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 6" );

      

How to use multi-line style correctly?

+1


source to share


3 answers


Finally, an elegant solution was found. I need to force refresh after resizing.



void MyFrame::OnSize(wxSizeEvent& )
{
    if( myNotebook ) {
        myNotebook->SetSize( GetClientRect() );
        myNotebook->Refresh();
    }
}

      

0


source


After experimenting, I found this way:

Add one line after all AddPage () calls



    myNotebook->Layout();

      

+1


source


The problem is that the pane containing the notebook page is covering the second row of tabs.

I can get the panel to go out of the way by handling the event EVT_NOTEBOOK_PAGE_CHANGED

and adding this line of code

myNotebook->GetPage( event.GetSelection() )->Move(0,40);

      

Ugly, but it gets the job done.

+1


source







All Articles