Kirix Support Forums

wxAuiNotebook AdvanceSelection question

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

wxAuiNotebook AdvanceSelection question

Postby ghostdev85 on Thu Apr 03, 2008 8:20 pm

Hello,

The wxAuiNotebook does not reorder itself when the page is being reordered (m_tabs variable), and if I were to use the AdvanceSelection() member function, the result would be a weird jumpy tabs after user have reordered to tabs... Is there a way to fix this?

Thank you...
ghostdev85
Registered User
 
Posts: 13
Joined: Sat Jan 13, 2007 6:03 am

Re: wxAuiNotebook AdvanceSelection question

Postby Ben on Sat Apr 05, 2008 1:13 pm

Hello,

Thanks for the report. Can you paste some code to help me duplicate this problem? It would be best if you could show me how to duplicate it on the wxAUI sample.

All the best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: wxAuiNotebook AdvanceSelection question

Postby ghostdev85 on Mon Apr 07, 2008 8:17 am

Hello,

I don't think it is a bug... But here it goes...
You can't simulate it in the AUI sample yet... Just do a button or whatever you can trigger, when pressing the button (or menu, etc) call the AdvanceSelection() in the wxAuiNotebook... It works correctly initially, but after you reorder the wxAuiNotebook tabs, the AdvanceSelection() seem to use the old order to do the "advance selection"...

Thank you...
ghostdev85
Registered User
 
Posts: 13
Joined: Sat Jan 13, 2007 6:03 am

Re: wxAuiNotebook AdvanceSelection question

Postby ghostdev85 on Mon Apr 07, 2008 10:09 pm

Hello,

I've looked through the codes, and I personally think that the AdvanceSelection member function of wxAuiNotebook should be as follow...(Note the following code does not necessarily follows wxWidgets guidelines)

Am I correct?

void AdvanceSelection(bool forward = true) {
wxAuiTabCtrl *tabctrl = GetActiveTabCtrl();
int newPage = -1;

if(forward == true)
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = 0;
else if (tabctrl->GetActivePage() < (int) (tabctrl->GetPages().GetCount() - 1))
newPage = tabctrl->GetActivePage() + 1;
}
else
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = (int) ((int)tabctrl->GetPages().GetCount() - 1);
else if (tabctrl->GetActivePage() > 0)
newPage = tabctrl->GetActivePage() - 1;
}
wxMessageBox("A");
if (newPage != -1)
{
tabctrl->SetActivePage(newPage);
}
}

Thank you...
ghostdev85
Registered User
 
Posts: 13
Joined: Sat Jan 13, 2007 6:03 am

Re: wxAuiNotebook AdvanceSelection question

Postby ghostdev85 on Mon Apr 07, 2008 10:22 pm

Sorry... The code should be:
void AdvanceSelection(bool forward = true) {
wxAuiTabCtrl *tabctrl = GetActiveTabCtrl();
int newPage = -1;

if(forward == true)
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = 0;
else if (tabctrl->GetActivePage() < (int) (tabctrl->GetPages().GetCount() - 1))
newPage = tabctrl->GetActivePage() + 1;
}
else;
else
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = (int) ((int)tabctrl->GetPages().GetCount() - 1);
else if (tabctrl->GetActivePage() > 0)
newPage = tabctrl->GetActivePage() - 1;
}
if (newPage != -1)
{
tabctrl->SetActivePage(newPage);
tabctrl->Refresh();
}
}
ghostdev85
Registered User
 
Posts: 13
Joined: Sat Jan 13, 2007 6:03 am

Re: wxAuiNotebook AdvanceSelection question

Postby ghostdev85 on Mon Apr 07, 2008 10:37 pm

Sorry again...
This should be the code...

void AdvanceSelection(bool forward = true) {
wxAuiTabCtrl *tabctrl = GetActiveTabCtrl();
int newPage = -1;

if(forward == true)
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = 0;
else if (tabctrl->GetActivePage() < (int) (tabctrl->GetPages().GetCount() - 1))
newPage = tabctrl->GetActivePage() + 1;
}
else;
else
if (tabctrl->GetPages().GetCount() > 1)
{
if (tabctrl->GetActivePage() == -1)
newPage = (int) ((int)tabctrl->GetPages().GetCount() - 1);
else if (tabctrl->GetActivePage() > 0)
newPage = tabctrl->GetActivePage() - 1;
}
if (newPage != -1)
{
tabctrl->SetActivePage(newPage);
tabctrl->Refresh();
tabctrl->Update();
tabctrl->DoShowHide();
}
}

Thank you...
ghostdev85
Registered User
 
Posts: 13
Joined: Sat Jan 13, 2007 6:03 am

Return to wxAUI Questions, Thoughts & Feedback