datectrl.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/datectrl.h
  3. // Purpose: implements wxDatePickerCtrl
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 2005-01-09
  7. // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DATECTRL_H_
  11. #define _WX_DATECTRL_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_DATEPICKCTRL
  14. #include "wx/datetimectrl.h" // the base class
  15. #define wxDatePickerCtrlNameStr wxT("datectrl")
  16. // wxDatePickerCtrl styles
  17. enum
  18. {
  19. // default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN
  20. wxDP_DEFAULT = 0,
  21. // a spin control-like date picker (not supported in generic version)
  22. wxDP_SPIN = 1,
  23. // a combobox-like date picker (not supported in mac version)
  24. wxDP_DROPDOWN = 2,
  25. // always show century in the default date display (otherwise it depends on
  26. // the system date format which may include the century or not)
  27. wxDP_SHOWCENTURY = 4,
  28. // allow not having any valid date in the control (by default it always has
  29. // some date, today initially if no valid date specified in ctor)
  30. wxDP_ALLOWNONE = 8
  31. };
  32. // ----------------------------------------------------------------------------
  33. // wxDatePickerCtrl: allow the user to enter the date
  34. // ----------------------------------------------------------------------------
  35. class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxDateTimePickerCtrl
  36. {
  37. public:
  38. /*
  39. The derived classes should implement ctor and Create() method with the
  40. following signature:
  41. bool Create(wxWindow *parent,
  42. wxWindowID id,
  43. const wxDateTime& dt = wxDefaultDateTime,
  44. const wxPoint& pos = wxDefaultPosition,
  45. const wxSize& size = wxDefaultSize,
  46. long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
  47. const wxValidator& validator = wxDefaultValidator,
  48. const wxString& name = wxDatePickerCtrlNameStr);
  49. */
  50. /*
  51. We inherit the methods to set/get the date from the base class.
  52. virtual void SetValue(const wxDateTime& dt) = 0;
  53. virtual wxDateTime GetValue() const = 0;
  54. */
  55. // And add methods to set/get the allowed valid range for the dates. If
  56. // either/both of them are invalid, there is no corresponding limit and if
  57. // neither is set, GetRange() returns false.
  58. virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
  59. virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0;
  60. };
  61. #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
  62. #include "wx/msw/datectrl.h"
  63. #define wxHAS_NATIVE_DATEPICKCTRL
  64. #elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
  65. #include "wx/osx/datectrl.h"
  66. #define wxHAS_NATIVE_DATEPICKCTRL
  67. #else
  68. #include "wx/generic/datectrl.h"
  69. class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlGeneric
  70. {
  71. public:
  72. wxDatePickerCtrl() { }
  73. wxDatePickerCtrl(wxWindow *parent,
  74. wxWindowID id,
  75. const wxDateTime& date = wxDefaultDateTime,
  76. const wxPoint& pos = wxDefaultPosition,
  77. const wxSize& size = wxDefaultSize,
  78. long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
  79. const wxValidator& validator = wxDefaultValidator,
  80. const wxString& name = wxDatePickerCtrlNameStr)
  81. : wxDatePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name)
  82. {
  83. }
  84. private:
  85. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl)
  86. };
  87. #endif
  88. #endif // wxUSE_DATEPICKCTRL
  89. #endif // _WX_DATECTRL_H_