1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
32 #include "wx/dialog.h"
33 #include "wx/settings.h"
34 #include "wx/dcclient.h"
39 #include "wx/msw/private.h"
45 #if defined(__POCKETPC__) || defined(__SMARTPHONE__)
48 #include "wx/msw/winundef.h"
52 #include "wx/statusbr.h"
53 #include "wx/generic/statusbr.h"
54 #endif // wxUSE_STATUSBAR
57 #include "wx/toolbar.h"
58 #endif // wxUSE_TOOLBAR
60 #include "wx/menuitem.h"
63 #ifdef __WXUNIVERSAL__
64 #include "wx/univ/theme.h"
65 #include "wx/univ/colschem.h"
66 #endif // __WXUNIVERSAL__
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 #if wxUSE_MENUS_NATIVE
73 extern wxMenu
*wxCurrentPopupMenu
;
74 #endif // wxUSE_MENUS_NATIVE
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
81 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
84 #if wxUSE_EXTENDED_RTTI
85 WX_DEFINE_FLAGS( wxFrameStyle
)
87 wxBEGIN_FLAGS( wxFrameStyle
)
88 // new style border flags, we put them first to
89 // use them for streaming out
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
)
97 // old style border flags
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
)
103 wxFLAGS_MEMBER(wxBORDER
)
105 // standard window styles
106 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
107 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
108 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
109 wxFLAGS_MEMBER(wxWANTS_CHARS
)
110 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
111 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
112 wxFLAGS_MEMBER(wxVSCROLL
)
113 wxFLAGS_MEMBER(wxHSCROLL
)
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
)
126 wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
)
127 wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
)
129 wxFLAGS_MEMBER(wxFRAME_SHAPED
)
131 wxEND_FLAGS( wxFrameStyle
)
133 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h")
135 wxBEGIN_PROPERTIES_TABLE(wxFrame
)
136 wxEVENT_PROPERTY( Menu
, wxEVT_COMMAND_MENU_SELECTED
, wxCommandEvent
)
138 wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
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"))
141 wxEND_PROPERTIES_TABLE()
143 wxBEGIN_HANDLERS_TABLE(wxFrame
)
144 wxEND_HANDLERS_TABLE()
146 wxCONSTRUCTOR_6( wxFrame
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Title
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
149 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
152 // ============================================================================
154 // ============================================================================
156 // ----------------------------------------------------------------------------
157 // static class members
158 // ----------------------------------------------------------------------------
161 #if wxUSE_NATIVE_STATUSBAR
162 bool wxFrame::m_useNativeStatusBar
= true;
164 bool wxFrame::m_useNativeStatusBar
= false;
166 #endif // wxUSE_NATIVE_STATUSBAR
168 // ----------------------------------------------------------------------------
169 // creation/destruction
170 // ----------------------------------------------------------------------------
176 #endif // wxUSE_MENUS
182 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
183 SHACTIVATEINFO
* info
= new SHACTIVATEINFO
;
184 memset(info
, 0, sizeof(SHACTIVATEINFO
));
185 info
->cbSize
= sizeof(SHACTIVATEINFO
);
187 m_activateInfo
= (void*) info
;
190 m_wasMinimized
= false;
193 bool wxFrame::Create(wxWindow
*parent
,
195 const wxString
& title
,
199 const wxString
& name
)
201 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
204 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
206 #if defined(__SMARTPHONE__)
207 SetLeftMenu(wxID_EXIT
, _("Done"));
210 #if wxUSE_ACCEL && defined(__POCKETPC__)
211 // The guidelines state that Ctrl+Q should quit the app.
212 // Let's define an accelerator table to send wxID_EXIT.
213 wxAcceleratorEntry entries
[1];
214 entries
[0].Set(wxACCEL_CTRL
, 'Q', wxID_EXIT
);
215 wxAcceleratorTable
accel(1, entries
);
216 SetAcceleratorTable(accel
);
217 #endif // wxUSE_ACCEL && __POCKETPC__
224 m_isBeingDeleted
= true;
227 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
228 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
230 m_activateInfo
= NULL
;
234 // ----------------------------------------------------------------------------
235 // wxFrame client size calculations
236 // ----------------------------------------------------------------------------
238 void wxFrame::DoSetClientSize(int width
, int height
)
240 // leave enough space for the status bar if we have (and show) it
242 wxStatusBar
*statbar
= GetStatusBar();
243 if ( statbar
&& statbar
->IsShown() )
245 height
+= statbar
->GetSize().y
;
247 #endif // wxUSE_STATUSBAR
249 // call GetClientAreaOrigin() to take the toolbar into account
250 wxPoint pt
= GetClientAreaOrigin();
254 wxTopLevelWindow::DoSetClientSize(width
, height
);
257 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
258 void wxFrame::DoGetClientSize(int *x
, int *y
) const
260 wxTopLevelWindow::DoGetClientSize(x
, y
);
262 // account for the possible toolbar
263 wxPoint pt
= GetClientAreaOrigin();
271 // adjust client area height to take the status bar into account
274 wxStatusBar
*statbar
= GetStatusBar();
275 if ( statbar
&& statbar
->IsShown() )
277 *y
-= statbar
->GetClientSize().y
;
280 #endif // wxUSE_STATUSBAR
283 // ----------------------------------------------------------------------------
284 // wxFrame: various geometry-related functions
285 // ----------------------------------------------------------------------------
287 void wxFrame::Raise()
289 ::SetForegroundWindow(GetHwnd());
292 // generate an artificial resize event
293 void wxFrame::SendSizeEvent()
297 RECT r
= wxGetWindowRect(GetHwnd());
299 (void)::PostMessage(GetHwnd(), WM_SIZE
,
300 IsMaximized() ? SIZE_MAXIMIZED
: SIZE_RESTORED
,
301 MAKELPARAM(r
.right
- r
.left
, r
.bottom
- r
.top
));
306 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
,
309 const wxString
& name
)
311 wxStatusBar
*statusBar
wxDUMMY_INITIALIZE(NULL
);
313 #if wxUSE_NATIVE_STATUSBAR
314 if ( !UsesNativeStatusBar() )
316 statusBar
= (wxStatusBar
*)new wxStatusBarGeneric(this, id
, style
);
321 statusBar
= new wxStatusBar(this, id
, style
, name
);
324 statusBar
->SetFieldsCount(number
);
329 void wxFrame::PositionStatusBar()
331 if ( !m_frameStatusBar
|| !m_frameStatusBar
->IsShown() )
335 GetClientSize(&w
, &h
);
337 m_frameStatusBar
->GetSize(&sw
, &sh
);
339 // Since we wish the status bar to be directly under the client area,
340 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
341 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
343 #endif // wxUSE_STATUSBAR
345 #if wxUSE_MENUS_NATIVE
347 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
349 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
351 wxMenu
*autoMenu
= NULL
;
353 if( menubar
->GetMenuCount() == 1 )
355 autoMenu
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar
->GetMenu(0));
356 SetRightMenu(wxID_ANY
, menubar
->GetLabelTop(0), autoMenu
);
360 autoMenu
= new wxMenu
;
362 for( size_t n
= 0; n
< menubar
->GetMenuCount(); n
++ )
364 wxMenu
*item
= menubar
->GetMenu(n
);
365 wxString label
= menubar
->GetLabelTop(n
);
366 wxMenu
*new_item
= wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item
);
367 autoMenu
->Append(wxID_ANY
, label
, new_item
);
370 SetRightMenu(wxID_ANY
, _("Menu"), autoMenu
);
373 #elif defined(WINCE_WITHOUT_COMMANDBAR)
376 wxToolMenuBar
* toolBar
= new wxToolMenuBar(this, wxID_ANY
,
377 wxDefaultPosition
, wxDefaultSize
,
378 wxBORDER_NONE
| wxTB_HORIZONTAL
,
379 wxToolBarNameStr
, menubar
);
381 menubar
->SetToolBar(toolBar
);
383 // Now adjust size for menu bar
386 //When the main window is created using CW_USEDEFAULT the height of the
387 // is created is not taken into account). So we resize the window after
388 // if a menubar is present
391 ::GetWindowRect((HWND
) GetHWND(), &rc
);
392 // adjust for menu / titlebar height
393 rc
.bottom
-= (2*menuHeight
-1);
395 ::MoveWindow((HWND
) GetHWND(), rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
);
399 wxFrameBase::AttachMenuBar(menubar
);
403 // actually remove the menu from the frame
404 m_hMenu
= (WXHMENU
)0;
405 InternalSetMenuBar();
407 else // set new non NULL menu bar
409 #if !defined(__WXWINCE__) || defined(WINCE_WITH_COMMANDBAR)
410 // Can set a menubar several times.
411 if ( menubar
->GetHMenu() )
413 m_hMenu
= menubar
->GetHMenu();
417 m_hMenu
= menubar
->Create();
421 wxFAIL_MSG( _T("failed to create menu bar") );
426 InternalSetMenuBar();
430 void wxFrame::InternalSetMenuBar()
432 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
435 if ( !::SetMenu(GetHwnd(), (HMENU
)m_hMenu
) )
437 wxLogLastError(wxT("SetMenu"));
442 #endif // wxUSE_MENUS_NATIVE
444 // Responds to colour changes, and passes event on to children.
445 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
447 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
451 if ( m_frameStatusBar
)
453 wxSysColourChangedEvent event2
;
454 event2
.SetEventObject( m_frameStatusBar
);
455 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
457 #endif // wxUSE_STATUSBAR
459 // Propagate the event to the non-top-level children
460 wxWindow::OnSysColourChanged(event
);
463 // Pass true to show full screen, false to restore.
464 bool wxFrame::ShowFullScreen(bool show
, long style
)
466 // TODO-CE: add support for CE
467 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
468 if ( IsFullScreen() == show
)
473 // zap the toolbar, menubar, and statusbar if needed
475 // TODO: hide commandbar for WINCE_WITH_COMMANDBAR
477 wxToolBar
*theToolBar
= GetToolBar();
479 if ((style
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
481 if ( theToolBar
->IsShown() )
483 theToolBar
->SetSize(wxDefaultCoord
,0);
484 theToolBar
->Show(false);
486 else // prevent it from being restored later
488 style
&= ~wxFULLSCREEN_NOTOOLBAR
;
491 #endif // wxUSE_TOOLBAR
493 if (style
& wxFULLSCREEN_NOMENUBAR
)
494 SetMenu((HWND
)GetHWND(), (HMENU
) NULL
);
497 wxStatusBar
*theStatusBar
= GetStatusBar();
499 // Save the number of fields in the statusbar
500 if ((style
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
502 if ( theStatusBar
->IsShown() )
503 theStatusBar
->Show(false);
505 style
&= ~wxFULLSCREEN_NOSTATUSBAR
;
507 #endif // wxUSE_STATUSBAR
509 else // restore to normal
511 // restore the toolbar, menubar, and statusbar if we had hid them
513 wxToolBar
*theToolBar
= GetToolBar();
515 if ((m_fsStyle
& wxFULLSCREEN_NOTOOLBAR
) && theToolBar
)
517 theToolBar
->Show(true);
519 #endif // wxUSE_TOOLBAR
521 if (m_fsStyle
& wxFULLSCREEN_NOMENUBAR
)
523 WXHMENU menu
= m_hMenu
;
525 #if wxUSE_MDI_ARCHITECTURE
526 wxMDIParentFrame
*frame
= wxDynamicCast(this, wxMDIParentFrame
);
529 wxMDIChildFrame
*child
= frame
->GetActiveChild();
532 menu
= child
->GetWinMenu();
535 #endif // wxUSE_MDI_ARCHITECTURE
539 ::SetMenu(GetHwnd(), (HMENU
)menu
);
544 wxStatusBar
*theStatusBar
= GetStatusBar();
546 if ((m_fsStyle
& wxFULLSCREEN_NOSTATUSBAR
) && theStatusBar
)
548 theStatusBar
->Show(true);
551 #endif // wxUSE_STATUSBAR
553 #endif // !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
555 return wxFrameBase::ShowFullScreen(show
, style
);
558 // ----------------------------------------------------------------------------
559 // tool/status bar stuff
560 // ----------------------------------------------------------------------------
564 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
566 #if defined(WINCE_WITHOUT_COMMANDBAR)
567 // We may already have a toolbar from calling SetMenuBar.
571 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
576 return m_frameToolBar
;
579 void wxFrame::PositionToolBar()
581 wxToolBar
*toolbar
= GetToolBar();
582 if ( toolbar
&& toolbar
->IsShown() )
584 #if defined(WINCE_WITHOUT_COMMANDBAR)
585 // We want to do something different in WinCE, because
586 // the toolbar should be associated with the commandbar,
587 // and not an independent window.
590 // don't call our (or even wxTopLevelWindow) version because we want
591 // the real (full) client area size, not excluding the tool/status bar
593 wxWindow::DoGetClientSize(&width
, &height
);
596 wxStatusBar
*statbar
= GetStatusBar();
597 if ( statbar
&& statbar
->IsShown() )
599 height
-= statbar
->GetClientSize().y
;
601 #endif // wxUSE_STATUSBAR
605 #if defined(WINCE_WITH_COMMANDBAR)
606 // We're using a commandbar - so we have to allow for it.
607 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
610 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
611 y
= rect
.bottom
- rect
.top
;
617 toolbar
->GetPosition(&tx
, &ty
);
618 toolbar
->GetSize(&tw
, &th
);
621 if (ty
< 0 && (-ty
== th
))
623 if (tx
< 0 && (-tx
== tw
))
629 if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
636 // if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
640 // use the 'real' MSW position here, don't offset relativly to the
641 // client area origin
643 // Optimise such that we don't have to always resize the toolbar
644 // when the frame changes, otherwise we'll get a lot of flicker.
645 bool heightChanging
wxDUMMY_INITIALIZE(true);
646 bool widthChanging
wxDUMMY_INITIALIZE(true);
648 if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
650 // It's OK if the current height is greater than what can be shown.
651 heightChanging
= (desiredH
> th
) ;
652 widthChanging
= (desiredW
!= tw
) ;
654 // The next time around, we may not have to set the size
656 desiredH
= desiredH
+ 200;
660 // It's OK if the current width is greater than what can be shown.
661 widthChanging
= (desiredW
> tw
) ;
662 heightChanging
= (desiredH
!= th
) ;
664 // The next time around, we may not have to set the size
666 desiredW
= desiredW
+ 200;
669 if (tx
!= 0 || ty
!= 0 || widthChanging
|| heightChanging
)
670 toolbar
->SetSize(x
, y
, desiredW
, desiredH
, wxSIZE_NO_ADJUSTMENTS
);
672 #endif // __WXWINCE__
676 #endif // wxUSE_TOOLBAR
678 // ----------------------------------------------------------------------------
679 // frame state (iconized/maximized/...)
680 // ----------------------------------------------------------------------------
682 // propagate our state change to all child frames: this allows us to emulate X
683 // Windows behaviour where child frames float independently of the parent one
684 // on the desktop, but are iconized/restored with it
685 void wxFrame::IconizeChildFrames(bool bIconize
)
687 m_iconized
= bIconize
;
689 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
691 node
= node
->GetNext() )
693 wxWindow
*win
= node
->GetData();
695 // iconizing the frames with this style under Win95 shell puts them at
696 // the bottom of the screen (as the MDI children) instead of making
697 // them appear in the taskbar because they are, by virtue of this
698 // style, not managed by the taskbar - instead leave Windows take care
701 if ( win
->GetWindowStyle() & wxFRAME_TOOL_WINDOW
)
705 // the child MDI frames are a special case and should not be touched by
706 // the parent frame - instead, they are managed by the user
707 wxFrame
*frame
= wxDynamicCast(win
, wxFrame
);
709 #if wxUSE_MDI_ARCHITECTURE
710 && !frame
->IsMDIChild()
711 #endif // wxUSE_MDI_ARCHITECTURE
714 // we don't want to restore the child frames which had been
715 // iconized even before we were iconized, so save the child frame
716 // status when iconizing the parent frame and check it when
720 frame
->m_wasMinimized
= frame
->IsIconized();
723 // note that we shouldn't touch the hidden frames neither because
724 // iconizing/restoring them would show them as a side effect
725 if ( !frame
->m_wasMinimized
&& frame
->IsShown() )
726 frame
->Iconize(bIconize
);
731 WXHICON
wxFrame::GetDefaultIcon() const
733 // we don't have any standard icons (any more)
737 // ===========================================================================
738 // message processing
739 // ===========================================================================
741 // ---------------------------------------------------------------------------
743 // ---------------------------------------------------------------------------
745 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
747 if ( wxWindow::MSWTranslateMessage(pMsg
) )
750 #if wxUSE_MENUS && wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
751 // try the menu bar accels
752 wxMenuBar
*menuBar
= GetMenuBar();
756 const wxAcceleratorTable
& acceleratorTable
= menuBar
->GetAccelTable();
757 return acceleratorTable
.Translate(this, pMsg
);
760 #endif // wxUSE_MENUS && wxUSE_ACCEL
763 // ---------------------------------------------------------------------------
764 // our private (non virtual) message handlers
765 // ---------------------------------------------------------------------------
767 bool wxFrame::HandlePaint()
770 if ( ::GetUpdateRect(GetHwnd(), &rect
, FALSE
) )
772 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
775 const wxIcon
& icon
= GetIcon();
776 HICON hIcon
= icon
.Ok() ? GetHiconOf(icon
)
777 : (HICON
)GetDefaultIcon();
779 // Hold a pointer to the dc so long as the OnPaint() message
780 // is being processed
782 HDC hdc
= ::BeginPaint(GetHwnd(), &ps
);
784 // Erase background before painting or we get white background
785 MSWDefWindowProc(WM_ICONERASEBKGND
, (WORD
)(LONG
)ps
.hdc
, 0L);
790 ::GetClientRect(GetHwnd(), &rect
);
792 // FIXME: why hardcoded?
793 static const int icon_width
= 32;
794 static const int icon_height
= 32;
796 int icon_x
= (int)((rect
.right
- icon_width
)/2);
797 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
799 ::DrawIcon(hdc
, icon_x
, icon_y
, hIcon
);
802 ::EndPaint(GetHwnd(), &ps
);
809 return wxWindow::HandlePaint();
814 // nothing to paint - processed
819 bool wxFrame::HandleSize(int WXUNUSED(x
), int WXUNUSED(y
), WXUINT id
)
821 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
826 // only do it it if we were iconized before, otherwise resizing the
827 // parent frame has a curious side effect of bringing it under it's
832 // restore all child frames too
833 IconizeChildFrames(false);
835 (void)SendIconizeEvent(false);
839 // iconize all child frames too
840 IconizeChildFrames(true);
845 #endif // !__WXWINCE__
851 #endif // wxUSE_STATUSBAR
855 #endif // wxUSE_TOOLBAR
857 #if defined(WINCE_WITH_COMMANDBAR)
858 // Position the menu command bar
859 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
862 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
863 wxSize clientSz
= GetClientSize();
865 if ( !::MoveWindow((HWND
) GetMenuBar()->GetCommandBar(), 0, 0, clientSz
.x
, rect
.bottom
- rect
.top
, true ) )
867 wxLogLastError(wxT("MoveWindow"));
871 #endif // WINCE_WITH_COMMANDBAR
874 // call the base class version to generate the appropriate events
878 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
882 // In case it's e.g. a toolbar.
883 wxWindow
*win
= wxFindWinFromHandle(control
);
885 return win
->MSWCommand(cmd
, id
);
888 // handle here commands from menus and accelerators
889 if ( cmd
== 0 || cmd
== 1 )
891 #if wxUSE_MENUS_NATIVE
892 if ( wxCurrentPopupMenu
)
894 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
895 wxCurrentPopupMenu
= NULL
;
897 return popupMenu
->MSWCommand(cmd
, id
);
899 #endif // wxUSE_MENUS_NATIVE
901 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
902 // handle here commands from Smartphone menu bar
903 if ( wxTopLevelWindow::HandleCommand(id
, cmd
, control
) )
907 #endif // __SMARTPHONE__ && __WXWINCE__
909 if ( ProcessCommand(id
) )
918 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD flags
, WXHMENU hMenu
)
921 if ( flags
== 0xFFFF && hMenu
== 0 )
923 // menu was removed from screen
926 #ifndef __WXMICROWIN__
927 else if ( !(flags
& MF_POPUP
) && !(flags
& MF_SEPARATOR
) )
934 // don't give hints for separators (doesn't make sense) nor for the
935 // items opening popup menus (they don't have them anyhow) but do clear
936 // the status line - otherwise, we would be left with the help message
937 // for the previous item which doesn't apply any more
938 DoGiveHelp(wxEmptyString
, false);
943 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
944 event
.SetEventObject(this);
946 return GetEventHandler()->ProcessEvent(event
);
949 bool wxFrame::HandleMenuLoop(const wxEventType
& evtType
, WXWORD isPopup
)
951 // we don't have the menu id here, so we use the id to specify if the event
952 // was from a popup menu or a normal one
953 wxMenuEvent
event(evtType
, isPopup
? -1 : 0);
954 event
.SetEventObject(this);
956 return GetEventHandler()->ProcessEvent(event
);
959 // ---------------------------------------------------------------------------
960 // the window proc for wxFrame
961 // ---------------------------------------------------------------------------
963 WXLRESULT
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
966 bool processed
= false;
970 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
973 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
975 SHHandleWMActivate(GetHwnd(), wParam
, lParam
, info
, FALSE
);
977 // This implicitly sends a wxEVT_ACTIVATE_APP event
979 wxTheApp
->SetActive(wParam
!= 0, FindFocus());
982 case WM_SETTINGCHANGE
:
984 SHACTIVATEINFO
* info
= (SHACTIVATEINFO
*) m_activateInfo
;
986 SHHandleWMSettingChange(GetHwnd(), wParam
, lParam
, info
);
992 wxActivateEvent
event(wxEVT_HIBERNATE
, true, wxID_ANY
);
993 event
.SetEventObject(wxTheApp
);
997 processed
= wxTheApp
->ProcessEvent(event
);
1004 // if we can't close, tell the system that we processed the
1005 // message - otherwise it would close us
1006 processed
= !Close();
1010 processed
= HandleSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
1017 UnpackCommand((WXWPARAM
)wParam
, (WXLPARAM
)lParam
,
1020 processed
= HandleCommand(id
, cmd
, (WXHWND
)hwnd
);
1025 processed
= HandlePaint();
1028 case WM_INITMENUPOPUP
:
1029 processed
= HandleInitMenuPopup((WXHMENU
) wParam
);
1032 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
1037 UnpackMenuSelect(wParam
, lParam
, &item
, &flags
, &hmenu
);
1039 processed
= HandleMenuSelect(item
, flags
, hmenu
);
1043 case WM_EXITMENULOOP
:
1044 processed
= HandleMenuLoop(wxEVT_MENU_CLOSE
, (WXWORD
)wParam
);
1047 case WM_QUERYDRAGICON
:
1049 const wxIcon
& icon
= GetIcon();
1050 HICON hIcon
= icon
.Ok() ? GetHiconOf(icon
)
1051 : (HICON
)GetDefaultIcon();
1053 processed
= rc
!= 0;
1056 #endif // !__WXMICROWIN__
1060 rc
= wxFrameBase::MSWWindowProc(message
, wParam
, lParam
);
1065 // handle WM_INITMENUPOPUP message
1066 bool wxFrame::HandleInitMenuPopup(WXHMENU hMenu
)
1068 wxMenu
* menu
= NULL
;
1071 int nCount
= GetMenuBar()->GetMenuCount();
1072 for (int n
= 0; n
< nCount
; n
++)
1074 if (GetMenuBar()->GetMenu(n
)->GetHMenu() == hMenu
)
1076 menu
= GetMenuBar()->GetMenu(n
);
1082 wxMenuEvent
event(wxEVT_MENU_OPEN
, 0, menu
);
1083 event
.SetEventObject(this);
1085 return GetEventHandler()->ProcessEvent(event
);
1088 // ----------------------------------------------------------------------------
1089 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
1090 // from the client area, so the client area is what's really available for the
1092 // ----------------------------------------------------------------------------
1094 // get the origin of the client area in the client coordinates
1095 wxPoint
wxFrame::GetClientAreaOrigin() const
1097 wxPoint pt
= wxTopLevelWindow::GetClientAreaOrigin();
1099 #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && \
1100 (!defined(__WXWINCE__) || (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)))
1101 wxToolBar
*toolbar
= GetToolBar();
1102 if ( toolbar
&& toolbar
->IsShown() )
1105 toolbar
->GetSize(&w
, &h
);
1107 if ( toolbar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
1116 #endif // wxUSE_TOOLBAR
1118 #if defined(WINCE_WITH_COMMANDBAR)
1119 if (GetMenuBar() && GetMenuBar()->GetCommandBar())
1122 ::GetWindowRect((HWND
) GetMenuBar()->GetCommandBar(), &rect
);
1123 pt
.y
+= (rect
.bottom
- rect
.top
);