Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Changing the Ribbon Bar Font
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing the Ribbon Bar Font

 Post Reply Post Reply
Author
Message
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Topic: Changing the Ribbon Bar Font
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.