]> git.saurik.com Git - wxWidgets.git/blob - src/common/framecmn.cpp
some sprintf()s replaced with wxString::Printf
[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 if ( bar != NULL ) {
34 int nCount = bar->GetMenuCount();
35 for (int n = 0; n < nCount; n++)
36 DoMenuUpdates(bar->GetMenu(n));
37 }
38 }
39
40 // update a menu and all submenus recursively
41 void wxFrame::DoMenuUpdates(wxMenu* menu)
42 {
43 wxNode* node = menu->GetItems().First();
44 while (node)
45 {
46 wxMenuItem* item = (wxMenuItem*) node->Data();
47 if ( !item->IsSeparator() )
48 {
49 wxWindowID id = item->GetId();
50 wxUpdateUIEvent event(id);
51 event.SetEventObject( this );
52
53 if (GetEventHandler()->ProcessEvent(event))
54 {
55 if (event.GetSetText())
56 menu->SetLabel(id, event.GetText());
57 if (event.GetSetChecked())
58 menu->Check(id, event.GetChecked());
59 if (event.GetSetEnabled())
60 menu->Enable(id, event.GetEnabled());
61 }
62
63 if (item->GetSubMenu())
64 DoMenuUpdates(item->GetSubMenu());
65 }
66 node = node->Next();
67 }
68 }