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