]> git.saurik.com Git - wxWidgets.git/blob - src/generic/panelg.cpp
use SetDefaultBackgroundColour() instead of SetBgColour()
[wxWidgets.git] / src / generic / panelg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/panelg.cpp
3 // Purpose: wxPanel and the keyboard handling code
4 // Author: Julian Smart, Robert Roebling, Vadim Zeitlin
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "panelg.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
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"
37 #endif
38
39 #include "wx/containr.h"
40 #include "wx/panel.h"
41
42 // ----------------------------------------------------------------------------
43 // wxWin macros
44 // ----------------------------------------------------------------------------
45
46 #if wxUSE_EXTENDED_RTTI
47 WX_DEFINE_FLAGS( wxPanelStyle )
48
49 wxBEGIN_FLAGS( wxPanelStyle )
50 // new style border flags, we put them first to
51 // use them for streaming out
52 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
53 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
54 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
55 wxFLAGS_MEMBER(wxBORDER_RAISED)
56 wxFLAGS_MEMBER(wxBORDER_STATIC)
57 wxFLAGS_MEMBER(wxBORDER_NONE)
58
59 // old style border flags
60 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
61 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
62 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
63 wxFLAGS_MEMBER(wxRAISED_BORDER)
64 wxFLAGS_MEMBER(wxSTATIC_BORDER)
65 wxFLAGS_MEMBER(wxBORDER)
66
67 // standard window styles
68 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
69 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
70 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
71 wxFLAGS_MEMBER(wxWANTS_CHARS)
72 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
73 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
74 wxFLAGS_MEMBER(wxVSCROLL)
75 wxFLAGS_MEMBER(wxHSCROLL)
76
77 wxEND_FLAGS( wxPanelStyle )
78
79 IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h")
80
81 wxBEGIN_PROPERTIES_TABLE(wxPanel)
82 wxPROPERTY_FLAGS( WindowStyle , wxPanelStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
83 // style wxTAB_TRAVERSAL
84 wxEND_PROPERTIES_TABLE()
85
86 wxBEGIN_HANDLERS_TABLE(wxPanel)
87 wxEND_HANDLERS_TABLE()
88
89 wxCONSTRUCTOR_5( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
90
91 #else
92 IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
93 #endif
94
95 BEGIN_EVENT_TABLE(wxPanel, wxWindow)
96 EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
97
98 EVT_SIZE(wxPanel::OnSize)
99
100 WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel)
101 END_EVENT_TABLE()
102
103 // ============================================================================
104 // implementation
105 // ============================================================================
106
107 WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel)
108
109 // ----------------------------------------------------------------------------
110 // wxPanel creation
111 // ----------------------------------------------------------------------------
112
113 void wxPanel::Init()
114 {
115 m_container.SetContainerWindow(this);
116 }
117
118 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
119 const wxPoint& pos,
120 const wxSize& size,
121 long style,
122 const wxString& name)
123 {
124 if ( !wxWindow::Create(parent, id, pos, size, style, name) )
125 return false;
126
127 #ifdef __WXMSW__
128 // panels don't have the same colour as normal windows under Windows
129 SetDefaultBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
130 #endif // __WXMSW__
131
132 return true;
133 }
134
135 wxPanel::~wxPanel()
136 {
137 }
138
139 void wxPanel::InitDialog()
140 {
141 wxInitDialogEvent event(GetId());
142 event.SetEventObject(this);
143 GetEventHandler()->ProcessEvent(event);
144 }
145
146 // ----------------------------------------------------------------------------
147 // event handlers
148 // ----------------------------------------------------------------------------
149
150 // Responds to colour changes, and passes event on to children.
151 void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event)
152 {
153 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
154 Refresh();
155
156 // Propagate the event to the non-top-level children
157 wxWindow::OnSysColourChanged(event);
158 }
159
160 void wxPanel::OnSize(wxSizeEvent& event)
161 {
162 if (GetAutoLayout())
163 Layout();
164 #if wxUSE_CONSTRAINTS
165 #if defined(__WXPM__)
166 else
167 {
168 // Need to properly move child windows under OS/2
169
170 PSWP pWinSwp = GetSwp();
171
172 if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0)
173 {
174 // Uninitialized
175
176 ::WinQueryWindowPos(GetHWND(), pWinSwp);
177 }
178 else
179 {
180 SWP vSwp;
181 int nYDiff;
182
183 ::WinQueryWindowPos(GetHWND(), &vSwp);
184 nYDiff = pWinSwp->cy - vSwp.cy;
185 MoveChildren(nYDiff);
186 pWinSwp->cx = vSwp.cx;
187 pWinSwp->cy = vSwp.cy;
188 }
189 }
190 #endif
191 #endif // wxUSE_CONSTRAINTS
192
193 event.Skip();
194 }
195