core/vgui/impl/wx/vgui_wx_menu.h
Go to the documentation of this file.
00001 // This is core/vgui/impl/wx/vgui_wx_menu.h
00002 #ifndef vgui_wx_menu_h_
00003 #define vgui_wx_menu_h_
00004 //=========================================================================
00005 //:
00006 // \file
00007 // \brief  wxWidgets mapping of the vgui_menu.
00008 // \author Miguel A. Figueroa-Villanueva (miguelfv)
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   04/18/2006 - File created. (miguelfv)
00013 // \endverbatim
00014 //=========================================================================
00015 
00016 #include <vgui/vgui_menu.h>
00017 
00018 #include <wx/event.h>
00019 class wxMenu;
00020 class wxMenuBar;
00021 
00022 #include <vcl_map.h>
00023 
00024 //-------------------------------------------------------------------------
00025 //: The wxWidgets mapping of the vgui_menu.
00026 //
00027 // Maps a vgui_menu object to the equivalent wxMenu and wxMenuBar.
00028 //-------------------------------------------------------------------------
00029 class vgui_wx_menu : public wxEvtHandler
00030 {
00031   DECLARE_EVENT_TABLE()
00032 
00033 public:
00034   vgui_wx_menu();
00035   virtual ~vgui_wx_menu();
00036 
00037   //: Create a wxMenuBar that maps to the vgui_menu.
00038   wxMenuBar* create_wx_menubar(const vgui_menu& menu);
00039 
00040   //: Create a wxMenu that maps to the vgui_menu.
00041   wxMenu* create_wx_menu(const vgui_menu& menu);
00042 
00043 private:
00044   //: Helper class that actually builds the mapped menus.
00045   wxMenu* create_wx_submenu(const vgui_menu& menu);
00046 
00047   //: Create the accelerator substring to add to the menu item name.
00048   vcl_string create_accelerator_string(const vgui_menu_item& item) const;
00049 
00050   //: Disconnect the Event Handlers from the event table.
00051   void disconnect_handlers();
00052 
00053   //: The event handler that delegates the call to the correct command.
00054   void on_command(wxCommandEvent& event);
00055 
00056   static const int MENU_ID_OFFSET;
00057   int item_count_;
00058 
00059   vcl_map<int,vgui_command_sptr> handlers_;
00060 };
00061 
00062 #endif // vgui_wx_menu_h_