]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
f6bcfd97 BP |
2 | // Name: wx/generic/panelg.h |
3 | // Purpose: wxPanel: a container for child controls | |
c801d85f KB |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) | |
678cd6de | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
678cd6de VZ |
12 | #ifndef _WX_GENERIC_PANEL_H_ |
13 | #define _WX_GENERIC_PANEL_H_ | |
c801d85f KB |
14 | |
15 | #ifdef __GNUG__ | |
f6bcfd97 | 16 | #pragma interface "panelg.h" |
c801d85f KB |
17 | #endif |
18 | ||
f6bcfd97 BP |
19 | // ---------------------------------------------------------------------------- |
20 | // headers and forward declarations | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
c801d85f | 23 | #include "wx/window.h" |
f6bcfd97 BP |
24 | |
25 | class WXDLLEXPORT wxButton; | |
c801d85f | 26 | |
908d4516 | 27 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; |
c801d85f | 28 | |
f6bcfd97 BP |
29 | // ---------------------------------------------------------------------------- |
30 | // wxPanel contains other controls and implements TAB traversal between them | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
06b57134 | 33 | class WXDLLEXPORT wxPanel : public wxWindow |
c801d85f | 34 | { |
c801d85f | 35 | public: |
edccf428 | 36 | wxPanel() { Init(); } |
27dc7e21 | 37 | |
341c92a8 VZ |
38 | // Old-style constructor (no default values for coordinates to avoid |
39 | // ambiguity with the new one) | |
40 | wxPanel(wxWindow *parent, | |
41 | int x, int y, int width, int height, | |
42 | long style = wxTAB_TRAVERSAL | wxNO_BORDER, | |
43 | const wxString& name = wxPanelNameStr) | |
44 | { | |
edccf428 VZ |
45 | Init(); |
46 | ||
341c92a8 VZ |
47 | Create(parent, -1, wxPoint(x, y), wxSize(width, height), style, name); |
48 | } | |
27dc7e21 | 49 | |
341c92a8 VZ |
50 | // Constructor |
51 | wxPanel(wxWindow *parent, | |
52 | wxWindowID id = -1, | |
53 | const wxPoint& pos = wxDefaultPosition, | |
54 | const wxSize& size = wxDefaultSize, | |
55 | long style = wxTAB_TRAVERSAL | wxNO_BORDER, | |
56 | const wxString& name = wxPanelNameStr) | |
57 | { | |
d220ae32 VZ |
58 | Init(); |
59 | ||
341c92a8 VZ |
60 | Create(parent, id, pos, size, style, name); |
61 | } | |
c801d85f | 62 | |
341c92a8 VZ |
63 | // Pseudo ctor |
64 | bool Create(wxWindow *parent, wxWindowID id, | |
65 | const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, | |
67 | long style = wxTAB_TRAVERSAL | wxNO_BORDER, | |
68 | const wxString& name = wxPanelNameStr); | |
27dc7e21 | 69 | |
341c92a8 VZ |
70 | // Sends an OnInitDialog event, which in turns transfers data to |
71 | // to the dialog via validators. | |
72 | virtual void InitDialog(); | |
c801d85f | 73 | |
1e6feb95 | 74 | #if wxUSE_BUTTON |
edccf428 VZ |
75 | // a default button is activated when Enter is pressed |
76 | wxButton *GetDefaultItem() const { return m_btnDefault; } | |
77 | void SetDefaultItem(wxButton *btn) { m_btnDefault = btn; } | |
1e6feb95 | 78 | #endif // wxUSE_BUTTON |
edccf428 VZ |
79 | |
80 | // implementation from now on | |
81 | // -------------------------- | |
82 | ||
341c92a8 VZ |
83 | // responds to colour changes |
84 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
27dc7e21 | 85 | |
341c92a8 VZ |
86 | // process a keyboard navigation message (Tab traversal) |
87 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
27dc7e21 | 88 | |
341c92a8 VZ |
89 | // set the focus to the first child if we get it |
90 | void OnFocus(wxFocusEvent& event); | |
c801d85f | 91 | |
3da17724 | 92 | // calls layout for layout constraints and sizers |
27dc7e21 RD |
93 | void OnSize(wxSizeEvent& event); |
94 | ||
3da17724 RR |
95 | // overridden to tab move focus into first focusable child |
96 | virtual void SetFocus(); | |
97 | ||
341c92a8 | 98 | // called by wxWindow whenever it gets focus |
319fefa9 VZ |
99 | void SetLastFocus(wxWindow *win) { m_winLastFocused = win; } |
100 | wxWindow *GetLastFocus() const { return m_winLastFocused; } | |
c801d85f | 101 | |
ada8f807 VS |
102 | virtual void RemoveChild(wxWindowBase *child); |
103 | ||
341c92a8 | 104 | protected: |
edccf428 VZ |
105 | // common part of all ctors |
106 | void Init(); | |
107 | ||
00c4e897 VZ |
108 | // set the focus to the child which had it the last time |
109 | bool SetFocusToChild(); | |
110 | ||
341c92a8 | 111 | // the child which had the focus last time this panel was activated |
319fefa9 | 112 | wxWindow *m_winLastFocused; |
06b57134 | 113 | |
1e6feb95 | 114 | #if wxUSE_BUTTON |
edccf428 VZ |
115 | // a default button or NULL |
116 | wxButton *m_btnDefault; | |
1e6feb95 | 117 | #endif // wxUSE_BUTTON |
edccf428 | 118 | |
06b57134 VZ |
119 | private: |
120 | DECLARE_DYNAMIC_CLASS(wxPanel) | |
121 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
122 | }; |
123 | ||
f6bcfd97 BP |
124 | // this function is for wxWindows use only |
125 | extern bool wxSetFocusToChild(wxWindow *win, wxWindow **child); | |
126 | ||
c801d85f | 127 | #endif |
678cd6de | 128 | // _WX_GENERIC_PANEL_H_ |