Aui has attached component wxAuiTabArt which draws.
How to change background or font color of title?
How to change aui tab color ?
-
- Earned some good credits
- Posts: 105
- Joined: Sun Nov 29, 2015 12:46 pm
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: How to change aui tab color ?
Hi,
Create wxAuiArtProvider-derived class and do what you want there?
Thank you.
Create wxAuiArtProvider-derived class and do what you want there?
Thank you.
-
- Earned some good credits
- Posts: 105
- Joined: Sun Nov 29, 2015 12:46 pm
Re: How to change aui tab color ?
Color should be not constants. For example: all tabs would have usual colors except tabs with modified files.
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: How to change aui tab color ?
Hi,
Like I said - create a new TabArt class and do whatever you want there.
Thank you.
Like I said - create a new TabArt class and do whatever you want there.
Thank you.
-
- Earned some good credits
- Posts: 105
- Joined: Sun Nov 29, 2015 12:46 pm
Re: How to change aui tab color ?
I have problem with virtual methods of tabArt.
I rewrite MyBaseTabArt = whole wxAuiGenericTabArt, except :
in DrawTab:
where
and
I use:
But GetFontColour was called as non-virtual, disassembly show that is jump to constant address.
I rewrite MyBaseTabArt = whole wxAuiGenericTabArt, except :
in DrawTab:
Code: Select all
wxColor font_color = GetFontColour(page.active, back_color);
Code: Select all
virtual wxColour GetFontColour(bool pageActive, const wxColour& back_color);
wxColour MyBaseTabArt::GetFontColour(bool pageActive, const wxColour& back_color) {
wxColor sys_color = wxSystemSettings::GetColour(
pageActive ? wxSYS_COLOUR_CAPTIONTEXT : wxSYS_COLOUR_INACTIVECAPTIONTEXT);
wxColor font_color = wxAuiHasSufficientContrast(back_color, sys_color) ? sys_color
: wxAuiGetBetterContrastColour(back_color, *wxWHITE, *wxBLACK);
return font_color;
}
Code: Select all
class MyTabArt: public MyBaseTabArt {
public:
virtual wxColour GetFontColour(bool pageActive, const wxColour& back_color) wxOVERRIDE;
};
wxColour MyTabArt::GetFontColour(bool pageActive, const wxColour& back_color) {
return wxColour(255,50,50);
}
Code: Select all
wxAuiTabArt *art = new MyTabArt;
auiNotebook->SetArtProvider(art);
-
- Moderator
- Posts: 19163
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: How to change aui tab color ?
There is no method called GetFontColour() in wxAuiTabArt.
Use the source, Luke!
-
- Earned some good credits
- Posts: 105
- Joined: Sun Nov 29, 2015 12:46 pm
Re: How to change aui tab color ?
This method is in my art class: MyBaseTabArt
-
- Moderator
- Posts: 19163
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: How to change aui tab color ?
How is that supposed to work? AUIs internal drawing routines only know about and use the methods from wxAuiTabArt. By subclassing wxAuiTabArt and overwriting one or more of its virtual methods, you can change what is drawn. Adding a new, unknown method will not change anything. How is the present code about to know that it needs to call your method to get the font color?
Anyway, after looking into the implementation of wxAuiGenericTabArt::DrawTab, i don't think it's possible to change the font color easily.
Code: Select all
wxColor sys_color = wxSystemSettings::GetColour(
page.active ? wxSYS_COLOUR_CAPTIONTEXT : wxSYS_COLOUR_INACTIVECAPTIONTEXT);
wxColor font_color = wxAuiHasSufficientContrast(back_color, sys_color) ? sys_color
: wxAuiGetBetterContrastColour(back_color, *wxWHITE, *wxBLACK);
dc.SetTextForeground(font_color);
dc.DrawText(draw_text,
text_offset,
drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1);
Your only option would be to re-implement the whole method. (You could of course copy the whole code into MyBaseTabArt and just make changes to the font color in the above code part).
Use the source, Luke!
-
- Earned some good credits
- Posts: 105
- Joined: Sun Nov 29, 2015 12:46 pm
Re: How to change aui tab color ?
I copy whole wxAuiGenericTabArt to my class and change my class.
Was problem with polymorphic.
Problem is solved:
was
Must be added necessary Clone in subclass!
Notabene: for good clone handling is needed metaclasses.
Was problem with polymorphic.
Problem is solved:
was
Code: Select all
wxAuiTabArt* MyBaseTabArt::Clone() {
return new MyBaseTabArt(*this);
}
Code: Select all
wxAuiTabArt *MyTabArt::Clone() {
return new MyTabArt(*this);
}