]> git.saurik.com Git - wxWidgets.git/blob - src/common/framecmn.cpp
59e2c3c868b6a9afca270c0b6fc5992afd7fc8aa
[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:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 void wxFrame::OnIdle(wxIdleEvent& event)
12 {
13 DoMenuUpdates();
14 }
15
16 // update all menus
17 void wxFrame::DoMenuUpdates()
18 {
19 wxMenuBar* bar = GetMenuBar();
20 if ( bar != NULL ) {
21 int nCount = bar->GetMenuCount();
22 for (int n = 0; n < nCount; n++)
23 DoMenuUpdates(bar->GetMenu(n));
24 }
25 }
26
27 // update a menu and all submenus recursively
28 void wxFrame::DoMenuUpdates(wxMenu* menu)
29 {
30 wxNode* node = menu->GetItems().First();
31 while (node)
32 {
33 wxMenuItem* item = (wxMenuItem*) node->Data();
34 if ( !item->IsSeparator() )
35 {
36 wxWindowID id = item->GetId();
37 wxUpdateUIEvent event(id);
38 event.SetEventObject( this );
39
40 if (GetEventHandler()->ProcessEvent(event))
41 {
42 if (event.GetSetText())
43 menu->SetLabel(id, event.GetText());
44 if (event.GetSetChecked())
45 menu->Check(id, event.GetChecked());
46 if (event.GetSetEnabled())
47 menu->Enable(id, event.GetEnabled());
48 }
49
50 if (item->GetSubMenu())
51 DoMenuUpdates(item->GetSubMenu());
52 }
53 node = node->Next();
54 }
55 }