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

Singleton that manages fonts and styles. More...

Public Member Functions

GUI_fontGetFont (GUI_FONT fontid=GUI_SMALL_DEFAULT_FONT, string styleset="default")
 
GUI_ElementStyleGetStyle (GUI_STYLE styleId=STYLE_DEFAULT, string styleset="default")
 

Static Public Member Functions

static FontsAndStylesGetInstance ()
 
static void DestroyInstance ()
 Destroys the instance of the singleton. More...
 

Private Member Functions

GUI_fontCreateFont (int height, string face, bool proportional, GUI_FONT _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, string styleset="default")
 Creates a font and adds it to a styleset. More...
 
GUI_ElementStyleCreateStyle (GUI_STYLE styleId, GUI_STYLE inherit_from=STYLE_DEFAULT, string styleset="default")
 Creates a new style and adds it to a styleset. More...
 
void createFonts ()
 Creates all the fonts. Currently all of them hardcoded. More...
 
void createStyles ()
 Creates all the styles. Currently all hardcoded. More...
 
void createStyleSet (string name)
 

Private Attributes

map< string, StyleSet * > stylesets
 Stores the available StyleSets.
 
string defaultStyle = "default"
 Defines the default style.
 

Static Private Attributes

static FontsAndStylesinstance = NULL
 Stores the instance of the fonts and styles manager.
 

Detailed Description

Singleton that manages fonts and styles.

Fonts and the Styles are not handled by a GUImanager because a GUImanager exists as one instance per vessel, while this data is global for the entire simulation.

See also
FontsAndStyles.h

Member Function Documentation

GUI_font * FontsAndStyles::CreateFont ( int  height,
string  face,
bool  proportional,
GUI_FONT  _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,
string  styleset = "default" 
)
private

Creates a font and adds it to a styleset.

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)
stylesetThe styleset this font is a part of
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.
void FontsAndStyles::createFonts ( )
private

Creates all the fonts. Currently all of them hardcoded.

Todo:
replace this with a parser
GUI_ElementStyle * FontsAndStyles::CreateStyle ( GUI_STYLE  styleId,
GUI_STYLE  inherit_from = STYLE_DEFAULT,
string  styleset = "default" 
)
private

Creates a new style and adds it to a styleset.

Set the style properties after creation.

Parameters
styleIdThe identifier of the style
inherit_fromThe created style will inherit all properties from this style. Pass STYLE_NONE if you don't have a style to inherit from
stylesetThe styleset this style should be added to.
void FontsAndStyles::createStyles ( )
private

Creates all the styles. Currently all hardcoded.

Todo:
Replace this with a parser
void FontsAndStyles::createStyleSet ( string  name)
private

Creates a new StyleSet

Parameters
nameThe name of the styleset. Must be unique!
void FontsAndStyles::DestroyInstance ( )
static

Destroys the instance of the singleton.

This is not ideal, because a singleton should not actually be deleted from the outside. However, since Orbiter doesn't really terminate between sessions, we need to deallocate it none the less. This method should only be called from SimExit()!! Any pointer to a font or a style will point to Nirvana after calling this function!

GUI_font * FontsAndStyles::GetFont ( GUI_FONT  fontid = GUI_SMALL_DEFAULT_FONT,
string  styleset = "default" 
)
Returns
The desired font
Parameters
fontidThe id identifying the font
stylesetThe styleset the font should be taken from
FontsAndStyles * FontsAndStyles::GetInstance ( )
static
Returns
The instance of the singleton
GUI_ElementStyle * FontsAndStyles::GetStyle ( GUI_STYLE  styleId = STYLE_DEFAULT,
string  styleset = "default" 
)
Returns
The desired style
Parameters
styleIdThe identifier of the desired style
stylesetThe styleset the style should be taken from

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