Table Of Contents

Previous topic

StyleItem

Next topic

ed_tab

This Page

phoenix_title StyleMgr

Manages style definitions and provides them on request. Also provides functionality for loading custom style sheets and modifying styles during run time.


class_hierarchy Inheritance Diagram

Inheritance diagram for class StyleMgr

Inheritance diagram of StyleMgr


method_summary Methods Summary

__init__ Initializes the Style Manager
BlankStyleDictionary Returns a dictionary of unset style items based on the
FindTagById Find the style tag that is associated with the given
GetCurrentStyleSetName Get the name of the currently set style
GetDefaultBackColour Gets the background color of the default style and returns
GetDefaultFont Constructs and returns a wxFont object from the settings
GetDefaultForeColour Gets the foreground color of the default style and returns
GetFontDictionary Does a system lookup to build a default set of fonts using
GetItemByName Gets and returns a style item using its name for the search
GetStyleByName Gets and returns a style string using its name for the search
GetStyleFont Returns the primary font facename by default
GetStyleSet Returns the current set of styles or the default set if
GetStyleSheet Finds the current style sheet and returns its path. The
GetSyntaxParams Get the set of syntax parameters
HasNamedStyle Checks if a style has been set/loaded or not
LoadStyleSheet Loads a custom style sheet and returns True on success
PackStyleSet Checks the difference of each item in the style set as
ParseStyleData Parses a string style definitions read from an Editra Style Sheet.
SetGlobalFont Sets one of the fonts in the global font set by tag
SetStyleFont Sets the primary or secondary font and their respective
SetStyles Sets the managers style data and returns True on success.
SetStyleTag Sets the value of style tag by name
SetSyntax Sets the Syntax Style Specs from a list of specifications
StyleDefault Clears the editor styles to default
UpdateAllStyles Refreshes all the styles and attributes of the control
UpdateBaseStyles Updates the base styles of editor to the current settings

api Class API



class StyleMgr(object)

Manages style definitions and provides them on request. Also provides functionality for loading custom style sheets and modifying styles during run time.


Methods



__init__(self, custom='')

Initializes the Style Manager

Parameters:custom – path to custom style sheet to use


BlankStyleDictionary(self)

Returns a dictionary of unset style items based on the tags defined in the current dictionary.

Returns:dictionary of unset style items using the current tag set as keys.


FindTagById(self, style_id)

Find the style tag that is associated with the given Id. Return value defaults to default_style .

Parameters:style_id – id of tag to look for
Returns:style tag string


GetCurrentStyleSetName(self)

Get the name of the currently set style

Returns:string


GetDefaultBackColour(self, as_hex=False)

Gets the background color of the default style and returns a Colour object. Otherwise returns white if the default style is not found.

Parameters:as_hex – return a hex string or colour object
Returns:wx.Colour of default style background or hex value


GetDefaultFont(self)

Constructs and returns a wxFont object from the settings of the default_style object.

Returns:wx.Font object of default style


GetDefaultForeColour(self, as_hex=False)

Gets the foreground color of the default style and returns a Colour object. Otherwise returns Black if the default style is not found.

Parameters:as_hex – return a hex string or colour object
Returns:wx.Colour of default style foreground or hex value


GetFontDictionary(self, default=True)

Does a system lookup to build a default set of fonts using ten point fonts as the standard size.

Parameters:default – return the default dictionary of fonts, else return the current running dictionary of fonts if it exists.
Returns:font dictionary (primary, secondary) + (size, size2)


GetItemByName(self, name)

Gets and returns a style item using its name for the search

Parameters:name – tag name of style item to get
Returns:style item (may be empty/null style item)


GetStyleByName(self, name)

Gets and returns a style string using its name for the search

Parameters:name – tag name of style to get
Returns:style item in string form


GetStyleFont(self, primary=True)

Returns the primary font facename by default

Parameters:primary – Get Primary(default) or Secondary Font
Returns:face name of current font in use


GetStyleSet(self)

Returns the current set of styles or the default set if there is no current set.

Returns:current style set dictionary


static GetStyleSheet(sheet_name=None)

Finds the current style sheet and returns its path. The lookup is done by first looking in the users config directory and if it is not found there it looks for one on the system level and if that fails it returns None.

Parameters:sheet_name – style sheet to look for
Returns:full path to style sheet


GetSyntaxParams(self)

Get the set of syntax parameters

Returns:list


HasNamedStyle(self, name)

Checks if a style has been set/loaded or not

Parameters:name – tag name of style to look for
Returns:whether item is in style set or not


LoadStyleSheet(self, style_sheet, force=False)

Loads a custom style sheet and returns True on success

Parameters:
  • style_sheet – path to style sheet to load
  • force – Force re-parse of style sheet, default is to use cached data when available
Returns:

whether style sheet was loaded or not



PackStyleSet(self, style_set)

Checks the difference of each item in the style set as compared to the default_style tag and packs any unset value in the item to be equal to the default style.

Parameters:style_set – style set to pack
Returns:style_set with all unset attributes set to match default style


ParseStyleData(self, style_data)

Parses a string style definitions read from an Editra Style Sheet.

Parameters:style_data – style sheet data string
Returns:dictionary of StyleItems constructed from the style sheet data.


SetGlobalFont(self, fonttag, fontface, size=-1)

Sets one of the fonts in the global font set by tag and sets it to the named font. Returns true on success.

Parameters:
  • fonttag – font type identifier key
  • fontface – face name to set global font to


SetStyleFont(self, wx_font, primary=True)

Sets the primary or secondary font and their respective size values.

Parameters:
  • wx_font – font object to set styles font info from
  • primary – Set primary(default) or secondary font


SetStyles(self, name, style_dict, nomerge=False)

Sets the managers style data and returns True on success.

Parameters:
  • name – name to store dictionary in cache under
  • style_dict – dictionary of style items to use as managers style set.
  • nomerge – merge against default set or not


SetStyleTag(self, style_tag, value)

Sets the value of style tag by name

Parameters:
  • style_tag – desired tag name of style definition
  • value – style item to set tag to
Returns:

bool



SetSyntax(self, synlst)

Sets the Syntax Style Specs from a list of specifications

Parameters:synlst – [(STYLE_ID, “STYLE_TYPE”), (STYLE_ID2, “STYLE_TYPE2)]


StyleDefault(self)

Clears the editor styles to default

Postcondition :style is reset to default


UpdateAllStyles(self, spec_style=None)

Refreshes all the styles and attributes of the control

Parameters:spec_style – style scheme name
Postcondition :style scheme is set to specified style


UpdateBaseStyles(self)

Updates the base styles of editor to the current settings

Postcondition :base style info is updated