VGUI PanelListPanel: Difference between revisions
Jump to navigation
Jump to search
m (Vgui PanelListPanel moved to VGUI PanelListPanel) |
No edit summary |
||
Line 17: | Line 17: | ||
Once we have our PanelListPanel created, we can add controls to it in our ApplySchemeSettings function. Heres the ApplySchemeSettings function for the skeleton PanelListPanel displayed in the image to the right: | Once we have our PanelListPanel created, we can add controls to it in our ApplySchemeSettings function. Heres the ApplySchemeSettings function for the skeleton PanelListPanel displayed in the image to the right: | ||
void | void CExample::ApplySchemeSettings( vgui::IScheme *pScheme ) | ||
{ | { | ||
BaseClass::ApplySchemeSettings( pScheme ); | BaseClass::ApplySchemeSettings( pScheme ); | ||
Line 45: | Line 45: | ||
Lastly we'll set the control size. | Lastly we'll set the control size. | ||
void | void CExample::PerformLayout() | ||
{ | { | ||
BaseClass::PerformLayout(); | BaseClass::PerformLayout(); |
Revision as of 22:19, 6 June 2009
A PanelListPanel is a vgui2 element defined in the vgui_controls library, in the file PanelListPanel.cpp. PanelListPanels are available in all source games. PanelListPanels display a list of user specified label, control pairs.
Example Usage
Before creating anything, we first need to include the PanelListPanel header file.
#include <vgui_controls/PanelListPanel.h>
PanelListPanels can be created via the c++ keyword new with a simple call to PanelListPanel.
vgui::PanelListPanel* myPanel = new PanelListPanel(this, "myPanel");
Once we have our PanelListPanel created, we can add controls to it in our ApplySchemeSettings function. Heres the ApplySchemeSettings function for the skeleton PanelListPanel displayed in the image to the right:
void CExample::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); char buffer [40]; for (int i = 0; i < 5; i++) { //Create Image Q_snprintf(buffer, sizeof(buffer), "image%i", i); vgui::ImagePanel* imagePanel = new ImagePanel( this, buffer ); imagePanel->SetImage(scheme()->GetImage("", false)); //Create Label Q_snprintf(buffer, sizeof(buffer), "label%i", i); vgui::Label* label = new Label( this, buffer, buffer ); label->SetText(buffer); //Add Label and Image to PanelListPanel m_pList->AddItem(label, imagePanel); } m_pList->SetVisible( true ); }
With m_pList being a pointer to the PanelListPanel.
Lastly we'll set the control size.
void CExample::PerformLayout() { BaseClass::PerformLayout(); m_pList->SetBounds( 280, 300, 200, 200 ); //posX, posY, width, height }
And we're done!