]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
08b97268 | 2 | // Name: src/msw/frame.cpp |
0d53fc34 | 3 | // Purpose: wxFrame |
2bda0e17 KB |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
7c0ea335 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
2bda0e17 KB |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
9f3362c4 | 24 | #pragma hdrstop |
2bda0e17 KB |
25 | #endif |
26 | ||
27 | #ifndef WX_PRECOMP | |
9f3362c4 | 28 | #include "wx/frame.h" |
9f3362c4 | 29 | #include "wx/app.h" |
1e6feb95 | 30 | #include "wx/menu.h" |
9f3362c4 VZ |
31 | #include "wx/utils.h" |
32 | #include "wx/dialog.h" | |
33 | #include "wx/settings.h" | |
34 | #include "wx/dcclient.h" | |
d3cc7c65 | 35 | #include "wx/mdi.h" |
f6bcfd97 | 36 | #include "wx/panel.h" |
9f3362c4 | 37 | #endif // WX_PRECOMP |
2bda0e17 KB |
38 | |
39 | #include "wx/msw/private.h" | |
7c0ea335 | 40 | |
4676948b JS |
41 | #ifdef __WXWINCE__ |
42 | #include <commctrl.h> | |
43 | #endif | |
44 | ||
afafd942 | 45 | #if defined(__POCKETPC__) || defined(__SMARTPHONE__) |
855ec944 VZ |
46 | #include <ole2.h> |
47 | #include <aygshell.h> | |
48 | #include "wx/msw/winundef.h" | |
afafd942 JS |
49 | #endif |
50 | ||
7c0ea335 VZ |
51 | #if wxUSE_STATUSBAR |
52 | #include "wx/statusbr.h" | |
ed791986 | 53 | #include "wx/generic/statusbr.h" |
7c0ea335 VZ |
54 | #endif // wxUSE_STATUSBAR |
55 | ||
56 | #if wxUSE_TOOLBAR | |
57 | #include "wx/toolbar.h" | |
58 | #endif // wxUSE_TOOLBAR | |
59 | ||
2bda0e17 | 60 | #include "wx/menuitem.h" |
6776a0b2 | 61 | #include "wx/log.h" |
2bda0e17 | 62 | |
1e6feb95 VZ |
63 | #ifdef __WXUNIVERSAL__ |
64 | #include "wx/univ/theme.h" | |
65 | #include "wx/univ/colschem.h" | |
66 | #endif // __WXUNIVERSAL__ | |
67 | ||
7c0ea335 VZ |
68 | // ---------------------------------------------------------------------------- |
69 | // globals | |
70 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 71 | |
1e6feb95 | 72 | #if wxUSE_MENUS_NATIVE |
03baf031 | 73 | extern wxMenu *wxCurrentPopupMenu; |
1e6feb95 | 74 | #endif // wxUSE_MENUS_NATIVE |
2bda0e17 | 75 | |
7c0ea335 VZ |
76 | // ---------------------------------------------------------------------------- |
77 | // event tables | |
78 | // ---------------------------------------------------------------------------- | |
79 | ||
0d53fc34 | 80 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
0d53fc34 | 81 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) |
2bda0e17 KB |
82 | END_EVENT_TABLE() |
83 | ||
51596bcb | 84 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
85 | WX_DEFINE_FLAGS( wxFrameStyle ) |
86 | ||
3ff066a4 | 87 | wxBEGIN_FLAGS( wxFrameStyle ) |
bc9fb572 JS |
88 | // new style border flags, we put them first to |
89 | // use them for streaming out | |
3ff066a4 SC |
90 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
91 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
92 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
93 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
94 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
95 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
cbe874bd | 96 | |
bc9fb572 | 97 | // old style border flags |
3ff066a4 SC |
98 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
99 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
100 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
101 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
102 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 103 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
104 | |
105 | // standard window styles | |
3ff066a4 SC |
106 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
107 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
108 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
109 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 110 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
111 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
112 | wxFLAGS_MEMBER(wxVSCROLL) | |
113 | wxFLAGS_MEMBER(wxHSCROLL) | |
bc9fb572 JS |
114 | |
115 | // frame styles | |
3ff066a4 SC |
116 | wxFLAGS_MEMBER(wxSTAY_ON_TOP) |
117 | wxFLAGS_MEMBER(wxCAPTION) | |
118 | wxFLAGS_MEMBER(wxTHICK_FRAME) | |
119 | wxFLAGS_MEMBER(wxSYSTEM_MENU) | |
120 | wxFLAGS_MEMBER(wxRESIZE_BORDER) | |
121 | wxFLAGS_MEMBER(wxRESIZE_BOX) | |
122 | wxFLAGS_MEMBER(wxCLOSE_BOX) | |
123 | wxFLAGS_MEMBER(wxMAXIMIZE_BOX) | |
124 | wxFLAGS_MEMBER(wxMINIMIZE_BOX) | |
bc9fb572 | 125 | |
3ff066a4 SC |
126 | wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW) |
127 | wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT) | |
bc9fb572 | 128 | |
3ff066a4 | 129 | wxFLAGS_MEMBER(wxFRAME_SHAPED) |
bc9fb572 | 130 | |
3ff066a4 | 131 | wxEND_FLAGS( wxFrameStyle ) |
bc9fb572 | 132 | |
51596bcb SC |
133 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") |
134 | ||
3ff066a4 | 135 | wxBEGIN_PROPERTIES_TABLE(wxFrame) |
fb8a56b7 | 136 | wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) |
c5ca409b | 137 | |
3ff066a4 | 138 | wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
af498247 VZ |
139 | wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
140 | wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
3ff066a4 | 141 | wxEND_PROPERTIES_TABLE() |
51596bcb | 142 | |
3ff066a4 SC |
143 | wxBEGIN_HANDLERS_TABLE(wxFrame) |
144 | wxEND_HANDLERS_TABLE() | |
51596bcb | 145 | |
cbe874bd | 146 | wxCONSTRUCTOR_6( wxFrame , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle) |
51596bcb SC |
147 | |
148 | #else | |
58b43418 | 149 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
51596bcb | 150 | #endif |
2bda0e17 | 151 | |
7c0ea335 VZ |
152 | // ============================================================================ |
153 | // implementation | |
154 | // ============================================================================ | |
155 | ||
156 | // ---------------------------------------------------------------------------- | |
157 | // static class members | |
158 | // ---------------------------------------------------------------------------- | |
159 | ||
1e6feb95 VZ |
160 | #if wxUSE_STATUSBAR |
161 | #if wxUSE_NATIVE_STATUSBAR | |
cbe874bd | 162 | bool wxFrame::m_useNativeStatusBar = true; |
1e6feb95 | 163 | #else |
cbe874bd | 164 | bool wxFrame::m_useNativeStatusBar = false; |
1e6feb95 VZ |
165 | #endif |
166 | #endif // wxUSE_NATIVE_STATUSBAR | |
2bda0e17 | 167 | |
7c0ea335 VZ |
168 | // ---------------------------------------------------------------------------- |
169 | // creation/destruction | |
170 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 171 | |
0d53fc34 | 172 | void wxFrame::Init() |
2bda0e17 | 173 | { |
cf8ff92f VZ |
174 | #if wxUSE_MENUS |
175 | m_hMenu = NULL; | |
176 | #endif // wxUSE_MENUS | |
177 | ||
9f3362c4 VZ |
178 | #if wxUSE_TOOLTIPS |
179 | m_hwndToolTip = 0; | |
180 | #endif | |
a2327a9f | 181 | |
cbe874bd | 182 | m_wasMinimized = false; |
7c0ea335 | 183 | } |
9f3362c4 | 184 | |
0d53fc34 | 185 | bool wxFrame::Create(wxWindow *parent, |
7c0ea335 VZ |
186 | wxWindowID id, |
187 | const wxString& title, | |
188 | const wxPoint& pos, | |
189 | const wxSize& size, | |
190 | long style, | |
191 | const wxString& name) | |
192 | { | |
82c9f85c | 193 | if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) |
ef6d716b | 194 | return false; |
d2aef312 | 195 | |
98a02e87 | 196 | SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
b9691677 | 197 | |
aaf803e9 | 198 | #if defined(__SMARTPHONE__) |
ef6d716b WS |
199 | SetLeftMenu(wxID_EXIT, _("Done")); |
200 | #endif | |
201 | ||
855ec944 | 202 | #if wxUSE_ACCEL && defined(__POCKETPC__) |
aaf803e9 JS |
203 | // The guidelines state that Ctrl+Q should quit the app. |
204 | // Let's define an accelerator table to send wxID_EXIT. | |
205 | wxAcceleratorEntry entries[1]; | |
206 | entries[0].Set(wxACCEL_CTRL, 'Q', wxID_EXIT); | |
207 | wxAcceleratorTable accel(1, entries); | |
208 | SetAcceleratorTable(accel); | |
855ec944 | 209 | #endif // wxUSE_ACCEL && __POCKETPC__ |
aaf803e9 | 210 | |
ef6d716b | 211 | return true; |
2bda0e17 KB |
212 | } |
213 | ||
0d53fc34 | 214 | wxFrame::~wxFrame() |
2bda0e17 | 215 | { |
cbe874bd | 216 | m_isBeingDeleted = true; |
82c9f85c | 217 | DeleteAllBars(); |
2bda0e17 KB |
218 | } |
219 | ||
d4597e13 VZ |
220 | // ---------------------------------------------------------------------------- |
221 | // wxFrame client size calculations | |
222 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 223 | |
0d53fc34 | 224 | void wxFrame::DoSetClientSize(int width, int height) |
2bda0e17 | 225 | { |
82c9f85c | 226 | // leave enough space for the status bar if we have (and show) it |
7c0ea335 | 227 | #if wxUSE_STATUSBAR |
8d8bd249 VZ |
228 | wxStatusBar *statbar = GetStatusBar(); |
229 | if ( statbar && statbar->IsShown() ) | |
230 | { | |
8d8bd249 VZ |
231 | height += statbar->GetSize().y; |
232 | } | |
7c0ea335 | 233 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 234 | |
68d02db3 VZ |
235 | // call GetClientAreaOrigin() to take the toolbar into account |
236 | wxPoint pt = GetClientAreaOrigin(); | |
237 | width += pt.x; | |
238 | height += pt.y; | |
239 | ||
82c9f85c | 240 | wxTopLevelWindow::DoSetClientSize(width, height); |
2bda0e17 KB |
241 | } |
242 | ||
d4597e13 VZ |
243 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. |
244 | void wxFrame::DoGetClientSize(int *x, int *y) const | |
245 | { | |
246 | wxTopLevelWindow::DoGetClientSize(x, y); | |
247 | ||
68d02db3 VZ |
248 | // account for the possible toolbar |
249 | wxPoint pt = GetClientAreaOrigin(); | |
250 | if ( x ) | |
251 | *x -= pt.x; | |
252 | ||
253 | if ( y ) | |
254 | *y -= pt.y; | |
255 | ||
d4597e13 VZ |
256 | #if wxUSE_STATUSBAR |
257 | // adjust client area height to take the status bar into account | |
258 | if ( y ) | |
259 | { | |
260 | wxStatusBar *statbar = GetStatusBar(); | |
261 | if ( statbar && statbar->IsShown() ) | |
262 | { | |
263 | *y -= statbar->GetClientSize().y; | |
264 | } | |
265 | } | |
266 | #endif // wxUSE_STATUSBAR | |
267 | } | |
268 | ||
7c0ea335 | 269 | // ---------------------------------------------------------------------------- |
0d53fc34 | 270 | // wxFrame: various geometry-related functions |
7c0ea335 VZ |
271 | // ---------------------------------------------------------------------------- |
272 | ||
0d53fc34 | 273 | void wxFrame::Raise() |
c48926e1 | 274 | { |
c48926e1 | 275 | ::SetForegroundWindow(GetHwnd()); |
c48926e1 VZ |
276 | } |
277 | ||
67bd5bad | 278 | // generate an artificial resize event |
0d53fc34 | 279 | void wxFrame::SendSizeEvent() |
67bd5bad | 280 | { |
67bd5bad GT |
281 | if ( !m_iconized ) |
282 | { | |
82c9f85c VZ |
283 | RECT r = wxGetWindowRect(GetHwnd()); |
284 | ||
67bd5bad GT |
285 | (void)::PostMessage(GetHwnd(), WM_SIZE, |
286 | IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED, | |
287 | MAKELPARAM(r.right - r.left, r.bottom - r.top)); | |
288 | } | |
289 | } | |
290 | ||
d427503c | 291 | #if wxUSE_STATUSBAR |
0d53fc34 | 292 | wxStatusBar *wxFrame::OnCreateStatusBar(int number, |
7c0ea335 VZ |
293 | long style, |
294 | wxWindowID id, | |
295 | const wxString& name) | |
2bda0e17 | 296 | { |
5cb598ae | 297 | wxStatusBar *statusBar wxDUMMY_INITIALIZE(NULL); |
2bda0e17 | 298 | |
47d67540 | 299 | #if wxUSE_NATIVE_STATUSBAR |
1f0500b3 | 300 | if ( !UsesNativeStatusBar() ) |
2bda0e17 | 301 | { |
1f0500b3 | 302 | statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style); |
2bda0e17 KB |
303 | } |
304 | else | |
305 | #endif | |
306 | { | |
1f0500b3 VZ |
307 | statusBar = new wxStatusBar(this, id, style, name); |
308 | } | |
ed791986 | 309 | |
1f0500b3 | 310 | statusBar->SetFieldsCount(number); |
2bda0e17 | 311 | |
7c0ea335 | 312 | return statusBar; |
2bda0e17 KB |
313 | } |
314 | ||
0d53fc34 | 315 | void wxFrame::PositionStatusBar() |
2bda0e17 | 316 | { |
d4597e13 | 317 | if ( !m_frameStatusBar || !m_frameStatusBar->IsShown() ) |
ed791986 VZ |
318 | return; |
319 | ||
cbc66a27 VZ |
320 | int w, h; |
321 | GetClientSize(&w, &h); | |
322 | int sw, sh; | |
323 | m_frameStatusBar->GetSize(&sw, &sh); | |
324 | ||
325 | // Since we wish the status bar to be directly under the client area, | |
326 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
327 | m_frameStatusBar->SetSize(0, h, w, sh); | |
2bda0e17 | 328 | } |
d427503c | 329 | #endif // wxUSE_STATUSBAR |
2bda0e17 | 330 | |
6522713c | 331 | #if wxUSE_MENUS_NATIVE |
ea9a4296 | 332 | |
0d53fc34 | 333 | void wxFrame::AttachMenuBar(wxMenuBar *menubar) |
2bda0e17 | 334 | { |
3180bc0e | 335 | #if defined(__SMARTPHONE__) && defined(__WXWINCE__) |
fb8a56b7 | 336 | |
ed679e74 WS |
337 | wxMenu *autoMenu = NULL; |
338 | ||
339 | if( menubar->GetMenuCount() == 1 ) | |
340 | { | |
341 | autoMenu = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar->GetMenu(0)); | |
342 | SetRightMenu(wxID_ANY, menubar->GetLabelTop(0), autoMenu); | |
343 | } | |
344 | else | |
fb8a56b7 | 345 | { |
ed679e74 WS |
346 | autoMenu = new wxMenu; |
347 | ||
348 | for( size_t n = 0; n < menubar->GetMenuCount(); n++ ) | |
349 | { | |
350 | wxMenu *item = menubar->GetMenu(n); | |
351 | wxString label = menubar->GetLabelTop(n); | |
352 | wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item); | |
353 | autoMenu->Append(wxID_ANY, label, new_item); | |
354 | } | |
355 | ||
356 | SetRightMenu(wxID_ANY, _("Menu"), autoMenu); | |
fb8a56b7 WS |
357 | } |
358 | ||
fb8a56b7 | 359 | #elif defined(WINCE_WITHOUT_COMMANDBAR) |
a96b4743 JS |
360 | if (!GetToolBar()) |
361 | { | |
a9102b36 | 362 | wxToolMenuBar* toolBar = new wxToolMenuBar(this, wxID_ANY, |
a96b4743 JS |
363 | wxDefaultPosition, wxDefaultSize, |
364 | wxBORDER_NONE | wxTB_HORIZONTAL, | |
af5454a4 | 365 | wxToolBarNameStr, menubar); |
a96b4743 JS |
366 | SetToolBar(toolBar); |
367 | menubar->SetToolBar(toolBar); | |
368 | } | |
fb8a56b7 WS |
369 | // Now adjust size for menu bar |
370 | int menuHeight = 26; | |
371 | ||
372 | //When the main window is created using CW_USEDEFAULT the height of the | |
373 | // is created is not taken into account). So we resize the window after | |
374 | // if a menubar is present | |
375 | { | |
376 | RECT rc; | |
377 | ::GetWindowRect((HWND) GetHWND(), &rc); | |
378 | // adjust for menu / titlebar height | |
379 | rc.bottom -= (2*menuHeight-1); | |
380 | ||
cbe874bd | 381 | ::MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); |
fb8a56b7 | 382 | } |
a96b4743 JS |
383 | #endif |
384 | ||
f008af16 | 385 | wxFrameBase::AttachMenuBar(menubar); |
6beb85c0 | 386 | |
f6bcfd97 | 387 | if ( !menubar ) |
c2dcfdef | 388 | { |
f6bcfd97 BP |
389 | // actually remove the menu from the frame |
390 | m_hMenu = (WXHMENU)0; | |
391 | InternalSetMenuBar(); | |
065de612 | 392 | } |
f6bcfd97 | 393 | else // set new non NULL menu bar |
065de612 | 394 | { |
3d487566 | 395 | #if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR) |
f6bcfd97 | 396 | // Can set a menubar several times. |
f6bcfd97 BP |
397 | if ( menubar->GetHMenu() ) |
398 | { | |
399 | m_hMenu = menubar->GetHMenu(); | |
400 | } | |
f008af16 | 401 | else // no HMENU yet |
f6bcfd97 | 402 | { |
f6bcfd97 | 403 | m_hMenu = menubar->Create(); |
065de612 | 404 | |
f6bcfd97 | 405 | if ( !m_hMenu ) |
f008af16 VZ |
406 | { |
407 | wxFAIL_MSG( _T("failed to create menu bar") ); | |
f6bcfd97 | 408 | return; |
f008af16 | 409 | } |
f6bcfd97 | 410 | } |
39d2f9a7 | 411 | #endif |
f6bcfd97 | 412 | InternalSetMenuBar(); |
1e6feb95 | 413 | } |
2bda0e17 KB |
414 | } |
415 | ||
0d53fc34 | 416 | void wxFrame::InternalSetMenuBar() |
2bda0e17 | 417 | { |
a96b4743 | 418 | #if defined(__WXMICROWIN__) || defined(__WXWINCE__) |
4676948b | 419 | // Nothing |
4676948b | 420 | #else |
42e69d6b | 421 | if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) ) |
2bda0e17 | 422 | { |
f6bcfd97 | 423 | wxLogLastError(wxT("SetMenu")); |
2bda0e17 | 424 | } |
04ef50df | 425 | #endif |
2bda0e17 KB |
426 | } |
427 | ||
1e6feb95 VZ |
428 | #endif // wxUSE_MENUS_NATIVE |
429 | ||
2bda0e17 | 430 | // Responds to colour changes, and passes event on to children. |
0d53fc34 | 431 | void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) |
2bda0e17 | 432 | { |
98a02e87 | 433 | SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
2bda0e17 KB |
434 | Refresh(); |
435 | ||
1e6feb95 | 436 | #if wxUSE_STATUSBAR |
2bda0e17 KB |
437 | if ( m_frameStatusBar ) |
438 | { | |
439 | wxSysColourChangedEvent event2; | |
440 | event2.SetEventObject( m_frameStatusBar ); | |
02800301 | 441 | m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); |
2bda0e17 | 442 | } |
1e6feb95 | 443 | #endif // wxUSE_STATUSBAR |
2bda0e17 KB |
444 | |
445 | // Propagate the event to the non-top-level children | |
446 | wxWindow::OnSysColourChanged(event); | |
447 | } | |
448 | ||
cbe874bd | 449 | // Pass true to show full screen, false to restore. |
0d53fc34 | 450 | bool wxFrame::ShowFullScreen(bool show, long style) |
a2327a9f | 451 | { |
b01a88e0 VZ |
452 | // TODO-CE: add support for CE |
453 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) | |
085ad686 | 454 | if ( IsFullScreen() == show ) |
cbe874bd | 455 | return false; |
c641b1d2 | 456 | |
a2327a9f JS |
457 | if (show) |
458 | { | |
b01a88e0 VZ |
459 | // zap the toolbar, menubar, and statusbar if needed |
460 | // | |
461 | // TODO: hide commandbar for WINCE_WITH_COMMANDBAR | |
1e6feb95 | 462 | #if wxUSE_TOOLBAR |
f6bcfd97 | 463 | wxToolBar *theToolBar = GetToolBar(); |
a2327a9f JS |
464 | |
465 | if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar) | |
466 | { | |
b01a88e0 VZ |
467 | if ( theToolBar->IsShown() ) |
468 | { | |
469 | theToolBar->SetSize(wxDefaultCoord,0); | |
470 | theToolBar->Show(false); | |
471 | } | |
472 | else // prevent it from being restored later | |
473 | { | |
474 | style &= ~wxFULLSCREEN_NOTOOLBAR; | |
475 | } | |
a2327a9f | 476 | } |
1e6feb95 | 477 | #endif // wxUSE_TOOLBAR |
a2327a9f JS |
478 | |
479 | if (style & wxFULLSCREEN_NOMENUBAR) | |
480 | SetMenu((HWND)GetHWND(), (HMENU) NULL); | |
481 | ||
1e6feb95 VZ |
482 | #if wxUSE_STATUSBAR |
483 | wxStatusBar *theStatusBar = GetStatusBar(); | |
1e6feb95 | 484 | |
a2327a9f JS |
485 | // Save the number of fields in the statusbar |
486 | if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
487 | { | |
b01a88e0 VZ |
488 | if ( theStatusBar->IsShown() ) |
489 | theStatusBar->Show(false); | |
490 | else | |
491 | style &= ~wxFULLSCREEN_NOSTATUSBAR; | |
a2327a9f | 492 | } |
1e6feb95 | 493 | #endif // wxUSE_STATUSBAR |
a2327a9f | 494 | } |
b01a88e0 | 495 | else // restore to normal |
a2327a9f | 496 | { |
b01a88e0 | 497 | // restore the toolbar, menubar, and statusbar if we had hid them |
1e6feb95 | 498 | #if wxUSE_TOOLBAR |
a2327a9f JS |
499 | wxToolBar *theToolBar = GetToolBar(); |
500 | ||
b01a88e0 | 501 | if ((m_fsStyle & wxFULLSCREEN_NOTOOLBAR) && theToolBar) |
a2327a9f | 502 | { |
cbe874bd | 503 | theToolBar->Show(true); |
a2327a9f | 504 | } |
1e6feb95 | 505 | #endif // wxUSE_TOOLBAR |
a2327a9f | 506 | |
bc88602a JS |
507 | if (m_fsStyle & wxFULLSCREEN_NOMENUBAR) |
508 | { | |
509 | WXHMENU menu = m_hMenu; | |
510 | ||
511 | #if wxUSE_MDI_ARCHITECTURE | |
512 | wxMDIParentFrame *frame = wxDynamicCast(this, wxMDIParentFrame); | |
513 | if (frame) | |
514 | { | |
515 | wxMDIChildFrame *child = frame->GetActiveChild(); | |
516 | if (child) | |
517 | { | |
518 | menu = child->GetWinMenu(); | |
519 | } | |
520 | } | |
521 | #endif // wxUSE_MDI_ARCHITECTURE | |
522 | ||
523 | if (menu) | |
524 | { | |
525 | ::SetMenu(GetHwnd(), (HMENU)menu); | |
526 | } | |
527 | } | |
b01a88e0 | 528 | |
1e6feb95 | 529 | #if wxUSE_STATUSBAR |
b01a88e0 VZ |
530 | wxStatusBar *theStatusBar = GetStatusBar(); |
531 | ||
532 | if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
a2327a9f | 533 | { |
b01a88e0 VZ |
534 | theStatusBar->Show(true); |
535 | PositionStatusBar(); | |
a2327a9f | 536 | } |
1e6feb95 | 537 | #endif // wxUSE_STATUSBAR |
a2327a9f | 538 | } |
b01a88e0 | 539 | #endif // !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
f6bcfd97 | 540 | |
085ad686 | 541 | return wxFrameBase::ShowFullScreen(show, style); |
2bda0e17 KB |
542 | } |
543 | ||
7c0ea335 VZ |
544 | // ---------------------------------------------------------------------------- |
545 | // tool/status bar stuff | |
546 | // ---------------------------------------------------------------------------- | |
547 | ||
d427503c | 548 | #if wxUSE_TOOLBAR |
7c0ea335 | 549 | |
0d53fc34 | 550 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) |
81d66cf3 | 551 | { |
3d487566 | 552 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
39d2f9a7 JS |
553 | // We may already have a toolbar from calling SetMenuBar. |
554 | if (GetToolBar()) | |
555 | return GetToolBar(); | |
556 | #endif | |
7c0ea335 | 557 | if ( wxFrameBase::CreateToolBar(style, id, name) ) |
81d66cf3 | 558 | { |
81d66cf3 | 559 | PositionToolBar(); |
81d66cf3 | 560 | } |
81d66cf3 | 561 | |
7c0ea335 | 562 | return m_frameToolBar; |
81d66cf3 JS |
563 | } |
564 | ||
0d53fc34 | 565 | void wxFrame::PositionToolBar() |
81d66cf3 | 566 | { |
d4597e13 VZ |
567 | wxToolBar *toolbar = GetToolBar(); |
568 | if ( toolbar && toolbar->IsShown() ) | |
569 | { | |
3d487566 | 570 | #if defined(WINCE_WITHOUT_COMMANDBAR) |
09785dd3 JS |
571 | // We want to do something different in WinCE, because |
572 | // the toolbar should be associated with the commandbar, | |
573 | // and not an independent window. | |
574 | // TODO | |
575 | #else | |
d4597e13 VZ |
576 | // don't call our (or even wxTopLevelWindow) version because we want |
577 | // the real (full) client area size, not excluding the tool/status bar | |
578 | int width, height; | |
579 | wxWindow::DoGetClientSize(&width, &height); | |
81d66cf3 | 580 | |
7c0ea335 | 581 | #if wxUSE_STATUSBAR |
d4597e13 VZ |
582 | wxStatusBar *statbar = GetStatusBar(); |
583 | if ( statbar && statbar->IsShown() ) | |
584 | { | |
585 | height -= statbar->GetClientSize().y; | |
586 | } | |
7c0ea335 | 587 | #endif // wxUSE_STATUSBAR |
81d66cf3 | 588 | |
fb8a56b7 WS |
589 | int x = 0; |
590 | int y = 0; | |
3d487566 | 591 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
592 | // We're using a commandbar - so we have to allow for it. |
593 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) | |
594 | { | |
595 | RECT rect; | |
596 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
597 | y = rect.bottom - rect.top; | |
598 | } | |
45f27284 JS |
599 | #endif |
600 | ||
229de929 | 601 | int tx, ty; |
81d66cf3 | 602 | int tw, th; |
229de929 | 603 | toolbar->GetPosition(&tx, &ty); |
d4597e13 | 604 | toolbar->GetSize(&tw, &th); |
cbe874bd | 605 | |
229de929 JS |
606 | // Adjust |
607 | if (ty < 0 && (-ty == th)) | |
608 | ty = 0; | |
609 | if (tx < 0 && (-tx == tw)) | |
cbe874bd WS |
610 | tx = 0; |
611 | ||
229de929 JS |
612 | int desiredW = tw; |
613 | int desiredH = th; | |
81d66cf3 | 614 | |
d4597e13 | 615 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) |
81d66cf3 | 616 | { |
229de929 | 617 | desiredH = height; |
81d66cf3 JS |
618 | } |
619 | else | |
620 | { | |
229de929 JS |
621 | desiredW = width; |
622 | // if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT ) | |
623 | // desiredW -= 3; | |
cbe874bd | 624 | } |
7c0ea335 | 625 | |
d4597e13 VZ |
626 | // use the 'real' MSW position here, don't offset relativly to the |
627 | // client area origin | |
229de929 JS |
628 | |
629 | // Optimise such that we don't have to always resize the toolbar | |
cbe874bd | 630 | // when the frame changes, otherwise we'll get a lot of flicker. |
5cb598ae WS |
631 | bool heightChanging wxDUMMY_INITIALIZE(true); |
632 | bool widthChanging wxDUMMY_INITIALIZE(true); | |
cbe874bd | 633 | |
229de929 JS |
634 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) |
635 | { | |
636 | // It's OK if the current height is greater than what can be shown. | |
637 | heightChanging = (desiredH > th) ; | |
638 | widthChanging = (desiredW != tw) ; | |
cbe874bd WS |
639 | |
640 | // The next time around, we may not have to set the size | |
229de929 JS |
641 | if (heightChanging) |
642 | desiredH = desiredH + 200; | |
643 | } | |
644 | else | |
645 | { | |
646 | // It's OK if the current width is greater than what can be shown. | |
647 | widthChanging = (desiredW > tw) ; | |
648 | heightChanging = (desiredH != th) ; | |
649 | ||
cbe874bd | 650 | // The next time around, we may not have to set the size |
229de929 JS |
651 | if (widthChanging) |
652 | desiredW = desiredW + 200; | |
653 | } | |
cbe874bd | 654 | |
229de929 | 655 | if (tx != 0 || ty != 0 || widthChanging || heightChanging) |
45f27284 | 656 | toolbar->SetSize(x, y, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS); |
cbe874bd | 657 | |
09785dd3 | 658 | #endif // __WXWINCE__ |
81d66cf3 JS |
659 | } |
660 | } | |
d4597e13 | 661 | |
d427503c | 662 | #endif // wxUSE_TOOLBAR |
d2aef312 | 663 | |
7c0ea335 VZ |
664 | // ---------------------------------------------------------------------------- |
665 | // frame state (iconized/maximized/...) | |
666 | // ---------------------------------------------------------------------------- | |
667 | ||
a23fd0e1 VZ |
668 | // propagate our state change to all child frames: this allows us to emulate X |
669 | // Windows behaviour where child frames float independently of the parent one | |
670 | // on the desktop, but are iconized/restored with it | |
0d53fc34 | 671 | void wxFrame::IconizeChildFrames(bool bIconize) |
d2aef312 | 672 | { |
4bc0f25e VZ |
673 | m_iconized = bIconize; |
674 | ||
222ed1d6 | 675 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
a23fd0e1 VZ |
676 | node; |
677 | node = node->GetNext() ) | |
678 | { | |
679 | wxWindow *win = node->GetData(); | |
680 | ||
3ca6a5f0 BP |
681 | // iconizing the frames with this style under Win95 shell puts them at |
682 | // the bottom of the screen (as the MDI children) instead of making | |
683 | // them appear in the taskbar because they are, by virtue of this | |
684 | // style, not managed by the taskbar - instead leave Windows take care | |
685 | // of them | |
686 | #ifdef __WIN95__ | |
687 | if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW ) | |
688 | continue; | |
689 | #endif // Win95 | |
690 | ||
3f7bc32b VZ |
691 | // the child MDI frames are a special case and should not be touched by |
692 | // the parent frame - instead, they are managed by the user | |
2e9f62da | 693 | wxFrame *frame = wxDynamicCast(win, wxFrame); |
1e6feb95 VZ |
694 | if ( frame |
695 | #if wxUSE_MDI_ARCHITECTURE | |
4ab2824c | 696 | && !frame->IsMDIChild() |
1e6feb95 VZ |
697 | #endif // wxUSE_MDI_ARCHITECTURE |
698 | ) | |
a23fd0e1 | 699 | { |
9327c3aa VZ |
700 | // we don't want to restore the child frames which had been |
701 | // iconized even before we were iconized, so save the child frame | |
702 | // status when iconizing the parent frame and check it when | |
703 | // restoring it | |
704 | if ( bIconize ) | |
705 | { | |
9c72ebec | 706 | frame->m_wasMinimized = frame->IsIconized(); |
9327c3aa VZ |
707 | } |
708 | ||
9c72ebec VZ |
709 | // note that we shouldn't touch the hidden frames neither because |
710 | // iconizing/restoring them would show them as a side effect | |
711 | if ( !frame->m_wasMinimized && frame->IsShown() ) | |
9327c3aa | 712 | frame->Iconize(bIconize); |
a23fd0e1 | 713 | } |
d2aef312 | 714 | } |
d2aef312 VZ |
715 | } |
716 | ||
0d53fc34 | 717 | WXHICON wxFrame::GetDefaultIcon() const |
82c9f85c | 718 | { |
94826170 VZ |
719 | // we don't have any standard icons (any more) |
720 | return (WXHICON)0; | |
82c9f85c VZ |
721 | } |
722 | ||
a23fd0e1 | 723 | // =========================================================================== |
42e69d6b | 724 | // message processing |
a23fd0e1 VZ |
725 | // =========================================================================== |
726 | ||
42e69d6b VZ |
727 | // --------------------------------------------------------------------------- |
728 | // preprocessing | |
729 | // --------------------------------------------------------------------------- | |
730 | ||
0d53fc34 | 731 | bool wxFrame::MSWTranslateMessage(WXMSG* pMsg) |
42e69d6b VZ |
732 | { |
733 | if ( wxWindow::MSWTranslateMessage(pMsg) ) | |
cbe874bd | 734 | return true; |
42e69d6b | 735 | |
1e6feb95 | 736 | #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
42e69d6b VZ |
737 | // try the menu bar accels |
738 | wxMenuBar *menuBar = GetMenuBar(); | |
739 | if ( !menuBar ) | |
cbe874bd | 740 | return false; |
42e69d6b VZ |
741 | |
742 | const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); | |
c50f1fb9 | 743 | return acceleratorTable.Translate(this, pMsg); |
1e6feb95 | 744 | #else |
cbe874bd | 745 | return false; |
1e6feb95 | 746 | #endif // wxUSE_MENUS && wxUSE_ACCEL |
42e69d6b VZ |
747 | } |
748 | ||
749 | // --------------------------------------------------------------------------- | |
750 | // our private (non virtual) message handlers | |
751 | // --------------------------------------------------------------------------- | |
752 | ||
0d53fc34 | 753 | bool wxFrame::HandlePaint() |
42e69d6b VZ |
754 | { |
755 | RECT rect; | |
cbe874bd | 756 | if ( ::GetUpdateRect(GetHwnd(), &rect, FALSE) ) |
42e69d6b | 757 | { |
4676948b | 758 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
759 | if ( m_iconized ) |
760 | { | |
f618020a MB |
761 | const wxIcon& icon = GetIcon(); |
762 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
763 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
764 | |
765 | // Hold a pointer to the dc so long as the OnPaint() message | |
766 | // is being processed | |
767 | PAINTSTRUCT ps; | |
768 | HDC hdc = ::BeginPaint(GetHwnd(), &ps); | |
769 | ||
770 | // Erase background before painting or we get white background | |
771 | MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); | |
772 | ||
773 | if ( hIcon ) | |
774 | { | |
775 | RECT rect; | |
776 | ::GetClientRect(GetHwnd(), &rect); | |
777 | ||
778 | // FIXME: why hardcoded? | |
779 | static const int icon_width = 32; | |
780 | static const int icon_height = 32; | |
781 | ||
782 | int icon_x = (int)((rect.right - icon_width)/2); | |
783 | int icon_y = (int)((rect.bottom - icon_height)/2); | |
784 | ||
785 | ::DrawIcon(hdc, icon_x, icon_y, hIcon); | |
786 | } | |
787 | ||
788 | ::EndPaint(GetHwnd(), &ps); | |
789 | ||
cbe874bd | 790 | return true; |
42e69d6b VZ |
791 | } |
792 | else | |
04ef50df | 793 | #endif |
42e69d6b | 794 | { |
5d1d2d46 | 795 | return wxWindow::HandlePaint(); |
42e69d6b VZ |
796 | } |
797 | } | |
798 | else | |
799 | { | |
800 | // nothing to paint - processed | |
cbe874bd | 801 | return true; |
42e69d6b VZ |
802 | } |
803 | } | |
804 | ||
4bc0f25e | 805 | bool wxFrame::HandleSize(int WXUNUSED(x), int WXUNUSED(y), WXUINT id) |
42e69d6b | 806 | { |
4676948b | 807 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
808 | switch ( id ) |
809 | { | |
4bc0f25e VZ |
810 | case SIZE_RESTORED: |
811 | case SIZE_MAXIMIZED: | |
42e69d6b VZ |
812 | // only do it it if we were iconized before, otherwise resizing the |
813 | // parent frame has a curious side effect of bringing it under it's | |
814 | // children | |
815 | if ( !m_iconized ) | |
816 | break; | |
817 | ||
818 | // restore all child frames too | |
cbe874bd | 819 | IconizeChildFrames(false); |
42e69d6b | 820 | |
cbe874bd | 821 | (void)SendIconizeEvent(false); |
42e69d6b VZ |
822 | break; |
823 | ||
4bc0f25e | 824 | case SIZE_MINIMIZED: |
42e69d6b | 825 | // iconize all child frames too |
cbe874bd | 826 | IconizeChildFrames(true); |
42e69d6b VZ |
827 | break; |
828 | } | |
276c8cfb WS |
829 | #else |
830 | wxUnusedVar(id); | |
4bc0f25e | 831 | #endif // !__WXWINCE__ |
42e69d6b VZ |
832 | |
833 | if ( !m_iconized ) | |
834 | { | |
1e6feb95 | 835 | #if wxUSE_STATUSBAR |
42e69d6b | 836 | PositionStatusBar(); |
1e6feb95 VZ |
837 | #endif // wxUSE_STATUSBAR |
838 | ||
839 | #if wxUSE_TOOLBAR | |
42e69d6b | 840 | PositionToolBar(); |
1e6feb95 | 841 | #endif // wxUSE_TOOLBAR |
42e69d6b | 842 | |
3d487566 | 843 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
844 | // Position the menu command bar |
845 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) | |
846 | { | |
847 | RECT rect; | |
848 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
849 | wxSize clientSz = GetClientSize(); | |
850 | ||
851 | if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) ) | |
852 | { | |
853 | wxLogLastError(wxT("MoveWindow")); | |
854 | } | |
855 | ||
856 | } | |
4bc0f25e | 857 | #endif // WINCE_WITH_COMMANDBAR |
42e69d6b VZ |
858 | } |
859 | ||
4bc0f25e VZ |
860 | // call the base class version to generate the appropriate events |
861 | return false; | |
42e69d6b VZ |
862 | } |
863 | ||
0d53fc34 | 864 | bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) |
42e69d6b VZ |
865 | { |
866 | if ( control ) | |
867 | { | |
868 | // In case it's e.g. a toolbar. | |
869 | wxWindow *win = wxFindWinFromHandle(control); | |
870 | if ( win ) | |
871 | return win->MSWCommand(cmd, id); | |
872 | } | |
873 | ||
874 | // handle here commands from menus and accelerators | |
875 | if ( cmd == 0 || cmd == 1 ) | |
876 | { | |
1e6feb95 | 877 | #if wxUSE_MENUS_NATIVE |
42e69d6b VZ |
878 | if ( wxCurrentPopupMenu ) |
879 | { | |
880 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
881 | wxCurrentPopupMenu = NULL; | |
882 | ||
883 | return popupMenu->MSWCommand(cmd, id); | |
884 | } | |
1e6feb95 | 885 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 886 | |
3180bc0e | 887 | #if defined(__SMARTPHONE__) && defined(__WXWINCE__) |
fb8a56b7 WS |
888 | // handle here commands from Smartphone menu bar |
889 | if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) ) | |
890 | { | |
891 | return true; | |
892 | } | |
3180bc0e | 893 | #endif // __SMARTPHONE__ && __WXWINCE__ |
fb8a56b7 | 894 | |
42e69d6b VZ |
895 | if ( ProcessCommand(id) ) |
896 | { | |
cbe874bd | 897 | return true; |
42e69d6b VZ |
898 | } |
899 | } | |
900 | ||
cbe874bd | 901 | return false; |
42e69d6b VZ |
902 | } |
903 | ||
0d53fc34 | 904 | bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) |
a23fd0e1 VZ |
905 | { |
906 | int item; | |
c219cecc | 907 | if ( flags == 0xFFFF && hMenu == 0 ) |
a23fd0e1 | 908 | { |
c219cecc | 909 | // menu was removed from screen |
a23fd0e1 VZ |
910 | item = -1; |
911 | } | |
04ef50df | 912 | #ifndef __WXMICROWIN__ |
c219cecc | 913 | else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) |
a23fd0e1 VZ |
914 | { |
915 | item = nItem; | |
916 | } | |
04ef50df | 917 | #endif |
a23fd0e1 VZ |
918 | else |
919 | { | |
c219cecc | 920 | // don't give hints for separators (doesn't make sense) nor for the |
f6bcfd97 BP |
921 | // items opening popup menus (they don't have them anyhow) but do clear |
922 | // the status line - otherwise, we would be left with the help message | |
923 | // for the previous item which doesn't apply any more | |
cbe874bd | 924 | DoGiveHelp(wxEmptyString, false); |
f6bcfd97 | 925 | |
cbe874bd | 926 | return false; |
a23fd0e1 VZ |
927 | } |
928 | ||
929 | wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item); | |
ccef86c7 VZ |
930 | event.SetEventObject(this); |
931 | ||
932 | return GetEventHandler()->ProcessEvent(event); | |
933 | } | |
934 | ||
935 | bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup) | |
936 | { | |
937 | // we don't have the menu id here, so we use the id to specify if the event | |
938 | // was from a popup menu or a normal one | |
939 | wxMenuEvent event(evtType, isPopup ? -1 : 0); | |
940 | event.SetEventObject(this); | |
a23fd0e1 VZ |
941 | |
942 | return GetEventHandler()->ProcessEvent(event); | |
943 | } | |
944 | ||
945 | // --------------------------------------------------------------------------- | |
0d53fc34 | 946 | // the window proc for wxFrame |
a23fd0e1 VZ |
947 | // --------------------------------------------------------------------------- |
948 | ||
c140b7e7 | 949 | WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
a23fd0e1 | 950 | { |
c140b7e7 | 951 | WXLRESULT rc = 0; |
cbe874bd | 952 | bool processed = false; |
a23fd0e1 VZ |
953 | |
954 | switch ( message ) | |
955 | { | |
42e69d6b VZ |
956 | case WM_CLOSE: |
957 | // if we can't close, tell the system that we processed the | |
958 | // message - otherwise it would close us | |
959 | processed = !Close(); | |
960 | break; | |
961 | ||
ccef86c7 VZ |
962 | case WM_SIZE: |
963 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
964 | break; | |
965 | ||
42e69d6b VZ |
966 | case WM_COMMAND: |
967 | { | |
968 | WORD id, cmd; | |
969 | WXHWND hwnd; | |
970 | UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, | |
971 | &id, &hwnd, &cmd); | |
972 | ||
973 | processed = HandleCommand(id, cmd, (WXHWND)hwnd); | |
974 | } | |
975 | break; | |
976 | ||
ccef86c7 VZ |
977 | case WM_PAINT: |
978 | processed = HandlePaint(); | |
979 | break; | |
980 | ||
92f1a59c JS |
981 | case WM_INITMENUPOPUP: |
982 | processed = HandleInitMenuPopup((WXHMENU) wParam); | |
983 | break; | |
984 | ||
4676948b | 985 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
a23fd0e1 VZ |
986 | case WM_MENUSELECT: |
987 | { | |
42e69d6b VZ |
988 | WXWORD item, flags; |
989 | WXHMENU hmenu; | |
990 | UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); | |
991 | ||
992 | processed = HandleMenuSelect(item, flags, hmenu); | |
a23fd0e1 VZ |
993 | } |
994 | break; | |
bc92cdf9 | 995 | |
ccef86c7 | 996 | case WM_EXITMENULOOP: |
373a5fb3 | 997 | processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); |
ccef86c7 | 998 | break; |
ccef86c7 | 999 | |
42e69d6b VZ |
1000 | case WM_QUERYDRAGICON: |
1001 | { | |
f618020a MB |
1002 | const wxIcon& icon = GetIcon(); |
1003 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
1004 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
1005 | rc = (long)hIcon; |
1006 | processed = rc != 0; | |
1007 | } | |
1008 | break; | |
ccef86c7 | 1009 | #endif // !__WXMICROWIN__ |
a23fd0e1 VZ |
1010 | } |
1011 | ||
1012 | if ( !processed ) | |
7e25f59e | 1013 | rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); |
a23fd0e1 VZ |
1014 | |
1015 | return rc; | |
1016 | } | |
21802234 | 1017 | |
92f1a59c JS |
1018 | // handle WM_INITMENUPOPUP message |
1019 | bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) | |
e39af974 | 1020 | { |
92f1a59c JS |
1021 | wxMenu* menu = NULL; |
1022 | if (GetMenuBar()) | |
1023 | { | |
1024 | int nCount = GetMenuBar()->GetMenuCount(); | |
1025 | for (int n = 0; n < nCount; n++) | |
1026 | { | |
1027 | if (GetMenuBar()->GetMenu(n)->GetHMenu() == hMenu) | |
1028 | { | |
1029 | menu = GetMenuBar()->GetMenu(n); | |
1030 | break; | |
1031 | } | |
1032 | } | |
1033 | } | |
cbe874bd | 1034 | |
92f1a59c | 1035 | wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu); |
e39af974 JS |
1036 | event.SetEventObject(this); |
1037 | ||
1038 | return GetEventHandler()->ProcessEvent(event); | |
e39af974 | 1039 | } |
a9928e9d JS |
1040 | |
1041 | // ---------------------------------------------------------------------------- | |
1042 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
1043 | // from the client area, so the client area is what's really available for the | |
1044 | // frame contents | |
1045 | // ---------------------------------------------------------------------------- | |
1046 | ||
1047 | // get the origin of the client area in the client coordinates | |
1048 | wxPoint wxFrame::GetClientAreaOrigin() const | |
1049 | { | |
1050 | wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); | |
1051 | ||
1052 | #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ | |
1053 | (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) | |
1054 | wxToolBar *toolbar = GetToolBar(); | |
1055 | if ( toolbar && toolbar->IsShown() ) | |
1056 | { | |
1057 | int w, h; | |
1058 | toolbar->GetSize(&w, &h); | |
1059 | ||
1060 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) | |
1061 | { | |
1062 | pt.x += w; | |
1063 | } | |
1064 | else | |
1065 | { | |
1066 | pt.y += h; | |
1067 | } | |
1068 | } | |
1069 | #endif // wxUSE_TOOLBAR | |
1070 | ||
3d487566 | 1071 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
1072 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) |
1073 | { | |
1074 | RECT rect; | |
1075 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
1076 | pt.y += (rect.bottom - rect.top); | |
1077 | } | |
a9928e9d JS |
1078 | #endif |
1079 | ||
1080 | return pt; | |
1081 | } |