#include "wx/colour.h"
#include "wx/region.h"
#include "wx/utils.h"
+#include "wx/intl.h"
#include "wx/validate.h" // for wxDefaultValidator (always include it)
class WXDLLEXPORT wxToolTip;
class WXDLLEXPORT wxWindowBase;
class WXDLLEXPORT wxWindow;
+class WXDLLEXPORT wxScrollHelper;
#if wxUSE_ACCESSIBILITY
class WXDLLEXPORT wxAccessible;
// ----------------------------------------------------------------------------
extern WXDLLEXPORT_DATA(wxWindowList) wxTopLevelWindows;
+extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
// ----------------------------------------------------------------------------
// wxWindowBase is the base class for all GUI controls/widgets, this is the public
// window attributes
// -----------------
-#if !defined(__WXMSW__) && \
- !defined(__WXMOTIF__)
-
- // FIXME: This is work in progress about moving SetTitle/GetTitle from wxWindow
- // to wxTopLevelWindow so initially enabled in wxMSW only to observe results
- // and continue on other platforms
-
- virtual void SetTitle( const wxString& WXUNUSED(title) ) {}
- virtual wxString GetTitle() const { return wxEmptyString; }
-
- // label is just the same as the title (but for, e.g., buttons it
- // makes more sense to speak about labels)
- virtual void SetLabel(const wxString& label) { SetTitle(label); }
- virtual wxString GetLabel() const { return GetTitle(); }
-#else
- // label is just the same as the title (but for, e.g., buttons it
- // makes more sense to speak about labels)
+ // label is just the same as the title (but for, e.g., buttons it
+ // makes more sense to speak about labels), title access
+ // is available from wxTLW classes only (frames, dialogs)
virtual void SetLabel(const wxString& label) = 0;
virtual wxString GetLabel() const = 0;
-#endif
// the window name is used for ressource setting in X, it is not the
// same as the window title/label
virtual void SetName( const wxString &name ) { m_windowName = name; }
virtual wxString GetName() const { return m_windowName; }
- // sets the window variant, calls internally DoSetVariant if variant has changed
- void SetWindowVariant( wxWindowVariant variant ) ;
- wxWindowVariant GetWindowVariant() const { return m_windowVariant ; }
+ // sets the window variant, calls internally DoSetVariant if variant
+ // has changed
+ void SetWindowVariant(wxWindowVariant variant);
+ wxWindowVariant GetWindowVariant() const { return m_windowVariant; }
// window id uniquely identifies the window among its siblings unless
void SetId( wxWindowID winid ) { m_windowId = winid; }
wxWindowID GetId() const { return m_windowId; }
+ // get or change the layout direction (LTR or RTL) for this window,
+ // wxLayout_Default is returned if layout direction is not supported
+ virtual wxLayoutDirection GetLayoutDirection() const
+ { return wxLayout_Default; }
+ virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
+ { }
+
+ // mirror coordinates for RTL layout if this window uses it and if the
+ // mirroring is not done automatically like Win32
+ virtual wxCoord AdjustForLayoutDirection(wxCoord x,
+ wxCoord width,
+ wxCoord widthTotal) const;
+
// generate a control id for the controls which were not given one by
// user
static int NewControlId() { return --ms_lastControlId; }
void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING)
{ Move(pt.x, pt.y, flags); }
+ void SetPosition(const wxPoint& pt) { Move(pt); }
+
// Z-order
virtual void Raise() = 0;
virtual void Lower() = 0;
void SetClientSize(const wxRect& rect)
{ SetClientSize( rect.width, rect.height ); }
- // get the window position and/or size (pointers may be NULL)
+ // get the window position (pointers may be NULL): notice that it is in
+ // client coordinates for child windows and screen coordinates for the
+ // top level ones, use GetScreenPosition() if you need screen
+ // coordinates for all kinds of windows
void GetPosition( int *x, int *y ) const { DoGetPosition(x, y); }
wxPoint GetPosition() const
{
- int w, h;
- DoGetPosition(&w, &h);
+ int x, y;
+ DoGetPosition(&x, &y);
- return wxPoint(w, h);
+ return wxPoint(x, y);
}
- void SetPosition( const wxPoint& pt ) { Move( pt ) ; }
+ // get the window position in screen coordinates
+ void GetScreenPosition(int *x, int *y) const { DoGetScreenPosition(x, y); }
+ wxPoint GetScreenPosition() const
+ {
+ int x, y;
+ DoGetScreenPosition(&x, &y);
+
+ return wxPoint(x, y);
+ }
+ // get the window size (pointers may be NULL)
void GetSize( int *w, int *h ) const { DoGetSize(w, h); }
wxSize GetSize() const
{
return wxSize(w, h);
}
+ void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); }
+ wxSize GetClientSize() const
+ {
+ int w, h;
+ DoGetClientSize(&w, &h);
+
+ return wxSize(w, h);
+ }
+
+ // get the position and size at once
wxRect GetRect() const
{
int x, y, w, h;
- GetPosition(& x, & y);
- GetSize(& w, & h);
+ GetPosition(&x, &y);
+ GetSize(&w, &h);
return wxRect(x, y, w, h);
}
- void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); }
- wxSize GetClientSize() const
+ wxRect GetScreenRect() const
{
- int w, h;
- DoGetClientSize(& w, & h);
+ int x, y, w, h;
+ GetScreenPosition(&x, &y);
+ GetSize(&w, &h);
- return wxSize(w, h);
+ return wxRect(x, y, w, h);
}
// get the origin of the client area of the window relative to the
*h = s.y;
}
+ void SetScrollHelper( wxScrollHelper *sh ) { m_scrollHelper = sh; }
+ wxScrollHelper *GetScrollHelper() { return m_scrollHelper; }
+
// reset the cached best size value so it will be recalculated the
// next time it is needed.
void InvalidateBestSize();
// the generic centre function - centers the window on parent by`
// default or on screen if it doesn't have parent or
// wxCENTER_ON_SCREEN flag is given
- void Centre( int direction = wxBOTH );
- void Center( int direction = wxBOTH ) { Centre(direction); }
-
- // centre on screen (only works for top level windows)
- void CentreOnScreen(int dir = wxBOTH) { Centre(dir | wxCENTER_ON_SCREEN); }
- void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); }
+ void Centre(int dir = wxBOTH) { DoCentre(dir); }
+ void Center(int dir = wxBOTH) { DoCentre(dir); }
// centre with respect to the the parent window
- void CentreOnParent(int dir = wxBOTH) { Centre(dir | wxCENTER_FRAME); }
+ void CentreOnParent(int dir = wxBOTH) { DoCentre(dir); }
void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); }
// set window size to wrap around its children
virtual bool IsShown() const { return m_isShown; }
virtual bool IsEnabled() const { return m_isEnabled; }
+ // returns true if the window is visible, i.e. IsShown() returns true
+ // if called on it and all its parents up to the first TLW
+ virtual bool IsShownOnScreen() const;
+
// get/set window style (setting style won't update the window and so
// is only useful for internal usage)
virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; }
// click it
virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); }
- // NB: these methods really don't belong here but with the current
- // class hierarchy there is no other place for them :-(
-
- // get the default child of this parent, i.e. the one which is
- // activated by pressing <Enter>
- virtual wxWindow *GetDefaultItem() const { return NULL; }
-
- // set this child as default, return the old default
- virtual wxWindow *SetDefaultItem(wxWindow * WXUNUSED(child))
- { return NULL; }
-
- // set this child as temporary default
- virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { }
-
// navigates in the specified direction by sending a wxNavigationKeyEvent
virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
// thaw the window: redraw it after it had been frozen
virtual void Thaw() { }
+ // return true if window had been frozen and not unthawed yet
+ virtual bool IsFrozen() const { return false; }
+
// adjust DC for drawing on this window
virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { }
+ // return true if the window contents is double buffered by the system
+ virtual bool IsDoubleBuffered() const { return false; }
+
// the update region of the window contains the areas which must be
// repainted by the program
const wxRegion& GetUpdateRegion() const { return m_updateRegion; }
// these functions verify whether the given point/rectangle belongs to
// (or at least intersects with) the update region
- bool IsExposed( int x, int y ) const;
- bool IsExposed( int x, int y, int w, int h ) const;
+ virtual bool DoIsExposed( int x, int y ) const;
+ virtual bool DoIsExposed( int x, int y, int w, int h ) const;
+ bool IsExposed( int x, int y ) const
+ { return DoIsExposed(x, y); }
+ bool IsExposed( int x, int y, int w, int h ) const
+ { return DoIsExposed(x, y, w, h); }
bool IsExposed( const wxPoint& pt ) const
- { return IsExposed(pt.x, pt.y); }
+ { return DoIsExposed(pt.x, pt.y); }
bool IsExposed( const wxRect& rect ) const
- { return IsExposed(rect.x, rect.y, rect.width, rect.height); }
+ { return DoIsExposed(rect.x, rect.y, rect.width, rect.height); }
// colours, fonts and cursors
// --------------------------
{ return DoPopupMenu(menu, x, y); }
#endif // wxUSE_MENUS
+ // override this method to return true for controls having multiple pages
+ virtual bool HasMultiplePages() const { return false; }
+
+
// scrollbars
// ----------
// associate this help text with all windows with the same id as this
// one
void SetHelpTextForId(const wxString& text);
- // get the help string associated with this window (may be empty)
- wxString GetHelpText() const;
-#else
+ // get the help string associated with the given position in this window
+ //
+ // notice that pt may be invalid if event origin is keyboard or unknown
+ // and this method should return the global window help text then
+ virtual wxString GetHelpTextAtPoint(const wxPoint& pt,
+ wxHelpEvent::Origin origin) const;
+ // returns the position-independent help text
+ wxString GetHelpText() const
+ {
+ return GetHelpTextAtPoint(wxDefaultPosition, wxHelpEvent::Origin_Unknown);
+ }
+
+#else // !wxUSE_HELP
// silently ignore SetHelpText() calls
void SetHelpText(const wxString& WXUNUSED(text)) { }
void SetHelpTextForId(const wxString& WXUNUSED(text)) { }
void DeleteRelatedConstraints();
void ResetConstraints();
- // these methods may be overriden for special layout algorithms
+ // these methods may be overridden for special layout algorithms
virtual void SetConstraintSizes(bool recurse = true);
virtual bool LayoutPhase1(int *noChanges);
virtual bool LayoutPhase2(int *noChanges);
wxAccessible* GetOrCreateAccessible() ;
#endif
+
+ // Set window transparency if the platform supports it
+ virtual bool SetTransparent(wxByte WXUNUSED(alpha)) { return false; }
+ virtual bool CanSetTransparent() { return false; }
+
+
// implementation
// --------------
// behaviour in the most common case
virtual bool ShouldInheritColours() const { return false; }
- // Reserved for future use
- virtual void ReservedWindowFunc1() {}
- virtual void ReservedWindowFunc2() {}
- virtual void ReservedWindowFunc3() {}
- virtual void ReservedWindowFunc4() {}
- virtual void ReservedWindowFunc5() {}
- virtual void ReservedWindowFunc6() {}
- virtual void ReservedWindowFunc7() {}
- virtual void ReservedWindowFunc8() {}
- virtual void ReservedWindowFunc9() {}
-
protected:
// event handling specific to wxWindow
virtual bool TryValidator(wxEvent& event);
// Virtual size (scrolling)
wxSize m_virtualSize;
+ wxScrollHelper *m_scrollHelper;
+
int m_minVirtualWidth; // VirtualSizeHints
int m_minVirtualHeight;
int m_maxVirtualWidth;
virtual void DoReleaseMouse() = 0;
// retrieve the position/size of the window
- virtual void DoGetPosition( int *x, int *y ) const = 0;
- virtual void DoGetSize( int *width, int *height ) const = 0;
- virtual void DoGetClientSize( int *width, int *height ) const = 0;
+ virtual void DoGetPosition(int *x, int *y) const = 0;
+ virtual void DoGetScreenPosition(int *x, int *y) const;
+ virtual void DoGetSize(int *width, int *height) const = 0;
+ virtual void DoGetClientSize(int *width, int *height) const = 0;
// get the size which best suits the window: for a control, it would be
// the minimal size which doesn't truncate the control, for a panel - the
// from both DoSetSize() and DoSetClientSize() and would usually just
// reposition this window except for composite controls which will want to
// arrange themselves inside the given rectangle
+ //
+ // Important note: the coordinates passed to this method are in parent's
+ // *window* coordinates and not parent's client coordinates (as the values
+ // passed to DoSetSize and returned by DoGetPosition are)!
virtual void DoMoveWindow(int x, int y, int width, int height) = 0;
+ // centre the window in the specified direction on parent, note that
+ // wxCENTRE_ON_SCREEN shouldn't be specified here, it only makes sense for
+ // TLWs
+ virtual void DoCentre(int dir);
+
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
// implements the window variants
virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
- // Reserved for future use
- void* m_windowReserved;
+ // Must be called when mouse capture is lost to send
+ // wxMouseCaptureLostEvent to windows on capture stack.
+ static void NotifyCaptureLost();
private:
// contains the last id generated by NewControlId
// the stack of windows which have captured the mouse
static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext;
+ // the window that currently has mouse capture
+ static wxWindow *ms_winCaptureCurrent;
+ // indicates if execution is inside CaptureMouse/ReleaseMouse
+ static bool ms_winCaptureChanging;
DECLARE_ABSTRACT_CLASS(wxWindowBase)
DECLARE_NO_COPY_CLASS(wxWindowBase)
#include "wx/msw/window.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/window.h"
-#elif defined(__WXGTK__)
+#elif defined(__WXGTK20__)
#ifdef __WXUNIVERSAL__
#define wxWindowNative wxWindowGTK
#else // !wxUniv
#define wxWindowGTK wxWindow
#endif // wxUniv
#include "wx/gtk/window.h"
+#elif defined(__WXGTK__)
+ #ifdef __WXUNIVERSAL__
+ #define wxWindowNative wxWindowGTK
+ #else // !wxUniv
+ #define wxWindowGTK wxWindow
+ #endif // wxUniv
+ #include "wx/gtk1/window.h"
#elif defined(__WXX11__)
#ifdef __WXUNIVERSAL__
#define wxWindowNative wxWindowX11
#endif // wxUniv
#include "wx/x11/window.h"
#elif defined(__WXMGL__)
- #ifdef __WXUNIVERSAL__
- #define wxWindowNative wxWindowMGL
- #else // !wxUniv
- #define wxWindowMGL wxWindow
- #endif // wxUniv
+ #define wxWindowNative wxWindowMGL
#include "wx/mgl/window.h"
+#elif defined(__WXDFB__)
+ #define wxWindowNative wxWindowDFB
+ #include "wx/dfb/window.h"
#elif defined(__WXMAC__)
#ifdef __WXUNIVERSAL__
#define wxWindowNative wxWindowMac
// get the (first) top level parent window
WXDLLEXPORT wxWindow* wxGetTopLevelParent(wxWindow *win);
-// deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId()
-inline int NewControlId() { return wxWindowBase::NewControlId(); }
+#if WXWIN_COMPATIBILITY_2_6
+ // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId()
+ wxDEPRECATED( int NewControlId() );
+ inline int NewControlId() { return wxWindowBase::NewControlId(); }
+#endif // WXWIN_COMPATIBILITY_2_6
#if wxUSE_ACCESSIBILITY
// ----------------------------------------------------------------------------
// If this object has the focus, child should be 'this'.
virtual wxAccStatus GetFocus(int* childId, wxAccessible** child);
+#if wxUSE_VARIANT
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// or 0 if this object is selected (GetType() == wxT("long")
// - a "void*" pointer to a wxAccessible child object
virtual wxAccStatus GetSelections(wxVariant* selections);
+#endif // wxUSE_VARIANT
};
#endif // wxUSE_ACCESSIBILITY