Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
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.

97 lines
2.3 KiB

9 years ago
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#ifndef VOICE_LISTBOX_H
3 years ago
#define VOICE_LISTBOX_H
9 years ago
#include "VGUI_Panel.h"
#include "VGUI_IntChangeSignal.h"
#include "vgui_slider2.h"
#include "vgui_scrollbar2.h"
9 years ago
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();
9 years ago
void Init();
void Term();
9 years ago
// 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 );
9 years ago
// Get the number of items currently in the listbox.
int GetNumItems();
9 years ago
// Get the width that listbox items will be set to (this changes if you resize the listbox).
int GetItemWidth();
9 years ago
// Get/set the scrollbar position (position says which element is at the top of the listbox).
int GetScrollPos();
void SetScrollPos( int pos );
9 years ago
// sets the last item the listbox should scroll to
// scroll to GetNumItems() if not set
void SetScrollRange( int maxScroll );
9 years ago
// returns the maximum value the scrollbar can scroll to
int GetScrollMax();
9 years ago
// vgui overrides.
virtual void setPos( int x, int y );
virtual void setSize( int wide, int tall );
virtual void setPixelScroll( int value );
9 years ago
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 )
9 years ago
{
m_pListBox->setPixelScroll( -value );
9 years ago
}
vgui::CListBox *m_pListBox;
};
void InternalLayout();
9 years ago
// All the items..
LBItem m_Items;
9 years ago
Panel m_ItemsPanel;
9 years ago
int m_ItemOffset; // where we're scrolled to
Slider2 m_Slider;
ScrollBar2 m_ScrollBar;
9 years ago
ListBoxSignal m_Signal;
int m_iScrollMax;
9 years ago
};
}
#endif // VOICE_LISTBOX_H