]> git.saurik.com Git - wxWidgets.git/blame - src/common/framecmn.cpp
BC++/16-bit support now working, but without resource system
[wxWidgets.git] / src / common / framecmn.cpp
CommitLineData
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
e6688c3f 22#ifndef __WXGTK__
46dc76ba 23void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
63fec618
VZ
24{
25 DoMenuUpdates();
26}
e52f60e6 27#endif
63fec618
VZ
28
29// update all menus
30void 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
41void 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}