Discussion:
Sizing a wxNotebook and its pages
Tim Burgess
2014-07-12 12:09:08 UTC
Permalink
Hi,

I'm using a wxNotebook to create a multi-tab control as the primary
component of my application's UI. I have a frame that contains a menu bar, a
panel containing the notebook and a status bar. The menu bar and status bar
are visible on the display, whilst the notebook control seems to occupy a
tiny window in the upper left of my frame, with the page titles not visible
(this is based on my wife's observations, as I'm blind). Using left/right
arrows or Ctrl+Tab/Ctrl+Shift+Tab moves between the pages of the dialog,
even though the page titles are not visible (I can tell this by use of my
screen-reading software, together with setting break points in an event
handler for the page change). Selecting a given page then using Tab to try
to move through its controls yields no speech output, so the sub-controls
aren't visible, even to the screen-reader. The code in the constructor of my
frame is:

myFrame::myFrame()
{
// Set up data structures and the menu system
...

// Set up the multi-tab notebook
wxPanel * pPanel = new wxPanel( this);
wxBoxSizer * vSizer = new wxBoxSizer(wxVERTICAL);
pPanel->SetSizer( vSizer);
pPanel->Layout();

pNotebook = new wxNotebook( pPanel, ID_NOTEBOOK, wxDefaultPosition,
wxDefaultSize, 0);

// The first page is an instance of a class derived from wxPanel - the PEPX
reference is data with no UI significance
// Initially, this first page was set up as for the others - the derived
class was an experiment to see if it helped solve this issue
pSetLibraryPage = new SetLibraryPage( pNotebook, pEPX);
pPatchExchangePage = new wxNotebookPage();
pEWIPatchSetPage = new wxNotebookPage();
pCurrentPatchPage = new wxNotebookPage();
pKeyPatchesPage = new wxNotebookPage();

pNotebook->AddPage( pSetLibraryPage, wstrSetLibraryPageTitle, true);
pNotebook->AddPage( pPatchExchangePage, wstrPatchExchangePageTitle, false);

pNotebook->AddPage( pEWIPatchSetPage, wstrEWIPatchSetPageTitle, false);
pNotebook->AddPage( pCurrentPatchPage, wstrCurrentPatchPageTitle, false);
pNotebook->AddPage( pKeyPatchesPage, wstrKeyPatchesPageTitle, false);
vSizer->Insert(0, pNotebook, wxSizerFlags( 5).Expand().Border());
vSizer->Show(pNotebook);

// Set up the status bar
...
}

Can anybody help me spot where I'm going wrong, please?

Best wishes.
Tim Burgess
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Eric Jensen
2014-07-12 12:50:11 UTC
Permalink
Hello Tim,

Saturday, July 12, 2014, 2:09:08 PM, you wrote:

TB> Hi,

TB> I'm using a wxNotebook to create a multi-tab control as the primary
TB> component of my application's UI. I have a frame that contains a menu bar, a
TB> panel containing the notebook and a status bar. The menu bar and status bar
TB> are visible on the display, whilst the notebook control seems to occupy a
TB> tiny window in the upper left of my frame, with the page titles not visible
TB> (this is based on my wife's observations, as I'm blind). Using left/right
TB> arrows or Ctrl+Tab/Ctrl+Shift+Tab moves between the pages of the dialog,
TB> even though the page titles are not visible (I can tell this by use of my
TB> screen-reading software, together with setting break points in an event
TB> handler for the page change). Selecting a given page then using Tab to try
TB> to move through its controls yields no speech output, so the sub-controls
TB> aren't visible, even to the screen-reader. The code in the constructor of my
TB> frame is:

