2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 01:47:45 +01:00
hlsdk-xash3d/game_shared/vgui_listbox.h

97 lines
2.3 KiB
C
Raw Normal View History

//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
2016-06-04 15:24:23 +02:00
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#ifndef VOICE_LISTBOX_H
2021-06-20 00:53:07 +02:00
#define VOICE_LISTBOX_H
2016-06-04 15:24:23 +02:00
#include "VGUI_Panel.h"
#include "VGUI_IntChangeSignal.h"
#include "vgui_slider2.h"
#include "vgui_scrollbar2.h"
2016-06-04 15:24:23 +02:00
namespace vgui
{
// Listbox class used by voice code. Based off of vgui's list panel but with some modifications:
// - This listbox clips its child items to its rectangle.
// - You can access things like the scrollbar and find out the item width.
// - The scrollbar scrolls one element at a time and the range is correct.
// Note: this listbox does not provide notification when items are
class CListBox : public Panel
{
public:
CListBox();
~CListBox();
2016-06-04 15:24:23 +02:00
void Init();
void Term();
2016-06-04 15:24:23 +02:00
// Add an item to the listbox. This automatically sets the item's parent to the listbox
// and resizes the item's width to fit within the listbox.
void AddItem( Panel *pPanel );
2016-06-04 15:24:23 +02:00
// Get the number of items currently in the listbox.
int GetNumItems();
2016-06-04 15:24:23 +02:00
// Get the width that listbox items will be set to (this changes if you resize the listbox).
int GetItemWidth();
2016-06-04 15:24:23 +02:00
// Get/set the scrollbar position (position says which element is at the top of the listbox).
int GetScrollPos();
void SetScrollPos( int pos );
2016-06-04 15:24:23 +02:00
// sets the last item the listbox should scroll to
// scroll to GetNumItems() if not set
void SetScrollRange( int maxScroll );
2016-06-04 15:24:23 +02:00
// returns the maximum value the scrollbar can scroll to
int GetScrollMax();
2016-06-04 15:24:23 +02:00
// vgui overrides.
virtual void setPos( int x, int y );
virtual void setSize( int wide, int tall );
virtual void setPixelScroll( int value );
2016-06-04 15:24:23 +02:00
virtual void paintBackground();
protected:
class LBItem
{
public:
Panel *m_pPanel;
LBItem *m_pPrev, *m_pNext;
};
class ListBoxSignal : public IntChangeSignal
{
public:
void intChanged( int value, Panel *panel )
2016-06-04 15:24:23 +02:00
{
m_pListBox->setPixelScroll( -value );
2016-06-04 15:24:23 +02:00
}
vgui::CListBox *m_pListBox;
};
void InternalLayout();
2016-06-04 15:24:23 +02:00
// All the items..
LBItem m_Items;
2016-06-04 15:24:23 +02:00
Panel m_ItemsPanel;
2016-06-04 15:24:23 +02:00
int m_ItemOffset; // where we're scrolled to
Slider2 m_Slider;
ScrollBar2 m_ScrollBar;
2016-06-04 15:24:23 +02:00
ListBoxSignal m_Signal;
int m_iScrollMax;
2016-06-04 15:24:23 +02:00
};
}
#endif // VOICE_LISTBOX_H