]> git.saurik.com Git - wxWidgets.git/blame - src/common/framecmn.cpp
Right-o, wxConv_local does cause some weird crashes, but things
[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();
e702ff0f 33
63fec618
VZ
34 if ( bar != NULL ) {
35 int nCount = bar->GetMenuCount();
36 for (int n = 0; n < nCount; n++)
6c41a418 37 DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL);
63fec618
VZ
38 }
39}
40
41// update a menu and all submenus recursively
6c41a418 42void wxFrame::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin))
63fec618 43{
6c41a418 44 wxEvtHandler* evtHandler = GetEventHandler();
63fec618
VZ
45 wxNode* node = menu->GetItems().First();
46 while (node)
47 {
48 wxMenuItem* item = (wxMenuItem*) node->Data();
49 if ( !item->IsSeparator() )
50 {
51 wxWindowID id = item->GetId();
52 wxUpdateUIEvent event(id);
53 event.SetEventObject( this );
54
e702ff0f 55 if (evtHandler->ProcessEvent(event))
63fec618
VZ
56 {
57 if (event.GetSetText())
58 menu->SetLabel(id, event.GetText());
59 if (event.GetSetChecked())
60 menu->Check(id, event.GetChecked());
61 if (event.GetSetEnabled())
62 menu->Enable(id, event.GetEnabled());
63 }
64
65 if (item->GetSubMenu())
6c41a418 66 DoMenuUpdates(item->GetSubMenu(), (wxWindow*) NULL);
63fec618
VZ
67 }
68 node = node->Next();
69 }
70}