%newgroup
+DocStr(wxVisualAttributes,
+ "struct containing all the visual attributes of a control");
+
+struct wxVisualAttributes
+{
+ %extend {
+ wxVisualAttributes() { return new wxVisualAttributes; }
+ ~wxVisualAttributes() {}
+ }
+
+ // the font used for control label/text inside it
+ wxFont font;
+
+ // the foreground colour
+ wxColour colFg;
+
+ // the background colour, may be wxNullColour if the controls background
+ // colour is not solid
+ wxColour colBg;
+};
+
+
+
+
+enum wxWindowVariant
+{
+ wxWINDOW_VARIANT_NORMAL, // Normal size
+ wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal )
+ wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal )
+ wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal )
+ wxWINDOW_VARIANT_MAX
+};
+
+
DocStr(wxWindow,
"
wx.Window is the base class for all windows and represents any visible
%pythonAppend wxWindow "self._setOORInfo(self)"
%pythonAppend wxWindow() ""
+ RefDoc(wxWindow, ""); // turn it off for the ctors
+
DocCtorStr(
- wxWindow(wxWindow* parent, const wxWindowID id,
+ wxWindow(wxWindow* parent, const wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
DocDeclStr(
- bool , Create(wxWindow* parent, const wxWindowID id,
+ bool , Create(wxWindow* parent, const wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
DocDeclStr(
virtual wxString , GetLabel() const,
- "Generic way of getting a label from any window, for identification
-purposes. The interpretation of this function differs from class to
-class. For frames and dialogs, the value returned is the title. For
-buttons or static text controls, it is the button text. This function
-can be useful for meta-programs (such as testing tools or
-special-needs access programs) which need to identify windows by name.");
+ "Generic way of getting a label from any window, for
+identification purposes. The interpretation of this function
+differs from class to class. For frames and dialogs, the value
+returned is the title. For buttons or static text controls, it is
+the button text. This function can be useful for meta-programs
+such as testing tools or special-needs access programs)which
+need to identify windows by name.");
- // the window name is used for ressource setting in X, it is not the
- // same as the window title/label
DocDeclStr(
virtual void , SetName( const wxString &name ),
- "Sets the window's name. The window name is used for ressource setting
-in X, it is not the same as the window title/label");
+ "Sets the window's name. The window name is used for ressource
+setting in X, it is not the same as the window title/label");
DocDeclStr(
virtual wxString , GetName() const,
- "Returns the window's name. This name is not guaranteed to be unique;
-it is up to the programmer to supply an appropriate name in the window
-constructor or via wx.Window.SetName.");
+ "Returns the windows name. This name is not guaranteed to be
+unique; it is up to the programmer to supply an appropriate name
+in the window constructor or via wx.Window.SetName.");
+
+
+ DocDeclStr(
+ void , SetWindowVariant( wxWindowVariant variant ),
+ "Sets the variant of the window/font size to use for this window,
+if the platform supports variants, for example, wxMac. Variant values are:
+
+ wx.WINDOW_VARIANT_NORMAL Normal size
+ wx.WINDOW_VARIANT_SMALL Smaller size (about 25 % smaller than normal)
+ wx.WINDOW_VARIANT_MINI Mini size (about 33 % smaller than normal)
+ wx.WINDOW_VARIANT_LARGE Large size (about 25 % larger than normal)
+");
+
+ DocDeclStr(
+ wxWindowVariant , GetWindowVariant() const,
+ "");
- // window id uniquely identifies the window among its siblings unless
- // it is -1 which means "don't care"
DocDeclStr(
void , SetId( wxWindowID winid ),
"Sets the identifier of the window. Each window has an integer
anything if there are no subwindows.");
-
- DocDeclStr(
- virtual void , SetSizeHints( int minW, int minH,
- int maxW = -1, int maxH = -1,
- int incW = -1, int incH = -1 ),
+
+ %nokwargs SetSizeHints;
+ DocStr(SetSizeHints,
"Allows specification of minimum and maximum window sizes, and window
size increments. If a pair of values is not set (or set to -1), the
default values will be used. If this function is called, the user
will not be able to size the window outside the given bounds. The
resizing increments are only significant under Motif or Xt.");
-
+ virtual void SetSizeHints( int minW, int minH,
+ int maxW = -1, int maxH = -1,
+ int incW = -1, int incH = -1 );
+ void SetSizeHints( const wxSize& minSize,
+ const wxSize& maxSize=wxDefaultSize,
+ const wxSize& incSize=wxDefaultSize);
- DocDeclStr(
- virtual void , SetVirtualSizeHints( int minW, int minH,
- int maxW = -1, int maxH = -1 ),
+
+ %nokwargs SetVirtualSizeHints;
+ DocStr(SetVirtualSizeHints,
"Allows specification of minimum and maximum virtual window sizes. If a
pair of values is not set (or set to -1), the default values will be
used. If this function is called, the user will not be able to size
the virtual area of the window outside the given bounds.");
-
+ virtual void SetVirtualSizeHints( int minW, int minH,
+ int maxW = -1, int maxH = -1 );
+ void SetVirtualSizeHints( const wxSize& minSize,
+ const wxSize& maxSize=wxDefaultSize);
DocDeclStr(
virtual int , GetMinWidth() const,
"");
+ DocDeclStr(
+ virtual wxSize , GetMinSize() const,
+ "");
+
DocStr(SetVirtualSize,
"Set the the virtual size of a window in pixels. For most windows this
virtual wxValidator *, GetValidator(),
"Returns a pointer to the current validator for the window, or None if
there is none.");
+
+
+ DocDeclStr(
+ virtual bool , Validate(),
+ "Validates the current values of the child controls using their
+validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY
+extra style flag set, the method will also call Validate() of all
+child windows. Returns false if any of the validations failed.");
+
+
+ DocDeclStr(
+ virtual bool , TransferDataToWindow(),
+ "Transfers values to child controls from data areas specified by
+their validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY
+extra style flag set, the method will also call
+TransferDataToWindow() of all child windows.");
+
+ DocDeclStr(
+ virtual bool , TransferDataFromWindow(),
+ "Transfers values from child controls to data areas specified by
+their validators. Returns false if a transfer failed. If the
+window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the
+method will also call TransferDataFromWindow() of all child
+windows.");
+
+
+ DocDeclStr(
+ virtual void , InitDialog(),
+ "Sends an EVT_INIT_DIALOG event, whose handler usually transfers
+data to the dialog via validators.");
+
use EVT_HOTKEY with an id equal to hotkeyId. Returns True if the
hotkey was registered successfully.");
bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) {
- #if wxUSE_HOTKEY
+ %#if wxUSE_HOTKEY
return self->RegisterHotKey(hotkeyId, modifiers, keycode);
- #else
+ %#else
return False;
- #endif
+ %#endif
}
DocDeclStr(
virtual void , Freeze(),
- "Freezes the window or, in other words, prevents any updates from
-taking place on screen, the window is not redrawn at all. Thaw must be
-called to reenable window redrawing.
+ "Freezes the window or, in other words, prevents any updates from taking place
+on screen, the window is not redrawn at all. Thaw must be called to reenable
+window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw
+being delayed until all the nesting has been undone.
This method is useful for visual appearance optimization (for example,
it is a good idea to use it before inserting large amount of text into
DocDeclStr(
virtual void , Thaw(),
- "Reenables window updating after a previous call to Freeze.");
+ "Reenables window updating after a previous call to Freeze. Calls to
+Freeze/Thaw may be nested, so Thaw must be called the same number of times
+that Freeze was before the window will be updated.");
DocDeclStr(
exposed.");
bool IsExposed( int x, int y, int w=1, int h=1 ) const;
%name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const;
- %name(isExposedRect) bool IsExposed( const wxRect& rect ) const;
+ %name(IsExposedRect) bool IsExposed( const wxRect& rect ) const;
// colours, fonts and cursors
// --------------------------
- // set/retrieve the window colours (system defaults are used by
- // default): Set functions return True if colour was changed
+ DocDeclStr(
+ wxVisualAttributes , GetDefaultAttributes() const,
+ "Get the default attributes for an instance of this class. This
+is useful if you want to use the same font or colour in your own
+control as in a standard control -- which is a much better idea
+than hard coding specific colours or fonts which might look
+completely out of place on the users system, especially if it
+uses themes.");
+
+
+ DocDeclStr(
+ static wxVisualAttributes ,
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL),
+ "Get the default attributes for this class. This is useful if
+you want to use the same font or colour in your own control as
+in a standard control -- which is a much better idea than hard
+coding specific colours or fonts which might look completely out
+of place on the users system, especially if it uses themes.
+The variant parameter is only relevant under Mac currently and is
+ignore under other platforms. Under Mac, it will change the size of the
+returned font. See SetWindowVariant for more about this.");
+
DocDeclStr(
virtual bool , SetBackgroundColour( const wxColour &colour ),
window might not look equally well when used with themes, i.e GTK+'s
ability to change its look as the user wishes with run-time loadable
modules.");
+
+ DocDeclStr(
+ void , SetDefaultBackgroundColour(const wxColour& colour),
+ "");
+
+
DocDeclStr(
virtual bool , SetForegroundColour( const wxColour &colour ),
was changed. The interpretation of foreground colour is dependent on
the window class; it may be the text colour or other colour, or it may
not be used at all.");
+
+ DocDeclStr(
+ void , SetDefaultForegroundColour(const wxColour& colour),
+ "");
+
DocDeclStr(
wxColour , GetBackgroundColour() const,
"Returns the background colour of the window.");
virtual bool , SetFont( const wxFont &font ),
"Sets the font for this window.");
+ DocDeclStr(
+ void , SetDefaultFont(const wxFont& font),
+ "");
+
+
+
DocDeclStr(
wxFont& , GetFont(),
- "Returns a reference to the font for this window.");
+ "Returns the default font used for this window.");
#endif
+// TODO: These are currently protected, but woudl be nice ot have them in wxPython...
+//
+// // inherit the parents visual attributes if they had been explicitly set
+// // by the user (i.e. we don't inherit default attributes) and if we don't
+// // have our own explicitly set
+// virtual void InheritAttributes();
+
+// // returns false from here if this window doesn't want to inherit the
+// // parents colours even if InheritAttributes() would normally do it
+// //
+// // this just provides a simple way to customize InheritAttributes()
+// // behaviour in the most common case
+// virtual bool ShouldInheritColours() const { return false; }
+
%pythoncode {
def PostCreate(self, pre):
+%{
+#ifdef __WXMSW__
+#include <wx/msw/private.h> // to get wxGetWindowId
+#endif
+%}
+
%inline %{
- wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
+ wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) {
#ifdef __WXMSW__
+ WXHWND hWnd = (WXHWND)_hWnd;
+ long id = wxGetWindowId(hWnd);
wxWindow* win = new wxWindow;
- win->SetHWND((WXHWND)hWnd);
- win->SubclassWin((WXHWND)hWnd);
+ parent->AddChild(win);
+ win->SetEventHandler(win);
+ win->SetHWND(hWnd);
+ win->SetId(id);
+ win->SubclassWin(hWnd);
+ win->AdoptAttributesFromHWND();
+ win->SetupColours();
return win;
#else
wxPyRaiseNotImplemented();