Kirix Support Forums

wxAuiNotebook

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

wxAuiNotebook

Postby djetter on Sat Sep 13, 2008 6:11 pm

Hi,

I've been struggling for hours with the following problem:

Suppose I create a wxFrame with a wxAuiManager, and I add a wxAuiNotebook as a center pane. If I don't add any tabs, then the center pane's background will be gray (on Windows, at least). How can I override this behavior? For example, how could I paint a red background or a blue background instead of a gray background?

I've tried overriding wxFrame's paint and erase events. I've tried overriding wxAuiNotebook's paint and erase events. I've tried overriding the 'DrawBackground' method in wxAuiManager's ArtProvider. I've tried overriding the 'DrawBackground' method in wxAuiNotebook's ArtProvider. I've searched the AUI code, and I still can't figure out who is drawing this gray background when there are no tabs.

If anyone can point me in the right direction, please let me know. Thanks for your help,

-------Drew
djetter
Registered User
 
Posts: 5
Joined: Sat Oct 28, 2006 2:33 pm
Location: Albuquerque, NM

Re: wxAuiNotebook

Postby djetter on Sun Sep 14, 2008 1:09 am

Ah ha! After stumbling around, trying a dozen wrong ways to implement my desired behavior, I finally found the right way!

I noticed that wxAuiNotebook has its own wxAuiManager...I set that wxAuiManager's ArtProvider to a my own custom class, with a custom 'DrawBackground' function, and that worked like a charm!

My problem was that I tried to over-ride the 'DrawBackground' function of my wxFrame's wxAuiManager, and I also tried to over-ride the 'DrawBackground' function of wxAuiNotebook's wxAuiTabArt, but I never realized wxAuiNotebook had its own wxAuiManager until now.

By the way, for future versions of wxAui, do you guys think you could make the functions in wxAuiDefaultDockArt virtual? I know the functions in wxAuiDockArt are virtual, but if you use wxAuiDockArt as a base, then you have to implement EVERY function yourself. If you can derive from wxAuiDefaultDockArt, then you only have to implement the functions you are customizing.

Anyway, my program now works exactly the way I want it to, so I'm happy! Thanks,

-------Drew
djetter
Registered User
 
Posts: 5
Joined: Sat Oct 28, 2006 2:33 pm
Location: Albuquerque, NM

Re: wxAuiNotebook

Postby Ben on Mon Sep 15, 2008 9:23 am

By the way, for future versions of wxAui, do you guys think you could make the functions in wxAuiDefaultDockArt virtual? I know the functions in wxAuiDockArt are virtual, but if you use wxAuiDockArt as a base, then you have to implement EVERY function yourself. If you can derive from wxAuiDefaultDockArt, then you only have to implement the functions you are customizing.


They already are virtual. In C++, if the base class has a function marked 'virtual', any derived classes (and classes derived from derived classes) will automatically inherit this virtualness. This means that wxAuiDefaultDockArt's methods are already virtual.

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

Postby djetter on Mon Sep 15, 2008 10:05 pm

Ah, I didn't know that. Thanks for the info!
djetter
Registered User
 
Posts: 5
Joined: Sat Oct 28, 2006 2:33 pm
Location: Albuquerque, NM

Re: wxAuiNotebook

Postby rmikkilineni on Tue Jun 21, 2011 12:59 pm

Though this post clears the confusion about wxAuiNoteBook having its own wxAuiManager. But i still have questions, It would be really helpful if comeone can clear the doubts i have.

1) I am trying to set custom TabArt ( wxAuiMyTabArt) as an art provider for wxAuiNotebook. wxAuiMyTabArt has an overridden "DrawTab(....)" but its never getting called. Is this a known bug in wxAui??
2) Do i have to call any update or refresh after changing the art provider using wxAuiNotebook:: SetArtProvider(wxAuiTabArt * ) ...
3) Is there a particular order in which i should create the notebook and art provider?? ( silly question)

I just want to know any nuances i am missing to see the change due to overridden function .

Thanks in Advance.
Will be waiting for a reply.

Regards
Ravi
rmikkilineni
Registered User
 
Posts: 2
Joined: Tue Jun 21, 2011 12:50 pm

Re: wxAuiNotebook

Postby rmikkilineni on Wed Jun 22, 2011 10:34 am

I have been reading about this potential bug in wxAuiNotebook and problems with custom drawing the Tabs.

Problem:
One of the common problems was using a custom TabArt (wxAuiMyTabArt : public wxAuiDefaultTabArt) and the overridden drawing functions ( like DrawTab , DrawBackground() ...etc) not getting called even after setting the new artprovider using wxAuiNotebook::setArtProvider(new wxAuiMyArtProvider).

WorkAround suggested by many :
use the SetArtProvider of the wxAuiManager which wxAuiNoteBook internallly uses to set the wxAuiMyDockArt also change the wxAuiMyTabArt for wxAuiNotebook
But its still not an intutive solution,also the methods to override( in wxAuiDockArt(abstract class)) are limited if you really want to do any tab related drawing..

My Solution is :

override wxAuiDefaultTabArt::Clone() in your derived class , potentially,implement the function as

wxAuiTabArt* wxAuiMyArt::Clone()
{
wxAuiMyTabArt* art = new wxAuiMyTabArt; /// In base class this line looks like wxAuiDefaultTabArt* art = new wxAuiDefaultTabArt;
art->SetNormalFont(m_normal_font);
art->SetSelectedFont(m_selected_font);
art->SetMeasuringFont(m_measuring_font);

return art;
}

and then set this as art provider immediately after creation of the wxAuiNoteBook.

Worked for me.

Ravi
rmikkilineni
Registered User
 
Posts: 2
Joined: Tue Jun 21, 2011 12:50 pm

Return to wxAUI Questions, Thoughts & Feedback