AGW Logo

agw_title ZoomBar

ZoomBar is a class that appoximatively mimics the behaviour of the Mac Dock, inside a wx.Panel.

This is the main class implementation.

hierarchy Inheritance Diagram

Inheritance diagram for: ZoomBar

Inheritance diagram of ZoomBar


appearance Control Appearance


ZoomBar

ZoomBar


method_summary Methods Summary

__init__Default class constructor.
AddButtonAdds a button to ZoomBar.
AddSeparatorAdds a separator to ZoomBar.
DoGetBestSizeGets the size which best suits the window: for a control, it would be the
DoLayoutCommon method to re-layout ZoomBar.
DrawButtonsDraws all the main button bitmaps on the ZoomBar client window.
DrawLabelsDraws all the button labels on the ZoomBar client window.
DrawReflectionsDraws all the reflection button bitmaps on the ZoomBar client window.
EnableButtonEnables/disables the button at position index.
GetBarColourReturns the background button bar colour.
GetButtonSizeReturns the original (not zoomed) button size, in pixels.
GetCenterZoomReturns True if buttons zoom upwards.
GetShowLabelsReturns True if button labels are currently shown.
GetShowReflectionsReturns True if reflections bitmap are currently shown.
GetZoomFactorReturns the current zoom factor.
HitTestHitTest method for ZoomBar.
InitialRepositionSets up the initial buttons and sizes them from the center.
IsButtonEnabledReturns True if the button at position index is enabled, False
OnEraseBackgroundHandles the wx.EVT_ERASE_BACKGROUND event for ZoomBar.
OnLeaveWindowHandles the wx.EVT_LEAVE_WINDOW event for ZoomBar.
OnLeftDownHandles the wx.EVT_LEFT_DOWN and wx.EVT_LEFT_DCLICK events for ZoomBar.
OnLeftUpHandles the wx.EVT_LEFT_UP event for ZoomBar.
OnMotionHandles the wx.EVT_MOTION event for ZoomBar.
OnPaintHandles the wx.EVT_PAINT event for ZoomBar.
OnSizeHandles the wx.EVT_SIZE event for ZoomBar.
RepositionRepositions all the buttons inside the ZoomBar.
ResetSizeResets all the button sizes and positions, recalculating the optimal ZoomBar
SetBarColourSets the background button bar colour.
SetButtonSizeSets the original button size.
SetCenterZoomSets to zoom from the center.
SetShowLabelsSets whether to show button labels or not.
SetShowReflectionsSets whether to show reflections or not.
SetZoomFactorSets the zoom factor for all the buttons.
SnapToBottomSnaps the background button bar bitmap and all the buttons to the bottom

API Class API

class ZoomBar(wx.PyControl)[source]

ZoomBar is a class that appoximatively mimics the behaviour of the Mac Dock, inside a wx.Panel.

This is the main class implementation.



__init__(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, name="ZoomBar")[source]

Default class constructor.

Parameters:
  • 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(normalBmp, reflectionBmp=wx.NullBitmap, label="", disabledBmp=wx.NullBitmap, disabledReflectionBmp=wx.NullBitmap)[source]

Adds a button to ZoomBar.

Parameters:
  • 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.



AddSeparator(normalBmp, reflectionBmp=wx.NullBitmap)[source]

Adds a separator to ZoomBar.

Parameters:
  • normalBmp – the separator main bitmap, an instance of wx.Bitmap;

  • reflectionBmp – a bitmap representing a reflection of the main bitmap, an instance of wx.Bitmap.



DoGetBestSize()[source]

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.PyControl.



DoLayout()[source]

Common method to re-layout ZoomBar.



DrawButtons(dc)[source]

Draws all the main button bitmaps on the ZoomBar client window.

Parameters:dc – an instance of wx.DC.


DrawLabels(dc)[source]

Draws all the button labels on the ZoomBar client window.

Parameters:dc – an instance of wx.DC.



DrawReflections(dc)[source]

Draws all the reflection button bitmaps on the ZoomBar client window.

Parameters:dc – an instance of wx.DC.



EnableButton(index, enable=True)[source]

Enables/disables the button at position index.

Parameters:
  • index – the index of the button to enable/disable;
  • enableTrue to enable the button, False to disable it.


GetBarColour()[source]

Returns the background button bar colour.



GetButtonSize()[source]

Returns the original (not zoomed) button size, in pixels.



GetCenterZoom()[source]

Returns True if buttons zoom upwards.



GetShowLabels()[source]

Returns True if button labels are currently shown.



GetShowReflections()[source]

Returns True if reflections bitmap are currently shown.



GetZoomFactor()[source]

Returns the current zoom factor.



HitTest(pos)[source]

HitTest method for ZoomBar.

Parameters:pos – the current mouse position.
Returns:an index representing the button on which the mouse is hovering, or wx.NOT_FOUND if no button has been hit.


InitialReposition()[source]

Sets up the initial buttons and sizes them from the center.



IsButtonEnabled(index)[source]

Returns True if the button at position index is enabled, False otherwise.

Parameters:index – the index of the button to check.


OnEraseBackground(event)[source]

Handles the wx.EVT_ERASE_BACKGROUND event for ZoomBar.

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

Note

This method is intentionally empty to avoid flicker.



OnLeaveWindow(event)[source]

Handles the wx.EVT_LEAVE_WINDOW event for ZoomBar.

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


OnLeftDown(event)[source]

Handles the wx.EVT_LEFT_DOWN and wx.EVT_LEFT_DCLICK events for ZoomBar.

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



OnLeftUp(event)[source]

Handles the wx.EVT_LEFT_UP event for ZoomBar.

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



OnMotion(event)[source]

Handles the wx.EVT_MOTION event for ZoomBar.

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



OnPaint(event)[source]

Handles the wx.EVT_PAINT event for ZoomBar.

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


OnSize(event)[source]

Handles the wx.EVT_SIZE event for ZoomBar.

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


Reposition(toButton)[source]

Repositions all the buttons inside the ZoomBar.

Parameters:toButton – the button currently hovered by the mouse (and hence zoomed).


ResetSize()[source]

Resets all the button sizes and positions, recalculating the optimal ZoomBar size.



SetBarColour(colour)[source]

Sets the background button bar colour.

Parameters:colour – an instance of wx.Colour;


SetButtonSize(size)[source]

Sets the original button size.

Parameters:size – the new (not-zoomed) button size, in pixels.


SetCenterZoom(center=True)[source]

Sets to zoom from the center.

Parameters:center – if True button zooms upwards.


SetShowLabels(show)[source]

Sets whether to show button labels or not.

Parameters:showTrue to show button labels, False otherwise.


SetShowReflections(show)[source]

Sets whether to show reflections or not.

Parameters:showTrue to show reflections, False otherwise.


SetZoomFactor(zoom)[source]

Sets the zoom factor for all the buttons. Larger number gives a greater zoom effect.

Parameters:zoom – a floating point number, greater than or equal to 1.0.


SnapToBottom(size)[source]

Snaps the background button bar bitmap and all the buttons to the bottom of ZoomBar.

Parameters:size – the current ZoomBar size.
Tree

Table Of Contents

Previous topic

ImageBar

Next topic

ZoomBarEvent