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.

91 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "DemoPage.h"
  8. #include <VGUI/IVGui.h>
  9. #include <vgui_controls/Controls.h>
  10. #include <Keyvalues.h>
  11. #include <vgui_controls/Frame.h>
  12. using namespace vgui;
  13. class FrameDemo: public DemoPage
  14. {
  15. public:
  16. FrameDemo(Panel *parent, const char *name);
  17. ~FrameDemo();
  18. void OnButtonClicked();
  19. void SetVisible(bool status);
  20. private:
  21. Frame *m_pFrame;
  22. };
  23. //-----------------------------------------------------------------------------
  24. // Purpose: Constructor
  25. //-----------------------------------------------------------------------------
  26. FrameDemo::FrameDemo(Panel *parent, const char *name) : DemoPage(parent, name)
  27. {
  28. // Create a Frame.
  29. // This frame has no parent, this way if you press the minimize button
  30. // a label will go on the taskbar.
  31. m_pFrame = new Frame(NULL, "AFrame");
  32. // Frames are well, a "frame" around a panel. They have a name bar
  33. // at the top where a title can be displayed, sizing hotspots on the corners,
  34. // and a minimize and close box in the upper right corner.
  35. // Set the title of the frame
  36. m_pFrame->SetTitle("A Demo Frame", "");
  37. // Frames are sizable and moveable by default.
  38. // Set its position and size
  39. m_pFrame->SetSize(300, 100);
  40. // Set its Position
  41. m_pFrame->MoveToCenterOfScreen();
  42. // Start the frame off invisible. This way it will not be visible when
  43. // other demo tabs are selected. It becomes visible when this demo tab is selected.
  44. m_pFrame->SetVisible(false);
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose: Destructor
  48. //-----------------------------------------------------------------------------
  49. FrameDemo::~FrameDemo()
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose: When we make this this demo page we make the frame visible.
  54. //-----------------------------------------------------------------------------
  55. void FrameDemo::SetVisible(bool status)
  56. {
  57. if (status)
  58. m_pFrame->SetVisible(true);
  59. else
  60. m_pFrame->SetVisible(false);
  61. DemoPage::SetVisible(status);
  62. }
  63. Panel* FrameDemo_Create(Panel *parent)
  64. {
  65. return new FrameDemo(parent, "FrameDemo");
  66. }