TB> myFrame::myFrame()
TB> {
TB> // Set up data structures and the menu system
TB> ...

TB> // Set up the multi-tab notebook
TB> wxPanel * pPanel = new wxPanel( this);
TB> wxBoxSizer * vSizer = new wxBoxSizer(wxVERTICAL);
pPanel->>SetSizer( vSizer);
pPanel->>Layout();

TB> pNotebook = new wxNotebook( pPanel, ID_NOTEBOOK, wxDefaultPosition,
TB> wxDefaultSize, 0);

TB> // The first page is an instance of a class derived from wxPanel - the PEPX
TB> reference is data with no UI significance
TB> // Initially, this first page was set up as for the others - the derived
TB> class was an experiment to see if it helped solve this issue
TB> pSetLibraryPage = new SetLibraryPage( pNotebook, pEPX);
TB> pPatchExchangePage = new wxNotebookPage();
TB> pEWIPatchSetPage = new wxNotebookPage();
TB> pCurrentPatchPage = new wxNotebookPage();
TB> pKeyPatchesPage = new wxNotebookPage();

pNotebook->>AddPage( pSetLibraryPage, wstrSetLibraryPageTitle, true);
pNotebook->>AddPage( pPatchExchangePage,
pNotebook->>wstrPatchExchangePageTitle, false);

pNotebook->>AddPage( pEWIPatchSetPage,
pNotebook->>wstrEWIPatchSetPageTitle, false);
pNotebook->>AddPage( pCurrentPatchPage,
pNotebook->>wstrCurrentPatchPageTitle, false);
pNotebook->>AddPage( pKeyPatchesPage, wstrKeyPatchesPageTitle, false);
vSizer->>Insert(0, pNotebook, wxSizerFlags( 5).Expand().Border());
vSizer->>Show(pNotebook);

I pasted your code into the "minimal" sample and it worked as
expected.

But i had to change lines like:
pPatchExchangePage = new wxNotebookPage();

to
pPatchExchangePage = new wxPanel(pNotebook);

I don't know if this was also an error in your code, or if it was only
for demonstration purposes, but the notebook pages must have the
notebook as parent. Otherwise you should get an Assert at runtime.

The sizer code looks ok and it worked for me under Windows.

Regards,
Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Tim Burgess
2014-07-12 15:20:12 UTC
Permalink
Hi,

Many thanks for this - it helped me make some progress. I wasn't getting the
assert, but I changed the references anyway. My first test commented out my
custom page class and just called new wxPanel( pNotebook), so that all the
pages were default wxPanel instances. This made the page titles visible to
me in the UI when using my screen-reader's review mode (they were invisible
previously).

I pass a pointer to the parent notebook to the constructor of my custom page
class, but have just realised the obvious - I needed the following line in
the constructor of my custom page class:

SetLibraryPage::SetLibraryPage( wxBookCtrlBase *parent, patchExchange *
pEPX)
{
this->SetParent( parent);
...
}

I now feel appropriately dumb:)

However, I still can't see the controls within the page using my
screen-reader's review mode and tabbing around the page doesn't appear to do
anything. There's nothing special within the SetLibraryPage UI - the
constructor sets up the UI elements as follows:

...
wxBoxSizer * hSizer1 = new wxBoxSizer( wxHORIZONTAL);
wxStaticText * lblPatchSet = new wxStaticText(this, wxID_ANY,
wstrPatchSetPrompt);
lstPatchSet = new wxListBox( this, ID_LIBRARIES_LIST_BOX, wxDefaultPosition,
wxSize( wxDefaultSize)); // , 0, wxstrChoices, wxLB_SORT);
wxStaticText * lblSetContents = new wxStaticText(this, wxID_ANY,
wstrSetContentsPrompt);
lstSetContents = new wxListBox( this, ID_LIBRARIES_LIST_BOX,
wxDefaultPosition, wxSize( wxDefaultSize)); // , 0, wxstrChoices,
wxLB_SORT);
wxStaticText * lblClipboard = new wxStaticText(this, wxID_ANY,
wstrClipboardPrompt);
lstClipboard = new wxListBox( this, ID_LIBRARIES_LIST_BOX,
wxDefaultPosition, wxSize( wxDefaultSize));
hSizer1->Add( lblPatchSet, 0, wxEXPAND);
hSizer1->Add( lstPatchSet, 0, wxEXPAND);
hSizer1->Add( lblSetContents, 0, wxEXPAND);
hSizer1->Add( lstSetContents, 0, wxEXPAND);
hSizer1->Add( lblClipboard, 0, wxEXPAND);
hSizer1->Add( lstClipboard, 0, wxEXPAND);

