]>
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 | |
3ca6a5f0 BP |
686 | if ( win->GetWindowStyle() & wxFRAME_TOOL_WINDOW ) |
687 | continue; | |
3ca6a5f0 | 688 | |
3f7bc32b VZ |
689 | // the child MDI frames are a special case and should not be touched by |
690 | // the parent frame - instead, they are managed by the user | |
2e9f62da | 691 | wxFrame *frame = wxDynamicCast(win, wxFrame); |
1e6feb95 VZ |
692 | if ( frame |
693 | #if wxUSE_MDI_ARCHITECTURE | |
4ab2824c | 694 | && !frame->IsMDIChild() |
1e6feb95 VZ |
695 | #endif // wxUSE_MDI_ARCHITECTURE |
696 | ) | |
a23fd0e1 | 697 | { |
9327c3aa VZ |
698 | // we don't want to restore the child frames which had been |
699 | // iconized even before we were iconized, so save the child frame | |
700 | // status when iconizing the parent frame and check it when | |
701 | // restoring it | |
702 | if ( bIconize ) | |
703 | { | |
9c72ebec | 704 | frame->m_wasMinimized = frame->IsIconized(); |
9327c3aa VZ |
705 | } |
706 | ||
9c72ebec VZ |
707 | // note that we shouldn't touch the hidden frames neither because |
708 | // iconizing/restoring them would show them as a side effect | |
709 | if ( !frame->m_wasMinimized && frame->IsShown() ) | |
9327c3aa | 710 | frame->Iconize(bIconize); |
a23fd0e1 | 711 | } |
d2aef312 | 712 | } |
d2aef312 VZ |
713 | } |
714 | ||
0d53fc34 | 715 | WXHICON wxFrame::GetDefaultIcon() const |
82c9f85c | 716 | { |
94826170 VZ |
717 | // we don't have any standard icons (any more) |
718 | return (WXHICON)0; | |
82c9f85c VZ |
719 | } |
720 | ||
a23fd0e1 | 721 | // =========================================================================== |
42e69d6b | 722 | // message processing |
a23fd0e1 VZ |
723 | // =========================================================================== |
724 | ||
42e69d6b VZ |
725 | // --------------------------------------------------------------------------- |
726 | // preprocessing | |
727 | // --------------------------------------------------------------------------- | |
728 | ||
1ac76609 | 729 | bool wxFrame::MSWDoTranslateMessage(wxFrame *frame, WXMSG *pMsg) |
42e69d6b VZ |
730 | { |
731 | if ( wxWindow::MSWTranslateMessage(pMsg) ) | |
cbe874bd | 732 | return true; |
42e69d6b | 733 | |
1e6feb95 | 734 | #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
42e69d6b VZ |
735 | // try the menu bar accels |
736 | wxMenuBar *menuBar = GetMenuBar(); | |
a1a1ca89 VZ |
737 | if ( menuBar ) |
738 | { | |
739 | const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); | |
1ac76609 | 740 | return acceleratorTable.Translate(frame, pMsg); |
a1a1ca89 VZ |
741 | } |
742 | #endif // wxUSE_MENUS && wxUSE_ACCEL | |
42e69d6b | 743 | |
cbe874bd | 744 | return false; |
42e69d6b VZ |
745 | } |
746 | ||
747 | // --------------------------------------------------------------------------- | |
748 | // our private (non virtual) message handlers | |
749 | // --------------------------------------------------------------------------- | |
750 | ||
0d53fc34 | 751 | bool wxFrame::HandlePaint() |
42e69d6b VZ |
752 | { |
753 | RECT rect; | |
cbe874bd | 754 | if ( ::GetUpdateRect(GetHwnd(), &rect, FALSE) ) |
42e69d6b | 755 | { |
4676948b | 756 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
757 | if ( m_iconized ) |
758 | { | |
f618020a MB |
759 | const wxIcon& icon = GetIcon(); |
760 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
761 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
762 | |
763 | // Hold a pointer to the dc so long as the OnPaint() message | |
764 | // is being processed | |
765 | PAINTSTRUCT ps; | |
766 | HDC hdc = ::BeginPaint(GetHwnd(), &ps); | |
767 | ||
768 | // Erase background before painting or we get white background | |
769 | MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); | |
770 | ||
771 | if ( hIcon ) | |
772 | { | |
773 | RECT rect; | |
774 | ::GetClientRect(GetHwnd(), &rect); | |
775 | ||
776 | // FIXME: why hardcoded? | |
777 | static const int icon_width = 32; | |
778 | static const int icon_height = 32; | |
779 | ||
780 | int icon_x = (int)((rect.right - icon_width)/2); | |
781 | int icon_y = (int)((rect.bottom - icon_height)/2); | |
782 | ||
783 | ::DrawIcon(hdc, icon_x, icon_y, hIcon); | |
784 | } | |
785 | ||
786 | ::EndPaint(GetHwnd(), &ps); | |
787 | ||
cbe874bd | 788 | return true; |
42e69d6b VZ |
789 | } |
790 | else | |
04ef50df | 791 | #endif |
42e69d6b | 792 | { |
5d1d2d46 | 793 | return wxWindow::HandlePaint(); |
42e69d6b VZ |
794 | } |
795 | } | |
796 | else | |
797 | { | |
798 | // nothing to paint - processed | |
cbe874bd | 799 | return true; |
42e69d6b VZ |
800 | } |
801 | } | |
802 | ||
4bc0f25e | 803 | bool wxFrame::HandleSize(int WXUNUSED(x), int WXUNUSED(y), WXUINT id) |
42e69d6b | 804 | { |
4676948b | 805 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
42e69d6b VZ |
806 | switch ( id ) |
807 | { | |
4bc0f25e VZ |
808 | case SIZE_RESTORED: |
809 | case SIZE_MAXIMIZED: | |
42e69d6b VZ |
810 | // only do it it if we were iconized before, otherwise resizing the |
811 | // parent frame has a curious side effect of bringing it under it's | |
812 | // children | |
813 | if ( !m_iconized ) | |
814 | break; | |
815 | ||
816 | // restore all child frames too | |
cbe874bd | 817 | IconizeChildFrames(false); |
42e69d6b | 818 | |
cbe874bd | 819 | (void)SendIconizeEvent(false); |
42e69d6b VZ |
820 | break; |
821 | ||
4bc0f25e | 822 | case SIZE_MINIMIZED: |
42e69d6b | 823 | // iconize all child frames too |
cbe874bd | 824 | IconizeChildFrames(true); |
42e69d6b VZ |
825 | break; |
826 | } | |
276c8cfb WS |
827 | #else |
828 | wxUnusedVar(id); | |
4bc0f25e | 829 | #endif // !__WXWINCE__ |
42e69d6b VZ |
830 | |
831 | if ( !m_iconized ) | |
832 | { | |
1e6feb95 | 833 | #if wxUSE_STATUSBAR |
42e69d6b | 834 | PositionStatusBar(); |
1e6feb95 VZ |
835 | #endif // wxUSE_STATUSBAR |
836 | ||
837 | #if wxUSE_TOOLBAR | |
42e69d6b | 838 | PositionToolBar(); |
1e6feb95 | 839 | #endif // wxUSE_TOOLBAR |
42e69d6b | 840 | |
3d487566 | 841 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
842 | // Position the menu command bar |
843 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) | |
844 | { | |
845 | RECT rect; | |
846 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
847 | wxSize clientSz = GetClientSize(); | |
848 | ||
849 | if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) ) | |
850 | { | |
851 | wxLogLastError(wxT("MoveWindow")); | |
852 | } | |
853 | ||
854 | } | |
4bc0f25e | 855 | #endif // WINCE_WITH_COMMANDBAR |
42e69d6b VZ |
856 | } |
857 | ||
4bc0f25e VZ |
858 | // call the base class version to generate the appropriate events |
859 | return false; | |
42e69d6b VZ |
860 | } |
861 | ||
0d53fc34 | 862 | bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) |
42e69d6b VZ |
863 | { |
864 | if ( control ) | |
865 | { | |
866 | // In case it's e.g. a toolbar. | |
867 | wxWindow *win = wxFindWinFromHandle(control); | |
868 | if ( win ) | |
869 | return win->MSWCommand(cmd, id); | |
870 | } | |
871 | ||
872 | // handle here commands from menus and accelerators | |
873 | if ( cmd == 0 || cmd == 1 ) | |
874 | { | |
1e6feb95 | 875 | #if wxUSE_MENUS_NATIVE |
42e69d6b VZ |
876 | if ( wxCurrentPopupMenu ) |
877 | { | |
878 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
879 | wxCurrentPopupMenu = NULL; | |
880 | ||
881 | return popupMenu->MSWCommand(cmd, id); | |
882 | } | |
1e6feb95 | 883 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 884 | |
3180bc0e | 885 | #if defined(__SMARTPHONE__) && defined(__WXWINCE__) |
fb8a56b7 WS |
886 | // handle here commands from Smartphone menu bar |
887 | if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) ) | |
888 | { | |
889 | return true; | |
890 | } | |
3180bc0e | 891 | #endif // __SMARTPHONE__ && __WXWINCE__ |
fb8a56b7 | 892 | |
42e69d6b VZ |
893 | if ( ProcessCommand(id) ) |
894 | { | |
cbe874bd | 895 | return true; |
42e69d6b VZ |
896 | } |
897 | } | |
898 | ||
cbe874bd | 899 | return false; |
42e69d6b VZ |
900 | } |
901 | ||
0d53fc34 | 902 | bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) |
a23fd0e1 VZ |
903 | { |
904 | int item; | |
c219cecc | 905 | if ( flags == 0xFFFF && hMenu == 0 ) |
a23fd0e1 | 906 | { |
c219cecc | 907 | // menu was removed from screen |
a23fd0e1 VZ |
908 | item = -1; |
909 | } | |
04ef50df | 910 | #ifndef __WXMICROWIN__ |
c219cecc | 911 | else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) |
a23fd0e1 VZ |
912 | { |
913 | item = nItem; | |
914 | } | |
04ef50df | 915 | #endif |
a23fd0e1 VZ |
916 | else |
917 | { | |
c219cecc | 918 | // don't give hints for separators (doesn't make sense) nor for the |
f6bcfd97 BP |
919 | // items opening popup menus (they don't have them anyhow) but do clear |
920 | // the status line - otherwise, we would be left with the help message | |
921 | // for the previous item which doesn't apply any more | |
cbe874bd | 922 | DoGiveHelp(wxEmptyString, false); |
f6bcfd97 | 923 | |
cbe874bd | 924 | return false; |
a23fd0e1 VZ |
925 | } |
926 | ||
927 | wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item); | |
ccef86c7 VZ |
928 | event.SetEventObject(this); |
929 | ||
930 | return GetEventHandler()->ProcessEvent(event); | |
931 | } | |
932 | ||
933 | bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup) | |
934 | { | |
935 | // we don't have the menu id here, so we use the id to specify if the event | |
936 | // was from a popup menu or a normal one | |
937 | wxMenuEvent event(evtType, isPopup ? -1 : 0); | |
938 | event.SetEventObject(this); | |
a23fd0e1 VZ |
939 | |
940 | return GetEventHandler()->ProcessEvent(event); | |
941 | } | |
942 | ||
943 | // --------------------------------------------------------------------------- | |
0d53fc34 | 944 | // the window proc for wxFrame |
a23fd0e1 VZ |
945 | // --------------------------------------------------------------------------- |
946 | ||
c140b7e7 | 947 | WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
a23fd0e1 | 948 | { |
c140b7e7 | 949 | WXLRESULT rc = 0; |
cbe874bd | 950 | bool processed = false; |
a23fd0e1 VZ |
951 | |
952 | switch ( message ) | |
953 | { | |
42e69d6b VZ |
954 | case WM_CLOSE: |
955 | // if we can't close, tell the system that we processed the | |
956 | // message - otherwise it would close us | |
957 | processed = !Close(); | |
958 | break; | |
959 | ||
ccef86c7 VZ |
960 | case WM_SIZE: |
961 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
962 | break; | |
963 | ||
42e69d6b VZ |
964 | case WM_COMMAND: |
965 | { | |
966 | WORD id, cmd; | |
967 | WXHWND hwnd; | |
968 | UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, | |
969 | &id, &hwnd, &cmd); | |
970 | ||
971 | processed = HandleCommand(id, cmd, (WXHWND)hwnd); | |
972 | } | |
973 | break; | |
974 | ||
ccef86c7 VZ |
975 | case WM_PAINT: |
976 | processed = HandlePaint(); | |
977 | break; | |
978 | ||
92f1a59c JS |
979 | case WM_INITMENUPOPUP: |
980 | processed = HandleInitMenuPopup((WXHMENU) wParam); | |
981 | break; | |
982 | ||
4676948b | 983 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
a23fd0e1 VZ |
984 | case WM_MENUSELECT: |
985 | { | |
42e69d6b VZ |
986 | WXWORD item, flags; |
987 | WXHMENU hmenu; | |
988 | UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); | |
989 | ||
990 | processed = HandleMenuSelect(item, flags, hmenu); | |
a23fd0e1 VZ |
991 | } |
992 | break; | |
bc92cdf9 | 993 | |
ccef86c7 | 994 | case WM_EXITMENULOOP: |
373a5fb3 | 995 | processed = HandleMenuLoop(wxEVT_MENU_CLOSE, (WXWORD)wParam); |
ccef86c7 | 996 | break; |
ccef86c7 | 997 | |
42e69d6b VZ |
998 | case WM_QUERYDRAGICON: |
999 | { | |
f618020a MB |
1000 | const wxIcon& icon = GetIcon(); |
1001 | HICON hIcon = icon.Ok() ? GetHiconOf(icon) | |
1002 | : (HICON)GetDefaultIcon(); | |
42e69d6b VZ |
1003 | rc = (long)hIcon; |
1004 | processed = rc != 0; | |
1005 | } | |
1006 | break; | |
ccef86c7 | 1007 | #endif // !__WXMICROWIN__ |
a23fd0e1 VZ |
1008 | } |
1009 | ||
1010 | if ( !processed ) | |
7e25f59e | 1011 | rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); |
a23fd0e1 VZ |
1012 | |
1013 | return rc; | |
1014 | } | |
21802234 | 1015 | |
92f1a59c JS |
1016 | // handle WM_INITMENUPOPUP message |
1017 | bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu) | |
e39af974 | 1018 | { |
92f1a59c JS |
1019 | wxMenu* menu = NULL; |
1020 | if (GetMenuBar()) | |
1021 | { | |
1022 | int nCount = GetMenuBar()->GetMenuCount(); | |
1023 | for (int n = 0; n < nCount; n++) | |
1024 | { | |
1025 | if (GetMenuBar()->GetMenu(n)->GetHMenu() == hMenu) | |
1026 | { | |
1027 | menu = GetMenuBar()->GetMenu(n); | |
1028 | break; | |
1029 | } | |
1030 | } | |
1031 | } | |
cbe874bd | 1032 | |
92f1a59c | 1033 | wxMenuEvent event(wxEVT_MENU_OPEN, 0, menu); |
e39af974 JS |
1034 | event.SetEventObject(this); |
1035 | ||
1036 | return GetEventHandler()->ProcessEvent(event); | |
e39af974 | 1037 | } |
a9928e9d JS |
1038 | |
1039 | // ---------------------------------------------------------------------------- | |
1040 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
1041 | // from the client area, so the client area is what's really available for the | |
1042 | // frame contents | |
1043 | // ---------------------------------------------------------------------------- | |
1044 | ||
1045 | // get the origin of the client area in the client coordinates | |
1046 | wxPoint wxFrame::GetClientAreaOrigin() const | |
1047 | { | |
1048 | wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); | |
1049 | ||
1050 | #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \ | |
1051 | (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))) | |
1052 | wxToolBar *toolbar = GetToolBar(); | |
1053 | if ( toolbar && toolbar->IsShown() ) | |
1054 | { | |
1055 | int w, h; | |
1056 | toolbar->GetSize(&w, &h); | |
1057 | ||
1058 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) | |
1059 | { | |
1060 | pt.x += w; | |
1061 | } | |
1062 | else | |
1063 | { | |
1064 | pt.y += h; | |
1065 | } | |
1066 | } | |
1067 | #endif // wxUSE_TOOLBAR | |
1068 | ||
3d487566 | 1069 | #if defined(WINCE_WITH_COMMANDBAR) |
fb8a56b7 WS |
1070 | if (GetMenuBar() && GetMenuBar()->GetCommandBar()) |
1071 | { | |
1072 | RECT rect; | |
1073 | ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); | |
1074 | pt.y += (rect.bottom - rect.top); | |
1075 | } | |
a9928e9d JS |
1076 | #endif |
1077 | ||
1078 | return pt; | |
1079 | } |