This class provides various art utilities, such as creating shadow, providing lighter / darker colours for a given colour, etc…
Default class constructor. |
|
Adds a new theme to the stock. |
|
Returns the background colour of a control when not in focus. |
|
Returns the best fit size for the supplied label & bitmap. |
|
Used internally. |
|
Convert the given image to a bitmap, optionally overlaying an alpha |
|
Creates a grey bitmap image from the input bitmap. |
|
Like the |
|
Draws a shadow using background bitmap. |
|
Colour rectangle according to the theme. |
|
Draws a button using the appropriate theme. |
|
Draws a button using the appropriate theme. |
|
Draws resize sash. |
|
Draws the menu bar background according to the active theme. |
|
Enables menu border drawing (XP style only). |
|
Draws the text & bitmap on the input dc. |
|
Draws the toolbar background according to the active theme. |
|
Adds a shadow under the window (Windows only). |
|
Initializes few standard bitmaps. |
|
Return the surrounding colour for a control. |
|
Returns the mnemonic index of the label and the label stripped of the ampersand mnemonic |
|
Return the padding buffer for a text or bitmap. |
|
Returns the top left x and y coordinates of the bitmap drawing. |
|
Returns the available colour schemes. |
|
Returns the font used by this theme. |
|
Returns |
|
Returns menu bar border drawing flag. |
|
Returns the current colour scheme. |
|
Returns the menu bar face colour. |
|
Returns the menu bar selection colour. |
|
Gets the visibility depth of the menu in Metallic style. |
|
Returns the colour used for the menu foreground. |
|
Returns the currently used menu theme. |
|
Returns the sunken flag for MS 2007 buttons. |
|
Returns |
|
Returns a bitmap from a stock. |
|
Returns the colour used for disabled menu items. |
|
Returns the colour used for enabled menu items. |
|
Returns the top left x and y coordinates of the text drawing. |
|
Returns the theme (Blue, Silver, Green etc.) base colour, if no theme is active |
|
Returns the alpha channel value for transparent windows. |
|
Returns the background colour of a control when it is in focus. |
|
Initialise the colour map. |
|
Initializes the bitmaps and colours. |
|
Returns whether a colour is dark or light. |
|
Return light contrast of colour. The colour returned is from the scale of |
|
Used internally. Makes a toplevel window transparent if the system supports it. |
|
Return mix of input colours. |
|
Handles the |
|
Paint a region with gradient colouring. The gradient is in crescent shape |
|
Paint rectangle with gradient colouring; the gradient lines are diagonal |
|
Paint a region with gradient colouring. |
|
Paint the rectangle with gradient colouring; the gradient lines are either |
|
Creates a random colour. |
|
Sets the menu bar gradient style. |
|
Sets the menu bar colour scheme to use. |
|
Set the menu theme, possible values (Style2007, StyleXP, StyleVista). |
|
Sets MS 2007 button style sunken or not. |
|
Enables/disables toobar shadow drop. |
|
Sets the alpha channel value for transparent windows. |
|
Takes a screenshot of the screen at given position & size (rect). |
|
Truncates a given string to fit given width size. if the text does not fit |
ArtManager
(wx.EvtHandler)¶This class provides various art utilities, such as creating shadow, providing lighter / darker colours for a given colour, etc…
__init__
(self)¶Default class constructor.
AddMenuTheme
(self, render)¶Adds a new theme to the stock.
render – a rendering theme class, which must be derived from
RendererBase
.
An integer representing the size of the renderers dictionary.
BackgroundColour
(self)¶Returns the background colour of a control when not in focus.
An instance of wx.Colour
.
CalcButtonBestSize
(self, label, bmp)¶Returns the best fit size for the supplied label & bitmap.
CanMakeWindowsTransparent
(self)¶Used internally.
True
if the system supports transparency of toplevel windows,
otherwise returns False
.
ConvertToBitmap
(self, xpm, alpha=None)¶Convert the given image to a bitmap, optionally overlaying an alpha channel to it.
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.
An instance of wx.Bitmap
.
CreateGreyBitmap
(self, bmp)¶Creates a grey bitmap image from the input bitmap.
DarkColour
(self, colour, percent)¶Like the LightColour
function, but create the colour darker by percent.
DrawBitmapShadow
(self, dc, rect, where=BottomShadow|RightShadow)¶Draws a shadow using background bitmap.
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:
Shadow Settings |
Value |
Description |
---|---|---|
|
1 |
Right side shadow |
|
2 |
Not full bottom shadow |
|
4 |
Full bottom shadow |
DrawButton
(self, dc, rect, theme, state, input=None)¶Colour rectangle according to the theme.
DrawButtonColour
(self, dc, rect, theme, state, colour)¶Draws a button using the appropriate theme.
DrawButtonTheme
(self, dc, rect, theme, state, useLightColours=True)¶Draws a button using the appropriate theme.
DrawDragSash
(self, rect)¶Draws resize sash.
rect (wx.Rect) – the sash client rectangle.
DrawMenuBarBg
(self, dc, rect)¶Draws the menu bar background according to the active theme.
DrawMenuBarBorder
(self, border)¶Enables menu border drawing (XP style only).
border (bool) – True
to draw the menubar border, False
otherwise.
DrawTextAndBitmap
(self, dc, rect, text, enable=True, font=wx.NullFont, fontColour=wx.BLACK, bitmap=wx.NullBitmap, grayBitmap=wx.NullBitmap, style=0)¶Draws the text & bitmap on the input dc.
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
(self, dc, rect)¶Draws the toolbar background according to the active theme.
DropShadow
(self, wnd, drop=True)¶Adds a shadow under the window (Windows only).
wnd – the window for which we are dropping a shadow, an instance of TopLevelWindow
;
drop (bool) – True
to drop a shadow, False
to remove it.
FillStockBitmaps
(self)¶Initializes few standard bitmaps.
GetAccelIndex
(self, label)¶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).
label (string) – a string containing an ampersand.
A tuple containing the mnemonic index of the label and the label stripped of the ampersand mnemonic.
GetAlignBuffer
(self)¶Return the padding buffer for a text or bitmap.
An integer representing the padding buffer.
GetBitmapStartLocation
(self, dc, rect, bitmap, text="", style=0)¶Returns the top left x and y coordinates of the bitmap drawing.
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:
Button style |
Value |
Description |
---|---|---|
|
1 |
A button with a XP style |
|
2 |
A button with a MS Office 2007 style |
|
4 |
A left-aligned button |
|
8 |
A center-aligned button |
|
16 |
A right-aligned button |
|
32 |
A button suitable for right-to-left languages |
A tuple containing the top left x and y coordinates of the bitmap drawing.
GetColourSchemes
(self)¶Returns the available colour schemes.
A list of strings representing the available colour schemes.
GetMBVerticalGradient
(self)¶Returns True
if the menu bar should be painted with vertical gradient.
GetMenuBarBorder
(self)¶Returns menu bar border drawing flag.
True
if the menu bar border is to be drawn, False
otherwise.
GetMenuBarColourScheme
(self)¶Returns the current colour scheme.
A string representing the current colour scheme.
GetMenuBarSelectionColour
(self)¶Returns the menu bar selection colour.
An instance of wx.Colour
.
GetMenuBgFactor
(self)¶Gets the visibility depth of the menu in Metallic style. The higher the value, the menu bar will look more raised
GetMenuFaceColour
(self)¶Returns the colour used for the menu foreground.
An instance of wx.Colour
.
GetMenuTheme
(self)¶Returns the currently used menu theme.
A string containing the currently used theme for the menu.
GetMS2007ButtonSunken
(self)¶Returns the sunken flag for MS 2007 buttons.
True
if the MS 2007 buttons are sunken, False
otherwise.
GetRaiseToolbar
(self)¶Returns True
if we are dropping a shadow under a toolbar.
GetStockBitmap
(self, name)¶Returns a bitmap from a stock.
name (string) – the bitmap name.
The stock bitmap, if name was found in the stock bitmap dictionary.
Otherwise, NullBitmap
is returned.
GetTextColourDisable
(self)¶Returns the colour used for disabled menu items.
An instance of wx.Colour
.
GetTextColourEnable
(self)¶Returns the colour used for enabled menu items.
An instance of wx.Colour
.
GetTextStartLocation
(self, dc, rect, bitmap, text, style=0)¶Returns the top left x and y coordinates 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).
A tuple containing the top left x and y coordinates of the text drawing, plus the truncated version of the input text.
See also
GetBitmapStartLocation
for a list of valid button styles.
GetThemeBaseColour
(self, useLightColours=True)¶Returns the theme (Blue, Silver, Green etc.) base colour, if no theme is active it return the active caption colour, lighter in 30%.
useLightColours (bool) – True
to use light colours, False
otherwise.
An instance of wx.Colour
.
GetTransparency
(self)¶Returns the alpha channel value for transparent windows.
An integer representing the alpha channel value.
HighlightBackgroundColour
(self)¶Returns the background colour of a control when it is in focus.
An instance of wx.Colour
.
InitColours
(self)¶Initialise the colour map.
Initialize
(self)¶Initializes the bitmaps and colours.
IsDark
(self, colour)¶Returns whether a colour is dark or light.
colour – an instance of wx.Colour
.
True
if the average RGB values are dark, False
otherwise.
LightColour
(self, colour, percent)¶Return light contrast of colour. The colour returned is from the scale of colour ==> white.
MakeWindowTransparent
(self, wnd, amount)¶Used internally. Makes a toplevel window transparent if the system supports it.
wnd – the toplevel window to make transparent, an instance of TopLevelWindow
;
amount (integer) – the window transparency to apply.
MixColours
(self, firstColour, secondColour, percent)¶Return mix of input colours.
OnSysColourChange
(self, event)¶Handles the wx.EVT_SYS_COLOUR_CHANGED
event for ArtManager
.
event – a SysColourChangedEvent
event to be processed.
PaintCrescentGradientBox
(self, dc, rect, startColour, endColour, concave=True)¶Paint a region with gradient colouring. The gradient is in crescent shape which fits the 2007 style.
PaintDiagonalGradientBox
(self, dc, rect, startColour, endColour, startAtUpperLeft=True, trimToSquare=True)¶Paint rectangle with gradient colouring; the gradient lines are diagonal and may start from the upper left corner or from the upper right corner.
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
(self, dc, region, startColour, endColour, vertical=True)¶Paint a region with gradient colouring.
dc – an instance of wx.DC
;
region – a region to be filled with gradient shading (an instance of
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
(self, dc, rect, startColour, endColour, vertical=True)¶Paint the rectangle with gradient colouring; the gradient lines are either horizontal or vertical.
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.
SetMBVerticalGradient
(self, v)¶Sets the menu bar gradient style.
v (bool) – True
for a vertical shaded gradient, False
otherwise.
SetMenuBarColour
(self, scheme)¶Sets the menu bar colour scheme to use.
scheme (string) – a string representing a colour scheme (i.e., ‘Default’, ‘Dark’, ‘Dark Olive Green’, ‘Generic’).
SetMenuTheme
(self, theme)¶Set the menu theme, possible values (Style2007, StyleXP, StyleVista).
theme (string) – a rendering theme class, either StyleXP
, Style2007
or StyleVista
.
SetMS2007ButtonSunken
(self, sunken)¶Sets MS 2007 button style sunken or not.
sunken (bool) – True
to have a sunken border effect, False
otherwise.
SetRaiseToolbar
(self, rais)¶Enables/disables toobar shadow drop.
rais (bool) – True
to drop a shadow below a toolbar, False
otherwise.
SetTransparency
(self, amount)¶Sets the alpha channel value for transparent windows.
amount (integer) – the actual transparency value (between 0 and 255).
Exception if the amount parameter is lower than 0
or greater than 255
.
TakeScreenShot
(self, rect, bmp)¶Takes a screenshot of the screen at given position & size (rect).
TruncateText
(self, dc, text, maxWidth)¶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 ...
.
dc – an instance of wx.DC
;
text (string) – the text to be (eventually) truncated;
maxWidth (integer) – the maximum width allowed for the text.
A new string containing the (possibly) truncated text.