Text Functions



OtkWidget OtkMakeTextLabel( OtkWidget Panel, char *Text, OtkColor fontcolor, float fontscale, 
                                      int fontweight, float x, float y );

	This function places text onto a panel or window.  Returns OtkWidget handle to enable
	future alterations or eventual removal.
	Parameters:
	  Panel - The container-panel, or parent widget, on which the label is attached/placed.
                  And to whose frame the coordinates will be relative!
	  Text - The character string array to make the label of.
	  Fontcolor - An OtkColor record.  Colors can be set by OtkSetColor(r,g,b).
	  fontsize - A float scaling factor.  1.0 is normal size, with each character being 12.0% 
                high by 8.0% wide in Otk coordinates.  A value for 4.0 quadruples the text size.
	  fontweight - 1.0 is normal. 2.0 is bold (double-weight).
	  x, y - Coordinates of the origin of the label's upper left edge relative to the
		containing panel's upper left origin.



void Otk_Modify_Text( OtkWidget label, char *text ) 

	Changes the text displayed by a label to the string passed by text.



void Otk_Modify_Text_Aspect( OtkWidget label, float aspect ) 

	Changes the text-label's horizontal/vertical size ratio.
	Passing an aspect factor of 1.0 sets the character aspect ratio to the default.
	Passing a value of 0.5, reduces the label's width while increasing it's tallness.
	See also Otk_Set_Text_Aspect below, to set aspect for all future labels.



void Otk_Modify_Text_Scale( OtkWidget label, float scale ) 

	Sets or changes the size of the text-label by the scale factor.
	For example, a value 2.5 makes the label 2.5 times larger.
	A value of 0.25 reduces the label to a quarter of it's default size.



void Otk_Modify_Text_Color( OtkWidget label, OtkColor text_color ) 

	Sets or changes a text-label's color.  Color values can be specified by
	OtkSetColor(r,g,b) or to pre-defined colors.



void Otk_Modify_Text_Slant( OtkWidget label, float slant ) 

	Sets or changes text to italic or normal.
	Where, slant = 0.0 is normal (oblique), and 1.0 is italic.
	Other values can be specified by various slant effects.



void Otk_Modify_Text_Thickness( OtkWidget label, float thickness ) 

	Sets or changes the text-label's boldness.  Thickness of 1.0 is the minimum
	and the normal default value.  A value of 2.0 is double-thick, and appears
	as bold.  Other values can be used for additional emphasis.
	Note:  Thickness values that are not round numbers (ex. 1.0, 2.0, 3.0), may
	not display propererly on all video cards.



void Otk_Modify_Text_Position( OtkWidget label, float x, float y ) 

	Moves the referenced text label to the new position, (x, y), where x and y
	are percentages of the container panel's size.



void Otk_Set_Text_Aspect( float aspect )


	Sets new default aspect ratio for all future text-labels, until changed.
	This changes horizontal/vertical size ratio of new text-labels.
	An aspect factor of 1.0 sets the character aspect ratio to the default.
	A value of 0.5, reduces the label' width while increasing their tallness.
	See also Otk_Modify_Text_Aspect above, to set aspect for a specific label.



void Otk_Get_Character_Size( OtkWidget label, float *width, float *height )

	Returns the current size, of a character in the referenced text-label, in the
	second and third parameter.  The size values are in percentages of the containing
	panel's size which ranges from 0.0 to 100.0.  This function is useful fitting text
	in specific regions.  Access this function prior to re-scaling.  Otk's default
	font-set is non-proportional.  All characters have the same size.  Since the
	second and third parameter's return values, you must pass addresses.



void Otk_Get_Text_Size( OtkWidget label, float *width, float *height )

	Returns the current size, of a text-label, in the second and third parameter.
	The size values are in percentages of the containing panel's size which ranges 
	from 0.0 to 100.0.  This function is useful fitting text in specific regions.
	Access this function prior to re-scaling.  Since the second and third parameter's
	return values, you must pass addresses.

	Example usage, (forces text to fit in 30% of parent window's width):
	     {
		float w, h;

		Otk_Get_Text_Size( label1, &w, &h );
		Otk_Modify_Text_Scale( label1, 30.0/w );
	     }




void Otk_FitTextInPanel( OtkWidget label )

	Convience function that re-scales text-label to fit exactly into it's container
	panel.  Useful when a panel is created specifically to hold only a text-label.
	The text will be scaled in width and height to match the width and height of
	the panel.


  

Back to main page

SourceForge.net Logo