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.

92 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DOD_RANDOM_BUTTON_H
  8. #define DOD_RANDOM_BUTTON_H
  9. #include "dodmouseoverpanelbutton.h"
  10. // CDODRandomButton - has the lower left corner cut out
  11. // and does mouseover
  12. /*
  13. |''''''''''''''''|
  14. | 9. Random |
  15. \_______________|
  16. */
  17. template <class T>
  18. class CDODRandomButton : public CDODMouseOverButton<T>
  19. {
  20. private:
  21. //DECLARE_CLASS_SIMPLE( CDODRandomButton, CDODMouseOverButton );
  22. public:
  23. CDODRandomButton(vgui::Panel *parent, const char *panelName, T *templatePanel ) :
  24. CDODMouseOverButton<T>( parent, panelName, templatePanel )
  25. {
  26. }
  27. protected:
  28. virtual void PaintBackground();
  29. virtual void PaintBorder();
  30. };
  31. //===============================================
  32. // CDODRandomButton - differently shaped button
  33. //===============================================
  34. template <class T>
  35. void CDODRandomButton<T>::PaintBackground()
  36. {
  37. int wide, tall;
  38. this->GetSize(wide,tall);
  39. int inset = tall;
  40. if ( CDODRandomButton<T>::m_iWhiteTexture < 0 )
  41. {
  42. CDODRandomButton<T>::m_iWhiteTexture = vgui::surface()->CreateNewTextureID();
  43. vgui::surface()->DrawSetTextureFile( CDODRandomButton<T>::m_iWhiteTexture, "vgui/white" , true, false);
  44. }
  45. surface()->DrawSetColor(this->GetBgColor());
  46. surface()->DrawSetTexture( CDODRandomButton<T>::m_iWhiteTexture );
  47. Vertex_t verts[4];
  48. verts[0].Init( Vector2D( 0, 0 ) );
  49. verts[1].Init( Vector2D( wide-1, 0 ) );
  50. verts[2].Init( Vector2D( wide-1, tall-1 ) );
  51. verts[3].Init( Vector2D( inset, tall-1 ) );
  52. surface()->DrawTexturedPolygon(4, verts);
  53. }
  54. template <class T>
  55. void CDODRandomButton<T>::PaintBorder()
  56. {
  57. int wide, tall;
  58. this->GetSize(wide,tall);
  59. int inset = tall;
  60. surface()->DrawSetColor(this->GetFgColor());
  61. // top
  62. surface()->DrawLine( 0, 1, wide-1, 1 );
  63. // left
  64. surface()->DrawLine( 1, 1, inset-1, tall-1 );
  65. // bottom
  66. surface()->DrawLine( inset-1, tall-1, wide-1, tall-1 );
  67. // right
  68. surface()->DrawLine( wide-1, 0, wide-1, tall-1 );
  69. }
  70. #endif //DOD_RANDOM_BUTTON_H