]> git.saurik.com Git - wxWidgets.git/blob - src/common/framecmn.cpp
163b00a160bcd53898ace9095e5e70f9d6f7af60
[wxWidgets.git] / src / common / framecmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: framecmn.cpp
3 // Purpose: common (for all platforms) wxFrame functions
4 // Author: Julian Smart, Vadim Zeitlin
5 // Created: 01/02/97
6 // Id: $Id$
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/frame.h"
19 #include "wx/menu.h"
20 #include "wx/menuitem.h"
21
22 #ifndef __WXGTK__
23 void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
24 {
25 DoMenuUpdates();
26 }
27 #endif
28
29 // update all menus
30 void wxFrame::DoMenuUpdates()
31 {
32 wxMenuBar* bar = GetMenuBar();
33
34 // Process events starting with the window with the focus, if any.
35 wxWindow* focusWin = wxFindFocusDescendant(this);
36
37 if ( bar != NULL ) {
38 int nCount = bar->GetMenuCount();
39 for (int n = 0; n < nCount; n++)
40 DoMenuUpdates(bar->GetMenu(n), focusWin);
41 }
42 }
43
44 // update a menu and all submenus recursively
45 void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* focusWin)
46 {
47 wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
48 wxNode* node = menu->GetItems().First();
49 while (node)
50 {
51 wxMenuItem* item = (wxMenuItem*) node->Data();
52 if ( !item->IsSeparator() )
53 {
54 wxWindowID id = item->GetId();
55 wxUpdateUIEvent event(id);
56 event.SetEventObject( this );
57
58 if (evtHandler->ProcessEvent(event))
59 {
60 if (event.GetSetText())
61 menu->SetLabel(id, event.GetText());
62 if (event.GetSetChecked())
63 menu->Check(id, event.GetChecked());
64 if (event.GetSetEnabled())
65 menu->Enable(id, event.GetEnabled());
66 }
67
68 if (item->GetSubMenu())
69 DoMenuUpdates(item->GetSubMenu(), focusWin);
70 }
71 node = node->Next();
72 }
73 }