X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a2979ead8d5f5f2023d30d05a3c2d55f7804e24a..3115bfa8a41372ecfd505f22c6a0eb9abc2bc96b:/include/wx/window.h diff --git a/include/wx/window.h b/include/wx/window.h index 91a1ac180d..62396ddcac 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -66,22 +66,22 @@ // 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 // ---------------------------------------------------------------------------- @@ -582,17 +582,35 @@ public: // 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)) { } @@ -641,6 +659,11 @@ public: 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 // ------------------- @@ -965,10 +988,19 @@ public: 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 @@ -1198,6 +1230,9 @@ public: // 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 + virtual bool CanApplyThemeBorder() const { return true; } + protected: // event handling specific to wxWindow virtual bool TryValidator(wxEvent& event); @@ -1358,6 +1393,11 @@ protected: // 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_SUNKEN; } + // 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; } @@ -1466,12 +1506,19 @@ private: // enabled/disabled void NotifyWindowOnEnableChange(bool enabled); +#if wxUSE_MENUS + // temporary event handler used by GetPopupMenuSelectionFromUser() + void InternalOnPopupMenu(wxCommandEvent& event); + + // implementation of the public GetPopupMenuSelectionFromUser() method + int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y); +#endif // wxUSE_MENUS // contains the last id generated by NewControlId static int ms_lastControlId; // 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