FileSelector.pkg 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $#include "FileSelector.h"
  2. /// %File selector's list entry (file or directory.)
  3. struct FileSelectorEntry
  4. {
  5. /// Name.
  6. String name_;
  7. /// Directory flag.
  8. bool directory_;
  9. };
  10. /// %File selector dialog.
  11. class FileSelector : public Object
  12. {
  13. public:
  14. /// Construct.
  15. FileSelector(Context* context);
  16. /// Destruct.
  17. virtual ~FileSelector();
  18. /// Set fileselector UI style.
  19. void SetDefaultStyle(XMLFile* style);
  20. /// Set title text.
  21. void SetTitle(const String& text);
  22. /// Set button texts.
  23. void SetButtonTexts(const String& okText, const String& cancelText);
  24. /// Set current path.
  25. void SetPath(const String& path);
  26. /// Set current filename.
  27. void SetFileName(const String& fileName);
  28. /// Set filters.
  29. void SetFilters(const Vector<String>& filters, unsigned defaultIndex);
  30. /// Set directory selection mode. Default false.
  31. void SetDirectoryMode(bool enable);
  32. /// Update elements to layout properly. Call this after manually adjusting the sub-elements.
  33. void UpdateElements();
  34. /// Return the UI style file.
  35. XMLFile* GetDefaultStyle() const;
  36. /// Return fileselector window.
  37. Window* GetWindow() const { return window_; }
  38. /// Return window title text element.
  39. Text* GetTitleText() const { return titleText_; }
  40. /// Return file list.
  41. ListView* GetFileList() const { return fileList_; }
  42. /// Return path editor.
  43. LineEdit* GetPathEdit() const { return pathEdit_; }
  44. /// Return filename editor.
  45. LineEdit* GetFileNameEdit() const { return fileNameEdit_; }
  46. /// Return filter dropdown.
  47. DropDownList* GetFilterList() const { return filterList_; }
  48. /// Return OK button.
  49. Button* GetOKButton() const { return okButton_; }
  50. /// Return cancel button.
  51. Button* GetCancelButton() const { return cancelButton_; }
  52. /// Return close button.
  53. Button* GetCloseButton() const { return closeButton_; }
  54. /// Return window title.
  55. const String& GetTitle() const;
  56. /// Return current path.
  57. const String& GetPath() const { return path_; }
  58. /// Return current filename.
  59. const String& GetFileName() const;
  60. /// Return current filter.
  61. const String& GetFilter() const;
  62. /// Return current filter index.
  63. unsigned GetFilterIndex() const;
  64. /// Return directory mode flag.
  65. bool GetDirectoryMode() const { return directoryMode_; }
  66. };