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.

76 lines
1.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef VGUI_HELPERS_H
  7. #define VGUI_HELPERS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/TreeView.h>
  12. #include <vgui_controls/CheckButton.h>
  13. class KeyValues;
  14. class ConVar;
  15. // This control keeps a ConVar's value updated with a CheckButton's value.
  16. class CConVarCheckButton : public vgui::CheckButton
  17. {
  18. public:
  19. typedef vgui::CheckButton BaseClass;
  20. CConVarCheckButton( vgui::Panel *parent, const char *panelName, const char *text );
  21. // Call this to initialize it with a cvar. The CheckButton will be set to the current
  22. // value of the ConVar.
  23. void SetConVar( ConVar *pVar );
  24. virtual void SetSelected( bool state );
  25. public:
  26. ConVar *m_pConVar;
  27. };
  28. // Return true if the state was changed at all (in any way that would require an InvalidateLayout on the control).
  29. typedef bool (*UpdateItemStateFn)(
  30. vgui::TreeView *pTree,
  31. int iChildItemId,
  32. KeyValues *pSub );
  33. // This function takes a bunch of KeyValues entries and incrementally updates
  34. // a tree control. This can be a lot more efficient than clearing the whole tree
  35. // control and re-adding all the elements if most of the elements don't usually change.
  36. //
  37. // NOTE: Only KeyValues nodes with a string named "Text" will be treated as items
  38. // that should be added to the tree.
  39. //
  40. // If iRoot is -1, then it uses GetRootItemIndex().
  41. //
  42. // Returns true if any elements were added or changed.
  43. bool IncrementalUpdateTree(
  44. vgui::TreeView *pTree,
  45. KeyValues *pValues,
  46. UpdateItemStateFn fn,
  47. int iRoot = -1
  48. );
  49. // Copy the contents of the list panel to the clipboard in tab-delimited form for Excel.
  50. void CopyListPanelToClipboard( vgui::ListPanel *pListPanel );
  51. #endif // VGUI_HELPERS_H