Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef WIZARDPANEL_H
  8. #define WIZARDPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Frame.h>
  13. namespace vgui
  14. {
  15. class WizardSubPanel;
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Type of dialog that supports moving back and forth through a series
  18. // of sub-dialogs, WizardSubPanels
  19. //-----------------------------------------------------------------------------
  20. class WizardPanel : public Frame
  21. {
  22. DECLARE_CLASS_SIMPLE( WizardPanel, Frame );
  23. public:
  24. WizardPanel(Panel *parent, const char *panelName);
  25. ~WizardPanel();
  26. // Start the wizard, starting with the startPanel
  27. virtual void Run(WizardSubPanel *startPanel);
  28. // Called when the buttons are pressed
  29. // WizardSubPanels can also call these functions to simulate a button being pressed
  30. MESSAGE_FUNC( OnNextButton, "NextButton" );
  31. MESSAGE_FUNC( OnPrevButton, "PrevButton" );
  32. MESSAGE_FUNC( OnFinishButton, "FinishButton" );
  33. MESSAGE_FUNC( OnCancelButton, "CancelButton" );
  34. // sets whether or not a button is enabled
  35. // this state is managed, and will be reset whenever going to a new page
  36. virtual void SetNextButtonEnabled(bool state);
  37. virtual void SetPrevButtonEnabled(bool state);
  38. virtual void SetFinishButtonEnabled(bool state);
  39. virtual void SetCancelButtonEnabled(bool state);
  40. // sets whether or not a button is visible
  41. // this state is unmanaged, the user needs to ensure that the buttons state
  42. // is correct when going both back and prev through the wizard
  43. virtual void SetNextButtonVisible(bool state);
  44. virtual void SetPrevButtonVisible(bool state);
  45. virtual void SetFinishButtonVisible(bool state);
  46. virtual void SetCancelButtonVisible(bool state);
  47. // sets the text for a button
  48. // setting the text to be NULL resets the text to it's default state
  49. // this state is unmanaged, the user needs to ensure that the buttons state
  50. // is correct when going both back and prev through the wizard
  51. virtual void SetNextButtonText(const char *text);
  52. virtual void SetPrevButtonText(const char *text);
  53. virtual void SetFinishButtonText(const char *text);
  54. virtual void SetCancelButtonText(const char *text);
  55. // general wizard state for all the subpanels to access
  56. virtual KeyValues *GetWizardData();
  57. // recalculates where the key focus should be in the wizard
  58. virtual void ResetKeyFocus();
  59. virtual void ResetDefaultButton();
  60. // resets the sub panel history for the control
  61. virtual void ResetHistory();
  62. // returns a page by name
  63. virtual WizardSubPanel *GetSubPanelByName(const char *pageName);
  64. virtual void ShowButtons(bool state);
  65. virtual void GetClientArea(int &x, int &y, int &wide, int &tall);
  66. protected:
  67. MESSAGE_FUNC_PTR( InternalActivateNextSubPanel, "ActivateNextSubPanel", panel )
  68. {
  69. ActivateNextSubPanel( (WizardSubPanel *)panel );
  70. }
  71. virtual void ActivateNextSubPanel(WizardSubPanel *subPanel);
  72. virtual void ActivatePrevSubPanel();
  73. virtual void CreateButtons();
  74. virtual void RecalculateTabOrdering();
  75. virtual vgui::WizardSubPanel *GetCurrentSubPanel() { return _currentSubPanel; }
  76. // overrides
  77. virtual void PerformLayout();
  78. virtual void ApplySchemeSettings(IScheme *pScheme);
  79. // reroute build messages to the currently active sub panel
  80. virtual void ActivateBuildMode();
  81. // close maps to the cancel button
  82. virtual void OnClose();
  83. virtual void OnCommand(const char *command);
  84. virtual void OnCloseFrameButtonPressed();
  85. private:
  86. WizardSubPanel *FindNextValidSubPanel(WizardSubPanel *currentPanel);
  87. Button *_prevButton;
  88. Button *_nextButton;
  89. Button *_cancelButton;
  90. Button *_finishButton;
  91. WizardSubPanel *_currentSubPanel;
  92. KeyValues *_currentData;
  93. Dar<WizardSubPanel *> _subPanelStack; // contains a list of all the subpanels (not including the current one)
  94. bool _showButtons;
  95. };
  96. } // namespace vgui
  97. #endif // WIZARDPANEL_H