Changing the Ribbon Bar Font |
Post Reply |
Author | |
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
Posted: 20 December 2007 at 5:56pm |
I'm trying to change the ribbon bar font and only getting partially there. Here's a screenshot of what I have so far with the font changed to wingdings to make the changes stand out:
The text on the buttons is updating, but the tab and group text does not do so. Here is how I got this far.
if (CFont* pFontToUse = rbfd.GetFont()) {
LOGFONT lfToUse = {0}; if (int nRC = pFontToUse->GetLogFont(&lfToUse)){ if (CXTPPaintManager* pPaintManager = pRibbonBar->GetPaintManager()){ pPaintManager->SetCommandBarsFontIndirect(&lfToUse); //pPaintManager->UpdateFonts(); doesn't seem necessary Any suggestions on getting the rest of the way? Thanks!
|
|
--Mike
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
try
CXTPRibbonPaintManager* pPaintManager = (CXTPRibbonPaintManager*)pRibbonBar->GetPaintManager()){
pPaintManager->m_fontGroupCaption.SetCustomFont(...);
pPaintManager->GetTabPaintManager()->SetFontIndirect(..);
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
I am assuming that you mean CXTPRibbonTheme rather than CXTPRibbonPaintManager. The call to m_fontGroupCaption.SetCustomFont seems to work fine. The call to GetTabPaintManager()->SetFontIndirect does work on the tab text, but it seems to have a bad side effect. It causes the text on the buttons and groups to rotate 90 degrees clockwise. Here are snapshots with and without that call:
Any further suggestions?
|
|
--Mike
|
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
Ah, I figured out what was going on. The SetFontIndirect call actually overwrites data in the LOGFONT structure that I pass in while it is fiddling with its internally held vertical font. When I pass that along to the next guy, it causes the text to rotate.
While I consider this a corruption of my data, and a little bit rude, I have worked around this by just making three copies of the LOGFONT and passing a unique one to each API.
|
|
--Mike
|
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
One last followup for posterity. I was having trouble with characters getting clipped until I added a call to pPaintManager->RefreshMetrics(); after the call to pPaintManager->SetCommandBarsFontIndirect(). That is, the tails on characters like y or g were getting clipped when I had multiline text on large buttons, and the tops of some Japanese characters were getting clipped in that locale.
|
|
--Mike
|
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
I just upgraded from 12.0.1 to 12.1.1, and the code generated from this thread won't compile:
LOGFONT lfDialogFont = ...
// The Codejock calls below to change the font will alter the font structure
// passed to them, so make a fresh copy of the font data for each call. LOGFONT lfTab = lfDialogFont; LOGFONT lfGroup = lfDialogFont; LOGFONT lfButtons = lfDialogFont; // tab captions (per Oleg)
pPaintManager->GetTabPaintManager()->SetFontIndirect(&lfTab); // group captions (per Oleg)
pPaintManager->m_fontGroupCaption.SetCustomFont(&lfGroup); // ribbon text (buttons, QAT, etc)
pPaintManager->SetCommandBarsFontIndirect(&lfButtons); // tell Codejock about the changes [PR5917116]
pPaintManager->RefreshMetrics(); I get these errors:
ribbon.cpp(2553) : error C2039: 'GetTabPaintManager' : is not a member of 'CXTPRibbonTheme'
source\ribbon\xtpribbontheme.h(47) : see declaration of 'CXTPRibbonTheme' ribbon.cpp(2553) : error C2227: left of '->SetFontIndirect' must point to class/struct/union/generic type ribbon.cpp(2556) : error C2039: 'm_fontGroupCaption' : is not a member of 'CXTPRibbonTheme' source\ribbon\xtpribbontheme.h(47) : see declaration of 'CXTPRibbonTheme' ribbon.cpp(2556) : error C2228: left of '.SetCustomFont' must have class/struct/union ribbon.cpp(11375) : error C2039: 'GetTabPaintManager' : is not a member of 'CXTPRibbonTheme' source\ribbon\xtpribbontheme.h(47) : see declaration of 'CXTPRibbonTheme' ribbon.cpp(11375) : error C2227: left of '->GetFont' must point to class/struct/union/generic type ribbon.cpp(11390) : error C2039: 'm_fontGroupCaption' : is not a member of 'CXTPRibbonTheme' source\ribbon\xtpribbontheme.h(47) : see declaration of 'CXTPRibbonTheme' ribbon.cpp(11390) : error C2228: left of '.SetCustomFont' must have class/struct/union What's up with that? Is there some other way to change the fonts now?
|
|
--Mike
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Yes, sorry CXTPRibbonPaintTheme and CXTPRibbonPaintMaanger are different classes now.
Please change to
pPaintManager->GetRibbonPaintManager()->GetTabPaintManager()->SetFontIndirect
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
OK, thanks, that works. One note, though: I normally only include Source\XTToolkitPro.h, but doing that only got me a forward declaration of CXTPRibbonPaintManager. I had to include Ribbon\XTPRibbonPaintManager.h to get the full declaration I needed to access members of the class. Is that to be expected? Is this a public class?
|
|
--Mike
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Sorry - our thing. Will be added to Source\Ribbon\Includes.h
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |