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