AGW Logo

agw_title ArtManager

This class provides various art utilities, such as creating shadow, providing lighter / darker colours for a given colour, etc...

hierarchy Inheritance Diagram

Inheritance diagram for: ArtManager

Inheritance diagram of ArtManager


method_summary Methods Summary

__init__Default class constructor.
AddMenuThemeAdds a new theme to the stock.
BackgroundColourReturns the background colour of a control when not in focus.
CalcButtonBestSizeReturns the best fit size for the supplied label & bitmap.
CanMakeWindowsTransparentUsed internally.
ConvertToBitmapConvert the given image to a bitmap, optionally overlaying an alpha channel to it.
CreateGreyBitmapCreates a grey bitmap image from the input bitmap.
DarkColourLike the LightColour function, but create the colour darker by percent.
DrawBitmapShadowDraws a shadow using background bitmap.
DrawButtonColour rectangle according to the theme.
DrawButtonColourDraws a button using the appropriate theme.
DrawButtonThemeDraws a button using the appropriate theme.
DrawDragSashDraws resize sash.
DrawMenuBarBgDraws the menu bar background according to the active theme.
DrawMenuBarBorderEnables menu border drawing (XP style only).
DrawTextAndBitmapDraws the text & bitmap on the input dc.
DrawToolBarBgDraws the toolbar background according to the active theme.
DropShadowAdds a shadow under the window (Windows only).
FillStockBitmapsInitializes few standard bitmaps.
FrameColourReturn the surrounding colour for a control.
FreeDestructor for the unique art manager object.
GetAccessor to the unique art manager object.
GetAccelIndexReturns the mnemonic index of the label and the label stripped of the ampersand mnemonic (e.g.
GetAlignBufferReturn the padding buffer for a text or bitmap.
GetBitmapStartLocationReturns the top left x and y cordinates of the bitmap drawing.
GetColourSchemesReturns the available colour schemes.
GetFontReturns the font used by this theme.
GetMBVerticalGradientReturns True if the menu bar should be painted with vertical gradient.
GetMS2007ButtonSunkenReturns the sunken flag for MS 2007 buttons.
GetMenuBarBorderReturns menu bar border drawing flag.
GetMenuBarColourSchemeReturns the current colour scheme.
GetMenuBarFaceColourReturns the menu bar face colour.
GetMenuBarSelectionColourReturns the menu bar selection colour.
GetMenuBgFactorGets the visibility depth of the menu in Metallic style.
GetMenuFaceColourReturns the colour used for the menu foreground.
GetMenuThemeReturns the currently used menu theme.
GetRaiseToolbarReturns True if we are dropping a shadow under a toolbar.
GetStockBitmapReturns a bitmap from a stock.
GetTextColourDisableReturns the colour used for disabled menu items.
GetTextColourEnableReturns the colour used for enabled menu items.
GetTextStartLocationReturns the top left x and y cordinates of the text drawing.
GetThemeBaseColourReturns the theme (Blue, Silver, Green etc.) base colour, if no theme is active
GetTransparencyReturns the alpha channel value for transparent windows.
HighlightBackgroundColourReturns the background colour of a control when it is in focus.
InitColoursInitialise the colour map.
InitializeInitializes the bitmaps and colours.
IsDarkReturns whether a colour is dark or light.
LightColourReturn light contrast of colour.
MakeWindowTransparentUsed internally.
MixColoursReturn mix of input colours.
OnSysColourChangeHandles the wx.EVT_SYS_COLOUR_CHANGED event for ArtManager.
PaintCrescentGradientBoxPaint a region with gradient colouring.
PaintDiagonalGradientBoxPaint rectangle with gradient colouring; the gradient lines are diagonal and may start from the upper left corner or from the upper right corner.
PaintGradientRegionPaint a region with gradient colouring.
PaintStraightGradientBoxPaint the rectangle with gradient colouring; the gradient lines are either horizontal or vertical.
RandomColourCreates a random colour.
SetMBVerticalGradientSets the menu bar gradient style.
SetMS2007ButtonSunkenSets MS 2007 button style sunken or not.
SetMenuBarColourSets the menu bar colour scheme to use.
SetMenuThemeSet the menu theme, possible values (Style2007, StyleXP, StyleVista).
SetRaiseToolbarEnables/disables toobar shadow drop.
SetTransparencySets the alpha channel value for transparent windows.
TakeScreenShotTakes a screenshot of the screen at given position & size (rect).
TruncateTextTruncates a given string to fit given width size.

API Class API

class ArtManager(wx.EvtHandler)[source]

This class provides various art utilities, such as creating shadow, providing lighter / darker colours for a given colour, etc...



__init__()[source]

Default class constructor.



AddMenuTheme(render)[source]

Adds a new theme to the stock.

Parameters:render – a rendering theme class, which must be derived from RendererBase.
Returns:An integer representing the size of the renderers dictionary.


BackgroundColour()[source]

Returns the background colour of a control when not in focus.

Returns:An instance of wx.Colour.


CalcButtonBestSize(label, bmp)[source]

Returns the best fit size for the supplied label & bitmap.

Parameters:
  • label (string) – the button label;
  • bmp – the bitmap associated with the button, an instance of wx.Bitmap.
Returns:

An instance of wx.Size, representing the best fit size for the supplied label & bitmap.



CanMakeWindowsTransparent()[source]

Used internally.

Returns:True if the system supports transparency of toplevel windows, otherwise returns False.


ConvertToBitmap(xpm, alpha=None)[source]

Convert the given image to a bitmap, optionally overlaying an alpha channel to it.

Parameters:
  • xpm (list of strings) – a list of strings formatted as XPM;
  • alpha (list of integers) – a list of alpha values, the same size as the xpm bitmap.
Returns:

An instance of wx.Bitmap.



CreateGreyBitmap(bmp)[source]

Creates a grey bitmap image from the input bitmap.

Parameters:bmp – a valid wx.Bitmap object to be greyed out.

Returns:A greyed-out representation of the input bitmap, an instance of wx.Bitmap.


DarkColour(colour, percent)[source]

Like the LightColour function, but create the colour darker by percent.

Parameters:
  • colour – the input colour to be darkened, an instance of wx.Colour;

  • percent (integer) – determines how dark the colour will be. percent = 100 returns black, percent = 0 returns colour.
Returns:

A dark contrast of the input colour, an instance of wx.Colour.



DrawBitmapShadow(dc, rect, where=3)[source]

Draws a shadow using background bitmap.

Parameters:
  • dc – an instance of wx.DC;
  • rect (wx.Rect) – the bitmap’s client rectangle;
  • where (integer) – where to draw the shadow. This can be any combination of the following bits:


    integer parameter settings
    Shadow Settings Value Description
    RightShadow 1 Right side shadow
    BottomShadow 2 Not full bottom shadow
    BottomShadowFull 4 Full bottom shadow


DrawButton(dc, rect, theme, state, input=None)[source]

Colour rectangle according to the theme.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the rectangle to be filled with gradient shading;
  • theme (string) – the theme to use to draw the button;
  • state (integer) – the button state;
  • input – a flag used to call the right method.


DrawButtonColour(dc, rect, theme, state, colour)[source]

Draws a button using the appropriate theme.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the button’s client rectangle;
  • theme (string) – the theme to use to draw the button;
  • state (integer) – the button state;
  • colour – a valid wx.Colour instance.



DrawButtonTheme(dc, rect, theme, state, useLightColours=True)[source]

Draws a button using the appropriate theme.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the button’s client rectangle;
  • theme (string) – the theme to use to draw the button;
  • state (integer) – the button state;
  • useLightColours (bool) – True to use light colours, False otherwise.


DrawDragSash(rect)[source]

Draws resize sash.

Parameters:rect (wx.Rect) – the sash client rectangle.


DrawMenuBarBg(dc, rect)[source]

Draws the menu bar background according to the active theme.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the menubar’s client rectangle.


DrawMenuBarBorder(border)[source]

Enables menu border drawing (XP style only).

Parameters:border (bool) – True to draw the menubar border, False otherwise.


DrawTextAndBitmap(dc, rect, text, enable=True, font=wx.NullFont, fontColour=wx.BLACK, bitmap=wx.NullBitmap, grayBitmap=wx.NullBitmap, style=0)[source]

Draws the text & bitmap on the input dc.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the text and bitmap client rectangle;
  • text (string) – the button label;
  • enable (bool) – True if the button is enabled, False otherwise;
  • font – the font to use to draw the text, an instance of wx.Font;
  • fontColour – the colour to use to draw the text, an instance of wx.Colour;
  • bitmap – the bitmap associated with the button, an instance of wx.Bitmap;

  • grayBitmap – a greyed-out version of the input bitmap representing a disabled bitmap, an instance of wx.Bitmap;

  • style (integer) – the button style.

See also

GetBitmapStartLocation for a list of valid button styles.



DrawToolBarBg(dc, rect)[source]

Draws the toolbar background according to the active theme.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the toolbar’s client rectangle.


DropShadow(wnd, drop=True)[source]

Adds a shadow under the window (Windows only).

Parameters:
  • wnd – the window for which we are dropping a shadow, an instance of wx.TopLevelWindow;
  • drop (bool) – True to drop a shadow, False to remove it.


FillStockBitmaps()[source]

Initializes few standard bitmaps.



FrameColour()[source]

Return the surrounding colour for a control.

Returns:An instance of wx.Colour.


classmethod Free()[source]

Destructor for the unique art manager object.



classmethod Get()[source]

Accessor to the unique art manager object.

Returns:A unique instance of ArtManager.


GetAccelIndex(label)[source]

Returns the mnemonic index of the label and the label stripped of the ampersand mnemonic (e.g. ‘lab&el’ ==> will result in 3 and labelOnly = label).

Parameters:label (string) – a string containining an ampersand.
Returns:A tuple containining the mnemonic index of the label and the label stripped of the ampersand mnemonic.


GetAlignBuffer()[source]

Return the padding buffer for a text or bitmap.

Returns:An integer representing the padding buffer.


GetBitmapStartLocation(dc, rect, bitmap, text='', style=0)[source]

Returns the top left x and y cordinates of the bitmap drawing.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the bitmap’s client rectangle;
  • bitmap (wx.Bitmap) – the bitmap associated with the button;
  • text (string) – the button label;
  • style (integer) – the button style. This can be one of the following bits:


    integer parameter settings
    Button style Value Description
    BU_EXT_XP_STYLE 1 A button with a XP style
    BU_EXT_2007_STYLE 2 A button with a MS Office 2007 style
    BU_EXT_LEFT_ALIGN_STYLE 4 A left-aligned button
    BU_EXT_CENTER_ALIGN_STYLE 8 A center-aligned button
    BU_EXT_RIGHT_ALIGN_STYLE 16 A right-aligned button
    BU_EXT_RIGHT_TO_LEFT_STYLE 32 A button suitable for right-to-left languages
Returns:

A tuple containining the top left x and y cordinates of the bitmap drawing.



GetColourSchemes()[source]

Returns the available colour schemes.

Returns:A list of strings representing the available colour schemes.


GetFont()[source]

Returns the font used by this theme.

Returns:An instance of wx.Font.


GetMBVerticalGradient()[source]

Returns True if the menu bar should be painted with vertical gradient.



GetMS2007ButtonSunken()[source]

Returns the sunken flag for MS 2007 buttons.

Returns:True if the MS 2007 buttons are sunken, False otherwise.


GetMenuBarBorder()[source]

Returns menu bar border drawing flag.

Returns:True if the menu bar border is to be drawn, False otherwise.


GetMenuBarColourScheme()[source]

Returns the current colour scheme.

Returns:A string representing the current colour scheme.


GetMenuBarFaceColour()[source]

Returns the menu bar face colour.

Returns:An instance of wx.Colour.


GetMenuBarSelectionColour()[source]

Returns the menu bar selection colour.

Returns:An instance of wx.Colour.


GetMenuBgFactor()[source]

Gets the visibility depth of the menu in Metallic style. The higher the value, the menu bar will look more raised



GetMenuFaceColour()[source]

Returns the colour used for the menu foreground.

Returns:An instance of wx.Colour.


GetMenuTheme()[source]

Returns the currently used menu theme.

Returns:A string containining the currently used theme for the menu.


GetRaiseToolbar()[source]

Returns True if we are dropping a shadow under a toolbar.



GetStockBitmap(name)[source]

Returns a bitmap from a stock.

Parameters:name (string) – the bitmap name.
Returns:The stock bitmap, if name was found in the stock bitmap dictionary. Othewise, wx.NullBitmap is returned.


GetTextColourDisable()[source]

Returns the colour used for disabled menu items.

Returns:An instance of wx.Colour.


GetTextColourEnable()[source]

Returns the colour used for enabled menu items.

Returns:An instance of wx.Colour.


GetTextStartLocation(dc, rect, bitmap, text, style=0)[source]

Returns the top left x and y cordinates of the text drawing. In case the text is too long, the text is being fixed (the text is cut and a ‘...’ mark is added in the end).

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the text’s client rectangle;
  • bitmap (wx.Bitmap) – the bitmap associated with the button;
  • text (string) – the button label;
  • style (integer) – the button style.
Returns:

A tuple containining the top left x and y cordinates of the text drawing, plus the truncated version of the input text.

See also

GetBitmapStartLocation for a list of valid button styles.



GetThemeBaseColour(useLightColours=True)[source]

Returns the theme (Blue, Silver, Green etc.) base colour, if no theme is active it return the active caption colour, lighter in 30%.

Parameters:useLightColours (bool) – True to use light colours, False otherwise.
Returns:An instance of wx.Colour.


GetTransparency()[source]

Returns the alpha channel value for transparent windows.

Returns:An integer representing the alpha channel value.


HighlightBackgroundColour()[source]

Returns the background colour of a control when it is in focus.

Returns:An instance of wx.Colour.


InitColours()[source]

Initialise the colour map.



Initialize()[source]

Initializes the bitmaps and colours.



IsDark(colour)[source]

Returns whether a colour is dark or light.

Parameters:colour – an instance of wx.Colour.

Returns:True if the average RGB values are dark, False otherwise.


LightColour(colour, percent)[source]

Return light contrast of colour. The colour returned is from the scale of colour ==> white.

Parameters:
  • colour – the input colour to be brightened, an instance of wx.Colour;

  • percent (integer) – determines how light the colour will be. percent = 100 returns white, percent = 0 returns colour.
Returns:

A light contrast of the input colour, an instance of wx.Colour.



MakeWindowTransparent(wnd, amount)[source]

Used internally. Makes a toplevel window transparent if the system supports it.

Parameters:
  • wnd – the toplevel window to make transparent, an instance of wx.TopLevelWindow;

  • amount (integer) – the window transparency to apply.


MixColours(firstColour, secondColour, percent)[source]

Return mix of input colours.

Parameters:
  • firstColour – the first colour to be mixed, an instance of wx.Colour;

  • secondColour – the second colour to be mixed, an instance of wx.Colour;

  • percent (integer) – the relative percentage of firstColour with respect to secondColour.
Returns:

An instance of wx.Colour.



OnSysColourChange(event)[source]

Handles the wx.EVT_SYS_COLOUR_CHANGED event for ArtManager.

Parameters:event – a wx.SysColourChangedEvent event to be processed.


PaintCrescentGradientBox(dc, rect, startColour, endColour, concave=True)[source]

Paint a region with gradient colouring. The gradient is in crescent shape which fits the 2007 style.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the rectangle to be filled with gradient shading;
  • startColour (wx.Colour) – the first colour of the gradient shading;
  • endColour (wx.Colour) – the second colour of the gradient shading;
  • concave (bool) – True for a concave effect, False for a convex one.


PaintDiagonalGradientBox(dc, rect, startColour, endColour, startAtUpperLeft=True, trimToSquare=True)[source]

Paint rectangle with gradient colouring; the gradient lines are diagonal and may start from the upper left corner or from the upper right corner.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the rectangle to be filled with gradient shading;
  • startColour (wx.Colour) – the first colour of the gradient shading;
  • endColour (wx.Colour) – the second colour of the gradient shading;
  • startAtUpperLeft (bool) – True to start the gradient lines at the upper left corner of the rectangle, False to start at the upper right corner;
  • trimToSquare (bool) – True to trim the gradient lines in a square.


PaintGradientRegion(dc, region, startColour, endColour, vertical=True)[source]

Paint a region with gradient colouring.

Parameters:
  • dc – an instance of wx.DC;

  • region – a region to be filled with gradient shading (an instance of wx.Region);
  • startColour (wx.Colour) – the first colour of the gradient shading;
  • endColour (wx.Colour) – the second colour of the gradient shading;
  • vertical (bool) – True for gradient colouring in the vertical direction, False for horizontal shading.


PaintStraightGradientBox(dc, rect, startColour, endColour, vertical=True)[source]

Paint the rectangle with gradient colouring; the gradient lines are either horizontal or vertical.

Parameters:
  • dc – an instance of wx.DC;

  • rect (wx.Rect) – the rectangle to be filled with gradient shading;
  • startColour (wx.Colour) – the first colour of the gradient shading;
  • endColour (wx.Colour) – the second colour of the gradient shading;
  • vertical (bool) – True for gradient colouring in the vertical direction, False for horizontal shading.


RandomColour()[source]

Creates a random colour.

Returns:An instance of wx.Colour.


SetMBVerticalGradient(v)[source]

Sets the menu bar gradient style.

Parameters:v (bool) – True for a vertical shaded gradient, False otherwise.


SetMS2007ButtonSunken(sunken)[source]

Sets MS 2007 button style sunken or not.

Parameters:sunken (bool) – True to have a sunken border effect, False otherwise.


SetMenuBarColour(scheme)[source]

Sets the menu bar colour scheme to use.

Parameters:scheme (string) – a string representing a colour scheme (i.e., ‘Default’, ‘Dark’, ‘Dark Olive Green’, ‘Generic’).


SetMenuTheme(theme)[source]

Set the menu theme, possible values (Style2007, StyleXP, StyleVista).

Parameters:theme (string) – a rendering theme class, either StyleXP, Style2007 or StyleVista.


SetRaiseToolbar(rais)[source]

Enables/disables toobar shadow drop.

Parameters:rais (bool) – True to drop a shadow below a toolbar, False otherwise.


SetTransparency(amount)[source]

Sets the alpha channel value for transparent windows.

Parameters:amount (integer) – the actual transparency value (between 0 and 255).
Raise :Exception if the amount parameter is lower than 0 or greater than 255.


TakeScreenShot(rect, bmp)[source]

Takes a screenshot of the screen at given position & size (rect).

Parameters:
  • rect (wx.Rect) – the screen rectangle we wish to capture;
  • bmp (wx.Bitmap) – currently unused.


TruncateText(dc, text, maxWidth)[source]

Truncates a given string to fit given width size. if the text does not fit into the given width it is truncated to fit. the format of the fixed text is <truncate text ...>.

Parameters:
  • dc – an instance of wx.DC;

  • text (string) – the text to be (eventually) truncated;
  • maxWidth (integer) – the maximum width allowed for the text.
Returns:

A new string containining the (possibly) truncated text.

Tree

Table Of Contents

Previous topic

artmanager

Next topic

DCSaver