c++c++11tabswxwidgetswxnotebook

How to Center Tabs of wxNotebook in wxWidgets


Hi am using wxWidgets and want to center the tabs in wxNotebook. The default position of the tab buttons are left(screenshot attached). That is they are aligned to the left of the window. How can I make the tab buttons to be at the center of the screen? In the screenshot two tab buttons/controls are shown which are aligned to the left. I have tried doing it by setting the style as wxBM_RIGHT in the wxNotebook constructor but that makes the tab go to the right side. There is no wxNB_CENTER, so how can I make the tabs stick to the middle of the screen? That is the tabs should be center/middle aligned. The sample code is as follows:

MyFrame::MyFrame(const wxString &title): wxFrame(NULL, wxID_ANY, title,wxDefaultPosition, wxSize(600,600))
{
wxPanel *mainPanel = new wxPanel(this, wxID_ANY);
wxNotebook *mainNotebook = new wxNotebook(mainPanel, wxID_ANY, wxDefaultPosition, wxSize(200,200),wxNB_RIGHT);/*i want tabs to be centered*/

wxPanel *tab1Panel = new wxPanel(mainNotebook, wxID_ANY);
wxPanel *tab2Panel = new wxPanel(mainNotebook, wxID_ANY);
mainNotebook->AddPage(tab1Panel, "Tab1", true, wxID_ANY);
mainNotebook->AddPage(tab2Panel, "Tab2", false, wxID_ANY);
}

My 2nd question is that is there a way to give the tabs some margins? Like the tabs should be some distance away from the top of the window.

Left aligned tabs


Solution

  • @JasonLiam,

    The answer to both questions is: You can't.

    Centering tabs in wxNotebook is supported and is done by default on OSX only.

    You can try to add a hidden tab, but I doubt it will help with the second problem.

    HTH!