]> git.saurik.com Git - wxWidgets.git/blob - src/generic/panelg.cpp
cleanup - reformat (take 2)
[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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/object.h"
29 #include "wx/font.h"
30 #include "wx/colour.h"
31 #include "wx/settings.h"
32 #include "wx/log.h"
33 #endif
34
35 #include "wx/containr.h"
36 #include "wx/panel.h"
37
38 // ----------------------------------------------------------------------------
39 // wxWin macros
40 // ----------------------------------------------------------------------------
41
42 #if wxUSE_EXTENDED_RTTI
43 WX_DEFINE_FLAGS( wxPanelStyle )
44
45 wxBEGIN_FLAGS( wxPanelStyle )
46 // new style border flags, we put them first to
47 // use them for streaming out
48 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
49 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
50 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
51 wxFLAGS_MEMBER(wxBORDER_RAISED)
52 wxFLAGS_MEMBER(wxBORDER_STATIC)
53 wxFLAGS_MEMBER(wxBORDER_NONE)
54
55 // old style border flags
56 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
57 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
58 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
59 wxFLAGS_MEMBER(wxRAISED_BORDER)
60 wxFLAGS_MEMBER(wxSTATIC_BORDER)
61 wxFLAGS_MEMBER(wxBORDER)
62
63 // standard window styles
64 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
65 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
66 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
67 wxFLAGS_MEMBER(wxWANTS_CHARS)
68 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
69 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
70 wxFLAGS_MEMBER(wxVSCROLL)
71 wxFLAGS_MEMBER(wxHSCROLL)
72
73 wxEND_FLAGS( wxPanelStyle )
74
75 IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h")
76
77 wxBEGIN_PROPERTIES_TABLE(wxPanel)
78 wxPROPERTY_FLAGS( WindowStyle , wxPanelStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
79 // style wxTAB_TRAVERSAL
80 wxEND_PROPERTIES_TABLE()
81
82 wxBEGIN_HANDLERS_TABLE(wxPanel)
83 wxEND_HANDLERS_TABLE()
84
85 wxCONSTRUCTOR_5( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
86
87 #else
88 IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
89 #endif
90
91 BEGIN_EVENT_TABLE(wxPanel, wxWindow)
92 EVT_SIZE(wxPanel::OnSize)
93
94 WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel)
95 END_EVENT_TABLE()
96
97 // ============================================================================
98 // implementation
99 // ============================================================================
100
101 WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel)
102
103 // ----------------------------------------------------------------------------
104 // wxPanel creation
105 // ----------------------------------------------------------------------------
106
107 void wxPanel::Init()
108 {
109 m_container.SetContainerWindow(this);
110 }
111
112 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
113 const wxPoint& pos,
114 const wxSize& size,
115 long style,
116 const wxString& name)
117 {
118 if ( !wxWindow::Create(parent, id, pos, size, style, name) )
119 return false;
120
121 // so that non-solid background renders correctly under GTK+:
122 SetThemeEnabled(true);
123
124 #if defined(__WXWINCE__) && (defined(__POCKETPC__) || defined(__SMARTPHONE__))
125 // Required to get solid control backgrounds under WinCE
126 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
127 #endif
128
129 return true;
130 }
131
132 wxPanel::~wxPanel()
133 {
134 }
135
136 void wxPanel::InitDialog()
137 {
138 wxInitDialogEvent event(GetId());
139 event.SetEventObject(this);
140 GetEventHandler()->ProcessEvent(event);
141 }
142
143 // ----------------------------------------------------------------------------
144 // event handlers
145 // ----------------------------------------------------------------------------
146
147 void wxPanel::OnSize(wxSizeEvent& event)
148 {
149 if (GetAutoLayout())
150 Layout();
151 #if wxUSE_CONSTRAINTS
152 #if defined(__WXPM__) && 0
153 else
154 {
155 // Need to properly move child windows under OS/2
156
157 PSWP pWinSwp = GetSwp();
158
159 if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0)
160 {
161 // Uninitialized
162
163 ::WinQueryWindowPos(GetHWND(), pWinSwp);
164 }
165 else
166 {
167 SWP vSwp;
168 int nYDiff;
169
170 ::WinQueryWindowPos(GetHWND(), &vSwp);
171 nYDiff = pWinSwp->cy - vSwp.cy;
172 MoveChildren(nYDiff);
173 pWinSwp->cx = vSwp.cx;
174 pWinSwp->cy = vSwp.cy;
175 }
176 }
177 #endif
178 #endif // wxUSE_CONSTRAINTS
179
180 event.Skip();
181 }
182