]>
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 | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
d9506e77 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
c801d85f KB |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
d9506e77 | 24 | #pragma hdrstop |
c801d85f KB |
25 | #endif |
26 | ||
27 | #ifndef WX_PRECOMP | |
d9506e77 VZ |
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" | |
8e609c82 | 33 | #include "wx/panel.h" |
841f23e1 | 34 | #include "wx/containr.h" |
c801d85f KB |
35 | #endif |
36 | ||
d9506e77 VZ |
37 | // ---------------------------------------------------------------------------- |
38 | // wxWin macros | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
51596bcb | 41 | #if wxUSE_EXTENDED_RTTI |
73c36334 JS |
42 | WX_DEFINE_FLAGS( wxPanelStyle ) |
43 | ||
3ff066a4 | 44 | wxBEGIN_FLAGS( wxPanelStyle ) |
73c36334 JS |
45 | // new style border flags, we put them first to |
46 | // use them for streaming out | |
3ff066a4 SC |
47 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
48 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
49 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
50 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
51 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
52 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
ca65c044 | 53 | |
73c36334 | 54 | // old style border flags |
3ff066a4 SC |
55 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
56 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
57 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
58 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
59 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 60 | wxFLAGS_MEMBER(wxBORDER) |
73c36334 JS |
61 | |
62 | // standard window styles | |
3ff066a4 SC |
63 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
64 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
65 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
66 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 67 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
68 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
69 | wxFLAGS_MEMBER(wxVSCROLL) | |
70 | wxFLAGS_MEMBER(wxHSCROLL) | |
73c36334 | 71 | |
3ff066a4 | 72 | wxEND_FLAGS( wxPanelStyle ) |
73c36334 | 73 | |
51596bcb SC |
74 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxPanel, wxWindow,"wx/panel.h") |
75 | ||
3ff066a4 | 76 | wxBEGIN_PROPERTIES_TABLE(wxPanel) |
af498247 | 77 | wxPROPERTY_FLAGS( WindowStyle , wxPanelStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
066f1b7a | 78 | // style wxTAB_TRAVERSAL |
3ff066a4 | 79 | wxEND_PROPERTIES_TABLE() |
51596bcb | 80 | |
3ff066a4 SC |
81 | wxBEGIN_HANDLERS_TABLE(wxPanel) |
82 | wxEND_HANDLERS_TABLE() | |
51596bcb | 83 | |
ca65c044 | 84 | wxCONSTRUCTOR_5( wxPanel , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
51596bcb SC |
85 | |
86 | #else | |
c801d85f | 87 | IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) |
51596bcb | 88 | #endif |
c801d85f KB |
89 | |
90 | BEGIN_EVENT_TABLE(wxPanel, wxWindow) | |
456bc6d9 VZ |
91 | EVT_SIZE(wxPanel::OnSize) |
92 | ||
93 | WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) | |
c801d85f KB |
94 | END_EVENT_TABLE() |
95 | ||
d9506e77 VZ |
96 | // ============================================================================ |
97 | // implementation | |
98 | // ============================================================================ | |
99 | ||
6b55490a | 100 | WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel) |
456bc6d9 | 101 | |
d9506e77 VZ |
102 | // ---------------------------------------------------------------------------- |
103 | // wxPanel creation | |
104 | // ---------------------------------------------------------------------------- | |
c801d85f | 105 | |
edccf428 | 106 | void wxPanel::Init() |
c801d85f | 107 | { |
9948d31f | 108 | m_container.SetContainerWindow(this); |
c801d85f KB |
109 | } |
110 | ||
debe6624 | 111 | bool wxPanel::Create(wxWindow *parent, wxWindowID id, |
90c3bdac VZ |
112 | const wxPoint& pos, |
113 | const wxSize& size, | |
114 | long style, | |
115 | const wxString& name) | |
c801d85f | 116 | { |
e736b21a VZ |
117 | if ( !wxWindow::Create(parent, id, pos, size, style, name) ) |
118 | return false; | |
119 | ||
fc55f961 VS |
120 | // so that non-solid background renders correctly under GTK+: |
121 | SetThemeEnabled(true); | |
ca65c044 | 122 | |
5497e635 | 123 | #if defined(__WXWINCE__) && (defined(__POCKETPC__) || defined(__SMARTPHONE__)) |
b554cf63 JS |
124 | // Required to get solid control backgrounds under WinCE |
125 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); | |
95b838be JS |
126 | #endif |
127 | ||
e736b21a | 128 | return true; |
c801d85f KB |
129 | } |
130 | ||
456bc6d9 VZ |
131 | wxPanel::~wxPanel() |
132 | { | |
456bc6d9 VZ |
133 | } |
134 | ||
19193a2c KB |
135 | void wxPanel::InitDialog() |
136 | { | |
137 | wxInitDialogEvent event(GetId()); | |
138 | event.SetEventObject(this); | |
139 | GetEventHandler()->ProcessEvent(event); | |
140 | } | |
141 | ||
d9506e77 | 142 | // ---------------------------------------------------------------------------- |
c40ce5ce | 143 | // event handlers |
d9506e77 VZ |
144 | // ---------------------------------------------------------------------------- |
145 | ||
28edd9ef | 146 | void wxPanel::OnSize(wxSizeEvent& event) |
d9506e77 | 147 | { |
d9506e77 VZ |
148 | if (GetAutoLayout()) |
149 | Layout(); | |
987263fe | 150 | #if wxUSE_CONSTRAINTS |
18a1de69 | 151 | #if defined(__WXPM__) && 0 |
879dcac2 DW |
152 | else |
153 | { | |
2b5f62a0 VZ |
154 | // Need to properly move child windows under OS/2 |
155 | ||
879dcac2 DW |
156 | PSWP pWinSwp = GetSwp(); |
157 | ||
158 | if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0) | |
2b5f62a0 | 159 | { |
879dcac2 | 160 | // Uninitialized |
2b5f62a0 | 161 | |
879dcac2 | 162 | ::WinQueryWindowPos(GetHWND(), pWinSwp); |
ca65c044 WS |
163 | } |
164 | else | |
879dcac2 DW |
165 | { |
166 | SWP vSwp; | |
167 | int nYDiff; | |
168 | ||
169 | ::WinQueryWindowPos(GetHWND(), &vSwp); | |
170 | nYDiff = pWinSwp->cy - vSwp.cy; | |
171 | MoveChildren(nYDiff); | |
172 | pWinSwp->cx = vSwp.cx; | |
173 | pWinSwp->cy = vSwp.cy; | |
174 | } | |
175 | } | |
176 | #endif | |
2b5f62a0 VZ |
177 | #endif // wxUSE_CONSTRAINTS |
178 | ||
28edd9ef | 179 | event.Skip(); |
d9506e77 | 180 | } |