containr.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/containr.h
  3. // Purpose: documentation of wxNavigationEnabled<>
  4. // Author: Vadim Zeitlin
  5. // Created: 2011-07-23
  6. // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. /**
  10. A helper class implementing TAB navigation among the window children.
  11. This class contains the functionality needed to correctly implement TAB
  12. navigation among the children of the window. Its exact contents is not
  13. important and is intentionally not documented as the only way to use this
  14. class is to inherit from it instead of inheriting from the usual base class
  15. directly. For example, if some class needs to inherit from wxControl but
  16. contains multiple sub-windows and needs to support keyboard navigation, it
  17. is enough to declare it in the following way:
  18. @code
  19. class MyControlWithSubChildren :
  20. public wxNavigationEnabled<wxControl>
  21. {
  22. public:
  23. // Default constructor is implemented in the same way as always.
  24. MyControlWithSubChildren() { }
  25. // Non-default constructor can't use wxControl ctor any more as
  26. // wxControl is not its direct base class, but it can use Create().
  27. MyControlWithSubChildren(wxWindow *parent, wxWindowID winid)
  28. {
  29. wxControl::Create(parent, winid);
  30. // More creation code...
  31. }
  32. // Everything else as usual ...
  33. };
  34. @endcode
  35. @library{wxcore}
  36. @since 2.9.3
  37. */
  38. template <class W>
  39. class wxNavigationEnabled : public W
  40. {
  41. public:
  42. /// The name of the real base window class that this class derives from.
  43. typedef W BaseWindowClass;
  44. /**
  45. Default constructor.
  46. This class provides only the default constructor as it's not possible,
  47. in general, to provide all the constructors of the real base class
  48. BaseWindowClass.
  49. This is however not usually a problem for wxWindow-derived classes as,
  50. by convention, they always define a Create() method such that calling
  51. it on an object initialized using the default constructor is equivalent
  52. to using a non-default constructor directly. So the classes inheriting
  53. from wxNavigationEnabled<W> should simply call W::Create() in their
  54. constructors.
  55. */
  56. wxNavigationEnabled();
  57. };