wxBoxSizer * hButtonSizer = new wxBoxSizer( wxHORIZONTAL);
wxbtnSendLibraryToEWI = new wxButton(this, ID_SEND_TO_EWI,
wstrSendToEWIButtonName, wxDefaultPosition, wxSize( wxDefaultSize));
wxbtnDeletePatchSet = new wxButton(this, ID_DELETE, wstrDeleteSetButtonName,
wxDefaultPosition, wxSize( wxDefaultSize));
hButtonSizer->Add( wxbtnSendLibraryToEWI, 0, wxEXPAND);
hButtonSizer->Add( wxbtnDeletePatchSet, 0, wxEXPAND);

wxBoxSizer * vBox = new wxBoxSizer( wxVERTICAL);
vBox->Add( hSizer1, 0, wxEXPAND);
vBox->Add( hButtonSizer, 0, wxEXPAND);
this->SetSizer( vBox);this->SetSizer( vBox);
...

Best wishes.

Tim Burgess

-----Original Message-----
From: wx-***@googlegroups.com [mailto:wx-***@googlegroups.com] On Behalf
Of Eric Jensen
Sent: 12 July 2014 13:50
To: Tim Burgess
Subject: Re: Sizing a wxNotebook and its pages

Hello Tim,

Saturday, July 12, 2014, 2:09:08 PM, you wrote:

TB> Hi,

TB> I'm using a wxNotebook to create a multi-tab control as the primary
TB> component of my application's UI. I have a frame that contains a
TB> menu bar, a panel containing the notebook and a status bar. The menu
TB> bar and status bar are visible on the display, whilst the notebook
TB> control seems to occupy a tiny window in the upper left of my frame,
TB> with the page titles not visible (this is based on my wife's
TB> observations, as I'm blind). Using left/right arrows or
TB> Ctrl+Tab/Ctrl+Shift+Tab moves between the pages of the dialog, even
TB> though the page titles are not visible (I can tell this by use of my
TB> screen-reading software, together with setting break points in an
TB> event handler for the page change). Selecting a given page then
TB> using Tab to try to move through its controls yields no speech
TB> output, so the sub-controls aren't visible, even to the screen-reader.
The code in the constructor of my frame is:

TB> myFrame::myFrame()
TB> {
TB> // Set up data structures and the menu system ...

TB> // Set up the multi-tab notebook
TB> wxPanel * pPanel = new wxPanel( this);
TB> wxBoxSizer * vSizer = new wxBoxSizer(wxVERTICAL);
pPanel->>SetSizer( vSizer);
pPanel->>Layout();

TB> pNotebook = new wxNotebook( pPanel, ID_NOTEBOOK, wxDefaultPosition,
TB> wxDefaultSize, 0);

TB> // The first page is an instance of a class derived from wxPanel -
TB> the PEPX reference is data with no UI significance // Initially,
TB> this first page was set up as for the others - the derived class was
TB> an experiment to see if it helped solve this issue
TB> pSetLibraryPage = new SetLibraryPage( pNotebook, pEPX);
TB> pPatchExchangePage = new wxNotebookPage(); pEWIPatchSetPage = new
TB> wxNotebookPage();
TB> pCurrentPatchPage = new wxNotebookPage(); pKeyPatchesPage = new
TB> wxNotebookPage();

pNotebook->>AddPage( pSetLibraryPage, wstrSetLibraryPageTitle, true);
pNotebook->>AddPage( pPatchExchangePage, wstrPatchExchangePageTitle,
pNotebook->>false);

pNotebook->>AddPage( pEWIPatchSetPage,
pNotebook->>wstrEWIPatchSetPageTitle, false);
pNotebook->>AddPage( pCurrentPatchPage,
pNotebook->>wstrCurrentPatchPageTitle, false); AddPage( pKeyPatchesPage,
pNotebook->>wstrKeyPatchesPageTitle, false);
vSizer->>Insert(0, pNotebook, wxSizerFlags( 5).Expand().Border());
vSizer->>Show(pNotebook);

I pasted your code into the "minimal" sample and it worked as expected.

But i had to change lines like:
pPatchExchangePage = new wxNotebookPage();

to
pPatchExchangePage = new wxPanel(pNotebook);

I don't know if this was also an error in your code, or if it was only for
demonstration purposes, but the notebook pages must have the notebook as
parent. Otherwise you should get an Assert at runtime.

The sizer code looks ok and it worked for me under Windows.

Regards,
Eric


--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Eric Jensen
2014-07-12 15:28:00 UTC
Permalink
Hello Tim,

Saturday, July 12, 2014, 5:20:12 PM, you wrote:

TB> Hi,

TB> Many thanks for this - it helped me make some progress. I wasn't getting the
TB> assert, but I changed the references anyway. My first test commented out my
TB> custom page class and just called new wxPanel( pNotebook), so that all the
TB> pages were default wxPanel instances. This made the page titles visible to
TB> me in the UI when using my screen-reader's review mode (they were invisible
TB> previously).

TB> I pass a pointer to the parent notebook to the constructor of my custom page
TB> class, but have just realised the obvious - I needed the following line in
TB> the constructor of my custom page class:

TB> SetLibraryPage::SetLibraryPage( wxBookCtrlBase *parent, patchExchange *
TB> pEPX)
TB> {
this->>SetParent( parent);
TB> ...
TB> }

TB> I now feel appropriately dumb:)

