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