]> git.saurik.com Git - wxWidgets.git/blob - src/common/framecmn.cpp
Added in-place editiging in wxListCtrl
[wxWidgets.git] / src / common / framecmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: framecmn.cpp
3 // Purpose: common (for all platforms) wxFrame functions
4 // Author: Julian Smart, Vadim Zeitlin
5 // Created: 01/02/97
6 // Id: $Id$
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/frame.h"
19 #include "wx/menu.h"
20
21 // wxGTK is a special case because it doesn't use the generic wxMenuItem
22 // class, but it's own (already defined in wx/menu.h) one
23 #ifndef __WXGTK__
24 #include "wx/menuitem.h"
25 #endif //WXGTK
26
27 void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) )
28 {
29 DoMenuUpdates();
30 }
31
32 // update all menus
33 void wxFrame::DoMenuUpdates()
34 {
35 wxMenuBar* bar = GetMenuBar();
36 if ( bar != NULL ) {
37 int nCount = bar->GetMenuCount();
38 for (int n = 0; n < nCount; n++)
39 DoMenuUpdates(bar->GetMenu(n));
40 }
41 }
42
43 // update a menu and all submenus recursively
44 void wxFrame::DoMenuUpdates(wxMenu* menu)
45 {
46 wxNode* node = menu->GetItems().First();
47 while (node)
48 {
49 wxMenuItem* item = (wxMenuItem*) node->Data();
50 if ( !item->IsSeparator() )
51 {
52 wxWindowID id = item->GetId();
53 wxUpdateUIEvent event(id);
54 event.SetEventObject( this );
55
56 if (GetEventHandler()->ProcessEvent(event))
57 {
58 if (event.GetSetText())
59 menu->SetLabel(id, event.GetText());
60 if (event.GetSetChecked())
61 menu->Check(id, event.GetChecked());
62 if (event.GetSetEnabled())
63 menu->Enable(id, event.GetEnabled());
64 }
65
66 if (item->GetSubMenu())
67 DoMenuUpdates(item->GetSubMenu());
68 }
69 node = node->Next();
70 }
71 }