2
0

CGUIFileOpenDialog.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #pragma once
  5. #include "IGUIFileOpenDialog.h"
  6. #include "IGUIButton.h"
  7. #include "IGUIListBox.h"
  8. #include "IGUIEditBox.h"
  9. #include "IFileSystem.h"
  10. namespace irr
  11. {
  12. namespace gui
  13. {
  14. class CGUIFileOpenDialog : public IGUIFileOpenDialog
  15. {
  16. public:
  17. //! constructor
  18. CGUIFileOpenDialog(const wchar_t *title, IGUIEnvironment *environment,
  19. IGUIElement *parent, s32 id, bool restoreCWD = false,
  20. io::path::char_type *startDir = 0);
  21. //! destructor
  22. virtual ~CGUIFileOpenDialog();
  23. //! returns the filename of the selected file. Returns NULL, if no file was selected.
  24. const wchar_t *getFileName() const override;
  25. //! Returns the filename of the selected file. Is empty if no file was selected.
  26. const io::path &getFileNameP() const override;
  27. //! Returns the directory of the selected file. Returns NULL, if no directory was selected.
  28. const io::path &getDirectoryName() const override;
  29. //! Returns the directory of the selected file converted to wide characters. Returns NULL if no directory was selected.
  30. const wchar_t *getDirectoryNameW() const override;
  31. //! called if an event happened.
  32. bool OnEvent(const SEvent &event) override;
  33. //! draws the element and its children
  34. void draw() override;
  35. protected:
  36. void setFileName(const irr::io::path &name);
  37. void setDirectoryName(const irr::io::path &name);
  38. //! Ensure filenames are converted correct depending on wide-char settings
  39. void pathToStringW(irr::core::stringw &result, const irr::io::path &p);
  40. //! fills the listbox with files.
  41. void fillListBox();
  42. //! sends the event that the file has been selected.
  43. void sendSelectedEvent(EGUI_EVENT_TYPE type);
  44. //! sends the event that the file choose process has been canceld
  45. void sendCancelEvent();
  46. core::position2d<s32> DragStart;
  47. io::path FileName;
  48. core::stringw FileNameW;
  49. io::path FileDirectory;
  50. io::path FileDirectoryFlat;
  51. core::stringw FileDirectoryFlatW;
  52. io::path RestoreDirectory;
  53. io::path StartDirectory;
  54. IGUIButton *CloseButton;
  55. IGUIButton *OKButton;
  56. IGUIButton *CancelButton;
  57. IGUIListBox *FileBox;
  58. IGUIEditBox *FileNameText;
  59. IGUIElement *EventParent;
  60. io::IFileSystem *FileSystem;
  61. io::IFileList *FileList;
  62. bool Dragging;
  63. };
  64. } // end namespace gui
  65. } // end namespace irr