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.

104 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Standard file menu
  4. //
  5. //=============================================================================
  6. #ifndef TOOLFILEMENUBUTTON_H
  7. #define TOOLFILEMENUBUTTON_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "toolutils/toolmenubutton.h"
  12. //-----------------------------------------------------------------------------
  13. // forward declarations
  14. //-----------------------------------------------------------------------------
  15. namespace vgui
  16. {
  17. class Panel;
  18. class Menu;
  19. }
  20. class CToolMenuButton;
  21. //-----------------------------------------------------------------------------
  22. // Called back by the file menu
  23. //-----------------------------------------------------------------------------
  24. class IFileMenuCallbacks
  25. {
  26. public:
  27. enum MenuItems_t
  28. {
  29. FILE_NEW = 0x01,
  30. FILE_OPEN = 0x02,
  31. FILE_SAVE = 0x04,
  32. FILE_SAVEAS = 0x08,
  33. FILE_CLOSE = 0x10,
  34. FILE_RECENT = 0x20,
  35. FILE_CLEAR_RECENT = 0x40,
  36. FILE_EXIT = 0x80,
  37. FILE_ALL = 0xFFFFFFFF
  38. };
  39. // Logically OR together all items that should be enabled
  40. virtual int GetFileMenuItemsEnabled( ) = 0;
  41. // Add recent files to the menu passed in
  42. virtual void AddRecentFilesToMenu( vgui::Menu *menu ) = 0;
  43. // Get the perforce file name (to set the various perforce menu options)
  44. virtual bool GetPerforceFileName( char *pFileName, int nMaxLen ) = 0;
  45. // Gets the root vgui panel
  46. virtual vgui::Panel *GetRootPanel() = 0;
  47. };
  48. //-----------------------------------------------------------------------------
  49. // Standard file menu
  50. //-----------------------------------------------------------------------------
  51. class CToolFileMenuButton : public CToolMenuButton
  52. {
  53. DECLARE_CLASS_SIMPLE( CToolFileMenuButton, CToolMenuButton );
  54. public:
  55. CToolFileMenuButton( vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget, IFileMenuCallbacks *pFileMenuCallback );
  56. virtual void OnShowMenu( vgui::Menu *menu );
  57. private:
  58. MESSAGE_FUNC( OnPerforceAdd, "OnPerforceAdd" );
  59. MESSAGE_FUNC( OnPerforceOpen, "OnPerforceOpen" );
  60. MESSAGE_FUNC( OnPerforceRevert, "OnPerforceRevert" );
  61. MESSAGE_FUNC( OnPerforceSubmit, "OnPerforceSubmit" );
  62. MESSAGE_FUNC( OnPerforceP4Win, "OnPerforceP4Win" );
  63. MESSAGE_FUNC( OnPerforceListOpenFiles, "OnPerforceListOpenFiles" );
  64. vgui::Menu *m_pRecentFiles;
  65. vgui::Menu *m_pPerforce;
  66. int m_nRecentFiles;
  67. IFileMenuCallbacks *m_pFileMenuCallback;
  68. int m_nPerforceAdd;
  69. int m_nPerforceOpen;
  70. int m_nPerforceRevert;
  71. int m_nPerforceSubmit;
  72. int m_nPerforceP4Win;
  73. int m_nPerforceListOpenFiles;
  74. };
  75. //-----------------------------------------------------------------------------
  76. // Global function to create the switch menu
  77. //-----------------------------------------------------------------------------
  78. CToolMenuButton* CreateToolFileMenuButton( vgui::Panel *parent, const char *panelName,
  79. const char *text, vgui::Panel *pActionTarget, IFileMenuCallbacks *pCallbacks );
  80. #endif // TOOLFILEMENUBUTTON_H