#define wxHAS_NATIVE_ENABLED_MANAGEMENT
#endif
-// This is defined when the underlying toolkit handles tab traversal natively
-// (currently this only works under GTK+ 2)
-#ifdef __WXGTK20__
- #define wxHAS_NATIVE_TAB_TRAVERSAL
-#endif
-
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxCaret;
-class WXDLLEXPORT wxControl;
-class WXDLLEXPORT wxCursor;
-class WXDLLEXPORT wxDC;
-class WXDLLEXPORT wxDropTarget;
-class WXDLLEXPORT wxItemResource;
-class WXDLLEXPORT wxLayoutConstraints;
-class WXDLLEXPORT wxResourceTable;
-class WXDLLEXPORT wxSizer;
-class WXDLLEXPORT wxToolTip;
-class WXDLLEXPORT wxWindowBase;
-class WXDLLEXPORT wxWindow;
-class WXDLLEXPORT wxScrollHelper;
+class WXDLLIMPEXP_FWD_CORE wxCaret;
+class WXDLLIMPEXP_FWD_CORE wxControl;
+class WXDLLIMPEXP_FWD_CORE wxCursor;
+class WXDLLIMPEXP_FWD_CORE wxDC;
+class WXDLLIMPEXP_FWD_CORE wxDropTarget;
+class WXDLLIMPEXP_FWD_CORE wxItemResource;
+class WXDLLIMPEXP_FWD_CORE wxLayoutConstraints;
+class WXDLLIMPEXP_FWD_CORE wxResourceTable;
+class WXDLLIMPEXP_FWD_CORE wxSizer;
+class WXDLLIMPEXP_FWD_CORE wxToolTip;
+class WXDLLIMPEXP_FWD_CORE wxWindowBase;
+class WXDLLIMPEXP_FWD_CORE wxWindow;
+class WXDLLIMPEXP_FWD_CORE wxScrollHelper;
#if wxUSE_ACCESSIBILITY
-class WXDLLEXPORT wxAccessible;
+class WXDLLIMPEXP_FWD_CORE wxAccessible;
#endif
// ----------------------------------------------------------------------------
#define wxWINDOW_DEFAULT_VARIANT wxT("window-default-variant")
#endif
+// valid values for Show/HideWithEffect()
+enum wxShowEffect
+{
+ wxSHOW_EFFECT_ROLL,
+ wxSHOW_EFFECT_SLIDE,
+ wxSHOW_EFFECT_BLEND,
+ wxSHOW_EFFECT_EXPAND,
+ wxSHOW_EFFECT_MAX
+};
+
// ----------------------------------------------------------------------------
// (pseudo)template list classes
// ----------------------------------------------------------------------------
wxWindowVariant GetWindowVariant() const { return m_windowVariant; }
- // window id uniquely identifies the window among its siblings unless
- // it is wxID_ANY which means "don't care"
- 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
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; }
- // get the id of the control following the one with the given
- // (autogenerated) id
- static int NextControlId(int winid) { return winid - 1; }
- // get the id of the control preceding the one with the given
- // (autogenerated) id
- static int PrevControlId(int winid) { return winid + 1; }
+
+ // window id uniquely identifies the window among its siblings unless
+ // it is wxID_ANY which means "don't care"
+ void SetId( wxWindowID winid ) { m_windowId = winid; }
+ wxWindowID GetId() const { return m_windowId; }
+
+ // returns true if this id value belong to the range reserved for the
+ // auto-generated (by NewControlId()) ids (they're always negative)
+ static bool IsAutoGeneratedId(wxWindowID id);
+
+ // generate a unique id (or count of them consecutively), returns a
+ // valid id in IsAutoGeneratedId() range or wxID_NONE if failed
+ static wxWindowID NewControlId(int count = 1);
+
+ // mark an id previously returned by NewControlId() as being unused any
+ // more so that it can be reused again for another control later
+ static void ReleaseControlId(wxWindowID id);
+
// moving/resizing
// ---------------
const wxSize& incSize=wxDefaultSize)
{ DoSetSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y, incSize.x, incSize.y); }
- virtual void DoSetSizeHints( int minW, int minH,
- int maxW, int maxH,
- int incW, int incH );
-
// Methods for setting virtual size hints
// FIXME: What are virtual size hints?
// components of the result respectively
virtual wxSize GetWindowBorderSize() const;
+ // wxSizer and friends use this to give a chance to a component to recalc
+ // its min size once one of the final size components is known. Override
+ // this function when that is useful (such as for wxStaticText which can
+ // stretch over several lines). Parameter availableOtherDir
+ // tells the item how much more space there is available in the opposite
+ // direction (-1 if unknown).
+ virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
+ { return false; }
// window state
// ------------
virtual bool Show( bool show = true );
bool Hide() { return Show(false); }
+ // show or hide the window with a special effect, not implemented on
+ // most platforms (where it is the same as Show()/Hide() respectively)
+ //
+ // timeout specifies how long the animation should take, in ms, the
+ // default value of 0 means to use the default (system-dependent) value
+ //
+ // direction is only used with wxSHOW_EFFECT_ROLL and SLIDE values
+ virtual bool ShowWithEffect(wxShowEffect effect,
+ unsigned timeout = 0,
+ wxDirection dir = wxBOTTOM)
+ {
+ wxUnusedVar(effect);
+ wxUnusedVar(timeout);
+ wxUnusedVar(dir);
+
+ return Show();
+ }
+
+ virtual bool HideWithEffect(wxShowEffect effect,
+ unsigned timeout = 0,
+ wxDirection dir = wxBOTTOM)
+ {
+ wxUnusedVar(effect);
+ wxUnusedVar(timeout);
+ wxUnusedVar(dir);
+
+ return Hide();
+ }
+
// returns true if window was enabled/disabled, false if nothing done
virtual bool Enable( bool enable = true );
bool Disable() { return Enable(false); }
virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
long GetExtraStyle() const { return m_exStyle; }
+ bool HasExtraStyle(int exFlag) const { return (m_exStyle & exFlag) != 0; }
+
// make the window modal (all other windows unresponsive)
virtual void MakeModal(bool modal = true);
// this class clients and take into account the current window state
virtual bool AcceptsFocus() const { return true; }
- // can this window have focus right now?
- bool CanAcceptFocus() const { return AcceptsFocus() && IsShown() && IsEnabled(); }
+ // can this window or one of its children accept focus?
+ //
+ // usually it's the same as AcceptsFocus() but is overridden for
+ // container windows
+ virtual bool AcceptsFocusRecursively() const { return AcceptsFocus(); }
// can this window be given focus by keyboard navigation? if not, the
// only way to give it focus (provided it accepts it at all) is to
// click it
virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); }
+
+ // this is mostly a helper for the various functions using it below
+ bool CanBeFocused() const { return IsShown() && IsEnabled(); }
+
+ // can this window itself have focus?
+ bool IsFocusable() const { return AcceptsFocus() && CanBeFocused(); }
+
+ // can this window have focus right now?
+ //
+ // if this method returns true, it means that calling SetFocus() will
+ // put focus either to this window or one of its children, if you need
+ // to know whether this window accepts focus itself, use IsFocusable()
+ bool CanAcceptFocus() const
+ { return AcceptsFocusRecursively() && CanBeFocused(); }
+
// can this window be assigned focus from keyboard right now?
bool CanAcceptFocusFromKeyboard() const
- { return AcceptsFocusFromKeyboard() && CanAcceptFocus(); }
+ { return AcceptsFocusFromKeyboard() && CanBeFocused(); }
+
+ // call this when the return value of AcceptsFocus() changes
+ virtual void SetCanFocus(bool WXUNUSED(canFocus)) { }
// navigates inside this window
bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward)
// move this window just before/after the specified one in tab order
// (the other window must be our sibling!)
void MoveBeforeInTabOrder(wxWindow *win)
- { DoMoveInTabOrder(win, MoveBefore); }
+ { DoMoveInTabOrder(win, OrderBefore); }
void MoveAfterInTabOrder(wxWindow *win)
- { DoMoveInTabOrder(win, MoveAfter); }
+ { DoMoveInTabOrder(win, OrderAfter); }
// parent/children relations
// needed just for extended runtime
const wxWindowList& GetWindowChildren() const { return GetChildren() ; }
+ // get the window before/after this one in the parents children list,
+ // returns NULL if this is the first/last window
+ wxWindow *GetPrevSibling() const { return DoGetSibling(OrderBefore); }
+ wxWindow *GetNextSibling() const { return DoGetSibling(OrderAfter); }
+
// get the parent or the parent of the parent
wxWindow *GetParent() const { return m_parent; }
inline wxWindow *GetGrandParent() const;
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
+ // returns true if the child is in the client area of the window, i.e. is
+ // not scrollbar, toolbar etc.
+ virtual bool IsClientAreaChild(const wxWindow *WXUNUSED(child)) const
+ { return true; }
+
// looking for windows
// -------------------
// be there)
bool RemoveEventHandler(wxEvtHandler *handler);
+ // Process an event by calling GetEventHandler()->ProcessEvent() and
+ // handling any exceptions thrown by event handlers. It's mostly useful
+ // when processing wx events when called from C code (e.g. in GTK+
+ // callback) when the exception wouldn't correctly propagate to
+ // wxEventLoop.
+ bool HandleWindowEvent(wxEvent& event) const;
+
// validators
// ----------
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
#if wxUSE_MENUS
+ // show popup menu at the given position, generate events for the items
+ // selected in it
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
{ return DoPopupMenu(menu, pos.x, pos.y); }
bool PopupMenu(wxMenu *menu, int x, int y)
{ return DoPopupMenu(menu, x, y); }
+
+ // simply return the id of the selected item or wxID_NONE without
+ // generating any events
+ int GetPopupMenuSelectionFromUser(wxMenu& menu, const wxPoint& pos)
+ { return DoGetPopupMenuSelectionFromUser(menu, pos.x, pos.y); }
+ int GetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
+ { return DoGetPopupMenuSelectionFromUser(menu, x, y); }
#endif // wxUSE_MENUS
// override this method to return true for controls having multiple pages
bool PageUp() { return ScrollPages(-1); }
bool PageDown() { return ScrollPages(1); }
+ // call this to always show one or both scrollbars, even if the window
+ // is big enough to not require them
+ virtual void AlwaysShowScrollbars(bool WXUNUSED(horz) = true,
+ bool WXUNUSED(vert) = true)
+ {
+ }
+
+ // return true if AlwaysShowScrollbars() had been called before for the
+ // corresponding orientation
+ virtual bool IsScrollbarAlwaysShown(int WXUNUSED(orient)) const
+ {
+ return false;
+ }
+
// context-sensitive help
// ----------------------
void SetAccessible(wxAccessible* accessible) ;
// Returns the accessible object.
- wxAccessible* GetAccessible() { return m_accessible; };
+ wxAccessible* GetAccessible() { return m_accessible; }
// Returns the accessible object, creating if necessary.
wxAccessible* GetOrCreateAccessible() ;
// area (normal windows can't, but e.g. menubar or statusbar can):
virtual bool CanBeOutsideClientArea() const { return false; }
+ // returns true if the platform should explicitly apply a theme border. Currently
+ // used only by Windows
+ virtual bool CanApplyThemeBorder() const { return true; }
+
protected:
// event handling specific to wxWindow
virtual bool TryValidator(wxEvent& event);
virtual bool TryParent(wxEvent& event);
- // common part of MoveBefore/AfterInTabOrder()
- enum MoveKind
+ enum WindowOrder
{
- MoveBefore, // insert before the given window
- MoveAfter // insert after the given window
+ OrderBefore, // insert before the given window
+ OrderAfter // insert after the given window
};
- virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
+
+ // common part of GetPrev/NextSibling()
+ wxWindow *DoGetSibling(WindowOrder order) const;
+
+ // common part of MoveBefore/AfterInTabOrder()
+ virtual void DoMoveInTabOrder(wxWindow *win, WindowOrder move);
// implementation of Navigate() and NavigateIn()
virtual bool DoNavigateIn(int flags);
-
#if wxUSE_CONSTRAINTS
// satisfy the constraints for the windows but don't set the window sizes
void SatisfyConstraints();
// Layout() window automatically when its size changes?
bool m_autoLayout:1;
+ // true if we had automatically allocated the id value for this window
+ // (i.e. wxID_ANY had been passed to the ctor)
+ bool m_freeId:1;
+
// window state
bool m_isShown:1;
bool m_isEnabled:1;
// specified) border for the window class
virtual wxBorder GetDefaultBorder() const;
+ // this allows you to implement standard control borders without
+ // repeating the code in different classes that are not derived from
+ // wxControl
+ virtual wxBorder GetDefaultBorderForControl() const { return wxBORDER_THEME; }
+
// Get the default size for the new window if no explicit size given. TLWs
// have their own default size so this is just for non top-level windows.
static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; }
// same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height) = 0;
+ virtual void DoSetSizeHints( int minW, int minH,
+ int maxW, int maxH,
+ int incW, int incH );
+
// move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just
// reposition this window except for composite controls which will want to
// enabled/disabled
void NotifyWindowOnEnableChange(bool enabled);
+#if wxUSE_MENUS
+ // temporary event handler used by GetPopupMenuSelectionFromUser()
+ void InternalOnPopupMenu(wxCommandEvent& event);
- // contains the last id generated by NewControlId
- static int ms_lastControlId;
+ // implementation of the public GetPopupMenuSelectionFromUser() method
+ int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y);
+#endif // wxUSE_MENUS
// the stack of windows which have captured the mouse
- static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext;
+ static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext;
// the window that currently has mouse capture
static wxWindow *ms_winCaptureCurrent;
// indicates if execution is inside CaptureMouse/ReleaseMouse