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.

121 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef LISTVIEWPANEL_H
  8. #define LISTVIEWPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <utllinkedlist.h>
  13. #include <utlvector.h>
  14. namespace vgui
  15. {
  16. class ListViewPanel;
  17. typedef bool (*ListViewSortFunc_t)(KeyValues *kv1, KeyValues *kv2);
  18. class ListViewItem;
  19. //-----------------------------------------------------------------------------
  20. // Purpose: List Ctrl Panel with each item having an icon and text after it
  21. //-----------------------------------------------------------------------------
  22. class ListViewPanel : public Panel
  23. {
  24. DECLARE_CLASS_SIMPLE( ListViewPanel, Panel );
  25. public:
  26. ListViewPanel(Panel *parent, const char *panelName);
  27. ~ListViewPanel();
  28. virtual int AddItem(const KeyValues *data, bool bScrollToItem, bool bSortOnAdd);
  29. virtual int GetItemCount();
  30. virtual KeyValues *GetItem(int itemID);
  31. virtual void ApplyItemChanges(int itemID);
  32. virtual void RemoveItem(int itemID);
  33. virtual void DeleteAllItems();
  34. virtual int GetItemIDFromPos(int iPos); // valid from [0, GetItemCount)
  35. virtual int InvalidItemID();
  36. virtual bool IsValidItemID(int itemID);
  37. virtual void ScrollToItem(int itemID);
  38. virtual void SetSortFunc(ListViewSortFunc_t func);
  39. virtual void SortList();
  40. // image handling
  41. virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone);
  42. virtual void SetFont(HFont font);
  43. // returns the count of selected items
  44. virtual int GetSelectedItemsCount();
  45. // returns the selected item by selection index, valid in range [0, GetNumSelectedRows)
  46. virtual int GetSelectedItem(int selectionIndex);
  47. // sets no item as selected
  48. virtual void ClearSelectedItems();
  49. // adds a item to the select list
  50. virtual void AddSelectedItem(int itemID);
  51. // sets this single item as the only selected item
  52. virtual void SetSingleSelectedItem(int itemID);
  53. protected:
  54. // overrides
  55. virtual void OnMouseWheeled(int delta);
  56. virtual void OnSizeChanged(int wide, int tall);
  57. virtual void PerformLayout();
  58. virtual void Paint();
  59. virtual void ApplySchemeSettings(IScheme *pScheme);
  60. virtual void OnMousePressed( MouseCode code);
  61. virtual void OnMouseDoublePressed( MouseCode code);
  62. virtual void OnKeyCodeTyped( KeyCode code);
  63. virtual void OnKeyTyped(wchar_t unichar);
  64. MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
  65. virtual int GetItemsPerColumn();
  66. private:
  67. ScrollBar *m_hbar;
  68. friend class ListViewItem;
  69. void OnItemMousePressed(ListViewItem* pItem, MouseCode code);
  70. void OnItemMouseDoublePressed(ListViewItem* pItem, MouseCode code);
  71. int GetItemsMaxWidth();
  72. int GetItemIndex(int itemID);
  73. void OnShiftSelect(int itemID);
  74. void FinishKeyPress(int itemID);
  75. CUtlLinkedList<ListViewItem*, int> m_DataItems;
  76. CUtlVector<int> m_SortedItems;
  77. ListViewSortFunc_t m_pSortFunc;
  78. int m_iRowHeight;
  79. HFont m_hFont;
  80. Color m_LabelFgColor;
  81. Color m_SelectionFgColor;
  82. // selection data
  83. CUtlVector<int> m_SelectedItems;
  84. int m_LastSelectedItemID;
  85. int m_ShiftStartItemID;
  86. bool m_bNeedsSort;
  87. bool m_bDeleteImageListWhenDone;
  88. ImageList *m_pImageList;
  89. };
  90. }
  91. #endif // LISTVIEWPANEL_H