dirdlg.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: dirdlg.h
  3. // Purpose: interface of wxDirDialog
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. #define wxDD_CHANGE_DIR 0x0100
  8. #define wxDD_DIR_MUST_EXIST 0x0200
  9. #define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now,
  10. #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
  11. /**
  12. Initial folder for generic directory dialog.
  13. */
  14. const char wxDirDialogDefaultFolderStr[] = "/";
  15. /**
  16. Default message for directory selector dialog.
  17. */
  18. const char wxDirSelectorPromptStr[] = "Select a directory";
  19. /**
  20. Default name for directory selector dialog.
  21. */
  22. const char wxDirDialogNameStr[] = "wxDirCtrl";
  23. /**
  24. @class wxDirDialog
  25. This class represents the directory chooser dialog.
  26. @beginStyleTable
  27. @style{wxDD_DEFAULT_STYLE}
  28. Equivalent to a combination of wxDEFAULT_DIALOG_STYLE and
  29. wxRESIZE_BORDER (the last one is not used under wxWinCE).
  30. @style{wxDD_DIR_MUST_EXIST}
  31. The dialog will allow the user to choose only an existing folder.
  32. When this style is not given, a "Create new directory" button is
  33. added to the dialog (on Windows) or some other way is provided to
  34. the user to type the name of a new folder.
  35. @style{wxDD_CHANGE_DIR}
  36. Change the current working directory to the directory chosen by the
  37. user.
  38. @endStyleTable
  39. Notice that @c wxRESIZE_BORDER has special side effect under recent (i.e.
  40. later than Win9x) Windows where two different directory selection dialogs
  41. are available and this style also implicitly selects the new version as the
  42. old one always has fixed size. As the new version is almost always
  43. preferable, it is recommended that @c wxRESIZE_BORDER style be always used.
  44. This is the case if the dialog is created with the default style value but
  45. if you need to use any additional styles you should still specify @c
  46. wxDD_DEFAULT_STYLE unless you explicitly need to use the old dialog version
  47. under Windows. E.g. do
  48. @code
  49. wxDirDialog dlg(NULL, "Choose input directory", "",
  50. wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
  51. @endcode
  52. instead of just using @c wxDD_DIR_MUST_EXIST style alone.
  53. @library{wxcore}
  54. @category{cmndlg}
  55. @see @ref overview_cmndlg_dir, wxFileDialog
  56. */
  57. class wxDirDialog : public wxDialog
  58. {
  59. public:
  60. /**
  61. Constructor. Use ShowModal() to show the dialog.
  62. @param parent
  63. Parent window.
  64. @param message
  65. Message to show on the dialog.
  66. @param defaultPath
  67. The default path, or the empty string.
  68. @param style
  69. The dialog style. See wxDirDialog
  70. @param pos
  71. Dialog position. Ignored under Windows.
  72. @param size
  73. Dialog size. Ignored under Windows.
  74. @param name
  75. The dialog name, not used.
  76. */
  77. wxDirDialog(wxWindow* parent,
  78. const wxString& message = wxDirSelectorPromptStr,
  79. const wxString& defaultPath = wxEmptyString,
  80. long style = wxDD_DEFAULT_STYLE,
  81. const wxPoint& pos = wxDefaultPosition,
  82. const wxSize& size = wxDefaultSize,
  83. const wxString& name = wxDirDialogNameStr);
  84. /**
  85. Destructor.
  86. */
  87. virtual ~wxDirDialog();
  88. /**
  89. Returns the message that will be displayed on the dialog.
  90. */
  91. virtual wxString GetMessage() const;
  92. /**
  93. Returns the default or user-selected path.
  94. */
  95. virtual wxString GetPath() const;
  96. /**
  97. Sets the message that will be displayed on the dialog.
  98. */
  99. virtual void SetMessage(const wxString& message);
  100. /**
  101. Sets the default path.
  102. */
  103. virtual void SetPath(const wxString& path);
  104. /**
  105. Shows the dialog, returning wxID_OK if the user pressed OK, and
  106. wxID_CANCEL otherwise.
  107. */
  108. int ShowModal();
  109. };
  110. // ============================================================================
  111. // Global functions/macros
  112. // ============================================================================
  113. /** @addtogroup group_funcmacro_dialog */
  114. //@{
  115. /**
  116. Pops up a directory selector dialog. The arguments have the same meaning
  117. as those of wxDirDialog::wxDirDialog(). The message is displayed at the
  118. top, and the default_path, if specified, is set as the initial selection.
  119. The application must check for an empty return value (if the user pressed
  120. Cancel). For example:
  121. @code
  122. const wxString& dir = wxDirSelector("Choose a folder");
  123. if ( !dir.empty() )
  124. {
  125. ...
  126. }
  127. @endcode
  128. @header{wx/dirdlg.h}
  129. */
  130. wxString wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
  131. const wxString& default_path = wxEmptyString,
  132. long style = 0,
  133. const wxPoint& pos = wxDefaultPosition,
  134. wxWindow* parent = NULL);
  135. //@}