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.

98 lines
2.5 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef SPLITTER_H
  8. #define SPLITTER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/EditablePanel.h>
  13. namespace vgui
  14. {
  15. enum SplitterMode_t
  16. {
  17. SPLITTER_MODE_HORIZONTAL = 0,
  18. SPLITTER_MODE_VERTICAL
  19. };
  20. class SplitterHandle;
  21. class SplitterChildPanel;
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Thin line used to divide sections, can be moved dragged!
  24. //-----------------------------------------------------------------------------
  25. class Splitter : public EditablePanel
  26. {
  27. DECLARE_CLASS_SIMPLE( Splitter, EditablePanel );
  28. public:
  29. // nCount is the number of splitters to create.
  30. // NOTE: The constructor here will create (nCount+1) EditablePanel children
  31. // and name them child0...childN for .res file purposes.
  32. Splitter( Panel *parent, const char *name, SplitterMode_t mode, int nCount );
  33. ~Splitter();
  34. // Evenly respace all splitters
  35. void EvenlyRespaceSplitters();
  36. // respace splitters using given fractions (must sum to 1)
  37. void RespaceSplitters( float *flFractions );
  38. // Inherited from Panel
  39. virtual void ApplySettings(KeyValues *inResourceData);
  40. virtual void GetSettings( KeyValues *outResourceData );
  41. virtual void PerformLayout();
  42. virtual void OnSizeChanged(int newWide, int newTall);
  43. virtual void ApplyUserConfigSettings(KeyValues *userConfig);
  44. virtual void GetUserConfigSettings(KeyValues *userConfig);
  45. virtual bool HasUserConfigSettings() { return true; }
  46. // Sets the splitter color
  47. void SetSplitterColor( Color c );
  48. // Enables borders on the splitters
  49. void EnableBorders( bool bEnable );
  50. // Locks the size of a particular child in pixels.
  51. void LockChildSize( int nChildIndex, int nSize );
  52. void UnlockChildSize( int nChildIndex );
  53. private:
  54. void RecreateSplitters( int nCount );
  55. struct SplitterInfo_t
  56. {
  57. SplitterChildPanel *m_pPanel; // This panel is to the left or above the handle
  58. SplitterHandle *m_pHandle;
  59. float m_flPos;
  60. bool m_bLocked;
  61. int m_nLockedSize;
  62. };
  63. int GetPosRange();
  64. int GetSplitterCount() const;
  65. int GetSplitterPosition( int nIndex );
  66. void SetSplitterPosition( int nIndex, int nPos );
  67. int GetSubPanelCount() const;
  68. int ComputeLockedSize( int nStartingIndex );
  69. CUtlVector< SplitterInfo_t > m_Splitters;
  70. SplitterMode_t m_Mode;
  71. friend class SplitterHandle;
  72. };
  73. } // namespace vgui
  74. #endif // SPLITTER_H