def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): RibbonControl.__init__(self, parent, id, pos, size, style=wx.BORDER_NONE) self._layouts_valid = False self.CommonInit(style) self.SetExtraStyle(wx.WS_EX_PROCESS_UI_UPDATES) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
def __init__(self, parent, id=wx.ID_ANY, label="", icon=wx.NullBitmap, style=0): """ Default class constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `label`: Label of the new button; :param `icon`: the icon used for the page in the ribbon bar tab area; :param `style`: Window style. """ RibbonControl.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, wx.BORDER_NONE) self.CommonInit(label, icon) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__(self, parent, id=wx.ID_ANY, label="", icon=wx.NullBitmap, style=0): """ Default class constructor. :param `parent`: pointer to a parent window, an instance of :class:`~lib.agw.ribbon.bar.RibbonBar`; :param `id`: window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `label`: label to be used in the :class:`~lib.agw.ribbon.bar.RibbonBar`'s tab list for this page (if the ribbon bar is set to display labels); :param `icon`: the icon used for the page in the ribbon bar tab area (if the ribbon bar is set to display icons); :param `style`: window style. Currently unused, should be zero. """ RibbonControl.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, wx.BORDER_NONE) self.CommonInit(label, icon) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=0): """ Default class constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `agwStyle`: the AGW-specific window style. """ RibbonControl.__init__(self, parent, id, pos, size, style=wx.BORDER_NONE) self._layouts_valid = False self.CommonInit(agwStyle) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
def __init__(self, sibling, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): RibbonControl.__init__(self, sibling.GetParent(), id, pos, size, style=wx.BORDER_NONE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self._sibling = sibling self._flags = (style & RIBBON_SCROLL_BTN_DIRECTION_MASK ) | RIBBON_SCROLL_BTN_FOR_PAGE self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_PAINT, self.OnPaint)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="RibbonToolBar"): """ Default class constructor. :param `parent`: pointer to a parent window, typically a :class:`~lib.agw.ribbon.panel.RibbonPanel`; :param `id`: window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `pos`: window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `style`: window style, currently unused. :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(style)
def __init__(self, parent, id=wx.ID_ANY, label="", minimised_icon=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=RIBBON_PANEL_DEFAULT_STYLE, name="RibbonPanel"): RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.CommonInit(label, minimised_icon, style) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=RIBBON_BAR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="RibbonBar"): RibbonControl.__init__(self, parent, id, pos, size, style=wx.NO_BORDER) self._flags = 0 self._tabs_total_width_ideal = 0 self._tabs_total_width_minimum = 0 self._tab_margin_left = 0 self._tab_margin_right = 0 self._tab_height = 0 self._tab_scroll_amount = 0 self._current_page = -1 self._current_hovered_page = -1 self._tab_scroll_left_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_right_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_buttons_shown = False self._pages = [] self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMouseMiddleDown) self.Bind(wx.EVT_MIDDLE_UP, self.OnMouseMiddleUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(style)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="RibbonToolbar"): RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(style)
def __init__(self, parent, id=wx.ID_ANY, label="", icon=wx.NullBitmap, style=0): RibbonControl.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, wx.BORDER_NONE) self.CommonInit(label, icon) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__(self, parent, id=wx.ID_ANY, label="", minimised_icon=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=RIBBON_PANEL_DEFAULT_STYLE, name="RibbonPanel"): """ Default class constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `label`: Label of the new button; :param `minimised_icon`: the bitmap to be used in place of the panel children when it is minimised; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `agwStyle`: the AGW-specific window style. This can be one of the following bits: ================================= =========== ================================= Window Styles Hex Value Description ================================= =========== ================================= ``RIBBON_PANEL_DEFAULT_STYLE`` 0x0 Defined as no other flags set. ``RIBBON_PANEL_NO_AUTO_MINIMISE`` 0x1 Prevents the panel from automatically minimising to conserve screen space. ``RIBBON_PANEL_EXT_BUTTON`` 0x8 Causes an extension button to be shown in the panel's chrome (if the bar in which it is contained has ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` set). The behaviour of this button is application controlled, but typically will show an extended drop-down menu relating to the panel. ``RIBBON_PANEL_MINIMISE_BUTTON`` 0x10 Causes a (de)minimise button to be shown in the panel's chrome (if the bar in which it is contained has the ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` style set). This flag is typically combined with ``RIBBON_PANEL_NO_AUTO_MINIMISE`` to make a panel which the user always has manual control over when it minimises. ================================= =========== ================================= :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.CommonInit(label, minimised_icon, agwStyle) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__( self, parent, id=wx.ID_ANY, label="", minimised_icon=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=RIBBON_PANEL_DEFAULT_STYLE, name="RibbonPanel", ): """ Default class constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `label`: Label of the new button; :param `minimised_icon`: the bitmap to be used in place of the panel children when it is minimised; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `agwStyle`: the AGW-specific window style. This can be one of the following bits: ================================= =========== ================================= Window Styles Hex Value Description ================================= =========== ================================= ``RIBBON_PANEL_DEFAULT_STYLE`` 0x0 Defined as no other flags set. ``RIBBON_PANEL_NO_AUTO_MINIMISE`` 0x1 Prevents the panel from automatically minimising to conserve screen space. ``RIBBON_PANEL_EXT_BUTTON`` 0x8 Causes an extension button to be shown in the panel's chrome (if the bar in which it is contained has ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` set). The behaviour of this button is application controlled, but typically will show an extended drop-down menu relating to the panel. ``RIBBON_PANEL_MINIMISE_BUTTON`` 0x10 Causes a (de)minimise button to be shown in the panel's chrome (if the bar in which it is contained has the ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` style set). This flag is typically combined with ``RIBBON_PANEL_NO_AUTO_MINIMISE`` to make a panel which the user always has manual control over when it minimises. ================================= =========== ================================= :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.CommonInit(label, minimised_icon, agwStyle) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def __init__(self, sibling, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): RibbonControl.__init__(self, sibling.GetParent(), id, pos, size, style=wx.BORDER_NONE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self._sibling = sibling self._flags = (style & RIBBON_SCROLL_BTN_DIRECTION_MASK) | RIBBON_SCROLL_BTN_FOR_PAGE self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_PAINT, self.OnPaint)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=RIBBON_BAR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="RibbonBar"): """ Default constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `style`: Window style; :param `validator`: the window validator; :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, style=wx.NO_BORDER) self._flags = 0 self._tabs_total_width_ideal = 0 self._tabs_total_width_minimum = 0 self._tab_margin_left = 0 self._tab_margin_right = 0 self._tab_height = 0 self._tab_scroll_amount = 0 self._current_page = -1 self._current_hovered_page = -1 self._tab_scroll_left_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_right_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_buttons_shown = False self._pages = [] self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMouseMiddleDown) self.Bind(wx.EVT_MIDDLE_UP, self.OnMouseMiddleUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(style)
def TryAfter(self, event): if self._expanded_dummy and self.ShouldSendEventToDummy(event): propagateOnce = wx.PropagateOnce(event) return self._expanded_dummy.GetEventHandler().ProcessEvent(event) else: return RibbonControl.TryAfter(self, event)
def RemoveChild(self, child): # Remove all references to the child from the collapse stack count = len(self._collapse_stack) src = dst = 0 while 1: item = self._collapse_stack[src] if item == child: src += 1 if src == count: break if src != dst: self._collapse_stack[dst] = item src += 1 dst += 1 if src == count: break if src > dst: self._collapse_stack = self._collapse_stack[ 0:dst] + self._collapse_stack[src:] # ... and then proceed as normal RibbonControl.RemoveChild(self, child)
def Show(self, show=True): if self._scroll_left_btn: self._scroll_left_btn.Show(show) if self._scroll_right_btn: self._scroll_right_btn.Show(show) return RibbonControl.Show(self, show)
def DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO): """ Sets the size of the window in pixels. :param integer `x`: required `x` position in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `y`: required `y` position in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `width`: required width in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `height`: required height in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `sizeFlags`: indicates the interpretation of other parameters. It is a bit list of the following: * ``wx.SIZE_AUTO_WIDTH``: a ``wx.DefaultCoord`` width value is taken to indicate a wxPython-supplied default width. * ``wx.SIZE_AUTO_HEIGHT``: a ``wx.DefaultCoord`` height value is taken to indicate a wxPython-supplied default height. * ``wx.SIZE_AUTO``: ``wx.DefaultCoord`` size values are taken to indicate a wxPython-supplied default size. * ``wx.SIZE_USE_EXISTING``: existing dimensions should be used if ``wx.DefaultCoord`` values are supplied. * ``wx.SIZE_ALLOW_MINUS_ONE``: allow negative dimensions (i.e. value of ``wx.DefaultCoord``) to be interpreted as real dimensions, not default values. * ``wx.SIZE_FORCE``: normally, if the position and the size of the window are already the same as the parameters of this function, nothing is done. but with this flag a window resize may be forced even in this case (supported in wx 2.6.2 and later and only implemented for MSW and ignored elsewhere currently). """ # When a resize triggers the scroll buttons to become visible, the page is resized. # This resize from within a resize event can cause (MSW) wxWidgets some confusion, # and report the 1st size to the 2nd size event. Hence the most recent size is # remembered internally and used in Layout() where appropiate. if self.GetMajorAxis() == wx.HORIZONTAL: self._size_in_major_axis_for_children = width if self._scroll_buttons_visible: if self._scroll_left_btn: self._size_in_major_axis_for_children += self._scroll_left_btn.GetSize( ).GetWidth() if self._scroll_right_btn: self._size_in_major_axis_for_children += self._scroll_right_btn.GetSize( ).GetWidth() else: self._size_in_major_axis_for_children = height if self._scroll_buttons_visible: if self._scroll_left_btn: self._size_in_major_axis_for_children += self._scroll_left_btn.GetSize( ).GetHeight() if self._scroll_right_btn: self._size_in_major_axis_for_children += self._scroll_right_btn.GetSize( ).GetHeight() RibbonControl.DoSetSize(self, x, y, width, height, sizeFlags)
def AddChild(self, child): RibbonControl.AddChild(self, child) # Window enter / leave events count for only the window in question, not # for children of the window. The panel wants to be in the hovered state # whenever the mouse cursor is within its boundary, so the events need to # be attached to children too. child.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnterChild) child.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeaveChild)
def RemoveChild(self, child): """ Remove all references to the child from the collapse stack. """ try: self._collapse_stack.remove(child) except ValueError: pass # ... and then proceed as normal RibbonControl.RemoveChild(self, child)
def DoGetBestSize(self): # TODO: Ask sizer # Common case of no sizer and single child taking up the entire panel if len(self.GetChildren()) == 1: child = self.GetChildren()[0] dc = wx.ClientDC(self) return self._art.GetPanelSize(dc, self, wx.Size(*child.GetBestSize()), None) return wx.Size(*RibbonControl.DoGetBestSize(self))
def __init__( self, parent, id=wx.ID_ANY, label="", minimised_icon=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=RIBBON_PANEL_DEFAULT_STYLE, name="RibbonPanel", ): """ Default class constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `label`: Label of the new button; :param `minimised_icon`: the bitmap to be used in place of the panel children when it is minimised; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `style`: Window style; :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, wx.BORDER_NONE, name=name) self.CommonInit(label, minimised_icon, style) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnSize)
def DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO): # When a resize triggers the scroll buttons to become visible, the page is resized. # This resize from within a resize event can cause (MSW) wxWidgets some confusion, # and report the 1st size to the 2nd size event. Hence the most recent size is # remembered internally and used in Layout() where appropiate. if self.GetMajorAxis() == wx.HORIZONTAL: self._size_in_major_axis_for_children = width else: self._size_in_major_axis_for_children = height RibbonControl.DoSetSize(self, x, y, width, height, sizeFlags)
def GetMinNotMinimisedSize(self): # Ask sizer if present if self.GetSizer(): dc = wx.ClientDC(self) return self._art.GetPanelSize(dc, self, wx.Size(*self.GetPanelSizerMinSize()), None) # Common case of no sizer and single child taking up the entire panel elif len(self.GetChildren()) == 1: child = self.GetChildren()[0] dc = wx.ClientDC(self) return self._art.GetPanelSize(dc, self, wx.Size(*child.GetMinSize()), None) return wx.Size(*RibbonControl.GetMinSize(self))
def SetArtProvider(self, art): if art == self._art: return RibbonControl.SetArtProvider(self, art) temp_dc = wx.ClientDC(self) for base in self._buttons: self.FetchButtonSizeInfo(base, RIBBON_BUTTONBAR_BUTTON_SMALL, temp_dc) self.FetchButtonSizeInfo(base, RIBBON_BUTTONBAR_BUTTON_MEDIUM, temp_dc) self.FetchButtonSizeInfo(base, RIBBON_BUTTONBAR_BUTTON_LARGE, temp_dc) self._layouts_valid = False self.Realize()
def DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO): """ Sets the size of the window in pixels. :param integer `x`: required `x` position in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `y`: required `y` position in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `width`: required width in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `height`: required height in pixels, or ``wx.DefaultCoord`` to indicate that the existing value should be used; :param integer `sizeFlags`: indicates the interpretation of other parameters. It is a bit list of the following: * ``wx.SIZE_AUTO_WIDTH``: a ``wx.DefaultCoord`` width value is taken to indicate a wxPython-supplied default width. * ``wx.SIZE_AUTO_HEIGHT``: a ``wx.DefaultCoord`` height value is taken to indicate a wxPython-supplied default height. * ``wx.SIZE_AUTO``: ``wx.DefaultCoord`` size values are taken to indicate a wxPython-supplied default size. * ``wx.SIZE_USE_EXISTING``: existing dimensions should be used if ``wx.DefaultCoord`` values are supplied. * ``wx.SIZE_ALLOW_MINUS_ONE``: allow negative dimensions (i.e. value of ``wx.DefaultCoord``) to be interpreted as real dimensions, not default values. * ``wx.SIZE_FORCE``: normally, if the position and the size of the window are already the same as the parameters of this function, nothing is done. but with this flag a window resize may be forced even in this case (supported in wx 2.6.2 and later and only implemented for MSW and ignored elsewhere currently). """ # At least on MSW, changing the size of a window will cause GetSize() to # report the new size, but a size event may not be handled immediately. # If self minimised check was performed in the OnSize handler, then # GetSize() could return a size much larger than the minimised size while # IsMinimised() returns True. This would then affect layout, as the panel # will refuse to grow any larger while in limbo between minimised and non. minimised = (self._flags & RIBBON_PANEL_NO_AUTO_MINIMISE) == 0 and self.IsMinimised(wx.Size(width, height)) if minimised != self._minimised: self._minimised = minimised for child in self.GetChildren(): child.Show(not minimised) self.Refresh() RibbonControl.DoSetSize(self, x, y, width, height, sizeFlags)
def DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO): # At least on MSW, changing the size of a window will cause GetSize() to # report the new size, but a size event may not be handled immediately. # If self minimised check was performed in the OnSize handler, then # GetSize() could return a size much larger than the minimised size while # IsMinimised() returns True. This would then affect layout, as the panel # will refuse to grow any larger while in limbo between minimised and non. minimised = (self._flags & RIBBON_PANEL_NO_AUTO_MINIMISE) == 0 and self.IsMinimised(wx.Size(width, height)) if minimised != self._minimised: self._minimised = minimised for child in self.GetChildren(): child.Show(not minimised) self.Refresh() RibbonControl.DoSetSize(self, x, y, width, height, sizeFlags)
def 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()`. :return: An instance of :class:`Size`. :note: Overridden from :class:`PyControl`. """ # Ask sizer if present if self.GetSizer(): dc = wx.ClientDC(self) return self._art.GetPanelSize(dc, self, wx.Size(*self.GetPanelSizerBestSize()), None) # Common case of no sizer and single child taking up the entire panel elif len(self.GetChildren()) == 1: child = self.GetChildren()[0] dc = wx.ClientDC(self) return self._art.GetPanelSize(dc, self, wx.Size(*child.GetBestSize()), None) return wx.Size(*RibbonControl.DoGetBestSize(self))
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=RIBBON_BAR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="RibbonBar"): """ Default constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `agwStyle`: the AGW-specific window style. This can be a combination of the following bits: ========================================== =========== ========================================== Window Styles Hex Value Description ========================================== =========== ========================================== ``RIBBON_BAR_DEFAULT_STYLE`` 0x9 Defined as ``RIBBON_BAR_FLOW_HORIZONTAL`` | ``RIBBON_BAR_SHOW_PAGE_LABELS`` | ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` ``RIBBON_BAR_FOLDBAR_STYLE`` 0x1e Defined as ``RIBBON_BAR_FLOW_VERTICAL`` | ``RIBBON_BAR_SHOW_PAGE_ICONS`` | ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` | ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` ``RIBBON_BAR_SHOW_PAGE_LABELS`` 0x1 Causes labels to be shown on the tabs in the ribbon bar. ``RIBBON_BAR_SHOW_PAGE_ICONS`` 0x2 Causes icons to be shown on the tabs in the ribbon bar. ``RIBBON_BAR_FLOW_HORIZONTAL`` 0x0 Causes panels within pages to stack horizontally. ``RIBBON_BAR_FLOW_VERTICAL`` 0x4 Causes panels within pages to stack vertically. ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` 0x8 Causes extension buttons to be shown on panels (where the panel has such a button). ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` 0x10 Causes minimise buttons to be shown on panels (where the panel has such a button). ========================================== =========== ========================================== :param `validator`: the window validator; :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, style=wx.NO_BORDER) self._flags = 0 self._tabs_total_width_ideal = 0 self._tabs_total_width_minimum = 0 self._tab_margin_left = 0 self._tab_margin_right = 0 self._tab_height = 0 self._tab_scroll_amount = 0 self._current_page = -1 self._current_hovered_page = -1 self._tab_scroll_left_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_right_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_buttons_shown = False self._pages = [] self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMouseMiddleDown) self.Bind(wx.EVT_MIDDLE_UP, self.OnMouseMiddleUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(agwStyle)
def RemoveChild(self, child): child.Bind(wx.EVT_ENTER_WINDOW, None) child.Bind(wx.EVT_LEAVE_WINDOW, None) RibbonControl.RemoveChild(self, child)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=RIBBON_BAR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="RibbonBar"): """ Default constructor. :param `parent`: Pointer to a parent window; :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create an identifier; :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython should generate a default position for the window; :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized; :param `agwStyle`: the AGW-specific window style. This can be a combination of the following bits: ========================================== =========== ========================================== Window Styles Hex Value Description ========================================== =========== ========================================== ``RIBBON_BAR_DEFAULT_STYLE`` 0x9 Defined as ``RIBBON_BAR_FLOW_HORIZONTAL`` | ``RIBBON_BAR_SHOW_PAGE_LABELS`` | ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` ``RIBBON_BAR_FOLDBAR_STYLE`` 0x1e Defined as ``RIBBON_BAR_FLOW_VERTICAL`` | ``RIBBON_BAR_SHOW_PAGE_ICONS`` | ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` | ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` ``RIBBON_BAR_SHOW_PAGE_LABELS`` 0x1 Causes labels to be shown on the tabs in the ribbon bar. ``RIBBON_BAR_SHOW_PAGE_ICONS`` 0x2 Causes icons to be shown on the tabs in the ribbon bar. ``RIBBON_BAR_FLOW_HORIZONTAL`` 0x0 Causes panels within pages to stack horizontally. ``RIBBON_BAR_FLOW_VERTICAL`` 0x4 Causes panels within pages to stack vertically. ``RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` 0x8 Causes extension buttons to be shown on panels (where the panel has such a button). ``RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS`` 0x10 Causes minimise buttons to be shown on panels (where the panel has such a button). ========================================== =========== ========================================== :param `validator`: the window validator; :param `name`: the window name. """ RibbonControl.__init__(self, parent, id, pos, size, style=wx.NO_BORDER) self._flags = 0 self._tabs_total_width_ideal = 0 self._tabs_total_width_minimum = 0 self._tab_margin_left = 0 self._tab_margin_right = 0 self._tab_height = 0 self._tab_scroll_amount = 0 self._current_page = -1 self._current_hovered_page = -1 self._tab_scroll_left_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_right_button_state = RIBBON_SCROLL_BTN_NORMAL self._tab_scroll_buttons_shown = False self._arePanelsShown = True self._pages = [] self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) self.Bind(wx.EVT_LEFT_DCLICK, self.OnMouseDoubleClick) self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMouseMiddleDown) self.Bind(wx.EVT_MIDDLE_UP, self.OnMouseMiddleUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp) self.Bind(wx.EVT_SIZE, self.OnSize) self.CommonInit(agwStyle)