Print Page | Close Window

Changing the Ribbon Bar Font

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=9161
Printed Date: 25 June 2024 at 6:42pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing the Ribbon Bar Font
Posted By: mrmathis
Subject: Changing the Ribbon Bar Font
Date 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



Replies:
Posted By: Oleg
Date Posted: 21 December 2007 at 1:02am
Hi,
 
try
 
CXTPRibbonPaintManager* pPaintManager = (CXTPRibbonPaintManager*)pRibbonBar->GetPaintManager()){
 
pPaintManager->m_fontGroupCaption.SetCustomFont(...);
pPaintManager->GetTabPaintManager()->SetFontIndirect(..);
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: mrmathis
Date Posted: 21 December 2007 at 10:48am
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


Posted By: mrmathis
Date Posted: 21 December 2007 at 5:19pm
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


Posted By: mrmathis
Date Posted: 25 April 2008 at 10:19am
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


Posted By: mrmathis
Date Posted: 11 December 2008 at 5:40pm
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


Posted By: Oleg
Date Posted: 12 December 2008 at 1:12am
Hi,
 
Yes, sorry CXTPRibbonPaintTheme and CXTPRibbonPaintMaanger are different classes now.
 
Please change to
 
pPaintManager->GetRibbonPaintManager()->GetTabPaintManager()->SetFontIndirect


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: mrmathis
Date Posted: 12 December 2008 at 8:39am
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


Posted By: Oleg
Date Posted: 12 December 2008 at 2:04pm
Hi,
Sorry - our thing. Will be added to Source\Ribbon\Includes.h


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net