]>
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 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
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 | 46 | #if wxUSE_EXTENDED_RTTI |
73c36334 JS |
47 | WX_DEFINE_FLAGS( wxPanelStyle ) |
48 | ||
49 | WX_BEGIN_FLAGS( wxPanelStyle ) | |
50 | // new style border flags, we put them first to | |
51 | // use them for streaming out | |
52 | WX_FLAGS_MEMBER(wxBORDER_SIMPLE) | |
53 | WX_FLAGS_MEMBER(wxBORDER_SUNKEN) | |
54 | WX_FLAGS_MEMBER(wxBORDER_DOUBLE) | |
55 | WX_FLAGS_MEMBER(wxBORDER_RAISED) | |
56 | WX_FLAGS_MEMBER(wxBORDER_STATIC) | |
57 | WX_FLAGS_MEMBER(wxBORDER_NONE) | |
58 | ||
59 | // old style border flags | |
60 | WX_FLAGS_MEMBER(wxSIMPLE_BORDER) | |
61 | WX_FLAGS_MEMBER(wxSUNKEN_BORDER) | |
62 | WX_FLAGS_MEMBER(wxDOUBLE_BORDER) | |
63 | WX_FLAGS_MEMBER(wxRAISED_BORDER) | |
64 | WX_FLAGS_MEMBER(wxSTATIC_BORDER) | |
65 | WX_FLAGS_MEMBER(wxNO_BORDER) | |
66 | ||
67 | // standard window styles | |
68 | WX_FLAGS_MEMBER(wxTAB_TRAVERSAL) | |
69 | WX_FLAGS_MEMBER(wxCLIP_CHILDREN) | |
70 | WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
71 | WX_FLAGS_MEMBER(wxWANTS_CHARS) | |
72 | WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE) | |
73 | WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
74 | WX_FLAGS_MEMBER(wxVSCROLL) | |
75 | WX_FLAGS_MEMBER(wxHSCROLL) | |
76 | ||
77 | WX_END_FLAGS( wxPanelStyle ) | |
78 | ||
51596bcb SC |
79 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h") |
80 | ||
81 | WX_BEGIN_PROPERTIES_TABLE(wxPanel) | |
73c36334 | 82 | WX_PROPERTY_FLAGS( WindowStyle , wxPanelStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
066f1b7a | 83 | // style wxTAB_TRAVERSAL |
51596bcb SC |
84 | WX_END_PROPERTIES_TABLE() |
85 | ||
86 | WX_BEGIN_HANDLERS_TABLE(wxPanel) | |
87 | WX_END_HANDLERS_TABLE() | |
88 | ||
5731f7db | 89 | WX_CONSTRUCTOR_5( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
51596bcb SC |
90 | |
91 | #else | |
c801d85f | 92 | IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) |
51596bcb | 93 | #endif |
c801d85f KB |
94 | |
95 | BEGIN_EVENT_TABLE(wxPanel, wxWindow) | |
456bc6d9 VZ |
96 | EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged) |
97 | ||
98 | EVT_SIZE(wxPanel::OnSize) | |
99 | ||
100 | WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) | |
c801d85f KB |
101 | END_EVENT_TABLE() |
102 | ||
d9506e77 VZ |
103 | // ============================================================================ |
104 | // implementation | |
105 | // ============================================================================ | |
106 | ||
6b55490a | 107 | WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel) |
456bc6d9 | 108 | |
d9506e77 VZ |
109 | // ---------------------------------------------------------------------------- |
110 | // wxPanel creation | |
111 | // ---------------------------------------------------------------------------- | |
c801d85f | 112 | |
edccf428 | 113 | void wxPanel::Init() |
c801d85f | 114 | { |
9948d31f | 115 | m_container.SetContainerWindow(this); |
c801d85f KB |
116 | } |
117 | ||
debe6624 | 118 | bool wxPanel::Create(wxWindow *parent, wxWindowID id, |
90c3bdac VZ |
119 | const wxPoint& pos, |
120 | const wxSize& size, | |
121 | long style, | |
122 | const wxString& name) | |
c801d85f | 123 | { |
8bf30fe9 | 124 | return wxWindow::Create(parent, id, pos, size, style, name); |
c801d85f KB |
125 | } |
126 | ||
456bc6d9 VZ |
127 | wxPanel::~wxPanel() |
128 | { | |
456bc6d9 VZ |
129 | } |
130 | ||
19193a2c KB |
131 | void wxPanel::InitDialog() |
132 | { | |
133 | wxInitDialogEvent event(GetId()); | |
134 | event.SetEventObject(this); | |
135 | GetEventHandler()->ProcessEvent(event); | |
136 | } | |
137 | ||
d9506e77 | 138 | // ---------------------------------------------------------------------------- |
c40ce5ce | 139 | // event handlers |
d9506e77 VZ |
140 | // ---------------------------------------------------------------------------- |
141 | ||
c801d85f KB |
142 | // Responds to colour changes, and passes event on to children. |
143 | void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) | |
144 | { | |
a756f210 | 145 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); |
c801d85f KB |
146 | Refresh(); |
147 | ||
148 | // Propagate the event to the non-top-level children | |
149 | wxWindow::OnSysColourChanged(event); | |
150 | } | |
151 | ||
28edd9ef | 152 | void wxPanel::OnSize(wxSizeEvent& event) |
d9506e77 VZ |
153 | { |
154 | #if wxUSE_CONSTRAINTS | |
155 | if (GetAutoLayout()) | |
156 | Layout(); | |
879dcac2 DW |
157 | #if defined(__WXPM__) |
158 | else | |
159 | { | |
2b5f62a0 VZ |
160 | // Need to properly move child windows under OS/2 |
161 | ||
879dcac2 DW |
162 | PSWP pWinSwp = GetSwp(); |
163 | ||
164 | if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0) | |
2b5f62a0 | 165 | { |
879dcac2 | 166 | // Uninitialized |
2b5f62a0 | 167 | |
879dcac2 | 168 | ::WinQueryWindowPos(GetHWND(), pWinSwp); |
2b5f62a0 VZ |
169 | } |
170 | else | |
879dcac2 DW |
171 | { |
172 | SWP vSwp; | |
173 | int nYDiff; | |
174 | ||
175 | ::WinQueryWindowPos(GetHWND(), &vSwp); | |
176 | nYDiff = pWinSwp->cy - vSwp.cy; | |
177 | MoveChildren(nYDiff); | |
178 | pWinSwp->cx = vSwp.cx; | |
179 | pWinSwp->cy = vSwp.cy; | |
180 | } | |
181 | } | |
182 | #endif | |
2b5f62a0 VZ |
183 | #endif // wxUSE_CONSTRAINTS |
184 | ||
28edd9ef | 185 | event.Skip(); |
d9506e77 VZ |
186 | } |
187 |