X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d69225772ad1ff3952a3ee74055dc93f85c13812..eb3efe0d4b8a0964cd0504a69c0e9540c18e390c:/wxPython/wx/lib/foldpanelbar.py diff --git a/wxPython/wx/lib/foldpanelbar.py b/wxPython/wx/lib/foldpanelbar.py index 4cc6c907e2..66a5ab2a15 100644 --- a/wxPython/wx/lib/foldpanelbar.py +++ b/wxPython/wx/lib/foldpanelbar.py @@ -3,7 +3,7 @@ # Ported From Jorgen Bodde & Julian Smart (Extended Demo) C++ Code By: # # Andrea Gavana, @ 23 Mar 2005 -# Latest Revision: 28 Mar 2005, 22.30 CET +# Latest Revision: 05 Nov 2005, 23.30 CET # # # TODO List @@ -30,9 +30,14 @@ # TODO: A Smart Way To Check Wether The Old - New Width Of The # Panel Changed, If So No Need To Resize The Fold Panel Items # -# 5. Implementing Styles Like FPB_SINGLE_FOLD and FPB_EXCLUSIVE_FOLD -# TODO: Jorgen Has Left Undone These Jobs. I Don't Really Get What They -# Should Supposed To Do, So If Someone Could Enlight Me, Please Let Me Know. +# +# DONE List: +# +# 1. Implemented Styles Like FPB_SINGLE_FOLD and FPB_EXCLUSIVE_FOLD +# Thanks To E. A. Tacao For His Nice Suggestions. +# +# 2. Added Some Maquillage To FoldPanelBar: When The Mouse Enters The Icon +# Region, It Is Changed To wx.CURSOR_HAND. # # # For The Original TODO List From Jorgen, Please Refer To: @@ -106,7 +111,7 @@ FoldPanelBar is supported on the following platforms: * Mac OSX (Thanks To Robin Dunn For The CaptionBar Size Patch) -Latest Revision: Andrea Gavana @ 30 Mar 2005, 22.30 CET +Latest Revision: Andrea Gavana @ 05 Nov 2005, 23.30 CET """ @@ -179,7 +184,7 @@ FPB_EXTRA_Y = 4 # pixels of the bmp to be aligned from the right filled with space FPB_BMP_RIGHTSPACE = 2 -# Not yet supported but added for future reference. Single fold forces +# Now supported! Single fold forces # other panels to close when they are open, and only opens the current panel. # This will allow the open panel to gain the full size left in the client area FPB_SINGLE_FOLD = 0x0001 @@ -188,9 +193,9 @@ FPB_SINGLE_FOLD = 0x0001 # show up at the top FPB_COLLAPSE_TO_BOTTOM = 0x0002 -# Not yet supported, but added for future reference. Single fold plus panels +# Now supported! Single fold plus panels # will be stacked at the bottom -FPB_EXCLUSIVE_FOLD = FPB_SINGLE_FOLD | FPB_COLLAPSE_TO_BOTTOM +FPB_EXCLUSIVE_FOLD = 0x0004 # Orientation Flag FPB_HORIZONTAL = wx.HORIZONTAL @@ -669,12 +674,13 @@ class CaptionBar(wx.Window): dc = wx.PaintDC(self) wndRect = self.GetRect() vertical = self.IsVertical() - + # TODO: Maybe first a memory DC should draw all, and then paint it on # the caption. This way a flickering arrow during resize is not visible self.FillCaptionBackground(dc) dc.SetFont(self._style.GetCaptionFont()) + dc.SetTextForeground(self._style.GetCaptionColour()) if vertical: dc.DrawText(self._caption, 4, FPB_EXTRA_Y/2) @@ -734,27 +740,52 @@ class CaptionBar(wx.Window): """ Catches the mouse click-double click. - If clicked on the arrow (single) or double on the caption we - change state and an event must be fired to let this panel - collapse or expand. + If clicked on the arrow (single) or double on the caption we change state + and an event must be fired to let this panel collapse or expand. """ - - send_event = False + send_event = False + vertical = self.IsVertical() + if event.LeftDown() and self._foldIcons: pt = event.GetPosition() rect = self.GetRect() - vertical = self.IsVertical() - + drw = (rect.GetWidth() - self._iconWidth - self._rightIndent) if vertical and pt.x > drw or not vertical and \ pt.y < (self._iconHeight + self._rightIndent): send_event = True elif event.LeftDClick(): + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) send_event = True + elif event.Entering() and self._foldIcons: + pt = event.GetPosition() + rect = self.GetRect() + + drw = (rect.GetWidth() - self._iconWidth - self._rightIndent) + if vertical and pt.x > drw or not vertical and \ + pt.y < (self._iconHeight + self._rightIndent): + self.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) + else: + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + + elif event.Leaving(): + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + + elif event.Moving(): + pt = event.GetPosition() + rect = self.GetRect() + + drw = (rect.GetWidth() - self._iconWidth - self._rightIndent) + if vertical and pt.x > drw or not vertical and \ + pt.y < (self._iconHeight + self._rightIndent): + self.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) + else: + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + # send the collapse, expand event to the parent if send_event: @@ -1172,7 +1203,7 @@ class FoldPanelBar(wx.Panel): self._foldPanel.SetSize(foldrect[2:]) - if self._extraStyle & FPB_COLLAPSE_TO_BOTTOM: + if self._extraStyle & FPB_COLLAPSE_TO_BOTTOM or self._extraStyle & FPB_EXCLUSIVE_FOLD: rect = self.RepositionCollapsedToBottom() vertical = self.IsVertical() if vertical and rect.GetHeight() > 0 or not vertical and rect.GetWidth() > 0: @@ -1212,7 +1243,7 @@ class FoldPanelBar(wx.Panel): # should be drawn at the bottom. All panels that are expanded # are drawn on top. The last expanded panel gets all the extra space - if self._extraStyle & FPB_COLLAPSE_TO_BOTTOM: + if self._extraStyle & FPB_COLLAPSE_TO_BOTTOM or self._extraStyle & FPB_EXCLUSIVE_FOLD: offset = 0 @@ -1353,9 +1384,22 @@ class FoldPanelBar(wx.Panel): the bottom and the order where the panel originally was placed is restored. """ + + fpbextrastyle = 0 + if self._extraStyle & FPB_SINGLE_FOLD or self._extraStyle & FPB_EXCLUSIVE_FOLD: + fpbextrastyle = 1 + for panel in self._panels: + panel.Collapse() + foldpanel.Expand() - self.RefreshPanelsFrom(foldpanel) + + if fpbextrastyle: + if self._extraStyle & FPB_EXCLUSIVE_FOLD: + self.RepositionCollapsedToBottom() + self.RefreshPanelsFrom(self._panels[0]) + else: + self.RefreshPanelsFrom(foldpanel) def ApplyCaptionStyle(self, foldpanel, cbstyle):