Added wrappers for wxAUI

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-07-08 02:13:59 +00:00
parent 06d4c4d65a
commit febb39df07
8 changed files with 2186 additions and 12 deletions

1114
wxPython/demo/AUI.py Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -48,15 +48,17 @@ _treeList = [
# new stuff
('Recent Additions/Updates', [
'AnalogClock',
'AUI',
'CheckListCtrlMixin',
'Pickers',
'RichTextCtrl',
'Treebook',
'Toolbook',
'Pickers',
]),
# managed windows == things with a (optional) caption you can close
('Frames and Dialogs', [
'AUI',
'Dialog',
'Frame',
'MDIWindows',

View File

@@ -43,7 +43,7 @@ reasons are long and complex, but suffice it to say that it was due to
mixing C++'s dynamic dispatch, and Python's runtime lookup of the
method attributes resulting in endless recursion of function calls.)
Because of this problem I used a hack that I have always hated, and
that is renaming the base class methods with a "base_" prefix, for
that is renaming the base class methods with a "base_*" prefix, for
example wx.Printout.base_OnBeginDocument. Now that the problem has
finally been solved I have replaced all the base_Whatever() methods
with the real Whatever() method as well as a simple wrapper named
@@ -67,7 +67,7 @@ Or like this with super()::
return super(MyPrintout, self).OnBeginDocument(start, end)
Note that the old way with the "base_" function still works, but you
Note that the old way with the "base_*" function still works, but you
will get a DeprecationWarning from calling base_OnBeginDocument. The
classes affected by this are:
@@ -167,6 +167,11 @@ hit (if any) in addition to the item and flags.
Added wrappers for wx.ColourPickerCtrl, wx.DirPickerCtrl,
wx.FilePickerCtrl, and wx.FontPickerCtrl.
Patch #1502016 wx.Image.ConvertToGreyscale now retains the alpha
channel.
Added wrappers for the wxAUI classes, in the wx.aui module.

View File

@@ -1469,6 +1469,43 @@ extern wxPyApp *wxPythonApp;
PCLASS::CBNAME(c); \
} \
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
void CBNAME(int a, const wxColour& c);
#define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a, const wxColour& c) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a, c); \
} \
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK__INTFONT(CBNAME) \
void CBNAME(int a, const wxFont& c);
#define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a, const wxFont& c) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
Py_DECREF(obj); \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a, c); \
} \
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
@@ -1970,6 +2007,31 @@ extern wxPyApp *wxPythonApp;
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_INT_INT(CBNAME) \
int CBNAME(int a)
#define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
int CLASS::CBNAME(int a) { \
int rval=-1; \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
if (ro) { \
rval = PyInt_AsLong(ro); \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
rval = PCLASS::CBNAME(a); \
return rval; \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
int CBNAME(long a, long b) const
@@ -2242,7 +2304,7 @@ extern wxPyApp *wxPythonApp;
PyObject* obj = wxPyMake_wxObject(&a,false); \
PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
Py_DECREF(obj); \
Py_DECREF(obj); Py_DECREF(ro); \
} \
wxPyEndBlockThreads(blocked); \
} \
@@ -2260,7 +2322,7 @@ extern wxPyApp *wxPythonApp;
PyObject* obj = wxPyMake_wxObject(&a,false); \
PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
Py_DECREF(obj); \
Py_DECREF(obj); Py_DECREF(ro); \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
@@ -2282,7 +2344,7 @@ extern wxPyApp *wxPythonApp;
PyObject* obj = wxPyMake_wxObject(&a,false); \
PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
Py_DECREF(obj); \
Py_DECREF(obj); Py_DECREF(ro); \
} \
wxPyEndBlockThreads(blocked); \
} \
@@ -2300,20 +2362,16 @@ extern wxPyApp *wxPythonApp;
PyObject* obj = wxPyMake_wxObject(&a,false); \
PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
Py_DECREF(obj); \
Py_DECREF(obj); Py_DECREF(ro); \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a,b,c); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
#define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
wxString CBNAME(size_t a) const
#define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
@@ -2386,4 +2444,56 @@ extern wxPyApp *wxPythonApp;
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_FONT_INT(CBNAME) \
wxFont CBNAME(int a)
#define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
wxFont CLASS::CBNAME(int a) { \
wxFont rv; \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
wxFont* ptr; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
if (ro) { \
if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
rv = *ptr; \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
rv = PCLASS::CBNAME(a); \
return rv; \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
wxColour CBNAME(int a)
#define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
wxColour CLASS::CBNAME(int a) { \
wxColour rv; \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
PyObject* ro; \
wxColour* ptr; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
if (ro) { \
if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
rv = *ptr; \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
rv = PCLASS::CBNAME(a); \
return rv; \
}
//---------------------------------------------------------------------------
#endif

View File

@@ -488,6 +488,31 @@ wxpExtensions.append(ext)
swig_sources = run_swig(['aui.i'], 'src', GENDIR, PKGDIR,
USE_SWIG, swig_force,
swig_args + ['-I'+opj(WXDIR, 'include/wx/aui')],
swig_deps + ['src/_aui_docstrings.i',
opj(WXDIR, 'include/wx/aui/framemanager.h'),
opj(WXDIR, 'include/wx/aui/floatpane.h'),
opj(WXDIR, 'include/wx/aui/dockart.h'),
])
if not MONOLITHIC:
auiLib = makeLibName('aui')
else:
auiLib = []
ext = Extension('_aui', swig_sources,
include_dirs = includes,
define_macros = defines,
library_dirs = libdirs,
libraries = libs + auiLib,
extra_compile_args = cflags,
extra_link_args = lflags,
**depends
)
wxpExtensions.append(ext)
#----------------------------------------------------------------------

View File

@@ -23,10 +23,12 @@ __all__ = [
'tools',
# other modules
'aui',
'calendar',
'grid',
'html',
'media',
'richtext',
'webkit',
'wizard',
'xrc',

View File

@@ -0,0 +1,516 @@
/////////////////////////////////////////////////////////////////////////////
// Name: _aui_docstrings.i
// Purpose: Docstrings for the wxAUI classes. These are in a separate
// file because we have SWIG scan the .h files directly.
//
// Author: Robin Dunn
//
// Created: 7-July-2006
// RCS-ID: $Id$
// Copyright: (c) 2006 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
DocStr(wxFrameManager,
"FrameManager manages the panes associated with it for a particular
`wx.Frame`, using a pane's `PaneInfo` information to determine each
pane's docking and floating behavior. FrameManager uses wxWidgets'
sizer mechanism to plan the layout of each frame. It uses a
replaceable `DockArt` class to do all drawing, so all drawing is
localized in one area, and may be customized depending on an
application's specific needs.
",
"
FrameManager works as follows: The programmer adds panes to the
class, or makes changes to existing pane properties (dock position,
floating state, show state, etc.). To apply these changes,
FrameManager's `Update` function is called. This batch processing
can be used to avoid flicker, by modifying more than one pane at a
time, and then \"committing\" all of the changes at once by calling
`Update`.
Panes can be added quite easily::
text1 = wx.TextCtrl(self, -1)
text2 = wx.TextCtrl(self, -1)
self._mgr.AddPane(text1, wx.LEFT, \"Pane Caption\")
self._mgr.AddPane(text2, wx.BOTTOM, \"Pane Caption\")
self._mgr.Update()
Later on, the positions can be modified easily. The following will
float an existing pane in a tool window::
self._mgr.GetPane(text1).Float();
**Layers, Rows and Directions, Positions**
Inside wx.aui the docking layout is figured out by checking several
pane parameters. Four of these are important for determining where a
pane will end up:
* **Direction**: Each docked pane has a direction, Top, Bottom,
Left, Right, or Center. This is fairly self-explanatory. The
pane will be placed in the location specified by this variable.
* **Position**: More than one pane can be placed inside of a
\"dock.\" Imagine two panes being docked on the left side of a
window. One pane can be placed over another. In proportionally
managed docks, the pane position indicates it's sequential
position, starting with zero. So, in our scenario with two panes
docked on the left side, the top pane in the dock would have
position 0, and the second one would occupy position 1.
* **Row**: A row can allow for two docks to be placed next to each
other. One of the most common places for this to happen is in
the toolbar. Multiple toolbar rows are allowed, the first row
being in row 0, and the second in row 1. Rows can also be used
on vertically docked panes.
* **Layer**: A layer is akin to an onion. Layer 0 is the very
center of the managed pane. Thus, if a pane is in layer 0, it
will be closest to the center window (also sometimes known as
the \"content window\"). Increasing layers \"swallow up\" all
layers of a lower value. This can look very similar to multiple
rows, but is different because all panes in a lower level yield
to panes in higher levels. The best way to understand layers is
by running the AUI sample in the wxPython demo.
");
DocStr(wxFrameManager::wxFrameManager,
"Constructor.
:param frame: Specifies the `wx.Frame` which should be managed.
If not set in the call to this constructor then `SetFrame`
should be called.
:param flags: Specifies options which allow the frame management
behavior to be modified.
",
"
Valid flags are:
============================== =================================
AUI_MGR_ALLOW_FLOATING Panes can be undocked and floated
AUI_MGR_ALLOW_ACTIVE_PANE The last pane clicked on will be
considered the active pane and will
be highlighted.
AUI_MGR_TRANSPARENT_DRAG If the platform supports it the panes
will be partially transparent while
dragging.
AUI_MGR_TRANSPARENT_HINT If the platform supports it the
hint used to show where the pane can
be docked will be partially transparent.
AUI_MGR_TRANSPARENT_HINT_FADE Should the transparent hint be faded
into view.
AUI_MGR_DEFAULT The default flags.
============================== =================================
");
DocStr(wxFrameManager::UnInit,
"UnInit uninitializes the framework and should be called before a
managed frame is destroyed. UnInit is usually called in the managed
wx.Frame's destructor.
", "");
DocStr(wxFrameManager::SetFlags,
"SetFlags is used to specify the FrameManager's behavioral
settings. The flags parameter is described in the docs for `__init__`
", "");
DocStr(wxFrameManager::GetFlags,
"GetFlags returns the current FrameManager's flags.
", "");
DocStr(wxFrameManager::SetFrame,
"SetFrame is called to specify the frame which is to be managed by the
FrameManager. It only needs to be called if the Frame was not given
to the manager in the constructor.
", "");
DocStr(wxFrameManager::GetFrame,
"GetFrame returns the frame currently being managed by the
FrameManager.
", "");
DocStr(wxFrameManager::SetArtProvider,
"SetArtProvider instructs FrameManager to use the art provider
specified for all drawing calls. This allows plugable look-and-feel
features. The previous art provider object, if any, will be destroyed
by FrameManager.
:note: If you wish to use a custom `DockArt` class to override drawing
or metrics then you shoudl derive your class from the `PyDockArt`
class, which has been instrumented for reflecting virtual calls to
Python methods.
", "");
DocStr(wxFrameManager::GetArtProvider,
"GetArtProvider returns the current art provider being used.
", "");
DocAStr(wxFrameManager::GetAllPanes,
"GetAllPanes(self) -> list",
"GetAllPanes returns a list of `PaneInfo` objects for all panes managed
by the frame manager.
", "");
DocStr(wxFrameManager::InsertPane,
"InsertPane is used to insert either a previously unmanaged pane window
into the frame manager, or to insert a currently managed pane
somewhere else. InsertPane will push all panes, rows, or docks aside
and insert the window into the position specified by
``insert_location``. Because ``insert_location`` can specify either a pane,
dock row, or dock layer, the ``insert_level`` parameter is used to
disambiguate this. The parameter ``insert_level`` can take a value of
``AUI_INSERT_PANE``, ``AUI_INSERT_ROW`` or ``AUI_INSERT_DOCK``.
", "");
DocStr(wxFrameManager::DetachPane,
"DetachPane tells the FrameManager to stop managing the pane specified
by window. The window, if in a floated frame, is reparented to the
frame managed by FrameManager.
", "");
DocStr(wxFrameManager::SavePerspective,
"SavePerspective saves the entire user interface layout into an encoded
string, which can then be stored someplace by the application. When a
perspective is restored using `LoadPerspective`, the entire user
interface will return to the state it was when the perspective was
saved.
", "");
DocStr(wxFrameManager::LoadPerspective,
"LoadPerspective loads a saved perspective. If ``update`` is ``True``,
`Update` is automatically invoked, thus realizing the saved
perspective on screen.
", "");
DocStr(wxFrameManager::Update,
"Update shoudl be called called after any number of changes are made to
any of the managed panes. Update must be invoked after `AddPane` or
`InsertPane` are called in order to \"realize\" or \"commit\" the
changes. In addition, any number of changes may be made to `PaneInfo`
structures (retrieved with `GetPane` or `GetAllPanes`), but to realize
the changes, Update must be called. This construction allows pane
flicker to be avoided by updating the whole layout at one time.
", "");
//----------------------------------------------------------------------
DocStr(wxPaneInfo,
"PaneInfo specifies all the parameters for a pane for the
`FrameManager`. These parameters specify where the pane is on the
screen, whether it is docked or floating, or hidden. In addition,
these parameters specify the pane's docked position, floating
position, preferred size, minimum size, caption text among many other
parameters.
", "");
DocStr(wxPaneInfo::IsOk,
"IsOk returns ``True`` if the PaneInfo structure is valid.
", "");
DocStr(wxPaneInfo::IsFixed,
"IsFixed returns ``True`` if the pane cannot be resized.
", "");
DocStr(wxPaneInfo::IsResizable,
"IsResizeable returns ``True`` if the pane can be resized.
", "");
DocStr(wxPaneInfo::IsShown,
"IsShown returns ``True`` if the pane should be drawn on the screen.
", "");
DocStr(wxPaneInfo::IsFloating,
"IsFloating returns ``True`` if the pane is floating.
", "");
DocStr(wxPaneInfo::IsDocked,
"IsDocked returns ``True`` if the pane is docked.
", "");
DocStr(wxPaneInfo::IsToolbar,
"IsToolbar returns ``True`` if the pane contains a toolbar.
", "");
DocStr(wxPaneInfo::IsTopDockable,
"IsTopDockable returns ``True`` if the pane can be docked at the top of
the managed frame.
", "");
DocStr(wxPaneInfo::IsBottomDockable,
"IsBottomDockable returns ``True`` if the pane can be docked at the
bottom of the managed frame.
", "");
DocStr(wxPaneInfo::IsLeftDockable,
"IsLeftDockable returns ``True`` if the pane can be docked on the left
of the managed frame.
", "");
DocStr(wxPaneInfo::IsRightDockable,
"IsRightDockable returns ``True`` if the pane can be docked on the
right of the managed frame.
", "");
DocStr(wxPaneInfo::IsFloatable,
"IsFloatable returns ``True`` if the pane can be undocked and displayed
as a floating window.
", "");
DocStr(wxPaneInfo::IsMovable,
"IsMoveable returns ``True`` if the docked frame can be undocked or moved
to another dock position.
", "");
DocStr(wxPaneInfo::HasCaption,
"HasCaption returns ``True`` if the pane displays a caption.
", "");
DocStr(wxPaneInfo::HasGripper,
"HasGripper returns ``True`` if the pane displays a gripper.
", "");
DocStr(wxPaneInfo::HasBorder,
"HasBorder returns ``True`` if the pane displays a border.
", "");
DocStr(wxPaneInfo::HasCloseButton,
"HasCloseButton returns ``True`` if the pane displays a button to close
the pane.
", "");
DocStr(wxPaneInfo::HasMaximizeButton,
"HasMaximizeButton returns ``True`` if the pane displays a button to
maximize the pane.
", "");
DocStr(wxPaneInfo::HasMinimizeButton,
"HasMinimizeButton returns ``True`` if the pane displays a button to
minimize the pane.
", "");
DocStr(wxPaneInfo::HasPinButton,
"HasPinButton returns ``True`` if the pane displays a button to float
the pane.
", "");
DocStr(wxPaneInfo::Name,
"Name sets the name of the pane so it can be referenced in lookup
functions.
", "");
DocStr(wxPaneInfo::Caption,
"Caption sets the caption of the pane.
", "");
DocStr(wxPaneInfo::Left,
"Left sets the pane dock position to the left side of the frame.
", "");
DocStr(wxPaneInfo::Right,
"Right sets the pane dock position to the right side of the frame.
", "");
DocStr(wxPaneInfo::Top,
"Top sets the pane dock position to the top of the frame.
", "");
DocStr(wxPaneInfo::Bottom,
"Bottom sets the pane dock position to the bottom of the frame.
", "");
DocStr(wxPaneInfo::Centre,
"Centre sets the pane to the center position of the frame.
", "");
DocStr(wxPaneInfo::Center,
"Center sets the pane to the center position of the frame.
", "");
DocStr(wxPaneInfo::Direction,
"Direction determines the direction of the docked pane.
", "");
DocStr(wxPaneInfo::Layer,
"Layer determines the layer of the docked pane.
", "");
DocStr(wxPaneInfo::Row,
"Row determines the row of the docked pane.
", "");
DocStr(wxPaneInfo::Position,
"Position determines the position of the docked pane.
", "");
DocStr(wxPaneInfo::MaxSize,
"MaxSize sets the maximum size of the pane.
", "");
DocStr(wxPaneInfo::BestSize,
"BestSize sets the ideal size for the pane.
", "");
DocStr(wxPaneInfo::MinSize,
"MinSize sets the minimum size of the pane.
", "");
DocStr(wxPaneInfo::FloatingPosition,
"FloatingPosition sets the position of the floating pane.
", "");
DocStr(wxPaneInfo::FloatingSize,
"FloatingSize sets the size of the floating pane.
", "");
DocStr(wxPaneInfo::Fixed,
"Fixed forces a pane to be fixed size so that it cannot be resized.
", "");
DocStr(wxPaneInfo::Resizable,
"Resized allows a pane to be resized if resizable is true, and forces
it to be a fixed size if resizeable is false.
", "");
DocStr(wxPaneInfo::Dock,
"Dock indicates that a pane should be docked.
", "");
DocStr(wxPaneInfo::Float,
"Float indicates that a pane should be floated.
", "");
DocStr(wxPaneInfo::Hide,
"Hide indicates that a pane should be hidden.
", "");
DocStr(wxPaneInfo::Show,
"Show indicates that a pane should be shown.
", "");
DocStr(wxPaneInfo::CaptionVisible,
"CaptionVisible indicates that a pane caption should be visible.
", "");
DocStr(wxPaneInfo::PaneBorder,
"PaneBorder indicates that a border should be drawn for the pane.
", "");
DocStr(wxPaneInfo::Gripper,
"Gripper indicates that a gripper should be drawn for the pane..
", "");
DocStr(wxPaneInfo::CloseButton,
"CloseButton indicates that a close button should be drawn for the
pane.
", "");
DocStr(wxPaneInfo::MaximizeButton,
"MaximizeButton indicates that a maximize button should be drawn for
the pane.
", "");
DocStr(wxPaneInfo::MinimizeButton,
"MinimizeButton indicates that a minimize button should be drawn for
the pane.
", "");
DocStr(wxPaneInfo::PinButton,
"PinButton indicates that a pin button should be drawn for the pane.
", "");
DocStr(wxPaneInfo::DestroyOnClose,
"DestroyOnClose indicates whether a pane should be detroyed when it is
closed.
", "");
DocStr(wxPaneInfo::TopDockable,
"TopDockable indicates whether a pane can be docked at the top of the
frame.
", "");
DocStr(wxPaneInfo::BottomDockable,
"BottomDockable indicates whether a pane can be docked at the bottom of
the frame.
", "");
DocStr(wxPaneInfo::LeftDockable,
"LeftDockable indicates whether a pane can be docked on the left of the
frame.
", "");
DocStr(wxPaneInfo::RightDockable,
"RightDockable indicates whether a pane can be docked on the right of
the frame.
", "");
DocStr(wxPaneInfo::Floatable,
"Floatable indicates whether a frame can be floated.
", "");
DocStr(wxPaneInfo::Movable,
"Movable indicates whether a frame can be moved.
", "");
DocStr(wxPaneInfo::Dockable,
"Dockable indicates whether a pane can be docked at any position of the
frame.
", "");
DocStr(wxPaneInfo::DefaultPane,
"DefaultPane specifies that the pane should adopt the default pane
settings.
", "");
DocStr(wxPaneInfo::CentrePane,
"CentrePane specifies that the pane should adopt the default center
pane settings.
", "");
DocStr(wxPaneInfo::CenterPane,
"CenterPane specifies that the pane should adopt the default center
pane settings.
", "");
DocStr(wxPaneInfo::ToolbarPane,
"ToolbarPane specifies that the pane should adopt the default toolbar
pane settings.
", "");
DocStr(wxPaneInfo::SetFlag,
"SetFlag turns the property given by flag on or off with the
option_state parameter.
", "");
DocStr(wxPaneInfo::HasFlag,
"HasFlag returns ``True`` if the the property specified by flag is
active for the pane.
", "");
//---------------------------------------------------------------------------
DocStr(wxDockArt,
"DockArt is an art provider class which does all of the drawing for
`FrameManager`. This allows the library caller to customize or replace the
dock art and drawing routines by deriving a new class from `PyDockArt`. The
active dock art class can be set via `FrameManager.SetArtProvider`.
", "");
DocStr(wxDefaultDockArt,
"DefaultDockArt is the type of art class constructed by default for the
`FrameManager`.","");

400
wxPython/src/aui.i Executable file
View File

@@ -0,0 +1,400 @@
/////////////////////////////////////////////////////////////////////////////
// Name: aui.i
// Purpose: Wrappers for the wxAUI classes.
//
// Author: Robin Dunn
//
// Created: 5-July-2006
// RCS-ID: $Id$
// Copyright: (c) 2006 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
%define DOCSTRING
"The wx.aui moduleis an Advanced User Interface library that aims to
implement \"cutting-edge\" interface usability and design features so
developers can quickly and easily create beautiful and usable
application interfaces.
**Vision and Design Principles**
wx.aui attempts to encapsulate the following aspects of the user
interface:
* Frame Management: Frame management provides the means to open,
move and hide common controls that are needed to interact with the
document, and allow these configurations to be saved into
different perspectives and loaded at a later time.
* Toolbars: Toolbars are a specialized subset of the frame
management system and should behave similarly to other docked
components. However, they also require additional functionality,
such as \"spring-loaded\" rebar support, \"chevron\" buttons and
end-user customizability.
* Modeless Controls: Modeless controls expose a tool palette or set
of options that float above the application content while allowing
it to be accessed. Usually accessed by the toolbar, these controls
disappear when an option is selected, but may also be \"torn off\"
the toolbar into a floating frame of their own.
* Look and Feel: Look and feel encompasses the way controls are
drawn, both when shown statically as well as when they are being
moved. This aspect of user interface design incorporates \"special
effects\" such as transparent window dragging as well as frame
animation.
**PyAUI adheres to the following principles**
- Use native floating frames to obtain a native look and feel for
all platforms;
- Use existing wxPython code where possible, such as sizer
implementation for frame management;
- Use standard wxPython coding conventions.
**Usage**
The following example shows a simple implementation that utilizes
`wx.aui.FrameManager` to manage three text controls in a frame window::
import wx
import wx.aui
class MyFrame(wx.Frame):
def __init__(self, parent, id=-1, title='wx.aui Test',
size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self._mgr = wx.aui.FrameManager(self)
# create several text controls
text1 = wx.TextCtrl(self, -1, 'Pane 1 - sample text',
wx.DefaultPosition, wx.Size(200,150),
wx.NO_BORDER | wx.TE_MULTILINE)
text2 = wx.TextCtrl(self, -1, 'Pane 2 - sample text',
wx.DefaultPosition, wx.Size(200,150),
wx.NO_BORDER | wx.TE_MULTILINE)
text3 = wx.TextCtrl(self, -1, 'Main content window',
wx.DefaultPosition, wx.Size(200,150),
wx.NO_BORDER | wx.TE_MULTILINE)
# add the panes to the manager
self._mgr.AddPane(text1, wx.LEFT, 'Pane Number One')
self._mgr.AddPane(text2, wx.BOTTOM, 'Pane Number Two')
self._mgr.AddPane(text3, wx.CENTER)
# tell the manager to 'commit' all the changes just made
self._mgr.Update()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
# deinitialize the frame manager
self._mgr.UnInit()
# delete the frame
self.Destroy()
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()
"
%enddef
%module(package="wx", docstring=DOCSTRING) aui
%{
#include "wx/wxPython/wxPython.h"
#include "wx/wxPython/pyclasses.h"
#include <wx/aui/aui.h>
%}
//---------------------------------------------------------------------------
%import core.i
%import windows.i
%pythoncode { wx = _core }
%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
%include _aui_docstrings.i
//---------------------------------------------------------------------------
#define wxUSE_AUI 1
#define WXDLLIMPEXP_AUI
#define unsigned
// We'll let SWIG handle the function overloading for these
%ignore wxPaneInfo::MaxSize(int x, int y);
%ignore wxPaneInfo::MinSize(int x, int y);
%ignore wxPaneInfo::BestSize(int x, int y);
%ignore wxPaneInfo::FloatingPosition(int x, int y);
%ignore wxPaneInfo::FloatingSize(int x, int y);
// But for these we will do the overloading (see %pythoncode below) so let's
// rename the C++ versions
%rename(_GetPaneByWidget) wxFrameManager::GetPane(wxWindow* window);
%rename(_GetPaneByName) wxFrameManager::GetPane(const wxString& name);
%rename(_AddPane1) wxFrameManager::AddPane(wxWindow* window, const wxPaneInfo& pane_info);
%rename(_AddPane2) wxFrameManager::AddPane(wxWindow* window, int direction = wxLEFT,
const wxString& caption = wxEmptyString);
// A typemap for the return value of wxFrameManager::GetAllPanes
%typemap(out) wxPaneInfoArray& {
$result = PyList_New(0);
for (size_t i=0; i < $1->GetCount(); i++) {
PyObject* pane_obj = SWIG_NewPointerObj((void*)(&$1->Item(i)), SWIGTYPE_p_wxPaneInfo, 0);
PyList_Append($result, pane_obj);
}
}
//---------------------------------------------------------------------------
// Get all our defs from the REAL header files.
%include framemanager.h
%include dockart.h
%include floatpane.h
//---------------------------------------------------------------------------
// Methods to inject into the FrameManager class that will sort out calls to
// the overloaded versions of GetPane and AddPane
%extend wxFrameManager {
%pythoncode {
def GetPane(self, item):
"""
GetPane(self, window_or_info item) -> PaneInfo
GetPane is used to search for a `PaneInfo` object either by
widget reference or by pane name, which acts as a unique id
for a window pane. The returned `PaneInfo` object may then be
modified to change a pane's look, state or position. After one
or more modifications to the `PaneInfo`, `FrameManager.Update`
should be called to realize the changes to the user interface.
If the lookup failed (meaning the pane could not be found in
the manager) GetPane returns an empty `PaneInfo`, a condition
which can be checked by calling `PaneInfo.IsOk`.
"""
if isinstance(item, wx.Window):
return self._GetPaneByWidget(item)
else:
return self._GetPaneByName(item)
def AddPane(self, window, info=None, caption=None):
"""
AddPane(self, window, info=None, caption=None) -> bool
AddPane tells the frame manager to start managing a child
window. There are two versions of this function. The first
verison accepts a `PaneInfo` object for the ``info`` parameter
and allows the full spectrum of pane parameter
possibilities. (Say that 3 times fast!)
The second version is used for simpler user interfaces which
do not require as much configuration. In this case the
``info`` parameter specifies the direction property of the
pane info, and defaults to ``wx.LEFT``. The pane caption may
also be specified as an extra parameter in this form.
"""
if type(arg1) == PaneInfo:
return self._AddPane1(window, arg1)
else:
# This Is AddPane2
if arg1 is None:
arg1 = wx.LEFT
if arg2 is None:
arg2 = ""
return self._AddPane2(window, arg1, arg2)
}
}
//---------------------------------------------------------------------------
%{
class wxPyDockArt : public wxDefaultDockArt
{
wxPyDockArt() : wxDefaultDockArt() {}
DEC_PYCALLBACK_INT_INT(GetMetric);
DEC_PYCALLBACK_VOID_INTINT(SetMetric);
DEC_PYCALLBACK__INTFONT(SetFont);
DEC_PYCALLBACK_FONT_INT(GetFont);
DEC_PYCALLBACK_COLOUR_INT(GetColour);
DEC_PYCALLBACK__INTCOLOUR(SetColour);
virtual void DrawSash(wxDC& dc,
int orientation,
const wxRect& rect)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawSash"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)",
odc, orientation, orect));
Py_DECREF(odc);
Py_DECREF(orect);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawSash(dc, orientation, rect);
}
virtual void DrawBackground(wxDC& dc,
int orientation,
const wxRect& rect)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawBackground"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)",
odc, orientation, orect));
Py_DECREF(odc);
Py_DECREF(orect);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawBackground(dc, orientation, rect);
}
virtual void DrawCaption(wxDC& dc,
const wxString& text,
const wxRect& rect,
wxPaneInfo& pane)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawCaption"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* otext = wx2PyString(text);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOO)",
odc, otext, orect, opane));
Py_DECREF(odc);
Py_DECREF(otext);
Py_DECREF(orect);
Py_DECREF(opane);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawCaption(dc, text, rect, pane);
}
virtual void DrawGripper(wxDC& dc,
const wxRect& rect,
wxPaneInfo& pane)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawGripper"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
Py_DECREF(odc);
Py_DECREF(orect);
Py_DECREF(opane);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawGripper(dc, rect, pane);
}
virtual void DrawBorder(wxDC& dc,
const wxRect& rect,
wxPaneInfo& pane)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawBorder"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", odc, orect, opane));
Py_DECREF(odc);
Py_DECREF(orect);
Py_DECREF(opane);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawBorder(dc, rect, pane);
}
virtual void DrawPaneButton(wxDC& dc,
int button,
int button_state,
const wxRect& rect,
wxPaneInfo& pane)
{
bool found;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DrawPaneButton"))) {
PyObject* odc = wxPyMake_wxObject(&dc, false);
PyObject* orect = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
PyObject* opane = wxPyConstructObject((void*)&pane, wxT("wxPaneInfo"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiIOO)",
odc, button, button_state,
orect, opane));
Py_DECREF(odc);
Py_DECREF(orect);
Py_DECREF(opane);
}
wxPyEndBlockThreads(blocked);
if (! found)
wxDefaultDockArt::DrawPaneButton(dc, button, button_state, rect, pane);
}
PYPRIVATE;
};
IMP_PYCALLBACK_INT_INT(wxPyDockArt, wxDefaultDockArt, GetMetric);
IMP_PYCALLBACK_VOID_INTINT(wxPyDockArt, wxDefaultDockArt, SetMetric);
IMP_PYCALLBACK__INTFONT(wxPyDockArt, wxDefaultDockArt, SetFont);
IMP_PYCALLBACK_FONT_INT(wxPyDockArt, wxDefaultDockArt, GetFont);
IMP_PYCALLBACK_COLOUR_INT(wxPyDockArt, wxDefaultDockArt, GetColour);
IMP_PYCALLBACK__INTCOLOUR(wxPyDockArt, wxDefaultDockArt, SetColour);
%}
DocStr(wxPyDockArt,
"This version of the `DockArt` class has been instrumented to be
subclassable in Python and to reflect all calls to the C++ base class
methods to the Python methods implemented in the derived class.", "");
class wxPyDockArt : public wxDefaultDockArt
{
%pythonAppend wxPyDockArt "self._setCallbackInfo(self, PyDockArt)"
PyDocArt();
};
#undef wxUSE_AUI
#undef WXDLLIMPEXP_AUI
//---------------------------------------------------------------------------