ZoomBar
is a class that appoximatively mimics the behaviour of the Mac Dock,
inside a Panel
.
This is the main class implementation.
Default class constructor. |
|
Adds a button to |
|
Adds a separator to |
|
Gets the size which best suits the window: for a control, it would be the |
|
Common method to re-layout |
|
Draws all the main button bitmaps on the |
|
Draws all the button labels on the |
|
Draws all the reflection button bitmaps on the |
|
Enables/disables the button at position index. |
|
Returns the background button bar colour. |
|
Returns the original (not zoomed) button size, in pixels. |
|
Returns |
|
Returns |
|
Returns |
|
Returns the current zoom factor. |
|
HitTest method for |
|
Sets up the initial buttons and sizes them from the center. |
|
Returns |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Repositions all the buttons inside the |
|
Resets all the button sizes and positions, recalculating the optimal |
|
Sets the background button bar colour. |
|
Sets the original button size. |
|
Sets to zoom from the center. |
|
Sets whether to show button labels or not. |
|
Sets whether to show reflections or not. |
|
Sets the zoom factor for all the buttons. Larger number gives a greater zoom |
|
Snaps the background button bar bitmap and all the buttons to the bottom |
ZoomBar
(wx.Control)¶ZoomBar
is a class that appoximatively mimics the behaviour of the Mac Dock,
inside a Panel
.
This is the main class implementation.
__init__
(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, name="ZoomBar")¶Default class constructor.
parent – the ZoomBar
parent. Must not be None
;
id – window identifier. A value of -1 indicates a default value;
pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
name – the window name.
AddButton
(self, normalBmp, reflectionBmp=wx.NullBitmap, label="", disabledBmp=wx.NullBitmap, disabledReflectionBmp=wx.NullBitmap)¶Adds a button to ZoomBar
.
normalBmp – the button main bitmap, an instance of wx.Bitmap
;
reflectionBmp – a bitmap representing a reflection of the main bitmap,
an instance of wx.Bitmap
;
label – the button label;
disabledBmp – the button main bitmap when the button is in a disabled
state, an instance of wx.Bitmap
;
disabledReflectionBmp – a bitmap representing a reflection of the main bitmap,
when the button is in a disabled state, an instance of wx.Bitmap
.
DoGetBestSize
(self)¶Gets the size which best suits the window: for a control, it would be the minimal size which doesn’t truncate the control, for a panel - the same size as it would have after a call to Fit().
Note
Overridden from wx.Control
.
DrawButtons
(self, dc)¶Draws all the main button bitmaps on the ZoomBar
client window.
dc – an instance of wx.DC
.
DrawLabels
(self, dc)¶Draws all the button labels on the ZoomBar
client window.
dc – an instance of wx.DC
.
DrawReflections
(self, dc)¶Draws all the reflection button bitmaps on the ZoomBar
client window.
dc – an instance of wx.DC
.
EnableButton
(self, index, enable=True)¶Enables/disables the button at position index.
index – the index of the button to enable/disable;
enable – True
to enable the button, False
to disable it.
GetBarColour
(self)¶Returns the background button bar colour.
GetButtonSize
(self)¶Returns the original (not zoomed) button size, in pixels.
GetCenterZoom
(self)¶Returns True
if buttons zoom upwards.
GetShowLabels
(self)¶Returns True
if button labels are currently shown.
GetShowReflections
(self)¶Returns True
if reflections bitmap are currently shown.
GetZoomFactor
(self)¶Returns the current zoom factor.
HitTest
(self, pos)¶HitTest method for ZoomBar
.
pos – the current mouse position.
an index representing the button on which the mouse is hovering,
or wx.NOT_FOUND
if no button has been hit.
InitialReposition
(self)¶Sets up the initial buttons and sizes them from the center.
IsButtonEnabled
(self, index)¶Returns True
if the button at position index is enabled, False
otherwise.
index – the index of the button to check.
OnEraseBackground
(self, event)¶Handles the wx.EVT_ERASE_BACKGROUND
event for ZoomBar
.
event – a EraseEvent
event to be processed.
Note
This method is intentionally empty to avoid flicker.
OnLeaveWindow
(self, event)¶Handles the wx.EVT_LEAVE_WINDOW
event for ZoomBar
.
event – a MouseEvent
event to be processed.
OnLeftDown
(self, event)¶Handles the wx.EVT_LEFT_DOWN
and wx.EVT_LEFT_DCLICK
events for ZoomBar
.
event – a MouseEvent
event to be processed.
OnLeftUp
(self, event)¶Handles the wx.EVT_LEFT_UP
event for ZoomBar
.
event – a MouseEvent
event to be processed.
OnMotion
(self, event)¶Handles the wx.EVT_MOTION
event for ZoomBar
.
event – a MouseEvent
event to be processed.
OnPaint
(self, event)¶Handles the wx.EVT_PAINT
event for ZoomBar
.
event – a PaintEvent
event to be processed.
OnSize
(self, event)¶Handles the wx.EVT_SIZE
event for ZoomBar
.
event – a wx.SizeEvent
event to be processed.
Reposition
(self, toButton)¶Repositions all the buttons inside the ZoomBar
.
toButton – the button currently hovered by the mouse (and hence zoomed).
SetBarColour
(self, colour)¶Sets the background button bar colour.
colour – an instance of wx.Colour
;
SetButtonSize
(self, size)¶Sets the original button size.
size – the new (not-zoomed) button size, in pixels.
SetCenterZoom
(self, center=True)¶Sets to zoom from the center.
center – if True
button zooms upwards.
SetShowLabels
(self, show)¶Sets whether to show button labels or not.
show – True
to show button labels, False
otherwise.
SetShowReflections
(self, show)¶Sets whether to show reflections or not.
show – True
to show reflections, False
otherwise.
SetZoomFactor
(self, zoom)¶Sets the zoom factor for all the buttons. Larger number gives a greater zoom effect.
zoom – a floating point number, greater than or equal to 1.0.