]> git.saurik.com Git - wxWidgets.git/blob - src/common/framecmn.cpp
* Deleted #include "wx/bufstrm.h"
[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 void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
23 {
24 DoMenuUpdates();
25 }
26
27 // update all menus
28 void wxFrame::DoMenuUpdates()
29 {
30 wxMenuBar* bar = GetMenuBar();
31 if ( bar != NULL ) {
32 int nCount = bar->GetMenuCount();
33 for (int n = 0; n < nCount; n++)
34 DoMenuUpdates(bar->GetMenu(n));
35 }
36 }
37
38 // update a menu and all submenus recursively
39 void wxFrame::DoMenuUpdates(wxMenu* menu)
40 {
41 wxNode* node = menu->GetItems().First();
42 while (node)
43 {
44 wxMenuItem* item = (wxMenuItem*) node->Data();
45 if ( !item->IsSeparator() )
46 {
47 wxWindowID id = item->GetId();
48 wxUpdateUIEvent event(id);
49 event.SetEventObject( this );
50
51 if (GetEventHandler()->ProcessEvent(event))
52 {
53 if (event.GetSetText())
54 menu->SetLabel(id, event.GetText());
55 if (event.GetSetChecked())
56 menu->Check(id, event.GetChecked());
57 if (event.GetSetEnabled())
58 menu->Enable(id, event.GetEnabled());
59 }
60
61 if (item->GetSubMenu())
62 DoMenuUpdates(item->GetSubMenu());
63 }
64 node = node->Next();
65 }
66 }