]>
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 | ||
f701d7ab JS |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
439b3bf1 | 18 | #include "wx/frame.h" |
f701d7ab | 19 | #include "wx/menu.h" |
e52f60e6 | 20 | #include "wx/menuitem.h" |
e6688c3f | 21 | |
46dc76ba | 22 | void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) |
63fec618 | 23 | { |
54517652 | 24 | DoMenuUpdates(); |
63fec618 VZ |
25 | } |
26 | ||
27 | // update all menus | |
28 | void wxFrame::DoMenuUpdates() | |
29 | { | |
54517652 | 30 | wxMenuBar* bar = GetMenuBar(); |
e702ff0f | 31 | |
54517652 RR |
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 | } | |
63fec618 VZ |
38 | } |
39 | ||
40 | // update a menu and all submenus recursively | |
6c41a418 | 41 | void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin)) |
63fec618 | 42 | { |
6c41a418 | 43 | wxEvtHandler* evtHandler = GetEventHandler(); |
dd60b9ec | 44 | wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst(); |
63fec618 VZ |
45 | while (node) |
46 | { | |
dd60b9ec | 47 | wxMenuItem* item = node->GetData(); |
63fec618 VZ |
48 | if ( !item->IsSeparator() ) |
49 | { | |
50 | wxWindowID id = item->GetId(); | |
51 | wxUpdateUIEvent event(id); | |
52 | event.SetEventObject( this ); | |
53 | ||
e702ff0f | 54 | if (evtHandler->ProcessEvent(event)) |
63fec618 VZ |
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()) | |
6c41a418 | 65 | DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL); |
63fec618 | 66 | } |
dd60b9ec | 67 | node = node->GetNext(); |
63fec618 VZ |
68 | } |
69 | } |