]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
d9506e77 VZ |
2 | // Name: src/generic/panelg.cpp |
3 | // Purpose: wxPanel and the keyboard handling code | |
4 | // Author: Julian Smart, Robert Roebling, Vadim Zeitlin | |
c801d85f KB |
5 | // Modified by: |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6aa89a22 JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
d9506e77 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
c801d85f | 20 | #ifdef __GNUG__ |
d9506e77 | 21 | #pragma implementation "panelg.h" |
c801d85f KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
d9506e77 | 28 | #pragma hdrstop |
c801d85f KB |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
d9506e77 VZ |
32 | #include "wx/object.h" |
33 | #include "wx/font.h" | |
34 | #include "wx/colour.h" | |
35 | #include "wx/settings.h" | |
36 | #include "wx/log.h" | |
c801d85f KB |
37 | #endif |
38 | ||
456bc6d9 VZ |
39 | #include "wx/containr.h" |
40 | #include "wx/panel.h" | |
c801d85f | 41 | |
d9506e77 VZ |
42 | // ---------------------------------------------------------------------------- |
43 | // wxWin macros | |
44 | // ---------------------------------------------------------------------------- | |
45 | ||
51596bcb SC |
46 | #if wxUSE_EXTENDED_RTTI |
47 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h") | |
48 | ||
49 | WX_BEGIN_PROPERTIES_TABLE(wxPanel) | |
50 | WX_END_PROPERTIES_TABLE() | |
51 | ||
52 | WX_BEGIN_HANDLERS_TABLE(wxPanel) | |
53 | WX_END_HANDLERS_TABLE() | |
54 | ||
55 | WX_CONSTRUCTOR_4( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) | |
56 | ||
57 | #else | |
c801d85f | 58 | IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) |
51596bcb | 59 | #endif |
c801d85f KB |
60 | |
61 | BEGIN_EVENT_TABLE(wxPanel, wxWindow) | |
456bc6d9 VZ |
62 | EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged) |
63 | ||
64 | EVT_SIZE(wxPanel::OnSize) | |
65 | ||
66 | WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) | |
c801d85f KB |
67 | END_EVENT_TABLE() |
68 | ||
d9506e77 VZ |
69 | // ============================================================================ |
70 | // implementation | |
71 | // ============================================================================ | |
72 | ||
6b55490a | 73 | WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel) |
456bc6d9 | 74 | |
d9506e77 VZ |
75 | // ---------------------------------------------------------------------------- |
76 | // wxPanel creation | |
77 | // ---------------------------------------------------------------------------- | |
c801d85f | 78 | |
edccf428 | 79 | void wxPanel::Init() |
c801d85f | 80 | { |
9948d31f | 81 | m_container.SetContainerWindow(this); |
c801d85f KB |
82 | } |
83 | ||
debe6624 | 84 | bool wxPanel::Create(wxWindow *parent, wxWindowID id, |
90c3bdac VZ |
85 | const wxPoint& pos, |
86 | const wxSize& size, | |
87 | long style, | |
88 | const wxString& name) | |
c801d85f | 89 | { |
8bf30fe9 | 90 | return wxWindow::Create(parent, id, pos, size, style, name); |
c801d85f KB |
91 | } |
92 | ||
456bc6d9 VZ |
93 | wxPanel::~wxPanel() |
94 | { | |
456bc6d9 VZ |
95 | } |
96 | ||
19193a2c KB |
97 | void wxPanel::InitDialog() |
98 | { | |
99 | wxInitDialogEvent event(GetId()); | |
100 | event.SetEventObject(this); | |
101 | GetEventHandler()->ProcessEvent(event); | |
102 | } | |
103 | ||
d9506e77 | 104 | // ---------------------------------------------------------------------------- |
c40ce5ce | 105 | // event handlers |
d9506e77 VZ |
106 | // ---------------------------------------------------------------------------- |
107 | ||
c801d85f KB |
108 | // Responds to colour changes, and passes event on to children. |
109 | void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) | |
110 | { | |
a756f210 | 111 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); |
c801d85f KB |
112 | Refresh(); |
113 | ||
114 | // Propagate the event to the non-top-level children | |
115 | wxWindow::OnSysColourChanged(event); | |
116 | } | |
117 | ||
28edd9ef | 118 | void wxPanel::OnSize(wxSizeEvent& event) |
d9506e77 VZ |
119 | { |
120 | #if wxUSE_CONSTRAINTS | |
121 | if (GetAutoLayout()) | |
122 | Layout(); | |
879dcac2 DW |
123 | #if defined(__WXPM__) |
124 | else | |
125 | { | |
2b5f62a0 VZ |
126 | // Need to properly move child windows under OS/2 |
127 | ||
879dcac2 DW |
128 | PSWP pWinSwp = GetSwp(); |
129 | ||
130 | if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0) | |
2b5f62a0 | 131 | { |
879dcac2 | 132 | // Uninitialized |
2b5f62a0 | 133 | |
879dcac2 | 134 | ::WinQueryWindowPos(GetHWND(), pWinSwp); |
2b5f62a0 VZ |
135 | } |
136 | else | |
879dcac2 DW |
137 | { |
138 | SWP vSwp; | |
139 | int nYDiff; | |
140 | ||
141 | ::WinQueryWindowPos(GetHWND(), &vSwp); | |
142 | nYDiff = pWinSwp->cy - vSwp.cy; | |
143 | MoveChildren(nYDiff); | |
144 | pWinSwp->cx = vSwp.cx; | |
145 | pWinSwp->cy = vSwp.cy; | |
146 | } | |
147 | } | |
148 | #endif | |
2b5f62a0 VZ |
149 | #endif // wxUSE_CONSTRAINTS |
150 | ||
28edd9ef | 151 | event.Skip(); |
d9506e77 VZ |
152 | } |
153 |