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.

101 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef DMEPICKER_H
  7. #define DMEPICKER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/EditablePanel.h"
  12. #include "vgui_controls/Frame.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "tier1/utlstring.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. namespace vgui
  19. {
  20. class Panel;
  21. class TextEntry;
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Forward declarations
  25. //-----------------------------------------------------------------------------
  26. struct DmePickerInfo_t
  27. {
  28. DmElementHandle_t m_hElement;
  29. const char *m_pChoiceString;
  30. };
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Main app window
  33. //-----------------------------------------------------------------------------
  34. class CDmePicker : public vgui::EditablePanel
  35. {
  36. DECLARE_CLASS_SIMPLE( CDmePicker, vgui::EditablePanel );
  37. public:
  38. CDmePicker( vgui::Panel *pParent );
  39. ~CDmePicker();
  40. // overridden frame functions
  41. virtual void Activate( const CUtlVector< DmePickerInfo_t >& vec );
  42. // Forward arrow keys to the list
  43. virtual void OnKeyCodePressed( vgui::KeyCode code );
  44. // Returns the selceted DmElement
  45. CDmElement *GetSelectedDme( );
  46. private:
  47. void RefreshDmeList();
  48. MESSAGE_FUNC( OnTextChanged, "TextChanged" );
  49. vgui::TextEntry *m_pFilterList;
  50. vgui::ListPanel *m_pDmeBrowser;
  51. CUtlString m_Filter;
  52. friend class CDmePickerFrame;
  53. };
  54. //-----------------------------------------------------------------------------
  55. // Purpose: Main app window
  56. //-----------------------------------------------------------------------------
  57. class CDmePickerFrame : public vgui::Frame
  58. {
  59. DECLARE_CLASS_SIMPLE( CDmePickerFrame, vgui::Frame );
  60. public:
  61. CDmePickerFrame( vgui::Panel *pParent, const char *pTitle );
  62. ~CDmePickerFrame();
  63. // Inherited from Frame
  64. virtual void OnCommand( const char *pCommand );
  65. // Purpose: Activate the dialog
  66. // the message "DmeSelected" will be sent if one was picked
  67. // Pass in a message to add as a subkey to the DmeSelected message
  68. void DoModal( const CUtlVector< DmePickerInfo_t >& vec, KeyValues *pContextKeyValues = NULL );
  69. private:
  70. void CleanUpMessage();
  71. CDmePicker *m_pPicker;
  72. vgui::Button *m_pOpenButton;
  73. vgui::Button *m_pCancelButton;
  74. KeyValues *m_pContextKeyValues;
  75. };
  76. #endif // DMEPICKER_H