dirdlg.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dirdlg.h
  3. // Purpose: wxDirDialog base class
  4. // Author: Robert Roebling
  5. // Modified by:
  6. // Created:
  7. // Copyright: (c) Robert Roebling
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DIRDLG_H_BASE_
  11. #define _WX_DIRDLG_H_BASE_
  12. #if wxUSE_DIRDLG
  13. #include "wx/dialog.h"
  14. // ----------------------------------------------------------------------------
  15. // constants
  16. // ----------------------------------------------------------------------------
  17. extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[];
  18. extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogDefaultFolderStr[];
  19. extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[];
  20. #define wxDD_CHANGE_DIR 0x0100
  21. #define wxDD_DIR_MUST_EXIST 0x0200
  22. // deprecated, on by default now, use wxDD_DIR_MUST_EXIST to disable it
  23. #define wxDD_NEW_DIR_BUTTON 0
  24. #ifdef __WXWINCE__
  25. #define wxDD_DEFAULT_STYLE wxDEFAULT_DIALOG_STYLE
  26. #else
  27. #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
  28. #endif
  29. //-------------------------------------------------------------------------
  30. // wxDirDialogBase
  31. //-------------------------------------------------------------------------
  32. class WXDLLIMPEXP_CORE wxDirDialogBase : public wxDialog
  33. {
  34. public:
  35. wxDirDialogBase() {}
  36. wxDirDialogBase(wxWindow *parent,
  37. const wxString& title = wxDirSelectorPromptStr,
  38. const wxString& defaultPath = wxEmptyString,
  39. long style = wxDD_DEFAULT_STYLE,
  40. const wxPoint& pos = wxDefaultPosition,
  41. const wxSize& sz = wxDefaultSize,
  42. const wxString& name = wxDirDialogNameStr)
  43. {
  44. Create(parent, title, defaultPath, style, pos, sz, name);
  45. }
  46. virtual ~wxDirDialogBase() {}
  47. bool Create(wxWindow *parent,
  48. const wxString& title = wxDirSelectorPromptStr,
  49. const wxString& defaultPath = wxEmptyString,
  50. long style = wxDD_DEFAULT_STYLE,
  51. const wxPoint& pos = wxDefaultPosition,
  52. const wxSize& sz = wxDefaultSize,
  53. const wxString& name = wxDirDialogNameStr)
  54. {
  55. if (!wxDialog::Create(parent, wxID_ANY, title, pos, sz, style, name))
  56. return false;
  57. m_path = defaultPath;
  58. m_message = title;
  59. return true;
  60. }
  61. #if WXWIN_COMPATIBILITY_2_6
  62. wxDEPRECATED( long GetStyle() const );
  63. wxDEPRECATED( void SetStyle(long style) );
  64. #endif // WXWIN_COMPATIBILITY_2_6
  65. virtual void SetMessage(const wxString& message) { m_message = message; }
  66. virtual void SetPath(const wxString& path) { m_path = path; }
  67. virtual wxString GetMessage() const { return m_message; }
  68. virtual wxString GetPath() const { return m_path; }
  69. protected:
  70. wxString m_message;
  71. wxString m_path;
  72. };
  73. // Universal and non-port related switches with need for generic implementation
  74. #if defined(__WXUNIVERSAL__)
  75. #include "wx/generic/dirdlgg.h"
  76. #define wxDirDialog wxGenericDirDialog
  77. #elif defined(__WXMSW__) && (!wxUSE_OLE || \
  78. (defined (__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS))
  79. #include "wx/generic/dirdlgg.h"
  80. #define wxDirDialog wxGenericDirDialog
  81. #elif defined(__WXMSW__) && defined(__WXWINCE__) && !defined(__HANDHELDPC__)
  82. #include "wx/generic/dirdlgg.h" // MS PocketPC or MS Smartphone
  83. #define wxDirDialog wxGenericDirDialog
  84. #elif defined(__WXMSW__)
  85. #include "wx/msw/dirdlg.h" // Native MSW
  86. #elif defined(__WXGTK20__)
  87. #include "wx/gtk/dirdlg.h" // Native GTK for gtk2.4
  88. #elif defined(__WXGTK__)
  89. #include "wx/generic/dirdlgg.h"
  90. #define wxDirDialog wxGenericDirDialog
  91. #elif defined(__WXMAC__)
  92. #include "wx/osx/dirdlg.h" // Native Mac
  93. #elif defined(__WXCOCOA__)
  94. #include "wx/cocoa/dirdlg.h" // Native Cocoa
  95. #elif defined(__WXMOTIF__) || \
  96. defined(__WXX11__) || \
  97. defined(__WXCOCOA__) || \
  98. defined(__WXPM__)
  99. #include "wx/generic/dirdlgg.h" // Other ports use generic implementation
  100. #define wxDirDialog wxGenericDirDialog
  101. #endif
  102. // ----------------------------------------------------------------------------
  103. // common ::wxDirSelector() function
  104. // ----------------------------------------------------------------------------
  105. WXDLLIMPEXP_CORE wxString
  106. wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
  107. const wxString& defaultPath = wxEmptyString,
  108. long style = wxDD_DEFAULT_STYLE,
  109. const wxPoint& pos = wxDefaultPosition,
  110. wxWindow *parent = NULL);
  111. #endif // wxUSE_DIRDLG
  112. #endif
  113. // _WX_DIRDLG_H_BASE_