FileDialog.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef FileDialog_H
  2. #define FileDialog_H
  3. #include "Array.h"
  4. #include "Thread.h"
  5. namespace Framework
  6. {
  7. class Text; //! Text.h
  8. void InitDialog();
  9. //! Creates a file open/save dialog
  10. class FileDialog : public virtual ReferenceCounter
  11. {
  12. private:
  13. RCArray<Text>* typeName;
  14. RCArray<Text>* type;
  15. int fileIndex;
  16. public:
  17. //! Constructor
  18. DLLEXPORT FileDialog();
  19. //! Destructor
  20. DLLEXPORT ~FileDialog();
  21. //! Clears the list of allowed file types
  22. DLLEXPORT void removeFileTypes();
  23. //! Adds an allowed file type
  24. //! \param name The name of the file type. Visible to the user in the
  25. //! select box \param typ The file type that may be selected
  26. DLLEXPORT void addFileType(const char* name, const char* typ);
  27. //! Adds an allowed file type
  28. //! \param name The name of the file type. Visible to the user in the
  29. //! select box \param typ The file type that may be selected
  30. DLLEXPORT void addFileType(Text* name, Text* typ);
  31. //! Sets the initially selected file type
  32. //! \param i The index of the file type. The one added first
  33. //! has index 0.
  34. DLLEXPORT void setFileTypeSelection(int i);
  35. //! Shows the file dialog
  36. //! \param open true if the dialog should be used for opening. false for
  37. //! saving \return The path to the selected file
  38. DLLEXPORT Text* anzeigen(bool open) const;
  39. };
  40. //! Manages a file open/save dialog without blocking
  41. class FileDialogTh : public Thread
  42. {
  43. private:
  44. FileDialog* dialog;
  45. Text* ret;
  46. bool open;
  47. public:
  48. //! Constructor
  49. DLLEXPORT FileDialogTh();
  50. //! Destructor
  51. DLLEXPORT ~FileDialogTh();
  52. //! Sets whether the dialog is for opening or saving
  53. //! \param b 1 if for opening. 0 if for saving
  54. DLLEXPORT void setOpen(bool b);
  55. //! Clears the list of allowed file types
  56. DLLEXPORT void removeFileTypes();
  57. //! Adds an allowed file type
  58. //! \param name The name of the file type. Visible to the user in the
  59. //! select box \param typ The file type that may be selected
  60. DLLEXPORT void addFileType(const char* name, const char* typ);
  61. //! Adds an allowed file type
  62. //! \param name The name of the file type. Visible to the user in the
  63. //! select box \param typ The file type that may be selected
  64. DLLEXPORT void addFileType(Text* name, Text* typ);
  65. //! Sets the initially selected file type
  66. //! \param i The index of the file type. The one added first
  67. //! has index 0.
  68. DLLEXPORT void setFileTypeSelection(int i);
  69. //! This function is called by the class itself.
  70. //! Use the start function to show the dialog
  71. DLLEXPORT void thread() override;
  72. //! Returns the path to the file.
  73. //! Only works after the thread has finished
  74. DLLEXPORT Text* getPfad() const;
  75. //! Returns the path to the file without increased reference counter.
  76. //! Only works after the thread has finished
  77. DLLEXPORT Text* zPfad() const;
  78. };
  79. }; // namespace Framework
  80. #endif