Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Putting Symbol font in Ccontrols button

Putting Symbol font in Ccontrols button

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Velvis on Thu Feb 01, 2001 6:42 pm

I would like to use a symbol from the PalmOS symbol font in a Ccontrols text button. Does anyone know how to do this?

Thanks
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby stephane on Fri Feb 02, 2001 2:00 am

Hi there.

Whatever your solution, you will have to modify the Ccontrols library, because the font is hardcoded in all of its text drawing functions.

In the case of text buttons, the function you are looking for is <b>Cdb()</b>, in <b>Ccontrols1.c</b>. The "simple" way of getting what you want is to cut and paste this function, and rename it, eg: CdbSymbol(). Change the textattr() in this new function to be textattr(3,1,0), for symbol, and call CdbSymbol( handle ) instead of Cdraw() in your code. You would need one function for each font you use, in this case.

Another way to go about it, is to delve a little deeper into Ccontrols, and modify the Cbutton() function, to define another parameter which would specify the font, then modify Cdb() to use that parameter as a variable in the textattr() call.

For a one shot deal, I think the first solution is quick and easy. If you want to modify your library for general re-use in later projects, try the second.

Cheers, hth,



St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby stephane on Fri Feb 02, 2001 3:58 am

Here's yet another way, that will be compatible with existing code because no extra parameters are added. What I've done is code the Cdb() function so that it looks for an "escape" sequence of "/f<i>n</i>" at the beginning of a string. This will tell Ccontrols to use font <i>n</i> when printing text for the text and switch buttons. Note that I had to fudge a bit for the LED font, and if you do use that font, the minimum height of the button should be 19 pixels. 'Nuff said, here's the code, "pretty" format from the PDE, cut it down if you're coding on the handheld.

<pre id=code><font face=courier size=2 id=code>
Cdb(pointer p) { // draw button
int c;
string s; // DST - 01/02/2001
int n, y; // DST - 01/02/2001

if (p[0]>0)
c=p[6]; // use defined frame if activated
else
c=2; // grey frame if de-activated
rect(0, p[1], p[2], p[1]+p[3], p[2]+p[4], p[7]);
frame(c, p[1], p[2], p[1]+p[3], p[2]+p[4], p[7]);
if(p[0]==2) // image button
bitmap( p[1], p[2], *p[5] );
else { // text buttons
// DST - start - 01/02/2001
s = *p[5];
n = 0;
y = p[2] + (p[4]/2)-2;
if( strleft( s, 2 ) == "/f" ) { // look for the font escape sequence
n = substr( s, 2, 1 ); // get the font number..
s = strright( s, strlen(s)-3 ); } // ..and rest of the string
if( n==6 ) // special case for LED font
// make sure height is >= 19 when coding button
y = p[2] + (p[4]/2) - 9;
//textattr(0,1,0);
textattr( n, 1, 0);
// DST - end - 01/02/2001
textalign(11);
//text( p[1] + (p[3]/2), p[2] + (p[4]/2)-2, *p[5] ); // DST - 01/02/2001
text( p[1] + (p[3]/2), y, s ); // DST - 01/02/2001
textattr(0,1,0); // DST - 01/02/2001
textalign(0); }
if(p[0]==3)
if(p[ 8 ])
Cib(p);
}
</font id=code></pre id=code>

Lines marked <b>DST</b> are my additions to the Ccontrols baseline, other comments are my own based on my understanding of the code.

Cheers,


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby Velvis on Fri Feb 02, 2001 5:09 pm

I havent tried it yet,but thanks alot. I was wondering if the line:

text( p[1] + (p[3]/2),p[2]+(p[4]/2)-2, *p[5] );

near the end after textalign(11); was supposed to be commented out.

Thanks again.
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby stephane on Fri Feb 02, 2001 5:20 pm

Yes, it is in fact commented out, the line below it is the updated version of the same line. Just the way I keep track of code changes.

Cheers,


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby Velvis on Fri Feb 02, 2001 5:31 pm

Ok I compiled it, but I am having trouble getting it to display the proper character.

I have called Csetcontent with "/f4002" & "/f42" (4 being the Symbol11 font and 002 or 2 being the left arrow character as listed from the kisfonts program.
But on the display I just get the "empty box" character.

Any ideas?

Thanks
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby Velvis on Fri Feb 02, 2001 5:38 pm

I figured it out... You must use "/f5"+(char)005)

Thanks!
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby Velvis on Fri Feb 02, 2001 5:57 pm

Do you have any ideas on how to make the symbol inside the button centered?
I used the following
"/f4"+(char)002);

which works but the arrow is not centered in the button.
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby stephane on Sat Feb 03, 2001 11:44 pm

Yes, you can use: "/f4"+(char)002);
You can also do it this way: "/f4\x02" using the hex character value.

As to the symbol text not being centered, I suspect that you mean it is not centered vertically, although horizontally it is fine. I believe this is because of the font not being a "standard" text font size, much the same case as the LED font. So what needs to be done, if this is the case, is to add more conditions along the lines of the 'if (n==6) etc..' in my original code, where you need to calculate a different vertical offset depending on the font you're dealing with.

I'm trying to streamline this routine a bit, adding the changes mentionned above, but it may be a few days before I can post any code.

hth,


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 1 guest

cron