diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/public/vgui_controls/PanelListPanel.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/public/vgui_controls/PanelListPanel.h')
| -rw-r--r-- | mp/src/public/vgui_controls/PanelListPanel.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/mp/src/public/vgui_controls/PanelListPanel.h b/mp/src/public/vgui_controls/PanelListPanel.h new file mode 100644 index 00000000..392feb3d --- /dev/null +++ b/mp/src/public/vgui_controls/PanelListPanel.h @@ -0,0 +1,124 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef PANELLISTPANEL_H
+#define PANELLISTPANEL_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <utllinkedlist.h>
+#include <utlvector.h>
+#include <vgui/VGUI.h>
+#include <vgui_controls/EditablePanel.h>
+
+class KeyValues;
+
+namespace vgui
+{
+
+//-----------------------------------------------------------------------------
+// Purpose: A list of variable height child panels
+// each list item consists of a label-panel pair. Height of the item is
+// determined from the lable.
+//-----------------------------------------------------------------------------
+class PanelListPanel : public EditablePanel
+{
+ DECLARE_CLASS_SIMPLE( PanelListPanel, Panel );
+
+public:
+ PanelListPanel( vgui::Panel *parent, char const *panelName );
+ ~PanelListPanel();
+
+ // DATA & ROW HANDLING
+ // The list now owns the panel
+ virtual int AddItem( Panel *labelPanel, Panel *panel );
+ int GetItemCount() const;
+ int GetItemIDFromRow( int nRow ) const;
+
+ // Iteration. Use these until they return InvalidItemID to iterate all the items.
+ int FirstItem() const;
+ int NextItem( int nItemID ) const;
+ int InvalidItemID() const;
+
+ virtual Panel *GetItemLabel(int itemID);
+ virtual Panel *GetItemPanel(int itemID);
+
+ ScrollBar* GetScrollbar() { return m_vbar; }
+
+ virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
+ virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items
+ void RemoveAll();
+
+ // painting
+ virtual vgui::Panel *GetCellRenderer( int row );
+
+ // layout
+ void SetFirstColumnWidth( int width );
+ int GetFirstColumnWidth();
+ void SetNumColumns( int iNumColumns );
+ int GetNumColumns( void );
+ void MoveScrollBarToTop();
+
+ // selection
+ void SetSelectedPanel( Panel *panel );
+ Panel *GetSelectedPanel();
+ /*
+ On a panel being selected, a message gets sent to it
+ "PanelSelected" int "state"
+ where state is 1 on selection, 0 on deselection
+ */
+
+ void SetVerticalBufferPixels( int buffer );
+
+ void ScrollToItem( int itemNumber );
+
+ CUtlVector< int > *GetSortedVector( void )
+ {
+ return &m_SortedItems;
+ }
+
+protected:
+ // overrides
+ virtual void OnSizeChanged(int wide, int tall);
+ MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
+ virtual void PerformLayout();
+ virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
+ virtual void OnMouseWheeled(int delta);
+
+private:
+ int ComputeVPixelsNeeded();
+
+ enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
+
+ typedef struct dataitem_s
+ {
+ // Always store a panel pointer
+ Panel *panel;
+ Panel *labelPanel;
+ } DATAITEM;
+
+ // list of the column headers
+
+ CUtlLinkedList<DATAITEM, int> m_DataItems;
+ CUtlVector<int> m_SortedItems;
+
+ ScrollBar *m_vbar;
+ Panel *m_pPanelEmbedded;
+
+ PHandle m_hSelectedItem;
+ int m_iFirstColumnWidth;
+ int m_iNumColumns;
+ int m_iDefaultHeight;
+ int m_iPanelBuffer;
+
+ CPanelAnimationVar( bool, m_bAutoHideScrollbar, "autohide_scrollbar", "0" );
+};
+
+}
+#endif // PANELLISTPANEL_H
|