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.

108 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CHECKBUTTON_H
  8. #define CHECKBUTTON_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/VGUI.h>
  13. #include <vgui_controls/ToggleButton.h>
  14. #include <vgui_controls/TextImage.h>
  15. namespace vgui
  16. {
  17. class TextImage;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Check box image
  20. //-----------------------------------------------------------------------------
  21. class CheckImage : public TextImage
  22. {
  23. public:
  24. CheckImage(CheckButton *CheckButton) : TextImage( "g" )
  25. {
  26. _CheckButton = CheckButton;
  27. SetSize(20, 13);
  28. }
  29. virtual void Paint();
  30. virtual void SetColor(Color color)
  31. {
  32. _borderColor1 = color;
  33. _borderColor2 = color;
  34. _checkColor = color;
  35. }
  36. Color _borderColor1;
  37. Color _borderColor2;
  38. Color _checkColor;
  39. Color _bgColor;
  40. private:
  41. CheckButton *_CheckButton;
  42. };
  43. //-----------------------------------------------------------------------------
  44. // Purpose: Tick-box button
  45. //-----------------------------------------------------------------------------
  46. class CheckButton : public ToggleButton
  47. {
  48. DECLARE_CLASS_SIMPLE( CheckButton, ToggleButton );
  49. public:
  50. CheckButton(Panel *parent, const char *panelName, const char *text);
  51. ~CheckButton();
  52. // Check the button
  53. virtual void SetSelected(bool state );
  54. // sets whether or not the state of the check can be changed
  55. // if this is set to false, then no input in the code or by the user can change it's state
  56. virtual void SetCheckButtonCheckable(bool state);
  57. virtual bool IsCheckButtonCheckable() const { return m_bCheckButtonCheckable; }
  58. Color GetDisabledFgColor() { return _disabledFgColor; }
  59. Color GetDisabledBgColor() { return _disabledBgColor; }
  60. CheckImage *GetCheckImage() { return _checkBoxImage; }
  61. virtual void SetHighlightColor(Color fgColor);
  62. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  63. protected:
  64. virtual void ApplySchemeSettings(IScheme *pScheme);
  65. MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
  66. virtual Color GetButtonFgColor();
  67. virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
  68. /* MESSAGES SENT
  69. "CheckButtonChecked" - sent when the check button state is changed
  70. "state" - button state: 1 is checked, 0 is unchecked
  71. */
  72. private:
  73. enum { CHECK_INSET = 6 };
  74. bool m_bCheckButtonCheckable;
  75. bool m_bUseSmallCheckImage;
  76. CheckImage *_checkBoxImage;
  77. Color _disabledFgColor;
  78. Color _disabledBgColor;
  79. Color _highlightFgColor;
  80. };
  81. } // namespace vgui
  82. #endif // CHECKBUTTON_H