1. corrected (but the fix is ugly) the multiple def button problem
[wxWidgets.git] / include / wx / generic / panelg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: panelg.h
3 // Purpose: wxPanel: similar to wxWindows but is coloured as for a dialog
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_PANEL_H_
13 #define _WX_GENERIC_PANEL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "panelg.h"
17 #endif
18
19 #include "wx/window.h"
20 #include "wx/button.h"
21
22 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
23
24 class WXDLLEXPORT wxPanel : public wxWindow
25 {
26 public:
27 wxPanel() { Init(); }
28
29 // Old-style constructor (no default values for coordinates to avoid
30 // ambiguity with the new one)
31 wxPanel(wxWindow *parent,
32 int x, int y, int width, int height,
33 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
34 const wxString& name = wxPanelNameStr)
35 {
36 Init();
37
38 Create(parent, -1, wxPoint(x, y), wxSize(width, height), style, name);
39 }
40
41 // Constructor
42 wxPanel(wxWindow *parent,
43 wxWindowID id = -1,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
47 const wxString& name = wxPanelNameStr)
48 {
49 Init();
50
51 Create(parent, id, pos, size, style, name);
52 }
53
54 // Pseudo ctor
55 bool Create(wxWindow *parent, wxWindowID id,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
59 const wxString& name = wxPanelNameStr);
60
61 // Sends an OnInitDialog event, which in turns transfers data to
62 // to the dialog via validators.
63 virtual void InitDialog();
64
65 // a default button is activated when Enter is pressed
66 wxButton *GetDefaultItem() const { return m_btnDefault; }
67 void SetDefaultItem(wxButton *btn) { m_btnDefault = btn; }
68
69 // implementation from now on
70 // --------------------------
71
72 // responds to colour changes
73 void OnSysColourChanged(wxSysColourChangedEvent& event);
74
75 // process a keyboard navigation message (Tab traversal)
76 void OnNavigationKey(wxNavigationKeyEvent& event);
77
78 // set the focus to the first child if we get it
79 void OnFocus(wxFocusEvent& event);
80
81 void OnSize(wxSizeEvent& event);
82
83 // called by wxWindow whenever it gets focus
84 void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
85 wxWindow *GetLastFocus() const { return m_winLastFocused; }
86
87 protected:
88 // common part of all ctors
89 void Init();
90
91 // the child which had the focus last time this panel was activated
92 wxWindow *m_winLastFocused;
93
94 // a default button or NULL
95 wxButton *m_btnDefault;
96
97 private:
98 DECLARE_DYNAMIC_CLASS(wxPanel)
99 DECLARE_EVENT_TABLE()
100 };
101
102 #endif
103 // _WX_GENERIC_PANEL_H_