remove numpy + matrix
[iramuteq] / aui / framemanager.py
1 # --------------------------------------------------------------------------- #
2 # AUI Library wxPython IMPLEMENTATION
3 #
4 # Original C++ Code From Kirix (wxAUI). You Can Find It At:
5 #
6 #    License: wxWidgets license
7 #
8 # http:#www.kirix.com/en/community/opensource/wxaui/about_wxaui.html
9 #
10 # Current wxAUI Version Tracked: wxWidgets 2.9.0 SVN HEAD
11 #
12 #
13 # Python Code By:
14 #
15 # Andrea Gavana, @ 23 Dec 2005
16 # Latest Revision: 10 Mar 2011, 15.00 GMT
17 #
18 # For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
19 # Write To Me At:
20 #
21 # andrea.gavana@gmail.com
22 # gavana@kpo.kz
23 #
24 # Or, Obviously, To The wxPython Mailing List!!!
25 #
26 # End Of Comments
27 # --------------------------------------------------------------------------- #
28
29 """
30 Description
31 ===========
32
33 framemanager is the central module of the AUI class framework.
34
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.
40
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()`.
46
47 Panes can be added quite easily::
48
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"))
53
54     self._mgr.Update()
55
56
57 Later on, the positions can be modified easily. The following will float an
58 existing pane in a tool window::
59
60     self._mgr.GetPane(text1).Float()
61
62
63 Layers, Rows and Directions, Positions
64 ======================================
65
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.
68
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
71 by this variable.
72
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. 
78
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. 
83
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`).
90 """
91
92 __author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
93 __date__ = "31 March 2009"
94
95
96 import wx
97 import time
98 import types
99 import warnings
100
101 import auibar
102 import auibook
103 import tabmdi
104 import dockart
105 import tabart
106
107 from aui_utilities import Clip, PaneCreateStippleBitmap, GetDockingImage, GetSlidingPoints
108
109 from aui_constants import *
110
111 # Define this as a translation function
112 _ = wx.GetTranslation
113
114 _winxptheme = False
115 if wx.Platform == "__WXMSW__":
116     try:
117         import winxptheme
118         _winxptheme = True
119     except ImportError:
120         pass
121
122 # wxPython version string
123 _VERSION_STRING = wx.VERSION_STRING
124
125 # AUI Events
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()
140
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. """
169
170 # ---------------------------------------------------------------------------- #
171
172 class AuiDockInfo(object):
173     """ A class to store all properties of a dock. """
174
175     def __init__(self):
176         """
177         Default class constructor.
178         Used internally, do not call it in your code!
179         """
180
181         object.__init__(self)
182         
183         self.dock_direction = 0
184         self.dock_layer = 0
185         self.dock_row = 0
186         self.size = 0
187         self.min_size = 0
188         self.resizable = True
189         self.fixed = False
190         self.toolbar = False
191         self.rect = wx.Rect()
192         self.panes = []
193
194
195     def IsOk(self):
196         """
197         Returns whether a dock is valid or not.
198
199         In order to be valid, a dock needs to have a non-zero `dock_direction`.
200         """
201
202         return self.dock_direction != 0
203
204     
205     def IsHorizontal(self):
206         """ Returns whether the dock is horizontal or not. """
207
208         return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
209
210
211     def IsVertical(self):
212         """ Returns whether the dock is vertical or not. """
213
214         return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]
215     
216
217 # ---------------------------------------------------------------------------- #
218
219 class AuiDockingGuideInfo(object):
220     """ A class which holds information about VS2005 docking guide windows. """
221
222     def __init__(self, other=None):
223         """
224         Default class constructor.
225         Used internally, do not call it in your code!
226
227         :param `other`: another instance of L{AuiDockingGuideInfo}.
228         """
229
230         if other:
231             self.Assign(other)
232         else:
233             # window representing the docking target
234             self.host = None
235             # dock direction (top, bottom, left, right, center)
236             self.dock_direction = AUI_DOCK_NONE
237
238
239     def Assign(self, other):
240         """
241         Assigns the properties of the `other` L{AuiDockingGuideInfo} to `self`.
242
243         :param `other`: another instance of L{AuiDockingGuideInfo}.
244         """
245
246         self.host = other.host
247         self.dock_direction = other.dock_direction
248
249
250     def Host(self, h):
251         """
252         Hosts a docking guide window.
253
254         :param `h`: an instance of L{AuiSingleDockingGuide} or L{AuiCenterDockingGuide}.
255         """
256
257         self.host = h
258         return self
259     
260
261     def Left(self):
262         """ Sets the guide window to left docking. """
263
264         self.dock_direction = AUI_DOCK_LEFT
265         return self
266
267     
268     def Right(self):
269         """ Sets the guide window to right docking. """
270
271         self.dock_direction = AUI_DOCK_RIGHT
272         return self 
273
274
275     def Top(self):
276         """ Sets the guide window to top docking. """
277
278         self.dock_direction = AUI_DOCK_TOP
279         return self 
280
281
282     def Bottom(self):
283         """ Sets the guide window to bottom docking. """
284
285         self.dock_direction = AUI_DOCK_BOTTOM
286         return self 
287
288
289     def Center(self):
290         """ Sets the guide window to center docking. """
291
292         self.dock_direction = AUI_DOCK_CENTER
293         return self 
294
295
296     def Centre(self):
297         """ Sets the guide window to centre docking. """
298         
299         self.dock_direction = AUI_DOCK_CENTRE
300         return self
301
302
303 # ---------------------------------------------------------------------------- #
304
305 class AuiDockUIPart(object):
306     """ A class which holds attributes for a UI part in the interface. """
307     
308     typeCaption = 0
309     typeGripper = 1
310     typeDock = 2
311     typeDockSizer = 3
312     typePane = 4
313     typePaneSizer = 5
314     typeBackground = 6
315     typePaneBorder = 7
316     typePaneButton = 8
317
318     def __init__(self):
319         """
320         Default class constructor.
321         Used internally, do not call it in your code!
322         """
323         
324         self.orientation = wx.VERTICAL
325         self.type = 0
326         self.rect = wx.Rect()
327
328
329 # ---------------------------------------------------------------------------- #
330
331 class AuiPaneButton(object):
332     """ A simple class which describes the caption pane button attributes. """
333
334     def __init__(self, button_id):
335         """
336         Default class constructor.
337         Used internally, do not call it in your code!
338
339         :param `button_id`: the pane button identifier.
340         """
341
342         self.button_id = button_id
343
344
345 # ---------------------------------------------------------------------------- #
346
347 # event declarations/classes
348
349 class AuiManagerEvent(wx.PyCommandEvent):
350     """ A specialized command event class for events sent by L{AuiManager}. """
351
352     def __init__(self, eventType, id=1):
353         """
354         Default class constructor.
355
356         :param `eventType`: the event kind;
357         :param `id`: the event identification number.
358         """
359
360         wx.PyCommandEvent.__init__(self, eventType, id)
361
362         self.manager = None
363         self.pane = None
364         self.button = 0
365         self.veto_flag = False
366         self.canveto_flag = True
367         self.dc = None
368
369
370     def SetManager(self, mgr):
371         """
372         Associates a L{AuiManager} to the current event.
373
374         :param `mgr`: an instance of L{AuiManager}.
375         """
376
377         self.manager = mgr
378
379
380     def SetDC(self, pdc):
381         """
382         Associates a `wx.DC` device context to this event.
383
384         :param `pdc`: a `wx.DC` device context object. 
385         """
386
387         self.dc = pdc
388
389
390     def SetPane(self, p):
391         """
392         Associates a L{AuiPaneInfo} instance to this event.
393
394         :param `p`: a L{AuiPaneInfo} instance.
395         """
396         
397         self.pane = p
398
399         
400     def SetButton(self, b):
401         """
402         Associates a L{AuiPaneButton} instance to this event.
403
404         :param `b`: a L{AuiPaneButton} instance.
405         """
406         
407         self.button = b
408
409         
410     def GetManager(self):
411         """ Returns the associated L{AuiManager} (if any). """
412
413         return self.manager
414
415
416     def GetDC(self):
417         """ Returns the associated `wx.DC` device context (if any). """
418
419         return self.dc
420     
421
422     def GetPane(self):
423         """ Returns the associated L{AuiPaneInfo} structure (if any). """
424         
425         return self.pane
426
427
428     def GetButton(self):
429         """ Returns the associated L{AuiPaneButton} instance (if any). """
430
431         return self.button
432
433
434     def Veto(self, veto=True):
435         """
436         Prevents the change announced by this event from happening.
437
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.
441
442         :param `veto`: ``True`` to veto the event, ``False`` otherwise.
443         """
444
445         self.veto_flag = veto
446
447         
448     def GetVeto(self):
449         """ Returns whether the event has been vetoed or not. """
450
451         return self.veto_flag
452
453     
454     def SetCanVeto(self, can_veto):
455         """
456         Sets whether the event can be vetoed or not.
457
458         :param `can_veto`: a bool flag. ``True`` if the event can be vetoed, ``False`` otherwise.
459         """
460
461         self.canveto_flag = can_veto
462
463         
464     def CanVeto(self):
465         """ Returns whether the event can be vetoed and has been vetoed. """
466
467         return  self.canveto_flag and self.veto_flag
468
469
470 # ---------------------------------------------------------------------------- #
471
472 class AuiPaneInfo(object):
473     """
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.
478     """
479     
480     optionFloating         = 2**0
481     optionHidden           = 2**1
482     optionLeftDockable     = 2**2
483     optionRightDockable    = 2**3
484     optionTopDockable      = 2**4
485     optionBottomDockable   = 2**5
486     optionFloatable        = 2**6
487     optionMovable          = 2**7
488     optionResizable        = 2**8
489     optionPaneBorder       = 2**9
490     optionCaption          = 2**10
491     optionGripper          = 2**11
492     optionDestroyOnClose   = 2**12
493     optionToolbar          = 2**13
494     optionActive           = 2**14
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
504     optionFlyOut           = 2**24
505     optionCaptionLeft      = 2**25
506
507     buttonClose            = 2**26
508     buttonMaximize         = 2**27
509     buttonMinimize         = 2**28
510     buttonPin              = 2**29
511     
512     buttonCustom1          = 2**30
513     buttonCustom2          = 2**31
514     buttonCustom3          = 2**32
515
516     savedHiddenState       = 2**33    # used internally
517     actionPane             = 2**34    # used internally
518     wasMaximized           = 2**35    # used internally
519     needsRestore           = 2**36    # used internally
520
521
522     def __init__(self):
523         """ Default class constructor. """
524         
525         self.window = None
526         self.frame = None
527         self.state = 0
528         self.dock_direction = AUI_DOCK_LEFT
529         self.dock_layer = 0
530         self.dock_row = 0
531         self.dock_pos = 0
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
539         self.caption = ""
540         self.buttons = []
541         self.name = ""
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
549         self.snapped = 0
550         
551         self.DefaultPane()
552         
553     
554     def dock_direction_get(self):
555         """
556         Getter for the `dock_direction`.
557
558         :see: L{dock_direction_set} for a set of valid docking directions.
559         """
560         
561         if self.IsMaximized():
562             return AUI_DOCK_CENTER
563         else:
564             return self._dock_direction
565
566
567     def dock_direction_set(self, value):
568         """
569         Setter for the `dock_direction`.
570
571         :param `value`: the docking direction. This cab ne one of the following bits:
572
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         ============================ ======= =============================================
585         
586         """
587         
588         self._dock_direction = value
589         
590     dock_direction = property(dock_direction_get, dock_direction_set)
591
592     def IsOk(self):
593         """
594         Returns ``True`` if the L{AuiPaneInfo} structure is valid.
595
596         :note: A pane structure is valid if it has an associated window.
597         """
598         
599         return self.window != None
600
601
602     def IsMaximized(self):
603         """ Returns ``True`` if the pane is maximized. """
604         
605         return self.HasFlag(self.optionMaximized)
606
607
608     def IsMinimized(self):
609         """ Returns ``True`` if the pane is minimized. """
610
611         return self.HasFlag(self.optionMinimized)
612
613
614     def IsFixed(self):
615         """ Returns ``True`` if the pane cannot be resized. """
616         
617         return not self.HasFlag(self.optionResizable)
618
619     
620     def IsResizeable(self):
621         """ Returns ``True`` if the pane can be resized. """
622         
623         return self.HasFlag(self.optionResizable)
624
625     
626     def IsShown(self):
627         """ Returns ``True`` if the pane is currently shown. """
628         
629         return not self.HasFlag(self.optionHidden)
630
631     
632     def IsFloating(self):
633         """ Returns ``True`` if the pane is floating. """
634
635         return self.HasFlag(self.optionFloating)
636
637     
638     def IsDocked(self):
639         """ Returns ``True`` if the pane is docked. """
640         
641         return not self.HasFlag(self.optionFloating)
642
643     
644     def IsToolbar(self):
645         """ Returns ``True`` if the pane contains a toolbar. """
646
647         return self.HasFlag(self.optionToolbar)
648
649     
650     def IsTopDockable(self):
651         """
652         Returns ``True`` if the pane can be docked at the top
653         of the managed frame.
654         """
655         
656         return self.HasFlag(self.optionTopDockable)
657
658     
659     def IsBottomDockable(self):
660         """
661         Returns ``True`` if the pane can be docked at the bottom
662         of the managed frame.
663         """
664         
665         return self.HasFlag(self.optionBottomDockable)
666
667     
668     def IsLeftDockable(self):
669         """
670         Returns ``True`` if the pane can be docked at the left
671         of the managed frame.
672         """
673         
674         return self.HasFlag(self.optionLeftDockable) 
675
676
677     def IsRightDockable(self):
678         """
679         Returns ``True`` if the pane can be docked at the right
680         of the managed frame.
681         """
682         
683         return self.HasFlag(self.optionRightDockable)
684
685
686     def IsDockable(self):
687         """ Returns ``True`` if the pane can be docked. """
688         
689         return self.IsTopDockable() or self.IsBottomDockable() or self.IsLeftDockable() or \
690                self.IsRightDockable() or self.IsNotebookDockable()
691     
692     
693     def IsFloatable(self):
694         """
695         Returns ``True`` if the pane can be undocked and displayed as a
696         floating window.
697         """
698
699         return self.HasFlag(self.optionFloatable)
700
701     
702     def IsMovable(self):
703         """
704         Returns ``True`` if the docked frame can be undocked or moved to
705         another dock position.
706         """
707         
708         return self.HasFlag(self.optionMovable)
709
710
711     def IsDestroyOnClose(self):
712         """
713         Returns ``True`` if the pane should be destroyed when it is closed.
714         
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.
718         """
719         
720         return self.HasFlag(self.optionDestroyOnClose)
721     
722
723     def IsNotebookDockable(self):
724         """
725         Returns ``True`` if a pane can be docked on top to another to create a
726         L{AuiNotebook}.
727         """
728
729         return self.HasFlag(self.optionNotebookDockable)
730     
731
732     def IsTopSnappable(self):
733         """ Returns ``True`` if the pane can be snapped at the top of the managed frame. """
734         
735         return self.HasFlag(self.optionTopSnapped)
736
737     
738     def IsBottomSnappable(self):
739         """ Returns ``True`` if the pane can be snapped at the bottom of the managed frame. """
740         
741         return self.HasFlag(self.optionBottomSnapped)
742
743     
744     def IsLeftSnappable(self):
745         """ Returns ``True`` if the pane can be snapped on the left of the managed frame. """
746         
747         return self.HasFlag(self.optionLeftSnapped) 
748
749
750     def IsRightSnappable(self):
751         """ Returns ``True`` if the pane can be snapped on the right of the managed frame. """
752         
753         return self.HasFlag(self.optionRightSnapped)
754
755
756     def IsSnappable(self):
757         """ Returns ``True`` if the pane can be snapped. """
758         
759         return self.IsTopSnappable() or self.IsBottomSnappable() or self.IsLeftSnappable() or \
760                self.IsRightSnappable()
761
762
763     def IsFlyOut(self):
764         """ Returns ``True`` if the floating pane has a "fly-out" effect. """
765
766         return self.HasFlag(self.optionFlyOut)        
767             
768
769     def HasCaption(self):
770         """ Returns ``True`` if the pane displays a caption. """
771         
772         return self.HasFlag(self.optionCaption)
773
774     
775     def HasCaptionLeft(self):
776         """ Returns ``True`` if the pane displays a caption on the left (rotated by 90 degrees). """
777         
778         return self.HasFlag(self.optionCaptionLeft)
779
780
781     def HasGripper(self):
782         """ Returns ``True`` if the pane displays a gripper. """
783         
784         return self.HasFlag(self.optionGripper) 
785
786
787     def HasBorder(self):
788         """ Returns ``True`` if the pane displays a border. """
789         
790         return self.HasFlag(self.optionPaneBorder)
791
792     
793     def HasCloseButton(self):
794         """ Returns ``True`` if the pane displays a button to close the pane. """
795
796         return self.HasFlag(self.buttonClose) 
797
798
799     def HasMaximizeButton(self):
800         """ Returns ``True`` if the pane displays a button to maximize the pane. """
801         
802         return self.HasFlag(self.buttonMaximize)
803
804     
805     def HasMinimizeButton(self):
806         """ Returns ``True`` if the pane displays a button to minimize the pane. """
807         
808         return self.HasFlag(self.buttonMinimize) 
809
810
811     def GetMinimizeMode(self):
812         """
813         Returns the minimization style for this pane.
814
815         Possible return values are:
816
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         ============================== ========= ==============================
831
832         The flags can be filtered with the following masks:
833
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         ============================== ========= ==============================
840
841         """
842         
843         return self.minimize_mode
844     
845
846     def HasPinButton(self):
847         """ Returns ``True`` if the pane displays a button to float the pane. """
848         
849         return self.HasFlag(self.buttonPin) 
850
851
852     def HasGripperTop(self):
853         """ Returns ``True`` if the pane displays a gripper at the top. """
854
855         return self.HasFlag(self.optionGripperTop)
856
857
858     def Window(self, w):
859         """
860         Associate a `wx.Window` derived window to this pane.
861
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.
865
866         :param `w`: a `wx.Window` derived window.
867         """
868
869         self.window = w
870         return self
871
872     
873     def Name(self, name):
874         """
875         Sets the name of the pane so it can be referenced in lookup functions.
876
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.
879
880         :param `name`: a string specifying the pane name.
881
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.
885         """
886
887         self.name = name
888         return self
889
890     
891     def Caption(self, caption):
892         """
893         Sets the caption of the pane.
894
895         :param `caption`: a string specifying the pane caption.
896         """
897         
898         self.caption = caption
899         return self
900
901     
902     def Left(self):
903         """ 
904         Sets the pane dock position to the left side of the frame.
905
906         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_LEFT`` as
907          parameter.
908         """
909         
910         self.dock_direction = AUI_DOCK_LEFT
911         return self
912
913     
914     def Right(self):
915         """
916         Sets the pane dock position to the right side of the frame.
917
918         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_RIGHT`` as
919          parameter.
920         """
921         
922         self.dock_direction = AUI_DOCK_RIGHT
923         return self
924
925     
926     def Top(self):
927         """
928         Sets the pane dock position to the top of the frame.
929
930         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_TOP`` as
931          parameter.
932         """
933
934         self.dock_direction = AUI_DOCK_TOP
935         return self
936
937     
938     def Bottom(self):
939         """
940         Sets the pane dock position to the bottom of the frame.
941
942         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_BOTTOM`` as
943          parameter.
944         """
945
946         self.dock_direction = AUI_DOCK_BOTTOM
947         return self
948
949     
950     def Center(self):
951         """
952         Sets the pane to the center position of the frame.
953
954         The centre pane is the space in the middle after all border panes (left, top,
955         right, bottom) are subtracted from the layout.
956
957         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_CENTER`` as
958          parameter.
959         """
960         
961         self.dock_direction = AUI_DOCK_CENTER
962         return self
963
964         
965     def Centre(self):
966         """
967         Sets the pane to the center position of the frame.
968
969         The centre pane is the space in the middle after all border panes (left, top,
970         right, bottom) are subtracted from the layout.
971
972         :note: This is the same thing as calling L{Direction} with ``AUI_DOCK_CENTRE`` as
973          parameter.
974         """
975         
976         self.dock_direction = AUI_DOCK_CENTRE
977         return self
978
979     
980     def Direction(self, direction):
981         """
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`.
985
986         :param `direction`: the direction of the docked pane.
987
988         :see: L{dock_direction_set} for a list of valid docking directions.        
989         """
990         
991         self.dock_direction = direction
992         return self
993
994     
995     def Layer(self, layer):
996         """
997         Determines the layer of the docked pane.
998
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.
1002
1003         :param `layer`: the layer of the docked pane.
1004         """
1005         
1006         self.dock_layer = layer
1007         return self
1008
1009     
1010     def Row(self, row):
1011         """
1012         Determines the row of the docked pane.
1013
1014         :param `row`: the row of the docked pane.
1015         """
1016         
1017         self.dock_row = row
1018         return self
1019
1020     
1021     def Position(self, pos):
1022         """
1023         Determines the position of the docked pane.
1024
1025         :param `pos`: the position of the docked pane.
1026         """
1027
1028         self.dock_pos = pos
1029         return self
1030
1031
1032     def MinSize(self, arg1=None, arg2=None):
1033         """
1034         Sets the minimum size of the pane.
1035
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.
1038
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).
1041         """
1042         
1043         if isinstance(arg1, wx.Size):
1044             ret = self.MinSize1(arg1)
1045         elif isinstance(arg1, types.TupleType):
1046             ret = self.MinSize1(wx.Size(*arg1))
1047         else:
1048             ret = self.MinSize2(arg1, arg2)
1049
1050         return ret
1051
1052     
1053     def MinSize1(self, size):
1054         """
1055         Sets the minimum size of the pane.
1056
1057         :see: L{MinSize} for an explanation of input parameters.
1058         """
1059         self.min_size = size
1060         return self
1061
1062
1063     def MinSize2(self, x, y):
1064         """
1065         Sets the minimum size of the pane.
1066
1067         :see: L{MinSize} for an explanation of input parameters.
1068         """
1069
1070         self.min_size = wx.Size(x, y)
1071         return self
1072
1073
1074     def MaxSize(self, arg1=None, arg2=None):
1075         """
1076         Sets the maximum size of the pane.
1077
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.
1080
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).
1083         """
1084         
1085         if isinstance(arg1, wx.Size):
1086             ret = self.MaxSize1(arg1)
1087         elif isinstance(arg1, types.TupleType):
1088             ret = self.MaxSize1(wx.Size(*arg1))
1089         else:
1090             ret = self.MaxSize2(arg1, arg2)
1091
1092         return ret
1093     
1094     
1095     def MaxSize1(self, size):
1096         """
1097         Sets the maximum size of the pane.
1098
1099         :see: L{MaxSize} for an explanation of input parameters.
1100         """
1101
1102         self.max_size = size
1103         return self
1104
1105
1106     def MaxSize2(self, x, y):
1107         """
1108         Sets the maximum size of the pane.
1109
1110         :see: L{MaxSize} for an explanation of input parameters.
1111         """
1112
1113         self.max_size.Set(x,y)
1114         return self
1115
1116
1117     def BestSize(self, arg1=None, arg2=None):
1118         """
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.
1121
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.
1124
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).
1127         """
1128         
1129         if isinstance(arg1, wx.Size):
1130             ret = self.BestSize1(arg1)
1131         elif isinstance(arg1, types.TupleType):
1132             ret = self.BestSize1(wx.Size(*arg1))
1133         else:
1134             ret = self.BestSize2(arg1, arg2)
1135
1136         return ret
1137     
1138             
1139     def BestSize1(self, size):
1140         """
1141         Sets the best size of the pane.
1142
1143         :see: L{BestSize} for an explanation of input parameters.
1144         """
1145
1146         self.best_size = size
1147         return self
1148
1149     
1150     def BestSize2(self, x, y):
1151         """
1152         Sets the best size of the pane.
1153
1154         :see: L{BestSize} for an explanation of input parameters.
1155         """
1156
1157         self.best_size.Set(x,y)
1158         return self
1159     
1160     
1161     def FloatingPosition(self, pos):
1162         """
1163         Sets the position of the floating pane.
1164
1165         :param `pos`: a `wx.Point` or a tuple indicating the pane floating position.
1166         """
1167         
1168         self.floating_pos = wx.Point(*pos)
1169         return self
1170
1171     
1172     def FloatingSize(self, size):
1173         """
1174         Sets the size of the floating pane.
1175
1176         :param `size`: a `wx.Size` or a tuple indicating the pane floating size.
1177         """
1178         
1179         self.floating_size = wx.Size(*size)
1180         return self
1181
1182
1183     def Maximize(self):
1184         """ Makes the pane take up the full area."""
1185
1186         return self.SetFlag(self.optionMaximized, True)
1187
1188
1189     def Minimize(self):
1190         """
1191         Makes the pane minimized in a L{AuiToolBar}.
1192
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.
1197         
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.
1200         """
1201         
1202         return self.SetFlag(self.optionMinimized, True)
1203
1204
1205     def MinimizeMode(self, mode):
1206         """
1207         Sets the expected minimized mode if the MinimizeButton() is visible.
1208
1209         The minimized pane can have a specific position in the work space:
1210
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         ============================== ========= ==============================
1220
1221         The caption of the minimized pane can be displayed in different modes:
1222
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         ============================== ========= ==============================
1230         
1231         """
1232         
1233         self.minimize_mode = mode
1234         return self
1235     
1236
1237     def Restore(self):
1238         """ Is the reverse of L{Maximize} and L{Minimize}."""
1239         
1240         return self.SetFlag(self.optionMaximized or self.optionMinimized, False)
1241
1242     
1243     def Fixed(self):
1244         """
1245         Forces a pane to be fixed size so that it cannot be resized.
1246         After calling L{Fixed}, L{IsFixed} will return ``True``.
1247         """
1248         
1249         return self.SetFlag(self.optionResizable, False)
1250
1251     
1252     def Resizable(self, resizable=True):
1253         """
1254         Allows a pane to be resizable if `resizable` is ``True``, and forces
1255         it to be a fixed size if `resizeable` is ``False``.
1256
1257         If `resizable` is ``False``, this is simply an antonym for L{Fixed}.
1258
1259         :param `resizable`: whether the pane will be resizeable or not.
1260         """
1261         
1262         return self.SetFlag(self.optionResizable, resizable)
1263
1264
1265     def Transparent(self, alpha):
1266         """
1267         Makes the pane transparent when floating.
1268
1269         :param `alpha`: an integer value between 0 and 255 for pane transparency.
1270         """
1271
1272         if alpha < 0 or alpha > 255:
1273             raise Exception("Invalid transparency value (%s)"%repr(alpha))
1274                             
1275         self.transparent = alpha
1276         self.needsTransparency = True
1277
1278     
1279     def Dock(self):
1280         """
1281         Indicates that a pane should be docked. It is the opposite of L{Float}.
1282         """
1283
1284         if self.IsNotebookPage():
1285             self.notebook_id = -1
1286             self.dock_direction = AUI_DOCK_NONE
1287         
1288         return self.SetFlag(self.optionFloating, False)
1289
1290     
1291     def Float(self):
1292         """
1293         Indicates that a pane should be floated. It is the opposite of L{Dock}.
1294         """
1295
1296         if self.IsNotebookPage():
1297             self.notebook_id = -1
1298             self.dock_direction = AUI_DOCK_NONE
1299
1300         return self.SetFlag(self.optionFloating, True)
1301
1302     
1303     def Hide(self):
1304         """
1305         Indicates that a pane should be hidden.
1306
1307         Calling L{Show} (``False``) achieve the same effect.
1308         """
1309         
1310         return self.SetFlag(self.optionHidden, True)
1311
1312     
1313     def Show(self, show=True):
1314         """
1315         Indicates that a pane should be shown.
1316
1317         :param `show`: whether the pane should be shown or not.
1318         """
1319         
1320         return self.SetFlag(self.optionHidden, not show)
1321     
1322
1323     # By defaulting to 1000, the tab will get placed at the end
1324     def NotebookPage(self, id, tab_position=1000):
1325         """
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}.
1328
1329         :param `id`: the notebook id;
1330         :param `tab_position`: the tab number of the pane once docked in a notebook.
1331         """
1332         
1333         # Remove any floating frame
1334         self.Dock()
1335         self.notebook_id = id
1336         self.dock_pos = tab_position
1337         self.dock_row = 0
1338         self.dock_layer = 0
1339         self.dock_direction = AUI_DOCK_NOTEBOOK_PAGE
1340
1341         return self
1342
1343
1344     def NotebookControl(self, id):
1345         """
1346         Forces a pane to be a notebook control (L{AuiNotebook}).
1347
1348         :param `id`: the notebook id.
1349         """
1350
1351         self.notebook_id = id
1352         self.window = None
1353         self.buttons = []
1354         
1355         if self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE:
1356             self.dock_direction = AUI_DOCK_NONE
1357             
1358         return self
1359     
1360
1361     def HasNotebook(self):
1362         """ Returns whether a pane has a L{AuiNotebook} or not. """
1363
1364         return self.notebook_id >= 0
1365
1366
1367     def IsNotebookPage(self):
1368         """ Returns whether the pane is a notebook page in a L{AuiNotebook}. """
1369
1370         return self.notebook_id >= 0 and self.dock_direction == AUI_DOCK_NOTEBOOK_PAGE
1371
1372
1373     def IsNotebookControl(self):
1374         """ Returns whether the pane is a notebook control (L{AuiNotebook}). """
1375
1376         return not self.IsNotebookPage() and self.HasNotebook()
1377
1378
1379     def SetNameFromNotebookId(self):
1380         """ Sets the pane name once docked in a L{AuiNotebook} using the notebook id. """
1381
1382         if self.notebook_id >= 0:
1383             self.name = "__notebook_%d"%self.notebook_id
1384             
1385         return self
1386
1387
1388     def CaptionVisible(self, visible=True, left=False):
1389         """
1390         Indicates that a pane caption should be visible. If `visible` is ``False``, no pane
1391         caption is drawn.
1392
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.
1395         """
1396
1397         if left:
1398             self.SetFlag(self.optionCaption, False)
1399             return self.SetFlag(self.optionCaptionLeft, visible)
1400
1401         self.SetFlag(self.optionCaptionLeft, False)
1402         return self.SetFlag(self.optionCaption, visible)
1403
1404     
1405     def PaneBorder(self, visible=True):
1406         """
1407         Indicates that a border should be drawn for the pane.
1408
1409         :param `visible`: whether the pane border should be visible or not.
1410         """
1411         
1412         return self.SetFlag(self.optionPaneBorder, visible)
1413
1414     
1415     def Gripper(self, visible=True):
1416         """
1417         Indicates that a gripper should be drawn for the pane.
1418
1419         :param `visible`: whether the gripper should be visible or not.
1420         """
1421         
1422         return self.SetFlag(self.optionGripper, visible)
1423
1424
1425     def GripperTop(self, attop=True):
1426         """
1427         Indicates that a gripper should be drawn at the top of the pane.
1428
1429         :param `attop`: whether the gripper should be drawn at the top or not.
1430         """
1431         
1432         return self.SetFlag(self.optionGripperTop, attop)
1433
1434     
1435     def CloseButton(self, visible=True):
1436         """
1437         Indicates that a close button should be drawn for the pane.
1438
1439         :param `visible`: whether the close button should be visible or not.
1440         """
1441         
1442         return self.SetFlag(self.buttonClose, visible)
1443
1444     
1445     def MaximizeButton(self, visible=True):
1446         """
1447         Indicates that a maximize button should be drawn for the pane.
1448
1449         :param `visible`: whether the maximize button should be visible or not.
1450         """
1451         
1452         return self.SetFlag(self.buttonMaximize, visible)
1453
1454     
1455     def MinimizeButton(self, visible=True):
1456         """
1457         Indicates that a minimize button should be drawn for the pane.
1458
1459         :param `visible`: whether the minimize button should be visible or not.
1460         """
1461
1462         return self.SetFlag(self.buttonMinimize, visible)
1463
1464     
1465     def PinButton(self, visible=True):
1466         """
1467         Indicates that a pin button should be drawn for the pane.
1468
1469         :param `visible`: whether the pin button should be visible or not.
1470         """
1471         
1472         return self.SetFlag(self.buttonPin, visible)
1473
1474     
1475     def DestroyOnClose(self, b=True):
1476         """
1477         Indicates whether a pane should be destroyed when it is closed.
1478
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.
1482
1483         :param `b`: whether the pane should be destroyed when it is closed or not.
1484         """
1485         
1486         return self.SetFlag(self.optionDestroyOnClose, b)
1487
1488     
1489     def TopDockable(self, b=True):
1490         """
1491         Indicates whether a pane can be docked at the top of the frame.
1492
1493         :param `b`: whether the pane can be docked at the top or not.
1494         """
1495         
1496         return self.SetFlag(self.optionTopDockable, b)
1497
1498     
1499     def BottomDockable(self, b=True):
1500         """
1501         Indicates whether a pane can be docked at the bottom of the frame.
1502
1503         :param `b`: whether the pane can be docked at the bottom or not.
1504         """
1505         
1506         return self.SetFlag(self.optionBottomDockable, b)
1507
1508     
1509     def LeftDockable(self, b=True):
1510         """
1511         Indicates whether a pane can be docked on the left of the frame.
1512
1513         :param `b`: whether the pane can be docked at the left or not.
1514         """
1515
1516         return self.SetFlag(self.optionLeftDockable, b)
1517
1518     
1519     def RightDockable(self, b=True):
1520         """
1521         Indicates whether a pane can be docked on the right of the frame.
1522
1523         :param `b`: whether the pane can be docked at the right or not.
1524         """
1525         
1526         return self.SetFlag(self.optionRightDockable, b)
1527
1528     
1529     def Floatable(self, b=True):
1530         """
1531         Sets whether the user will be able to undock a pane and turn it
1532         into a floating window.
1533
1534         :param `b`: whether the pane can be floated or not.
1535         """
1536         
1537         return self.SetFlag(self.optionFloatable, b)
1538
1539     
1540     def Movable(self, b=True):
1541         """
1542         Indicates whether a pane can be moved.
1543
1544         :param `b`: whether the pane can be moved or not.
1545         """
1546         
1547         return self.SetFlag(self.optionMovable, b)
1548
1549
1550     def NotebookDockable(self, b=True):
1551         """
1552         Indicates whether a pane can be docked in an automatic L{AuiNotebook}.
1553
1554         :param `b`: whether the pane can be docked in a notebook or not.
1555         """
1556         
1557         return self.SetFlag(self.optionNotebookDockable, b)
1558                                   
1559
1560     def DockFixed(self, b=True):
1561         """
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.
1565
1566         :param `b`: whether the pane will have a resize sash or not.
1567         """
1568
1569         return self.SetFlag(self.optionDockFixed, b)
1570
1571                                    
1572     def Dockable(self, b=True):
1573         """
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} .
1576
1577         :param `b`: whether the frame can be docked or not.
1578         """
1579
1580         return self.TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b)
1581     
1582
1583     def TopSnappable(self, b=True):
1584         """
1585         Indicates whether a pane can be snapped at the top of the main frame.
1586
1587         :param `b`: whether the pane can be snapped at the top of the main frame or not.
1588         """
1589         
1590         return self.SetFlag(self.optionTopSnapped, b)
1591
1592     
1593     def BottomSnappable(self, b=True):
1594         """
1595         Indicates whether a pane can be snapped at the bottom of the main frame.
1596
1597         :param `b`: whether the pane can be snapped at the bottom of the main frame or not.
1598         """
1599         
1600         return self.SetFlag(self.optionBottomSnapped, b)
1601
1602     
1603     def LeftSnappable(self, b=True):
1604         """
1605         Indicates whether a pane can be snapped on the left of the main frame.
1606
1607         :param `b`: whether the pane can be snapped at the left of the main frame or not.
1608         """
1609
1610         return self.SetFlag(self.optionLeftSnapped, b)
1611
1612     
1613     def RightSnappable(self, b=True):
1614         """
1615         Indicates whether a pane can be snapped on the right of the main frame.
1616
1617         :param `b`: whether the pane can be snapped at the right of the main frame or not.
1618         """
1619         
1620         return self.SetFlag(self.optionRightSnapped, b)
1621
1622
1623     def Snappable(self, b=True):
1624         """
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} .
1627
1628         :param `b`: whether the pane can be snapped on the main frame or not.
1629         """
1630     
1631         return self.TopSnappable(b).BottomSnappable(b).LeftSnappable(b).RightSnappable(b)
1632
1633
1634     def FlyOut(self, b=True):
1635         """
1636         Indicates whether a pane, when floating, has a "fly-out" effect
1637         (i.e., floating panes which only show themselves when moused over).
1638
1639         :param `b`: whether the pane can be snapped on the main frame or not.
1640         """
1641
1642         return self.SetFlag(self.optionFlyOut, b)
1643     
1644     
1645     # Copy over the members that pertain to docking position
1646     def SetDockPos(self, source):
1647         """
1648         Copies the `source` pane members that pertain to docking position to `self`.
1649
1650         :param `source`: the source pane from where to copy the attributes.
1651         """
1652         
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)
1661         
1662         return self
1663
1664
1665     def DefaultPane(self):
1666         """ Specifies that the pane should adopt the default pane settings. """
1667         
1668         state = self.state    
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
1674
1675         self.state = state
1676         
1677         return self
1678     
1679     
1680     def CentrePane(self):
1681         """
1682         Specifies that the pane should adopt the default center pane settings.
1683
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.
1686         """
1687         
1688         return self.CenterPane()
1689
1690     
1691     def CenterPane(self):
1692         """
1693         Specifies that the pane should adopt the default center pane settings.
1694
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.
1697         """
1698         
1699         self.state = 0
1700         return self.Center().PaneBorder().Resizable()
1701     
1702      
1703     def ToolbarPane(self):
1704         """ Specifies that the pane should adopt the default toolbar pane settings. """
1705         
1706         self.DefaultPane()
1707         state = self.state
1708         
1709         state |= (self.optionToolbar | self.optionGripper)
1710         state &= ~(self.optionResizable | self.optionCaption | self.optionCaptionLeft)
1711         
1712         if self.dock_layer == 0:
1713             self.dock_layer = 10
1714
1715         self.state = state
1716         
1717         return self
1718
1719
1720     def Icon(self, icon):
1721         """
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
1724         the caption space.
1725
1726         :param icon: an icon to draw on the caption space, or ``None``.
1727         """
1728
1729         if icon is None:
1730             icon = wx.NullIcon
1731             
1732         self.icon = icon
1733         return self        
1734     
1735
1736     def SetFlag(self, flag, option_state):
1737         """
1738         Turns the property given by `flag` on or off with the `option_state`
1739         parameter.
1740
1741         :param `flag`: the property to set;
1742         :param `option_state`: either ``True`` or ``False``.
1743         """
1744         
1745         state = self.state
1746         
1747         if option_state:
1748             state |= flag
1749         else:
1750             state &= ~flag
1751
1752         self.state = state
1753
1754         if flag in [self.buttonClose, self.buttonMaximize, self.buttonMinimize, self.buttonPin]:
1755             self.ResetButtons()
1756             
1757         return self
1758     
1759     
1760     def HasFlag(self, flag):
1761         """
1762         Returns ``True`` if the the property specified by flag is active for the pane.
1763
1764         :param `flag`: the property to check for activity.
1765         """
1766         
1767         return (self.state & flag and [True] or [False])[0]
1768
1769
1770     def ResetButtons(self):
1771         """
1772         Resets all the buttons and recreates them from scratch depending on the
1773         L{AuiPaneInfo} flags.
1774         """
1775
1776         floating = self.HasFlag(self.optionFloating)
1777         self.buttons = []
1778
1779         if not floating and self.HasMinimizeButton():
1780             button = AuiPaneButton(AUI_BUTTON_MINIMIZE)
1781             self.buttons.append(button)
1782     
1783         if not floating and self.HasMaximizeButton():
1784             button = AuiPaneButton(AUI_BUTTON_MAXIMIZE_RESTORE)
1785             self.buttons.append(button)
1786
1787         if not floating and self.HasPinButton():
1788             button = AuiPaneButton(AUI_BUTTON_PIN)
1789             self.buttons.append(button)
1790
1791         if self.HasCloseButton():
1792             button = AuiPaneButton(AUI_BUTTON_CLOSE)
1793             self.buttons.append(button)
1794         
1795
1796     def CountButtons(self):
1797         """ Returns the number of visible buttons in the docked pane. """
1798
1799         n = 0
1800         
1801         if self.HasCaption() or self.HasCaptionLeft():
1802             if isinstance(wx.GetTopLevelParent(self.window), AuiFloatingFrame):
1803                 return 1
1804             
1805             if self.HasCloseButton():
1806                 n += 1
1807             if self.HasMaximizeButton():
1808                 n += 1
1809             if self.HasMinimizeButton():
1810                 n += 1
1811             if self.HasPinButton():
1812                 n += 1
1813
1814         return n
1815     
1816
1817     def IsHorizontal(self):
1818         """ Returns ``True`` if the pane `dock_direction` is horizontal. """
1819
1820         return self.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]
1821
1822     def IsVertical(self):
1823         """ Returns ``True`` if the pane `dock_direction` is vertical. """
1824
1825         return self.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT]
1826
1827
1828 # Null AuiPaneInfo reference
1829 NonePaneInfo = AuiPaneInfo()
1830
1831
1832 # ---------------------------------------------------------------------------- #
1833
1834 class AuiDockingGuide(wx.Frame):
1835     """ Base class for L{AuiCenterDockingGuide} and L{AuiSingleDockingGuide}."""
1836
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"):
1840         """
1841         Default class constructor. Used internally, do not call it in your code!
1842
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.
1853         """
1854
1855         wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
1856
1857
1858     def HitTest(self, x, y):
1859         """
1860         To be overridden by parent classes.
1861
1862         :param `x`: the `x` mouse position;
1863         :param `y`: the `y` mouse position.
1864         """
1865
1866         return 0
1867
1868     
1869     def ValidateNotebookDocking(self, valid):
1870         """
1871         To be overridden by parent classes.
1872
1873         :param `valid`: whether a pane can be docked on top to another to form an automatic
1874          L{AuiNotebook}.
1875         """
1876         
1877         return 0
1878
1879 # ============================================================================
1880 # implementation
1881 # ============================================================================
1882
1883 # ---------------------------------------------------------------------------
1884 # AuiDockingGuideWindow
1885 # ---------------------------------------------------------------------------
1886
1887 class AuiDockingGuideWindow(wx.Window):
1888     """ Target class for L{AuiSingleDockingGuide} and L{AuiCenterDockingGuide}. """
1889
1890     def __init__(self, parent, rect, direction=0, center=False, useAero=False):
1891         """
1892         Default class constructor. Used internally, do not call it in your code!
1893
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``,
1897          ``wx.CENTER``;
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.
1901         """
1902
1903         wx.Window.__init__(self, parent, -1, rect.GetPosition(), rect.GetSize(), wx.NO_BORDER)
1904
1905         self._direction = direction
1906         self._center = center
1907         self._valid = True
1908         self._useAero = useAero
1909         
1910         self._bmp_unfocus, self._bmp_focus = GetDockingImage(direction, useAero, center)
1911         
1912         self._currentImage = self._bmp_unfocus
1913         self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
1914         
1915         self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
1916         self.Bind(wx.EVT_PAINT, self.OnPaint)
1917
1918
1919     def SetValid(self, valid):
1920         """
1921         Sets the docking direction as valid or invalid.
1922
1923         :param `valid`: whether the docking direction is allowed or not.
1924         """
1925
1926         self._valid = valid
1927
1928
1929     def IsValid(self):
1930         """ Returns whether the docking direction is valid. """
1931         
1932         return self._valid
1933
1934
1935     def OnEraseBackground(self, event):
1936         """
1937         Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{AuiDockingGuideWindow}.
1938
1939         :param `event`: a `wx.EraseEvent` to be processed.
1940
1941         :note: This is intentionally empty to reduce flickering while drawing.
1942         """
1943
1944         pass
1945
1946
1947     def DrawBackground(self, dc):
1948         """
1949         Draws the docking guide background.
1950
1951         :param `dc`: a `wx.DC` device context object.
1952         """
1953
1954         rect = self.GetClientRect()
1955
1956         dc.SetPen(wx.TRANSPARENT_PEN)
1957         dc.SetBrush(wx.Brush(colourTargetBackground))
1958         dc.DrawRectangleRect(rect)
1959
1960         dc.SetPen(wx.Pen(colourTargetBorder))
1961
1962         left = rect.GetLeft()
1963         top = rect.GetTop()
1964         right = rect.GetRight()
1965         bottom = rect.GetBottom()
1966
1967         if self._direction != wx.CENTER:
1968         
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)
1977
1978             dc.SetPen(wx.Pen(colourTargetShade))
1979
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)
1984
1985         
1986     def DrawDottedLine(self, dc, point, length, vertical):
1987         """
1988         Draws a dotted line (not used if the docking guide images are ok).
1989
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.
1994         """
1995
1996         for i in xrange(0, length, 2):
1997             dc.DrawPoint(point.x, point.y)
1998             if vertical:
1999                 point.y += 2
2000             else:
2001                 point.x += 2
2002         
2003
2004     def DrawIcon(self, dc):
2005         """
2006         Draws the docking guide icon (not used if the docking guide images are ok).
2007
2008         :param `dc`: a `wx.DC` device context object.
2009         """
2010
2011         rect = wx.Rect(*self.GetClientRect())
2012         point = wx.Point()
2013         length = 0
2014
2015         rect.Deflate(4, 4)
2016         dc.SetPen(wx.Pen(colourIconBorder))
2017         dc.SetBrush(wx.Brush(colourIconBackground))
2018         dc.DrawRectangleRect(rect)
2019
2020         right1 = rect.GetRight() + 1
2021         bottom1 = rect.GetBottom() + 1
2022
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)
2026
2027         rect.Deflate(1, 1)
2028
2029         if self._direction == wx.TOP:
2030             rect.height -= rect.height / 2
2031             point = rect.GetBottomLeft()
2032             length = rect.width
2033
2034         elif self._direction == wx.LEFT:
2035             rect.width -= rect.width / 2
2036             point = rect.GetTopRight()
2037             length = rect.height
2038
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
2044
2045         elif self._direction == wx.BOTTOM:
2046             rect.y += rect.height / 2
2047             rect.height -= rect.height / 2
2048             point = rect.GetTopLeft()
2049             length = rect.width
2050
2051         elif self._direction == wx.CENTER:
2052             rect.Deflate(1, 1)
2053             point = rect.GetTopLeft()
2054             length = rect.width
2055
2056         dc.GradientFillLinear(rect, colourIconDockingPart1,
2057                               colourIconDockingPart2, self._direction)
2058
2059         dc.SetPen(wx.Pen(colourIconBorder))
2060
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)
2066         
2067         elif self._direction in [wx.TOP, wx.BOTTOM]:
2068             self.DrawDottedLine(dc, point, length, False)
2069         
2070         else:
2071             self.DrawDottedLine(dc, point, length, True)
2072         
2073
2074     def DrawArrow(self, dc):
2075         """
2076         Draws the docking guide arrow icon (not used if the docking guide images are ok).
2077
2078         :param `dc`: a `wx.DC` device context object.
2079         """
2080
2081         rect = self.GetClientRect()
2082         point = wx.Point()
2083
2084         point.x = (rect.GetLeft() + rect.GetRight()) / 2
2085         point.y = (rect.GetTop() + rect.GetBottom()) / 2
2086         rx, ry = wx.Size(), wx.Size()
2087         
2088         if self._direction == wx.TOP:
2089             rx = wx.Size(1, 0)
2090             ry = wx.Size(0, 1)
2091
2092         elif self._direction == wx.LEFT:
2093             rx = wx.Size(0, -1)
2094             ry = wx.Size(1, 0)
2095
2096         elif self._direction == wx.RIGHT:
2097             rx = wx.Size(0, 1)
2098             ry = wx.Size(-1, 0)
2099
2100         elif self._direction == wx.BOTTOM:
2101             rx = wx.Size(-1, 0)
2102             ry = wx.Size(0, -1)        
2103
2104         point.x += ry.x*3
2105         point.y += ry.y*3
2106
2107         dc.SetPen(wx.Pen(colourIconArrow))
2108
2109         for i in xrange(4):
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)
2113             point.x += ry.x
2114             point.y += ry.y
2115
2116     
2117     def OnPaint(self, event):
2118         """
2119         Handles the ``wx.EVT_PAINT`` event for L{AuiDockingGuideWindow}.
2120
2121         :param `event`: a `wx.PaintEvent` to be processed.
2122         """
2123
2124         dc = wx.AutoBufferedPaintDC(self)
2125         if self._currentImage.IsOk() and self._valid:
2126             dc.DrawBitmap(self._currentImage, 0, 0, True)
2127         else:
2128             self.Draw(dc)
2129
2130
2131     def Draw(self, dc):
2132         """
2133         Draws the whole docking guide window (not used if the docking guide images are ok).
2134
2135         :param `dc`: a `wx.DC` device context object.
2136         """
2137
2138         self.DrawBackground(dc)
2139
2140         if self._valid:
2141             self.DrawIcon(dc)
2142             self.DrawArrow(dc)
2143
2144
2145     def UpdateDockGuide(self, pos):
2146         """
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
2149         outside.
2150
2151         :param `pos`: a `wx.Point` mouse position.
2152         """
2153
2154         inside = self.GetScreenRect().Contains(pos)
2155         
2156         if inside:
2157             image = self._bmp_focus
2158         else:
2159             image = self._bmp_unfocus
2160
2161         if image != self._currentImage:
2162             self._currentImage = image
2163             self.Refresh()
2164             self.Update()
2165
2166
2167 # ---------------------------------------------------------------------------
2168 # AuiSingleDockingGuide
2169 # ---------------------------------------------------------------------------
2170
2171 class AuiSingleDockingGuide(AuiDockingGuide):
2172     """ A docking guide window for single docking hint (not diamond-shaped HUD). """
2173     
2174     def __init__(self, parent, direction=0):
2175         """
2176         Default class constructor. Used internally, do not call it in your code!
2177
2178         :param `parent`: the L{AuiSingleDockingGuide} parent;
2179         :param `direction`: one of ``wx.TOP``, ``wx.BOTTOM``, ``wx.LEFT``, ``wx.RIGHT``.
2180         """
2181
2182         self._direction = direction
2183
2184         style = wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP | \
2185                 wx.FRAME_NO_TASKBAR | wx.NO_BORDER
2186
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
2191
2192         AuiDockingGuide.__init__(self, parent, style=style, name="auiSingleDockTarget")
2193         
2194         self.Hide()
2195
2196         useAero = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES
2197         useWhidbey = GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES
2198         
2199         self._useAero = useAero or useWhidbey
2200         self._valid = True
2201         
2202         if useAero:
2203             sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2204         elif useWhidbey:
2205             sizeX, sizeY = whidbeySizeX, whidbeySizeY
2206         else:
2207             sizeX, sizeY = guideSizeX, guideSizeY
2208
2209         if direction not in [wx.TOP, wx.BOTTOM]:
2210             sizeX, sizeY = sizeY, sizeX
2211
2212         if self._useAero:
2213             self.CreateShapesWithStyle(useWhidbey)
2214             
2215             if wx.Platform == "__WXGTK__":
2216                 self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
2217             else:
2218                 self.SetGuideShape()
2219             
2220             self.SetSize(self.region.GetBox().GetSize())
2221         else:
2222             self.SetSize((sizeX, sizeY))
2223             
2224         self.rect = wx.Rect(0, 0, sizeX, sizeY)
2225
2226         if self._useAero:
2227             useAero = (useWhidbey and [2] or [1])[0]
2228         else:
2229             useAero = 0
2230             
2231         self.target = AuiDockingGuideWindow(self, self.rect, direction, False, useAero)
2232
2233
2234     def CreateShapesWithStyle(self, useWhidbey):
2235         """
2236         Creates the docking guide window shape based on which docking bitmaps are used.
2237
2238         :param `useWhidbey`: if ``True``, use Whidbey-style bitmaps; if ``False``, use the
2239          Aero-style bitmaps.
2240          """
2241
2242         sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2243         if useWhidbey:
2244             sizeX, sizeY = whidbeySizeX, whidbeySizeY
2245
2246         if self._direction not in [wx.TOP, wx.BOTTOM]:
2247             sizeX, sizeY = sizeY, sizeX
2248
2249         useAero = (useWhidbey and [2] or [1])[0]      
2250         bmp, dummy = GetDockingImage(self._direction, useAero, False)
2251         region = wx.RegionFromBitmap(bmp)
2252             
2253         self.region = region
2254         
2255
2256     def AeroMove(self, pos):
2257         """
2258         Moves the docking window to the new position. Overridden in children classes.
2259
2260         :param `pos`: the new docking guide position.
2261         """
2262
2263         pass
2264     
2265
2266     def SetGuideShape(self, event=None):
2267         """
2268         Sets the correct shape for the docking guide window.
2269
2270         :param `event`: on wxGTK, a `wx.WindowCreateEvent` event to process.
2271         """
2272
2273         self.SetShape(self.region)        
2274                 
2275         if event is not None:
2276             # Skip the event on wxGTK
2277             event.Skip()
2278             wx.CallAfter(wx.SafeYield, self, True)
2279
2280
2281     def SetShape(self, region):
2282         """
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. 
2287
2288         :param `region`: the shape of the frame.
2289
2290         :note: Overridden for wxMac.        
2291         """
2292         
2293         if wx.Platform == '__WXMAC__':
2294             # HACK so we don't crash when SetShape is called
2295             return
2296         else:
2297             super(AuiSingleDockingGuide, self).SetShape(region)
2298
2299
2300     def SetValid(self, valid):
2301         """
2302         Sets the docking direction as valid or invalid.
2303
2304         :param `valid`: whether the docking direction is allowed or not.
2305         """
2306
2307         self._valid = valid
2308
2309
2310     def IsValid(self):
2311         """ Returns whether the docking direction is valid. """
2312         
2313         return self._valid
2314
2315
2316     def UpdateDockGuide(self, pos):
2317         """
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
2320         outside.
2321
2322         :param `pos`: a `wx.Point` mouse position.
2323         """
2324
2325         self.target.UpdateDockGuide(pos)
2326
2327         
2328     def HitTest(self, x, y):
2329         """
2330         Checks if the mouse position is inside the target window rect.
2331
2332         :param `x`: the `x` mouse position;
2333         :param `y`: the `y` mouse position.
2334         """
2335
2336         if self.target.GetScreenRect().Contains((x, y)):
2337             return wx.ALL
2338
2339         return -1
2340
2341
2342 # ---------------------------------------------------------------------------
2343 # AuiCenterDockingGuide
2344 # ---------------------------------------------------------------------------
2345
2346 class AuiCenterDockingGuide(AuiDockingGuide):
2347     """ A docking guide window for multiple docking hint (diamond-shaped HUD). """
2348     
2349     def __init__(self, parent):
2350         """
2351         Default class constructor.
2352         Used internally, do not call it in your code!
2353
2354         :param `parent`: the L{AuiCenterDockingGuide} parent.
2355         """
2356
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")
2360
2361         self.Hide()
2362
2363         self.CreateShapesWithStyle()
2364         self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
2365         
2366         if wx.Platform == "__WXGTK__":
2367             self.Bind(wx.EVT_WINDOW_CREATE, self.SetGuideShape)
2368         else:
2369             self.SetGuideShape()
2370             
2371         self.SetSize(self.region.GetBox().GetSize())
2372
2373         self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
2374         self.Bind(wx.EVT_PAINT, self.OnPaint)
2375
2376
2377     def CreateShapesWithStyle(self):
2378         """ Creates the docking guide window shape based on which docking bitmaps are used. """
2379
2380         useAero = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_AERO_DOCKING_GUIDES) != 0
2381         useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
2382
2383         self._useAero = 0
2384         if useAero:
2385             self._useAero = 1
2386         elif useWhidbey:
2387             self._useAero = 2
2388         
2389         if useAero:
2390             sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2391         elif useWhidbey:
2392             sizeX, sizeY = whidbeySizeX, whidbeySizeY          
2393         else:
2394             sizeX, sizeY = guideSizeX, guideSizeY
2395
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)
2401             
2402         if not self._useAero:
2403
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)
2409
2410             
2411             # top-left diamond
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()]
2419             # top-right diamond
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()]
2427
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)]]
2433             
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))
2444
2445         elif useAero:
2446
2447             self._aeroBmp = aero_dock_pane.GetBitmap()
2448             region = wx.RegionFromBitmap(self._aeroBmp)
2449
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]
2455             self._valid = True
2456
2457         elif useWhidbey:
2458
2459             self._aeroBmp = whidbey_dock_pane.GetBitmap()
2460             region = wx.RegionFromBitmap(self._aeroBmp)
2461
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]
2467             self._valid = True
2468             
2469             
2470         self.region = region
2471         
2472
2473     def SetGuideShape(self, event=None):
2474         """
2475         Sets the correct shape for the docking guide window.
2476
2477         :param `event`: on wxGTK, a `wx.WindowCreateEvent` event to process.
2478         """
2479
2480         self.SetShape(self.region)        
2481
2482         if event is not None:
2483             # Skip the event on wxGTK
2484             event.Skip()
2485             wx.CallAfter(wx.SafeYield, self, True)
2486
2487             
2488     def UpdateDockGuide(self, pos):
2489         """
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
2492         outside.
2493
2494         :param `pos`: a `wx.Point` mouse position.
2495         """
2496
2497         if not self._useAero:
2498             for target in self.GetChildren():
2499                 target.UpdateDockGuide(pos)
2500         else:
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]
2507                             self.Refresh()
2508                         else:
2509                             self._aeroBmp = self._allAeroBmps[-1]
2510                             self.Refresh()
2511                             
2512                     return
2513
2514             if self._aeroBmp != self._allAeroBmps[-1]:
2515                 self._aeroBmp = self._allAeroBmps[-1]
2516                 self.Refresh()
2517
2518
2519     def HitTest(self, x, y):
2520         """
2521         Checks if the mouse position is inside the target windows rect.
2522
2523         :param `x`: the `x` mouse position;
2524         :param `y`: the `y` mouse position.
2525         """
2526
2527         if not self._useAero:
2528             if self.targetLeft.GetScreenRect().Contains((x, y)):
2529                 return wx.LEFT
2530             if self.targetTop.GetScreenRect().Contains((x, y)):
2531                 return wx.UP
2532             if self.targetRight.GetScreenRect().Contains((x, y)):
2533                 return wx.RIGHT
2534             if self.targetBottom.GetScreenRect().Contains((x, y)):
2535                 return wx.DOWN
2536             if self.targetCenter.IsValid() and self.targetCenter.GetScreenRect().Contains((x, y)):
2537                 return wx.CENTER
2538         else:
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]
2545
2546         return -1
2547
2548
2549     def ValidateNotebookDocking(self, valid):
2550         """
2551         Sets whether a pane can be docked on top of another to create an automatic
2552         L{AuiNotebook}.
2553
2554         :param `valid`: whether a pane can be docked on top to another to form an automatic
2555          L{AuiNotebook}.
2556         """
2557
2558         if not self._useAero:
2559             if self.targetCenter.IsValid() != valid:        
2560                 self.targetCenter.SetValid(valid)
2561                 self.targetCenter.Refresh()
2562         else:
2563             if self._valid != valid:
2564                 self._valid = valid
2565                 self.Refresh()
2566     
2567
2568     def AeroMove(self, pos):
2569         """
2570         Moves the docking guide window to the new position.
2571
2572         :param `pos`: the new docking guide position.
2573         """
2574
2575         if not self._useAero:
2576             return
2577
2578         useWhidbey = (GetManager(self.GetParent()).GetAGWFlags() & AUI_MGR_WHIDBEY_DOCKING_GUIDES) != 0
2579
2580         if useWhidbey:
2581             sizeX, sizeY = whidbeySizeX, whidbeySizeY            
2582         else:
2583             sizeX, sizeY = aeroguideSizeX, aeroguideSizeY
2584             
2585         size = self.GetSize()
2586         
2587         leftRect, topRect, rightRect, bottomRect, centerRect = self._aeroRects
2588         thePos = pos + wx.Point((size.x-sizeY)/2, (size.y-sizeX)/2)
2589         
2590         centerRect.SetPosition(thePos)
2591
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))
2596         
2597         
2598     def OnEraseBackground(self, event):
2599         """
2600         Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{AuiCenterDockingGuide}.
2601
2602         :param `event`: `wx.EraseEvent` to be processed.
2603
2604         :note: This is intentionally empty to reduce flickering while drawing.
2605         """
2606         
2607         pass
2608
2609
2610     def OnPaint(self, event):
2611         """
2612         Handles the ``wx.EVT_PAINT`` event for L{AuiCenterDockingGuide}.
2613
2614         :param `event`: a `wx.PaintEvent` to be processed.
2615         """
2616
2617         dc = wx.AutoBufferedPaintDC(self)
2618
2619         if self._useAero:
2620             dc.SetBrush(wx.TRANSPARENT_BRUSH)
2621             dc.SetPen(wx.TRANSPARENT_PEN)
2622         else:
2623             dc.SetBrush(wx.Brush(colourTargetBackground))
2624             dc.SetPen(wx.Pen(colourTargetBorder))
2625
2626         rect = self.GetClientRect()
2627         dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
2628
2629         if self._useAero:
2630             dc.DrawBitmap(self._aeroBmp, 0, 0, True)
2631             if not self._valid:
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)
2636                 
2637             return
2638         
2639         dc.SetPen(wx.Pen(colourTargetBorder, 2))
2640         for pts in self._triangles:
2641             dc.DrawLinePoint(pts[0], pts[1])
2642             
2643
2644 # ----------------------------------------------------------------------------
2645 # AuiDockingHintWindow
2646 # ----------------------------------------------------------------------------
2647
2648 class AuiDockingHintWindow(wx.Frame):
2649     """ The original wxAUI docking window hint. """
2650
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"):
2655         """
2656         Default class constructor. Used internally, do not call it in your code!
2657
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.
2668         """
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
2673
2674         wx.Frame.__init__(self, parent, id, title, pos, size, style, name=name)
2675         
2676         self._blindMode = False
2677         self.SetBackgroundColour(colourHintBackground)
2678         
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)
2687
2688         self.Bind(wx.EVT_SIZE, self.OnSize)
2689         
2690
2691     def MakeVenetianBlinds(self):
2692         """
2693         Creates the "venetian blind" effect if L{AuiManager} has the ``AUI_MGR_VENETIAN_BLINDS_HINT``
2694         flag set.
2695         """
2696
2697         amount = 128
2698         size = self.GetClientSize()
2699         region = wx.Region(0, 0, size.x, 1)
2700
2701         for y in xrange(size.y):
2702
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]
2706             
2707             if 16*j+8 < amount:
2708                 region.Union(0, y, size.x, 1)
2709                         
2710         self.SetShape(region)
2711
2712
2713     def SetBlindMode(self, agwFlags):
2714         """
2715         Sets whether venetian blinds or transparent hints will be shown as docking hint.
2716         This depends on the L{AuiManager} flags.
2717
2718         :param `agwFlags`: the L{AuiManager} flags.
2719         """
2720
2721         self._blindMode = (agwFlags & AUI_MGR_VENETIAN_BLINDS_HINT) != 0
2722
2723         if self._blindMode or not self.CanSetTransparent():
2724             self.MakeVenetianBlinds()
2725             self.SetTransparent(255)
2726         
2727         else:
2728             self.SetShape(wx.Region())
2729             if agwFlags & AUI_MGR_HINT_FADE == 0:                
2730                 self.SetTransparent(80)
2731             else:
2732                 self.SetTransparent(0)
2733
2734
2735     def SetShape(self, region):
2736         """
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. 
2741
2742         :param `region`: the shape of the frame (an instance of `wx.Region`).
2743
2744         :note: Overridden for wxMac.        
2745         """
2746         
2747         if wx.Platform == '__WXMAC__':
2748             # HACK so we don't crash when SetShape is called
2749             return
2750         else:
2751             super(AuiDockingHintWindow, self).SetShape(region)
2752
2753
2754     def Show(self, show=True):
2755         """
2756         Show the hint window.
2757
2758         :param `show`: whether to show or hide the hint docking window.
2759         """
2760         
2761         super(AuiDockingHintWindow, self).Show(show)
2762         if wx.Platform == '__WXMAC__':
2763             # Need to manually do layout since its a borderless frame.
2764             self.Layout()
2765
2766
2767     def OnSize(self, event):
2768         """
2769         Handles the ``wx.EVT_SIZE`` event for L{AuiDockingHintWindow}.
2770
2771         :param `event`: a `wx.SizeEvent` to be processed.
2772         """
2773
2774         if self._blindMode or not self.CanSetTransparent():
2775             self.MakeVenetianBlinds()
2776
2777
2778 # ---------------------------------------------------------------------------- #
2779
2780 # -- AuiFloatingFrame class implementation --            
2781
2782 class AuiFloatingFrame(wx.MiniFrame):
2783     """ AuiFloatingFrame is the frame class that holds floating panes. """
2784
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):
2788         """
2789         Default class constructor. Used internally, do not call it in your code!
2790
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.
2797         """
2798             
2799         if pane and pane.IsResizeable():
2800             style += wx.RESIZE_BORDER
2801         if pane:
2802             self._is_toolbar = pane.IsToolbar()
2803
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
2815             
2816         wx.MiniFrame.__init__(self, parent, id, title, pos=pane.floating_pos,
2817                               size=pane.floating_size, style=style, name="auiFloatingFrame")
2818
2819         self._fly_timer = wx.Timer(self, wx.ID_ANY)
2820         self._check_fly_timer = wx.Timer(self, wx.ID_ANY)
2821         
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)
2828
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)
2835         else:
2836             self.Bind(wx.EVT_MOVE, self.OnMove)
2837
2838         self._fly = False
2839         self._send_size = True
2840         self._alpha_amount = 255
2841         
2842         self._owner_mgr = owner_mgr
2843         self._moving = False
2844         self._lastDirection = None
2845         self._transparent = 255
2846
2847         self._last_rect = wx.Rect()
2848         self._last2_rect = wx.Rect()
2849         self._last3_rect = wx.Rect()
2850
2851         self._mgr = AuiManager()
2852         self._mgr.SetManagedWindow(self)
2853         self._mgr.SetArtProvider(owner_mgr.GetArtProvider())
2854         self._mgr.SetAGWFlags(owner_mgr.GetAGWFlags())
2855
2856
2857     def CopyAttributes(self, pane):
2858         """
2859         Copies all the attributes of the input `pane` into another L{AuiPaneInfo}.
2860
2861         :param `pane`: the source L{AuiPaneInfo} from where to copy attributes.
2862         """
2863
2864         contained_pane = AuiPaneInfo()
2865
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
2888
2889         return contained_pane
2890     
2891
2892     def SetPaneWindow(self, pane):
2893         """
2894         Sets all the properties of a pane.
2895
2896         :param `pane`: the L{AuiPaneInfo} to analyze.
2897         """
2898
2899         self._is_toolbar = pane.IsToolbar()
2900         self._pane_window = pane.window
2901
2902         if isinstance(pane.window, auibar.AuiToolBar):
2903             pane.window.SetAuiManager(self._mgr)
2904         
2905         self._pane_window.Reparent(self)
2906         
2907         contained_pane = self.CopyAttributes(pane)
2908         
2909         contained_pane.Dock().Center().Show(). \
2910                        CaptionVisible(False). \
2911                        PaneBorder(False). \
2912                        Layer(0).Row(0).Position(0)
2913
2914         if not contained_pane.HasGripper() and not self._useNativeMiniframes:
2915             contained_pane.CaptionVisible(True)
2916
2917         indx = self._owner_mgr._panes.index(pane)
2918
2919         # Carry over the minimum size
2920         pane_min_size = pane.window.GetMinSize()
2921
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):
2927
2928             pane_min_size = pane_best_size
2929             self._pane_window.SetMinSize(pane_min_size)
2930     
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)
2937
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)
2942
2943         min_size = pane.window.GetMinSize()
2944
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]
2951                 
2952             self.SetMinSize((new_x, new_y))
2953         else:
2954             self.SetMinSize(min_size)
2955
2956         self._mgr.AddPane(self._pane_window, contained_pane)
2957         self._mgr.Update()           
2958
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)
2965             self.SetSize(tmp)
2966         
2967         self.SetTitle(pane.caption)
2968
2969         if pane.floating_size != wx.Size(-1, -1):
2970             self.SetSize(pane.floating_size)
2971         else:
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)
2980                 else:
2981                     size.x += self._owner_mgr._art.GetMetric(AUI_DOCKART_GRIPPER_SIZE)
2982
2983             if not self._useNativeMiniframes:
2984                 size.y += self._owner_mgr._art.GetMetric(AUI_DOCKART_CAPTION_SIZE)
2985                 
2986             pane.floating_size = size
2987             
2988             self.SetClientSize(size)
2989
2990         self._owner_mgr._panes[indx] = pane
2991
2992         self._fly_step = abs(pane.floating_size.y - \
2993                              (caption_size + 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)))/10
2994
2995         self._floating_size = wx.Size(*self.GetSize())
2996
2997         if pane.IsFlyOut():
2998             self._check_fly_timer.Start(50)
2999
3000         
3001     def GetOwnerManager(self):
3002         """ Returns the L{AuiManager} that manages the pane. """
3003
3004         return self._owner_mgr
3005
3006
3007     def OnSize(self, event):
3008         """
3009         Handles the ``wx.EVT_SIZE`` event for L{AuiFloatingFrame}.
3010
3011         :param `event`: a `wx.SizeEvent` to be processed.
3012         """
3013
3014         if self._owner_mgr and self._send_size:
3015             self._owner_mgr.OnFloatingPaneResized(self._pane_window, event.GetSize())
3016
3017     
3018     def OnClose(self, event):
3019         """
3020         Handles the ``wx.EVT_CLOSE`` event for L{AuiFloatingFrame}.
3021
3022         :param `event`: a `wx.CloseEvent` to be processed.
3023         """
3024
3025         if self._owner_mgr:
3026             self._owner_mgr.OnFloatingPaneClosed(self._pane_window, event)
3027
3028         if not event.GetVeto():
3029             self._mgr.DetachPane(self._pane_window)
3030
3031             if isinstance(self._pane_window, auibar.AuiToolBar):
3032                 self._pane_window.SetAuiManager(self._owner_mgr)
3033
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
3037
3038             self.Destroy()
3039     
3040
3041     def OnActivate(self, event):
3042         """
3043         Handles the ``wx.EVT_ACTIVATE`` event for L{AuiFloatingFrame}.
3044
3045         :param `event`: a `wx.ActivateEvent` to be processed.
3046         """
3047
3048         if self._owner_mgr and event.GetActive():
3049             self._owner_mgr.OnFloatingPaneActivated(self._pane_window)
3050
3051
3052     def OnMove(self, event):
3053         """
3054         Handles the ``wx.EVT_MOVE`` event for L{AuiFloatingFrame}.
3055
3056         :param `event`: a `wx.MoveEvent` to be processed.
3057
3058         :note: This event is not processed on wxMAC or if L{AuiManager} is not using the
3059          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3060         """
3061
3062         if self._owner_mgr:
3063             self._owner_mgr.OnFloatingPaneMoved(self._pane_window, event)
3064                 
3065
3066     def OnMoveEvent(self, event):
3067         """
3068         Handles the ``wx.EVT_MOVE`` and ``wx.EVT_MOVING`` events for L{AuiFloatingFrame}.
3069
3070         :param `event`: a `wx.MoveEvent` to be processed.
3071
3072         :note: This event is only processed on wxMAC or if L{AuiManager} is using the
3073          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3074         """
3075
3076         win_rect = self.GetRect()
3077
3078         if win_rect == self._last_rect:
3079             return
3080
3081         # skip the first move event
3082         if self._last_rect.IsEmpty():        
3083             self._last_rect = wx.Rect(*win_rect)
3084             return
3085         
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)
3092             return
3093
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)
3099             return
3100
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)
3104
3105         if _VERSION_STRING < "2.9":
3106             leftDown = wx.GetMouseState().LeftDown()
3107         else:
3108             leftDown = wx.GetMouseState().LeftIsDown()
3109
3110         if not leftDown:
3111             return
3112
3113         if not self._moving:        
3114             self.OnMoveStart(event)
3115             self._moving = True
3116
3117         if self._last3_rect.IsEmpty():
3118             return
3119
3120         self.OnMoving(event)
3121
3122
3123     def OnIdle(self, event):
3124         """
3125         Handles the ``wx.EVT_IDLE`` event for L{AuiFloatingFrame}.
3126
3127         :param `event`: a `wx.IdleEvent` event to be processed.
3128
3129         :note: This event is only processed on wxMAC or if L{AuiManager} is using the
3130          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.        
3131         """
3132
3133         if self._moving:        
3134             if _VERSION_STRING < "2.9":
3135                 leftDown = wx.GetMouseState().LeftDown()
3136             else:
3137                 leftDown = wx.GetMouseState().LeftIsDown()
3138
3139             if not leftDown:
3140                 self._moving = False
3141                 self.OnMoveFinished()
3142             else:            
3143                 event.RequestMore()
3144
3145         
3146     def OnMoveStart(self, event):
3147         """
3148         The user has just started moving the floating pane.
3149
3150         :param `event`: an instance of `wx.MouseEvent`.
3151     
3152         :note: This method is used only on wxMAC or if L{AuiManager} is using the
3153          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3154         """
3155
3156         # notify the owner manager that the pane has started to move
3157         if self._owner_mgr:
3158             if self._owner_mgr._from_move:
3159                 return
3160             self._owner_mgr._action_window = self._pane_window
3161             point = wx.GetMousePosition()
3162             action_offset = point - self.GetPosition()
3163
3164             if self._is_toolbar:
3165                 self._owner_mgr._toolbar_action_offset = action_offset
3166                 self._owner_mgr.OnMotion_DragToolbarPane(point)
3167             else:
3168                 self._owner_mgr._action_offset = action_offset
3169                 self._owner_mgr.OnMotion_DragFloatingPane(point)
3170
3171     
3172     def OnMoving(self, event):
3173         """
3174         The user is moving the floating pane.
3175
3176         :param `event`: an instance of `wx.MouseEvent`.
3177         
3178         :note: This method is used only on wxMAC or if L{AuiManager} is using the
3179          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3180         """
3181
3182         # notify the owner manager that the pane is moving
3183         self.OnMoveStart(event)
3184         
3185
3186     def OnMoveFinished(self):
3187         """
3188         The user has just finished moving the floating pane.
3189
3190         :note: This method is used only on wxMAC or if L{AuiManager} is using the
3191          ``AUI_MGR_USE_NATIVE_MINIFRAMES`` style.
3192         """
3193
3194         # notify the owner manager that the pane has finished moving
3195         if self._owner_mgr:
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)
3200             else:
3201                 self._owner_mgr.OnLeftUp_DragFloatingPane(point)
3202
3203             self._owner_mgr.OnFloatingPaneMoved(self._pane_window, point)
3204     
3205
3206     def OnCheckFlyTimer(self, event):
3207         """
3208         Handles the ``wx.EVT_TIMER`` event for L{AuiFloatingFrame}.
3209
3210         :param `event`: a `wx.TimerEvent` to be processed.
3211
3212         :note: This is used solely for "fly-out" panes.        
3213         """
3214         
3215         if self._owner_mgr:
3216             pane = self._mgr.GetPane(self._pane_window)
3217             if pane.IsFlyOut():
3218                 if self.IsShownOnScreen():
3219                     self.FlyOut()
3220                         
3221
3222     def OnFindManager(self, event):
3223         """
3224         Handles the ``EVT_AUI_FIND_MANAGER`` event for L{AuiFloatingFrame}.
3225
3226         :param `event`: a L{AuiManagerEvent} event to be processed.
3227         """
3228         
3229         event.SetManager(self._owner_mgr)
3230
3231
3232     def FlyOut(self):
3233         """ Starts the flying in and out of a floating pane. """
3234
3235         if self._fly_timer.IsRunning():
3236             return
3237
3238         if _VERSION_STRING < "2.9":
3239             leftDown = wx.GetMouseState().LeftDown()
3240         else:
3241             leftDown = wx.GetMouseState().LeftIsDown()
3242
3243         if leftDown:
3244             return
3245         
3246         rect = wx.Rect(*self.GetScreenRect())
3247         rect.Inflate(10, 10)
3248
3249         if rect.Contains(wx.GetMousePosition()):
3250             if not self._fly:
3251                 return
3252             self._send_size = False
3253             self._fly_timer.Start(5)
3254         else:
3255             if self._fly:
3256                 return
3257             self._send_size = False
3258             self._fly_timer.Start(5)
3259
3260
3261     def OnFlyTimer(self, event):            
3262         """
3263         Handles the ``wx.EVT_TIMER`` event for L{AuiFloatingFrame}.
3264
3265         :param `event`: a `wx.TimerEvent` to be processed.
3266         """
3267
3268         current_size = self.GetClientSize()
3269         floating_size = wx.Size(*self._owner_mgr.GetPane(self._pane_window).floating_size)
3270
3271         if floating_size.y == -1:
3272             floating_size = self._floating_size
3273         
3274         if not self._fly:
3275             min_size = self._mgr.GetArtProvider().GetMetric(AUI_DOCKART_CAPTION_SIZE)
3276
3277             if wx.Platform != "__WXMSW__":
3278                 min_size += 2*wx.SystemSettings.GetMetric(wx.SYS_EDGE_Y)
3279
3280             if current_size.y - self._fly_step <= min_size:
3281                 self.SetClientSize((current_size.x, min_size))
3282                 self._fly = True
3283                 self._fly_timer.Stop()
3284                 self._send_size = True
3285             else:
3286                 self.SetClientSize((current_size.x, current_size.y-self._fly_step))
3287
3288         else:
3289             if current_size.y + self._fly_step >= floating_size.y:
3290                 self.SetClientSize((current_size.x, floating_size.y))
3291                 self._fly = False
3292                 self._fly_timer.Stop()
3293                 self._send_size = True
3294             else:
3295                 self.SetClientSize((current_size.x, current_size.y+self._fly_step))
3296
3297         self.Update()
3298         self.Refresh()
3299
3300
3301     def FadeOut(self):
3302         """ Actually starts the fading out of the floating pane. """
3303
3304         while 1:
3305             self._alpha_amount -= 10
3306             if self._alpha_amount <= 0:
3307                 self._alpha_amount = 255
3308                 return
3309
3310             self.SetTransparent(self._alpha_amount)
3311             wx.SafeYield()
3312             wx.MilliSleep(15)
3313
3314     
3315 # -- static utility functions --
3316
3317 def DrawResizeHint(dc, rect):
3318     """
3319     Draws a resize hint while a sash is dragged.
3320
3321     :param `rect`: a `wx.Rect` rectangle which specifies the sash dimensions.
3322     """
3323         
3324     if wx.Platform == "__WXMSW__" and wx.App.GetComCtl32Version() >= 600:
3325         if wx.GetOsVersion()[1] > 5:
3326             # Windows Vista
3327             dc.SetPen(wx.Pen("black", 2, wx.SOLID))
3328             dc.SetBrush(wx.TRANSPARENT_BRUSH)
3329         else:
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)
3336     else:
3337         stipple = PaneCreateStippleBitmap()
3338         brush = wx.BrushFromBitmap(stipple)
3339         dc.SetBrush(brush)
3340         dc.SetPen(wx.TRANSPARENT_PEN)
3341
3342         dc.SetLogicalFunction(wx.XOR)
3343         dc.DrawRectangleRect(rect)    
3344
3345
3346 def CopyDocksAndPanes(src_docks, src_panes):
3347     """
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.
3352
3353     :param `src_docks`: a list of L{AuiDockInfo} classes;
3354     :param `src_panes`: a list of L{AuiPaneInfo} classes.
3355     """
3356     
3357     dest_docks = src_docks
3358     dest_panes = src_panes
3359
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]
3366
3367     return dest_docks, dest_panes
3368
3369
3370 def CopyDocksAndPanes2(src_docks, src_panes):
3371     """
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.
3376
3377     :param `src_docks`: a list of L{AuiDockInfo} classes;
3378     :param `src_panes`: a list of L{AuiPaneInfo} classes.
3379     """
3380     
3381     dest_docks = []
3382
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)
3395
3396     dest_panes = []
3397
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
3422
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]
3429
3430         dest_docks[ii] = dock
3431         
3432     return dest_docks, dest_panes
3433
3434
3435 def GetMaxLayer(docks, dock_direction):
3436     """
3437     This is an internal function which returns
3438     the highest layer inside the specified dock.
3439
3440     :param `docks`: a list of L{AuiDockInfo};
3441     :param `dock_direction`: the L{AuiDockInfo} docking direction to analyze.
3442     """
3443     
3444     max_layer = 0
3445
3446     for dock in docks:
3447         if dock.dock_direction == dock_direction and dock.dock_layer > max_layer and not dock.fixed:
3448             max_layer = dock.dock_layer
3449     
3450     return max_layer
3451
3452
3453 def GetMaxRow(panes, dock_direction, dock_layer):
3454     """
3455     This is an internal function which returns
3456     the highest layer inside the specified dock.
3457
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.
3461     """
3462     
3463     max_row = 0
3464
3465     for pane in panes:
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
3469     
3470     return max_row
3471
3472
3473 def DoInsertDockLayer(panes, dock_direction, dock_layer):
3474     """
3475     This is an internal function that inserts a new dock
3476     layer by incrementing all existing dock layer values by one.
3477     
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.
3481     """
3482     
3483     for ii in xrange(len(panes)):
3484         pane = panes[ii]
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
3487
3488         panes[ii] = pane
3489
3490     return panes
3491
3492
3493 def DoInsertDockRow(panes, dock_direction, dock_layer, dock_row):
3494     """
3495     This is an internal function that inserts a new dock
3496     row by incrementing all existing dock row values by one.
3497     
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.
3502     """
3503     
3504     for pane in panes:
3505         if not pane.IsFloating() and pane.dock_direction == dock_direction and \
3506            pane.dock_layer == dock_layer and pane.dock_row >= dock_row:
3507             pane.dock_row += 1
3508
3509     return panes
3510
3511     
3512 def DoInsertPane(panes, dock_direction, dock_layer, dock_row, dock_pos):
3513     """
3514     This is an internal function that inserts a new pane
3515     by incrementing all existing dock position values by one.
3516     
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.
3522     """
3523
3524     for ii in xrange(len(panes)):
3525         pane = panes[ii]
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
3530
3531         panes[ii] = pane
3532
3533     return panes
3534
3535
3536 def FindDocks(docks, dock_direction, dock_layer=-1, dock_row=-1, reverse=False):
3537     """
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).
3541     
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;
3546     """
3547     
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))]
3552     
3553     arr = [x[-1] for x in sorted(matchDocks, reverse=reverse)]
3554     
3555     return arr
3556
3557
3558 def FindOppositeDocks(docks, dock_direction):
3559     """
3560     This is an internal function that returns a list of docks
3561     which is related to the opposite direction.
3562
3563     :param `docks`: a list of L{AuiDockInfo};
3564     :param `dock_direction`: the L{AuiDockInfo} docking direction to analyze;
3565     """
3566
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)
3575
3576     return arr    
3577
3578
3579 def FindPaneInDock(dock, window):
3580     """
3581     This method looks up a specified window pointer inside a dock.
3582     If found, the corresponding L{AuiPaneInfo} pointer is returned, otherwise ``None``.
3583
3584     :param `dock`: a L{AuiDockInfo} structure;
3585     :param `window`: a `wx.Window` derived window (associated to a pane).
3586     """
3587
3588     for p in dock.panes:
3589         if p.window == window:
3590             return p
3591     
3592     return None
3593
3594
3595 def GetToolBarDockOffsets(docks):
3596     """
3597     Returns the toolbar dock offsets (top-left and bottom-right).
3598
3599     :param `docks`: a list of L{AuiDockInfo} to analyze.
3600     """
3601
3602     top_left = wx.Size(0, 0)
3603     bottom_right = wx.Size(0, 0)
3604
3605     for dock in docks:
3606         if dock.toolbar:
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
3611
3612             elif dock_direction == AUI_DOCK_TOP:
3613                 top_left.y += dock.rect.height
3614                 bottom_right.y += dock.rect.height
3615
3616             elif dock_direction == AUI_DOCK_RIGHT:
3617                 bottom_right.x += dock.rect.width
3618             
3619             elif dock_direction == AUI_DOCK_BOTTOM:
3620                 bottom_right.y += dock.rect.height
3621
3622     return top_left, bottom_right        
3623     
3624
3625 def GetInternalFrameRect(window, docks):
3626     """
3627     Returns the window rectangle excluding toolbars.
3628
3629     :param `window`: a `wx.Window` derived window;
3630     :param `docks`: a list of L{AuiDockInfo} structures.
3631     """
3632
3633     frameRect = wx.Rect()
3634
3635     frameRect.SetTopLeft(window.ClientToScreen(window.GetClientAreaOrigin()))
3636     frameRect.SetSize(window.GetClientSize())
3637
3638     top_left, bottom_right = GetToolBarDockOffsets(docks)
3639
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
3645
3646     return frameRect
3647
3648
3649 def CheckOutOfWindow(window, pt):
3650     """
3651     Checks if a point is outside the window rectangle.
3652     
3653     :param `window`: a `wx.Window` derived window;
3654     :param `pt`: a `wx.Point` object.
3655     """
3656
3657     auiWindowMargin = 30
3658     marginRect = wx.Rect(*window.GetClientRect())
3659     marginRect.Inflate(auiWindowMargin, auiWindowMargin)
3660
3661     return not marginRect.Contains(pt)
3662
3663
3664 def CheckEdgeDrop(window, docks, pt):
3665     """
3666     Checks on which edge of a window the drop action has taken place.
3667
3668     :param `window`: a `wx.Window` derived window;
3669     :param `docks`: a list of L{AuiDockInfo} structures;
3670     :param `pt`: a `wx.Point` object.
3671     """
3672
3673     screenPt = window.ClientToScreen(pt)
3674     clientSize = window.GetClientSize()
3675     frameRect = GetInternalFrameRect(window, docks)
3676
3677     if screenPt.y >= frameRect.GetTop() and screenPt.y < frameRect.GetBottom():
3678         if pt.x < auiLayerInsertOffset and pt.x > auiLayerInsertOffset - auiLayerInsertPixels:
3679             return wx.LEFT
3680         
3681         if pt.x >= clientSize.x - auiLayerInsertOffset and \
3682            pt.x < clientSize.x - auiLayerInsertOffset + auiLayerInsertPixels:
3683             return wx.RIGHT
3684         
3685     if screenPt.x >= frameRect.GetLeft() and screenPt.x < frameRect.GetRight():
3686         if pt.y < auiLayerInsertOffset and pt.y > auiLayerInsertOffset - auiLayerInsertPixels:
3687             return wx.TOP
3688         
3689         if pt.y >= clientSize.y - auiLayerInsertOffset and \
3690            pt.y < clientSize.y - auiLayerInsertOffset + auiLayerInsertPixels:
3691             return wx.BOTTOM
3692
3693     return -1
3694
3695
3696 def RemovePaneFromDocks(docks, pane, exc=None):
3697     """
3698     Removes a pane window from all docks
3699     with a possible exception specified by parameter `exc`.
3700
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.
3704     """
3705     
3706     for ii in xrange(len(docks)):
3707         d = docks[ii]
3708         if d == exc:
3709             continue
3710         pi = FindPaneInDock(d, pane.window)
3711         if pi:
3712             d.panes.remove(pi)
3713
3714         docks[ii] = d            
3715
3716     return docks
3717
3718
3719 def RenumberDockRows(docks):
3720     """
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.
3724
3725     :param `docks`: a list of L{AuiDockInfo} structures.    
3726     """
3727     
3728     for ii in xrange(len(docks)):
3729         dock = docks[ii]
3730         dock.dock_row = ii
3731         for jj in xrange(len(dock.panes)):
3732             dock.panes[jj].dock_row = ii
3733
3734         docks[ii] = dock
3735         
3736     return docks
3737
3738
3739 def SetActivePane(panes, active_pane):
3740     """
3741     Sets the active pane, as well as cycles through
3742     every other pane and makes sure that all others' active flags
3743     are turned off.
3744
3745     :param `panes`: a list of L{AuiPaneInfo} structures;
3746     :param `active_pane`: the pane to be made active (if found).
3747     """
3748
3749     for pane in panes:
3750         pane.state &= ~AuiPaneInfo.optionActive
3751
3752     for pane in panes:
3753         if pane.window == active_pane and not pane.IsNotebookPage():
3754             pane.state |= AuiPaneInfo.optionActive
3755             return True, panes
3756             
3757     return False, panes
3758         
3759
3760 def ShowDockingGuides(guides, show):
3761     """
3762     Shows or hide the docking guide windows.
3763
3764     :param `guides`: a list of L{AuiDockingGuideInfo} classes;
3765     :param `show`: whether to show or hide the docking guide windows.
3766     """
3767
3768     for target in guides:
3769         
3770         if show and not target.host.IsShown():
3771             target.host.Show()
3772             target.host.Update()
3773         
3774         elif not show and target.host.IsShown():        
3775             target.host.Hide()
3776         
3777
3778 def RefreshDockingGuides(guides):
3779     """
3780     Refreshes the docking guide windows.
3781
3782     :param `guides`: a list of L{AuiDockingGuideInfo} classes;
3783     """
3784     
3785     for target in guides:
3786         if target.host.IsShown():
3787             target.host.Refresh()
3788         
3789     
3790 def PaneSortFunc(p1, p2):
3791     """
3792     This function is used to sort panes by dock position.
3793
3794     :param `p1`: a L{AuiPaneInfo} instance;
3795     :param `p2`: another L{AuiPaneInfo} instance.    
3796     """
3797     
3798     return (p1.dock_pos < p2.dock_pos and [-1] or [1])[0]
3799
3800
3801 def GetNotebookRoot(panes, notebook_id):
3802     """
3803     Returns the L{AuiPaneInfo} which has the specified `notebook_id`.
3804
3805     :param `panes`: a list of L{AuiPaneInfo} instances;
3806     :param `notebook_id`: the target notebook id.
3807     """    
3808
3809     for paneInfo in panes:
3810         if paneInfo.IsNotebookControl() and paneInfo.notebook_id == notebook_id:
3811             return paneInfo
3812         
3813     return None
3814
3815
3816 def EscapeDelimiters(s):
3817     """
3818     Changes ``;`` into ``\`` and ``|`` into ``\|`` in the input string.  
3819
3820     :param `s`: the string to be analyzed.
3821
3822     :note: This is an internal functions which is used for saving perspectives.    
3823     """
3824     
3825     result = s.replace(";", "\\")
3826     result = result.replace("|", "|\\")
3827     
3828     return result
3829
3830
3831 def IsDifferentDockingPosition(pane1, pane2):
3832     """
3833     Returns whether `pane1` and `pane2` are in a different docking position
3834     based on pane status, docking direction, docking layer and docking row.
3835
3836     :param `pane1`: a L{AuiPaneInfo} instance;
3837     :param `pane2`: another L{AuiPaneInfo} instance.
3838     """
3839
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
3844
3845
3846 # Convenience function
3847 def AuiManager_HasLiveResize(manager):
3848     """
3849     Static function which returns if the input `manager` should have "live resize"
3850     behaviour.
3851
3852     :param `manager`: an instance of L{AuiManager}.
3853
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.
3856     """
3857
3858     # With Core Graphics on Mac, it's not possible to show sash feedback,
3859     # so we'll always use live update instead.
3860     
3861     if wx.Platform == "__WXMAC__":
3862         return True
3863     else:
3864         return (manager.GetAGWFlags() & AUI_MGR_LIVE_RESIZE) == AUI_MGR_LIVE_RESIZE
3865
3866
3867 # Convenience function
3868 def AuiManager_UseNativeMiniframes(manager):
3869     """
3870     Static function which returns if the input `manager` should use native `wx.MiniFrame` as
3871     floating panes.
3872
3873     :param `manager`: an instance of L{AuiManager}.
3874
3875     :note: This method always returns ``True`` on wxMac as this platform doesn't have
3876      the ability to use custom drawn miniframes.
3877     """
3878
3879     # With Core Graphics on Mac, it's not possible to show sash feedback,
3880     # so we'll always use live update instead.
3881     
3882     if wx.Platform == "__WXMAC__":
3883         return True
3884     else:
3885         return (manager.GetAGWFlags() & AUI_MGR_USE_NATIVE_MINIFRAMES) == AUI_MGR_USE_NATIVE_MINIFRAMES
3886
3887
3888 def GetManager(window):
3889     """
3890     This function will return the aui manager for a given window.
3891     
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.
3897     """
3898     
3899     if not isinstance(wx.GetTopLevelParent(window), AuiFloatingFrame):
3900         if isinstance(window, auibar.AuiToolBar):
3901             return window.GetAuiManager()
3902     
3903     evt = AuiManagerEvent(wxEVT_AUI_FIND_MANAGER)
3904     evt.SetManager(None)
3905     evt.ResumePropagation(wx.EVENT_PROPAGATE_MAX)
3906
3907     if not window.GetEventHandler().ProcessEvent(evt):
3908         return None
3909
3910     return evt.GetManager()
3911
3912
3913 # ---------------------------------------------------------------------------- #
3914
3915 class AuiManager(wx.EvtHandler):
3916     """
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.
3923
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()`.
3929
3930     Panes can be added quite easily::
3931
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"))
3936
3937         self._mgr.Update()
3938
3939
3940     Later on, the positions can be modified easily. The following will float an
3941     existing pane in a tool window::
3942
3943         self._mgr.GetPane(text1).Float()
3944
3945
3946     **Layers, Rows and Directions, Positions:**
3947     
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.
3950
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
3953     by this variable.
3954
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. 
3960
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. 
3965
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`).
3972     """
3973
3974     def __init__(self, managed_window=None, agwFlags=None):
3975         """
3976         Default class constructor.
3977         
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:
3981
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          ==================================== ==================================
4002
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``
4005
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.
4009         """
4010
4011         wx.EvtHandler.__init__(self)
4012         
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
4021
4022         self._frame = None
4023         self._dock_constraint_x = 0.3
4024         self._dock_constraint_y = 0.3
4025         self._reserved = None
4026     
4027         self._panes = []
4028         self._docks = []
4029         self._uiparts = []
4030         
4031         self._guides = []
4032         self._notebooks = []
4033
4034         self._masterManager = None
4035         self._currentDragItem = -1
4036         self._lastknowndocks = {}
4037
4038         self._hint_fadetimer = wx.Timer(self, wx.ID_ANY)
4039         self._hint_fademax = 50
4040         self._last_hint = wx.Rect()
4041
4042         self._from_move = False
4043         self._last_rect = wx.Rect()
4044         
4045         if agwFlags is None:
4046             agwFlags = AUI_MGR_DEFAULT
4047             
4048         self._agwFlags = agwFlags
4049         self._is_docked = (False, wx.RIGHT, wx.TOP, 0)
4050         self._snap_limits = (15, 15)
4051
4052         if wx.Platform == "__WXMSW__":
4053             self._animation_step = 30.0
4054         else:
4055             self._animation_step = 5.0
4056
4057         self._hint_rect = wx.Rect()
4058
4059         self._preview_timer = wx.Timer(self, wx.ID_ANY)
4060         self._sliding_frame = None
4061
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
4066
4067         if managed_window:
4068             self.SetManagedWindow(managed_window)
4069
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)
4083
4084         self.Bind(wx.EVT_MOVE, self.OnMove)
4085         self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChanged)
4086         
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)
4092
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)
4096         
4097
4098     def CreateFloatingFrame(self, parent, pane_info):
4099         """
4100         Creates a floating frame for the windows.
4101
4102         :param `parent`: the floating frame parent;
4103         :param `pane_info`: the L{AuiPaneInfo} class with all the pane's information.
4104         """
4105
4106         return AuiFloatingFrame(parent, self, pane_info)
4107
4108
4109     def CanDockPanel(self, p):
4110         """
4111         Returns whether a pane can be docked or not.
4112
4113         :param `p`: the L{AuiPaneInfo} class with all the pane's information.
4114         """        
4115
4116         # is the pane dockable?
4117         if not p.IsDockable():
4118             return False
4119
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))
4123
4124
4125     def GetPaneByWidget(self, window):
4126         """
4127         This version of L{GetPane} looks up a pane based on a
4128         'pane window'.
4129
4130         :param `window`: a `wx.Window` derived window.
4131
4132         :see: L{GetPane}
4133         """
4134
4135         for p in self._panes:
4136             if p.window == window:
4137                 return p
4138
4139         return NonePaneInfo
4140
4141
4142     def GetPaneByName(self, name):
4143         """
4144         This version of L{GetPane} looks up a pane based on a
4145         'pane name'.
4146
4147         :param `name`: the pane name.
4148
4149         :see: L{GetPane}        
4150         """
4151         
4152         for p in self._panes:
4153             if p.name == name:
4154                 return p
4155         
4156         return NonePaneInfo
4157
4158
4159     def GetPane(self, item):
4160         """
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}.
4165
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.
4169
4170         :param `item`: either a pane name or a `wx.Window`.        
4171         """
4172
4173         if isinstance(item, basestring):
4174             return self.GetPaneByName(item)
4175         else:
4176             return self.GetPaneByWidget(item)
4177
4178
4179     def GetAllPanes(self):
4180         """ Returns a reference to all the pane info structures. """
4181         
4182         return self._panes
4183
4184
4185     def ShowPane(self, window, show):
4186         """
4187         Shows or hides a pane based on the window passed as input.
4188
4189         :param `window`: a `wx.Window` derived window;
4190         :param `show`: ``True`` to show the pane, ``False`` otherwise.
4191         """
4192
4193         p = self.GetPane(window)
4194         
4195         if p.IsOk():
4196             if p.IsNotebookPage():
4197                 if show:
4198                 
4199                     notebook = self._notebooks[p.notebook_id]
4200                     id = notebook.GetPageIndex(p.window)
4201                     if id >= 0:
4202                         notebook.SetSelection(id)
4203                     self.ShowPane(notebook, True)
4204                 
4205             else:
4206                 p.Show(show)
4207                 
4208             if p.frame:
4209                 p.frame.Raise()
4210                 
4211             self.Update()
4212
4213             
4214     def HitTest(self, x, y):
4215         """
4216         This is an internal function which determines
4217         which UI item the specified coordinates are over.
4218         
4219         :param `x`: specifies a x position in client coordinates;
4220         :param `y`: specifies a y position in client coordinates.
4221         """
4222
4223         result = None
4224
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:
4231                 continue
4232
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:
4237                 continue
4238         
4239             # if the point is inside the rectangle, we have a hit
4240             if item.rect.Contains((x, y)):
4241                 result = item
4242         
4243         return result
4244
4245
4246     def PaneHitTest(self, panes, pt):
4247         """
4248         Similar to L{HitTest}, but it checks in which L{AuiPaneInfo} rectangle the
4249         input point belongs to.
4250
4251         :param `panes`: a list of L{AuiPaneInfo} instances;
4252         :param `pt`: a `wx.Point` object.
4253         """
4254
4255         for paneInfo in panes:
4256             if paneInfo.IsDocked() and paneInfo.IsShown() and paneInfo.rect.Contains(pt):
4257                 return paneInfo
4258
4259         return NonePaneInfo
4260
4261
4262     # SetAGWFlags() and GetAGWFlags() allow the owner to set various
4263     # options which are global to AuiManager
4264
4265     def SetAGWFlags(self, agwFlags):
4266         """
4267         This method is used to specify L{AuiManager}'s settings flags.
4268
4269         :param `agwFlags`: specifies options which allow the frame management behavior
4270          to be modified. `agwFlags` can be one of the following style bits:
4271
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          ==================================== ==================================
4292
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.
4296         
4297         """
4298         
4299         self._agwFlags = agwFlags
4300
4301         if len(self._guides) > 0:
4302        &