Counter Strike : Global Offensive Source Code
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
3.0 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TOOLWINDOW_H
  7. #define TOOLWINDOW_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui/vgui.h>
  12. #include <vgui_controls/Frame.h>
  13. struct TWEdgePair_t;
  14. namespace vgui
  15. {
  16. class ToolWindow;
  17. class PropertySheet;
  18. // So that an app can have a "custom" tool window class created during window drag/drop operations on the property sheet
  19. class IToolWindowFactory
  20. {
  21. public:
  22. virtual ToolWindow *InstanceToolWindow( Panel *parent, bool contextLabel, Panel *firstPage, char const *title, bool contextMenu ) = 0;
  23. };
  24. enum ESharedEdge
  25. {
  26. TOOLWINDOW_NONE = -1,
  27. TOOLWINDOW_LEFT = 0, // The other window's left side is 'shared' with our right side
  28. TOOLWINDOW_TOP,
  29. TOOLWINDOW_RIGHT,
  30. TOOLWINDOW_BOTTOM,
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Purpose: Simple frame that holds a property sheet
  34. //-----------------------------------------------------------------------------
  35. class ToolWindow : public Frame
  36. {
  37. DECLARE_CLASS_SIMPLE( ToolWindow, Frame );
  38. public:
  39. ToolWindow(Panel *parent, bool contextLabel, IToolWindowFactory *factory = 0, Panel *page = NULL, char const *title = NULL, bool contextMenu = false, bool inGlobalList = true );
  40. ~ToolWindow();
  41. virtual bool IsDraggableTabContainer() const;
  42. // returns a pointer to the PropertySheet this dialog encapsulates
  43. PropertySheet *GetPropertySheet();
  44. // wrapper for PropertySheet interface
  45. void AddPage(Panel *page, const char *title, bool contextMenu );
  46. void RemovePage( Panel *page );
  47. Panel *GetActivePage();
  48. void SetActivePage( Panel *page );
  49. void SetToolWindowFactory( IToolWindowFactory *factory );
  50. IToolWindowFactory *GetToolWindowFactory();
  51. static int GetToolWindowCount();
  52. static ToolWindow *GetToolWindow( int index );
  53. static CUtlVector< ToolWindow * > s_ToolWindows;
  54. virtual void Grow( int edge = 0, int from_x = -1, int from_y = -1 );
  55. virtual void GrowFromClick();
  56. void GetSiblingToolWindows( CUtlVector< ToolWindow * > &vecSiblings );
  57. void EnableStickyEdges( bool bEnable );
  58. bool IsStickEdgesEnabled() const;
  59. protected:
  60. // vgui overrides
  61. virtual void PerformLayout();
  62. virtual void ActivateBuildMode();
  63. virtual void RequestFocus(int direction = 0);
  64. virtual void OnSetFocus();
  65. virtual void OnMousePressed(MouseCode code);
  66. virtual void OnMouseDoublePressed(MouseCode code);
  67. MESSAGE_FUNC( OnPageChanged, "PageChanged" );
  68. // Override Frame method in order to grow sibling tool windows if possible
  69. virtual void OnGripPanelMoved( int nNewX, int nNewY, int nNewW, int nNewH );
  70. virtual void OnGripPanelMoveFinished();
  71. private:
  72. void FindOverlappingEdges_R( CUtlVector< ToolWindow * > &vecSiblings, CUtlRBTree< TWEdgePair_t > &rbCurrentEdges, ESharedEdge eEdgeType, int line[ 4 ] );
  73. void MoveSibling( ToolWindow *pSibling, ESharedEdge eEdge, int dpixels );
  74. PropertySheet *m_pPropertySheet;
  75. IToolWindowFactory *m_pFactory;
  76. bool m_bStickyEdges : 1;
  77. };
  78. }; // vgui
  79. #endif // TOOLWINDOW_H