tags:

views:

240

answers:

3

This code works perfectly

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 numerous they have to be horizontally scrolled.

Using the wxNB_MULTILINE style does not work properly: the second line of tabs is obscured 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 do I use the multiline style correctly?

+1  A: 

After experimentation, I found this way:

Add one line, after all the AddPage() calls

    myNotebook->Layout();
ravenspoint
This does not work reliably
ravenspoint
+1  A: 

The problem seems to be that the panel which holds the notebook page covers the second line of tabs.

I can force the panel to move out of the way by handling the EVT_NOTEBOOK_PAGE_CHANGED event and adding this line of code

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

Ugly, but it does the job.

ravenspoint
A: 

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

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