IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
GUI_font Class Reference

Public Member Functions

 GUI_font (int height, string face, bool proportional, int _id, GUI_COLOR _color, GUI_COLOR _bgcolor, GUI_COLOR _hilightcolor=GUI_COLOR(0, 0, 0), GUI_COLOR _hilightbg=GUI_COLOR(0, 0, 0), FontStyle style=FONT_NORMAL)
 Creates a new font. More...
 
void Print (SURFHANDLE tgt, std::string &text, int _x, int _y, RECT &elementPos, bool highlight=false, GUI_TEXT_POS tpos=T_LEFT, GUI_TEXT_VERTICAL_POS vpos=V_TOP)
 Prints a string to the target surface at the desired coordinates. More...
 
int GetId ()
 
int GetfHeight ()
 
int GetfWidth ()
 
int GetTextWidth (string &text)
 

Private Member Functions

void createFont (Font *font)
 Allocates a texture surface and prerenders the font to it using a sketchpad.
 

Private Attributes

int id
 The id of this font.
 
int fheight
 height of a symbol (font size)
 
int fwidth
 average width of a symbol
 
int width
 Entire width of the texture used to prerender the font.
 
SURFHANDLE src
 source surface with the prerendered font
 
bool hasHighlightFont
 whether or not this font has a variant for highlights
 
GUI_COLOR color
 The default color of this font.
 
GUI_COLOR bgcolor
 The default background color (the color the font is drawn on, since we don't have transparency)
 
GUI_COLOR hilightcolor
 The color of this font if the text is hilighted.
 
GUI_COLOR hilightbg
 The background color to draw the hilighted font on.
 
int charpos [94]
 stores character positions in the bitmap for non-monotype fonts
 

Detailed Description

font class to handle text output

Constructor & Destructor Documentation

GUI_font::GUI_font ( int  height,
string  face,
bool  proportional,
int  _id,
GUI_COLOR  _color,
GUI_COLOR  _bgcolor,
GUI_COLOR  _hilightcolor = GUI_COLOR(0, 0, 0),
GUI_COLOR  _hilightbg = GUI_COLOR(0,0,0),
FontStyle  style = FONT_NORMAL 
)

Creates a new font.

Parameters
heightThe desired font height (size) in pixel
faceThe typeface name of the font (e.g. "Arial")
proportionalFlag for proportional/fixed pitch font (not sure what that means, it's a sketchpad option)
_ididentifier for this font
_colorThe text color of the font
_bgcolorThe color of the background the font is drawn on (as we can't do color key blitting!)
_hilightcolorAn alternate color in which the font should appear when hilighted. if not defined, no hilight font will be created
_hilightbgAn alternate background color for the highlighted font. If undefined, the normal background color will be used
stylefont decoration style (bold, italic, underlined etc)
Note
See orbiter api reference of oapiCreateFont() for more explanation on height, face, proportional and style, as these arguments will be passed unaltered to sketchpad to draw the font.
See also
FontsAndStyles

Member Function Documentation

int GUI_font::GetfHeight ( )
Returns
The text size of this font (pixel)
int GUI_font::GetfWidth ( )
inline
Returns
The AVERAGE width of a character in this font
See also
GetTextWidth()
int GUI_font::GetId ( )
Returns
The id of this font
int GUI_font::GetTextWidth ( string &  text)
Returns
The total width of the passed string when printed in this font (pixel)
See also
GetfWidth()
void GUI_font::Print ( SURFHANDLE  tgt,
std::string &  text,
int  _x,
int  _y,
RECT &  elementPos,
bool  highlight = false,
GUI_TEXT_POS  tpos = T_LEFT,
GUI_TEXT_VERTICAL_POS  vpos = V_TOP 
)

Prints a string to the target surface at the desired coordinates.

where exactly the text is printed depends on tpos and vpos.

See also
GUI_TEXT_POS
GUI_TEXT_VERTICAL_POS
Parameters
tgtThe SURFHANDLE to draw the text on
textReference to a string containing the text to be drawn
_xx coordinate relative to the target surface. Exact interpretation depends on tpos
_yy coordinate relative to the target surface Exact interpretation depends on vpos
elementPosA clipping rect. Any text falling outside of this rectangle won't be drawn.
highlightIf true, the text will be printed using the highlighted font
tposText justification. can either be T_LEFT, T_RIGHT or T_CENTER
vposVertical alignement of the text. can either be V_TOP, V_BOTTOM or V_CENTER

The documentation for this class was generated from the following files: