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.

96 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef DIRECTORYSELECTDIALOG_H
  7. #define DIRECTORYSELECTDIALOG_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/Controls.h>
  12. #include <vgui_controls/TreeView.h>
  13. #include <vgui_controls/Frame.h>
  14. namespace vgui
  15. {
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Used to handle dynamically populating the tree view
  18. //-----------------------------------------------------------------------------
  19. class DirectoryTreeView : public TreeView
  20. {
  21. public:
  22. DirectoryTreeView(DirectorySelectDialog *parent, const char *name);
  23. virtual void GenerateChildrenOfNode(int itemIndex);
  24. private:
  25. DirectorySelectDialog *m_pParent;
  26. };
  27. //-----------------------------------------------------------------------------
  28. // Purpose: Utility dialog, used to let user select a directory (like during install)
  29. //-----------------------------------------------------------------------------
  30. class DirectorySelectDialog : public Frame
  31. {
  32. DECLARE_CLASS_SIMPLE( DirectorySelectDialog, Frame );
  33. public:
  34. DirectorySelectDialog(vgui::Panel *parent, const char *title);
  35. // sets where it should start searching
  36. void SetStartDirectory(const char *path);
  37. // sets what name should show up by default in the create directory dialog
  38. void SetDefaultCreateDirectoryName(const char *defaultCreateDirName);
  39. // opens the dialog
  40. void DoModal();
  41. /* action signals
  42. "DirectorySelected"
  43. "dir" - the directory that was selected
  44. */
  45. // Expand the tree nodes to match a supplied path, optionally selecting the final directory
  46. void ExpandTreeToPath( const char *lpszPath, bool bSelectFinalDirectory = true );
  47. protected:
  48. virtual void PerformLayout();
  49. virtual void ApplySchemeSettings(IScheme *pScheme);
  50. virtual void OnClose();
  51. // command buttons
  52. virtual void OnCommand(const char *command);
  53. private:
  54. MESSAGE_FUNC( OnTextChanged, "TextChanged" );
  55. MESSAGE_FUNC( OnTreeViewItemSelected, "TreeViewItemSelected" );
  56. MESSAGE_FUNC_CHARPTR( OnCreateDirectory, "CreateDirectory", dir );
  57. void BuildDirTree();
  58. void BuildDriveChoices();
  59. void ExpandTreeNode(const char *path, int parentNodeIndex);
  60. void GenerateChildrenOfDirectoryNode(int nodeIndex);
  61. void GenerateFullPathForNode(int nodeIndex, char *path, int pathBufferSize);
  62. bool DoesDirectoryHaveSubdirectories(const char *path, const char *dir);
  63. char m_szCurrentDir[512];
  64. char m_szDefaultCreateDirName[64];
  65. char m_szCurrentDrive[16];
  66. vgui::TreeView *m_pDirTree;
  67. vgui::ComboBox *m_pDriveCombo;
  68. vgui::Button *m_pCancelButton;
  69. vgui::Button *m_pSelectButton;
  70. vgui::Button *m_pCreateButton;
  71. friend class DirectoryTreeView;
  72. };
  73. } // namespace vgui
  74. #endif // DIRECTORYSELECTDIALOG_H