StyleMgr¶Manages style definitions and provides them on request. Also provides functionality for loading custom style sheets and modifying styles during run time.
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 |
Class API¶Manages style definitions and provides them on request. Also provides functionality for loading custom style sheets and modifying styles during run time.
Initializes the Style Manager
| Parameters: | custom – path to custom style sheet to use |
|---|
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. |
|---|
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 |
Get the name of the currently set style
| Returns: | string |
|---|
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 |
Constructs and returns a wxFont object from the settings of the default_style object.
| Returns: | wx.Font object of default style |
|---|
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 |
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) |
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) |
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 |
Returns the primary font facename by default
| Parameters: | primary – Get Primary(default) or Secondary Font |
|---|---|
| Returns: | face name of current font in use |
Returns the current set of styles or the default set if there is no current set.
| Returns: | current style set dictionary |
|---|
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 |
Get the set of syntax parameters
| Returns: | list |
|---|
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 |
Loads a custom style sheet and returns True on success
| Parameters: |
|
|---|---|
| Returns: | whether style sheet was loaded or not |
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 |
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. |
Sets one of the fonts in the global font set by tag and sets it to the named font. Returns true on success.
| Parameters: |
|
|---|
Sets the primary or secondary font and their respective size values.
| Parameters: |
|
|---|
Sets the managers style data and returns True on success.
| Parameters: |
|
|---|
Sets the value of style tag by name
| Parameters: |
|
|---|---|
| Returns: | bool |
Sets the Syntax Style Specs from a list of specifications
| Parameters: | synlst – [(STYLE_ID, “STYLE_TYPE”), (STYLE_ID2, “STYLE_TYPE2)] |
|---|
Clears the editor styles to default
| Postcondition : | style is reset to default |
|---|
Refreshes all the styles and attributes of the control
| Parameters: | spec_style – style scheme name |
|---|---|
| Postcondition : | style scheme is set to specified style |
Updates the base styles of editor to the current settings
| Postcondition : | base style info is updated |
|---|