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.

82 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef MENUBUTTON_H
  8. #define MENUBUTTON_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Button.h>
  13. #include "vgui_controls/Menu.h"
  14. namespace vgui
  15. {
  16. class Menu;
  17. class TextImage;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Button that displays a menu when pressed
  20. //-----------------------------------------------------------------------------
  21. class MenuButton : public Button
  22. {
  23. DECLARE_CLASS_SIMPLE( MenuButton, Button );
  24. public:
  25. MenuButton(Panel *parent, const char *panelName, const char *text);
  26. ~MenuButton();
  27. // functions designed to be overriden
  28. virtual void OnShowMenu(Menu *menu) {}
  29. virtual void OnHideMenu(Menu *menu) {}
  30. virtual int OnCheckMenuItemCount() { return 0; }
  31. virtual void SetMenu(Menu *menu);
  32. virtual void HideMenu(void);
  33. virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1);
  34. MESSAGE_FUNC( OnMenuClose, "MenuClose" );
  35. MESSAGE_FUNC_PARAMS( OnKillFocus, "KillFocus", kv ); // called after the panel loses the keyboard focus
  36. virtual void DoClick();
  37. virtual void SetOpenOffsetY(int yOffset);
  38. virtual bool CanBeDefaultButton(void);
  39. // sets the direction in which the menu opens from the button, defaults to down
  40. virtual void SetOpenDirection(Menu::MenuDirection_e direction);
  41. virtual void OnKeyCodeTyped(KeyCode code);
  42. virtual void OnCursorEntered();
  43. virtual void Paint();
  44. virtual void PerformLayout();
  45. virtual void ApplySchemeSettings( IScheme *pScheme );
  46. virtual void OnCursorMoved( int x, int y );
  47. // This style is like the IE "back" button where the left side acts like a regular button, the the right side has a little
  48. // combo box dropdown indicator and presents and submenu
  49. void SetDropMenuButtonStyle( bool state );
  50. bool IsDropMenuButtonStyle() const;
  51. Menu *GetMenu();
  52. private:
  53. Menu *m_pMenu;
  54. Menu::MenuDirection_e m_iDirection;
  55. int _openOffsetY; // vertical offset of menu from the menu button
  56. bool m_bDropMenuButtonStyle : 1;
  57. TextImage *m_pDropMenuImage;
  58. int m_nImageIndex;
  59. };
  60. }; // namespace vgui
  61. #endif // MENUBUTTON_H