]>
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 | ||
c801d85f KB |
46 | IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) |
47 | ||
48 | BEGIN_EVENT_TABLE(wxPanel, wxWindow) | |
456bc6d9 VZ |
49 | EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged) |
50 | ||
51 | EVT_SIZE(wxPanel::OnSize) | |
52 | ||
53 | WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) | |
c801d85f KB |
54 | END_EVENT_TABLE() |
55 | ||
d9506e77 VZ |
56 | // ============================================================================ |
57 | // implementation | |
58 | // ============================================================================ | |
59 | ||
6b55490a | 60 | WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel) |
456bc6d9 | 61 | |
d9506e77 VZ |
62 | // ---------------------------------------------------------------------------- |
63 | // wxPanel creation | |
64 | // ---------------------------------------------------------------------------- | |
c801d85f | 65 | |
edccf428 | 66 | void wxPanel::Init() |
c801d85f | 67 | { |
9948d31f | 68 | m_container.SetContainerWindow(this); |
c801d85f KB |
69 | } |
70 | ||
debe6624 | 71 | bool wxPanel::Create(wxWindow *parent, wxWindowID id, |
90c3bdac VZ |
72 | const wxPoint& pos, |
73 | const wxSize& size, | |
74 | long style, | |
75 | const wxString& name) | |
c801d85f | 76 | { |
8bf30fe9 | 77 | return wxWindow::Create(parent, id, pos, size, style, name); |
c801d85f KB |
78 | } |
79 | ||
456bc6d9 VZ |
80 | wxPanel::~wxPanel() |
81 | { | |
456bc6d9 VZ |
82 | } |
83 | ||
19193a2c KB |
84 | void wxPanel::InitDialog() |
85 | { | |
86 | wxInitDialogEvent event(GetId()); | |
87 | event.SetEventObject(this); | |
88 | GetEventHandler()->ProcessEvent(event); | |
89 | } | |
90 | ||
d9506e77 | 91 | // ---------------------------------------------------------------------------- |
c40ce5ce | 92 | // event handlers |
d9506e77 VZ |
93 | // ---------------------------------------------------------------------------- |
94 | ||
c801d85f KB |
95 | // Responds to colour changes, and passes event on to children. |
96 | void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) | |
97 | { | |
a756f210 | 98 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); |
c801d85f KB |
99 | Refresh(); |
100 | ||
101 | // Propagate the event to the non-top-level children | |
102 | wxWindow::OnSysColourChanged(event); | |
103 | } | |
104 | ||
28edd9ef | 105 | void wxPanel::OnSize(wxSizeEvent& event) |
d9506e77 VZ |
106 | { |
107 | #if wxUSE_CONSTRAINTS | |
108 | if (GetAutoLayout()) | |
109 | Layout(); | |
879dcac2 DW |
110 | #if defined(__WXPM__) |
111 | else | |
112 | { | |
2b5f62a0 VZ |
113 | // Need to properly move child windows under OS/2 |
114 | ||
879dcac2 DW |
115 | PSWP pWinSwp = GetSwp(); |
116 | ||
117 | if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0) | |
2b5f62a0 | 118 | { |
879dcac2 | 119 | // Uninitialized |
2b5f62a0 | 120 | |
879dcac2 | 121 | ::WinQueryWindowPos(GetHWND(), pWinSwp); |
2b5f62a0 VZ |
122 | } |
123 | else | |
879dcac2 DW |
124 | { |
125 | SWP vSwp; | |
126 | int nYDiff; | |
127 | ||
128 | ::WinQueryWindowPos(GetHWND(), &vSwp); | |
129 | nYDiff = pWinSwp->cy - vSwp.cy; | |
130 | MoveChildren(nYDiff); | |
131 | pWinSwp->cx = vSwp.cx; | |
132 | pWinSwp->cy = vSwp.cy; | |
133 | } | |
134 | } | |
135 | #endif | |
2b5f62a0 VZ |
136 | #endif // wxUSE_CONSTRAINTS |
137 | ||
28edd9ef | 138 | event.Skip(); |
d9506e77 VZ |
139 | } |
140 |