Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Core Movie Maker UI API
  4. //
  5. //=============================================================================
  6. #ifndef TOOLMENUBUTTON_H
  7. #define TOOLMENUBUTTON_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/menubutton.h"
  12. #include "tier1/utldict.h"
  13. #include "tier1/utlsymbol.h"
  14. //-----------------------------------------------------------------------------
  15. // Base class for tools menus
  16. //-----------------------------------------------------------------------------
  17. class CToolMenuButton : public vgui::MenuButton
  18. {
  19. DECLARE_CLASS_SIMPLE( CToolMenuButton, vgui::MenuButton );
  20. public:
  21. CToolMenuButton( vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *actionTarget );
  22. virtual void OnShowMenu(vgui::Menu *menu);
  23. vgui::Menu *GetMenu();
  24. // Add a simple text item to the menu
  25. virtual int AddMenuItem( char const *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
  26. virtual int AddCheckableMenuItem( char const *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
  27. // Wide-character version to add a simple text item to the menu
  28. virtual int AddMenuItem( char const *itemName, const wchar_t *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
  29. virtual int AddCheckableMenuItem( char const *itemName, const wchar_t *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
  30. virtual int FindMenuItem( char const *itemName );
  31. virtual void AddSeparatorAfterItem( char const *itemName );
  32. virtual void MoveMenuItem( int itemID, int moveBeforeThisItemID );
  33. virtual void SetItemEnabled( int itemID, bool state );
  34. // Pass in a NULL binding to clear it
  35. virtual void SetCurrentKeyBindingLabel( char const *itemName, char const *binding );
  36. virtual void AddSeparator();
  37. void Reset();
  38. protected:
  39. void UpdateMenuItemKeyBindings();
  40. vgui::Menu *m_pMenu;
  41. vgui::Panel *m_pActionTarget;
  42. struct MenuItem_t
  43. {
  44. MenuItem_t()
  45. : m_ItemID( 0 ),
  46. m_KeyBinding( UTL_INVAL_SYMBOL )
  47. {
  48. }
  49. unsigned short m_ItemID;
  50. CUtlSymbol m_KeyBinding;
  51. };
  52. CUtlDict< MenuItem_t, unsigned short > m_Items;
  53. };
  54. #endif // TOOLMENUBUTTON_H