TB> However, I still can't see the controls within the page using my
TB> screen-reader's review mode and tabbing around the page doesn't appear to do
TB> anything. There's nothing special within the SetLibraryPage UI - the
TB> constructor sets up the UI elements as follows:

It's a little suspicious that you needed this line:
this->SetParent( parent);

This probably means that you're not calling the base constructor so
that the window is not properly created.

Regards,
Eric
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Tim Burgess
2014-07-12 15:42:06 UTC
Permalink
OK,

I really should have gone to bed earlier last night, then I might not have
deserved the ridicule now due. Of course, you're absolutely right:

SetLibraryPage::SetLibraryPage( wxBookCtrlBase *parent, patchExchange *
pEPX)
:wxPanel( parent)
{
...
}

Removes the need to set the parent and all of my controls now appear.

Thanks again for being so understanding and helpful.

Best wishes.
Tim Burgess


-----Original Message-----
From: wx-***@googlegroups.com [mailto:wx-***@googlegroups.com] On Behalf
Of Eric Jensen
Sent: 12 July 2014 16:28
To: Tim Burgess
Subject: Re[2]: Sizing a wxNotebook and its pages

Hello Tim,

Saturday, July 12, 2014, 5:20:12 PM, you wrote:

TB> Hi,

TB> Many thanks for this - it helped me make some progress. I wasn't
TB> getting the assert, but I changed the references anyway. My first
TB> test commented out my custom page class and just called new wxPanel(
TB> pNotebook), so that all the pages were default wxPanel instances.
TB> This made the page titles visible to me in the UI when using my
TB> screen-reader's review mode (they were invisible previously).

TB> I pass a pointer to the parent notebook to the constructor of my
TB> custom page class, but have just realised the obvious - I needed the
TB> following line in the constructor of my custom page class:

TB> SetLibraryPage::SetLibraryPage( wxBookCtrlBase *parent,
TB> patchExchange *
TB> pEPX)
TB> {
this->>SetParent( parent);
TB> ...
TB> }

TB> I now feel appropriately dumb:)

TB> However, I still can't see the controls within the page using my
TB> screen-reader's review mode and tabbing around the page doesn't
TB> appear to do anything. There's nothing special within the
TB> SetLibraryPage UI - the constructor sets up the UI elements as follows:

It's a little suspicious that you needed this line:
this->SetParent( parent);

This probably means that you're not calling the base constructor so that the
window is not properly created.

Regards,
Eric


--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...