IPB SourceForge.net Logo

Welcome Guest ( Log In | Register )

[ Outline ] · Standard · Linear+

> Unicode IPA Extensions Problem, Need Help with GUI SetFont

Dizasta
post Dec 17 2006, 09:04 PM
Post #1


Advanced Member
***

Group: Members
Posts: 35
Joined: 20-October 06
Member No.: 472



Hi guys,

I am stumped at this point because I have been unable to get my GUI to display text in menu items correctly: to be precise, characters in the IPA extension show up as squares. Characters from the Phonetic Extensions show up though.

It is most likely because the DefaultMenuItem object resorts to using the default Windows GUI font for menu items. I know this because when I go to the control panel -> appearance and edit the menu items to use Arial Unicode MS, the characters are correctly displayed. For anyone who wants to check, here'e one character in the IPA Extension that shows up as squares is: U+025B (The Latin Small Letter Open E) and U+0254 (Latin Small Letter Open O).

Any ideas/code examples about how to proceed will be greatly appreciated. Thanks.

D.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
 
Reply to this topicStart new topicStart Poll
Replies
Dizasta
post Dec 24 2006, 07:47 PM
Post #2


Advanced Member
***

Group: Members
Posts: 35
Joined: 20-October 06
Member No.: 472



Thanks for the tip. I tried to subclass the DefaultMenuItem but for some reason, my overrides canPaint() and paint() are not being called.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
vortic
post Dec 30 2006, 07:11 PM
Post #3


Advanced Member
***

Group: Members
Posts: 1026
Joined: 13-April 04
Member No.: 42



QUOTE(Dizasta @ Dec 24 2006, 02:47 PM)
Thanks for the tip. I tried to subclass the DefaultMenuItem but for some reason, my overrides canPaint() and paint() are not being called.
*



Dizasta,

Sorry for taking so long to get back to you.

Hmmm. I just tried something real quick in the dev svn, and it seems to work. Are you using 0.9.0 release or current svn checkout?

Using the FrameStyles example as a test to modify it, I put this in FrameStyles.cpp:

CODE
class MyCustomMenuItem : public DefaultMenuItem {
public:

MyCustomMenuItem() {
}

MyCustomMenuItem(const String& caption, MenuItem* parent=NULL, Menu* menuOwner=NULL)
 : DefaultMenuItem(caption, parent, menuOwner) {

}

virtual ~MyCustomMenuItem(){}

virtual void paint( GraphicsContext* ctx, Rect* paintRect ) {
 //DefaultMenuItem::paint(ctx, paintRect);//not needed  
 bounds_ = *paintRect;

 int gcs = ctx->saveState();
 
 BasicFill   fill;  
 
 
 fill.setColor(   Color::getColor("orange") );  

 ctx->setCurrentFill( &fill );    

 Rect bounds = *paintRect;
 
 BezierCurve rect;
 rect.rectangle( bounds );
 ctx->draw( &rect );  

 bounds.inflate(-12,0,0,0);  

 //set your custom font here
 Font myFont;  
 myFont.setName("Arial Unicode MS");//maker sure this font is available.  
 myFont.setBold(true);
 myFont.setColor( Color::getColor("blue") );

 ctx->setCurrentFont(&myFont);

 ctx->textBoundedBy( &bounds, caption_, GraphicsContext::tdoCenterVertAlign );  

 ctx->setCurrentFill( NULL );

 ctx->restoreState(gcs);
 
}

};


Then, in FrameStyles.cpp where the menu is being constructed, I changed this:
CODE
MenuItem* frameStyle = new DefaultMenuItem( "Set Frame Style to", main, menu );


to this:
CODE

 MenuItem* frameStyle = new MyCustomMenuItem( "Set Frame Style to", main, menu );
 frameStyle->setCanPaint( true );


And this works ok. Does it work for you?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicTopic OptionsStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
 

Lo-fi Version : 18th May 2013 - 01:31 PM