common code of wxFrame class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3bbb630a21
commit
63fec618dc
55
src/common/framecmn.cpp
Normal file
55
src/common/framecmn.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: framecmn.cpp
|
||||
// Purpose: common (for all platforms) wxFrame functions
|
||||
// Author: Julian Smart, Vadim Zeitlin
|
||||
// Created: 01/02/97
|
||||
// Id:
|
||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void wxFrame::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
DoMenuUpdates();
|
||||
}
|
||||
|
||||
// update all menus
|
||||
void wxFrame::DoMenuUpdates()
|
||||
{
|
||||
wxMenuBar* bar = GetMenuBar();
|
||||
if ( bar != NULL ) {
|
||||
int nCount = bar->GetMenuCount();
|
||||
for (int n = 0; n < nCount; n++)
|
||||
DoMenuUpdates(bar->GetMenu(n));
|
||||
}
|
||||
}
|
||||
|
||||
// update a menu and all submenus recursively
|
||||
void wxFrame::DoMenuUpdates(wxMenu* menu)
|
||||
{
|
||||
wxNode* node = menu->GetItems().First();
|
||||
while (node)
|
||||
{
|
||||
wxMenuItem* item = (wxMenuItem*) node->Data();
|
||||
if ( !item->IsSeparator() )
|
||||
{
|
||||
wxWindowID id = item->GetId();
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject( this );
|
||||
|
||||
if (GetEventHandler()->ProcessEvent(event))
|
||||
{
|
||||
if (event.GetSetText())
|
||||
menu->SetLabel(id, event.GetText());
|
||||
if (event.GetSetChecked())
|
||||
menu->Check(id, event.GetChecked());
|
||||
if (event.GetSetEnabled())
|
||||
menu->Enable(id, event.GetEnabled());
|
||||
}
|
||||
|
||||
if (item->GetSubMenu())
|
||||
DoMenuUpdates(item->GetSubMenu());
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user