1 # --------------------------------------------------------------------------- #
2 # AUI Library wxPython IMPLEMENTATION
4 # Original C++ Code From Kirix (wxAUI). You Can Find It At:
6 # License: wxWidgets license
8 # http:#www.kirix.com/en/community/opensource/wxaui/about_wxaui.html
10 # Current wxAUI Version Tracked: wxWidgets 2.9.0 SVN HEAD
15 # Andrea Gavana, @ 23 Dec 2005
16 # Latest Revision: 10 Mar 2011, 15.00 GMT
18 # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
21 # andrea.gavana@gmail.com
24 # Or, Obviously, To The wxPython Mailing List!!!
27 # --------------------------------------------------------------------------- #
33 framemanager is the central module of the AUI class framework.
35 L{AuiManager} manages the panes associated with it for a particular `wx.Frame`, using
36 a pane's L{AuiPaneInfo} information to determine each pane's docking and floating
37 behavior. AuiManager uses wxPython' sizer mechanism to plan the layout of each frame.
38 It uses a replaceable dock art class to do all drawing, so all drawing is localized
39 in one area, and may be customized depending on an application's specific needs.
41 AuiManager works as follows: the programmer adds panes to the class, or makes
42 changes to existing pane properties (dock position, floating state, show state, etc...).
43 To apply these changes, AuiManager's L{AuiManager.Update} function is called. This batch
44 processing can be used to avoid flicker, by modifying more than one pane at a time,
45 and then "committing" all of the changes at once by calling `Update()`.
47 Panes can be added quite easily::
49 text1 = wx.TextCtrl(self, -1)
50 text2 = wx.TextCtrl(self, -1)
51 self._mgr.AddPane(text1, AuiPaneInfo().Left().Caption("Pane Number One"))
52 self._mgr.AddPane(text2, AuiPaneInfo().Bottom().Caption("Pane Number Two"))
57 Later on, the positions can be modified easily. The following will float an
58 existing pane in a tool window::
60 self._mgr.GetPane(text1).Float()
63 Layers, Rows and Directions, Positions
64 ======================================
66 Inside AUI, the docking layout is figured out by checking several pane parameters.
67 Four of these are important for determining where a pane will end up.
69 **Direction** - Each docked pane has a direction, `Top`, `Bottom`, `Left`, `Right`, or `Center`.
70 This is fairly self-explanatory. The pane will be placed in the location specified
73 **Position** - More than one pane can be placed inside of a "dock". Imagine two panes
74 being docked on the left side of a window. One pane can be placed over another.
75 In proportionally managed docks, the pane position indicates it's sequential position,
76 starting with zero. So, in our scenario with two panes docked on the left side, the
77 top pane in the dock would have position 0, and the second one would occupy position 1.
79 **Row** - A row can allow for two docks to be placed next to each other. One of the most
80 common places for this to happen is in the toolbar. Multiple toolbar rows are allowed,
81 the first row being in row 0, and the second in row 1. Rows can also be used on
82 vertically docked panes.
84 **Layer** - A layer is akin to an onion. Layer 0 is the very center of the managed pane.
85 Thus, if a pane is in layer 0, it will be closest to the center window (also sometimes
86 known as the "content window"). Increasing layers "swallow up" all layers of a lower
87 value. This can look very similar to multiple rows, but is different because all panes
88 in a lower level yield to panes in higher levels. The best way to understand layers
89 is by running the AUI sample (`AUI.py`).
92 __author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
93 __date__ = "31 March 2009"
107 from aui_utilities import Clip, PaneCreateStippleBitmap, GetDockingImage, GetSlidingPoints
109 from aui_constants import *
111 # Define this as a translation function
112 _ = wx.GetTranslation
115 if wx.Platform == "__WXMSW__":
122 # wxPython version string
123 _VERSION_STRING = wx.VERSION_STRING
126 wxEVT_AUI_PANE_BUTTON = wx.NewEventType()
127 wxEVT_AUI_PANE_CLOSE = wx.NewEventType()
128 wxEVT_AUI_PANE_MAXIMIZE = wx.NewEventType()
129 wxEVT_AUI_PANE_RESTORE = wx.NewEventType()
130 wxEVT_AUI_RENDER = wx.NewEventType()
131 wxEVT_AUI_FIND_MANAGER = wx.NewEventType()
132 wxEVT_AUI_PANE_MINIMIZE = wx.NewEventType()
133 wxEVT_AUI_PANE_MIN_RESTORE = wx.NewEventType()
134 wxEVT_AUI_PANE_FLOATING = wx.NewEventType()
135 wxEVT_AUI_PANE_FLOATED = wx.NewEventType()
136 wxEVT_AUI_PANE_DOCKING = wx.NewEventType()
137 wxEVT_AUI_PANE_DOCKED = wx.NewEventType()
138 wxEVT_AUI_PANE_ACTIVATED = wx.NewEventType()
139 wxEVT_AUI_PERSPECTIVE_CHANGED = wx.NewEventType()
141 EVT_AUI_PANE_BUTTON = wx.PyEventBinder(wxEVT_AUI_PANE_BUTTON, 0)
142 """ Fires an event when the user left-clicks on a pane button. """
143 EVT_AUI_PANE_CLOSE = wx.PyEventBinder(wxEVT_AUI_PANE_CLOSE, 0)
144 """ A pane in `AuiManager` has been closed. """
145 EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder(wxEVT_AUI_PANE_MAXIMIZE, 0)
146 """ A pane in `AuiManager` has been maximized. """
147 EVT_AUI_PANE_RESTORE = wx.PyEventBinder(wxEVT_AUI_PANE_RESTORE, 0)
148 """ A pane in `AuiManager` has been restored from a maximized state. """
149 EVT_AUI_RENDER = wx.PyEventBinder(wxEVT_AUI_RENDER, 0)
150 """ Fires an event every time the AUI frame is being repainted. """
151 EVT_AUI_FIND_MANAGER = wx.PyEventBinder(wxEVT_AUI_FIND_MANAGER, 0)
152 """ Used to find which AUI manager is controlling a certain pane. """
153 EVT_AUI_PANE_MINIMIZE = wx.PyEventBinder(wxEVT_AUI_PANE_MINIMIZE, 0)
154 """ A pane in `AuiManager` has been minimized. """
155 EVT_AUI_PANE_MIN_RESTORE = wx.PyEventBinder(wxEVT_AUI_PANE_MIN_RESTORE, 0)
156 """ A pane in `AuiManager` has been restored from a minimized state. """
157 EVT_AUI_PANE_FLOATING = wx.PyEventBinder(wxEVT_AUI_PANE_FLOATING, 0)
158 """ A pane in `AuiManager` is about to be floated. """
159 EVT_AUI_PANE_FLOATED = wx.PyEventBinder(wxEVT_AUI_PANE_FLOATED, 0)
160 """ A pane in `AuiManager` has been floated. """
161 EVT_AUI_PANE_DOCKING = wx.PyEventBinder(wxEVT_AUI_PANE_DOCKING, 0)
162 """ A pane in `AuiManager` is about to be docked. """
163 EVT_AUI_PANE_DOCKED = wx.PyEventBinder(wxEVT_AUI_PANE_DOCKED, 0)
164 """ A pane in `AuiManager` has been docked. """
165 EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder(wxEVT_AUI_PANE_ACTIVATED, 0)
166 """ A pane in `AuiManager` has been activated. """
167 EVT_AUI_PERSPECTIVE_CHANGED = wx.PyEventBinder(wxEVT_AUI_PERSPECTIVE_CHANGED, 0)
168 """ The layout in `AuiManager` has been changed. """
170 # ---------------------------------------------------------------------------- #
172 class AuiDockInfo(object):
173 """ A class to store all properties of a dock. """
177 Default class constructor.
178 Used internally, do not call it in your code!
181 object.__init__(self)
183 self.dock_direction = 0
188 self.resizable = True
191 self.rect = wx.Rect()
197 Returns whether a dock is valid or not.
199 In order to be valid, a dock needs to have a non-zero `dock_direction`.
202 return self.dock_direction != 0
205 def IsHorizontal(self):
206 """ Returns whether the dock is horizontal or not. """
208 return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
211 def IsVertical(self):
212 """ Returns whether the dock is vertical or not. """
214 return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]
217 # ---------------------------------------------------------------------------- #
219 class AuiDockingGuideInfo(object):
220 """ A class which holds information about VS2005 docking guide windows. """
222 def __init__(self, other=None):
224 Default class constructor.
225 Used internally, do not call it in your code!
227 :param `other`: another instance of L{AuiDockingGuideInfo}.
233 # window representing the docking target
235 # dock direction (top, bottom, left, right, center)
236 self.dock_direction = AUI_DOCK_NONE
239 def Assign(self, other):
241 Assigns the properties of the `other` L{AuiDockingGuideInfo} to `self`.
243 :param `other`: another instance of L{AuiDockingGuideInfo}.
246 self.host = other.host
247 self.dock_direction = other.dock_direction
252 Hosts a docking guide window.
254 :param `h`: an instance of L{AuiSingleDockingGuide} or L{AuiCenterDockingGuide}.
262 """ Sets the guide window to left docking. """
264 self.dock_direction = AUI_DOCK_LEFT
269 """ Sets the guide window to right docking. """
271 self.dock_direction = AUI_DOCK_RIGHT
276 """ Sets the guide window to top docking. """
278 self.dock_direction = AUI_DOCK_TOP
283 """ Sets the guide window to bottom docking. """
285 self.dock_direction = AUI_DOCK_BOTTOM
290 """ Sets the guide window to center docking. """
292 self.dock_direction = AUI_DOCK_CENTER
297 """ Sets the guide window to centre docking. """
299 self.dock_direction = AUI_DOCK_CENTRE
303 # ---------------------------------------------------------------------------- #
305 class AuiDockUIPart(object):
306 """ A class which holds attributes for a UI part in the interface. """
320 Default class constructor.
321 Used internally, do not call it in your code!
324 self.orientation = wx.VERTICAL
326 self.rect = wx.Rect()
329 # ---------------------------------------------------------------------------- #
331 class AuiPaneButton(object):
332 """ A simple class which describes the caption pane button attributes. """
334 def __init__(self, button_id):
336 Default class constructor.
337 Used internally, do not call it in your code!
339 :param `button_id`: the pane button identifier.
342 self.button_id = button_id
345 # ---------------------------------------------------------------------------- #
347 # event declarations/classes
349 class AuiManagerEvent(wx.PyCommandEvent):
350 """ A specialized command event class for events sent by L{AuiManager}. """
352 def __init__(self, eventType, id=1):
354 Default class constructor.
356 :param `eventType`: the event kind;
357 :param `id`: the event identification number.
360 wx.PyCommandEvent.__init__(self, eventType, id)
365 self.veto_flag = False
366 self.canveto_flag = True
370 def SetManager(self, mgr):
372 Associates a L{AuiManager} to the current event.
374 :param `mgr`: an instance of L{AuiManager}.
380 def SetDC(self, pdc):
382 Associates a `wx.DC` device context to this event.
384 :param `pdc`: a `wx.DC` device context object.
390 def SetPane(self, p):
392 Associates a L{AuiPaneInfo} instance to this event.
394 :param `p`: a L{AuiPaneInfo} instance.
400 def SetButton(self, b):
402 Associates a L{AuiPaneButton} instance to this event.
404 :param `b`: a L{AuiPaneButton} instance.
410 def GetManager(self):
411 """ Returns the associated L{AuiManager} (if any). """
417 """ Returns the associated `wx.DC` device context (if any). """
423 """ Returns the associated L{AuiPaneInfo} structure (if any). """
429 """ Returns the associated L{AuiPaneButton} instance (if any). """
434 def Veto(self, veto=True):
436 Prevents the change announced by this event from happening.
438 It is in general a good idea to notify the user about the reasons for
439 vetoing the change because otherwise the applications behaviour (which
440 just refuses to do what the user wants) might be quite surprising.
442 :param `veto`: ``True`` to veto the event, ``False`` otherwise.
445 self.veto_flag = veto
449 """ Returns whether the event has been vetoed or not. """
451 return self.veto_flag
454 def SetCanVeto(self, can_veto):
456 Sets whether the event can be vetoed or not.
458 :param `can_veto`: a bool flag. ``True`` if the event can be vetoed, ``False`` otherwise.
461 self.canveto_flag = can_veto
465 """ Returns whether the event can be vetoed and has been vetoed. """
467 return self.canveto_flag and self.veto_flag
470 # ---------------------------------------------------------------------------- #
472 class AuiPaneInfo(object):
474 AuiPaneInfo specifies all the parameters for a pane. These parameters specify where
475 the pane is on the screen, whether it is docked or floating, or hidden. In addition,
476 these parameters specify the pane's docked position, floating position, preferred
477 size, minimum size, caption text among many other parameters.
480 optionFloating = 2**0
482 optionLeftDockable = 2**2
483 optionRightDockable = 2**3
484 optionTopDockable = 2**4
485 optionBottomDockable = 2**5
486 optionFloatable = 2**6
488 optionResizable = 2**8
489 optionPaneBorder = 2**9
490 optionCaption = 2**10
491 optionGripper = 2**11
492 optionDestroyOnClose = 2**12
493 optionToolbar = 2**13
495 optionGripperTop = 2**15
496 optionMaximized = 2**16
497 optionDockFixed = 2**17
498 optionNotebookDockable = 2**18
499 optionMinimized = 2**19
500 optionLeftSnapped = 2**20
501 optionRightSnapped = 2**21
502 optionTopSnapped = 2**22
503 optionBottomSnapped = 2**23
505 optionCaptionLeft = 2**25
508 buttonMaximize = 2**27
509 buttonMinimize = 2**28
512 buttonCustom1 = 2**30
513 buttonCustom2 = 2**31
514 buttonCustom3 = 2**32
516 savedHiddenState = 2**33 # used internally
517 actionPane = 2**34 # used internally
518 wasMaximized = 2**35 # used internally
519 needsRestore = 2**36 # used internally
523 """ Default class constructor. """
528 self.dock_direction = AUI_DOCK_LEFT
532 self.minimize_mode = AUI_MINIMIZE_POS_SMART
533 self.floating_pos = wx.Point(-1, -1)
534 self.floating_size = wx.Size(-1, -1)
535 self.best_size = wx.Size(-1, -1)
536 self.min_size = wx.Size(-1, -1)
537 self.max_size = wx.Size(-1, -1)
538 self.dock_proportion = 0
542 self.icon = wx.NullIcon
543 self.rect = wx.Rect()
544 self.notebook_id = -1
545 self.transparent = 255
546 self.needsTransparency = False
547 self.previousDockPos = None
548 self.previousDockSize = 0
554 def dock_direction_get(self):
556 Getter for the `dock_direction`.
558 :see: L{dock_direction_set} for a set of valid docking directions.
561 if self.IsMaximized():
562 return AUI_DOCK_CENTER
564 return self._dock_direction
567 def dock_direction_set(self, value):
569 Setter for the `dock_direction`.
571 :param `value`: the docking direction. This cab ne one of the following bits:
573 ============================ ======= =============================================
574 Dock Flag Value Description
575 ============================ ======= =============================================
576 ``AUI_DOCK_NONE`` 0 No docking direction.
577 ``AUI_DOCK_TOP`` 1 Top docking direction.
578 ``AUI_DOCK_RIGHT`` 2 Right docking direction.
579 ``AUI_DOCK_BOTTOM`` 3 Bottom docking direction.
580 ``AUI_DOCK_LEFT`` 4 Left docking direction.
581 ``AUI_DOCK_CENTER`` 5 Center docking direction.
582 ``AUI_DOCK_CENTRE`` 5 Centre docking direction.
583 ``AUI_DOCK_NOTEBOOK_PAGE`` 6 Automatic AuiNotebooks docking style.
584 ============================ ======= =============================================
588 self._dock_direction = value
590 dock_direction = property(dock_direction_get, dock_direction_set)
594 Returns ``True`` if the L{AuiPaneInfo} structure is valid.
596 :note: A pane structure is valid if it has an associated window.
599 return self.window != None
602 def IsMaximized(self):
603 """ Returns ``True`` if the pane is maximized. """
605 return self.HasFlag(self.optionMaximized)
608 def IsMinimized(self):
609 """ Returns ``True`` if the pane is minimized. """
611 return self.HasFlag(self.optionMinimized)
615 """ Returns ``True`` if the pane cannot be resized. """
617 return not self.HasFlag(self.optionResizable)
620 def IsResizeable(self):
621 """ Returns ``True`` if the pane can be resized. """
623 return self.HasFlag(self.optionResizable)
627 """ Returns ``True`` if the pane is currently shown. """
629 return not self.HasFlag(self.optionHidden)
632 def IsFloating(self):
633 """ Returns ``True`` if the pane is floating. """
635 return self.HasFlag(self.optionFloating)
639 """ Returns ``True`` if the pane is docked. """
641 return not self.HasFlag(self.optionFloating)
645 """ Returns ``True`` if the pane contains a toolbar. """
647 return self.HasFlag(self.optionToolbar)
650 def IsTopDockable(self):
652 Returns ``True`` if the pane can be docked at the top
653 of the managed frame.
656 return self.HasFlag(self.optionTopDockable)
659 def IsBottomDockable(self):
661 Returns ``True`` if the pane can be docked at the bottom
662 of the managed frame.
665 return self.HasFlag(self.optionBottomDockable)
668 def IsLeftDockable(self):
670 Returns ``True`` if the pane can be docked at the left
671 of the managed frame.
674 return self.HasFlag(self.optionLeftDockable)
677 def IsRightDockable(self):
679 Returns ``True`` if the pane can be docked at the right
680 of the managed frame.
683 return self.HasFlag(self.optionRightDockable)
686 def IsDockable(self):
687 """ Returns ``True`` if the pane can be docked. """
689 return self.IsTopDockable() or self.IsBottomDockable() or self.IsLeftDockable() or \
690 self.IsRightDockable() or self.IsNotebookDockable()
693 def IsFloatable(self):
695 Returns ``True`` if the pane can be undocked and displayed as a
699 return self.HasFlag(self.optionFloatable)
704 Returns ``True`` if the docked frame can be undocked or moved to
705 another dock position.
708 return self.HasFlag(self.optionMovable)
711 def IsDestroyOnClose(self):
713 Returns ``True`` if the pane should be destroyed when it is closed.
715 Normally a pane is simply hidden when the close button is clicked. Calling L{DestroyOnClose}
716 with a ``True`` input parameter will cause the window to be destroyed when the user clicks
717 the pane's close button.
720 return self.HasFlag(self.optionDestroyOnClose)
723 def IsNotebookDockable(self):
725 Returns ``True`` if a pane can be docked on top to another to create a
729 return self.HasFlag(self.optionNotebookDockable)
732 def IsTopSnappable(self):
733 """ Returns ``True`` if the pane can be snapped at the top of the managed frame. """
735 return self.HasFlag(self.optionTopSnapped)
738 def IsBottomSnappable(self):
739 """ Returns ``True`` if the pane can be snapped at the bottom of the managed frame. """
741 return self.HasFlag(self.optionBottomSnapped)
744 def IsLeftSnappable(self):
745 """ Returns ``True`` if the pane can be snapped on the left of the managed frame. """
747 return self.HasFlag(self.optionLeftSnapped)
750 def IsRightSnappable(self):
751 """ Returns ``True`` if the pane can be snapped on the right of the managed frame. """
753 return self.HasFlag(self.optionRightSnapped)
756 def IsSnappable(self):
757 """ Returns ``True`` if the pane can be snapped. """
759 return self.IsTopSnappable() or self.IsBottomSnappable() or self.IsLeftSnappable() or \
760 self.IsRightSnappable()
764 """ Returns ``True`` if the floating pane has a "fly-out" effect. """
766 return self.HasFlag(self.optionFlyOut)
769 def HasCaption(self):
770 """ Returns ``True`` if the pane displays a caption. """
772 return self.HasFlag(self.optionCaption)
775 def HasCaptionLeft(self):
776 """ Returns ``True`` if the pane displays a caption on the left (rotated by 90 degrees). """
778 return self.HasFlag(self.optionCaptionLeft)
781 def HasGripper(self):
782 """ Returns ``True`` if the pane displays a gripper. """
784 return self.HasFlag(self.optionGripper)
788 """ Returns ``True`` if the pane displays a border. """
790 return self.HasFlag(self.optionPaneBorder)
793 def HasCloseButton(self):
794 """ Returns ``True`` if the pane displays a button to close the pane. """
796 return self.HasFlag(self.buttonClose)
799 def HasMaximizeButton(self):
800 """ Returns ``True`` if the pane displays a button to maximize the pane. """
802 return self.HasFlag(self.buttonMaximize)
805 def HasMinimizeButton(self):
806 """ Returns ``True`` if the pane displays a button to minimize the pane. """
808 return self.HasFlag(self.buttonMinimize)
811 def GetMinimizeMode(self):
813 Returns the minimization style for this pane.
815 Possible return values are:
817 ============================== ========= ==============================
818 Minimize Mode Flag Hex Value Description
819 ============================== ========= ==============================
820 ``AUI_MINIMIZE_POS_SMART`` 0x01 Minimizes the pane on the closest tool bar
821 ``AUI_MINIMIZE_POS_TOP`` 0x02 Minimizes the pane on the top tool bar
822 ``AUI_MINIMIZE_POS_LEFT`` 0x03 Minimizes the pane on its left tool bar
823 ``AUI_MINIMIZE_POS_RIGHT`` 0x04 Minimizes the pane on its right tool bar
824 ``AUI_MINIMIZE_POS_BOTTOM`` 0x05 Minimizes the pane on its bottom tool bar
825 ``AUI_MINIMIZE_POS_MASK`` 0x07 Mask to filter the position flags
826 ``AUI_MINIMIZE_CAPT_HIDE`` 0x0 Hides the caption of the minimized pane
827 ``AUI_MINIMIZE_CAPT_SMART`` 0x08 Displays the caption in the best rotation (horizontal or clockwise)
828 ``AUI_MINIMIZE_CAPT_HORZ`` 0x10 Displays the caption horizontally
829 ``AUI_MINIMIZE_CAPT_MASK`` 0x18 Mask to filter the caption flags
830 ============================== ========= ==============================
832 The flags can be filtered with the following masks:
834 ============================== ========= ==============================
835 Minimize Mask Flag Hex Value Description
836 ============================== ========= ==============================
837 ``AUI_MINIMIZE_POS_MASK`` 0x07 Filters the position flags
838 ``AUI_MINIMIZE_CAPT_MASK`` 0x18 Filters the caption flags
839 ============================== ========= ==============================
843 return self.minimize_mode
846 def HasPinButton(self):
847 """ Returns ``True`` if the pane displays a button to float the pane. """
849 return self.HasFlag(self.buttonPin)
852 def HasGripperTop(self):
853 """ Returns ``True`` if the pane displays a gripper at the top. """
855 return self.HasFlag(self.optionGripperTop)
860 Associate a `wx.Window` derived window to this pane.
862 This normally does not need to be specified, as the window pointer is
863 automatically assigned to the L{AuiPaneInfo} structure as soon as it is
864 added to the manager.
866 :param `w`: a `wx.Window` derived window.
873 def Name(self, name):
875 Sets the name of the pane so it can be referenced in lookup functions.
877 If a name is not specified by the user, a random name is assigned to the pane
878 when it is added to the manager.
880 :param `name`: a string specifying the pane name.
882 :warning: If you are using L{AuiManager.SavePerspective} and L{AuiManager.LoadPerspective}, you will have
883 to specify a name for your pane using L{Name}, as randomly generated names can
884 not be properly restored.
891 def Caption(self, caption):
893 Sets the caption of the pane.
895 :param `caption`: a string specifying the pane caption.
898 self.caption = caption
904 Sets the pane dock position to the left side of the frame.
906 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_LEFT`` as
910 self.dock_direction = AUI_DOCK_LEFT
916 Sets the pane dock position to the right side of the frame.
918 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_RIGHT`` as
922 self.dock_direction = AUI_DOCK_RIGHT
928 Sets the pane dock position to the top of the frame.
930 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_TOP`` as
934 self.dock_direction = AUI_DOCK_TOP
940 Sets the pane dock position to the bottom of the frame.
942 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_BOTTOM`` as
946 self.dock_direction = AUI_DOCK_BOTTOM
952 Sets the pane to the center position of the frame.
954 The centre pane is the space in the middle after all border panes (left, top,
955 right, bottom) are subtracted from the layout.
957 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_CENTER`` as
961 self.dock_direction = AUI_DOCK_CENTER
967 Sets the pane to the center position of the frame.
969 The centre pane is the space in the middle after all border panes (left, top,
970 right, bottom) are subtracted from the layout.
972 :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_CENTRE`` as
976 self.dock_direction = AUI_DOCK_CENTRE
980 def Direction(self, direction):
982 Determines the direction of the docked pane. It is functionally the
983 same as calling L{Left}, L{Right}, L{Top} or L{Bottom}, except that docking direction
984 may be specified programmatically via the parameter `direction`.
986 :param `direction`: the direction of the docked pane.
988 :see: L{dock_direction_set} for a list of valid docking directions.
991 self.dock_direction = direction
995 def Layer(self, layer):
997 Determines the layer of the docked pane.
999 The dock layer is similar to an onion, the inner-most layer being layer 0. Each
1000 shell moving in the outward direction has a higher layer number. This allows for
1001 more complex docking layout formation.
1003 :param `layer`: the layer of the docked pane.
1006 self.dock_layer = layer
1012 Determines the row of the docked pane.
1014 :param `row`: the row of the docked pane.
1021 def Position(self, pos):
1023 Determines the position of the docked pane.
1025 :param `pos`: the position of the docked pane.
1032 def MinSize(self, arg1=None, arg2=None):
1034 Sets the minimum size of the pane.
1036 This method is split in 2 versions depending on the input type. If `arg1` is
1037 a `wx.Size` object, then L{MinSize1} is called. Otherwise, L{MinSize2} is called.
1039 :param `arg1`: a `wx.Size` object, a (x, y) tuple or or a `x` coordinate.
1040 :param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
1043 if isinstance(arg1, wx.Size):
1044 ret = self.MinSize1(arg1)
1045 elif isinstance(arg1, types.TupleType):
1046 ret = self.MinSize1(wx.Size(*arg1))
1048 ret = self.MinSize2(arg1, arg2)
1053 def MinSize1(self, size):
1055 Sets the minimum size of the pane.
1057 :see: L{MinSize} for an explanation of input parameters.
1059 self.min_size = size
1063 def MinSize2(self, x, y):
1065 Sets the minimum size of the pane.
1067 :see: L{MinSize} for an explanation of input parameters.
1070 self.min_size = wx.Size(x, y)
1074 def MaxSize(self, arg1=None, arg2=None):
1076 Sets the maximum size of the pane.
1078 This method is split in 2 versions depending on the input type. If `arg1` is
1079 a `wx.Size` object, then L{MaxSize1} is called. Otherwise, L{MaxSize2} is called.
1081 :param `arg1`: a `wx.Size` object, a (x, y) tuple or a `x` coordinate.
1082 :param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
1085 if isinstance(arg1, wx.Size):
1086 ret = self.MaxSize1(arg1)
1087 elif isinstance(arg1, types.TupleType):
1088 ret = self.MaxSize1(wx.Size(*arg1))
1090 ret = self.MaxSize2(arg1, arg2)
1095 def MaxSize1(self, size):
1097 Sets the maximum size of the pane.
1099 :see: L{MaxSize} for an explanation of input parameters.
1102 self.max_size = size
1106 def MaxSize2(self, x, y):
1108 Sets the maximum size of the pane.
1110 :see: L{MaxSize} for an explanation of input parameters.
1113 self.max_size.Set(x,y)
1117 def BestSize(self, arg1=None, arg2=None):
1119 Sets the ideal size for the pane. The docking manager will attempt to use
1120 this size as much as possible when docking or floating the pane.
1122 This method is split in 2 versions depending on the input type. If `arg1` is
1123 a `wx.Size` object, then L{BestSize1} is called. Otherwise, L{BestSize2} is called.
1125 :param `arg1`: a `wx.Size` object, a (x, y) tuple or a `x` coordinate.
1126 :param `arg2`: a `y` coordinate (only if `arg1` is a `x` coordinate, otherwise unused).
1129 if isinstance(arg1, wx.Size):
1130 ret = self.BestSize1(arg1)
1131 elif isinstance(arg1, types.TupleType):
1132 ret = self.BestSize1(wx.Size(*arg1))
1134 ret = self.BestSize2(arg1, arg2)
1139 def BestSize1(self, size):
1141 Sets the best size of the pane.
1143 :see: L{BestSize} for an explanation of input parameters.
1146 self.best_size = size
1150 def BestSize2(self, x, y):
1152 Sets the best size of the pane.
1154 :see: L{BestSize} for an explanation of input parameters.
1157 self.best_size.Set(x,y)
1161 def FloatingPosition(self, pos):
1163 Sets the position of the floating pane.
1165 :param `pos`: a `wx.Point` or a tuple indicating the pane floating position.
1168 self.floating_pos = wx.Point(*pos)
1172 def FloatingSize(self, size):
1174 Sets the size of the floating pane.
1176 :param `size`: a `wx.Size` or a tuple indicating the pane floating size.
1179 self.floating_size = wx.Size(*size)
1184 """ Makes the pane take up the full area."""
1186 return self.SetFlag(self.optionMaximized, True)
1191 Makes the pane minimized in a L{AuiToolBar}.
1193 Clicking on the minimize button causes a new L{AuiToolBar} to be created
1194 and added to the frame manager, (currently the implementation is such that
1195 panes at West will have a toolbar at the right, panes at South will have
1196 toolbars at the bottom etc...) and the pane is hidden in the manager.
1198 Clicking on the restore button on the newly created toolbar will result in the
1199 toolbar being removed and the original pane being restored.
1202 return self.SetFlag(self.optionMinimized, True)
1205 def MinimizeMode(self, mode):
1207 Sets the expected minimized mode if the MinimizeButton() is visible.
1209 The minimized pane can have a specific position in the work space:
1211 ============================== ========= ==============================
1212 Minimize Mode Flag Hex Value Description
1213 ============================== ========= ==============================
1214 ``AUI_MINIMIZE_POS_SMART`` 0x01 Minimizes the pane on the closest tool bar
1215 ``AUI_MINIMIZE_POS_TOP`` 0x02 Minimizes the pane on the top tool bar
1216 ``AUI_MINIMIZE_POS_LEFT`` 0x03 Minimizes the pane on its left tool bar
1217 ``AUI_MINIMIZE_POS_RIGHT`` 0x04 Minimizes the pane on its right tool bar
1218 ``AUI_MINIMIZE_POS_BOTTOM`` 0x05 Minimizes the pane on its bottom tool bar
1219 ============================== ========= ==============================
1221 The caption of the minimized pane can be displayed in different modes:
1223 ============================== ========= ==============================
1224 Caption Mode Flag Hex Value Description
1225 ============================== ========= ==============================
1226 ``AUI_MINIMIZE_CAPT_HIDE`` 0x0 Hides the caption of the minimized pane
1227 ``AUI_MINIMIZE_CAPT_SMART`` 0x08 Displays the caption in the best rotation (horizontal in the top and in the bottom tool bar or clockwise in the right and in the left tool bar)
1228 ``AUI_MINIMIZE_CAPT_HORZ`` 0x10 Displays the caption horizontally
1229 ============================== ========= ==============================
1233 self.minimize_mode = mode
1238 """ Is the reverse of L{Maximize} and L{Minimize}."""
1240 return self.SetFlag(self.optionMaximized or self.optionMinimized, False)
1245 Forces a pane to be fixed size so that it cannot be resized.
1246 After calling L{Fixed}, L{IsFixed} will return ``True``.
1249 return self.SetFlag(self.optionResizable, False)
1252 def Resizable(self, resizable=True):
1254 Allows a pane to be resizable if `resizable` is ``True``, and forces
1255 it to be a fixed size if `resizeable` is ``False``.
1257 If `resizable` is ``False``, this is simply an antonym for L{Fixed}.
1259 :param `resizable`: whether the pane will be resizeable or not.
1262 return self.SetFlag(self.optionResizable, resizable)
1265 def Transparent(self, alpha):
1267 Makes the pane transparent when floating.
1269 :param `alpha`: an integer value between 0 and 255 for pane transparency.
1272 if alpha < 0 or alpha > 255:
1273 raise Exception("Invalid transparency value (%s)"%repr(alpha))
1275 self.transparent = alpha
1276 self.needsTransparency = True
1281 Indicates that a pane should be docked. It is the opposite of L{Float}.
1284 if self.IsNotebookPage():
1285 self.notebook_id = -1
1286 self.dock_direction = AUI_DOCK_NONE
1288 return self.SetFlag(self.optionFloating, False)
1293 Indicates that a pane should be floated. It is the opposite of L{Dock}.
1296 if self.IsNotebookPage():
1297 self.notebook_id = -1
1298 self.dock_direction = AUI_DOCK_NONE
1300 return self.SetFlag(self.optionFloating, True)
1305 Indicates that a pane should be hidden.
1307 Calling L{Show} (``False``) achieve the same effect.
1310 return self.SetFlag(self.optionHidden, True)
1313 def Show(self, show=True):
1315 Indicates that a pane should be shown.
1317 :param `show`: whether the pane should be shown or not.
1320 return self.SetFlag(self.optionHidden, not show)
1323 # By defaulting to 1000, the tab will get placed at the end
1324 def NotebookPage(self, id, tab_position=1000):
1326 Forces a pane to be a notebook page, so that the pane can be
1327 docked on top to another to create a L{AuiNotebook}.
1329 :param `id`: the notebook id;
1330 :param `tab_position`: the tab number of the pane once docked in a notebook.
1333 # Remove any floating frame
1335 self.notebook_id = id
1336 self.dock_pos = tab_position
1339 self.dock_direction = AUI_DOCK_NOTEBOOK_PAGE
1344 def NotebookControl(self, id):
1346 Forces a pane to be a notebook control (L{AuiNotebook}).
1348 :param `id`: the notebook id.
1351 self.notebook_id = id
1355 if self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE:
1356 self.dock_direction = AUI_DOCK_NONE
1361 def HasNotebook(self):
1362 """ Returns whether a pane has a L{AuiNotebook} or not. """
1364 return self.notebook_id >= 0
1367 def IsNotebookPage(self):
1368 """ Returns whether the pane is a notebook page in a L{AuiNotebook}. """
1370 return self.notebook_id >= 0 and self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE
1373 def IsNotebookControl(self):
1374 """ Returns whether the pane is a notebook control (L{AuiNotebook}). """
1376 return not self.IsNotebookPage() and self.HasNotebook()
1379 def SetNameFromNotebookId(self):
1380 """ Sets the pane name once docked in a L{AuiNotebook} using the notebook id. """
1382 if self.notebook_id >= 0:
1383 self.name = "__notebook_%d"%self.notebook_id
1388 def CaptionVisible(self, visible=True, left=False):
1390 Indicates that a pane caption should be visible. If `visible` is ``False``, no pane
1393 :param `visible`: whether the caption should be visible or not;
1394 :param `left`: whether the caption should be drawn on the left (rotated by 90 degrees) or not.
1398 self.SetFlag(self.optionCaption, False)
1399 return self.SetFlag(self.optionCaptionLeft, visible)
1401 self.SetFlag(self.optionCaptionLeft, False)
1402 return self.SetFlag(self.optionCaption, visible)
1405 def PaneBorder(self, visible=True):
1407 Indicates that a border should be drawn for the pane.
1409 :param `visible`: whether the pane border should be visible or not.
1412 return self.SetFlag(self.optionPaneBorder, visible)
1415 def Gripper(self, visible=True):
1417 Indicates that a gripper should be drawn for the pane.
1419 :param `visible`: whether the gripper should be visible or not.
1422 return self.SetFlag(self.optionGripper, visible)
1425 def GripperTop(self, attop=True):
1427 Indicates that a gripper should be drawn at the top of the pane.
1429 :param `attop`: whether the gripper should be drawn at the top or not.
1432 return self.SetFlag(self.optionGripperTop, attop)
1435 def CloseButton(self, visible=True):
1437 Indicates that a close button should be drawn for the pane.
1439 :param `visible`: whether the close button should be visible or not.
1442 return self.SetFlag(self.buttonClose, visible)
1445 def MaximizeButton(self, visible=True):
1447 Indicates that a maximize button should be drawn for the pane.
1449 :param `visible`: whether the maximize button should be visible or not.
1452 return self.SetFlag(self.buttonMaximize, visible)
1455 def MinimizeButton(self, visible=True):
1457 Indicates that a minimize button should be drawn for the pane.
1459 :param `visible`: whether the minimize button should be visible or not.
1462 return self.SetFlag(self.buttonMinimize, visible)
1465 def PinButton(self, visible=True):
1467 Indicates that a pin button should be drawn for the pane.
1469 :param `visible`: whether the pin button should be visible or not.
1472 return self.SetFlag(self.buttonPin, visible)
1475 def DestroyOnClose(self, b=True):
1477 Indicates whether a pane should be destroyed when it is closed.
1479 Normally a pane is simply hidden when the close button is clicked. Setting
1480 `b` to ``True`` will cause the window to be destroyed when the user clicks
1481 the pane's close button.
1483 :param `b`: whether the pane should be destroyed when it is closed or not.
1486 return self.SetFlag(self.optionDestroyOnClose, b)
1489 def TopDockable(self, b=True):
1491 Indicates whether a pane can be docked at the top of the frame.
1493 :param `b`: whether the pane can be docked at the top or not.
1496 return self.SetFlag(self.optionTopDockable, b)
1499 def BottomDockable(self, b=True):
1501 Indicates whether a pane can be docked at the bottom of the frame.
1503 :param `b`: whether the pane can be docked at the bottom or not.
1506 return self.SetFlag(self.optionBottomDockable, b)
1509 def LeftDockable(self, b=True):
1511 Indicates whether a pane can be docked on the left of the frame.
1513 :param `b`: whether the pane can be docked at the left or not.
1516 return self.SetFlag(self.optionLeftDockable, b)
1519 def RightDockable(self, b=True):
1521 Indicates whether a pane can be docked on the right of the frame.
1523 :param `b`: whether the pane can be docked at the right or not.
1526 return self.SetFlag(self.optionRightDockable, b)
1529 def Floatable(self, b=True):
1531 Sets whether the user will be able to undock a pane and turn it
1532 into a floating window.
1534 :param `b`: whether the pane can be floated or not.
1537 return self.SetFlag(self.optionFloatable, b)
1540 def Movable(self, b=True):
1542 Indicates whether a pane can be moved.
1544 :param `b`: whether the pane can be moved or not.
1547 return self.SetFlag(self.optionMovable, b)
1550 def NotebookDockable(self, b=True):
1552 Indicates whether a pane can be docked in an automatic L{AuiNotebook}.
1554 :param `b`: whether the pane can be docked in a notebook or not.
1557 return self.SetFlag(self.optionNotebookDockable, b)
1560 def DockFixed(self, b=True):
1562 Causes the containing dock to have no resize sash. This is useful
1563 for creating panes that span the entire width or height of a dock, but should
1564 not be resizable in the other direction.
1566 :param `b`: whether the pane will have a resize sash or not.
1569 return self.SetFlag(self.optionDockFixed, b)
1572 def Dockable(self, b=True):
1574 Specifies whether a frame can be docked or not. It is the same as specifying
1575 L{TopDockable} . L{BottomDockable} . L{LeftDockable} . L{RightDockable} .
1577 :param `b`: whether the frame can be docked or not.
1580 return self.TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b)
1583 def TopSnappable(self, b=True):
1585 Indicates whether a pane can be snapped at the top of the main frame.
1587 :param `b`: whether the pane can be snapped at the top of the main frame or not.
1590 return self.SetFlag(self.optionTopSnapped, b)
1593 def BottomSnappable(self, b=True):
1595 Indicates whether a pane can be snapped at the bottom of the main frame.
1597 :param `b`: whether the pane can be snapped at the bottom of the main frame or not.
1600 return self.SetFlag(self.optionBottomSnapped, b)
1603 def LeftSnappable(self, b=True):
1605 Indicates whether a pane can be snapped on the left of the main frame.
1607 :param `b`: whether the pane can be snapped at the left of the main frame or not.
1610 return self.SetFlag(self.optionLeftSnapped, b)
1613 def RightSnappable(self, b=True):
1615 Indicates whether a pane can be snapped on the right of the main frame.
1617 :param `b`: whether the pane can be snapped at the right of the main frame or not.
1620 return self.SetFlag(self.optionRightSnapped, b)
1623 def Snappable(self, b=True):
1625 Indicates whether a pane can be snapped on the main frame. This is
1626 equivalent as calling L{TopSnappable} . L{BottomSnappable} . L{LeftSnappable} . L{RightSnappable} .
1628 :param `b`: whether the pane can be snapped on the main frame or not.
1631 return self.TopSnappable(b).BottomSnappable(b).LeftSnappable(b).RightSnappable(b)
1634 def FlyOut(self, b=True):
1636 Indicates whether a pane, when floating, has a "fly-out" effect
1637 (i.e., floating panes which only show themselves when moused over).
1639 :param `b`: whether the pane can be snapped on the main frame or not.
1642 return self.SetFlag(self.optionFlyOut, b)
1645 # Copy over the members that pertain to docking position
1646 def SetDockPos(self, source):
1648 Copies the `source` pane members that pertain to docking position to `self`.
1650 :param `source`: the source pane from where to copy the attributes.
1653 self.dock_direction = source.dock_direction
1654 self.dock_layer = source.dock_layer
1655 self.dock_row = source.dock_row
1656 self.dock_pos = source.dock_pos
1657 self.dock_proportion = source.dock_proportion
1658 self.floating_pos = wx.Point(*source.floating_pos)
1659 self.floating_size = wx.Size(*source.floating_size)
1660 self.rect = wx.Rect(*source.rect)
1665 def DefaultPane(self):
1666 """ Specifies that the pane should adopt the default pane settings. """
1669 state |= self.optionTopDockable | self.optionBottomDockable | \
1670 self.optionLeftDockable | self.optionRightDockable | \
1671 self.optionNotebookDockable | \
1672 self.optionFloatable | self.optionMovable | self.optionResizable | \
1673 self.optionCaption | self.optionPaneBorder | self.buttonClose
1680 def CentrePane(self):
1682 Specifies that the pane should adopt the default center pane settings.
1684 Centre panes usually do not have caption bars. This function provides an easy way of
1685 preparing a pane to be displayed in the center dock position.
1688 return self.CenterPane()
1691 def CenterPane(self):
1693 Specifies that the pane should adopt the default center pane settings.
1695 Centre panes usually do not have caption bars. This function provides an easy way of
1696 preparing a pane to be displayed in the center dock position.
1700 return self.Center().PaneBorder().Resizable()
1703 def ToolbarPane(self):
1704 """ Specifies that the pane should adopt the default toolbar pane settings. """
1709 state |= (self.optionToolbar | self.optionGripper)
1710 state &= ~(self.optionResizable | self.optionCaption | self.optionCaptionLeft)
1712 if self.dock_layer == 0:
1713 self.dock_layer = 10
1720 def Icon(self, icon):
1722 Specifies whether an icon is drawn on the left of the caption text when
1723 the pane is docked. If `icon` is ``None`` or `wx.NullIcon`, no icon is drawn on
1726 :param icon: an icon to draw on the caption space, or ``None``.
1736 def SetFlag(self, flag, option_state):
1738 Turns the property given by `flag` on or off with the `option_state`
1741 :param `flag`: the property to set;
1742 :param `option_state`: either ``True`` or ``False``.
1754 if flag in [self.buttonClose, self.buttonMaximize, self.buttonMinimize, self.buttonPin]:
1760 def HasFlag(self, flag):
1762 Returns ``True`` if the the property specified by flag is active for the pane.
1764 :param `flag`: the property to check for activity.
1767 return (self.state & flag and [True] or [False])[0]
1770 def ResetButtons(self):
1772 Resets all the buttons and recreates them from scratch depending on the
1773 L{AuiPaneInfo} flags.
1776 floating = self.HasFlag(self.optionFloating)
1779 if not floating and self.HasMinimizeButton():
1780 button = AuiPaneButton(AUI_BUTTON_MINIMIZE)
1781 self.buttons.append(button)
1783 if not floating and self.HasMaximizeButton():
1784 button = AuiPaneButton(AUI_BUTTON_MAXIMIZE_RESTORE)
1785 self.buttons.append(button)
1787 if not floating and self.HasPinButton():
1788 button = AuiPaneButton(AUI_BUTTON_PIN)
1789 self.buttons.append(button)
1791 if self.HasCloseButton():
1792 button = AuiPaneButton(AUI_BUTTON_CLOSE)
1793 self.buttons.append(button)
1796 def CountButtons(self):
1797 """ Returns the number of visible buttons in the docked pane. """
1801 if self.HasCaption() or self.HasCaptionLeft():
1802 if isinstance(wx.GetTopLevelParent(self.window), AuiFloatingFrame):
1805 if self.HasCloseButton():
1807 if self.HasMaximizeButton():
1809 if self.HasMinimizeButton():
1811 if self.HasPinButton():
1817 def IsHorizontal(self):
1818 """ Returns ``True`` if the pane `dock_direction` is horizontal. """
1820 return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
1822 def IsVertical(self):
1823 """ Returns ``True`` if the pane `dock_direction` is vertical. """
1825 return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT]
1828 # Null AuiPaneInfo reference
1829 NonePaneInfo = AuiPaneInfo()
1832 # ---------------------------------------------------------------------------- #
1834 class AuiDockingGuide(wx.Frame):
1835 """ Base class for L{AuiCenterDockingGuide} and L{AuiSingleDockingGuide}."""
1837 def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
1838 size=wx.DefaultSize, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
1839 wx.FRAME_NO_TASKBAR | wx.NO_BORDER, name="AuiDockingGuide"):
1841 Default class constructor. Used internally, do not call it in your code!
1843 :param `parent`: the L{AuiDockingGuide} parent;
1844 :param `id`: the window identifier. It may take a value of -1 to indicate a default value.
1845 :param `title`: the caption to be displayed on the frame's title bar.
1846 :param `pos`: the window position. A value of (-1, -1) indicates a default position,
1847 chosen by either the windowing system or wxPython, depending on platform.
1848 :param `size`: the window size. A value of (-1, -1) indicates a default size, chosen by
1849 either the windowing system or wxPython, depending on platform.
1850 :param `style`: the window style.
1851 :param `name`: the name of the window. This parameter is used to associate a name with the
1852 item, allowing the application user to set Motif resource values for individual windows.
1855 wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
1858 def HitTest(self, x, y):
1860 To be overridden by parent classes.
1862 :param `x`: the `x` mouse position;
1863 :param `y`: the `y` mouse position.
1869 def ValidateNotebookDocking(self, valid):
1871 To be overridden by parent classes.
1873 :param `valid`: whether a pane can be docked on top to another to form an automatic
1879 # ============================================================================
1881 # ============================================================================
1883 # ---------------------------------------------------------------------------
1884 # AuiDockingGuideWindow
1885 # ---------------------------------------------------------------------------
1887 class AuiDockingGuideWindow(wx.Window):
1888 """ Target class for L{AuiSingleDockingGuide} and L{AuiCenterDockingGuide}. """
1890 def __init__(self, parent, rect, direction=0, center=False, useAero=False):
1892 Default class constructor. Used internally, do not call it in your code!
1894 :param `parent`: the L{AuiDockingGuideWindow} parent;
1895 :param `rect`: the window rect;
1896 :param `direction`: one of ``wx.TOP``, ``wx.BOTTOM``, ``wx.LEFT``, ``wx.RIGHT``,
1898 :param `center`: whether the calling class is a L{AuiCenterDockingGuide};
1899 :param `useAero`: whether to use the new Aero-style bitmaps or Whidbey-style bitmaps
1900 for the docking guide.
1903 wx.Window.__init__(self, parent, -1, rect.GetPosition(), rect.GetSize(), wx.NO_BORDER)
1905 self._direction = direction
1906 self._center = center
1908 self._useAero = useAero
1910 self._bmp_unfocus, self._bmp_focus = GetDockingImage(direction, useAero, center)
1912 self._currentImage = self._bmp_unfocus
1913 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
1915 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
1916 self.Bind(wx.EVT_PAINT, self.OnPaint)
1919 def SetValid(self, valid):
1921 Sets the docking direction as valid or invalid.
1923 :param `valid`: whether the docking direction is allowed or not.
1930 """ Returns whether the docking direction is valid. """
1935 def OnEraseBackground(self, event):
1937 Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{AuiDockingGuideWindow}.
1939 :param `event`: a `wx.EraseEvent` to be processed.
1941 :note: This is intentionally empty to reduce flickering while drawing.
1947 def DrawBackground(self, dc):
1949 Draws the docking guide background.
1951 :param `dc`: a `wx.DC` device context object.
1954 rect = self.GetClientRect()
1956 dc.SetPen(wx.TRANSPARENT_PEN)
1957 dc.SetBrush(wx.Brush(colourTargetBackground))
1958 dc.DrawRectangleRect(rect)
1960 dc.SetPen(wx.Pen(colourTargetBorder))
1962 left = rect.GetLeft()
1964 right = rect.GetRight()
1965 bottom = rect.GetBottom()
1967 if self._direction != wx.CENTER:
1969 if not self._center or self._direction != wx.BOTTOM:
1970 dc.DrawLine(left, top, right+1, top)
1971 if not self._center or self._direction != wx.RIGHT:
1972 dc.DrawLine(left, top, left, bottom+1)
1973 if not self._center or self._direction != wx.LEFT:
1974 dc.DrawLine(right, top, right, bottom+1)
1975 if not self._center or self._direction != wx.TOP:
1976 dc.DrawLine(left, bottom, right+1, bottom)
1978 dc.SetPen(wx.Pen(colourTargetShade))
1980 if self._direction != wx.RIGHT:
1981 dc.DrawLine(left + 1, top + 1, left + 1, bottom)
1982 if self._direction != wx.BOTTOM:
1983 dc.DrawLine(left + 1, top + 1, right, top + 1)
1986 def DrawDottedLine(self, dc, point, length, vertical):
1988 Draws a dotted line (not used if the docking guide images are ok).
1990 :param `dc`: a `wx.DC` device context object;
1991 :param `point`: a `wx.Point` where to start drawing the dotted line;
1992 :param `length`: the length of the dotted line;
1993 :param `vertical`: whether it is a vertical docking guide window or not.
1996 for i in xrange(0, length, 2):
1997 dc.DrawPoint(point.x, point.y)
2004 def DrawIcon(self, dc):
2006 Draws the docking guide icon (not used if the docking guide images are ok).
2008 :param `dc`: a `wx.DC` device context object.
2011 rect = wx.Rect(*self.GetClientRect())
2016 dc.SetPen(wx.Pen(colourIconBorder))
2017 dc.SetBrush(wx.Brush(colourIconBackground))
2018 dc.DrawRectangleRect(rect)
2020 right1 = rect.GetRight() + 1
2021 bottom1 = rect.GetBottom() + 1
2023 dc.SetPen(wx.Pen(colourIconShadow))
2024 dc.DrawLine(rect.x + 1, bottom1, right1 + 1, bottom1)
2025 dc.DrawLine(right1, rect.y + 1, right1, bottom1 + 1)
2029 if self._direction == wx.TOP:
2030 rect.height -= rect.height / 2
2031 point = rect.GetBottomLeft()
2034 elif self._direction == wx.LEFT:
2035 rect.width -= rect.width / 2
2036 point = rect.GetTopRight()
2037 length = rect.height
2039 elif self._direction == wx.RIGHT:
2040 rect.x += rect.width / 2
2041 rect.width -= rect.width / 2
2042 point = rect.GetTopLeft()
2043 length = rect.height
2045 elif self._direction == wx.BOTTOM:
2046 rect.y += rect.height / 2
2047 rect.height -= rect.height / 2
2048 point = rect.GetTopLeft()
2051 elif self._direction == wx.CENTER:
2053 point = rect.GetTopLeft()
2056 dc.GradientFillLinear(rect, colourIconDockingPart1,
2057 colourIconDockingPart2, self._direction)
2059 dc.SetPen(wx.Pen(colourIconBorder))
2061 if self._direction == wx.CENTER:
2062 self.DrawDottedLine(dc, rect.GetTopLeft(), rect.width, False)
2063 self.DrawDottedLine(dc, rect.GetTopLeft(), rect.height, True)
2064 self.DrawDottedLine(dc, rect.GetBottomLeft(), rect.width, False)
2065 self.DrawDottedLine(dc, rect.GetTopRight(), rect.height, True)
2067 elif self._direction in [wx.TOP, wx.BOTTOM]:
2068 self.DrawDottedLine(dc, point, length, False)
2071 self.DrawDottedLine(dc, point, length, True)
2074 def DrawArrow(self, dc):
2076 Draws the docking guide arrow icon (not used if the docking guide images are ok).
2078 :param `dc`: a `wx.DC` device context object.
2081 rect = self.GetClientRect()
2084 point.x = (rect.GetLeft() + rect.GetRight()) / 2
2085 point.y = (rect.GetTop() + rect.GetBottom()) / 2
2086 rx, ry = wx.Size(), wx.Size()
2088 if self._direction == wx.TOP:
2092 elif self._direction == wx.LEFT:
2096 elif self._direction == wx.RIGHT:
2100 elif self._direction == wx.BOTTOM:
2107 dc.SetPen(wx.Pen(colourIconArrow))
2110 pt1 = wx.Point(point.x - rx.x*i, point.y - rx.y*i)
2111 pt2 = wx.Point(point.x + rx.x*(i+1), point.y + rx.y*(i+1))
2112 dc.DrawLinePoint(pt1, pt2)
2117 def OnPaint(self, event):
2119 Handles the ``wx.EVT_PAINT`` event for L{AuiDockingGuideWindow}.
2121 :param `event`: a `wx.PaintEvent` to be processed.
2124 dc = wx.AutoBufferedPaintDC(self)
2125 if self._currentImage.IsOk() and self._valid:
2126 dc.DrawBitmap(self._currentImage, 0, 0, True)
2133 Draws the whole docking guide window (not used if the docking guide images are ok).
2135 :param `dc`: a `wx.DC` device context object.
2138 self.DrawBackground(dc)
2145 def UpdateDockGuide(self, pos):
2147 Updates the docking guide images depending on the mouse position, using focused
2148 images if the mouse is inside the docking guide or unfocused images if it is
2151 :param `pos`: a `wx.Point` mouse position.
2154 inside = self.GetScreenRect().Contains(pos)
2157 image = self._bmp_focus
2159 image = self._bmp_unfocus
2161 if image != self._currentImage:
2162 self._currentImage = image
2167 # ---------------------------------------------------------------------------
2168 # AuiSingleDockingGuide
2169 # ---------------------------------------------------------------------------
2171 class AuiSingleDockingGuide(AuiDockingGuide):
2172 """ A docking guide window for single docking hint (not diamond-shaped HUD). """
2174 def __init__(self, parent, direction=0):
2176 Default class constructor. Used internally, do not call it in your code!
2178 :param `parent`: the L{AuiSingleDockingGuide} parent;
2179 :param `direction`: one of ``wx.TOP``, ``wx.BOTTOM``, ``wx.LEFT``, ``wx.RIGHT``.
2182 self._direction = direction
2184 style = wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | \
2185 wx.FRAME_NO_TASKBAR | wx.NO_BORDER
2187 # Use of FRAME_SHAPED on wxMac causes the frame to be visible
2188 # breaking the docking hints.
2189 if wx.Platform != '__WXMAC__':
2190 style |= wx.FRAME_SHAPED
2192 AuiDockingGuide.__init__(self, parent, style=style, name="auiSingleDockTarget")
2196 useAero = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES
2197 useWhidbey = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES
2199 self._useAero = useAero or useWhidbey
2203 sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2205 sizeX, sizeY = whidbeySizeX, whidbeySizeY
2207 sizeX, sizeY = guideSizeX, guideSizeY
2209 if direction not in [wx.TOP, wx.BOTTOM]:
2210 sizeX, sizeY = sizeY, sizeX
2213 self.CreateShapesWithStyle(useWhidbey)
2215 if wx.Platform == "__WXGTK__":
2216 self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
2218 self.SetGuideShape()
2220 self.SetSize(self.region.GetBox().GetSize())
2222 self.SetSize((sizeX, sizeY))
2224 self.rect = wx.Rect(0, 0, sizeX, sizeY)
2227 useAero = (useWhidbey and [2] or [1])[0]
2231 self.target = AuiDockingGuideWindow(self, self.rect, direction, False, useAero)
2234 def CreateShapesWithStyle(self, useWhidbey):
2236 Creates the docking guide window shape based on which docking bitmaps are used.
2238 :param `useWhidbey`: if ``True``, use Whidbey-style bitmaps; if ``False``, use the
2242 sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2244 sizeX, sizeY = whidbeySizeX, whidbeySizeY
2246 if self._direction not in [wx.TOP, wx.BOTTOM]:
2247 sizeX, sizeY = sizeY, sizeX
2249 useAero = (useWhidbey and [2] or [1])[0]
2250 bmp, dummy = GetDockingImage(self._direction, useAero, False)
2251 region = wx.RegionFromBitmap(bmp)
2253 self.region = region
2256 def AeroMove(self, pos):
2258 Moves the docking window to the new position. Overridden in children classes.
2260 :param `pos`: the new docking guide position.
2266 def SetGuideShape(self, event=None):
2268 Sets the correct shape for the docking guide window.
2270 :param `event`: on wxGTK, a `wx.WindowCreateEvent` event to process.
2273 self.SetShape(self.region)
2275 if event is not None:
2276 # Skip the event on wxGTK
2278 wx.CallAfter(wx.SafeYield, self, True)
2281 def SetShape(self, region):
2283 If the platform supports it, sets the shape of the window to that depicted by `region`.
2284 The system will not display or respond to any mouse event for the pixels that lie
2285 outside of the region. To reset the window to the normal rectangular shape simply call
2286 L{SetShape} again with an empty region.
2288 :param `region`: the shape of the frame.
2290 :note: Overridden for wxMac.
2293 if wx.Platform == '__WXMAC__':
2294 # HACK so we don't crash when SetShape is called
2297 super(AuiSingleDockingGuide, self).SetShape(region)
2300 def SetValid(self, valid):
2302 Sets the docking direction as valid or invalid.
2304 :param `valid`: whether the docking direction is allowed or not.
2311 """ Returns whether the docking direction is valid. """
2316 def UpdateDockGuide(self, pos):
2318 Updates the docking guide images depending on the mouse position, using focused
2319 images if the mouse is inside the docking guide or unfocused images if it is
2322 :param `pos`: a `wx.Point` mouse position.
2325 self.target.UpdateDockGuide(pos)
2328 def HitTest(self, x, y):
2330 Checks if the mouse position is inside the target window rect.
2332 :param `x`: the `x` mouse position;
2333 :param `y`: the `y` mouse position.
2336 if self.target.GetScreenRect().Contains((x, y)):
2342 # ---------------------------------------------------------------------------
2343 # AuiCenterDockingGuide
2344 # ---------------------------------------------------------------------------
2346 class AuiCenterDockingGuide(AuiDockingGuide):
2347 """ A docking guide window for multiple docking hint (diamond-shaped HUD). """
2349 def __init__(self, parent):
2351 Default class constructor.
2352 Used internally, do not call it in your code!
2354 :param `parent`: the L{AuiCenterDockingGuide} parent.
2357 AuiDockingGuide.__init__(self, parent, style=wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
2358 wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED,
2359 name="auiCenterDockTarget")
2363 self.CreateShapesWithStyle()
2364 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
2366 if wx.Platform == "__WXGTK__":
2367 self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
2369 self.SetGuideShape()
2371 self.SetSize(self.region.GetBox().GetSize())
2373 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
2374 self.Bind(wx.EVT_PAINT, self.OnPaint)
2377 def CreateShapesWithStyle(self):
2378 """ Creates the docking guide window shape based on which docking bitmaps are used. """
2380 useAero = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES) != 0
2381 useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
2390 sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2392 sizeX, sizeY = whidbeySizeX, whidbeySizeY
2394 sizeX, sizeY = guideSizeX, guideSizeY
2396 rectLeft = wx.Rect(0, sizeY, sizeY, sizeX)
2397 rectTop = wx.Rect(sizeY, 0, sizeX, sizeY)
2398 rectRight = wx.Rect(sizeY+sizeX, sizeY, sizeY, sizeX)
2399 rectBottom = wx.Rect(sizeY, sizeX + sizeY, sizeX, sizeY)
2400 rectCenter = wx.Rect(sizeY, sizeY, sizeX, sizeX)
2402 if not self._useAero:
2404 self.targetLeft = AuiDockingGuideWindow(self, rectLeft, wx.LEFT, True, useAero)
2405 self.targetTop = AuiDockingGuideWindow(self, rectTop, wx.TOP, True, useAero)
2406 self.targetRight = AuiDockingGuideWindow(self, rectRight, wx.RIGHT, True, useAero)
2407 self.targetBottom = AuiDockingGuideWindow(self, rectBottom, wx.BOTTOM, True, useAero)
2408 self.targetCenter = AuiDockingGuideWindow(self, rectCenter, wx.CENTER, True, useAero)
2412 tld = [wx.Point(rectTop.x, rectTop.y+rectTop.height-8),
2413 wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y),
2414 rectTop.GetBottomLeft()]
2415 # bottom-left diamond
2416 bld = [wx.Point(rectLeft.x+rectLeft.width-8, rectLeft.y+rectLeft.height),
2417 wx.Point(rectBottom.x, rectBottom.y+8),
2418 rectBottom.GetTopLeft()]
2420 trd = [wx.Point(rectTop.x+rectTop.width, rectTop.y+rectTop.height-8),
2421 wx.Point(rectRight.x+8, rectRight.y),
2422 rectRight.GetTopLeft()]
2423 # bottom-right diamond
2424 brd = [wx.Point(rectRight.x+8, rectRight.y+rectRight.height),
2425 wx.Point(rectBottom.x+rectBottom.width, rectBottom.y+8),
2426 rectBottom.GetTopRight()]
2428 self._triangles = [tld[0:2], bld[0:2],
2429 [wx.Point(rectTop.x+rectTop.width-1, rectTop.y+rectTop.height-8),
2430 wx.Point(rectRight.x+7, rectRight.y)],
2431 [wx.Point(rectRight.x+7, rectRight.y+rectRight.height),
2432 wx.Point(rectBottom.x+rectBottom.width-1, rectBottom.y+8)]]
2434 region = wx.Region()
2435 region.UnionRect(rectLeft)
2436 region.UnionRect(rectTop)
2437 region.UnionRect(rectRight)
2438 region.UnionRect(rectBottom)
2439 region.UnionRect(rectCenter)
2440 region.UnionRegion(wx.RegionFromPoints(tld))
2441 region.UnionRegion(wx.RegionFromPoints(bld))
2442 region.UnionRegion(wx.RegionFromPoints(trd))
2443 region.UnionRegion(wx.RegionFromPoints(brd))
2447 self._aeroBmp = aero_dock_pane.GetBitmap()
2448 region = wx.RegionFromBitmap(self._aeroBmp)
2450 self._allAeroBmps = [aero_dock_pane_left.GetBitmap(), aero_dock_pane_top.GetBitmap(),
2451 aero_dock_pane_right.GetBitmap(), aero_dock_pane_bottom.GetBitmap(),
2452 aero_dock_pane_center.GetBitmap(), aero_dock_pane.GetBitmap()]
2453 self._deniedBitmap = aero_denied.GetBitmap()
2454 self._aeroRects = [rectLeft, rectTop, rectRight, rectBottom, rectCenter]
2459 self._aeroBmp = whidbey_dock_pane.GetBitmap()
2460 region = wx.RegionFromBitmap(self._aeroBmp)
2462 self._allAeroBmps = [whidbey_dock_pane_left.GetBitmap(), whidbey_dock_pane_top.GetBitmap(),
2463 whidbey_dock_pane_right.GetBitmap(), whidbey_dock_pane_bottom.GetBitmap(),
2464 whidbey_dock_pane_center.GetBitmap(), whidbey_dock_pane.GetBitmap()]
2465 self._deniedBitmap = whidbey_denied.GetBitmap()
2466 self._aeroRects = [rectLeft, rectTop, rectRight, rectBottom, rectCenter]
2470 self.region = region
2473 def SetGuideShape(self, event=None):
2475 Sets the correct shape for the docking guide window.
2477 :param `event`: on wxGTK, a `wx.WindowCreateEvent` event to process.
2480 self.SetShape(self.region)
2482 if event is not None:
2483 # Skip the event on wxGTK
2485 wx.CallAfter(wx.SafeYield, self, True)
2488 def UpdateDockGuide(self, pos):
2490 Updates the docking guides images depending on the mouse position, using focused
2491 images if the mouse is inside the docking guide or unfocused images if it is
2494 :param `pos`: a `wx.Point` mouse position.
2497 if not self._useAero:
2498 for target in self.GetChildren():
2499 target.UpdateDockGuide(pos)
2501 lenRects = len(self._aeroRects)
2502 for indx, rect in enumerate(self._aeroRects):
2503 if rect.Contains(pos):
2504 if self._allAeroBmps[indx] != self._aeroBmp:
2505 if indx < lenRects - 1 or (indx == lenRects - 1 and self._valid):
2506 self._aeroBmp = self._allAeroBmps[indx]
2509 self._aeroBmp = self._allAeroBmps[-1]
2514 if self._aeroBmp != self._allAeroBmps[-1]:
2515 self._aeroBmp = self._allAeroBmps[-1]
2519 def HitTest(self, x, y):
2521 Checks if the mouse position is inside the target windows rect.
2523 :param `x`: the `x` mouse position;
2524 :param `y`: the `y` mouse position.
2527 if not self._useAero:
2528 if self.targetLeft.GetScreenRect().Contains((x, y)):
2530 if self.targetTop.GetScreenRect().Contains((x, y)):
2532 if self.targetRight.GetScreenRect().Contains((x, y)):
2534 if self.targetBottom.GetScreenRect().Contains((x, y)):
2536 if self.targetCenter.IsValid() and self.targetCenter.GetScreenRect().Contains((x, y)):
2539 constants = [wx.LEFT, wx.UP, wx.RIGHT, wx.DOWN, wx.CENTER]
2540 lenRects = len(self._aeroRects)
2541 for indx, rect in enumerate(self._aeroRects):
2542 if rect.Contains((x, y)):
2543 if indx < lenRects or (indx == lenRects-1 and self._valid):
2544 return constants[indx]
2549 def ValidateNotebookDocking(self, valid):
2551 Sets whether a pane can be docked on top of another to create an automatic
2554 :param `valid`: whether a pane can be docked on top to another to form an automatic
2558 if not self._useAero:
2559 if self.targetCenter.IsValid() != valid:
2560 self.targetCenter.SetValid(valid)
2561 self.targetCenter.Refresh()
2563 if self._valid != valid:
2568 def AeroMove(self, pos):
2570 Moves the docking guide window to the new position.
2572 :param `pos`: the new docking guide position.
2575 if not self._useAero:
2578 useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
2581 sizeX, sizeY = whidbeySizeX, whidbeySizeY
2583 sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2585 size = self.GetSize()
2587 leftRect, topRect, rightRect, bottomRect, centerRect = self._aeroRects
2588 thePos = pos + wx.Point((size.x-sizeY)/2, (size.y-sizeX)/2)
2590 centerRect.SetPosition(thePos)
2592 leftRect.SetPosition(thePos + wx.Point(-sizeY, 0))
2593 topRect.SetPosition(thePos + wx.Point(0, -sizeY))
2594 rightRect.SetPosition(thePos + wx.Point(sizeX, 0))
2595 bottomRect.SetPosition(thePos + wx.Point(0, sizeX))
2598 def OnEraseBackground(self, event):
2600 Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{AuiCenterDockingGuide}.
2602 :param `event`: `wx.EraseEvent` to be processed.
2604 :note: This is intentionally empty to reduce flickering while drawing.
2610 def OnPaint(self, event):
2612 Handles the ``wx.EVT_PAINT`` event for L{AuiCenterDockingGuide}.
2614 :param `event`: a `wx.PaintEvent` to be processed.
2617 dc = wx.AutoBufferedPaintDC(self)
2620 dc.SetBrush(wx.TRANSPARENT_BRUSH)
2621 dc.SetPen(wx.TRANSPARENT_PEN)
2623 dc.SetBrush(wx.Brush(colourTargetBackground))
2624 dc.SetPen(wx.Pen(colourTargetBorder))
2626 rect = self.GetClientRect()
2627 dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
2630 dc.DrawBitmap(self._aeroBmp, 0, 0, True)
2632 diff = (self._useAero == 2 and [1] or [0])[0]
2633 bmpX, bmpY = self._deniedBitmap.GetWidth(), self._deniedBitmap.GetHeight()
2634 xPos, yPos = (rect.x + (rect.width)/2 - bmpX/2), (rect.y + (rect.height)/2 - bmpY/2)
2635 dc.DrawBitmap(self._deniedBitmap, xPos+1, yPos+diff, True)
2639 dc.SetPen(wx.Pen(colourTargetBorder, 2))
2640 for pts in self._triangles:
2641 dc.DrawLinePoint(pts[0], pts[1])
2644 # ----------------------------------------------------------------------------
2645 # AuiDockingHintWindow
2646 # ----------------------------------------------------------------------------
2648 class AuiDockingHintWindow(wx.Frame):
2649 """ The original wxAUI docking window hint. """
2651 def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
2652 size=wx.Size(1, 1), style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT |
2653 wx.FRAME_NO_TASKBAR | wx.NO_BORDER | wx.FRAME_SHAPED,
2654 name="auiHintWindow"):
2656 Default class constructor. Used internally, do not call it in your code!
2658 :param `parent`: the L{AuiDockingGuide} parent;
2659 :param `id`: the window identifier. It may take a value of -1 to indicate a default value.
2660 :param `title`: the caption to be displayed on the frame's title bar;
2661 :param `pos`: the window position. A value of (-1, -1) indicates a default position,
2662 chosen by either the windowing system or wxPython, depending on platform;
2663 :param `size`: the window size. A value of (-1, -1) indicates a default size, chosen by
2664 either the windowing system or wxPython, depending on platform;
2665 :param `style`: the window style;
2666 :param `name`: the name of the window. This parameter is used to associate a name with the
2667 item, allowing the application user to set Motif resource values for individual windows.
2669 if wx.Platform == '__WXMAC__' and style & wx.FRAME_SHAPED:
2670 # Having the shaped frame causes the frame to not be visible
2671 # with the transparent style hints.
2672 style -= wx.FRAME_SHAPED
2674 wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
2676 self._blindMode = False
2677 self.SetBackgroundColour(colourHintBackground)
2679 # Can't set background colour on a frame on wxMac
2680 # so add a panel to set the colour on.
2681 if wx.Platform == '__WXMAC__':
2682 sizer = wx.BoxSizer(wx.HORIZONTAL)
2683 self.panel = wx.Panel(self)
2684 sizer.Add(self.panel, 1, wx.EXPAND)
2685 self.SetSizer(sizer)
2686 self.panel.SetBackgroundColour(colourHintBackground)
2688 self.Bind(wx.EVT_SIZE, self.OnSize)
2691 def MakeVenetianBlinds(self):
2693 Creates the "venetian blind" effect if L{AuiManager} has the ``AUI_MGR_VENETIAN_BLINDS_HINT``
2698 size = self.GetClientSize()
2699 region = wx.Region(0, 0, size.x, 1)
2701 for y in xrange(size.y):
2703 # Reverse the order of the bottom 4 bits
2704 j = (y & 8 and [1] or [0])[0] | (y & 4 and [2] or [0])[0] | \
2705 (y & 2 and [4] or [0])[0] | (y & 1 and [8] or [0])[0]
2708 region.Union(0, y, size.x, 1)
2710 self.SetShape(region)
2713 def SetBlindMode(self, agwFlags):
2715 Sets whether venetian blinds or transparent hints will be shown as docking hint.
2716 This depends on the L{AuiManager} flags.
2718 :param `agwFlags`: the L{AuiManager} flags.
2721 self._blindMode = (agwFlags & AUI_MGR_VENETIAN_BLINDS_HINT) != 0
2723 if self._blindMode or not self.CanSetTransparent():
2724 self.MakeVenetianBlinds()
2725 self.SetTransparent(255)
2728 self.SetShape(wx.Region())
2729 if agwFlags & AUI_MGR_HINT_FADE == 0:
2730 self.SetTransparent(80)
2732 self.SetTransparent(0)
2735 def SetShape(self, region):
2737 If the platform supports it, sets the shape of the window to that depicted by `region`.
2738 The system will not display or respond to any mouse event for the pixels that lie
2739 outside of the region. To reset the window to the normal rectangular shape simply call
2740 L{SetShape} again with an empty region.
2742 :param `region`: the shape of the frame (an instance of `wx.Region`).
2744 :note: Overridden for wxMac.
2747 if wx.Platform == '__WXMAC__':
2748 # HACK so we don't crash when SetShape is called
2751 super(AuiDockingHintWindow, self).SetShape(region)
2754 def Show(self, show=True):
2756 Show the hint window.
2758 :param `show`: whether to show or hide the hint docking window.
2761 super(AuiDockingHintWindow, self).Show(show)
2762 if wx.Platform == '__WXMAC__':
2763 # Need to manually do layout since its a borderless frame.
2767 def OnSize(self, event):
2769 Handles the ``wx.EVT_SIZE`` event for L{AuiDockingHintWindow}.
2771 :param `event`: a `wx.SizeEvent` to be processed.
2774 if self._blindMode or not self.CanSetTransparent():
2775 self.MakeVenetianBlinds()
2778 # ---------------------------------------------------------------------------- #
2780 # -- AuiFloatingFrame class implementation --
2782 class AuiFloatingFrame(wx.MiniFrame):
2783 """ AuiFloatingFrame is the frame class that holds floating panes. """
2785 def __init__(self, parent, owner_mgr, pane=None, id=wx.ID_ANY, title="",
2786 style=wx.FRAME_TOOL_WINDOW | wx.FRAME_FLOAT_ON_PARENT |
2787 wx.FRAME_NO_TASKBAR | wx.CLIP_CHILDREN):
2789 Default class constructor. Used internally, do not call it in your code!
2791 :param `parent`: the L{AuiFloatingFrame} parent;
2792 :param `owner_mgr`: the L{AuiManager} that manages the floating pane;
2793 :param `pane`: the L{AuiPaneInfo} pane that is about to float;
2794 :param `id`: the window identifier. It may take a value of -1 to indicate a default value.
2795 :param `title`: the caption to be displayed on the frame's title bar.
2796 :param `style`: the window style.
2799 if pane and pane.IsResizeable():
2800 style += wx.RESIZE_BORDER
2802 self._is_toolbar = pane.IsToolbar()
2804 self._useNativeMiniframes = False
2805 if AuiManager_UseNativeMiniframes(owner_mgr):
2806 # On wxMac we always use native miniframes
2807 self._useNativeMiniframes = True
2808 style += wx.CAPTION + wx.SYSTEM_MENU
2809 if pane.HasCloseButton():
2810 style += wx.CLOSE_BOX
2811 if pane.HasMaximizeButton():
2812 style += wx.MAXIMIZE_BOX
2813 if pane.HasMinimizeButton():
2814 style += wx.MINIMIZE_BOX
2816 wx.MiniFrame.__init__(self, parent, id, title, pos=pane.floating_pos,
2817 size=pane.floating_size, style=style, name="auiFloatingFrame")
2819 self._fly_timer = wx.Timer(self, wx.ID_ANY)
2820 self._check_fly_timer = wx.Timer(self, wx.ID_ANY)
2822 self.Bind(wx.EVT_CLOSE, self.OnClose)
2823 self.Bind(wx.EVT_SIZE, self.OnSize)
2824 self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
2825 self.Bind(wx.EVT_TIMER, self.OnCheckFlyTimer, self._check_fly_timer)
2826 self.Bind(wx.EVT_TIMER, self.OnFlyTimer, self._fly_timer)
2827 self.Bind(EVT_AUI_FIND_MANAGER, self.OnFindManager)
2829 if self._useNativeMiniframes:
2830 self.Bind(wx.EVT_MOVE, self.OnMoveEvent)
2831 self.Bind(wx.EVT_MOVING, self.OnMoveEvent)
2832 self.Bind(wx.EVT_IDLE, self.OnIdle)
2833 self._useNativeMiniframes = True
2834 self.SetExtraStyle(wx.WS_EX_PROCESS_IDLE)
2836 self.Bind(wx.EVT_MOVE, self.OnMove)
2839 self._send_size = True
2840 self._alpha_amount = 255
2842 self._owner_mgr = owner_mgr
2843 self._moving = False
2844 self._lastDirection = None
2845 self._transparent = 255
2847 self._last_rect = wx.Rect()
2848 self._last2_rect = wx.Rect()
2849 self._last3_rect = wx.Rect()
2851 self._mgr = AuiManager()
2852 self._mgr.SetManagedWindow(self)
2853 self._mgr.SetArtProvider(owner_mgr.GetArtProvider())
2854 self._mgr.SetAGWFlags(owner_mgr.GetAGWFlags())
2857 def CopyAttributes(self, pane):
2859 Copies all the attributes of the input `pane` into another L{AuiPaneInfo}.
2861 :param `pane`: the source L{AuiPaneInfo} from where to copy attributes.
2864 contained_pane = AuiPaneInfo()
2866 contained_pane.name = pane.name
2867 contained_pane.caption = pane.caption
2868 contained_pane.window = pane.window
2869 contained_pane.frame = pane.frame
2870 contained_pane.state = pane.state
2871 contained_pane.dock_direction = pane.dock_direction
2872 contained_pane.dock_layer = pane.dock_layer
2873 contained_pane.dock_row = pane.dock_row
2874 contained_pane.dock_pos = pane.dock_pos
2875 contained_pane.best_size = wx.Size(*pane.best_size)
2876 contained_pane.min_size = wx.Size(*pane.min_size)
2877 contained_pane.max_size = wx.Size(*pane.max_size)
2878 contained_pane.floating_pos = wx.Point(*pane.floating_pos)
2879 contained_pane.floating_size = wx.Size(*pane.floating_size)
2880 contained_pane.dock_proportion = pane.dock_proportion
2881 contained_pane.buttons = pane.buttons
2882 contained_pane.rect = wx.Rect(*pane.rect)
2883 contained_pane.icon = pane.icon
2884 contained_pane.notebook_id = pane.notebook_id
2885 contained_pane.transparent = pane.transparent
2886 contained_pane.snapped = pane.snapped
2887 contained_pane.minimize_mode = pane.minimize_mode
2889 return contained_pane
2892 def SetPaneWindow(self, pane):
2894 Sets all the properties of a pane.
2896 :param `pane`: the L{AuiPaneInfo} to analyze.
2899 self._is_toolbar = pane.IsToolbar()
2900 self._pane_window = pane.window
2902 if isinstance(pane.window, auibar.AuiToolBar):
2903 pane.window.SetAuiManager(self._mgr)
2905 self._pane_window.Reparent(self)
2907 contained_pane = self.CopyAttributes(pane)
2909 contained_pane.Dock().Center().Show(). \
2910 CaptionVisible(False). \
2911 PaneBorder(False). \
2912 Layer(0).Row(0).Position(0)
2914 if not contained_pane.HasGripper() and not self._useNativeMiniframes:
2915 contained_pane.CaptionVisible(True)
2917 indx = self._owner_mgr._panes.index(pane)
2919 # Carry over the minimum size
2920 pane_min_size = pane.window.GetMinSize()
2922 # if the best size is smaller than the min size
2923 # then set the min size to the best size as well
2924 pane_best_size = contained_pane.best_size
2925 if pane_best_size.IsFullySpecified() and (pane_best_size.x < pane_min_size.x or \
2926 pane_best_size.y < pane_min_size.y):
2928 pane_min_size = pane_best_size
2929 self._pane_window.SetMinSize(pane_min_size)
2931 # if the frame window's max size is greater than the min size
2932 # then set the max size to the min size as well
2933 cur_max_size = self.GetMaxSize()
2934 if cur_max_size.IsFullySpecified() and (cur_max_size.x < pane_min_size.x or \
2935 cur_max_size.y < pane_min_size.y):
2936 self.SetMaxSize(pane_min_size)
2938 art_provider = self._mgr.GetArtProvider()
2939 caption_size = art_provider.GetMetric(AUI_DOCKART_CAPTION_SIZE)
2940 button_size = art_provider.GetMetric(AUI_DOCKART_PANE_BUTTON_SIZE) + \
2941 4*art_provider.GetMetric(AUI_DOCKART_PANE_BORDER_SIZE)
2943 min_size = pane.window.GetMinSize()
2945 if min_size.y < caption_size or min_size.x < button_size:
2946 new_x, new_y = min_size.x, min_size.y
2947 if min_size.y < caption_size:
2948 new_y = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)+caption_size] or [1])[0]
2949 if min_size.x < button_size:
2950 new_x = (pane.IsResizeable() and [2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_X)+button_size] or [1])[0]
2952 self.SetMinSize((new_x, new_y))
2954 self.SetMinSize(min_size)
2956 self._mgr.AddPane(self._pane_window, contained_pane)
2959 if pane.min_size.IsFullySpecified():
2960 # because SetSizeHints() calls Fit() too (which sets the window
2961 # size to its minimum allowed), we keep the size before calling
2962 # SetSizeHints() and reset it afterwards...
2963 tmp = self.GetSize()
2964 self.GetSizer().SetSizeHints(self)
2967 self.SetTitle(pane.caption)
2969 if pane.floating_size != wx.Size(-1, -1):
2970 self.SetSize(pane.floating_size)
2972 size = pane.best_size
2973 if size == wx.Size(-1, -1):
2974 size = pane.min_size
2975 if size == wx.Size(-1, -1):
2976 size = self._pane_window.GetSize()
2977 if self._owner_mgr and pane.HasGripper():
2978 if pane.HasGripperTop():
2979 size.y += self._owner_mgr._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
2981 size.x += self._owner_mgr._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
2983 if not self._useNativeMiniframes:
2984 size.y += self._owner_mgr._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
2986 pane.floating_size = size
2988 self.SetClientSize(size)
2990 self._owner_mgr._panes[indx] = pane
2992 self._fly_step = abs(pane.floating_size.y - \
2993 (caption_size + 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)))/10
2995 self._floating_size = wx.Size(*self.GetSize())
2998 self._check_fly_timer.Start(50)
3001 def GetOwnerManager(self):
3002 """ Returns the L{AuiManager} that manages the pane. """
3004 return self._owner_mgr
3007 def OnSize(self, event):
3009 Handles the ``wx.EVT_SIZE`` event for L{AuiFloatingFrame}.
3011 :param `event`: a `wx.SizeEvent` to be processed.
3014 if self._owner_mgr and self._send_size:
3015 self._owner_mgr.OnFloatingPaneResized(self._pane_window, event.GetSize())
3018 def OnClose(self, event):
3020 Handles the ``wx.EVT_CLOSE`` event for L{AuiFloatingFrame}.
3022 :param `event`: a `wx.CloseEvent` to be processed.
3026 self._owner_mgr.OnFloatingPaneClosed(self._pane_window, event)
3028 if not event.GetVeto():
3029 self._mgr.DetachPane(self._pane_window)
3031 if isinstance(self._pane_window, auibar.AuiToolBar):
3032 self._pane_window.SetAuiManager(self._owner_mgr)
3034 # if we do not do this, then we can crash...
3035 if self._owner_mgr and self._owner_mgr._action_window == self:
3036 self._owner_mgr._action_window = None
3041 def OnActivate(self, event):
3043 Handles the ``wx.EVT_ACTIVATE`` event for L{AuiFloatingFrame}.
3045 :param `event`: a `wx.ActivateEvent` to be processed.
3048 if self._owner_mgr and event.GetActive():
3049 self._owner_mgr.OnFloatingPaneActivated(self._pane_window)
3052 def OnMove(self, event):
3054 Handles the ``wx.EVT_MOVE`` event for L{AuiFloatingFrame}.
3056 :param `event`: a `wx.MoveEvent` to be processed.
3058 :note: This event is not processed on wxMAC or if L{AuiManager} is not using the
3059 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3063 self._owner_mgr.OnFloatingPaneMoved(self._pane_window, event)
3066 def OnMoveEvent(self, event):
3068 Handles the ``wx.EVT_MOVE`` and ``wx.EVT_MOVING`` events for L{AuiFloatingFrame}.
3070 :param `event`: a `wx.MoveEvent` to be processed.
3072 :note: This event is only processed on wxMAC or if L{AuiManager} is using the
3073 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3076 win_rect = self.GetRect()
3078 if win_rect == self._last_rect:
3081 # skip the first move event
3082 if self._last_rect.IsEmpty():
3083 self._last_rect = wx.Rect(*win_rect)
3086 # skip if moving too fast to avoid massive redraws and
3087 # jumping hint windows
3088 if abs(win_rect.x - self._last_rect.x) > 3 or abs(win_rect.y - self._last_rect.y) > 3:
3089 self._last3_rect = wx.Rect(*self._last2_rect)
3090 self._last2_rect = wx.Rect(*self._last_rect)
3091 self._last_rect = wx.Rect(*win_rect)
3094 # prevent frame redocking during resize
3095 if self._last_rect.GetSize() != win_rect.GetSize():
3096 self._last3_rect = wx.Rect(*self._last2_rect)
3097 self._last2_rect = wx.Rect(*self._last_rect)
3098 self._last_rect = wx.Rect(*win_rect)
3101 self._last3_rect = wx.Rect(*self._last2_rect)
3102 self._last2_rect = wx.Rect(*self._last_rect)
3103 self._last_rect = wx.Rect(*win_rect)
3105 if _VERSION_STRING < "2.9":
3106 leftDown = wx.GetMouseState().LeftDown()
3108 leftDown = wx.GetMouseState().LeftIsDown()
3113 if not self._moving:
3114 self.OnMoveStart(event)
3117 if self._last3_rect.IsEmpty():
3120 self.OnMoving(event)
3123 def OnIdle(self, event):
3125 Handles the ``wx.EVT_IDLE`` event for L{AuiFloatingFrame}.
3127 :param `event`: a `wx.IdleEvent` event to be processed.
3129 :note: This event is only processed on wxMAC or if L{AuiManager} is using the
3130 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3134 if _VERSION_STRING < "2.9":
3135 leftDown = wx.GetMouseState().LeftDown()
3137 leftDown = wx.GetMouseState().LeftIsDown()
3140 self._moving = False
3141 self.OnMoveFinished()
3146 def OnMoveStart(self, event):
3148 The user has just started moving the floating pane.
3150 :param `event`: an instance of `wx.MouseEvent`.
3152 :note: This method is used only on wxMAC or if L{AuiManager} is using the
3153 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3156 # notify the owner manager that the pane has started to move
3158 if self._owner_mgr._from_move:
3160 self._owner_mgr._action_window = self._pane_window
3161 point = wx.GetMousePosition()
3162 action_offset = point - self.GetPosition()
3164 if self._is_toolbar:
3165 self._owner_mgr._toolbar_action_offset = action_offset
3166 self._owner_mgr.OnMotion_DragToolbarPane(point)
3168 self._owner_mgr._action_offset = action_offset
3169 self._owner_mgr.OnMotion_DragFloatingPane(point)
3172 def OnMoving(self, event):
3174 The user is moving the floating pane.
3176 :param `event`: an instance of `wx.MouseEvent`.
3178 :note: This method is used only on wxMAC or if L{AuiManager} is using the
3179 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3182 # notify the owner manager that the pane is moving
3183 self.OnMoveStart(event)
3186 def OnMoveFinished(self):
3188 The user has just finished moving the floating pane.
3190 :note: This method is used only on wxMAC or if L{AuiManager} is using the
3191 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3194 # notify the owner manager that the pane has finished moving
3196 self._owner_mgr._action_window = self._pane_window
3197 point = wx.GetMousePosition()
3198 if self._is_toolbar:
3199 self._owner_mgr.OnLeftUp_DragToolbarPane(point)
3201 self._owner_mgr.OnLeftUp_DragFloatingPane(point)
3203 self._owner_mgr.OnFloatingPaneMoved(self._pane_window, point)
3206 def OnCheckFlyTimer(self, event):
3208 Handles the ``wx.EVT_TIMER`` event for L{AuiFloatingFrame}.
3210 :param `event`: a `wx.TimerEvent` to be processed.
3212 :note: This is used solely for "fly-out" panes.
3216 pane = self._mgr.GetPane(self._pane_window)
3218 if self.IsShownOnScreen():
3222 def OnFindManager(self, event):
3224 Handles the ``EVT_AUI_FIND_MANAGER`` event for L{AuiFloatingFrame}.
3226 :param `event`: a L{AuiManagerEvent} event to be processed.
3229 event.SetManager(self._owner_mgr)
3233 """ Starts the flying in and out of a floating pane. """
3235 if self._fly_timer.IsRunning():
3238 if _VERSION_STRING < "2.9":
3239 leftDown = wx.GetMouseState().LeftDown()
3241 leftDown = wx.GetMouseState().LeftIsDown()
3246 rect = wx.Rect(*self.GetScreenRect())
3247 rect.Inflate(10, 10)
3249 if rect.Contains(wx.GetMousePosition()):
3252 self._send_size = False
3253 self._fly_timer.Start(5)
3257 self._send_size = False
3258 self._fly_timer.Start(5)
3261 def OnFlyTimer(self, event):
3263 Handles the ``wx.EVT_TIMER`` event for L{AuiFloatingFrame}.
3265 :param `event`: a `wx.TimerEvent` to be processed.
3268 current_size = self.GetClientSize()
3269 floating_size = wx.Size(*self._owner_mgr.GetPane(self._pane_window).floating_size)
3271 if floating_size.y == -1:
3272 floating_size = self._floating_size
3275 min_size = self._mgr.GetArtProvider().GetMetric(AUI_DOCKART_CAPTION_SIZE)
3277 if wx.Platform != "__WXMSW__":
3278 min_size += 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)
3280 if current_size.y - self._fly_step <= min_size:
3281 self.SetClientSize((current_size.x, min_size))
3283 self._fly_timer.Stop()
3284 self._send_size = True
3286 self.SetClientSize((current_size.x, current_size.y-self._fly_step))
3289 if current_size.y + self._fly_step >= floating_size.y:
3290 self.SetClientSize((current_size.x, floating_size.y))
3292 self._fly_timer.Stop()
3293 self._send_size = True
3295 self.SetClientSize((current_size.x, current_size.y+self._fly_step))
3302 """ Actually starts the fading out of the floating pane. """
3305 self._alpha_amount -= 10
3306 if self._alpha_amount <= 0:
3307 self._alpha_amount = 255
3310 self.SetTransparent(self._alpha_amount)
3315 # -- static utility functions --
3317 def DrawResizeHint(dc, rect):
3319 Draws a resize hint while a sash is dragged.
3321 :param `rect`: a `wx.Rect` rectangle which specifies the sash dimensions.
3324 if wx.Platform == "__WXMSW__" and wx.App.GetComCtl32Version() >= 600:
3325 if wx.GetOsVersion()[1] > 5:
3327 dc.SetPen(wx.Pen("black", 2, wx.SOLID))
3328 dc.SetBrush(wx.TRANSPARENT_BRUSH)
3330 # Draw the nice XP style splitter
3331 dc.SetPen(wx.TRANSPARENT_PEN)
3332 dc.SetBrush(wx.BLACK_BRUSH)
3333 dc.SetLogicalFunction(wx.INVERT)
3334 dc.DrawRectangleRect(rect)
3335 dc.SetLogicalFunction(wx.COPY)
3337 stipple = PaneCreateStippleBitmap()
3338 brush = wx.BrushFromBitmap(stipple)
3340 dc.SetPen(wx.TRANSPARENT_PEN)
3342 dc.SetLogicalFunction(wx.XOR)
3343 dc.DrawRectangleRect(rect)
3346 def CopyDocksAndPanes(src_docks, src_panes):
3348 This utility function creates shallow copies of
3349 the dock and pane info. L{AuiDockInfo} usually contain pointers
3350 to L{AuiPaneInfo} classes, thus this function is necessary to reliably
3351 reconstruct that relationship in the new dock info and pane info arrays.
3353 :param `src_docks`: a list of L{AuiDockInfo} classes;
3354 :param `src_panes`: a list of L{AuiPaneInfo} classes.
3357 dest_docks = src_docks
3358 dest_panes = src_panes
3360 for ii in xrange(len(dest_docks)):
3361 dock = dest_docks[ii]
3362 for jj in xrange(len(dock.panes)):
3363 for kk in xrange(len(src_panes)):
3364 if dock.panes[jj] == src_panes[kk]:
3365 dock.panes[jj] = dest_panes[kk]
3367 return dest_docks, dest_panes
3370 def CopyDocksAndPanes2(src_docks, src_panes):
3372 This utility function creates full copies of
3373 the dock and pane info. L{AuiDockInfo} usually contain pointers
3374 to L{AuiPaneInfo} classes, thus this function is necessary to reliably
3375 reconstruct that relationship in the new dock info and pane info arrays.
3377 :param `src_docks`: a list of L{AuiDockInfo} classes;
3378 :param `src_panes`: a list of L{AuiPaneInfo} classes.
3383 for ii in xrange(len(src_docks)):
3384 dest_docks.append(AuiDockInfo())
3385 dest_docks[ii].dock_direction = src_docks[ii].dock_direction
3386 dest_docks[ii].dock_layer = src_docks[ii].dock_layer
3387 dest_docks[ii].dock_row = src_docks[ii].dock_row
3388 dest_docks[ii].size = src_docks[ii].size
3389 dest_docks[ii].min_size = src_docks[ii].min_size
3390 dest_docks[ii].resizable = src_docks[ii].resizable
3391 dest_docks[ii].fixed = src_docks[ii].fixed
3392 dest_docks[ii].toolbar = src_docks[ii].toolbar
3393 dest_docks[ii].panes = src_docks[ii].panes
3394 dest_docks[ii].rect = wx.Rect(*src_docks[ii].rect)
3398 for ii in xrange(len(src_panes)):
3399 dest_panes.append(AuiPaneInfo())
3400 dest_panes[ii].name = src_panes[ii].name
3401 dest_panes[ii].caption = src_panes[ii].caption
3402 dest_panes[ii].window = src_panes[ii].window
3403 dest_panes[ii].frame = src_panes[ii].frame
3404 dest_panes[ii].state = src_panes[ii].state
3405 dest_panes[ii].dock_direction = src_panes[ii].dock_direction
3406 dest_panes[ii].dock_layer = src_panes[ii].dock_layer
3407 dest_panes[ii].dock_row = src_panes[ii].dock_row
3408 dest_panes[ii].dock_pos = src_panes[ii].dock_pos
3409 dest_panes[ii].best_size = wx.Size(*src_panes[ii].best_size)
3410 dest_panes[ii].min_size = wx.Size(*src_panes[ii].min_size)
3411 dest_panes[ii].max_size = wx.Size(*src_panes[ii].max_size)
3412 dest_panes[ii].floating_pos = wx.Point(*src_panes[ii].floating_pos)
3413 dest_panes[ii].floating_size = wx.Size(*src_panes[ii].floating_size)
3414 dest_panes[ii].dock_proportion = src_panes[ii].dock_proportion
3415 dest_panes[ii].buttons = src_panes[ii].buttons
3416 dest_panes[ii].rect = wx.Rect(*src_panes[ii].rect)
3417 dest_panes[ii].icon = src_panes[ii].icon
3418 dest_panes[ii].notebook_id = src_panes[ii].notebook_id
3419 dest_panes[ii].transparent = src_panes[ii].transparent
3420 dest_panes[ii].snapped = src_panes[ii].snapped
3421 dest_panes[ii].minimize_mode = src_panes[ii].minimize_mode
3423 for ii in xrange(len(dest_docks)):
3424 dock = dest_docks[ii]
3425 for jj in xrange(len(dock.panes)):
3426 for kk in xrange(len(src_panes)):
3427 if dock.panes[jj] == src_panes[kk]:
3428 dock.panes[jj] = dest_panes[kk]
3430 dest_docks[ii] = dock
3432 return dest_docks, dest_panes
3435 def GetMaxLayer(docks, dock_direction):
3437 This is an internal function which returns
3438 the highest layer inside the specified dock.
3440 :param `docks`: a list of L{AuiDockInfo};
3441 :param `dock_direction`: the L{AuiDockInfo} docking direction to analyze.
3447 if dock.dock_direction == dock_direction and dock.dock_layer > max_layer and not dock.fixed:
3448 max_layer = dock.dock_layer
3453 def GetMaxRow(panes, dock_direction, dock_layer):
3455 This is an internal function which returns
3456 the highest layer inside the specified dock.
3458 :param `panes`: a list of L{AuiPaneInfo};
3459 :param `dock_direction`: the L{AuiPaneInfo} docking direction to analyze;
3460 :param `dock_layer`: the L{AuiPaneInfo} layer to analyze.
3466 if pane.dock_direction == dock_direction and pane.dock_layer == dock_layer and \
3467 pane.dock_row > max_row:
3468 max_row = pane.dock_row
3473 def DoInsertDockLayer(panes, dock_direction, dock_layer):
3475 This is an internal function that inserts a new dock
3476 layer by incrementing all existing dock layer values by one.
3478 :param `panes`: a list of L{AuiPaneInfo};
3479 :param `dock_direction`: the L{AuiPaneInfo} docking direction to analyze;
3480 :param `dock_layer`: the L{AuiPaneInfo} layer to analyze.
3483 for ii in xrange(len(panes)):
3485 if not pane.IsFloating() and pane.dock_direction == dock_direction and pane.dock_layer >= dock_layer:
3486 pane.dock_layer = pane.dock_layer + 1
3493 def DoInsertDockRow(panes, dock_direction, dock_layer, dock_row):
3495 This is an internal function that inserts a new dock
3496 row by incrementing all existing dock row values by one.
3498 :param `panes`: a list of L{AuiPaneInfo};
3499 :param `dock_direction`: the L{AuiPaneInfo} docking direction to analyze;
3500 :param `dock_layer`: the L{AuiPaneInfo} layer to analyze;
3501 :param `dock_row`: the L{AuiPaneInfo} row to analyze.
3505 if not pane.IsFloating() and pane.dock_direction == dock_direction and \
3506 pane.dock_layer == dock_layer and pane.dock_row >= dock_row:
3512 def DoInsertPane(panes, dock_direction, dock_layer, dock_row, dock_pos):
3514 This is an internal function that inserts a new pane
3515 by incrementing all existing dock position values by one.
3517 :param `panes`: a list of L{AuiPaneInfo};
3518 :param `dock_direction`: the L{AuiPaneInfo} docking direction to analyze;
3519 :param `dock_layer`: the L{AuiPaneInfo} layer to analyze;
3520 :param `dock_row`: the L{AuiPaneInfo} row to analyze;
3521 :param `dock_pos`: the L{AuiPaneInfo} row to analyze.
3524 for ii in xrange(len(panes)):
3526 if not pane.IsFloating() and pane.dock_direction == dock_direction and \
3527 pane.dock_layer == dock_layer and pane.dock_row == dock_row and \
3528 pane.dock_pos >= dock_pos:
3529 pane.dock_pos = pane.dock_pos + 1
3536 def FindDocks(docks, dock_direction, dock_layer=-1, dock_row=-1, reverse=False):
3538 This is an internal function that returns a list of docks which meet
3539 the specified conditions in the parameters and returns a sorted array
3540 (sorted by layer and then row).
3542 :param `docks`: a list of L{AuiDockInfo};
3543 :param `dock_direction`: the L{AuiDockInfo} docking direction to analyze;
3544 :param `dock_layer`: the L{AuiDockInfo} layer to analyze;
3545 :param `dock_row`: the L{AuiDockInfo} row to analyze;
3548 matchDocks = [(d.dock_layer, d.dock_row, d.dock_direction, d) for d in docks if \
3549 (dock_direction == -1 or dock_direction == d.dock_direction) and \
3550 ((dock_layer == -1 or dock_layer == d.dock_layer) and \
3551 (dock_row == -1 or dock_row == d.dock_row))]
3553 arr = [x[-1] for x in sorted(matchDocks, reverse=reverse)]
3558 def FindOppositeDocks(docks, dock_direction):
3560 This is an internal function that returns a list of docks
3561 which is related to the opposite direction.
3563 :param `docks`: a list of L{AuiDockInfo};
3564 :param `dock_direction`: the L{AuiDockInfo} docking direction to analyze;
3567 if dock_direction == AUI_DOCK_LEFT:
3568 arr = FindDocks(docks, AUI_DOCK_RIGHT, -1, -1)
3569 elif dock_direction == AUI_DOCK_TOP:
3570 arr = FindDocks(docks, AUI_DOCK_BOTTOM, -1, -1)
3571 elif dock_direction == AUI_DOCK_RIGHT:
3572 arr = FindDocks(docks, AUI_DOCK_LEFT, -1, -1)
3573 elif dock_direction == AUI_DOCK_BOTTOM:
3574 arr = FindDocks(docks, AUI_DOCK_TOP, -1, -1)
3579 def FindPaneInDock(dock, window):
3581 This method looks up a specified window pointer inside a dock.
3582 If found, the corresponding L{AuiPaneInfo} pointer is returned, otherwise ``None``.
3584 :param `dock`: a L{AuiDockInfo} structure;
3585 :param `window`: a `wx.Window` derived window (associated to a pane).
3588 for p in dock.panes:
3589 if p.window == window:
3595 def GetToolBarDockOffsets(docks):
3597 Returns the toolbar dock offsets (top-left and bottom-right).
3599 :param `docks`: a list of L{AuiDockInfo} to analyze.
3602 top_left = wx.Size(0, 0)
3603 bottom_right = wx.Size(0, 0)
3607 dock_direction = dock.dock_direction
3608 if dock_direction == AUI_DOCK_LEFT:
3609 top_left.x += dock.rect.width
3610 bottom_right.x += dock.rect.width
3612 elif dock_direction == AUI_DOCK_TOP:
3613 top_left.y += dock.rect.height
3614 bottom_right.y += dock.rect.height
3616 elif dock_direction == AUI_DOCK_RIGHT:
3617 bottom_right.x += dock.rect.width
3619 elif dock_direction == AUI_DOCK_BOTTOM:
3620 bottom_right.y += dock.rect.height
3622 return top_left, bottom_right
3625 def GetInternalFrameRect(window, docks):
3627 Returns the window rectangle excluding toolbars.
3629 :param `window`: a `wx.Window` derived window;
3630 :param `docks`: a list of L{AuiDockInfo} structures.
3633 frameRect = wx.Rect()
3635 frameRect.SetTopLeft(window.ClientToScreen(window.GetClientAreaOrigin()))
3636 frameRect.SetSize(window.GetClientSize())
3638 top_left, bottom_right = GetToolBarDockOffsets(docks)
3640 # make adjustments for toolbars
3641 frameRect.x += top_left.x
3642 frameRect.y += top_left.y
3643 frameRect.width -= bottom_right.x
3644 frameRect.height -= bottom_right.y
3649 def CheckOutOfWindow(window, pt):
3651 Checks if a point is outside the window rectangle.
3653 :param `window`: a `wx.Window` derived window;
3654 :param `pt`: a `wx.Point` object.
3657 auiWindowMargin = 30
3658 marginRect = wx.Rect(*window.GetClientRect())
3659 marginRect.Inflate(auiWindowMargin, auiWindowMargin)
3661 return not marginRect.Contains(pt)
3664 def CheckEdgeDrop(window, docks, pt):
3666 Checks on which edge of a window the drop action has taken place.
3668 :param `window`: a `wx.Window` derived window;
3669 :param `docks`: a list of L{AuiDockInfo} structures;
3670 :param `pt`: a `wx.Point` object.
3673 screenPt = window.ClientToScreen(pt)
3674 clientSize = window.GetClientSize()
3675 frameRect = GetInternalFrameRect(window, docks)
3677 if screenPt.y >= frameRect.GetTop() and screenPt.y < frameRect.GetBottom():
3678 if pt.x < auiLayerInsertOffset and pt.x > auiLayerInsertOffset - auiLayerInsertPixels:
3681 if pt.x >= clientSize.x - auiLayerInsertOffset and \
3682 pt.x < clientSize.x - auiLayerInsertOffset + auiLayerInsertPixels:
3685 if screenPt.x >= frameRect.GetLeft() and screenPt.x < frameRect.GetRight():
3686 if pt.y < auiLayerInsertOffset and pt.y > auiLayerInsertOffset - auiLayerInsertPixels:
3689 if pt.y >= clientSize.y - auiLayerInsertOffset and \
3690 pt.y < clientSize.y - auiLayerInsertOffset + auiLayerInsertPixels:
3696 def RemovePaneFromDocks(docks, pane, exc=None):
3698 Removes a pane window from all docks
3699 with a possible exception specified by parameter `exc`.
3701 :param `docks`: a list of L{AuiDockInfo} structures;
3702 :param `pane`: the L{AuiPaneInfo} pane to be removed;
3703 :param `exc`: the possible pane exception.
3706 for ii in xrange(len(docks)):
3710 pi = FindPaneInDock(d, pane.window)
3719 def RenumberDockRows(docks):
3721 Takes a dock and assigns sequential numbers
3722 to existing rows. Basically it takes out the gaps so if a
3723 dock has rows with numbers 0, 2, 5, they will become 0, 1, 2.
3725 :param `docks`: a list of L{AuiDockInfo} structures.
3728 for ii in xrange(len(docks)):
3731 for jj in xrange(len(dock.panes)):
3732 dock.panes[jj].dock_row = ii
3739 def SetActivePane(panes, active_pane):
3741 Sets the active pane, as well as cycles through
3742 every other pane and makes sure that all others' active flags
3745 :param `panes`: a list of L{AuiPaneInfo} structures;
3746 :param `active_pane`: the pane to be made active (if found).
3750 pane.state &= ~AuiPaneInfo.optionActive
3753 if pane.window == active_pane and not pane.IsNotebookPage():
3754 pane.state |= AuiPaneInfo.optionActive
3760 def ShowDockingGuides(guides, show):
3762 Shows or hide the docking guide windows.
3764 :param `guides`: a list of L{AuiDockingGuideInfo} classes;
3765 :param `show`: whether to show or hide the docking guide windows.
3768 for target in guides:
3770 if show and not target.host.IsShown():
3772 target.host.Update()
3774 elif not show and target.host.IsShown():
3778 def RefreshDockingGuides(guides):
3780 Refreshes the docking guide windows.
3782 :param `guides`: a list of L{AuiDockingGuideInfo} classes;
3785 for target in guides:
3786 if target.host.IsShown():
3787 target.host.Refresh()
3790 def PaneSortFunc(p1, p2):
3792 This function is used to sort panes by dock position.
3794 :param `p1`: a L{AuiPaneInfo} instance;
3795 :param `p2`: another L{AuiPaneInfo} instance.
3798 return (p1.dock_pos < p2.dock_pos and [-1] or [1])[0]
3801 def GetNotebookRoot(panes, notebook_id):
3803 Returns the L{AuiPaneInfo} which has the specified `notebook_id`.
3805 :param `panes`: a list of L{AuiPaneInfo} instances;
3806 :param `notebook_id`: the target notebook id.
3809 for paneInfo in panes:
3810 if paneInfo.IsNotebookControl() and paneInfo.notebook_id == notebook_id:
3816 def EscapeDelimiters(s):
3818 Changes ``;`` into ``\`` and ``|`` into ``\|`` in the input string.
3820 :param `s`: the string to be analyzed.
3822 :note: This is an internal functions which is used for saving perspectives.
3825 result = s.replace(";", "\\")
3826 result = result.replace("|", "|\\")
3831 def IsDifferentDockingPosition(pane1, pane2):
3833 Returns whether `pane1` and `pane2` are in a different docking position
3834 based on pane status, docking direction, docking layer and docking row.
3836 :param `pane1`: a L{AuiPaneInfo} instance;
3837 :param `pane2`: another L{AuiPaneInfo} instance.
3840 return pane1.IsFloating() != pane2.IsFloating() or \
3841 pane1.dock_direction != pane2.dock_direction or \
3842 pane1.dock_layer != pane2.dock_layer or \
3843 pane1.dock_row != pane2.dock_row
3846 # Convenience function
3847 def AuiManager_HasLiveResize(manager):
3849 Static function which returns if the input `manager` should have "live resize"
3852 :param `manager`: an instance of L{AuiManager}.
3854 :note: This method always returns ``True`` on wxMac as this platform doesn't have
3855 the ability to use `wx.ScreenDC` to draw sashes.
3858 # With Core Graphics on Mac, it's not possible to show sash feedback,
3859 # so we'll always use live update instead.
3861 if wx.Platform == "__WXMAC__":
3864 return (manager.GetAGWFlags() & AUI_MGR_LIVE_RESIZE) == AUI_MGR_LIVE_RESIZE
3867 # Convenience function
3868 def AuiManager_UseNativeMiniframes(manager):
3870 Static function which returns if the input `manager` should use native `wx.MiniFrame` as
3873 :param `manager`: an instance of L{AuiManager}.
3875 :note: This method always returns ``True`` on wxMac as this platform doesn't have
3876 the ability to use custom drawn miniframes.
3879 # With Core Graphics on Mac, it's not possible to show sash feedback,
3880 # so we'll always use live update instead.
3882 if wx.Platform == "__WXMAC__":
3885 return (manager.GetAGWFlags() & AUI_MGR_USE_NATIVE_MINIFRAMES) == AUI_MGR_USE_NATIVE_MINIFRAMES
3888 def GetManager(window):
3890 This function will return the aui manager for a given window.
3892 :param `window`: this parameter should be any child window or grand-child
3893 window (and so on) of the frame/window managed by L{AuiManager}. The window
3894 does not need to be managed by the manager itself, nor does it even need
3895 to be a child or sub-child of a managed window. It must however be inside
3896 the window hierarchy underneath the managed window.
3899 if not isinstance(wx.GetTopLevelParent(window), AuiFloatingFrame):
3900 if isinstance(window, auibar.AuiToolBar):
3901 return window.GetAuiManager()
3903 evt = AuiManagerEvent(wxEVT_AUI_FIND_MANAGER)
3904 evt.SetManager(None)
3905 evt.ResumePropagation(wx.EVENT_PROPAGATE_MAX)
3907 if not window.GetEventHandler().ProcessEvent(evt):
3910 return evt.GetManager()
3913 # ---------------------------------------------------------------------------- #
3915 class AuiManager(wx.EvtHandler):
3917 AuiManager manages the panes associated with it for a particular `wx.Frame`,
3918 using a pane's L{AuiPaneInfo} information to determine each pane's docking and
3919 floating behavior. L{AuiManager} uses wxPython's sizer mechanism to plan the
3920 layout of each frame. It uses a replaceable dock art class to do all drawing,
3921 so all drawing is localized in one area, and may be customized depending on an
3922 applications' specific needs.
3924 L{AuiManager} works as follows: the programmer adds panes to the class, or makes
3925 changes to existing pane properties (dock position, floating state, show state, etc...).
3926 To apply these changes, the L{AuiManager.Update} function is called. This batch
3927 processing can be used to avoid flicker, by modifying more than one pane at a time,
3928 and then "committing" all of the changes at once by calling `Update()`.
3930 Panes can be added quite easily::
3932 text1 = wx.TextCtrl(self, -1)
3933 text2 = wx.TextCtrl(self, -1)
3934 self._mgr.AddPane(text1, AuiPaneInfo().Left().Caption("Pane Number One"))
3935 self._mgr.AddPane(text2, AuiPaneInfo().Bottom().Caption("Pane Number Two"))
3940 Later on, the positions can be modified easily. The following will float an
3941 existing pane in a tool window::
3943 self._mgr.GetPane(text1).Float()
3946 **Layers, Rows and Directions, Positions:**
3948 Inside AUI, the docking layout is figured out by checking several pane parameters.
3949 Four of these are important for determining where a pane will end up.
3951 **Direction** - Each docked pane has a direction, `Top`, `Bottom`, `Left`, `Right`, or `Center`.
3952 This is fairly self-explanatory. The pane will be placed in the location specified
3955 **Position** - More than one pane can be placed inside of a "dock". Imagine two panes
3956 being docked on the left side of a window. One pane can be placed over another.
3957 In proportionally managed docks, the pane position indicates it's sequential position,
3958 starting with zero. So, in our scenario with two panes docked on the left side, the
3959 top pane in the dock would have position 0, and the second one would occupy position 1.
3961 **Row** - A row can allow for two docks to be placed next to each other. One of the most
3962 common places for this to happen is in the toolbar. Multiple toolbar rows are allowed,
3963 the first row being in row 0, and the second in row 1. Rows can also be used on
3964 vertically docked panes.
3966 **Layer** - A layer is akin to an onion. Layer 0 is the very center of the managed pane.
3967 Thus, if a pane is in layer 0, it will be closest to the center window (also sometimes
3968 known as the "content window"). Increasing layers "swallow up" all layers of a lower
3969 value. This can look very similar to multiple rows, but is different because all panes
3970 in a lower level yield to panes in higher levels. The best way to understand layers
3971 is by running the AUI sample (`AUI.py`).
3974 def __init__(self, managed_window=None, agwFlags=None):
3976 Default class constructor.
3978 :param `managed_window`: specifies the window which should be managed;
3979 :param `agwFlags`: specifies options which allow the frame management behavior to be
3980 modified. `agwFlags` can be a combination of the following style bits:
3982 ==================================== ==================================
3983 Flag name Description
3984 ==================================== ==================================
3985 ``AUI_MGR_ALLOW_FLOATING`` Allow floating of panes
3986 ``AUI_MGR_ALLOW_ACTIVE_PANE`` If a pane becomes active, "highlight" it in the interface
3987 ``AUI_MGR_TRANSPARENT_DRAG`` If the platform supports it, set transparency on a floating pane while it is dragged by the user
3988 ``AUI_MGR_TRANSPARENT_HINT`` If the platform supports it, show a transparent hint window when the user is about to dock a floating pane
3989 ``AUI_MGR_VENETIAN_BLINDS_HINT`` Show a "venetian blind" effect when the user is about to dock a floating pane
3990 ``AUI_MGR_RECTANGLE_HINT`` Show a rectangle hint effect when the user is about to dock a floating pane
3991 ``AUI_MGR_HINT_FADE`` If the platform supports it, the hint window will fade in and out
3992 ``AUI_MGR_NO_VENETIAN_BLINDS_FADE`` Disables the "venetian blind" fade in and out
3993 ``AUI_MGR_LIVE_RESIZE`` Live resize when the user drag a sash
3994 ``AUI_MGR_ANIMATE_FRAMES`` Fade-out floating panes when they are closed (all platforms which support frames transparency) and show a moving rectangle when they are docked (Windows < Vista and GTK only)
3995 ``AUI_MGR_AERO_DOCKING_GUIDES`` Use the new Aero-style bitmaps as docking guides
3996 ``AUI_MGR_PREVIEW_MINIMIZED_PANES`` Slide in and out minimized panes to preview them
3997 ``AUI_MGR_WHIDBEY_DOCKING_GUIDES`` Use the new Whidbey-style bitmaps as docking guides
3998 ``AUI_MGR_SMOOTH_DOCKING`` Performs a "smooth" docking of panes (a la PyQT)
3999 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` Use miniframes with native caption bar as floating panes instead or custom drawn caption bars (forced on wxMac)
4000 ``AUI_MGR_AUTONB_NO_CAPTION`` Panes that merge into an automatic notebook will not have the pane caption visible
4001 ==================================== ==================================
4003 Default value for `agwFlags` is:
4004 ``AUI_MGR_DEFAULT`` = ``AUI_MGR_ALLOW_FLOATING`` | ``AUI_MGR_TRANSPARENT_HINT`` | ``AUI_MGR_HINT_FADE`` | ``AUI_MGR_NO_VENETIAN_BLINDS_FADE``
4006 :note: If using the ``AUI_MGR_USE_NATIVE_MINIFRAMES``, double-clicking on a
4007 floating pane caption will not re-dock the pane, but simply maximize it (if
4008 L{AuiPaneInfo.MaximizeButton} has been set to ``True``) or do nothing.
4011 wx.EvtHandler.__init__(self)
4013 self._action = actionNone
4014 self._action_window = None
4015 self._hover_button = None
4016 self._art = dockart.AuiDefaultDockArt()
4017 self._hint_window = None
4018 self._active_pane = None
4019 self._has_maximized = False
4020 self._has_minimized = False
4023 self._dock_constraint_x = 0.3
4024 self._dock_constraint_y = 0.3
4025 self._reserved = None
4032 self._notebooks = []
4034 self._masterManager = None
4035 self._currentDragItem = -1
4036 self._lastknowndocks = {}
4038 self._hint_fadetimer = wx.Timer(self, wx.ID_ANY)
4039 self._hint_fademax = 50
4040 self._last_hint = wx.Rect()
4042 self._from_move = False
4043 self._last_rect = wx.Rect()
4045 if agwFlags is None:
4046 agwFlags = AUI_MGR_DEFAULT
4048 self._agwFlags = agwFlags
4049 self._is_docked = (False, wx.RIGHT, wx.TOP, 0)
4050 self._snap_limits = (15, 15)
4052 if wx.Platform == "__WXMSW__":
4053 self._animation_step = 30.0
4055 self._animation_step = 5.0
4057 self._hint_rect = wx.Rect()
4059 self._preview_timer = wx.Timer(self, wx.ID_ANY)
4060 self._sliding_frame = None
4062 self._autoNBTabArt = tabart.AuiDefaultTabArt()
4063 self._autoNBStyle = AUI_NB_DEFAULT_STYLE | AUI_NB_BOTTOM | \
4064 AUI_NB_SUB_NOTEBOOK | AUI_NB_TAB_EXTERNAL_MOVE
4065 self._autoNBStyle -= AUI_NB_DRAW_DND_TAB
4068 self.SetManagedWindow(managed_window)
4070 self.Bind(wx.EVT_PAINT, self.OnPaint)
4071 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
4072 self.Bind(wx.EVT_SIZE, self.OnSize)
4073 self.Bind(wx.EVT_SET_CURSOR, self.OnSetCursor)
4074 self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
4075 self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
4076 self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
4077 self.Bind(wx.EVT_MOTION, self.OnMotion)
4078 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
4079 self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
4080 self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnCaptureLost)
4081 self.Bind(wx.EVT_TIMER, self.OnHintFadeTimer, self._hint_fadetimer)
4082 self.Bind(wx.EVT_TIMER, self.SlideIn, self._preview_timer)
4084 self.Bind(wx.EVT_MOVE, self.OnMove)
4085 self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChanged)
4087 self.Bind(EVT_AUI_PANE_BUTTON, self.OnPaneButton)
4088 self.Bind(EVT_AUI_RENDER, self.OnRender)
4089 self.Bind(EVT_AUI_FIND_MANAGER, self.OnFindManager)
4090 self.Bind(EVT_AUI_PANE_MIN_RESTORE, self.OnRestoreMinimizedPane)
4091 self.Bind(EVT_AUI_PANE_DOCKED, self.OnPaneDocked)
4093 self.Bind(auibook.EVT_AUINOTEBOOK_BEGIN_DRAG, self.OnTabBeginDrag)
4094 self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnTabPageClose)
4095 self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnTabSelected)
4098 def CreateFloatingFrame(self, parent, pane_info):
4100 Creates a floating frame for the windows.
4102 :param `parent`: the floating frame parent;
4103 :param `pane_info`: the L{AuiPaneInfo} class with all the pane's information.
4106 return AuiFloatingFrame(parent, self, pane_info)
4109 def CanDockPanel(self, p):
4111 Returns whether a pane can be docked or not.
4113 :param `p`: the L{AuiPaneInfo} class with all the pane's information.
4116 # is the pane dockable?
4117 if not p.IsDockable():
4120 # if a key modifier is pressed while dragging the frame,
4121 # don't dock the window
4122 return not (wx.GetKeyState(wx.WXK_CONTROL) or wx.GetKeyState(wx.WXK_ALT))
4125 def GetPaneByWidget(self, window):
4127 This version of L{GetPane} looks up a pane based on a
4130 :param `window`: a `wx.Window` derived window.
4135 for p in self._panes:
4136 if p.window == window:
4142 def GetPaneByName(self, name):
4144 This version of L{GetPane} looks up a pane based on a
4147 :param `name`: the pane name.
4152 for p in self._panes:
4159 def GetPane(self, item):
4161 Looks up a L{AuiPaneInfo} structure based
4162 on the supplied window pointer. Upon failure, L{GetPane}
4163 returns an empty L{AuiPaneInfo}, a condition which can be checked
4164 by calling L{AuiPaneInfo.IsOk}.
4166 The pane info's structure may then be modified. Once a pane's
4167 info is modified, L{Update} must be called to
4168 realize the changes in the UI.
4170 :param `item`: either a pane name or a `wx.Window`.
4173 if isinstance(item, basestring):
4174 return self.GetPaneByName(item)
4176 return self.GetPaneByWidget(item)
4179 def GetAllPanes(self):
4180 """ Returns a reference to all the pane info structures. """
4185 def ShowPane(self, window, show):
4187 Shows or hides a pane based on the window passed as input.
4189 :param `window`: a `wx.Window` derived window;
4190 :param `show`: ``True`` to show the pane, ``False`` otherwise.
4193 p = self.GetPane(window)
4196 if p.IsNotebookPage():
4199 notebook = self._notebooks[p.notebook_id]
4200 id = notebook.GetPageIndex(p.window)
4202 notebook.SetSelection(id)
4203 self.ShowPane(notebook, True)
4214 def HitTest(self, x, y):
4216 This is an internal function which determines
4217 which UI item the specified coordinates are over.
4219 :param `x`: specifies a x position in client coordinates;
4220 :param `y`: specifies a y position in client coordinates.
4225 for item in self._uiparts:
4226 # we are not interested in typeDock, because this space
4227 # isn't used to draw anything, just for measurements
4228 # besides, the entire dock area is covered with other
4229 # rectangles, which we are interested in.
4230 if item.type == AuiDockUIPart.typeDock:
4233 # if we already have a hit on a more specific item, we are not
4234 # interested in a pane hit. If, however, we don't already have
4235 # a hit, returning a pane hit is necessary for some operations
4236 if item.type in [AuiDockUIPart.typePane, AuiDockUIPart.typePaneBorder] and result:
4239 # if the point is inside the rectangle, we have a hit
4240 if item.rect.Contains((x, y)):
4246 def PaneHitTest(self, panes, pt):
4248 Similar to L{HitTest}, but it checks in which L{AuiPaneInfo} rectangle the
4249 input point belongs to.
4251 :param `panes`: a list of L{AuiPaneInfo} instances;
4252 :param `pt`: a `wx.Point` object.
4255 for paneInfo in panes:
4256 if paneInfo.IsDocked() and paneInfo.IsShown() and paneInfo.rect.Contains(pt):
4262 # SetAGWFlags() and GetAGWFlags() allow the owner to set various
4263 # options which are global to AuiManager
4265 def SetAGWFlags(self, agwFlags):
4267 This method is used to specify L{AuiManager}'s settings flags.
4269 :param `agwFlags`: specifies options which allow the frame management behavior
4270 to be modified. `agwFlags` can be one of the following style bits:
4272 ==================================== ==================================
4273 Flag name Description
4274 ==================================== ==================================
4275 ``AUI_MGR_ALLOW_FLOATING`` Allow floating of panes
4276 ``AUI_MGR_ALLOW_ACTIVE_PANE`` If a pane becomes active, "highlight" it in the interface
4277 ``AUI_MGR_TRANSPARENT_DRAG`` If the platform supports it, set transparency on a floating pane while it is dragged by the user
4278 ``AUI_MGR_TRANSPARENT_HINT`` If the platform supports it, show a transparent hint window when the user is about to dock a floating pane
4279 ``AUI_MGR_VENETIAN_BLINDS_HINT`` Show a "venetian blind" effect when the user is about to dock a floating pane
4280 ``AUI_MGR_RECTANGLE_HINT`` Show a rectangle hint effect when the user is about to dock a floating pane
4281 ``AUI_MGR_HINT_FADE`` If the platform supports it, the hint window will fade in and out
4282 ``AUI_MGR_NO_VENETIAN_BLINDS_FADE`` Disables the "venetian blind" fade in and out
4283 ``AUI_MGR_LIVE_RESIZE`` Live resize when the user drag a sash
4284 ``AUI_MGR_ANIMATE_FRAMES`` Fade-out floating panes when they are closed (all platforms which support frames transparency) and show a moving rectangle when they are docked (Windows < Vista and GTK only)
4285 ``AUI_MGR_AERO_DOCKING_GUIDES`` Use the new Aero-style bitmaps as docking guides
4286 ``AUI_MGR_PREVIEW_MINIMIZED_PANES`` Slide in and out minimized panes to preview them
4287 ``AUI_MGR_WHIDBEY_DOCKING_GUIDES`` Use the new Whidbey-style bitmaps as docking guides
4288 ``AUI_MGR_SMOOTH_DOCKING`` Performs a "smooth" docking of panes (a la PyQT)
4289 ``AUI_MGR_USE_NATIVE_MINIFRAMES`` Use miniframes with native caption bar as floating panes instead or custom drawn caption bars (forced on wxMac)
4290 ``AUI_MGR_AUTONB_NO_CAPTION`` Panes that merge into an automatic notebook will not have the pane caption visible
4291 ==================================== ==================================
4293 :note: If using the ``AUI_MGR_USE_NATIVE_MINIFRAMES``, double-clicking on a
4294 floating pane caption will not re-dock the pane, but simply maximize it (if
4295 L{AuiPaneInfo.MaximizeButton} has been set to ``True``) or do nothing.
4299 self._agwFlags = agwFlags
4301 if len(self._guides) > 0: