diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/vgui_panel_zoo | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/vgui_panel_zoo')
62 files changed, 6510 insertions, 0 deletions
diff --git a/utils/vgui_panel_zoo/AnimatingImagePanelDemo.cpp b/utils/vgui_panel_zoo/AnimatingImagePanelDemo.cpp new file mode 100644 index 0000000..9f70f8c --- /dev/null +++ b/utils/vgui_panel_zoo/AnimatingImagePanelDemo.cpp @@ -0,0 +1,62 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/Controls.h> +#include <vgui/IScheme.h> +#include <vgui_controls/AnimatingImagePanel.h> +#include <vgui/IImage.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// An AnimatingImagePanel is a panel class that handles drawing of Animated Images and gives +// them all kinds of panel features. +//----------------------------------------------------------------------------- +class AnimatingImagePanelDemo: public DemoPage +{ + public: + AnimatingImagePanelDemo(Panel *parent, const char *name); + ~AnimatingImagePanelDemo(); + + private: + AnimatingImagePanel *m_pAnimImagePanel; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +AnimatingImagePanelDemo::AnimatingImagePanelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create an Animating Image Panel + m_pAnimImagePanel = new AnimatingImagePanel(this, "AnAnimatingImagePanel"); + + // Each image file is named c1, c2, c3... c20, one image for each frame of the animation. + // This loads the 20 images in to the Animation class. + m_pAnimImagePanel->LoadAnimation("resource\\steam\\c", 20); + + // Set the position + m_pAnimImagePanel->SetPos(100, 100); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +AnimatingImagePanelDemo::~AnimatingImagePanelDemo() +{ +} + + + +Panel* AnimatingImagePanelDemo_Create(Panel *parent) +{ + return new AnimatingImagePanelDemo(parent, "AnimatingImagePanelDemo"); +} + diff --git a/utils/vgui_panel_zoo/ButtonDemo.cpp b/utils/vgui_panel_zoo/ButtonDemo.cpp new file mode 100644 index 0000000..e0baa40 --- /dev/null +++ b/utils/vgui_panel_zoo/ButtonDemo.cpp @@ -0,0 +1,81 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> +#include <Keyvalues.h> +#include <vgui_controls/Button.h> + + +using namespace vgui; + + +class ButtonDemo: public DemoPage +{ + public: + ButtonDemo(Panel *parent, const char *name); + ~ButtonDemo(); + + void OnButtonClicked(); + + private: + Button *m_pButton; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ButtonDemo::ButtonDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a button. + m_pButton = new Button(this, "AButton", "ClickMe"); + + // Set its position. + m_pButton->SetPos(100, 100); + + // Install a command that will be executed when the button is pressed + // Here we use a KeyValues command, this is mapped using the Message map + // below to a function. + m_pButton->SetCommand(new KeyValues ("ButtonClicked")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ButtonDemo::~ButtonDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void ButtonDemo::OnButtonClicked() +{ + ivgui()->DPrintf("Button was clicked.\n"); +} + + + +MessageMapItem_t ButtonDemo::m_MessageMap[] = +{ + MAP_MESSAGE( ButtonDemo, "ButtonClicked", OnButtonClicked ), +}; + +IMPLEMENT_PANELMAP(ButtonDemo, DemoPage); + + + +Panel* ButtonDemo_Create(Panel *parent) +{ + return new ButtonDemo(parent, "ButtonDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ButtonDemo2.cpp b/utils/vgui_panel_zoo/ButtonDemo2.cpp new file mode 100644 index 0000000..918ea8f --- /dev/null +++ b/utils/vgui_panel_zoo/ButtonDemo2.cpp @@ -0,0 +1,80 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> +#include <Keyvalues.h> +#include <vgui_controls/Button.h> + + +using namespace vgui; + + +class ButtonDemo2: public DemoPage +{ + public: + ButtonDemo2(Panel *parent, const char *name); + ~ButtonDemo2(); + + void OnCommand(const char *command); + + private: + Button *m_pButton; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ButtonDemo2::ButtonDemo2(Panel *parent, const char *name) : DemoPage(parent, name) +{ + SetPos(0,80); + int wide, tall; + GetParent()->GetSize(wide, tall); + SetSize (wide, tall - 80); + + // Create a button. + m_pButton = new Button(this, "AButton", "ClickMe"); + + // Set its position. + m_pButton->SetPos(100, 100); + + // Install a command that will be executed when the button is pressed + // Here we use a string command. Panels recieve string commands through + // a command message map, already implemented in the Panel class. + // the onCommand function parses the command string + // and takes the appropriate action. + m_pButton->SetCommand("ButtonClicked"); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ButtonDemo2::~ButtonDemo2() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void ButtonDemo2::OnCommand(const char *command) +{ + if (!strcmp(command, "ButtonClicked") ) + { + ivgui()->DPrintf("Button was clicked.\n"); + } +} + + + +Panel* ButtonDemo2_Create(Panel *parent) +{ + return new ButtonDemo2(parent, "ButtonDemo2"); +} + + diff --git a/utils/vgui_panel_zoo/CControlCatalog.cpp b/utils/vgui_panel_zoo/CControlCatalog.cpp new file mode 100644 index 0000000..831ba60 --- /dev/null +++ b/utils/vgui_panel_zoo/CControlCatalog.cpp @@ -0,0 +1,187 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + + +#include "CControlCatalog.h" +#include "stdio.h" + +#include <vgui/ISurface.h> +#include "vgui_controls/Controls.h" +#include "tier1/KeyValues.h" + +#include <vgui_controls/Label.h> +#include <vgui_controls/ComboBox.h> + +#include "vgui/IVGui.h" // for dprinf statements + +#include "filesystem.h" + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CControlCatalog::CControlCatalog(): Frame(NULL, "PanelZoo") +{ + SetTitle("VGUI SDK Sample Application", true); + // calculate defaults + int x, y, wide, tall; + vgui::surface()->GetScreenSize(wide, tall); + + int dwide, dtall; + dwide = 535; + dtall = 405; + x = (int)((wide - dwide) * 0.5); + y = (int)((tall - dtall) * 0.5); + SetBounds (x, y, dwide, dtall); + + // Add all demos to the panel list + + // These are SDK control display demos + m_PanelList.AddToTail(SampleButtons_Create(this)); + m_PanelList.AddToTail(SampleMenus_Create(this)); + m_PanelList.AddToTail(SampleDropDowns_Create(this)); + m_PanelList.AddToTail(SampleListPanelColumns_Create(this)); + m_PanelList.AddToTail(SampleListPanelCats_Create(this)); + m_PanelList.AddToTail(SampleListPanelBoth_Create(this)); + m_PanelList.AddToTail(SampleRadioButtons_Create(this)); + m_PanelList.AddToTail(SampleCheckButtons_Create(this)); + m_PanelList.AddToTail(SampleTabs_Create(this)); + m_PanelList.AddToTail(SampleEditFields_Create(this)); + m_PanelList.AddToTail(SampleSliders_Create(this)); + m_PanelList.AddToTail(DefaultColors_Create(this)); + + // These are panel zoo demos + // These have commented source files with a step by step + // of how to make and use each control + // They will have resource file attributes eventually. + m_PanelList.AddToTail(ImageDemo_Create(this)); + m_PanelList.AddToTail(ImagePanelDemo_Create(this)); + m_PanelList.AddToTail(TextImageDemo_Create(this)); + m_PanelList.AddToTail(LabelDemo_Create(this)); + m_PanelList.AddToTail(Label2Demo_Create(this)); + m_PanelList.AddToTail(TextEntryDemo_Create(this)); + m_PanelList.AddToTail(TextEntryDemo2_Create(this)); + m_PanelList.AddToTail(TextEntryDemo3_Create(this)); + m_PanelList.AddToTail(TextEntryDemo4_Create(this)); + m_PanelList.AddToTail(TextEntryDemo5_Create(this)); + m_PanelList.AddToTail(ButtonDemo_Create(this)); + m_PanelList.AddToTail(ButtonDemo2_Create(this)); + m_PanelList.AddToTail(CheckButtonDemo_Create(this)); + m_PanelList.AddToTail(ToggleButtonDemo_Create(this)); + m_PanelList.AddToTail(RadioButtonDemo_Create(this)); + m_PanelList.AddToTail(MenuDemo_Create(this)); + m_PanelList.AddToTail(MenuDemo2_Create(this)); + m_PanelList.AddToTail(CascadingMenuDemo_Create(this)); + m_PanelList.AddToTail(MessageBoxDemo_Create(this)); + m_PanelList.AddToTail(QueryBoxDemo_Create(this)); + m_PanelList.AddToTail(ComboBoxDemo_Create(this)); + m_PanelList.AddToTail(ComboBox2Demo_Create(this)); + m_PanelList.AddToTail(FrameDemo_Create(this)); + m_PanelList.AddToTail(ProgressBarDemo_Create(this)); + m_PanelList.AddToTail(ScrollBarDemo_Create(this)); + m_PanelList.AddToTail(ScrollBar2Demo_Create(this)); + m_PanelList.AddToTail(EditablePanelDemo_Create(this)); + m_PanelList.AddToTail(EditablePanel2Demo_Create(this)); + m_PanelList.AddToTail(ListPanelDemo_Create(this)); + m_PanelList.AddToTail(TooltipsDemo_Create(this)); + m_PanelList.AddToTail(AnimatingImagePanelDemo_Create(this)); + m_PanelList.AddToTail(WizardPanelDemo_Create(this)); + m_PanelList.AddToTail(FileOpenDemo_Create(this)); + m_PanelList.AddToTail(HTMLDemo_Create(this)); + m_PanelList.AddToTail(HTMLDemo2_Create(this)); + m_PanelList.AddToTail(MenuBarDemo_Create(this)); + + + m_pSelectControl = new ComboBox(this, "ControlSelect", 10, false); + + // Position the box. + m_pSelectControl->SetPos(90, 50); + + // Set the width of the Combo box so any element selected will display nicely. + m_pSelectControl->SetWide(180); + + CUtlRBTree< char const *, int > sorted( 0, 0, CaselessStringLessThan ); + + int i; + for ( i = 0; i < m_PanelList.Size(); i++) + { + sorted.Insert( m_PanelList[i]->GetName() ); + } + + // Add text selections to the menu list + // These are the names of the panels in the panel list + for ( i = sorted.FirstInorder() ; i != sorted.InvalidIndex(); i = sorted.NextInorder( i ) ) + { + m_pSelectControl->AddItem( sorted[ i ], NULL); + } + + m_pSelectControl->ActivateItem(0); + m_pPrevPanel = m_PanelList[0]; + + m_pCategoryLabel = new Label (this, "CategoryLabel", "Category"); + m_pCategoryLabel->GetContentSize(wide, tall); + m_pCategoryLabel->SetSize(wide + Label::Content/2, tall + Label::Content/2); + m_pCategoryLabel->SetPos(27, 50); +} + + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CControlCatalog::~CControlCatalog() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Handles closing of the dialog - shuts down the whole app +//----------------------------------------------------------------------------- +void CControlCatalog::OnClose() +{ + Frame::OnClose(); + + // stop vgui running + vgui::ivgui()->Stop(); +} + + +//----------------------------------------------------------------------------- +// Purpose: Checks to see if any text in the combobox has changed +//----------------------------------------------------------------------------- +void CControlCatalog::OnTextChanged() +{ + char buf[40]; + m_pSelectControl->GetText(buf, sizeof( buf )); + + m_pPrevPanel->SetVisible(false); + + for (int i = 0; i < m_PanelList.Size(); i++) + { + if (!strcmp(buf, m_PanelList[i]->GetName())) + { + m_PanelList[i]->SetVisible(true); + m_pPrevPanel = m_PanelList[i]; + break; + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t CControlCatalog::m_MessageMap[] = +{ + MAP_MESSAGE( CControlCatalog, "TextChanged", OnTextChanged ), // message from the text entry +}; + +IMPLEMENT_PANELMAP(CControlCatalog, Frame); + + + + diff --git a/utils/vgui_panel_zoo/CControlCatalog.h b/utils/vgui_panel_zoo/CControlCatalog.h new file mode 100644 index 0000000..2730d12 --- /dev/null +++ b/utils/vgui_panel_zoo/CControlCatalog.h @@ -0,0 +1,109 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + + +#ifndef CControlCatalog_H +#define CControlCatalog_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Frame.h> +#include <utlvector.h> + +namespace vgui +{ + class ComboBox; + class Label; +}; + +using namespace vgui; + +Panel* ImageDemo_Create(Panel *parent); +Panel* ImagePanelDemo_Create(Panel *parent); +Panel* TextImageDemo_Create(Panel *parent); +Panel* LabelDemo_Create(Panel *parent); +Panel* Label2Demo_Create(Panel *parent); +Panel* TextEntryDemo_Create(Panel *parent); +Panel* TextEntryDemo2_Create(Panel *parent); +Panel* TextEntryDemo3_Create(Panel *parent); +Panel* TextEntryDemo4_Create(Panel *parent); +Panel* TextEntryDemo5_Create(Panel *parent); + +Panel* MenuDemo_Create(Panel *parent); +Panel* MenuDemo2_Create(Panel *parent); +Panel* CascadingMenuDemo_Create(Panel *parent); + +Panel* ButtonDemo_Create(Panel *parent); +Panel* ButtonDemo2_Create(Panel *parent); +Panel* CheckButtonDemo_Create(Panel *parent); +Panel* ToggleButtonDemo_Create(Panel *parent); +Panel* RadioButtonDemo_Create(Panel *parent); + +Panel* MessageBoxDemo_Create(Panel *parent); +Panel* QueryBoxDemo_Create(Panel *parent); +Panel* ComboBoxDemo_Create(Panel *parent); +Panel* ComboBox2Demo_Create(Panel *parent); + +Panel* FrameDemo_Create(Panel *parent); +Panel* ProgressBarDemo_Create(Panel *parent); +Panel* ScrollBarDemo_Create(Panel *parent); +Panel* ScrollBar2Demo_Create(Panel *parent); + +Panel* EditablePanelDemo_Create(Panel *parent); +Panel* EditablePanel2Demo_Create(Panel *parent); + +Panel* ListPanelDemo_Create(Panel *parent); + +Panel* TooltipsDemo_Create(Panel *parent); +Panel* AnimatingImagePanelDemo_Create(Panel *parent); +Panel* WizardPanelDemo_Create(Panel *parent); +Panel* FileOpenDemo_Create(Panel *parent); + + +Panel* SampleButtons_Create(Panel *parent); +Panel* SampleMenus_Create(Panel *parent); +Panel* SampleDropDowns_Create(Panel *parent); +Panel* SampleListPanelColumns_Create(Panel *parent); +Panel* SampleListPanelCats_Create(Panel *parent); +Panel* SampleListPanelBoth_Create(Panel *parent); +Panel* SampleRadioButtons_Create(Panel *parent); +Panel* SampleCheckButtons_Create(Panel *parent); +Panel* SampleTabs_Create(Panel *parent); +Panel* SampleEditFields_Create(Panel *parent); +Panel* SampleSliders_Create(Panel *parent); +Panel* DefaultColors_Create(Panel *parent); + +Panel* HTMLDemo_Create(Panel *parent); +Panel* HTMLDemo2_Create(Panel *parent); + +Panel* MenuBarDemo_Create(Panel *parent); + +class CControlCatalog: public Frame +{ +public: + CControlCatalog(); + ~CControlCatalog(); + + void OnClose(); + +private: + + void OnTextChanged(); + + ComboBox *m_pSelectControl; + CUtlVector<Panel *> m_PanelList; + Panel * m_pPrevPanel; + Label *m_pCategoryLabel; + + DECLARE_PANELMAP(); +}; + +#endif // CControlCatalog_H + + diff --git a/utils/vgui_panel_zoo/CascadingMenu.cpp b/utils/vgui_panel_zoo/CascadingMenu.cpp new file mode 100644 index 0000000..3881823 --- /dev/null +++ b/utils/vgui_panel_zoo/CascadingMenu.cpp @@ -0,0 +1,208 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Menu.h> +#include <vgui_controls/MenuButton.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + + + +using namespace vgui; + + +class CascadingMenuDemo: public DemoPage +{ + public: + CascadingMenuDemo(Panel *parent, const char *name); + ~CascadingMenuDemo(); + void InitMenus(); + + // Functions that are executed in response to selecting ] + // menu items. + void OnMaggie(); + void OnHomer(); + void OnMarcia(); + void OnJohn(); + void OnRed(); + + private: + + MenuButton *m_pOuterMenuButton; + Menu *m_pOuterMenu; + MenuButton *m_pInnerMenuButton; + Menu *m_pInnerMenu; + Menu *m_pInnerMenu2; + Menu *m_pDeepestMenu; + DECLARE_PANELMAP(); + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CascadingMenuDemo::CascadingMenuDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + InitMenus(); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CascadingMenuDemo::~CascadingMenuDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Create cascading menus. +// We will create a Menu with 2 Menus inside it, and yet another Menu inside one of those! +//----------------------------------------------------------------------------- +void CascadingMenuDemo::InitMenus() +{ + // A drop down menu button for the top most menu + m_pOuterMenuButton = new MenuButton(this, "OuterMenu", "Click to open menu"); + + // Size the Button so we can read its label. + m_pOuterMenuButton->SizeToContents(); + int wide, tall; + m_pOuterMenuButton->GetContentSize(wide, tall); + m_pOuterMenuButton->SetSize(wide + Label::Content, tall + Label::Content); + + + // Create the Menu to go with it. + m_pOuterMenu = new Menu(m_pOuterMenuButton, "OuterMenu"); + + // Add the menu items to this menu + m_pOuterMenu->AddMenuItem("&Homer", new KeyValues ("Homer"), this); + m_pOuterMenu->AddMenuItem("&Apu", new KeyValues ("Apu"), this); + m_pOuterMenu->AddMenuItem("&Bart", new KeyValues ("Bart"), this); + m_pOuterMenu->AddMenuItem("Lisa", new KeyValues ("Lisa"), this); + m_pOuterMenu->AddMenuItem("&George", new KeyValues ("George"), this); + m_pOuterMenu->AddMenuItem("&Marge", new KeyValues ("Marge"), this); + m_pOuterMenu->AddMenuItem("Maggi&e", new KeyValues ("Maggie"), this); + m_pOuterMenu->SetVisible(false); + + // Make the number of visible menu items 20 + m_pOuterMenu->SetNumberOfVisibleItems(20); + + // Attach this menu to the menu button + m_pOuterMenuButton->SetMenu(m_pOuterMenu); + + // Position the menu button on screen. + int x, y, dwide, dtall; + GetBounds (x, y, dwide, dtall); + m_pOuterMenuButton->SetPos(10, dtall/2); + + // Create cascading menu #1 + // Cascading menu's don't need menu buttons, as they are triggered + // by selecting the menu item of the menu they are in. + m_pInnerMenu = new Menu(m_pOuterMenu, "InnerMenu"); + + // Add menu items to this menu. + m_pInnerMenu->AddMenuItem("Marcia", new KeyValues ("Marcia"), this); + m_pInnerMenu->AddMenuItem("Greg", new KeyValues ("Greg"), this); + m_pInnerMenu->AddMenuItem("&Peter", new KeyValues ("Peter"), this); + m_pInnerMenu->AddMenuItem("AliceWithALongName", new KeyValues ("Alice"), this); + m_pInnerMenu->AddMenuItem("&Carol", new KeyValues ("Carol"), this); + m_pInnerMenu->AddMenuItem("&Tiger", new KeyValues ("Tiger"), this); + m_pInnerMenu->AddMenuItem("&Sam", new KeyValues ("Sam"), this); + m_pInnerMenu->AddMenuItem("&Bobby", new KeyValues ("Bobby"), this); + m_pInnerMenu->AddMenuItem("Cindy", new KeyValues ("Cindy"), this); + m_pInnerMenu->SetVisible(false); + // Now add the cascading menu to the top menu as a menu item! + m_pOuterMenu->AddCascadingMenuItem("InnerMenu", this, m_pInnerMenu); + + // Create cascading menu #2 + m_pInnerMenu2 = new Menu(m_pOuterMenu, "InnerMenu2"); + m_pInnerMenu2->AddMenuItem("John", new KeyValues ("John"), this); + m_pInnerMenu2->AddMenuItem("Paul", new KeyValues ("Paul"), this); + m_pInnerMenu2->AddMenuItem("Ringo", new KeyValues ("Ringo"), this); + m_pInnerMenu2->AddMenuItem("George", new KeyValues ("George"), this); + m_pInnerMenu2->AddMenuItem("Magical", new KeyValues ("Magical"), this); + m_pInnerMenu2->AddMenuItem("Mystery", new KeyValues ("Mystery"), this); + m_pInnerMenu2->AddMenuItem("Tour", new KeyValues ("Tour"), this); + m_pInnerMenu2->AddMenuItem("Yellow Sub", new KeyValues ("Yellow Sub"), this); + m_pInnerMenu2->SetVisible(false); + + // Add this cascading menu to the top menu as a manu item. + m_pOuterMenu->AddCascadingMenuItem("InnerMenu2", this, m_pInnerMenu2); + + + // Finally, a cascading menu inside a cascading menu! + m_pDeepestMenu = new Menu(m_pInnerMenu, "DeepestMenu"); + + // Add menu items to this menu. + m_pDeepestMenu->AddMenuItem("Red", new KeyValues ("Red"), this); + m_pDeepestMenu->AddMenuItem("Orange", new KeyValues ("Orange"), this); + m_pDeepestMenu->AddMenuItem("Yellow", new KeyValues ("Yellow"), this); + m_pDeepestMenu->AddMenuItem("Green", new KeyValues ("Green"), this); + m_pDeepestMenu->AddMenuItem("Blue", new KeyValues ("Blue"), this); + m_pDeepestMenu->AddMenuItem("Indigo", new KeyValues ("Indigo"), this); + m_pDeepestMenu->AddMenuItem("Purple", new KeyValues ("Purple"), this); + m_pDeepestMenu->AddMenuItem("Yellow Sun", new KeyValues ("Yellow Sun"), this); + m_pDeepestMenu->SetVisible(false); + + // Set the number of visible items in the menu to 4, this menu will have a scrollbar. + m_pDeepestMenu->SetNumberOfVisibleItems(4); + + // Add this menu item to one of the other menus already in the top most menu above + m_pInnerMenu->AddCascadingMenuItem("DeepestMenu", this, m_pDeepestMenu); + +} + +// Messages recieved from each of the menus, prints out when message is recieved +void CascadingMenuDemo::OnMaggie() +{ + ivgui()->DPrintf("Maggie selected.\n"); +} + +void CascadingMenuDemo::OnMarcia() +{ + ivgui()->DPrintf("Marcia selected.\n"); +} + +void CascadingMenuDemo::OnJohn() +{ + ivgui()->DPrintf("John selected.\n"); +} + +void CascadingMenuDemo::OnRed() +{ + ivgui()->DPrintf("Red selected.\n"); +} + +void CascadingMenuDemo::OnHomer() +{ + ivgui()->DPrintf("Homer selected.\n"); +} + + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t CascadingMenuDemo::m_MessageMap[] = +{ + MAP_MESSAGE( CascadingMenuDemo, "Maggie", OnMaggie ), // from outermenu + MAP_MESSAGE( CascadingMenuDemo, "Homer", OnHomer ), // from outermenu + MAP_MESSAGE( CascadingMenuDemo, "Marcia", OnMarcia ), // from innermenu2 + MAP_MESSAGE( CascadingMenuDemo, "John", OnJohn ), // from innermenu2 + MAP_MESSAGE( CascadingMenuDemo, "Red", OnRed ), // from deepest menu + +}; + +IMPLEMENT_PANELMAP(CascadingMenuDemo, DemoPage); + + +Panel* CascadingMenuDemo_Create(Panel *parent) +{ + return new CascadingMenuDemo(parent, "CascadingMenuDemo"); +} + + diff --git a/utils/vgui_panel_zoo/CheckButtonDemo.cpp b/utils/vgui_panel_zoo/CheckButtonDemo.cpp new file mode 100644 index 0000000..e9ab29a --- /dev/null +++ b/utils/vgui_panel_zoo/CheckButtonDemo.cpp @@ -0,0 +1,141 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/CheckButton.h> + + +using namespace vgui; + + +class CheckButtonDemo: public DemoPage +{ + public: + CheckButtonDemo(Panel *parent, const char *name); + ~CheckButtonDemo(); + + void OnCheckButton1Checked(); + void OnCheckButton2Checked(); + + + private: + CheckButton *m_pCheckButton1; + CheckButton *m_pCheckButton2; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CheckButtonDemo::CheckButtonDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + SetBorder(NULL); + + // Check buttons are a little checkable box with a label attached. + // You can have as many check buttons checked at one time as you want. + + // Create a check button. + m_pCheckButton1 = new CheckButton(this, "ACheckButton", "ClickMe"); + + // Set its position. + m_pCheckButton1->SetPos(100, 100); + + // A little label for our button + m_pCheckButton1->SetText("Click the check button!"); + + // Size the label so the message fits nicely. + m_pCheckButton1->SizeToContents(); + + // Start the button off checked. Its unchecked by default. + m_pCheckButton1->SetSelected(true); + + // Check buttons are Buttons, and can send a command when clicked. + // Install a command to be sent when the box is checked or unchecked + m_pCheckButton1->SetCommand(new KeyValues("Check1")); + + + + // Create another check button. + m_pCheckButton2 = new CheckButton(this, "AnotherCheckButton", "ClickMe"); + + // Set its position. + m_pCheckButton2->SetPos(100, 120); + + // A little label for our button + m_pCheckButton2->SetText("Click the other check button!"); + + // Size the label so the message fits nicely. + m_pCheckButton2->SizeToContents(); + + // Install a command to be sent when the box is checked or unchecked + m_pCheckButton2->SetCommand(new KeyValues("Check2")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CheckButtonDemo::~CheckButtonDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void CheckButtonDemo::OnCheckButton1Checked() +{ + if (m_pCheckButton1->IsSelected()) + { + ivgui()->DPrintf("Check box one is checked.\n"); + } + else + { + ivgui()->DPrintf("Check box one is unchecked.\n"); + } + +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void CheckButtonDemo::OnCheckButton2Checked() +{ + if (m_pCheckButton2->IsSelected()) + { + ivgui()->DPrintf("Check box two is checked.\n"); + } + else + { + ivgui()->DPrintf("Check box two is unchecked.\n"); + } +} + + + + +MessageMapItem_t CheckButtonDemo::m_MessageMap[] = +{ + MAP_MESSAGE( CheckButtonDemo, "Check1", OnCheckButton1Checked ), + MAP_MESSAGE( CheckButtonDemo, "Check2", OnCheckButton2Checked ), +}; + +IMPLEMENT_PANELMAP(CheckButtonDemo, DemoPage); + + + +Panel* CheckButtonDemo_Create(Panel *parent) +{ + return new CheckButtonDemo(parent, "CheckButtonDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ComboBox2.cpp b/utils/vgui_panel_zoo/ComboBox2.cpp new file mode 100644 index 0000000..12916a2 --- /dev/null +++ b/utils/vgui_panel_zoo/ComboBox2.cpp @@ -0,0 +1,136 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include "vgui_controls/Controls.h" + +#include "tier1/KeyValues.h" +#include <vgui_controls/Button.h> +#include <vgui_controls/ComboBox.h> + + +using namespace vgui; + +// Combo boxes are boxes that display text and have a menu attached. +// Selecting an item from the menu changes the displayed text in the box. + +class ComboBox2Demo: public DemoPage +{ + DECLARE_CLASS_SIMPLE( ComboBox2Demo, DemoPage ); + public: + ComboBox2Demo(Panel *parent, const char *name); + ~ComboBox2Demo(); + + void OnButtonClicked(); + void AddItemToComboBoxMenu(); + + private: + Button *m_pButton; + ComboBox *m_pComboBox; + + DECLARE_PANELMAP(); + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ComboBox2Demo::ComboBox2Demo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a new combo box. + // The first arg is the parent, the second the name + // The third arg is the number of items that will be in the menu + // In settin this arg to 4, if we add more than 4 items to the menu + // a scroll bar will be enabled. + // The fourth arg is if the box is editable or not, this time we set it to true. + m_pComboBox = new ComboBox(this, "Directions", 6, true); + + // Position the box. + m_pComboBox->SetPos(100, 100); + + // Set the width of the Combo box so any element selected will display nicely. + m_pComboBox->SetWide(150); + + // Add some text selections to the menu list + m_pComboBox->AddItem("Right", NULL ); + m_pComboBox->AddItem("Left", NULL ); + m_pComboBox->AddItem("Up", NULL ); + m_pComboBox->AddItem("Down", NULL ); + m_pComboBox->AddItem("Forward", NULL ); + m_pComboBox->AddItem("Backward", NULL ); + m_pComboBox->AddItem("Backward and really long", NULL ); + + + // Create a button. Clicking this button will send a command back to us. + // In response to this command we will get the contents of the combo box + // and add it to the list of items in the list. + m_pButton = new Button (this, "AButton", "Click to add an item name to the menu"); + + m_pButton->SizeToContents(); + m_pButton->SetPos(270, 100); + + // Install a command that will be executed when the button is pressed + m_pButton->SetCommand(new KeyValues ("ButtonClicked")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ComboBox2Demo::~ComboBox2Demo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void ComboBox2Demo::OnButtonClicked() +{ + ivgui()->DPrintf("Button was clicked.\n"); + + // Lets check out what's in the combo box and add it to the menu. + AddItemToComboBoxMenu(); +} + +void ComboBox2Demo::AddItemToComboBoxMenu() +{ + char boxText[128]; + + // Get the text from the combo box + m_pComboBox->GetText(boxText, sizeof( boxText ) ); + + // We won't add empty text strings to the menu. + if (!strcmp(boxText, "")) + return; + + // Add this item to the combo box menu + // If you wanted to check for uniqueness you would have to keep a + // list of the items in the menu and check it. + m_pComboBox->AddItem(boxText, NULL); + + // Reset the combo box to empty + m_pComboBox->SetText(""); +} + +MessageMapItem_t ComboBox2Demo::m_MessageMap[] = +{ + MAP_MESSAGE( ComboBox2Demo, "ButtonClicked", OnButtonClicked ), +}; + +IMPLEMENT_PANELMAP(ComboBox2Demo, BaseClass); + + + + +Panel* ComboBox2Demo_Create(Panel *parent) +{ + return new ComboBox2Demo(parent, "ComboBox2Demo"); +} + + diff --git a/utils/vgui_panel_zoo/ComboBoxDemo.cpp b/utils/vgui_panel_zoo/ComboBoxDemo.cpp new file mode 100644 index 0000000..5c33be1 --- /dev/null +++ b/utils/vgui_panel_zoo/ComboBoxDemo.cpp @@ -0,0 +1,79 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" + +#include "tier1/KeyValues.h" +#include <vgui_controls/ComboBox.h> + + +using namespace vgui; + +// Combo boxes are boxes that display text and have a menu attached. +// Selecting an item from the menu changes the displayed text in the box. + +class ComboBoxDemo: public DemoPage +{ +public: + ComboBoxDemo(Panel *parent, const char *name); + ~ComboBoxDemo(); + +private: + ComboBox *m_pComboBox; + + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ComboBoxDemo::ComboBoxDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a new combo box. + // The first arg is the parent, the second the name + // The third arg is the number of items that will be in the list + // The fourth arg is if the box is editable or not. + m_pComboBox = new ComboBox(this, "Directions", 6, false); + + // Position the box. + m_pComboBox->SetPos(100, 100); + + // Set the width of the Combo box so any element selected will display nicely. + m_pComboBox->SetWide(80); + + // Add text selections to the menu list + m_pComboBox->AddItem("Right", NULL ); + m_pComboBox->AddItem("Left", NULL ); + m_pComboBox->AddItem("Up", NULL ); + m_pComboBox->AddItem("Down", NULL ); + m_pComboBox->AddItem("Forward", NULL ); + m_pComboBox->AddItem("Backward", NULL ); + + // Activate the first item in the list, so our box will start out + // with a default selection. ("Right") + m_pComboBox->ActivateItem(0); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ComboBoxDemo::~ComboBoxDemo() +{ +} + + + + +Panel* ComboBoxDemo_Create(Panel *parent) +{ + return new ComboBoxDemo(parent, "ComboBoxDemo"); +} + + diff --git a/utils/vgui_panel_zoo/DefaultColors.cpp b/utils/vgui_panel_zoo/DefaultColors.cpp new file mode 100644 index 0000000..c62ef92 --- /dev/null +++ b/utils/vgui_panel_zoo/DefaultColors.cpp @@ -0,0 +1,92 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> +#include <vgui_controls/Panel.h> +#include <vgui/IScheme.h> +#include <Color.h> +#include <stdio.h> + +using namespace vgui; + +Color colors[] = { + Color(0,0,0), + Color(30, 30, 30), + Color(45, 49, 40), + Color(62, 70, 55), + Color(76, 88, 68), + Color(100, 120, 100), + Color(136, 145, 128), + Color(160, 170, 149), + Color(216, 222, 211), + Color(255, 255, 255), + Color(149, 136, 49), + Color(196, 181, 80) +}; + + + +class DefaultColors: public DemoPage +{ + public: + DefaultColors(Panel *parent, const char *name); + ~DefaultColors(); + + void Paint(); + private: + Panel *m_pColorPanel[12]; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +DefaultColors::DefaultColors(Panel *parent, const char *name) : DemoPage(parent, name) +{ + char buf[32]; + for (int i=1; i<=12; i++) + { + sprintf(buf, "ColorPanel%d", i); + m_pColorPanel[i-1] = new Panel (this, buf); + } + LoadControlSettings("Demo/DefaultColors.res"); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +DefaultColors::~DefaultColors() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: Apply settings +//----------------------------------------------------------------------------- +void DefaultColors::Paint() +{ + for (int i=0; i<12; i++) + { + IScheme *pScheme = scheme()->GetIScheme( m_pColorPanel[i]->GetScheme() ); + m_pColorPanel[i]->SetBorder(pScheme->GetBorder("DefaultBorder")); + m_pColorPanel[i]->SetBgColor(colors[i]); + } + + Panel::Paint(); +} + + +Panel* DefaultColors_Create(Panel *parent) +{ + return new DefaultColors(parent, "Default Colors"); +} + + diff --git a/utils/vgui_panel_zoo/DefaultColors.res b/utils/vgui_panel_zoo/DefaultColors.res new file mode 100644 index 0000000..0e3b557 --- /dev/null +++ b/utils/vgui_panel_zoo/DefaultColors.res @@ -0,0 +1,18 @@ +"DefaultColors" +{ + "Color1" + { + "ControlName" "Panel" + "xpos" "90" + "ypos" "25" + "wide" "35" + "tall" "35" + "autoResize" "0" + "pinCorner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "1" + "color" "0 0 0" + "tooltiptext" "r:0 g:0 b:0" + } +}
\ No newline at end of file diff --git a/utils/vgui_panel_zoo/DemoPage.cpp b/utils/vgui_panel_zoo/DemoPage.cpp new file mode 100644 index 0000000..9fa133f --- /dev/null +++ b/utils/vgui_panel_zoo/DemoPage.cpp @@ -0,0 +1,31 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +DemoPage::DemoPage(Panel *parent, const char *name) : PropertyPage(parent, name) +{ + SetPos(1,80); + int wide, tall; + GetParent()->GetSize(wide, tall); + SetSize (wide-2, tall - 81); + + SetPaintBorderEnabled(false); + SetVisible(false); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +DemoPage::~DemoPage() +{ +} diff --git a/utils/vgui_panel_zoo/DemoPage.h b/utils/vgui_panel_zoo/DemoPage.h new file mode 100644 index 0000000..0033a16 --- /dev/null +++ b/utils/vgui_panel_zoo/DemoPage.h @@ -0,0 +1,26 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include <vgui_controls/PropertyPage.h> +#include "filesystem.h" +#include <vgui_controls/Panel.h> + +#include <VGUI/IVGui.h> // for dprinf statements + +using namespace vgui; + +//----------------------------------------------------------------------------- +// This class contains the basic layout for every demo panel. +//----------------------------------------------------------------------------- +class DemoPage: public PropertyPage +{ + public: + DemoPage(Panel *parent, const char *name); + ~DemoPage(); + + private: +};
\ No newline at end of file diff --git a/utils/vgui_panel_zoo/EditablePanel2Demo.cpp b/utils/vgui_panel_zoo/EditablePanel2Demo.cpp new file mode 100644 index 0000000..111d338 --- /dev/null +++ b/utils/vgui_panel_zoo/EditablePanel2Demo.cpp @@ -0,0 +1,150 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "tier1/KeyValues.h" +#include <vgui_controls/ComboBox.h> + +using namespace vgui; + + +class EditablePanel2Demo: public DemoPage +{ + public: + EditablePanel2Demo(Panel *parent, const char *name); + ~EditablePanel2Demo(); + + private: + ComboBox *m_pInternetSpeed; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +EditablePanel2Demo::EditablePanel2Demo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Editable panels are able to have their layout described by external + // resource files. All Frames belong to the Editable Panel class. + // The class EditablePanel2Demo is a PropertyPage class, and PropertyPage + // is an EditablePanel, so we can load in a resource file for this class. + + + // Load the vgui controls from a resource file. + // The resource file looks like this: + /* EDITABLE PANEL DEMO RESOURCE FILE LAYOUT + "EditablePanelDemo" + { + "SpeedLabel" + { + "ControlName" "Label" + "fieldName" "SpeedLabel" + "xpos" "20" + "ypos" "30" + "wide" "96" + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "labelText" "Internet &Speed" + "textAlignment" "east" + "associate" "InternetSpeed" + } + "InternetSpeed" + { + "ControlName" "ComboBox" + "fieldName" "InternetSpeed" + "xpos" "124" + "ypos" "30" + "wide" "200" + "tall" "20" + "autoResize" "0" + "pinCorner" "0" + "visible" "1" + "enabled" "1" + "tabPosition" "0" + "textHidden" "0" + "editable" "0" + "maxchars" "-1" + } + } + */ + + // VGUI control panel resource values are grouped by a panel name, here + // we have 2 panels, one called "SpeedLabel" and one called + // "Internet Speed". + // Each control has a set of keyValues that describe attributes of + // the panel. SpeedLabel's control name is Label, this is a vgui Label class. + // Its 'xpos' and 'ypos' tell is position in the parent window. + // Its 'wide' and 'tall' tell its size. + // 'AutoResize' is false meaning this panel will not grow or shrink in size + // response to panel resizing. + // More panel attributes follow, until we come to 'labelText'. + // This is the text that will appear in the label. The text is + // "Internet Speed" and the ampersand (&) in front of the 'S' indicates + // that S is a hotkey in the label name. + // 'Associate' associates this label with another vgui control that will + // gain focus when the hotkey is hit. The associated control is called + // "InternetSpeed" and this panel name happens to be the very next panel in the list. + // Its 'ControlName' tells us it is a ComboBox. Hitting the 'S' hotkey will trigger + // the combo box to gain focus. Note that the combo box does not currently + // have any items within it. + + + // This will be the menu items of our combo box menu. + // List of all the different internet speeds + char *g_Speeds[] = + { + { "Modem - 14.4k"}, + { "Modem - 28.8k"}, + { "Modem - 33.6k"}, + { "Modem - 56k"}, + { "ISDN - 112k"}, + { "DSL > 256k"}, + { "LAN/T1 > 1M"}, + }; + + // Create a combo box with the name "InternetSpeed" + // The parameters of the resource file will be applied to this + // combo box. + m_pInternetSpeed = new ComboBox(this, "InternetSpeed", ARRAYSIZE(g_Speeds), false); + + // Add menu items to this combo box. + for (int i = 0; i < ARRAYSIZE(g_Speeds); i++) + { + m_pInternetSpeed->AddItem(g_Speeds[i], NULL ); + } + + // Load the resource file settings into our panel. + LoadControlSettings("Demo/EditablePanelDemo.res"); + + // When the settings are applied (in applySettings()) our panels gain the + // additional layout specified by the resource keyValues. + + // There, we are done, we have created one control from "thin air" (the Label) + // and only had to specify the menu items of the other control (the ComboBox). + // All the rest of the layout was done using the EditablePanel's smarts and + // a resource file. + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +EditablePanel2Demo::~EditablePanel2Demo() +{ +} + + + +Panel* EditablePanel2Demo_Create(Panel *parent) +{ + return new EditablePanel2Demo(parent, "EditablePanel2Demo"); +} + + diff --git a/utils/vgui_panel_zoo/EditablePanelDemo.cpp b/utils/vgui_panel_zoo/EditablePanelDemo.cpp new file mode 100644 index 0000000..fb7cfcc --- /dev/null +++ b/utils/vgui_panel_zoo/EditablePanelDemo.cpp @@ -0,0 +1,145 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" + +#include "tier1/KeyValues.h" +#include <vgui_controls/EditablePanel.h> +#include <vgui_controls/Label.h> +#include <vgui_controls/ComboBox.h> + +using namespace vgui; + +// EditablePanels are panels that can create certain vgui controls +// by using the function createControlByName() + + +class EditablePanelDemo: public DemoPage +{ + public: + EditablePanelDemo(Panel *parent, const char *name); + ~EditablePanelDemo(); + + private: + EditablePanel *m_pEditablePanel; + Label *m_pSpeedLabel; + ComboBox *m_pInternetSpeed; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +EditablePanelDemo::EditablePanelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create an EditablePanel. + m_pEditablePanel = new EditablePanel(this, "AnEditablePanel"); + + + // Set its position and size + m_pEditablePanel->SetSize(400, 200); + m_pEditablePanel->SetPos(0, 0); + + // Add a child Label panel to the EditablePanel + m_pSpeedLabel = (Label *)(m_pEditablePanel->CreateControlByName("Label")); + // Set its parent to our editable panel. + m_pSpeedLabel->SetParent(m_pEditablePanel); + // Set its Position + m_pSpeedLabel->SetPos(20, 30); + // Set its size + m_pSpeedLabel->SetSize(96,20); + // Set it not to resize with the window. + m_pSpeedLabel->SetAutoResize(PIN_TOPLEFT, AUTORESIZE_NO, 0, 0, 0, 0 ); + // Set it visible + m_pSpeedLabel->SetVisible(true); + // Set it enabled + m_pSpeedLabel->SetEnabled(true); + // Set its tab position + m_pSpeedLabel->SetTabPosition(0); + // Set the text in the label + m_pSpeedLabel->SetText("Internet &Speed"); + // Set its text alignment + m_pSpeedLabel->SetContentAlignment(Label::a_east); + + // Add another child panel to the EditablePanel, this time a ComboBox. + + // This will be the menu items of our combo box menu. + // List of all the different internet speeds + char *g_Speeds[] = + { + { "Modem - 14.4k"}, + { "Modem - 28.8k"}, + { "Modem - 33.6k"}, + { "Modem - 56k"}, + { "ISDN - 112k"}, + { "DSL > 256k"}, + { "LAN/T1 > 1M"}, + }; + + // Create the combo box using the create function + m_pInternetSpeed = (ComboBox *)(m_pEditablePanel->CreateControlByName("ComboBox")); + // Set its parent to our editable panel. + m_pInternetSpeed->SetParent(m_pEditablePanel); + // Set its position next to the label. + m_pInternetSpeed->SetPos(124, 30); + // Set its size + m_pInternetSpeed->SetSize(200, 20); + // Set it not to resize with the window. + m_pInternetSpeed->SetAutoResize(PIN_TOPLEFT, AUTORESIZE_NO, 0, 0, 0, 0 ); + // Set it visible + m_pInternetSpeed->SetVisible(true); + // Set it enabled + m_pInternetSpeed->SetEnabled(true); + // Set its tab position + m_pInternetSpeed->SetTabPosition(0); + // Set its text hidden attribute + m_pInternetSpeed->SetTextHidden(false); + // Set it not editable + m_pInternetSpeed->SetEditable(false); + // Set its maxchars to -1 since it is not editable + //m_pInternetSpeed->SetMaximumCharCount(-1); + // Set the number of items in the combo box menu + m_pInternetSpeed->SetNumberOfEditLines(ARRAYSIZE(g_Speeds)); + // Set the drop down arrow button visible + m_pInternetSpeed->SetDropdownButtonVisible(true); + + + // Add menu items to this combo box. + for (int i = 0; i < ARRAYSIZE(g_Speeds); i++) + { + m_pInternetSpeed->AddItem(g_Speeds[i], NULL ); + } + + // Associate our label with our combo box + m_pSpeedLabel->SetAssociatedControl(m_pInternetSpeed); + + // Now you're saying... why bother using an EditablePanel class for this? + // I could have just created a panel and just created each child panel on my own + // using code like this: memberLabel = new Label(NULL, NULL, "Label"); + // I could have even saved many lines of code by choosing nice constructor args. + // Well the real power of editable panels lies in the use of Resource Files + // as seen in the next example. +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +EditablePanelDemo::~EditablePanelDemo() +{ +} + + + +Panel* EditablePanelDemo_Create(Panel *parent) +{ + return new EditablePanelDemo(parent, "EditablePanelDemo"); +} + + diff --git a/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp b/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp new file mode 100644 index 0000000..41ef377 --- /dev/null +++ b/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp @@ -0,0 +1,88 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> +#include <Keyvalues.h> +#include <vgui_controls/FileOpenDialog.h> + +using namespace vgui; + + +class FileOpenDemo: public DemoPage +{ + public: + FileOpenDemo(Panel *parent, const char *name); + ~FileOpenDemo(); + + void SetVisible(bool status); + + private: + void OnFileSelected(const char *fullpath); + + DHANDLE<FileOpenDialog> m_hFileDialog; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +FileOpenDemo::FileOpenDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +FileOpenDemo::~FileOpenDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: When we make this this demo page visible we make the dialog visible. +//----------------------------------------------------------------------------- +void FileOpenDemo::SetVisible(bool status) +{ + if (status) + { + if (!m_hFileDialog.Get()) + { + // Pop up the dialog + FileOpenDialog *pFileDialog = new FileOpenDialog (NULL, "Find the TestFile", true); + m_hFileDialog = pFileDialog; + m_hFileDialog->AddActionSignalTarget(this); + } + m_hFileDialog->DoModal(false); + } +} + +//----------------------------------------------------------------------------- +// Purpose: When a file is selected print out its full path in the debugger +//----------------------------------------------------------------------------- +void FileOpenDemo::OnFileSelected(const char *fullpath) +{ + ivgui()->DPrintf("File selected\n"); + ivgui()->DPrintf(fullpath); + ivgui()->DPrintf("\n"); +} + +MessageMapItem_t FileOpenDemo::m_MessageMap[] = +{ + MAP_MESSAGE_CONSTCHARPTR(FileOpenDemo, "FileSelected", OnFileSelected, "fullpath"), +}; + +IMPLEMENT_PANELMAP(FileOpenDemo, DemoPage); + + +Panel* FileOpenDemo_Create(Panel *parent) +{ + return new FileOpenDemo(parent, "FileOpenDialogDemo"); +} + + diff --git a/utils/vgui_panel_zoo/FrameDemo.cpp b/utils/vgui_panel_zoo/FrameDemo.cpp new file mode 100644 index 0000000..422c208 --- /dev/null +++ b/utils/vgui_panel_zoo/FrameDemo.cpp @@ -0,0 +1,91 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> + +#include <Keyvalues.h> +#include <vgui_controls/Frame.h> + + +using namespace vgui; + + +class FrameDemo: public DemoPage +{ + public: + FrameDemo(Panel *parent, const char *name); + ~FrameDemo(); + + void OnButtonClicked(); + + void SetVisible(bool status); + + private: + Frame *m_pFrame; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +FrameDemo::FrameDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a Frame. + // This frame has no parent, this way if you press the minimize button + // a label will go on the taskbar. + m_pFrame = new Frame(NULL, "AFrame"); + + // Frames are well, a "frame" around a panel. They have a name bar + // at the top where a title can be displayed, sizing hotspots on the corners, + // and a minimize and close box in the upper right corner. + + // Set the title of the frame + m_pFrame->SetTitle("A Demo Frame", ""); + + // Frames are sizable and moveable by default. + + // Set its position and size + m_pFrame->SetSize(300, 100); + + // Set its Position + m_pFrame->MoveToCenterOfScreen(); + + // Start the frame off invisible. This way it will not be visible when + // other demo tabs are selected. It becomes visible when this demo tab is selected. + m_pFrame->SetVisible(false); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +FrameDemo::~FrameDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: When we make this this demo page we make the frame visible. +//----------------------------------------------------------------------------- +void FrameDemo::SetVisible(bool status) +{ + if (status) + m_pFrame->SetVisible(true); + else + m_pFrame->SetVisible(false); + + DemoPage::SetVisible(status); +} + + +Panel* FrameDemo_Create(Panel *parent) +{ + return new FrameDemo(parent, "FrameDemo"); +} + + diff --git a/utils/vgui_panel_zoo/HTMLDemo.cpp b/utils/vgui_panel_zoo/HTMLDemo.cpp new file mode 100644 index 0000000..2dbb69b --- /dev/null +++ b/utils/vgui_panel_zoo/HTMLDemo.cpp @@ -0,0 +1,66 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/HTML.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// HTML controls display HTML content. +//----------------------------------------------------------------------------- +class HTMLDemo: public DemoPage +{ + public: + HTMLDemo(Panel *parent, const char *name); + ~HTMLDemo(); + + private: + + HTML *m_pHTML; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +HTMLDemo::HTMLDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pHTML = new HTML(this, "AHTML"); + + // Position the window and make it nice and wide, but preserve the + // height to one line. + m_pHTML->SetBounds(10, 10, 500, 300); + + // now open a URL + m_pHTML->OpenURL("http://www.valvesoftware.com", NULL); +// m_pHTML->OpenURL("file:///c:/temp/WebCap.plg"); + // the URL can be any valid URL accepted by Internet Explorer, use file:///c:/... for local filesystem files :) + + // this call causes the control to repaint itself every 1000msec or so, to allow animated gifs to work + // bdawson:TODO + //m_pHTML->StartAnimate(1000); +} + + + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +HTMLDemo::~HTMLDemo() +{ +} + + +Panel* HTMLDemo_Create(Panel *parent) +{ + return new HTMLDemo(parent, "HTMLDemo"); +} + + diff --git a/utils/vgui_panel_zoo/HTMLDemo2.cpp b/utils/vgui_panel_zoo/HTMLDemo2.cpp new file mode 100644 index 0000000..59d7fa5 --- /dev/null +++ b/utils/vgui_panel_zoo/HTMLDemo2.cpp @@ -0,0 +1,70 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/HTML.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// HTML controls display HTML content, 2 side by side. +//----------------------------------------------------------------------------- +class HTMLDemo2: public DemoPage +{ + public: + HTMLDemo2(Panel *parent, const char *name); + ~HTMLDemo2(); + + private: + + HTML *m_pHTML1; + HTML *m_pHTML2; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +HTMLDemo2::HTMLDemo2(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pHTML1 = new HTML(this, "AHTML1"); + m_pHTML2 = new HTML(this, "AHTML2"); + + // Position the window and make it nice and wide, but preserve the + // height to one line. + m_pHTML1->SetBounds(10, 10, 240, 300); + + m_pHTML2->SetBounds(20+250, 10, 240, 300); + + // now open a URL + m_pHTML1->OpenURL("http://www.valvesoftware.com", NULL); + m_pHTML2->OpenURL("http://www.valve-erc.com", NULL); + // the URL can be any valid URL accepted by Internet Explorer, use file:///c:/... for local filesystem files :) + + // this call causes the control to repaint itself every 1000msec or so, to allow animated gifs to work + // bdawson:TODO + //m_pHTML1->StartAnimate(1000); +} + + + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +HTMLDemo2::~HTMLDemo2() +{ +} + + +Panel* HTMLDemo2_Create(Panel *parent) +{ + return new HTMLDemo2(parent, "HTMLDemo2"); +} + + diff --git a/utils/vgui_panel_zoo/ImageDemo.cpp b/utils/vgui_panel_zoo/ImageDemo.cpp new file mode 100644 index 0000000..3b6ac99 --- /dev/null +++ b/utils/vgui_panel_zoo/ImageDemo.cpp @@ -0,0 +1,79 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" +#include <vgui/IScheme.h> +#include <vgui/IImage.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// An Image is an class that handles drawing of a tga image +// They are not panels. +//----------------------------------------------------------------------------- +class ImageDemo: public DemoPage +{ + typedef DemoPage BaseClass; + +public: + ImageDemo(Panel *parent, const char *name); + ~ImageDemo(); + + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void Paint(); + +private: + IImage *m_pImage; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ImageDemo::ImageDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // now insert an image + m_pImage = NULL; +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ImageDemo::~ImageDemo() +{ +} + +//----------------------------------------------------------------------------- +// Scheme settings +//----------------------------------------------------------------------------- +void ImageDemo::ApplySchemeSettings(IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings( pScheme ); + + // now insert an image + m_pImage = scheme()->GetImage("Resource/valve_logo", false); +} + +//----------------------------------------------------------------------------- +// Purpose: Paint the image on screen. Images are not panels, +// You must call the Paint method explicitly for them. +// and set thier position in the frame every time you draw them. +//----------------------------------------------------------------------------- +void ImageDemo::Paint() +{ + m_pImage->SetPos(100, 100); + m_pImage->Paint(); +} + + +Panel* ImageDemo_Create(Panel *parent) +{ + return new ImageDemo(parent, "ImageDemo"); +} + diff --git a/utils/vgui_panel_zoo/ImagePanelDemo.cpp b/utils/vgui_panel_zoo/ImagePanelDemo.cpp new file mode 100644 index 0000000..14e7abb --- /dev/null +++ b/utils/vgui_panel_zoo/ImagePanelDemo.cpp @@ -0,0 +1,75 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" + +#include "vgui_controls/Controls.h" +#include <vgui/IScheme.h> +#include <vgui_controls/ImagePanel.h> +#include <vgui/IImage.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// An ImagePanel is a panel class that handles drawing of Images and gives +// them all kinds of panel features. +//----------------------------------------------------------------------------- +class ImagePanelDemo: public DemoPage +{ + typedef DemoPage BaseClass; + +public: + ImagePanelDemo(Panel *parent, const char *name); + ~ImagePanelDemo(); + + virtual void ApplySchemeSettings(IScheme *pScheme); + +private: + IImage *m_pImage; + ImagePanel *m_pImagePanel; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ImagePanelDemo::ImagePanelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create an Image Panel + m_pImagePanel = new ImagePanel(this, "AnImagePanel"); + + // Set the position + m_pImagePanel->SetPos(100, 100); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ImagePanelDemo::~ImagePanelDemo() +{ +} + +//----------------------------------------------------------------------------- +// Scheme settings +//----------------------------------------------------------------------------- +void ImagePanelDemo::ApplySchemeSettings(IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings( pScheme ); + + // get an image + m_pImage = scheme()->GetImage("Resource/valve_logo", false ); + + // now insert an image + m_pImagePanel->SetImage(m_pImage); +} + +Panel* ImagePanelDemo_Create(Panel *parent) +{ + return new ImagePanelDemo(parent, "ImagePanelDemo"); +} + diff --git a/utils/vgui_panel_zoo/Label2Demo.cpp b/utils/vgui_panel_zoo/Label2Demo.cpp new file mode 100644 index 0000000..28771aa --- /dev/null +++ b/utils/vgui_panel_zoo/Label2Demo.cpp @@ -0,0 +1,88 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "tier1/KeyValues.h" +#include <vgui_controls/Label.h> + +#include "vgui_controls/Controls.h" +#include <vgui/IScheme.h> +#include <vgui/IImage.h> +#include <vgui_controls/TextImage.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A Label is a panel class to handle the display of images and text strings. +// Here we demonstrate a label that has multiple images and strings in it. +// This demo shows a label with multiple images in it. +//----------------------------------------------------------------------------- + +class Label2Demo: public DemoPage +{ + DECLARE_CLASS_SIMPLE( Label2Demo, DemoPage ); + + public: + Label2Demo(Panel *parent, const char *name); + ~Label2Demo(); + + virtual void ApplySchemeSettings(vgui::IScheme *pScheme); + + private: + Label *m_pLabel; + TextImage *m_pEndText; + IImage *_statusImage; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +Label2Demo::Label2Demo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a Label object that displayes the words "LabelText" + m_pLabel = new Label(this, "Label2Demo", "Beginning Label Text"); + + // Create a label holding the ending text + m_pEndText = new TextImage("Ending Label Text"); + + m_pLabel->SetSize( 240, 24 ); + + // Set the label position + m_pLabel->SetPos(100, 100); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +Label2Demo::~Label2Demo() +{ +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void Label2Demo::ApplySchemeSettings(vgui::IScheme *pScheme) +{ + BaseClass::ApplySchemeSettings(pScheme); + + // Label's ApplySchemeSettings wipes out the images that were added + // Re-add them. + m_pLabel->InvalidateLayout(true); + _statusImage = scheme()->GetImage("/friends/icon_busy", false); + m_pLabel->AddImage(_statusImage, 0); + m_pLabel->AddImage(m_pEndText, 0); +} + + +Panel* Label2Demo_Create(Panel *parent) +{ + return new Label2Demo(parent, "Label2Demo"); +} + + diff --git a/utils/vgui_panel_zoo/LabelDemo.cpp b/utils/vgui_panel_zoo/LabelDemo.cpp new file mode 100644 index 0000000..a175225 --- /dev/null +++ b/utils/vgui_panel_zoo/LabelDemo.cpp @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "tier1/KeyValues.h" +#include <vgui_controls/Label.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A Label is a panel class to handle the display of images and text strings. +// Here we demonstrate a simple text only label. +//----------------------------------------------------------------------------- + +class LabelDemo: public DemoPage +{ + public: + LabelDemo(Panel *parent, const char *name); + ~LabelDemo(); + + private: + Label *m_pLabel; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +LabelDemo::LabelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pLabel = new Label(this, "ALabel", "LabelText"); + m_pLabel->SetPos(100, 100); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +LabelDemo::~LabelDemo() +{ +} + + +Panel* LabelDemo_Create(Panel *parent) +{ + return new LabelDemo(parent, "LabelDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ListPanelDemo.cpp b/utils/vgui_panel_zoo/ListPanelDemo.cpp new file mode 100644 index 0000000..eec7b3a --- /dev/null +++ b/utils/vgui_panel_zoo/ListPanelDemo.cpp @@ -0,0 +1,103 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" +#include "tier1/KeyValues.h" +#include <vgui_controls/ListPanel.h> + + +using namespace vgui; + + +class ListPanelDemo: public DemoPage +{ + public: + ListPanelDemo(Panel *parent, const char *name); + ~ListPanelDemo(); + + void onButtonClicked(); + + private: + ListPanel *m_pListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ListPanelDemo::ListPanelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pListPanel = new ListPanel(this, "AListPanel"); + + // Add a column header + m_pListPanel->AddColumnHeader(0, "Muppet", "Muppet", 150, 20, 200); + + // Add another column header + m_pListPanel->AddColumnHeader(1, "Description", "Description", 150, 20, 200 ); + + // Set its position. + m_pListPanel->SetPos(90, 25); + m_pListPanel->SetSize(400, 250); + + // Add rows of data to the table + KeyValues *data = new KeyValues ("item"); + data->SetString("Muppet", "Kermit"); + data->SetString("Description", "The frog"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Miss Piggy"); + data->SetString("Description", "The diva"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Statler"); + data->SetString("Description", "Old guy"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Waldorf"); + data->SetString("Description", "Old guy"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Gonzo"); + data->SetString("Description", "The unknown"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Fozzie"); + data->SetString("Description", "The bear"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Betty Lou"); + data->SetString("Description", "[none]"); + m_pListPanel->AddItem(data, 0, false, false); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ListPanelDemo::~ListPanelDemo() +{ +} + + + + +Panel* ListPanelDemo_Create(Panel *parent) +{ + return new ListPanelDemo(parent, "ListPanelDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ListPanelDemo2.cpp b/utils/vgui_panel_zoo/ListPanelDemo2.cpp new file mode 100644 index 0000000..6581979 --- /dev/null +++ b/utils/vgui_panel_zoo/ListPanelDemo2.cpp @@ -0,0 +1,99 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI_IVGui.h> +#include <VGUI_Controls.h> +#include <VGUI_KeyValues.h> +#include <VGUI_ListPanel.h> + +using namespace vgui; + +class ListPanelDemo2: public DemoPage +{ + public: + ListPanelDemo2(Panel *parent, const char *name); + ~ListPanelDemo2(); + + void onButtonClicked(); + + private: + ListPanel *m_pListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ListPanelDemo2::ListPanelDemo2(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pListPanel = new ListPanel(this, "AListPanel"); + + // Add a column header + m_pListPanel->addColumnHeader(0, "Muppet", "Muppet", 150, true, 20, 200, true); + + // Add another column header + m_pListPanel->addColumnHeader(1, "Description", "Description", 150, true, 20, 200, true); + + // Set its position. + m_pListPanel->setPos(90, 25); + m_pListPanel->setSize(400, 250); + + // Add rows of data to the table + KeyValues *data = new KeyValues ("item"); + data->SetString("Muppet", "Kermit"); + data->SetString("Description", "The frog"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Miss Piggy"); + data->SetString("Description", "The diva"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Statler"); + data->SetString("Description", "Old guy"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Waldorf"); + data->SetString("Description", "Old guy"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Gonzo"); + data->SetString("Description", "The unknown"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Fozzie"); + data->SetString("Description", "The bear"); + m_pListPanel->addItem(data); + + data->SetString("Muppet", "Betty Lou"); + data->SetString("Description", "[none]"); + m_pListPanel->addItem(data); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ListPanelDemo2::~ListPanelDemo2() +{ +} + + +Panel* ListPanelDemo2_Create(Panel *parent) +{ + return new ListPanelDemo2(parent, "ListPanelDemo2"); +} + + diff --git a/utils/vgui_panel_zoo/MenuBarDemo.cpp b/utils/vgui_panel_zoo/MenuBarDemo.cpp new file mode 100644 index 0000000..bd6ef44 --- /dev/null +++ b/utils/vgui_panel_zoo/MenuBarDemo.cpp @@ -0,0 +1,156 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/MenuBar.h> +#include <vgui_controls/MenuButton.h> +#include <vgui_controls/Menu.h> +#include "vgui/ISurface.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A MenuBar +//----------------------------------------------------------------------------- + +class MenuBarDemo: public DemoPage +{ + public: + MenuBarDemo(Panel *parent, const char *name); + ~MenuBarDemo(); + + private: + MenuBar *m_pMenuBar; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +MenuBarDemo::MenuBarDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pMenuBar = new MenuBar(this, "AMenuBar"); + m_pMenuBar->SetPos(0, 20); + + // Make a couple menus and attach them in. + + // A menu + MenuButton *pMenuButton = new MenuButton(this, "FileMenuButton", "&File"); + Menu *pMenu = new Menu(pMenuButton, "AMenu"); + pMenu->AddMenuItem("&New", new KeyValues ("NewFile"), this); + pMenu->AddMenuItem("&Open", new KeyValues ("OpenFile"), this); + pMenu->AddMenuItem("&Save", new KeyValues ("SaveFile"), this); + pMenuButton->SetMenu(pMenu); + + m_pMenuBar->AddButton(pMenuButton); + + // A menu + pMenuButton = new MenuButton(this, "EditMenuButton", "&Edit"); + pMenu = new Menu(pMenuButton, "AMenu"); + pMenu->AddMenuItem("&Undo", new KeyValues ("Undo"), this); + pMenu->AddMenuItem("&Find", new KeyValues ("Find"), this); + pMenu->AddMenuItem("Select&All", new KeyValues ("SelectAll"), this); + pMenuButton->SetMenu(pMenu); + + m_pMenuBar->AddButton(pMenuButton); + + // A menu + pMenuButton = new MenuButton(this, "ViewMenuButton", "&View"); + pMenu = new Menu(pMenuButton, "AMenu"); + pMenu->AddMenuItem("&FullScreen", new KeyValues ("FullScreen"), this); + pMenu->AddMenuItem("&SplitScreen", new KeyValues ("SplitScreen"), this); + pMenu->AddMenuItem("&Properties", new KeyValues ("Properties"), this); + pMenu->AddMenuItem("&Output", new KeyValues ("Output"), this); + pMenuButton->SetMenu(pMenu); + + m_pMenuBar->AddButton(pMenuButton); + + // A menu + pMenuButton = new MenuButton(this, "Big", "&HugeMenu"); + pMenu = new Menu(pMenuButton, "HugeMenu"); + int items = 150; + for ( int i = 0 ; i < items; ++i ) + { + char sz[ 32 ]; + Q_snprintf( sz, sizeof( sz ), "Item %03d", i + 1 ); + + int idx = pMenu->AddMenuItem( sz, new KeyValues ( sz ), this); + + if ( !(i % 4 ) ) + { + char binding[ 256 ]; + Q_snprintf( binding, sizeof( binding ), "Ctrl+%c", 'A' + ( rand() % 26 ) ); + pMenu->SetCurrentKeyBinding( idx, binding ); + } + + if ( !(i % 7 ) ) + { + pMenu->AddSeparator(); + } + } + pMenuButton->SetMenu(pMenu); + + m_pMenuBar->AddButton(pMenuButton); + + pMenuButton = new MenuButton(this, "Big", "&HalfHuge"); + pMenu = new Menu(pMenuButton, "HalfHuge"); + int htotal = 0; + int itemHeight = pMenu->GetMenuItemHeight(); + + int workX, workY, workWide, workTall; + surface()->GetWorkspaceBounds(workX, workY, workWide, workTall); + + int i = 0; + while ( htotal < ( workTall / 2 ) ) + { + char sz[ 32 ]; + Q_snprintf( sz, sizeof( sz ), "Item %03d", i + 1 ); + + int idx = pMenu->AddMenuItem( sz, new KeyValues ( sz ), this); + + if ( !(i % 4 ) ) + { + char binding[ 256 ]; + Q_snprintf( binding, sizeof( binding ), "Ctrl+%c", 'A' + ( rand() % 26 ) ); + pMenu->SetCurrentKeyBinding( idx, binding ); + } + + if ( !(i % 7 ) ) + { + pMenu->AddSeparator(); + htotal += 3; + } + ++i; + htotal += itemHeight; + } + pMenuButton->SetMenu(pMenu); + + m_pMenuBar->AddButton(pMenuButton); + + int bwide, btall; + pMenuButton->GetSize( bwide, btall); + int wide, tall; + GetParent()->GetSize(wide, tall); + m_pMenuBar->SetSize(wide - 2, btall + 8); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +MenuBarDemo::~MenuBarDemo() +{ +} + + +Panel* MenuBarDemo_Create(Panel *parent) +{ + return new MenuBarDemo(parent, "MenuBarDemo"); +} + + diff --git a/utils/vgui_panel_zoo/MenuDemo.cpp b/utils/vgui_panel_zoo/MenuDemo.cpp new file mode 100644 index 0000000..52cd2d3 --- /dev/null +++ b/utils/vgui_panel_zoo/MenuDemo.cpp @@ -0,0 +1,116 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "MenuDemo.h" + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +MenuDemo::MenuDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // It takes 3 parts to make a simple menu. + // 1. A MenuButton that triggers the menu to open. + // 2. A Menu that opens when the button is pressed. + // 3. MenuItems that are listed in the menu and execute commands when selected. + + // First create a menu button. + m_pMenuButton = new MenuButton(this, "AMenuButton", "Press Me To Open Menu!"); + + // Size the Button to its label. + int wide, tall; + m_pMenuButton->GetContentSize(wide, tall); + m_pMenuButton->SetSize(wide + Label::Content, tall + Label::Content); + + + // Next create a menu, and link it to the menu button + m_pMenu = new Menu(m_pMenuButton, "AMenu"); + + // Now add menu items to the menu. These are the choices that will be seen. + + // In adding an item the first arg is the name of the item as it will + // appear in the list, '&' chars are used to flag windows hotkeys that + // will also work to select the item. They will have a little underline + // underneath them. + // The second arg is a KeyValues structure, that in this case holds a string name + // of the command to be sent when the item is selected. + // The third arg is the target of the command, we are sending all commands + // back to this class. + m_pMenu->AddMenuItem("&Homer", new KeyValues ("Homer"), this); + m_pMenu->AddMenuItem("&Apu", new KeyValues ("Apu"), this); + m_pMenu->AddMenuItem("&Bart", new KeyValues ("Bart"), this); + // A Menu Item with no hotkey + m_pMenu->AddMenuItem("Lisa", new KeyValues ("Lisa"), this); + m_pMenu->AddMenuItem("&George", new KeyValues ("George"), this); + m_pMenu->AddMenuItem("&Marge", new KeyValues ("Marge"), this); + // The 'M' hotkey was already used in Marge, 'a' and 'g' are also taken. + // Use another letter not taken for the hotkey. + m_pMenu->AddMenuItem("Maggi&e", new KeyValues ("Maggie"), this); + + // Hide the menu to start. The button will make it visible. + m_pMenu->SetVisible(false); + + // Tell the menu button which menu it should open. + m_pMenuButton->SetMenu(m_pMenu); + + // Position the menu button in the window. + int x, y, dwide, dtall; + GetBounds (x, y, dwide, dtall); + m_pMenuButton->SetPos(10, dtall/2); + + // By default the menu's width will be that of the largest item it contains. + + // You can also set a fixed width, which we will do so our menu doesn't look so + // scrawny. + // Get the size of the menu button + m_pMenuButton->GetSize(wide, tall); + + // Set the width of the menu to be the same as the menu button. + // Comment this line out if you want to see the menu in its original scrawny size + m_pMenu->SetFixedWidth(wide); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +MenuDemo::~MenuDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: This is the function that will be executed when the "Maggie" +// messsage is recieved. Selecting the "Maggie" menu item will trigger +// this message to be sent. This class has been selected as the target of the +// button, and our Message Map translates this string message to a function +// command. +//----------------------------------------------------------------------------- +void MenuDemo::OnMaggie() +{ + // Put a breakpoint here and watch the code break + // when you select "Maggie" + ivgui()->DPrintf("Maggie selected.\n"); + +} + + +// explain message passing +MessageMapItem_t MenuDemo::m_MessageMap[] = +{ + MAP_MESSAGE( MenuDemo, "Maggie", OnMaggie ), // from outermenu +}; + +IMPLEMENT_PANELMAP(MenuDemo, DemoPage); + + + + +Panel* MenuDemo_Create(Panel *parent) +{ + return new MenuDemo(parent, "MenuDemo"); +} + + diff --git a/utils/vgui_panel_zoo/MenuDemo.h b/utils/vgui_panel_zoo/MenuDemo.h new file mode 100644 index 0000000..a06f5e0 --- /dev/null +++ b/utils/vgui_panel_zoo/MenuDemo.h @@ -0,0 +1,40 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/Menu.h> +#include <vgui_controls/MenuButton.h> +#include <Keyvalues.h> + +using namespace vgui; + + +class MenuDemo: public DemoPage +{ + public: + MenuDemo(Panel *parent, const char *name); + ~MenuDemo(); + void InitMenus(); + + void OnMaggie(); + + protected: + // Menu that opens when button is pressed + Menu *m_pMenu; + + // Button to trigger the menu + MenuButton *m_pMenuButton; + + private: + // explain this + DECLARE_PANELMAP(); + +};
\ No newline at end of file diff --git a/utils/vgui_panel_zoo/MenuDemo2.cpp b/utils/vgui_panel_zoo/MenuDemo2.cpp new file mode 100644 index 0000000..0ed25b3 --- /dev/null +++ b/utils/vgui_panel_zoo/MenuDemo2.cpp @@ -0,0 +1,42 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "MenuDemo.h" + +class MenuDemo; + +using namespace vgui; + + +class MenuDemo2 : public MenuDemo +{ + public: + MenuDemo2(Panel *parent, const char *name); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +MenuDemo2::MenuDemo2(Panel *parent, const char *name) : MenuDemo(parent, name) +{ + // Set the number of items visible in the menu at one time to 5 + // If there are more than 5 items in the menu a scrollbar will + // be added automatically + m_pMenu->SetNumberOfVisibleItems(5); + + // Lets also make it so this menu opens up above the button + // instead of below it + m_pMenuButton->SetOpenDirection(Menu::UP); +} + + +Panel* MenuDemo2_Create(Panel *parent) +{ + return new MenuDemo2(parent, "MenuDemo2"); +} + + diff --git a/utils/vgui_panel_zoo/MessageBoxDemo.cpp b/utils/vgui_panel_zoo/MessageBoxDemo.cpp new file mode 100644 index 0000000..1b0877b --- /dev/null +++ b/utils/vgui_panel_zoo/MessageBoxDemo.cpp @@ -0,0 +1,118 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> + +#include <Keyvalues.h> +#include <vgui_controls/Button.h> +#include <vgui_controls/MessageBox.h> + + +using namespace vgui; + +// Message boxes are windows that pop up in response to events. +// They are particularly useful for error messages. +// In this example we will trigger the opening of a message box when +// a button is pressed. + +class MessageBoxDemo: public DemoPage +{ + public: + MessageBoxDemo(Panel *parent, const char *name); + ~MessageBoxDemo(); + + void OnButtonClicked(); + void ShowMessageBox(); + private: + Button *m_pButton; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +MessageBoxDemo::MessageBoxDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a button to trigger the message box. + m_pButton = new Button(this, "AButton", "Click Me For A Message"); + + // Size the button to its text. + int wide, tall; + m_pButton->GetContentSize(wide, tall); + m_pButton->SetSize(wide + Label::Content, tall + Label::Content); + + // Set its position. + m_pButton->SetPos(100, 100); + + // Install a command that will be executed when the button is pressed + // Here we use a KeyValues command, this is mapped using the Message map + // below to a function. + m_pButton->SetCommand(new KeyValues ("ButtonClicked")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +MessageBoxDemo::~MessageBoxDemo() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +// +//----------------------------------------------------------------------------- +void MessageBoxDemo::OnButtonClicked() +{ + ivgui()->DPrintf("Button was clicked.\n"); + + // When the button is clicked we open the message box in response. + ShowMessageBox(); +} + +//----------------------------------------------------------------------------- +// Purpose: Display a message box +//----------------------------------------------------------------------------- + +void MessageBoxDemo::ShowMessageBox() +{ + // create a new message box. + // The first arg is the name of the window and will be across the top. + // The second arg is the text that will appear in the message box. + // The third arg is if the box starts minimized (yes since we want the button to open it) + // The fourth arg is a parent window arg. + MessageBox *pMessage = new MessageBox ("Message Window", "Here is some message box text\n You must click OK to continue.", NULL); + + + // This command will pop up the message box and hold it there until we click + // the OK button. When the OK button is clicked the message box object is destroyed. + pMessage->DoModal(); +} + + + + + +MessageMapItem_t MessageBoxDemo::m_MessageMap[] = +{ + MAP_MESSAGE( MessageBoxDemo, "ButtonClicked", OnButtonClicked ), +}; + +IMPLEMENT_PANELMAP(MessageBoxDemo, DemoPage); + + + +Panel* MessageBoxDemo_Create(Panel *parent) +{ + return new MessageBoxDemo(parent, "MessageBoxDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ProgressBarDemo.cpp b/utils/vgui_panel_zoo/ProgressBarDemo.cpp new file mode 100644 index 0000000..54ba1ac --- /dev/null +++ b/utils/vgui_panel_zoo/ProgressBarDemo.cpp @@ -0,0 +1,109 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui/ISystem.h> +#include <vgui_controls/Controls.h> +#include <vgui_controls/ProgressBar.h> + +using namespace vgui; + +static const int TIMEOUT = 5000; // 5 second timeout + +//----------------------------------------------------------------------------- +// Progress bars are used to illustrate a waiting period (such as +// connecting to a server. +// Here we create a progress bar that fills up every 5 seconds. +//----------------------------------------------------------------------------- +class ProgressBarDemo: public DemoPage +{ + public: + ProgressBarDemo(Panel *parent, const char *name); + ~ProgressBarDemo(); + + void OnTick(); + void SetVisible(bool status); + + private: + ProgressBar *m_pProgressBar; + int m_iTimeoutTime; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ProgressBarDemo::ProgressBarDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pProgressBar = new ProgressBar(this, "AProgressBar"); + m_pProgressBar->SetPos(100, 100); + m_pProgressBar->SetWide(300); + + // This makes panel receive a 'Tick' message every frame + // (~50ms, depending on sleep times/framerate) + // Panel is automatically removed from tick signal list when it's deleted + ivgui()->AddTickSignal(this->GetVPanel()); + + m_iTimeoutTime = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ProgressBarDemo::~ProgressBarDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: When the page is shown, initialize the progress bar. +//----------------------------------------------------------------------------- +void ProgressBarDemo::SetVisible(bool status) +{ + if (status) + { + // Set the timeout time. + m_iTimeoutTime = system()->GetTimeMillis() + TIMEOUT; + + // Set progress bar to be none of the way done + m_pProgressBar->SetProgress(0); + + } + DemoPage::SetVisible(status); +} + +//----------------------------------------------------------------------------- +// Purpose: Advances the status bar to the end, then starts over +//----------------------------------------------------------------------------- +void ProgressBarDemo::OnTick() +{ + if (m_iTimeoutTime) + { + int currentTime = system()->GetTimeMillis(); + + // Check for timeout + if (currentTime > m_iTimeoutTime) + { + // Timed out, make a new timeout time + m_iTimeoutTime = system()->GetTimeMillis() + TIMEOUT; + } + else + { + // Advance the status bar, in the range 0% to 100% + float timePassedPercentage = (float)(currentTime - m_iTimeoutTime + TIMEOUT) / (float)TIMEOUT; + m_pProgressBar->SetProgress(timePassedPercentage); + } + } +} + + +Panel* ProgressBarDemo_Create(Panel *parent) +{ + return new ProgressBarDemo(parent, "ProgressBarDemo"); +} + + diff --git a/utils/vgui_panel_zoo/QueryBoxDemo.cpp b/utils/vgui_panel_zoo/QueryBoxDemo.cpp new file mode 100644 index 0000000..612b9a7 --- /dev/null +++ b/utils/vgui_panel_zoo/QueryBoxDemo.cpp @@ -0,0 +1,147 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> + +#include <Keyvalues.h> +#include <vgui_controls/Button.h> +#include <vgui_controls/QueryBox.h> + + +using namespace vgui; + +// Query boxes are windows that pop up in response to events. +// They are useful for asking questions (like... "Are you sure you want to do this?"). +// In this example we will trigger the opening of a query box when +// a button is pressed. +// Query boxes are Message boxes that have an OK and a Cancel button, +// each button may be linked to an additional command in order to trigger an +// appropriate response. + +class QueryBoxDemo: public DemoPage +{ + public: + QueryBoxDemo(Panel *parent, const char *name); + ~QueryBoxDemo(); + + void OnButtonClicked(); + void ShowQueryBox(); + void OnOK(); + void OnCancel(); + + private: + Button *m_pButton; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +QueryBoxDemo::QueryBoxDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a button to trigger the message box. + m_pButton = new Button(this, "AButton", "Click Me For A Question"); + + // Size the button to its text. + m_pButton->SizeToContents(); + + // Set its position. + m_pButton->SetPos(100, 100); + + // Install a command that will be executed when the button is pressed + // Here we use a KeyValues command, this is mapped using the Message map + // below to a function. + m_pButton->SetCommand(new KeyValues ("ButtonClicked")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +QueryBoxDemo::~QueryBoxDemo() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +// Popup the query box. +//----------------------------------------------------------------------------- +void QueryBoxDemo::OnButtonClicked() +{ + ivgui()->DPrintf("Button was clicked.\n"); + + // When the button is clicked we open the message box in response. + ShowQueryBox(); +} + +//----------------------------------------------------------------------------- +// Purpose: Display a query box +//----------------------------------------------------------------------------- +void QueryBoxDemo::ShowQueryBox() +{ + // create a new message box. + // The first arg is the name of the window and will be across the top. + // The second arg is the text that will appear in the message box. + + QueryBox *pQuery = new QueryBox ("Message Window", "Will you pick OK or Cancel?"); + + // Make ourselves the target of the button messages + pQuery->AddActionSignalTarget(this); + + // Install the message to be sent when the ok button is clicked. + pQuery->SetOKCommand(new KeyValues("OKClicked")); + + // Install the message to be sent when the cancel button is clicked. + pQuery->SetCancelCommand(new KeyValues("Cancel")); + + // This command will pop up the message box and hold it there until we click + // a button. When a button is clicked the query box object is destroyed. + pQuery->DoModal(); +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +// Respond to the OK button in the query box. +//----------------------------------------------------------------------------- +void QueryBoxDemo::OnOK() +{ + ivgui()->DPrintf("Query received the OK.\n"); +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +// Respond to the Cancel button in the query box +//----------------------------------------------------------------------------- +void QueryBoxDemo::OnCancel() +{ + ivgui()->DPrintf("Query was canceled.\n"); +} + + + +MessageMapItem_t QueryBoxDemo::m_MessageMap[] = +{ + MAP_MESSAGE( QueryBoxDemo, "ButtonClicked", OnButtonClicked ), + MAP_MESSAGE( QueryBoxDemo, "OKClicked", OnOK ), + MAP_MESSAGE( QueryBoxDemo, "Cancel", OnCancel ), + +}; + +IMPLEMENT_PANELMAP(QueryBoxDemo, DemoPage); + + + +Panel* QueryBoxDemo_Create(Panel *parent) +{ + return new QueryBoxDemo(parent, "QueryBoxDemo"); +} + + diff --git a/utils/vgui_panel_zoo/RadioButtonDemo.cpp b/utils/vgui_panel_zoo/RadioButtonDemo.cpp new file mode 100644 index 0000000..65f7251 --- /dev/null +++ b/utils/vgui_panel_zoo/RadioButtonDemo.cpp @@ -0,0 +1,135 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/RadioButton.h> + + +using namespace vgui; + + +class RadioButtonDemo: public DemoPage +{ + public: + RadioButtonDemo(Panel *parent, const char *name); + ~RadioButtonDemo(); + + void OnRadioButtonHit(); + + + private: + RadioButton *m_pRadioButton1; + RadioButton *m_pRadioButton2; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +RadioButtonDemo::RadioButtonDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Radio buttons are a little dot circle with a label attached. + // You can have only one radio button selected at a time. + // Other radio buttons will become deselected. + + // Create a radio button. + m_pRadioButton1 = new RadioButton(this, "ARadioButton", "ClickMe"); + + // Set its position. + m_pRadioButton1->SetPos(100, 100); + + // A little label for our button + m_pRadioButton1->SetText("Click the radio button!"); + + // Size the label so the message fits nicely. + m_pRadioButton1->SizeToContents(); + + // Radio buttons are Buttons, and can send a command when clicked. + // Install a command to be sent when the box is checked or unchecked + m_pRadioButton1->SetCommand(new KeyValues("Radio1")); + + // Radio buttons are grouped together by tab position sub tab position + // determines the order to move through the buttons when arrow keys are hit + m_pRadioButton1->SetSubTabPosition(0); + + + // Create another radio button. + m_pRadioButton2 = new RadioButton(this, "AnotherRadioButton", "ClickMe"); + + // Set its position. + m_pRadioButton2->SetPos(100, 120); + + // A little label for our button + m_pRadioButton2->SetText("Click the other radio button!"); + + // Size the label so the message fits nicely. + m_pRadioButton2->SizeToContents(); + + // Start the button off checked. Its unchecked by default. + m_pRadioButton2->SetSelected(true); + + m_pRadioButton1->SetSubTabPosition(1); + + // Don't install a command to be sent when the box is checked or unchecked, + // Because all buttons respons when a new one is checked (they uncheck themselves if checked) + // In this case when a button is selected a RadioButtonChecked message gets sent + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +RadioButtonDemo::~RadioButtonDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void RadioButtonDemo::OnRadioButtonHit() +{ + if (m_pRadioButton1->IsSelected()) + { + ivgui()->DPrintf("Radio button one is checked.\n"); + } + else + { + ivgui()->DPrintf("Radio button one is unchecked.\n"); + } + + if (m_pRadioButton2->IsSelected()) + { + ivgui()->DPrintf("Radio button two is checked.\n"); + } + else + { + ivgui()->DPrintf("Radio button two is unchecked.\n"); + } +} + + + +MessageMapItem_t RadioButtonDemo::m_MessageMap[] = +{ + MAP_MESSAGE( RadioButtonDemo, "RadioButtonChecked", OnRadioButtonHit ), +}; + +IMPLEMENT_PANELMAP(RadioButtonDemo, DemoPage); + + + +Panel* RadioButtonDemo_Create(Panel *parent) +{ + return new RadioButtonDemo(parent, "RadioButtonDemo"); +} + + diff --git a/utils/vgui_panel_zoo/SampleButtons.cpp b/utils/vgui_panel_zoo/SampleButtons.cpp new file mode 100644 index 0000000..ce6495a --- /dev/null +++ b/utils/vgui_panel_zoo/SampleButtons.cpp @@ -0,0 +1,133 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> +#include <Keyvalues.h> +#include <vgui_controls/Button.h> +#include <vgui_controls/MenuButton.h> + +using namespace vgui; + + +class SampleButtons: public DemoPage +{ + public: + SampleButtons(Panel *parent, const char *name); + ~SampleButtons(); + + void onButtonClicked(); + + private: + Button *m_pEnabledButton; + Button *m_pDepressedButton; + Button *m_pDefaultButton; + Button *m_pDisabledButton; + Button *m_pDisActiveButton; + Button *m_pMoreInfoButton; + Button *m_pExpandButton; + MenuButton *m_pMenuButton; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleButtons::SampleButtons(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a button. + m_pEnabledButton = new Button(this, "EnabledButton", "Enabled"); + // Set its position. + m_pEnabledButton->SetPos(90, 15); + // Set its size + m_pEnabledButton->SetSize(90, 25); + + // Install a command that will be executed when the button is pressed + // Here we use a KeyValues command, this is mapped using the Message map + // below to a function. + m_pEnabledButton->SetCommand(new KeyValues ("ButtonClicked")); + + m_pEnabledButton->SetEnabled(true); + + + m_pDepressedButton = new Button(this, "ActiveButton", "Active"); + m_pDepressedButton->SetPos(192, 15); + m_pDepressedButton->SetSize(90, 25); + // Set it pressed down + m_pDepressedButton->ForceDepressed(true); + + m_pDefaultButton = new Button(this, "DefaultButton", "Default"); + // Set this button to be the default + m_pDefaultButton->SetAsDefaultButton(true); + m_pDefaultButton->SetPos(292, 15); + m_pDefaultButton->SetSize(90, 25); + + + m_pDisabledButton = new Button(this, "DisabledButton", "Disabled"); + m_pDisabledButton->SetPos(90, 55); + m_pDisabledButton->SetSize(90, 25); + // Set it disabled + m_pDisabledButton->SetEnabled(false); + + m_pDisActiveButton = new Button(this, "DisActiveButton", "Active"); + m_pDisActiveButton->SetPos(192, 55); + m_pDisActiveButton->SetSize(90, 25); + // Set it pressed down + m_pDisActiveButton->ForceDepressed(true); + // Set it disabled + m_pDisActiveButton->SetEnabled(false); + + + + m_pMoreInfoButton = new Button(this, "MoreInfoButton", "More info required..."); + m_pMoreInfoButton->SetPos(90, 105); + m_pMoreInfoButton->SetSize(160, 25); + + m_pExpandButton = new Button(this, "ExpandButton", "Expand this window >>"); + m_pExpandButton->SetPos(90, 155); + m_pExpandButton->SetSize(160, 25); + + m_pMenuButton = new MenuButton(this, "MenuButton", "Open a menu"); + m_pMenuButton->SetPos(90, 205); + m_pMenuButton->SetSize(125, 25); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleButtons::~SampleButtons() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void SampleButtons::onButtonClicked() +{ + ivgui()->DPrintf("Button was clicked.\n"); +} + + + +MessageMapItem_t SampleButtons::m_MessageMap[] = +{ + MAP_MESSAGE( SampleButtons, "ButtonClicked", onButtonClicked ), +}; + +IMPLEMENT_PANELMAP(SampleButtons, DemoPage); + + + +Panel* SampleButtons_Create(Panel *parent) +{ + return new SampleButtons(parent, "Buttons"); +} + + diff --git a/utils/vgui_panel_zoo/SampleCheckButtons.cpp b/utils/vgui_panel_zoo/SampleCheckButtons.cpp new file mode 100644 index 0000000..31d9f73 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleCheckButtons.cpp @@ -0,0 +1,50 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + + +using namespace vgui; + + +class SampleCheckButtons: public DemoPage +{ + public: + SampleCheckButtons(Panel *parent, const char *name); + ~SampleCheckButtons(); + + private: + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleCheckButtons::SampleCheckButtons(Panel *parent, const char *name) : DemoPage(parent, name) +{ + LoadControlSettings("Demo/SampleCheckButtons.res"); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleCheckButtons::~SampleCheckButtons() +{ +} + + + + +Panel* SampleCheckButtons_Create(Panel *parent) +{ + return new SampleCheckButtons(parent, "Check buttons"); +} + + diff --git a/utils/vgui_panel_zoo/SampleDropDowns.cpp b/utils/vgui_panel_zoo/SampleDropDowns.cpp new file mode 100644 index 0000000..ac11551 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleDropDowns.cpp @@ -0,0 +1,105 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <vgui_controls/ComboBox.h> +#include <vgui_controls/Label.h> + +using namespace vgui; + + +class SampleDropDowns: public DemoPage +{ + public: + SampleDropDowns(Panel *parent, const char *name); + ~SampleDropDowns(); + + private: + ComboBox *m_pNormal; + ComboBox *m_pNormalScroll; + ComboBox *m_pNormal2; + ComboBox *m_pNormal3; + + Label *m_pLabel1; + Label *m_pLabel2; + Label *m_pLabel3; + Label *m_pLabel4; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleDropDowns::SampleDropDowns(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pNormal = new ComboBox(this, "Pills", 6, false); + m_pNormal->SetPos(90, 25); + m_pNormal->SetWide(80); + m_pNormal->AddItem("Red Pill", NULL ); + m_pNormal->AddItem("Blue Pill", NULL ); + m_pNormal->AddItem("ReallyLongName Pill", NULL ); + m_pNormal->ActivateItem(0); + m_pLabel1 = new Label (this, "WhichLabel", "Which"); + m_pLabel1->SizeToContents(); + m_pLabel1->SetPos(43, 25); + + m_pNormalScroll = new ComboBox(this, "Moves", 6, false); + m_pNormalScroll->SetPos(243, 25); + m_pNormalScroll->SetWide(130); + m_pNormalScroll->AddItem("Freezes", NULL ); + m_pNormalScroll->AddItem("Kipup", NULL ); + m_pNormalScroll->AddItem("Donkey", NULL ); + m_pNormalScroll->AddItem("Sidewinder", NULL ); + m_pNormalScroll->AddItem("Handspin", NULL ); + m_pNormalScroll->AddItem("Coffee Grinder", NULL ); + m_pNormalScroll->AddItem("Headspin", NULL ); + m_pNormalScroll->AddItem("The Worm", NULL ); + m_pNormalScroll->ActivateItem(6); + m_pLabel2 = new Label (this, "MoveLabel", "Move"); + m_pLabel2->SizeToContents(); + m_pLabel2->SetPos(200, 25); + + m_pNormal2 = new ComboBox(this, "Pills2", 6, false); + m_pNormal2->SetPos(90, 125); + m_pNormal2->SetWide(80); + m_pNormal2->AddItem("one", NULL ); + m_pNormal2->AddItem("two", NULL ); + m_pNormal2->ActivateItem(1); + m_pLabel3 = new Label (this, "ALabel", "Label on top"); + m_pLabel3->SizeToContents(); + m_pLabel3->SetPos(90, 100); + + m_pNormal3 = new ComboBox(this, "Pills", 6, false); + m_pNormal3->SetPos(90, 200); + m_pNormal3->SetWide(80); + m_pNormal3->AddItem("one", NULL ); + m_pNormal3->AddItem("two", NULL ); + m_pNormal3->ActivateItem(0); + m_pNormal3->SetEnabled(false); + m_pLabel4 = new Label (this, "DLabel", "Disabled"); + m_pLabel4->SetPos(90, 175); + m_pLabel4->SizeToContents(); + m_pLabel4->SetEnabled(false); + + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleDropDowns::~SampleDropDowns() +{ +} + + + +Panel* SampleDropDowns_Create(Panel *parent) +{ + return new SampleDropDowns(parent, "Drop-downs"); +} + + diff --git a/utils/vgui_panel_zoo/SampleEditFields.cpp b/utils/vgui_panel_zoo/SampleEditFields.cpp new file mode 100644 index 0000000..ba9279f --- /dev/null +++ b/utils/vgui_panel_zoo/SampleEditFields.cpp @@ -0,0 +1,58 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/TextEntry.h> + + +using namespace vgui; + + +class SampleEditFields: public DemoPage +{ + public: + SampleEditFields(Panel *parent, const char *name); + ~SampleEditFields(); + + + private: + TextEntry *m_pTextEntry; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleEditFields::SampleEditFields(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pTextEntry = new TextEntry (this, "ATextEntry"); + int wide, tall; + m_pTextEntry->GetSize(wide, tall); + m_pTextEntry->SetBounds(150, 200, 150, tall); + m_pTextEntry->InsertString("with content"); + m_pTextEntry->SetEnabled(false); + + LoadControlSettings("Demo/SampleEditFields.res"); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleEditFields::~SampleEditFields() +{ +} + +Panel* SampleEditFields_Create(Panel *parent) +{ + return new SampleEditFields(parent, "Edit Fields"); +} + + diff --git a/utils/vgui_panel_zoo/SampleListCategories.cpp b/utils/vgui_panel_zoo/SampleListCategories.cpp new file mode 100644 index 0000000..6d821f0 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleListCategories.cpp @@ -0,0 +1,103 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" +#include "tier1/KeyValues.h" +#include "vgui_controls/SectionedListPanel.h" + + +using namespace vgui; + + +class SampleListPanelCats: public DemoPage +{ + public: + SampleListPanelCats(Panel *parent, const char *name); + ~SampleListPanelCats(); + + void OnButtonClicked(); + + private: + SectionedListPanel *m_pSectionedListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleListPanelCats::SampleListPanelCats(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pSectionedListPanel = new SectionedListPanel(this, "AListPanel"); + + // Add a new section + m_pSectionedListPanel->AddSection(0, "LIST ITEMS"); + m_pSectionedListPanel->AddColumnToSection(0, "items", "items", 0, 150); + + // Add items to the list + KeyValues *data = new KeyValues ("items"); + data->SetString("items", "Many actions"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Performed on"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "List items can"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Only be accessed"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Using the right-"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Click menu"); + m_pSectionedListPanel->AddItem(0, data); + + + // Add a new section + m_pSectionedListPanel->AddSection(1, "RIGHT CLICK"); + m_pSectionedListPanel->AddColumnToSection(1, "items", "items", 0, 150); + + // Add items to the list + data->SetString("items", "Right-click the item"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "To access its"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "List of associated"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "Commands"); + m_pSectionedListPanel->AddItem(1, data); + + + // Set its position. + m_pSectionedListPanel->SetPos(90, 25); + m_pSectionedListPanel->SetSize(200, 150); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleListPanelCats::~SampleListPanelCats() +{ +} + + + + +Panel* SampleListPanelCats_Create(Panel *parent) +{ + return new SampleListPanelCats(parent, "List Panel - categories"); +} + + diff --git a/utils/vgui_panel_zoo/SampleListPanelBoth.cpp b/utils/vgui_panel_zoo/SampleListPanelBoth.cpp new file mode 100644 index 0000000..9e43555 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleListPanelBoth.cpp @@ -0,0 +1,120 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" +#include "tier1/KeyValues.h" +#include "vgui_controls/SectionedListPanel.h" + + +using namespace vgui; + + +class SampleListPanelBoth: public DemoPage +{ + public: + SampleListPanelBoth(Panel *parent, const char *name); + ~SampleListPanelBoth(); + + void onButtonClicked(); + + private: + SectionedListPanel *m_pSectionedListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleListPanelBoth::SampleListPanelBoth(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pSectionedListPanel = new SectionedListPanel(this, "AListPanel"); + + // Add a new section + m_pSectionedListPanel->AddSection(0, "LIST ITEMS"); + m_pSectionedListPanel->AddColumnToSection(0, "items", "items", 0, 150 ); + + // Add items to the list + KeyValues *data = new KeyValues ("items"); + data->SetString("items", "Many actions"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Performed on"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "List items can"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Only be accessed"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Using the right-"); + m_pSectionedListPanel->AddItem(0, data); + + data->SetString("items", "Click menu"); + m_pSectionedListPanel->AddItem(0, data); + + // Add a new section + //m_pSectionedListPanel->AddSection(1, "RIGHT CLICK"); + m_pSectionedListPanel->AddColumnToSection(0, "items", "items", 0, 150 ); + + // Add items to the list + data->SetString("items", "Right-click the item"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "To access its"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "List of associated"); + m_pSectionedListPanel->AddItem(1, data); + + data->SetString("items", "Commands"); + m_pSectionedListPanel->AddItem(1, data); + + + // Add a new section + m_pSectionedListPanel->AddSection(2, "RIGHT CLICK"); + m_pSectionedListPanel->AddColumnToSection(2, "items", "items", 0, 150); + + // Add items to the list + data->SetString("items", "Right-click the item"); + m_pSectionedListPanel->AddItem(2, data); + + data->SetString("items", "To access its"); + m_pSectionedListPanel->AddItem(2, data); + + data->SetString("items", "List of associated"); + m_pSectionedListPanel->AddItem(2, data); + + data->SetString("items", "Commands"); + m_pSectionedListPanel->AddItem(2, data); + + + // Set its position. + m_pSectionedListPanel->SetPos(90, 25); + m_pSectionedListPanel->SetSize(200, 150); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleListPanelBoth::~SampleListPanelBoth() +{ +} + + + + +Panel* SampleListPanelBoth_Create(Panel *parent) +{ + return new SampleListPanelBoth(parent, "List Panel - both"); +} + + diff --git a/utils/vgui_panel_zoo/SampleListPanelBoth.h b/utils/vgui_panel_zoo/SampleListPanelBoth.h new file mode 100644 index 0000000..f4abe4c --- /dev/null +++ b/utils/vgui_panel_zoo/SampleListPanelBoth.h @@ -0,0 +1,120 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> +#include <Keyvalues.h> +#include <vgui_controls/SectionedListPanel.h> + + +using namespace vgui; + + +class SampleListPanelBoth: public DemoPage +{ + public: + SampleListPanelBoth(Panel *parent, const char *name); + ~SampleListPanelBoth(); + + void onButtonClicked(); + + private: + SectionedListPanel *m_pSectionedListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleListPanelBoth::SampleListPanelBoth(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pSectionedListPanel = new SectionedListPanel(this, "AListPanel"); + + // Add a new section + m_pSectionedListPanel->addSection(0, "LIST ITEMS"); + m_pSectionedListPanel->addColumnToSection(0, "items", SectionedListPanel::COLUMN_TEXT); + + // Add items to the list + KeyValues *data = new KeyValues ("items"); + data->SetString("items", "Many actions"); + m_pSectionedListPanel->addItem(0, 0, data); + + data->SetString("items", "Performed on"); + m_pSectionedListPanel->addItem(1, 0, data); + + data->SetString("items", "List items can"); + m_pSectionedListPanel->addItem(2, 0, data); + + data->SetString("items", "Only be accessed"); + m_pSectionedListPanel->addItem(3, 0, data); + + data->SetString("items", "Using the right-"); + m_pSectionedListPanel->addItem(4, 0, data); + + data->SetString("items", "Click menu"); + m_pSectionedListPanel->addItem(5, 0, data); + + // Add a new section + m_pSectionedListPanel->addSection(1, "RIGHT CLICK"); + m_pSectionedListPanel->addColumnToSection(0, "items", SectionedListPanel::COLUMN_TEXT); + + // Add items to the list + data->SetString("items", "Right-click the item"); + m_pSectionedListPanel->addItem(10, 1, data); + + data->SetString("items", "To access its"); + m_pSectionedListPanel->addItem(11, 1, data); + + data->SetString("items", "List of associated"); + m_pSectionedListPanel->addItem(12, 1, data); + + data->SetString("items", "Commands"); + m_pSectionedListPanel->addItem(13, 1, data); + + + // Add a new section + m_pSectionedListPanel->addSection(2, "RIGHT CLICK"); + m_pSectionedListPanel->addColumnToSection(2, "items", SectionedListPanel::COLUMN_TEXT); + + // Add items to the list + data->SetString("items", "Right-click the item"); + m_pSectionedListPanel->addItem(10, 2, data); + + data->SetString("items", "To access its"); + m_pSectionedListPanel->addItem(11, 2, data); + + data->SetString("items", "List of associated"); + m_pSectionedListPanel->addItem(12, 2, data); + + data->SetString("items", "Commands"); + m_pSectionedListPanel->addItem(13, 2, data); + + + // Set its position. + m_pSectionedListPanel->setPos(90, 25); + m_pSectionedListPanel->setSize(200, 150); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleListPanelBoth::~SampleListPanelBoth() +{ +} + + + + +Panel* SampleListPanelBoth_Create(Panel *parent) +{ + return new SampleListPanelBoth(parent, "List Panel - categories"); +} + + diff --git a/utils/vgui_panel_zoo/SampleListPanelColumns.cpp b/utils/vgui_panel_zoo/SampleListPanelColumns.cpp new file mode 100644 index 0000000..6ddf507 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleListPanelColumns.cpp @@ -0,0 +1,100 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include "tier1/KeyValues.h" +#include "vgui_controls/ListPanel.h" + + +using namespace vgui; + + +class SampleListPanelColumns: public DemoPage +{ + public: + SampleListPanelColumns(Panel *parent, const char *name); + ~SampleListPanelColumns(); + + private: + ListPanel *m_pListPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleListPanelColumns::SampleListPanelColumns(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Create a list panel. + m_pListPanel = new ListPanel(this, "AListPanel"); + + // Add a column header + m_pListPanel->AddColumnHeader(0, "Muppet", "Muppet", 150, 20, 200); + + // Add another column header + m_pListPanel->AddColumnHeader(1, "Description", "Description", 150, 20, 200); + + // Set its position. + m_pListPanel->SetPos(90, 25); + m_pListPanel->SetSize(400, 150); + + // Add rows of data to the table + KeyValues *data = new KeyValues ("item"); + data->SetString("Muppet", "Kermit"); + data->SetString("Description", "The frog"); + m_pListPanel->AddItem(data, 0, false, false ); + + data->SetString("Muppet", "Miss Piggy"); + data->SetString("Description", "The diva"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Statler"); + data->SetString("Description", "Old guy"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Waldorf"); + data->SetString("Description", "Old guy"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Gonzo"); + data->SetString("Description", "The unknown"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Scooter"); + data->SetString("Description", "The man"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Fozzie"); + data->SetString("Description", "The bear"); + m_pListPanel->AddItem(data, 0, false, false); + + data->SetString("Muppet", "Betty Lou"); + data->SetString("Description", "[none]"); + m_pListPanel->AddItem(data, 0, false, false); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleListPanelColumns::~SampleListPanelColumns() +{ +} + + + + +Panel* SampleListPanelColumns_Create(Panel *parent) +{ + return new SampleListPanelColumns(parent, "List Panel - columns"); +} + + diff --git a/utils/vgui_panel_zoo/SampleMenus.cpp b/utils/vgui_panel_zoo/SampleMenus.cpp new file mode 100644 index 0000000..9240d1f --- /dev/null +++ b/utils/vgui_panel_zoo/SampleMenus.cpp @@ -0,0 +1,397 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/Menu.h> +#include <vgui_controls/MenuItem.h> +#include <vgui_controls/MenuButton.h> +#include <Keyvalues.h> +#include <vgui_controls/Label.h> + +using namespace vgui; + + +class SampleMenus: public DemoPage +{ + public: + SampleMenus(Panel *parent, const char *name); + ~SampleMenus(); + void InitMenus(); + void OnCommand( const char *command ); + +private: + // Menu that opens when button is pressed + Menu *m_pMenu; + + Menu *m_pOuterMenu; + Menu *m_pInnerMenu; + Menu *m_pInnerMenu2; + + Menu *m_pScrollMenu; + + // Button to trigger the menu + MenuButton *m_pMenuButton; + MenuButton *m_pOuterMenuButton; + MenuButton *m_pScrollMenuButton; + + // These are the same menus as above with checkable menu items in them + MenuButton *m_pMenuButton2; + MenuButton *m_pOuterMenuButton2; + MenuButton *m_pScrollMenuButton2; + + Menu *m_pMenu2; + + Menu *m_pOuterMenu2; + Menu *m_pInnerMenu_2; + Menu *m_pInnerMenu22; + + Menu *m_pScrollMenu2; + + + MenuButton *m_pMenuButton3; + Menu *m_pMenu3; + + MenuButton *m_pMenuButton4; + Menu *m_pMenu4; + + MenuButton *m_pMenuButton5; + Menu *m_pMenu5; + +}; +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleMenus::SampleMenus(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // A fixed width menu + m_pMenuButton = new MenuButton(this, "AMenuButton", "Fixed width"); + int wide, tall; + m_pMenuButton->GetContentSize(wide, tall); + m_pMenuButton->SetSize(wide + Label::Content, tall + Label::Content); + // Position the menu button in the window. + m_pMenuButton->SetPos(95, 15); + + m_pMenu = new Menu(m_pMenuButton, "AMenu"); + m_pMenu->AddMenuItem("Menu Item", "junk", this); + m_pMenu->AddMenuItem("Another Choice", "junk", this); + m_pMenu->AddMenuItem("Menu Item", "junk", this); + m_pMenu->SetVisible(false); + m_pMenuButton->SetMenu(m_pMenu); + + m_pMenuButton->GetSize(wide, tall); + m_pMenu->SetFixedWidth(wide); + + + // Cascading menu + InitMenus(); + + + // Scrolling menu + m_pScrollMenuButton = new MenuButton(this, "AMenuButton", "Scrolling"); + m_pScrollMenuButton->GetContentSize(wide, tall); + m_pScrollMenuButton->SetSize(wide + Label::Content, tall + Label::Content); + // Position the menu button in the window. + m_pScrollMenuButton->SetPos(360, 15); + m_pScrollMenu = new Menu(m_pScrollMenuButton, "AScrollingMenu"); + m_pScrollMenu->AddMenuItem("Freezes", "junk", this); + m_pScrollMenu->AddMenuItem("Kipup", "junk", this); + m_pScrollMenu->AddMenuItem("Donkey", "junk", this); + m_pScrollMenu->AddMenuItem("Sidewinder", "junk", this); + m_pScrollMenu->AddMenuItem("Handspin", "junk", this); + m_pScrollMenu->AddMenuItem("Coffee Grinder", "junk", this); + m_pScrollMenu->AddMenuItem("Headspin", "junk", this); + m_pScrollMenu->AddMenuItem("The Worm", "junk", this); + m_pScrollMenu->SetNumberOfVisibleItems(5); + m_pScrollMenu->SetVisible(false); + m_pScrollMenuButton->SetMenu(m_pScrollMenu); + + + + // A fixed width menu with checkable menu items and items with names longer than the menu width + m_pMenuButton2 = new MenuButton(this, "AMenuButton", "A Check menu"); + m_pMenuButton2->GetContentSize(wide, tall); + m_pMenuButton2->SetSize(wide + Label::Content, tall + Label::Content); + + // Position the menu button in the window. + m_pMenuButton2->SetPos(95, 85); + m_pMenu2 = new Menu(m_pMenuButton2, "AMenu"); + m_pMenu2->AddCheckableMenuItem("Menu Item Long Long Name", "junk", this ); + m_pMenu2->AddCheckableMenuItem("Another Choice", "junk", this ); + // last item not checkable for testing + m_pMenu2->AddMenuItem("Menu Item", "junk", this); + m_pMenu2->SetVisible(false); + m_pMenuButton2->SetMenu(m_pMenu2); + m_pMenuButton2->GetSize(wide, tall); + m_pMenu2->SetFixedWidth(wide); + + // Cascading menu with checkable menu items and items with names longer than the menu width + InitMenus(); + + // Scrolling menu with checkable menu items and items with names longer than the menu width + m_pScrollMenuButton2 = new MenuButton(this, "AMenuButton", "Scrolling"); + m_pScrollMenuButton2->GetContentSize(wide, tall); + m_pScrollMenuButton2->SetSize(wide + Label::Content, tall + Label::Content); + + // Position the menu button in the window. + m_pScrollMenuButton2->SetPos(360, 85); + m_pScrollMenu2 = new Menu(m_pScrollMenuButton2, "AScrollingMenu"); + m_pScrollMenu2->AddCheckableMenuItem("Freezes", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Kipup", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Donkey", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Sidewinder", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Handspin", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Coffee Grinder", "junk", this); + m_pScrollMenu2->AddCheckableMenuItem("Headspin", "junk", this); + // last item not checkable for testing + m_pScrollMenu2->AddMenuItem("The Worm", "junk", this); + m_pScrollMenu2->SetNumberOfVisibleItems(5); + m_pScrollMenu2->SetVisible(false); + m_pScrollMenuButton2->SetMenu(m_pScrollMenu2); + // Lets check off some stuff + m_pMenu2->SetMenuItemChecked( 1, true ); + m_pScrollMenu2->SetMenuItemChecked( 0, true ); + m_pScrollMenu2->SetMenuItemChecked( 2, true ); + m_pScrollMenu2->SetMenuItemChecked( 3, true ); + + + Label *buttonLabel = new Label (this, "buttonLabel", "These are the same menus as above with checkable/elipsis menuitems"); + buttonLabel->SetPos(95, 60); + buttonLabel->SizeToContents(); + + + // A button to toggle a check setting in a menu + Button *toggleMenuCheckButton = new Button (this, "Toggle Menu Check", "Toggle Simple Menu Check"); + toggleMenuCheckButton->SetCommand("Check"); + toggleMenuCheckButton->AddActionSignalTarget(this); + toggleMenuCheckButton->GetContentSize(wide, tall); + toggleMenuCheckButton->SetSize(wide + Label::Content, tall + Label::Content); + toggleMenuCheckButton->SetPos( 95, 220); + + + // A non fixed width menu with checkable menu items + m_pMenuButton3 = new MenuButton(this, "AMenuButton", "A menu"); + m_pMenuButton3->GetContentSize(wide, tall); + m_pMenuButton3->SetSize(wide + Label::Content, tall + Label::Content); + // Position the menu button in the window. + m_pMenuButton3->SetPos(285, 220); + m_pMenu3 = new Menu(m_pMenuButton3, "AMenu"); + m_pMenu3->AddCheckableMenuItem("Menu Item", "junk", this); + m_pMenu3->AddCheckableMenuItem("Another Choice", "junk", this); + m_pMenu3->AddCheckableMenuItem("Menu Item", "junk", this); + m_pMenu3->SetVisible(false); + m_pMenuButton3->SetMenu(m_pMenu3); + + + // A non fixed width menu + m_pMenuButton4 = new MenuButton(this, "AMenuButton", "A menu"); + m_pMenuButton4->GetContentSize(wide, tall); + m_pMenuButton4->SetSize(wide + Label::Content, tall + Label::Content); + // Position the menu button in the window. + m_pMenuButton4->SetPos(355, 220); + m_pMenu4 = new Menu(m_pMenuButton4, "AMenu"); + m_pMenu4->AddMenuItem("Menu Item", "junk", this); + m_pMenu4->AddMenuItem("Another Choice", "junk", this); + m_pMenu4->AddMenuItem("Menu Item", "junk", this); + m_pMenu4->SetVisible(false); + m_pMenuButton4->SetMenu(m_pMenu4); + + + // A non fixed width menu with a minimum width + m_pMenuButton5 = new MenuButton(this, "AMenuButton", "A Minimum Width Menu"); + m_pMenuButton5->GetContentSize(wide, tall); + m_pMenuButton5->SetSize(wide + Label::Content, tall + Label::Content); + + m_pMenuButton5->GetContentSize(wide, tall); + m_pMenuButton5->SetSize(wide + Label::Content, tall + Label::Content); + // Position the menu button in the window. + m_pMenuButton5->SetPos(355, 270); + m_pMenu5 = new Menu(m_pMenuButton5, "AMenu"); + m_pMenu5->AddMenuItem("Menu Item", "junk", this); + m_pMenu5->AddMenuItem("Another Choice", "junk", this); + m_pMenu5->AddMenuItem("Menu Item", "junk", this); + m_pMenu5->SetVisible(false); + m_pMenuButton5->GetSize(wide, tall); + m_pMenu5->SetMinimumWidth(wide); + m_pMenuButton5->SetMenu(m_pMenu5); + +} + + +//----------------------------------------------------------------------------- +// Purpose: Create cascading menus. +// We will create a Menu with 2 Menus inside it, and yet another Menu inside one of those! +//----------------------------------------------------------------------------- +void SampleMenus::InitMenus() +{ + // A drop down menu button for the top most menu + m_pOuterMenuButton = new MenuButton(this, "OuterMenu", "Cascading"); + + // Size the Button so we can read its label. + int wide, tall; + m_pOuterMenuButton->GetContentSize(wide, tall); + m_pOuterMenuButton->SetSize(wide + Label::Content, tall + Label::Content); + + + // Create the Menu to go with it. + m_pOuterMenu = new Menu(m_pOuterMenuButton, "OuterMenu"); + + // Add the menu items to this menu + m_pOuterMenu->SetVisible(false); + + m_pOuterMenu->SetNumberOfVisibleItems(5); + + // Attach this menu to the menu button + m_pOuterMenuButton->SetMenu(m_pOuterMenu); + + // Position the menu button on screen. + m_pOuterMenuButton->SetPos(220, 15); + + // Create cascading menu #1 + m_pInnerMenu = new Menu(m_pOuterMenu, "InnerMenu"); + + // Add menu items to this menu. + m_pInnerMenu->AddMenuItem("Marcia", "junk", this); + m_pInnerMenu->AddMenuItem("Greg", "junk", this); + m_pInnerMenu->AddMenuItem("Peter", "junk", this); + m_pInnerMenu->SetVisible(false); + + // Now add the cascading menu to the top menu as a menu item! + m_pOuterMenu->AddCascadingMenuItem("Cascades", this, m_pInnerMenu); + + // Create cascading menu #2 + m_pInnerMenu2 = new Menu(m_pOuterMenu, "InnerMenu2"); + m_pInnerMenu2->AddMenuItem("One Fish", "junk", this); + m_pInnerMenu2->AddMenuItem("Two Fish", "junk", this); + m_pInnerMenu2->AddMenuItem("Red Fish", "junk", this); + m_pInnerMenu2->AddMenuItem("Blue Fish", "junk", this); + m_pInnerMenu2->SetVisible(false); + + // Add this cascading menu to the top menu as a manu item. + m_pOuterMenu->AddCascadingMenuItem("Cascading Choice", this, m_pInnerMenu2); + + + // Make one of the items in the menu disabled. + m_pOuterMenu->AddMenuItem("Normal Menuitem", "junk", this); + m_pOuterMenu->AddMenuItem("Disabled Menuitem", "Disabled", this); + + Panel *menuItem = m_pOuterMenu->FindChildByName("Disabled Menuitem"); + assert(menuItem); + menuItem->SetEnabled(false); + + m_pOuterMenu->AddMenuItem("Normal Menuitem", "junk", this); + + + + + + + // A drop down menu button for the top most menu + m_pOuterMenuButton2 = new MenuButton(this, "OuterMenu", "Cascading"); + + // Size the Button so we can read its label. + m_pOuterMenuButton2->GetContentSize(wide, tall); + m_pOuterMenuButton2->SetSize(wide + Label::Content, tall + Label::Content); + + // Create the Menu to go with it. + m_pOuterMenu2 = new Menu(m_pOuterMenuButton2, "OuterMenu"); + + // Add the menu items to this menu + m_pOuterMenu2->SetVisible(false); + + m_pOuterMenu2->SetNumberOfVisibleItems(7); + + // Attach this menu to the menu button + m_pOuterMenuButton2->SetMenu(m_pOuterMenu2); + + // Position the menu button on screen. + m_pOuterMenuButton2->SetPos(220, 85); + + // Create cascading menu #1 + m_pInnerMenu_2 = new Menu(m_pOuterMenu2, "InnerMenu"); + + // Add menu items to this menu. + m_pInnerMenu_2->AddCheckableMenuItem("Marcia", "junk", this); + m_pInnerMenu_2->AddCheckableMenuItem("Greg", "junk", this); + m_pInnerMenu_2->AddMenuItem("Peter", "junk", this); + m_pInnerMenu_2->SetVisible(false); + + // Now add the cascading menu to the top menu as a menu item! + m_pOuterMenu2->AddCascadingMenuItem("Cascades", this, m_pInnerMenu_2); + + // Create cascading menu #2 + m_pInnerMenu22 = new Menu(m_pOuterMenu2, "InnerMenu2"); + m_pInnerMenu22->AddCheckableMenuItem("One Fish", "junk", this); + m_pInnerMenu22->AddCheckableMenuItem("Two Fish", "junk", this); + m_pInnerMenu22->AddCheckableMenuItem("Red Fish", "junk", this); + m_pInnerMenu22->AddCheckableMenuItem("Blue Fish", "junk", this); + m_pInnerMenu22->SetVisible(false); + + // Add this cascading menu to the top menu as a manu item. + m_pOuterMenu2->AddCascadingMenuItem("Cascading Choice", this, m_pInnerMenu22); + + + // Make one of the items in the menu disabled. + m_pOuterMenu2->AddMenuItem("Normal Menuitem", "junk", this); + // checkable so we can see what disabled checkable items look like + m_pOuterMenu2->AddCheckableMenuItem("Disabled Menuitem", "Disabled", this); + + menuItem = m_pOuterMenu2->FindChildByName("Disabled Menuitem"); + assert(menuItem); + menuItem->SetEnabled(false); + + m_pOuterMenu2->AddMenuItem("Normal Menuitem", "junk", this); + m_pOuterMenu2->AddCheckableMenuItem("Normal Checkable", "junk", this); + + // Lets check off some stuff for starters + m_pOuterMenu2->SetMenuItemChecked( 3, true ); + m_pOuterMenu2->SetMenuItemChecked( 5, true ); + //m_pInnerMenu_2->SetMenuItemChecked( 0, true ); + m_pInnerMenu22->SetMenuItemChecked( 0, true ); + m_pInnerMenu22->SetMenuItemChecked( 1, true ); + m_pInnerMenu22->SetMenuItemChecked( 2, true ); + // another way of checking a menu item + m_pInnerMenu22->GetMenuItem(3)->SetChecked( true ); + + +} + +void SampleMenus::OnCommand( const char *command ) +{ + // Hitting the button will toggle the checking and unchecking + // of the first item of menu3 + if (!stricmp(command, "Check")) + { + if (!m_pMenu3->GetMenuItem(0)->IsChecked()) + // check the first menu item in the first menu + m_pMenu3->SetMenuItemChecked( 0, true ); + else + // another way of setting the checked state. + m_pMenu3->GetMenuItem(0)->SetChecked(false); + } + + Panel::OnCommand(command); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleMenus::~SampleMenus() +{ +} + + + +Panel* SampleMenus_Create(Panel *parent) +{ + return new SampleMenus(parent, "Menus"); +} + + diff --git a/utils/vgui_panel_zoo/SampleRadioButtons.cpp b/utils/vgui_panel_zoo/SampleRadioButtons.cpp new file mode 100644 index 0000000..0a9ffb0 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleRadioButtons.cpp @@ -0,0 +1,50 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + + +using namespace vgui; + + +class SampleRadioButtons: public DemoPage +{ + public: + SampleRadioButtons(Panel *parent, const char *name); + ~SampleRadioButtons(); + + private: + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleRadioButtons::SampleRadioButtons(Panel *parent, const char *name) : DemoPage(parent, name) +{ + LoadControlSettings("Demo/SampleRadioButtons.res"); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleRadioButtons::~SampleRadioButtons() +{ +} + + + + +Panel* SampleRadioButtons_Create(Panel *parent) +{ + return new SampleRadioButtons(parent, "Radio buttons"); +} + + diff --git a/utils/vgui_panel_zoo/SampleSliders.cpp b/utils/vgui_panel_zoo/SampleSliders.cpp new file mode 100644 index 0000000..92002a1 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleSliders.cpp @@ -0,0 +1,91 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Slider.h> +#include <vgui_controls/Label.h> + + +using namespace vgui; + + +class SampleSliders: public DemoPage +{ + public: + SampleSliders(Panel *parent, const char *name); + ~SampleSliders(); + + private: + Slider *m_pSlider; + Slider *m_pSlider2; + Slider *m_pSlider3; + Label *m_pSliderLabel; + Label *m_pSliderLabel2; + Label *m_pSliderLabel3; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleSliders::SampleSliders(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pSliderLabel = new Label (this, "ASliderLabel", "Label on top"); + m_pSliderLabel->SizeToContents(); + m_pSliderLabel->SetPos(90, 25); + m_pSliderLabel->SetZPos(1); + + m_pSlider = new Slider (this, "ALabeledSlider"); + m_pSlider->SetPos(90,50); + m_pSlider->SetSize(165, 30); + m_pSlider->SetTickCaptions("0", "test"); + m_pSlider->SetNumTicks(7); + m_pSlider->SetZPos(0); + + m_pSliderLabel2 = new Label (this, "ASliderLabel", "Or, without numbers"); + m_pSliderLabel2->SizeToContents(); + m_pSliderLabel2->SetPos(290, 25); + m_pSliderLabel2->SetZPos(1); + + m_pSlider2 = new Slider (this, "ALabeledSlider"); + m_pSlider2->SetPos(290,50); + m_pSlider2->SetSize(165, 50); + m_pSlider2->SetNumTicks(7); + m_pSlider2->SetZPos(0); + + + m_pSliderLabel3 = new Label (this, "ASliderLabel", "Label at left"); + m_pSliderLabel3->SizeToContents(); + m_pSliderLabel3->SetPos(90, 125); + + m_pSlider3 = new Slider (this, "ALabeledSlider"); + int wide, tall; + m_pSliderLabel->GetSize(wide, tall); + m_pSlider3->SetPos(90+wide,125); + m_pSlider3->SetSize(150, 50); + m_pSlider3->SetNumTicks(5); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleSliders::~SampleSliders() +{ +} + + + + +Panel* SampleSliders_Create(Panel *parent) +{ + return new SampleSliders(parent, "Slider Bars"); +} + + diff --git a/utils/vgui_panel_zoo/SampleTabs.cpp b/utils/vgui_panel_zoo/SampleTabs.cpp new file mode 100644 index 0000000..08c145d --- /dev/null +++ b/utils/vgui_panel_zoo/SampleTabs.cpp @@ -0,0 +1,69 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/PropertySheet.h> + +using namespace vgui; + + +class SampleTabs: public DemoPage +{ + public: + SampleTabs(Panel *parent, const char *name); + ~SampleTabs(); + + private: + PropertySheet *m_pPropertySheet; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleTabs::SampleTabs(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pPropertySheet = new PropertySheet(this, "Tabs"); + m_pPropertySheet->SetBounds(90,25, 375, 200); + m_pPropertySheet->SetTabWidth(75); + + Panel *testPanel = new PropertyPage (this, "tab1"); + testPanel->SetBounds(90,50, 375, 200); + m_pPropertySheet->AddPage(testPanel, "Keyboard"); + + Panel *testPanel2 = new PropertyPage (this, "tab2"); + testPanel->SetBounds(90,50,375,200); + m_pPropertySheet->AddPage(testPanel2, "Mouse"); + + Panel *testPanel3 = new PropertyPage (this, "tab3"); + testPanel->SetBounds(90,50,375,200); + m_pPropertySheet->AddPage(testPanel3, "Audio"); + + Panel *testPanel4 = new PropertyPage (this, "tab4"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel4, "Video"); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleTabs::~SampleTabs() +{ +} + + + + +Panel* SampleTabs_Create(Panel *parent) +{ + return new SampleTabs(parent, "Tabs"); +} + + diff --git a/utils/vgui_panel_zoo/SampleTabs2.cpp b/utils/vgui_panel_zoo/SampleTabs2.cpp new file mode 100644 index 0000000..0137359 --- /dev/null +++ b/utils/vgui_panel_zoo/SampleTabs2.cpp @@ -0,0 +1,88 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI_IVGui.h> +#include <VGUI_KeyValues.h> +#include <VGUI_Controls.h> +#include <VGUI_PropertySheet.h> + +using namespace vgui; + + +class SampleTabs2: public DemoPage +{ + public: + SampleTabs2(Panel *parent, const char *name); + ~SampleTabs2(); + + private: + PropertySheet *m_pPropertySheet; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +SampleTabs2::SampleTabs2(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pPropertySheet = new PropertySheet(this, "Tabs"); + m_pPropertySheet->SetBounds(90,25, 344, 200); + m_pPropertySheet->SetTabWidth(75); + + Panel *testPanel = new PropertyPage (this, "tab1"); + testPanel->SetBounds(90,50, 375, 200); + m_pPropertySheet->AddPage(testPanel, "Keyboard"); + + Panel *testPanel2 = new PropertyPage (this, "tab2"); + testPanel->SetBounds(90,50,375,200); + m_pPropertySheet->AddPage(testPanel2, "Mouse"); + + Panel *testPanel3 = new PropertyPage (this, "tab3"); + testPanel->SetBounds(90,50,375,200); + m_pPropertySheet->AddPage(testPanel3, "Audio"); + + Panel *testPanel4 = new PropertyPage (this, "tab4"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel4, "Video"); + + Panel *testPanel5 = new PropertyPage (this, "tab5"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel5, "Brother"); + + Panel *testPanel6 = new PropertyPage (this, "tab6"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel6, "Brother2"); + + Panel *testPanel7 = new PropertyPage (this, "tab7"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel7, "Brother3"); + + Panel *testPanel8 = new PropertyPage (this, "tab8"); + testPanel->SetBounds(90,50, 375,200); + m_pPropertySheet->AddPage(testPanel8, "Brother4"); + + m_pPropertySheet->SetScrolling(true); + + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +SampleTabs2::~SampleTabs2() +{ +} + + + +Panel* SampleTabs2_Create(Panel *parent) +{ + return new SampleTabs2(parent, "Scrolling Tabs"); +} + + diff --git a/utils/vgui_panel_zoo/ScrollBar2Demo.cpp b/utils/vgui_panel_zoo/ScrollBar2Demo.cpp new file mode 100644 index 0000000..1055ebc --- /dev/null +++ b/utils/vgui_panel_zoo/ScrollBar2Demo.cpp @@ -0,0 +1,126 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui/IScheme.h> +#include <vgui_controls/ScrollBar.h> +#include <vgui_controls/Label.h> +#include <stdio.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A ScrollBar is an class for selecting a numerical value from a range. +// E.g. in the case of a scrolling text window we use the scroll bar to select +// what line/char of text display should start at in the text window. + +// Some terms: +// +// There are arrow buttons on either end of the scroll bar. +// These move the scroll bar 'slider' or 'nob' across the space between the arrows. +// The nob moves over a user specified 'range' of numbers. +// +// ---------------------------------------------------- +// | / |..............| |................ | \ | +// | \ |..............| nob |.................| / | +// ---------------------------------------------------- +// +// In this demo we create a horizongal scroll bar that is not attached to anything. +// We display the current value of the slider nob next to the scroll bar. +//----------------------------------------------------------------------------- +class ScrollBar2Demo: public DemoPage +{ + public: + ScrollBar2Demo(Panel *parent, const char *name); + ~ScrollBar2Demo(); + + void OnSliderMoved(); + + private: + ScrollBar *m_pScrollbar; + Label *m_pScrollValue; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ScrollBar2Demo::ScrollBar2Demo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // A vertical slider + m_pScrollbar = new ScrollBar (this, "AScrollbar", false); + + // Set the position of the bar + m_pScrollbar->SetPos(100, 100); + + // Set the size of the bar + m_pScrollbar->SetSize (200, 20); + + // Set the size of the bar nob, which is actually proportionally + // related to how many lines of info fit into the window the + // scroll bar is attatched to vs how many total lines there are. + // With a size of 10, the scroll bar value will pass from 0 to 100. + m_pScrollbar->SetRangeWindow(50); + + // Set the range of the bar, + // We want our range displayed to go from 0 to 100. + // We must take size of the bar nob into account, and set the max to 110. + m_pScrollbar->SetRange(0, 110); + + // Set how far the scroll bar slider moves + // when a scroll bar arrow button is pressed + m_pScrollbar->SetButtonPressedScrollValue(5); + + // Set the starting value of the bar nob. + // This will put the nob at the top of the vertical scroll bar. + m_pScrollbar->SetValue(0); + + // Finally we create a little label to tell us what the current value + // of the scroll bar is. + // We will update it every time the slider is moved. + m_pScrollValue = new Label (this, "ScrollBarValue", "0"); + + // Stick the label next to the scroll bar. + m_pScrollValue->SetPos(100, 130); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ScrollBar2Demo::~ScrollBar2Demo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to movement of the scroll bar nob by updating the label's +// text with the current value of the scrollbar. +//----------------------------------------------------------------------------- +void ScrollBar2Demo::OnSliderMoved() +{ + char number[6]; + sprintf (number, "%d", m_pScrollbar->GetValue()); + m_pScrollValue->SetText(number); +} + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t ScrollBar2Demo::m_MessageMap[] = +{ + MAP_MESSAGE( ScrollBar2Demo, "ScrollBarSliderMoved", OnSliderMoved ), +}; +IMPLEMENT_PANELMAP(ScrollBar2Demo, Panel); + + +Panel* ScrollBar2Demo_Create(Panel *parent) +{ + return new ScrollBar2Demo(parent, "ScrollBar2Demo"); +} + diff --git a/utils/vgui_panel_zoo/ScrollBarDemo.cpp b/utils/vgui_panel_zoo/ScrollBarDemo.cpp new file mode 100644 index 0000000..ed44946 --- /dev/null +++ b/utils/vgui_panel_zoo/ScrollBarDemo.cpp @@ -0,0 +1,126 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui/IScheme.h> +#include <vgui_controls/ScrollBar.h> +#include <vgui_controls/Label.h> +#include <stdio.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A ScrollBar is an class for selecting a numerical value from a range. +// E.g. in the case of a scrolling text window we use the scroll bar to select +// what line/char of text display should start at in the text window. + +// Some terms: +// +// There are arrow buttons on either end of the scroll bar. +// These move the scroll bar 'slider' or 'nob' across the space between the arrows. +// The nob moves over a user specified 'range' of numbers. +// +// ---------------------------------------------------- +// | / |..............| |................ | \ | +// | \ |..............| nob |.................| / | +// ---------------------------------------------------- +// +// In this demo we create a vertical scroll bar that is not attached to anything. +// We display the current value of the slider nob next to the scroll bar. +//----------------------------------------------------------------------------- +class ScrollBarDemo: public DemoPage +{ + public: + ScrollBarDemo(Panel *parent, const char *name); + ~ScrollBarDemo(); + + void OnSliderMoved(); + + private: + ScrollBar *m_pScrollbar; + Label *m_pScrollValue; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ScrollBarDemo::ScrollBarDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // A vertical slider + m_pScrollbar = new ScrollBar (this, "ASscrollbar", true); + + // Set the position of the bar + m_pScrollbar->SetPos(100, 100); + + // Set the size of the bar + m_pScrollbar->SetSize (20, 200); + + // Set the size of the bar nob, which is actually proportionally + // related to how many lines of info fit into the window the + // scroll bar is attatched to vs how many total lines there are. + // With a size of 10, the scroll bar value will pass from 0 to 100. + m_pScrollbar->SetRangeWindow(10); + + // Set the range of the bar, + // We want our range displayed to go from 0 to 100. + // We must take size of the bar nob into account, and set the max to 110. + m_pScrollbar->SetRange(0, 110); + + // Set how far the scroll bar slider moves + // when a scroll bar arrow button is pressed + m_pScrollbar->SetButtonPressedScrollValue(5); + + // Set the starting value of the bar nob. + // This will put the nob at the top of the vertical scroll bar. + m_pScrollbar->SetValue(0); + + // Finally we create a little label to tell us what the current value + // of the scroll bar is. + // We will update it every time the slider is moved. + m_pScrollValue = new Label (this, "ScrollBarValue", "0"); + + // Stick the label next to the scroll bar. + m_pScrollValue->SetPos(130, 100); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ScrollBarDemo::~ScrollBarDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to movement of the scroll bar nob by updating the label's +// text with the current value of the scrollbar. +//----------------------------------------------------------------------------- +void ScrollBarDemo::OnSliderMoved() +{ + char number[6]; + sprintf (number, "%d", m_pScrollbar->GetValue()); + m_pScrollValue->SetText(number); +} + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t ScrollBarDemo::m_MessageMap[] = +{ + MAP_MESSAGE( ScrollBarDemo, "ScrollBarSliderMoved", OnSliderMoved ), +}; +IMPLEMENT_PANELMAP(ScrollBarDemo, Panel); + + +Panel* ScrollBarDemo_Create(Panel *parent) +{ + return new ScrollBarDemo(parent, "ScrollBarDemo"); +} + diff --git a/utils/vgui_panel_zoo/ScrollBarDemo2.cpp b/utils/vgui_panel_zoo/ScrollBarDemo2.cpp new file mode 100644 index 0000000..db4f992 --- /dev/null +++ b/utils/vgui_panel_zoo/ScrollBarDemo2.cpp @@ -0,0 +1 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// diff --git a/utils/vgui_panel_zoo/TextEntryDemo.cpp b/utils/vgui_panel_zoo/TextEntryDemo.cpp new file mode 100644 index 0000000..499ecfc --- /dev/null +++ b/utils/vgui_panel_zoo/TextEntryDemo.cpp @@ -0,0 +1,101 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextEntry.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Text Entry controls are notepad-like windows that hold text. +// They have a border around them and typically hold editable text information. +// In this demo we create a very simple text entry window. It holds one +// line of text and is editable. Typing more text will fill the window with +// text and as you hit the end the text will scroll. +// The cursor can be moved +// around with arrow keys or positioned with the mouse. Clicking and dragging +// will select text. Right clicking in +// a text edit window will open a cut/copy/paste dropdown, and the windows +// keyboard commands will work as well (ctrl-c/ctrl-v). Some other windows +// keys work as well (home, delete, end). +// When URL's are displayed in TextEntry windows they become clickable, and +// will open a browser when clicked. +//----------------------------------------------------------------------------- +class TextEntryDemo: public DemoPage +{ + public: + TextEntryDemo(Panel *parent, const char *name); + ~TextEntryDemo(); + + private: + void SetVisible(bool status); + + TextEntry *m_pTextEntry; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextEntryDemo::TextEntryDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pTextEntry = new TextEntry(this, "ATextEntry"); + + // Get the size of the window + int wide, tall; + m_pTextEntry->GetSize(wide, tall); + + // Position the window and make it nice and wide, but preserve the + // height to one line. + m_pTextEntry->SetBounds(100, 100, 200, tall); + + // Insert text after you have set the starting + // size and position of the window + m_pTextEntry->InsertString("Some starting text"); + + // We want all the text in the window selected the + // first time the user clicks in the window. + m_pTextEntry->SelectAllOnFirstFocus(true); + + // Note window has horizontal scrolling of text on by default. + // You can enforce a char limit by using setMaximumCharCount() + + + // A non editable textentry filled with text to test elipses: + TextEntry *m_pTextEntry2 = new TextEntry(this, "ATextEntry"); + m_pTextEntry2->SetBounds(100, 130, 200, tall); + m_pTextEntry2->InsertString("Some starting text longer than before for an elipsis"); + m_pTextEntry2->SetHorizontalScrolling(false); +} + +void TextEntryDemo::SetVisible(bool status) +{ + // We want all the text in the window selected the + // first time the user clicks in the window. + if (status) + m_pTextEntry->SelectAllOnFirstFocus(true);; + + DemoPage::SetVisible(status); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextEntryDemo::~TextEntryDemo() +{ +} + + +Panel* TextEntryDemo_Create(Panel *parent) +{ + return new TextEntryDemo(parent, "TextEntryDemo"); +} + + diff --git a/utils/vgui_panel_zoo/TextEntryDemo2.cpp b/utils/vgui_panel_zoo/TextEntryDemo2.cpp new file mode 100644 index 0000000..05b86e0 --- /dev/null +++ b/utils/vgui_panel_zoo/TextEntryDemo2.cpp @@ -0,0 +1,75 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextEntry.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Text Entry controls are notepad-like windows that hold text. +// In this demo we create an editable text entry window that holds multiple lines +// of text. We initialize it with some starting text and add a scroll bar to the +// window. +//----------------------------------------------------------------------------- +class TextEntryDemo2: public DemoPage +{ + public: + TextEntryDemo2(Panel *parent, const char *name); + ~TextEntryDemo2(); + private: + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextEntryDemo2::TextEntryDemo2(Panel *parent, const char *name) : DemoPage(parent, name) +{ + TextEntry *pTextEntry = new TextEntry(this, "AnotherTextEntry"); + + // Position the window and make it nice and wide. + // Make it tall enough to fit several lines of text. + pTextEntry->SetBounds(100, 100, 200, 100); + + + // Make this window hold multiple lines of text. + // This will turn off horizontal scrolling, + // and wrap text from line to line. + pTextEntry->SetMultiline(true); + // When we type we want to catch the enter key and + // have the text entry insert a newline char. + pTextEntry->SetCatchEnterKey(true); + + // Add a vertical scroll bar. + pTextEntry->SetVerticalScrollbar(true); + + // Insert text after you have set the size and position of the window + pTextEntry->InsertString("Some starting text and a pile of text. "); + pTextEntry->InsertString("Some more text to make mutiple lines. "); + pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. "); + pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. "); + pTextEntry->InsertString("That's it a nice number of chars."); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextEntryDemo2::~TextEntryDemo2() +{ +} + + +Panel* TextEntryDemo2_Create(Panel *parent) +{ + return new TextEntryDemo2(parent, "TextEntryDemo2"); +} + + diff --git a/utils/vgui_panel_zoo/TextEntryDemo3.cpp b/utils/vgui_panel_zoo/TextEntryDemo3.cpp new file mode 100644 index 0000000..def6b95 --- /dev/null +++ b/utils/vgui_panel_zoo/TextEntryDemo3.cpp @@ -0,0 +1,77 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextEntry.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// TextEntry controls are notepad-like windows that hold text. +// In this demo we create an NON-editable text entry window that holds multiple lines +// of text. We initialize it with some text and add a scroll bar to the +// window. +//----------------------------------------------------------------------------- +class TextEntryDemo3: public DemoPage +{ + public: + TextEntryDemo3(Panel *parent, const char *name); + ~TextEntryDemo3(); + + private: + TextEntry *m_pTextEntry; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextEntryDemo3::TextEntryDemo3(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pTextEntry = new TextEntry(this, "YetAnotherTextEntry"); + + // Position the window and make it nice and wide. + // Make it tall enough to fit several lines of text. + m_pTextEntry->SetBounds(100, 100, 200, 100); + + + // Make this window hold multiple lines of text. + // This will turn off horizontal scrolling, + // and wrap text from line to line. + m_pTextEntry->SetMultiline(true); + + // Add a vertical scroll bar. + m_pTextEntry->SetVerticalScrollbar(true); + + // Insert text after you have set the size and position of the window + m_pTextEntry->InsertString("Some starting text and a pile of text. "); + m_pTextEntry->InsertString("Some more text to make mutiple lines. "); + m_pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. "); + m_pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. "); + m_pTextEntry->InsertString("That's it a nice number of chars."); + + // This Text window is not editable by the user. It will only display. + m_pTextEntry->SetEditable(false); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextEntryDemo3::~TextEntryDemo3() +{ +} + + +Panel* TextEntryDemo3_Create(Panel *parent) +{ + return new TextEntryDemo3(parent, "TextEntryDemo3"); +} + + diff --git a/utils/vgui_panel_zoo/TextEntryDemo4.cpp b/utils/vgui_panel_zoo/TextEntryDemo4.cpp new file mode 100644 index 0000000..f10a7cd --- /dev/null +++ b/utils/vgui_panel_zoo/TextEntryDemo4.cpp @@ -0,0 +1,146 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextEntry.h> +#include <vgui/ISystem.h> +#include <vgui_controls/Controls.h> +#include <stdio.h> + +using namespace vgui; + +static const int TIMEOUT = 1000; // 1 second timeout + +//----------------------------------------------------------------------------- +// Text Entry controls are notepad-like windows that hold text. +// In this demo we create a NON-editable text entry window that holds multiple lines +// of text. We initialize it with some starting text and add a scroll bar to the +// window. +// Then we use a tick function to add some more text to the window every one second. +// As the window fills with text, the window scrolls vertically. +// The scroll bar will appear after a few lines and the scroll bar +// slider will shrink as even more text is added. +//----------------------------------------------------------------------------- +class TextEntryDemo4: public DemoPage +{ + public: + TextEntryDemo4(Panel *parent, const char *name); + ~TextEntryDemo4(); + + void SetVisible(bool state); + void OnTick(); + + private: + TextEntry *m_pTextEntry; + int m_iTimeoutTime; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextEntryDemo4::TextEntryDemo4(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pTextEntry = new TextEntry(this, "FancyTextEntry"); + + // Position the window and make it nice and wide. + // Make it tall enough to fit several lines of text. + m_pTextEntry->SetBounds(100, 100, 400, 200); + + + // Make this window hold multiple lines of text. + // This will turn off horizontal scrolling, + // and wrap text from line to line. + m_pTextEntry->SetMultiline(true); + + // Add a vertical scroll bar. + m_pTextEntry->SetVerticalScrollbar(true); + + // Insert text after you have set the size and position of the window + m_pTextEntry->InsertString("Some starting text and a pile of text. "); + m_pTextEntry->InsertString("Some more text to make mutiple lines. "); + m_pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. "); + m_pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. "); + m_pTextEntry->InsertString("That's it a nice number of chars.\n"); + + // This Text window is not editable by the user. It will only display. + m_pTextEntry->SetEditable(false); + + // This makes panel receive a 'Tick' message every frame + // (~50ms, depending on sleep times/framerate) + // Panel is automatically removed from tick signal list when it's deleted + ivgui()->AddTickSignal(this->GetVPanel()); + + m_iTimeoutTime = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextEntryDemo4::~TextEntryDemo4() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: When the page is shown, initialize the time +//----------------------------------------------------------------------------- +void TextEntryDemo4::SetVisible(bool state) +{ + if (state) + { + // Set the timeout time. + m_iTimeoutTime = system()->GetTimeMillis() + TIMEOUT; + + } + DemoPage::SetVisible(state); +} + + +//----------------------------------------------------------------------------- +// Purpose: Adds lines to the text entry every second. +//----------------------------------------------------------------------------- +void TextEntryDemo4::OnTick() +{ + if (m_iTimeoutTime) + { + int currentTime = system()->GetTimeMillis(); + + // Check for timeout + if (currentTime > m_iTimeoutTime) + { + char buf[125]; + sprintf (buf, "Additional Text %d\n", m_iTimeoutTime); + + // Move to the end of the history before we add some new text. + // Its important to call this and explicitly move to the + // correct position in case someone clicked in + // the window (this moves the cursor) + // If you comment out this line and rerun you will see + // that if you click in the text window additional + // text will be added where you clicked. + m_pTextEntry->GotoTextEnd(); + + // Add some text to the text entry window + m_pTextEntry->InsertString(buf); + + // Timed out, make a new timeout time + m_iTimeoutTime = system()->GetTimeMillis() + TIMEOUT; + } + } +} + + + +Panel* TextEntryDemo4_Create(Panel *parent) +{ + return new TextEntryDemo4(parent, "TextEntryDemo4"); +} + + diff --git a/utils/vgui_panel_zoo/TextEntryDemo5.cpp b/utils/vgui_panel_zoo/TextEntryDemo5.cpp new file mode 100644 index 0000000..e49272e --- /dev/null +++ b/utils/vgui_panel_zoo/TextEntryDemo5.cpp @@ -0,0 +1,87 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextEntry.h> +#include <vgui/KeyCode.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Text Entry controls are notepad-like windows that hold text. +// In this demo we create an editable text entry window that holds multiple lines +// of text. We initialize it with some starting text. +// We override the enter key to clear the text. To add a newline manually you can +// type ctrl-enter +//----------------------------------------------------------------------------- +class TextEntryDemo5: public DemoPage +{ + public: + TextEntryDemo5(Panel *parent, const char *name); + ~TextEntryDemo5(); + private: + + void OnKeyCodeTyped(KeyCode code); + + TextEntry *m_pTextEntry; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextEntryDemo5::TextEntryDemo5(Panel *parent, const char *name) : DemoPage(parent, name) +{ + m_pTextEntry = new TextEntry(this, "AnotherTextEntry"); + + // Position the window and make it nice and wide. + // Make it tall enough to fit several lines of text. + m_pTextEntry->SetBounds(100, 100, 200, 100); + + + // Make this window hold multiple lines of text. + // This will turn off horizontal scrolling, + // and wrap text from line to line. + m_pTextEntry->SetMultiline(true); + + // Insert text after you have set the size and position of the window + m_pTextEntry->InsertString("Some starting text and a pile of text. "); + m_pTextEntry->InsertString("Some more text to make mutiple lines. "); + m_pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. "); + m_pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. "); + m_pTextEntry->InsertString("That's it a nice number of chars."); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextEntryDemo5::~TextEntryDemo5() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: When the enter key is pressed we clear the textentry. +// To add a newline use ctrl-return. +//----------------------------------------------------------------------------- +void TextEntryDemo5::OnKeyCodeTyped(KeyCode code) +{ + if (code == KEY_ENTER) + { + m_pTextEntry->SetText(""); + } + + DemoPage::OnKeyCodeTyped(code); +} + +Panel* TextEntryDemo5_Create(Panel *parent) +{ + return new TextEntryDemo5(parent, "TextEntryDemo5"); +} + + diff --git a/utils/vgui_panel_zoo/TextImageDemo.cpp b/utils/vgui_panel_zoo/TextImageDemo.cpp new file mode 100644 index 0000000..e584378 --- /dev/null +++ b/utils/vgui_panel_zoo/TextImageDemo.cpp @@ -0,0 +1,68 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> + +#include <vgui_controls/TextImage.h> + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// A TextImage is an Image that handles drawing of a text string +// They are not panels. +//----------------------------------------------------------------------------- +class TextImageDemo: public DemoPage +{ + public: + TextImageDemo(Panel *parent, const char *name); + ~TextImageDemo(); + + void Paint(); + + private: + TextImage *m_pTextImage; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TextImageDemo::TextImageDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + + // Create a TextImage object that says "Text Image Text" + //m_pTextImage = new TextImage("Text Image Text", GetScheme()); + m_pTextImage = new TextImage("Text Image Text"); + + // Set the position + m_pTextImage->SetPos(100, 100); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TextImageDemo::~TextImageDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Paint the image on screen. TextImages are not panels, you must +// call this method explicitly for them. +//----------------------------------------------------------------------------- +void TextImageDemo::Paint() +{ + m_pTextImage->Paint(); +} + + +Panel* TextImageDemo_Create(Panel *parent) +{ + return new TextImageDemo(parent, "TextImageDemo"); +} + diff --git a/utils/vgui_panel_zoo/ToggleButtonDemo.cpp b/utils/vgui_panel_zoo/ToggleButtonDemo.cpp new file mode 100644 index 0000000..65808ef --- /dev/null +++ b/utils/vgui_panel_zoo/ToggleButtonDemo.cpp @@ -0,0 +1,99 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <Keyvalues.h> +#include <vgui_controls/Controls.h> + +#include <vgui_controls/ToggleButton.h> + + +using namespace vgui; + +// Toggle buttons are a buttons that stay down when you click them. +// Clicking again toggles the button back up. + +class ToggleButtonDemo: public DemoPage +{ + public: + ToggleButtonDemo(Panel *parent, const char *name); + ~ToggleButtonDemo(); + + void OnToggleButtonToggled(); + + + private: + ToggleButton *m_pToggleButton; + + DECLARE_PANELMAP(); +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +ToggleButtonDemo::ToggleButtonDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + // Toggle buttons are a buttons that stay down when you click them. + + // Create a Toggle button. + m_pToggleButton = new ToggleButton(this, "AToggleButton", "Toggle me!"); + + // Set its position. + m_pToggleButton->SetPos(100, 100); + + // Size the button so the message fits nicely. + int wide, tall; + m_pToggleButton->GetContentSize(wide, tall); + m_pToggleButton->SetSize(wide + Label::Content, tall + Label::Content); + + + // Toggle buttons are Buttons, and can send a command when clicked. + // Install a command to be sent when the button is toggled. + m_pToggleButton->SetCommand(new KeyValues("Toggle")); + +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +ToggleButtonDemo::~ToggleButtonDemo() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Respond to a message based action signal +//----------------------------------------------------------------------------- +void ToggleButtonDemo::OnToggleButtonToggled() +{ + if (m_pToggleButton->IsDepressed()) + { + ivgui()->DPrintf("Toggle button is down.\n"); + } + else + { + ivgui()->DPrintf("Toggle button is up.\n"); + } +} + + + +MessageMapItem_t ToggleButtonDemo::m_MessageMap[] = +{ + MAP_MESSAGE( ToggleButtonDemo, "Toggle", OnToggleButtonToggled ), +}; + +IMPLEMENT_PANELMAP(ToggleButtonDemo, DemoPage); + + + +Panel* ToggleButtonDemo_Create(Panel *parent) +{ + return new ToggleButtonDemo(parent, "ToggleButtonDemo"); +} + + diff --git a/utils/vgui_panel_zoo/TooltipDemo.cpp b/utils/vgui_panel_zoo/TooltipDemo.cpp new file mode 100644 index 0000000..4724eb8 --- /dev/null +++ b/utils/vgui_panel_zoo/TooltipDemo.cpp @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +#include <KeyValues.h> +#include <vgui_controls/ToggleButton.h> +#include <vgui_controls/Tooltip.h> + +using namespace vgui; + + +class TooltipsDemo: public DemoPage +{ + public: + TooltipsDemo(Panel *parent, const char *name); + ~TooltipsDemo(); + + private: + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +TooltipsDemo::TooltipsDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ + ToggleButton *pButton = new ToggleButton (this, "RadioDesc5", ""); + pButton->GetTooltip()->SetTooltipFormatToSingleLine(); + + LoadControlSettings("Demo/SampleToolTips.res"); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +TooltipsDemo::~TooltipsDemo() +{ +} + + + + +Panel* TooltipsDemo_Create(Panel *parent) +{ + return new TooltipsDemo(parent, "TooltipsDemo"); +} + + diff --git a/utils/vgui_panel_zoo/WizardPanelDemo.cpp b/utils/vgui_panel_zoo/WizardPanelDemo.cpp new file mode 100644 index 0000000..6455c43 --- /dev/null +++ b/utils/vgui_panel_zoo/WizardPanelDemo.cpp @@ -0,0 +1,348 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#include "DemoPage.h" + +#include <VGUI/IVGui.h> +//#include <vgui_controls/Controls.h> + +#include <vgui_controls/WizardPanel.h> +#include <vgui_controls/WizardSubPanel.h> +#include <vgui_controls/PHandle.h> + +#include <vgui_controls/RadioButton.h> +#include <vgui_controls/TextEntry.h> +#include <vgui/ISurface.h> + +using namespace vgui; + +//----------------------------------------------------------------------------- +// This is a demo of a Wizard. +// A wizard is an interactive utility within an application that guides the user through +// each step of a task. +// +// Wizards typically display a sequence of steps, the user fills in information +// or makes selections and then clicks a "next" button to go to the next panel +// in the sequence. After all panels have been completed, the user clicks "finish" +// and the wizard exits. +// +// In VGUI, the Wizard class is the panel that holds the wizard navigation buttons +// to move to the previous or next panel, and the finish and cancel buttons to +// exit. It also creates the panels that display when the buttons are pressed, called +// WizardSubPanels. These panels have thier own layout and functions that determine +// when to enable/disable the Wizard's navigation buttons. +// +// In this demo we have a Wizard class, called CWonderfulWizard, that contains +// two WizardSubPanel classes, called CSomeSelections and CMoreSelections. +// +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// CSomeSelections: First sub panel of the Wonderful wizard +// Provide some user options that we load from a resource file. +//----------------------------------------------------------------------------- +class CSomeSelections : public WizardSubPanel +{ +public: + CSomeSelections(Panel *parent, const char *panelName); + ~CSomeSelections(){}; + + virtual WizardSubPanel *GetNextSubPanel(); + virtual void OnDisplayAsPrev(); + // Called when the wizard 'next' button is pressed. + // Return true if the wizard should advance. + virtual bool OnNextButton() { return true;} + virtual void PerformLayout(); + +private: + TextEntry *m_pFirstNameEdit; + TextEntry *m_pLastNameEdit; + TextEntry *m_pUserNameEdit; + TextEntry *m_pEmailEdit; + }; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CSomeSelections::CSomeSelections(Panel *parent, const char *panelName) : +WizardSubPanel(parent, panelName) +{ + // create the controls + m_pUserNameEdit = new TextEntry(this, "UserNameEdit"); + m_pUserNameEdit->SetPos(100,100); + m_pFirstNameEdit = new TextEntry(this, "FirstNameEdit"); + m_pLastNameEdit = new TextEntry(this, "LastNameEdit"); + m_pEmailEdit = new TextEntry(this, "EmailEdit"); + + // The layout of the controls is loaded from a resource file. + LoadControlSettings("Demo/WizardPanelDemo.res"); +} + + +//----------------------------------------------------------------------------- +// Purpose: Return a pointer to the next subpanel that should be displayed +// Output : WizardSubPanel * +//----------------------------------------------------------------------------- +WizardSubPanel *CSomeSelections::GetNextSubPanel() +{ + // The next panel to be displayed is called 'CMoreSelections' + return dynamic_cast<WizardSubPanel *>(GetWizardPanel()->FindChildByName("CMoreSelections")); +} + +//----------------------------------------------------------------------------- +// Purpose: Execute this code when a panel has had the 'prev' button pressed +// and the panel to be displayed is this one. +// Input : +//----------------------------------------------------------------------------- +void CSomeSelections::OnDisplayAsPrev() +{ + // Enable the 'next' button + GetWizardPanel()->SetNextButtonEnabled(true); + // Buttons are disabled by default, so the prev button will be disabled, + // which is correct since there are no panels before this one. +} + +//----------------------------------------------------------------------------- +// Purpose: Layout the window. +//----------------------------------------------------------------------------- +void CSomeSelections::PerformLayout() +{ + // Set the title of the Wizard. + GetWizardPanel()->SetTitle("Some Selections", false); + // Make sure the 'finish' button is disabled, since we are not on the last panel. + GetWizardPanel()->SetFinishButtonEnabled(false); +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// CMoreSelections: Second and last sub panel of the Wonderful wizard +// Just one radio button in here. If the button is selected +// The 'finish' button becomes enabled. +//----------------------------------------------------------------------------- +class CMoreSelections : public WizardSubPanel +{ +public: + CMoreSelections(Panel *parent, const char *panelName); + ~CMoreSelections(){}; + + virtual WizardSubPanel *GetNextSubPanel(); + virtual void OnDisplayAsNext(); + virtual bool OnPrevButton() { return true;} + virtual void PerformLayout(); + void OnRadioButtonChecked(Panel *panel); + + DECLARE_PANELMAP(); + +private: + RadioButton *m_pDoneRadio; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CMoreSelections::CMoreSelections(Panel *parent, const char *panelName) : +WizardSubPanel(parent, panelName) +{ + // create the controls + // a radio button + m_pDoneRadio = new RadioButton(this, "DoneRadio", "Are you done?"); + m_pDoneRadio->SizeToContents(); + m_pDoneRadio->SetPos(100,100); +} + +//----------------------------------------------------------------------------- +// Purpose: The wizard tried to get the subpanel after this one. +// There is no panel to be displayed after this one. So return NULL +//----------------------------------------------------------------------------- +WizardSubPanel *CMoreSelections::GetNextSubPanel() +{ + return NULL; +} + +//----------------------------------------------------------------------------- +// Purpose: Called when the subpanel is displayed +// All controls & data should be reinitialized at this time +//----------------------------------------------------------------------------- +void CMoreSelections::OnDisplayAsNext() +{ + // There is no next panel so disable this button. + GetWizardPanel()->SetNextButtonEnabled(false); + // We want the finish button disabled until the radio button is set. + GetWizardPanel()->SetFinishButtonEnabled(false); +} + +//----------------------------------------------------------------------------- +// Purpose: Layout the window and enable/disable buttons as appropriate. +//----------------------------------------------------------------------------- +void CMoreSelections::PerformLayout() +{ + // Set the title of the Wizard. + GetWizardPanel()->SetTitle("All finished?", false); + + // Check if the radio button is selected. + if ( m_pDoneRadio->IsSelected()) + { + // If it is, we will enable the 'finish' button. + GetWizardPanel()->SetFinishButtonEnabled(true); + + } + GetWizardPanel()->SetNextButtonEnabled(false); +} + +//----------------------------------------------------------------------------- +// Purpose: Upon checking the radio button, enable the 'finish' button. +//----------------------------------------------------------------------------- +void CMoreSelections::OnRadioButtonChecked(Panel *panel) +{ + if ( m_pDoneRadio->IsSelected()) + { + GetWizardPanel()->SetFinishButtonEnabled(true); + + } +} + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t CMoreSelections::m_MessageMap[] = +{ + MAP_MESSAGE_PTR( CMoreSelections, "RadioButtonChecked", OnRadioButtonChecked, "panel" ), // custom message +}; +IMPLEMENT_PANELMAP(CMoreSelections, Panel); + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// Purpose: A wizard panel containing two +// wizard sub panels +//----------------------------------------------------------------------------- +class CWonderfulWizard : public WizardPanel +{ +public: + CWonderfulWizard(); + ~CWonderfulWizard(){}; + + void Run(void); + void Open(); + +private: +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CWonderfulWizard::CWonderfulWizard() : WizardPanel(NULL, "WonderfulWizard") +{ + // The size of the Wizard. + //SetBounds(0, 0, 480, 360); + + // The first panel to be displayed. + WizardSubPanel *subPanel = new CSomeSelections(this, "CSomeSelections"); + subPanel->SetVisible(false); + + // The second panel to be displayed. + subPanel = new CMoreSelections(this, "CMoreSelections"); + subPanel->SetVisible(false); +} + +//----------------------------------------------------------------------------- +// Purpose: Start the wizard, starting with the startPanel +//----------------------------------------------------------------------------- +void CWonderfulWizard::Run( void ) +{ + SetVisible(true); + + // Call run, with the name of the first panel to be displayed. + WizardPanel::Run(dynamic_cast<WizardSubPanel *>(FindChildByName("CSomeSelections"))); + + SetTitle("A Wizard Panel ", true); +} + +//----------------------------------------------------------------------------- +// Purpose: Display the wizard. +//----------------------------------------------------------------------------- +void CWonderfulWizard::Open() +{ + RequestFocus(); + MoveToFront(); + SetVisible(true); + surface()->SetMinimized(this->GetVPanel(), false); +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// Purpose: A demonstration of a wizard panel containing two +// wizard sub panels +//----------------------------------------------------------------------------- +class WizardPanelDemo: public DemoPage +{ +public: + WizardPanelDemo(Panel *parent, const char *name); + ~WizardPanelDemo(){}; + + void SetVisible(bool status); + +private: + // We use a handle because the window could be destroyed if someone + // closed the wizard. + DHANDLE<CWonderfulWizard> m_hWizardPanel; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +WizardPanelDemo::WizardPanelDemo(Panel *parent, const char *name) : DemoPage(parent, name) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: When we make this this demo page visible we make the wizard visible. +//----------------------------------------------------------------------------- +void WizardPanelDemo::SetVisible(bool status) +{ + if (status) + { + // Pop up the dialog + if (m_hWizardPanel.Get()) + { + m_hWizardPanel->Open(); + } + else + { + CWonderfulWizard *pWizardPanel = new CWonderfulWizard(); + pWizardPanel->SetPos(100, 100); + pWizardPanel->SetSize(480, 360); + + surface()->CreatePopup(pWizardPanel->GetVPanel(), false); + m_hWizardPanel = pWizardPanel; + m_hWizardPanel->Run(); + } + } + else + { + if (m_hWizardPanel.Get()) + { + m_hWizardPanel->SetVisible(false); + } + } + + DemoPage::SetVisible(status); +} + + + +Panel* WizardPanelDemo_Create(Panel *parent) +{ + return new WizardPanelDemo(parent, "WizardPanelDemo"); +} + + diff --git a/utils/vgui_panel_zoo/ZooUI.cpp b/utils/vgui_panel_zoo/ZooUI.cpp new file mode 100644 index 0000000..6abc8f9 --- /dev/null +++ b/utils/vgui_panel_zoo/ZooUI.cpp @@ -0,0 +1,140 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + +#include "ZooUI.h" +#include "stdio.h" + +#include <VGUI_ISurface.h> +#include <VGUI_Controls.h> +#include <VGUI_KeyValues.h> + +#include <VGUI_PropertySheet.h> + + +#include <VGUI_IVGui.h> // for dprinf statements + + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CZooUI::CZooUI(): Frame(NULL, "PanelZoo") +{ + SetTitle("Panel Zoo", true); + // calculate defaults + int x, y, wide, tall; + vgui::surface()->GetScreenSize(wide, tall); + + int dwide, dtall; + dwide = 1400; + dtall = 500; + x = (int)((wide - dwide) * 0.5); + y = (int)((tall - dtall) * 0.5); + SetBounds (x, y, dwide, dtall); + + SetVisible(true); + vgui::surface()->CreatePopup(GetVPanel(), false); + //loadControlSettings("PanelZoo.res"); + + // property sheet + m_pTabPanel = new PropertySheet(this, "ZooTabs"); + m_pTabPanel->SetBounds(0,50, 1400, 450); + m_pTabPanel->SetTabWidth(50); + + m_pTabPanel->AddPage(ImageDemo_Create(this), "ImageDemo"); + m_pTabPanel->AddPage(ImagePanelDemo_Create(this), "ImagePanelDemo"); + m_pTabPanel->AddPage(TextImageDemo_Create(this), "TextImageDemo"); + + + m_pTabPanel->AddPage(LabelDemo_Create(this), "LabelDemo"); + m_pTabPanel->AddPage(Label2Demo_Create(this), "Label2Demo"); + + + m_pTabPanel->AddPage(TextEntryDemo_Create(this), "TextEntryDemo"); + m_pTabPanel->AddPage(TextEntryDemo2_Create(this), "TextEntryDemo2"); + m_pTabPanel->AddPage(TextEntryDemo3_Create(this), "TextEntryDemo3"); + m_pTabPanel->AddPage(TextEntryDemo4_Create(this), "TextEntryDemo4"); + + m_pTabPanel->AddPage(ButtonDemo_Create(this), "ButtonDemo"); + m_pTabPanel->AddPage(ButtonDemo2_Create(this), "ButtonDemo2"); + + m_pTabPanel->AddPage(CheckButtonDemo_Create(this), "CheckButtonDemo"); + m_pTabPanel->AddPage(ToggleButtonDemo_Create(this), "ToggleButtonDemo"); + m_pTabPanel->AddPage(RadioButtonDemo_Create(this), "RadioButtonDemo"); + + + m_pTabPanel->AddPage(MenuDemo_Create(this), "MenuDemo"); + m_pTabPanel->AddPage(MenuDemo2_Create(this), "MenuDemo2"); + m_pTabPanel->AddPage(CascadingMenuDemo_Create(this), "CascadingMenuDemo"); + + m_pTabPanel->AddPage(MessageBoxDemo_Create(this), "MessageBoxDemo"); + m_pTabPanel->AddPage(QueryBoxDemo_Create(this), "QueryBoxDemo"); + + + m_pTabPanel->AddPage(ComboBoxDemo_Create(this), "ComboBoxDemo"); + m_pTabPanel->AddPage(ComboBox2Demo_Create(this), "ComboBox2Demo"); + + + m_pTabPanel->AddPage(FrameDemo_Create(this), "FrameDemo"); + + m_pTabPanel->AddPage(ProgressBarDemo_Create(this), "ProgressBarDemo"); + m_pTabPanel->AddPage(ScrollBarDemo_Create(this), "ScrollBarDemo"); + m_pTabPanel->AddPage(ScrollBar2Demo_Create(this), "ScrollBar2Demo"); + + m_pTabPanel->AddPage(EditablePanelDemo_Create(this), "EditablePanelDemo"); + m_pTabPanel->AddPage(EditablePanel2Demo_Create(this), "EditablePanel2Demo"); + +} + + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CZooUI::~CZooUI() +{ +} + +void CZooUI::OnCommand(const char *command) +{ + if (!stricmp(command, "Close")) + { + OnClose(); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Handles closing of the dialog - shuts down the whole app +//----------------------------------------------------------------------------- +void CZooUI::OnClose() +{ + Frame::OnClose(); + + // stop vgui running + vgui::ivgui()->Stop(); +} + +//----------------------------------------------------------------------------- +// Purpose: Handles closing of the dialog - shuts down the whole app +//----------------------------------------------------------------------------- +void CZooUI::OnMinimize() +{ + Frame::OnMinimize(); +} + +//----------------------------------------------------------------------------- +// Purpose: Message map +//----------------------------------------------------------------------------- +MessageMapItem_t CZooUI::m_MessageMap[] = +{ + MAP_MESSAGE( CZooUI, "Close", OnClose ), +}; + +IMPLEMENT_PANELMAP(CZooUI, BaseClass); + + diff --git a/utils/vgui_panel_zoo/ZooUI.h b/utils/vgui_panel_zoo/ZooUI.h new file mode 100644 index 0000000..096c1be --- /dev/null +++ b/utils/vgui_panel_zoo/ZooUI.h @@ -0,0 +1,80 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#ifndef ZOOUI_H +#define ZOOUI_H +#ifdef _WIN32 +#pragma once +#endif + +#include <VGUI_Frame.h> + +namespace vgui +{ + class MenuButton; + class TextEntry; + class PropertySheet; +}; + +using namespace vgui; + +Panel* ImageDemo_Create(Panel *parent); +Panel* ImagePanelDemo_Create(Panel *parent); +Panel* TextImageDemo_Create(Panel *parent); +Panel* LabelDemo_Create(Panel *parent); +Panel* Label2Demo_Create(Panel *parent); +Panel* TextEntryDemo_Create(Panel *parent); +Panel* TextEntryDemo2_Create(Panel *parent); +Panel* TextEntryDemo3_Create(Panel *parent); +Panel* TextEntryDemo4_Create(Panel *parent); + +Panel* MenuDemo_Create(Panel *parent); +Panel* MenuDemo2_Create(Panel *parent); +Panel* CascadingMenuDemo_Create(Panel *parent); + +Panel* ButtonDemo_Create(Panel *parent); +Panel* ButtonDemo2_Create(Panel *parent); +Panel* CheckButtonDemo_Create(Panel *parent); +Panel* ToggleButtonDemo_Create(Panel *parent); +Panel* RadioButtonDemo_Create(Panel *parent); + +Panel* MessageBoxDemo_Create(Panel *parent); +Panel* QueryBoxDemo_Create(Panel *parent); +Panel* ComboBoxDemo_Create(Panel *parent); +Panel* ComboBox2Demo_Create(Panel *parent); + +Panel* FrameDemo_Create(Panel *parent); +Panel* ProgressBarDemo_Create(Panel *parent); +Panel* ScrollBarDemo_Create(Panel *parent); +Panel* ScrollBar2Demo_Create(Panel *parent); + +Panel* EditablePanelDemo_Create(Panel *parent); +Panel* EditablePanel2Demo_Create(Panel *parent); + +class CZooUI: public Frame +{ +public: + CZooUI(); + ~CZooUI(); + + void OnClose(); + void OnMinimize(); + void OnCommand(const char *command); + +private: + + vgui::PropertySheet *m_pTabPanel; + + DECLARE_PANELMAP(); +}; + +#endif // SURVEY_H + + + + + diff --git a/utils/vgui_panel_zoo/panel_zoo.vpc b/utils/vgui_panel_zoo/panel_zoo.vpc new file mode 100644 index 0000000..2382116 --- /dev/null +++ b/utils/vgui_panel_zoo/panel_zoo.vpc @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// PANEL_ZOO.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro OUTBINDIR "$SRCDIR\..\game\bin" + +$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc" +$include "$SRCDIR\game\protobuf_include.vpc" + +$Configuration +{ + $Compiler + { + $AdditionalIncludeDirectories "$BASE,$SRCDIR\vgui2\vlocalize,$SRCDIR\vgui2\controls,$SRCDIR\vgui2\include,$SRCDIR\vgui2\controls" + } + $Linker + { + $AdditionalLibraryDirectories "$LIBCOMMON;$LIBPUBLIC" + } +} + +$Project "Panel_zoo" +{ + $Folder "Source Files" + { + $File "AnimatingImagePanelDemo.cpp" + $File "ButtonDemo.cpp" + $File "ButtonDemo2.cpp" + $File "CascadingMenu.cpp" + $File "CControlCatalog.cpp" + $File "CheckButtonDemo.cpp" + $File "ComboBox2.cpp" + $File "ComboBoxDemo.cpp" + $File "DefaultColors.cpp" + $File "DemoPage.cpp" + $File "EditablePanel2Demo.cpp" + $File "EditablePanelDemo.cpp" + $File "FileOpenDialogDemo.cpp" + $File "FrameDemo.cpp" + $File "HTMLDemo.cpp" + $File "HTMLDemo2.cpp" + $File "ImageDemo.cpp" + $File "ImagePanelDemo.cpp" + $File "Label2Demo.cpp" + $File "LabelDemo.cpp" + $File "ListPanelDemo.cpp" + $File "MenuBarDemo.cpp" + $File "MenuDemo.cpp" + $File "MenuDemo2.cpp" + $File "MessageBoxDemo.cpp" + $File "ProgressBarDemo.cpp" + $File "QueryBoxDemo.cpp" + $File "RadioButtonDemo.cpp" + $File "SampleButtons.cpp" + $File "SampleCheckButtons.cpp" + $File "SampleDropDowns.cpp" + $File "SampleEditFields.cpp" + $File "SampleListCategories.cpp" + $File "SampleListPanelBoth.cpp" + $File "SampleListPanelColumns.cpp" + $File "SampleMenus.cpp" + $File "SampleRadioButtons.cpp" + $File "SampleSliders.cpp" + $File "SampleTabs.cpp" + $File "ScrollBar2Demo.cpp" + $File "ScrollBarDemo.cpp" + $File "testfile.cpp" + $File "TextEntryDemo.cpp" + $File "TextEntryDemo2.cpp" + $File "TextEntryDemo3.cpp" + $File "TextEntryDemo4.cpp" + $File "TextEntryDemo5.cpp" + $File "TextImageDemo.cpp" + $File "ToggleButtonDemo.cpp" + $File "TooltipDemo.cpp" + $File "$SRCDIR\public\vgui_controls\vgui_controls.cpp" + $File "WizardPanelDemo.cpp" + } + + $Folder "Header Files" + { + $File "CControlCatalog.h" + $File "DemoPage.h" + $File "$SRCDIR\public\tier1\interface.h" + $File "MenuDemo.h" + $File "SampleListPanelBoth.h" + } + + $Folder "Link Libraries" + { + $Lib appframework + $Lib tier2 + $Lib tier3 + $Lib vgui_controls + $Lib mathlib + $ImpLibexternal steam_api + } +} diff --git a/utils/vgui_panel_zoo/testfile.cpp b/utils/vgui_panel_zoo/testfile.cpp new file mode 100644 index 0000000..50f052e --- /dev/null +++ b/utils/vgui_panel_zoo/testfile.cpp @@ -0,0 +1,178 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//===========================================================================// +#include "interface.h" + +#include <windows.h> +//#include "..\..\tracker\common\winlite.h" +#include "vgui_controls/Controls.h" +#include "vgui/vgui.h" +#include "VGUI\IPanel.h" +#include "VGUI\IScheme.h" +#include "VGUI\ISurface.h" +#include "VGUI\ILocalize.h" +#include "VGUI\IVGui.h" +#include "vgui_controls/Panel.h" +#include "filesystem.h" +#include "tier0/icommandline.h" +#include "appframework/tier3app.h" +#include "inputsystem/iinputsystem.h" +#include "CControlCatalog.h" + +#include <stdio.h> + +//----------------------------------------------------------------------------- +// Purpose: Warning/Msg call back through this API +// Input : type - +// *pMsg - +// Output : SpewRetval_t +//----------------------------------------------------------------------------- +SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg ) +{ + switch ( type ) + { + + default: + case SPEW_MESSAGE: + case SPEW_ASSERT: + case SPEW_LOG: + OutputDebugString( pMsg ); + break; + case SPEW_WARNING: + OutputDebugString( pMsg ); + break; + case SPEW_ERROR: + OutputDebugString( pMsg ); + exit( -1 ); + break; + } + + return SPEW_CONTINUE; +} + +//----------------------------------------------------------------------------- +// Purpose: Entry point +// loads interfaces and initializes dialog +//----------------------------------------------------------------------------- +static CreateInterfaceFn s_pFactoryList[2]; + +void *VGuiFactory( const char *pName, int *pReturnCode ) +{ + for ( int i = 0; i < ARRAYSIZE( s_pFactoryList ); ++i ) + { + void *pInterface = s_pFactoryList[i]( pName, pReturnCode ); + if ( pInterface ) + return pInterface; + } + return NULL; +} + + +//----------------------------------------------------------------------------- +// The application object +//----------------------------------------------------------------------------- +class CPanelZooApp : public CVguiSteamApp +{ + typedef CVguiSteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool Create(); + virtual bool PreInit(); + virtual int Main(); + virtual void Destroy() {} +}; + +DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CPanelZooApp ); + + +//----------------------------------------------------------------------------- +// The application object +//----------------------------------------------------------------------------- +bool CPanelZooApp::Create() +{ + SpewOutputFunc( SpewFunc ); + SpewActivate( "panelzoo", 2 ); + + AppSystemInfo_t appSystems[] = + { + { "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION }, + { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION }, + { "", "" } // Required to terminate the list + }; + + return AddSystems( appSystems ); +} + + +//----------------------------------------------------------------------------- +// Setup +//----------------------------------------------------------------------------- +bool CPanelZooApp::PreInit() +{ + if ( !BaseClass::PreInit() ) + return false; + + if ( !BaseClass::SetupSearchPaths( NULL, false, true ) ) + { + ::MessageBox( NULL, "Error", "Unable to initialize file system\n", MB_OK ); + return false; + } + + g_pFullFileSystem->AddSearchPath( "platform", "PLATFORM" ); + return true; +} + + +//----------------------------------------------------------------------------- +// Purpose: Entry point +//----------------------------------------------------------------------------- +int CPanelZooApp::Main() +{ + // In order to load resource files the file must be in your vgui filesystem path. +// g_pFullFileSystem->AddSearchPath("../", "resources"); + + // Init the surface +// vgui::surface()->Init(); + + // Make a embedded panel + vgui::Panel *panel = new vgui::Panel(NULL, "TopPanel"); + vgui::surface()->SetEmbeddedPanel( panel->GetVPanel() ); + + // Load the scheme + if (!vgui::scheme()->LoadSchemeFromFile( "//platform/Resource/SourceScheme.res", "PANELZOO" )) + return 1; + + // localization + g_pVGuiLocalize->AddFile( "Resource/platform_english.txt" ); + g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt" ); + g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt" ); + + // Start vgui + vgui::ivgui()->Start(); + + // Add our main window + CControlCatalog *panelZoo = new CControlCatalog(); + panelZoo->Activate(); + + // Run app frame loop + while (vgui::ivgui()->IsRunning()) + { + vgui::ivgui()->RunFrame(); + } + + delete panelZoo; +// delete panel; + + return 1; +} + + + + + + |