PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/site-packages/wx-2.8-msw-unicode/wx/lib/agw/aui/__init__.py

https://github.com/astory/RankPanda
Python | 246 lines | 245 code | 0 blank | 1 comment | 0 complexity | 06999d913ae2cd84110693fc25506ff1 MD5 | raw file
  1. """
  2. AUI is an Advanced User Interface library that aims to implement "cutting-edge"
  3. interface usability and design features so developers can quickly and easily create
  4. beautiful and usable application interfaces.
  5. Vision and Design Principles
  6. ----------------------------
  7. AUI attempts to encapsulate the following aspects of the user interface:
  8. * **Frame Management**: Frame management provides the means to open, move and hide common
  9. controls that are needed to interact with the document, and allow these configurations
  10. to be saved into different perspectives and loaded at a later time.
  11. * **Toolbars**: Toolbars are a specialized subset of the frame management system and should
  12. behave similarly to other docked components. However, they also require additional
  13. functionality, such as "spring-loaded" rebar support, "chevron" buttons and end-user
  14. customizability.
  15. * **Modeless Controls**: Modeless controls expose a tool palette or set of options that
  16. float above the application content while allowing it to be accessed. Usually accessed
  17. by the toolbar, these controls disappear when an option is selected, but may also be
  18. "torn off" the toolbar into a floating frame of their own.
  19. * **Look and Feel**: Look and feel encompasses the way controls are drawn, both when shown
  20. statically as well as when they are being moved. This aspect of user interface design
  21. incorporates "special effects" such as transparent window dragging as well as frame animation.
  22. AUI adheres to the following principles:
  23. - Use native floating frames to obtain a native look and feel for all platforms;
  24. - Use existing wxPython code where possible, such as sizer implementation for frame management;
  25. - Use standard wxPython coding conventions.
  26. Usage:
  27. ------
  28. The following example shows a simple implementation that uses `AuiManager` to manage
  29. three text controls in a frame window::
  30. class MyFrame(wx.Frame):
  31. def __init__(self, parent, id=-1, title="AUI Test", pos=wx.DefaultPosition,
  32. size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
  33. wx.Frame.__init__(self, parent, id, title, pos, size, style)
  34. self._mgr = aui.AuiManager()
  35. # notify AUI which frame to use
  36. self._mgr.SetManagedWindow(self)
  37. # create several text controls
  38. text1 = wx.TextCtrl(self, -1, "Pane 1 - sample text",
  39. wx.DefaultPosition, wx.Size(200,150),
  40. wx.NO_BORDER | wx.TE_MULTILINE)
  41. text2 = wx.TextCtrl(self, -1, "Pane 2 - sample text",
  42. wx.DefaultPosition, wx.Size(200,150),
  43. wx.NO_BORDER | wx.TE_MULTILINE)
  44. text3 = wx.TextCtrl(self, -1, "Main content window",
  45. wx.DefaultPosition, wx.Size(200,150),
  46. wx.NO_BORDER | wx.TE_MULTILINE)
  47. # add the panes to the manager
  48. self._mgr.AddPane(text1, AuiPaneInfo().Left().Caption("Pane Number One"))
  49. self._mgr.AddPane(text2, AuiPaneInfo().Bottom().Caption("Pane Number Two"))
  50. self._mgr.AddPane(text3, AuiPaneInfo().CenterPane())
  51. # tell the manager to "commit" all the changes just made
  52. self._mgr.Update()
  53. self.Bind(wx.EVT_CLOSE, self.OnClose)
  54. def OnClose(self, event):
  55. # deinitialize the frame manager
  56. self._mgr.UnInit()
  57. self.Destroy()
  58. event.Skip()
  59. # our normal wxApp-derived class, as usual
  60. app = wx.PySimpleApp()
  61. frame = MyFrame(None)
  62. app.SetTopWindow(frame)
  63. frame.Show()
  64. app.MainLoop()
  65. What's New
  66. ----------
  67. Current wxAUI Version Tracked: wxWidgets 2.9.0 (SVN HEAD)
  68. The wxPython AUI version fixes the following bugs or implement the following
  69. missing features (the list is not exhaustive):
  70. - Visual Studio 2005 style docking: http://www.kirix.com/forums/viewtopic.php?f=16&t=596
  71. - Dock and Pane Resizing: http://www.kirix.com/forums/viewtopic.php?f=16&t=582
  72. - Patch concerning dock resizing: http://www.kirix.com/forums/viewtopic.php?f=16&t=610
  73. - Patch to effect wxAuiToolBar orientation switch: http://www.kirix.com/forums/viewtopic.php?f=16&t=641
  74. - AUI: Core dump when loading a perspective in wxGTK (MSW OK): http://www.kirix.com/forums/viewtopic.php?f=15&t=627
  75. - wxAuiNotebook reordered AdvanceSelection(): http://www.kirix.com/forums/viewtopic.php?f=16&t=617
  76. - Vertical Toolbar Docking Issue: http://www.kirix.com/forums/viewtopic.php?f=16&t=181
  77. - Patch to show the resize hint on mouse-down in aui: http://trac.wxwidgets.org/ticket/9612
  78. - The Left/Right and Top/Bottom Docks over draw each other: http://trac.wxwidgets.org/ticket/3516
  79. - MinSize() not honoured: http://trac.wxwidgets.org/ticket/3562
  80. - Layout problem with wxAUI: http://trac.wxwidgets.org/ticket/3597
  81. - Resizing children ignores current window size: http://trac.wxwidgets.org/ticket/3908
  82. - Resizing panes under Vista does not repaint background: http://trac.wxwidgets.org/ticket/4325
  83. - Resize sash resizes in response to click: http://trac.wxwidgets.org/ticket/4547
  84. - "Illegal" resizing of the AuiPane? (wxPython): http://trac.wxwidgets.org/ticket/4599
  85. - Floating wxAUIPane Resize Event doesn't update its position: http://trac.wxwidgets.org/ticket/9773
  86. - Don't hide floating panels when we maximize some other panel: http://trac.wxwidgets.org/ticket/4066
  87. - wxAUINotebook incorrect ALLOW_ACTIVE_PANE handling: http://trac.wxwidgets.org/ticket/4361
  88. - Page changing veto doesn't work, (patch supplied): http://trac.wxwidgets.org/ticket/4518
  89. - Show and DoShow are mixed around in wxAuiMDIChildFrame: http://trac.wxwidgets.org/ticket/4567
  90. - wxAuiManager & wxToolBar - ToolBar Of Size Zero: http://trac.wxwidgets.org/ticket/9724
  91. - wxAuiNotebook doesn't behave properly like a container as far as...: http://trac.wxwidgets.org/ticket/9911
  92. - Serious layout bugs in wxAUI: http://trac.wxwidgets.org/ticket/10620
  93. Plus the following features:
  94. - AuiManager:
  95. (a) Implementation of a simple minimize pane system: Clicking on this minimize button causes a new
  96. AuiToolBar to be created and added to the frame manager, (currently the implementation is such
  97. that panes at West will have a toolbar at the right, panes at South will have toolbars at the
  98. bottom etc...) and the pane is hidden in the manager.
  99. Clicking on the restore button on the newly created toolbar will result in the toolbar being
  100. removed and the original pane being restored;
  101. (b) Panes can be docked on top of each other to form `AuiNotebooks`; `AuiNotebooks` tabs can be torn
  102. off to create floating panes;
  103. (c) On Windows XP, use the nice sash drawing provided by XP while dragging the sash;
  104. (d) Possibility to set an icon on docked panes;
  105. (e) Possibility to draw a sash visual grip, for enhanced visualization of sashes;
  106. (f) Implementation of a native docking art (`ModernDockArt`). Windows XP only, **requires** Mark Hammond's
  107. pywin32 package (winxptheme);
  108. (g) Possibility to set a transparency for floating panes (a la Paint .NET);
  109. (h) Snapping the main frame to the screen in any positin specified by horizontal and vertical
  110. alignments;
  111. (i) Snapping floating panes on left/right/top/bottom or any combination of directions, a la Winamp;
  112. (j) "Fly-out" floating panes, i.e. panes which show themselves only when the mouse hover them;
  113. (k) Ability to set custom bitmaps for pane buttons (close, maximize, etc...);
  114. (l) Implementation of the style ``AUI_MGR_ANIMATE_FRAMES``, which fade-out floating panes when
  115. they are closed (all platforms which support frames transparency) and show a moving rectangle
  116. when they are docked and minimized (Windows < Vista and GTK only);
  117. (m) A pane switcher dialog is available to cycle through existing AUI panes.
  118. - AuiNotebook:
  119. (a) Implementation of the style ``AUI_NB_HIDE_ON_SINGLE_TAB``, a la `wx.lib.agw.flatnotebook`;
  120. (b) Implementation of the style ``AUI_NB_SMART_TABS``, a la `wx.lib.agw.flatnotebook`;
  121. (c) Implementation of the style ``AUI_NB_USE_IMAGES_DROPDOWN``, which allows to show tab images
  122. on the tab dropdown menu instead of bare check menu items (a la `wx.lib.agw.flatnotebook`);
  123. (d) 6 different tab arts are available, namely:
  124. (1) Default "glossy" theme (as in `wx.aui.AuiNotebook`)
  125. (2) Simple theme (as in `wx.aui.AuiNotebook`)
  126. (3) Firefox 2 theme
  127. (4) Visual Studio 2003 theme (VC71)
  128. (5) Visual Studio 2005 theme (VC81)
  129. (6) Google Chrome theme
  130. (e) Enabling/disabling tabs;
  131. (f) Setting the colour of the tab's text;
  132. (g) Implementation of the style ``AUI_NB_CLOSE_ON_TAB_LEFT``, which draws the tab close button on
  133. the left instead of on the right (a la Camino browser);
  134. (h) Ability to save and load perspectives in `AuiNotebook` (experimental);
  135. (i) Possibility to add custom buttons in the `AuiNotebook` tab area;
  136. (j) Implementation of the style ``AUI_NB_TAB_FLOAT``, which allows the floating of single tabs.
  137. Known limitation: when the notebook is more or less full screen, tabs cannot be dragged far
  138. enough outside of the notebook to become floating pages;
  139. (k) Implementation of the style ``AUI_NB_DRAW_DND_TAB`` (on by default), which draws an image
  140. representation of a tab while dragging;
  141. (l) Implementation of the style ``AUI_NB_SASH_DCLICK_UNSPLIT``, which unsplit a splitted AuiNotebook
  142. when double-clicking on a sash.
  143. - AuiToolBar:
  144. (a) ``AUI_TB_PLAIN_BACKGROUND`` style that allows to easy setup a plain background to the AUI toolbar,
  145. without the need to override drawing methods. This style contrasts with the default behaviour
  146. of the `wx.aui.AuiToolBar` that draws a background gradient and this break the window design when
  147. putting it within a control that has margin between the borders and the toolbar (example: put
  148. `wx.aui.AuiToolBar` within a `wx.StaticBoxSizer` that has a plain background);
  149. (b) `AuiToolBar` allow item alignment: http://trac.wxwidgets.org/ticket/10174;
  150. (c) `AUIToolBar` `DrawButton()` improvement: http://trac.wxwidgets.org/ticket/10303;
  151. (d) `AuiToolBar` automatically assign new id for tools: http://trac.wxwidgets.org/ticket/10173;
  152. (e) `AuiToolBar` Allow right-click on any kind of button: http://trac.wxwidgets.org/ticket/10079;
  153. (f) `AuiToolBar` idle update only when visible: http://trac.wxwidgets.org/ticket/10075.
  154. TODOs
  155. -----
  156. - Documentation, documentation and documentation;
  157. - Fix `tabmdi.AuiMDIParentFrame` and friends, they do not work correctly at present;
  158. - Allow specification of `CaptionLeft()` to `AuiPaneInfo` to show the caption bar of docked panes
  159. on the left instead of on the top (with caption text rotated by 90 degrees then). This is
  160. similar to what `wxDockIt` did;
  161. - Make developer-created `AuiNotebooks` and automatic (framemanager-created) `AuiNotebooks` behave
  162. the same way (undocking of tabs) - DONE, to some extent;
  163. - Find a way to dock panes in already floating panes (`AuiFloatingFrames`), as they already have
  164. their own `AuiManager`;
  165. - Add events for panes when they are about to float or to be docked (something like
  166. ``EVT_AUI_PANE_FLOATING/ED`` and ``EVT_AUI_PANE_DOCKING/ED``);
  167. - Implement the 4-ways splitter behaviour for horizontal and vertical sashes if they intersect;
  168. - Extend `tabart.py` with more aui tab arts;
  169. - Implement ``AUI_NB_LEFT`` and ``AUI_NB_RIGHT`` tab locations in `AuiNotebook`;
  170. - Move `AuiDefaultToolBarArt` into a separate module (as with `tabart.py` and `dockart.py`) and
  171. provide more arts for toolbars (maybe from `wx.lib.agw.flatmenu`?)
  172. - Support multiple-rows/multiple columns toolbars;
  173. - Integrate as much as possible with `wx.lib.agw.flatmenu`, from dropdown menus in `AuiNotebook` to
  174. toolbars and menu positioning;
  175. - Possibly handle minimization of panes in a different way (or provide an option to switch to
  176. another way of minimizing panes);
  177. - Clean up/speed up the code, especially time-consuming for-loops;
  178. - Possibly integrate `wxPyRibbon` (still on development), at least on Windows.
  179. License And Version:
  180. --------------------
  181. AUI library is freeware and distributed under the wxPython license.
  182. Latest revision: Andrea Gavana @ 06 May 2009, 17.00 GMT
  183. Version 1.0.
  184. """
  185. __author__ = "Andrea Gavana <andrea.gavana@gmail.com>"
  186. __date__ = "31 March 2009"
  187. from aui_constants import *
  188. from aui_utilities import *
  189. from auibar import *
  190. from auibook import *
  191. from tabart import *
  192. from dockart import *
  193. from framemanager import *
  194. from tabmdi import *