]>
Commit | Line | Data |
---|---|---|
63fec618 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: framecmn.cpp | |
3 | // Purpose: common (for all platforms) wxFrame functions | |
4 | // Author: Julian Smart, Vadim Zeitlin | |
5 | // Created: 01/02/97 | |
439b3bf1 | 6 | // Id: $Id$ |
63fec618 VZ |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
439b3bf1 VZ |
11 | #include "wx/frame.h" |
12 | ||
63fec618 VZ |
13 | void wxFrame::OnIdle(wxIdleEvent& event) |
14 | { | |
15 | DoMenuUpdates(); | |
16 | } | |
17 | ||
18 | // update all menus | |
19 | void wxFrame::DoMenuUpdates() | |
20 | { | |
21 | wxMenuBar* bar = GetMenuBar(); | |
22 | if ( bar != NULL ) { | |
23 | int nCount = bar->GetMenuCount(); | |
24 | for (int n = 0; n < nCount; n++) | |
25 | DoMenuUpdates(bar->GetMenu(n)); | |
26 | } | |
27 | } | |
28 | ||
29 | // update a menu and all submenus recursively | |
30 | void wxFrame::DoMenuUpdates(wxMenu* menu) | |
31 | { | |
32 | wxNode* node = menu->GetItems().First(); | |
33 | while (node) | |
34 | { | |
35 | wxMenuItem* item = (wxMenuItem*) node->Data(); | |
36 | if ( !item->IsSeparator() ) | |
37 | { | |
38 | wxWindowID id = item->GetId(); | |
39 | wxUpdateUIEvent event(id); | |
40 | event.SetEventObject( this ); | |
41 | ||
42 | if (GetEventHandler()->ProcessEvent(event)) | |
43 | { | |
44 | if (event.GetSetText()) | |
45 | menu->SetLabel(id, event.GetText()); | |
46 | if (event.GetSetChecked()) | |
47 | menu->Check(id, event.GetChecked()); | |
48 | if (event.GetSetEnabled()) | |
49 | menu->Enable(id, event.GetEnabled()); | |
50 | } | |
51 | ||
52 | if (item->GetSubMenu()) | |
53 | DoMenuUpdates(item->GetSubMenu()); | |
54 | } | |
55 | node = node->Next(); | |
56 | } | |
57 | } |