# `wxDatePickerCtrl`
[🔗](https://github.com/erlang/otp/blob/master/lib/wx/src/gen/wxDatePickerCtrl.erl#L58)

This control allows the user to select a date.

Unlike `m:wxCalendarCtrl`, which is a relatively big control, `m:wxDatePickerCtrl` is
implemented as a small window showing the currently selected date. The control can be
edited using the keyboard, and can also display a popup window for more user-friendly date
selection, depending on the styles used and the platform.

It is only available if `wxUSE_DATEPICKCTRL` is set to 1.

## Styles

This class supports the following styles:

* wxDP_SPIN: Creates a control without a month calendar drop down but with
spin-control-like arrows to change individual date components. This style is not supported
by the generic version.

* wxDP_DROPDOWN: Creates a control with a month calendar drop-down part from which the user
can select a date. This style is not supported in OSX/Cocoa native version.

* wxDP_DEFAULT: Creates a control with the style that is best supported for the current
platform (currently wxDP_SPIN under Windows and OSX/Cocoa and wxDP_DROPDOWN elsewhere).

* wxDP_ALLOWNONE: With this style, the control allows the user to not enter any valid date
at all. Without it - the default - the control always has some valid date. This style is
not supported in OSX/Cocoa native version.

* wxDP_SHOWCENTURY: Forces display of the century in the default date format. Without this
style the century could be displayed, or not, depending on the default date representation
in the system. This style is not supported in OSX/Cocoa native version currently. As can
be seen from the remarks above, most of the control style are only supported in the native
MSW implementation. In portable code it's recommended to use `wxDP_DEFAULT` style only,
possibly combined with `wxDP_SHOWCENTURY` (this is also the style used by default if none
is specified).

See:
* `m:wxCalendarCtrl`

* `m:wxDateEvent`

This class is derived, and can use functions, from:

* `m:wxPickerBase`

* `m:wxControl`

* `m:wxWindow`

* `m:wxEvtHandler`

wxWidgets docs: [wxDatePickerCtrl](https://docs.wxwidgets.org/3.2/classwx_date_picker_ctrl.html)

## Events

Event types emitted from this class:

* [`date_changed`](`m:wxDateEvent`)

# `wxDatePickerCtrl`

```elixir
-type wxDatePickerCtrl() :: wx:wx_object().
```

# `destroy`

```elixir
-spec destroy(This :: wxDatePickerCtrl()) -> ok.
```

Destroys the object

# `getRange`

```elixir
-spec getRange(This, Dt1, Dt2) -> boolean()
                  when This :: wxDatePickerCtrl(), Dt1 :: wx:wx_datetime(), Dt2 :: wx:wx_datetime().
```

If the control had been previously limited to a range of dates using `setRange/3`,
returns the lower and upper bounds of this range.

If no range is set (or only one of the bounds is set), `dt1` and/or `dt2` are set to be invalid.

Notice that when using a native MSW implementation of this control the lower range is
always set, even if `setRange/3` hadn't been called explicitly, as the native control only supports
dates later than year 1601.

Return: false if no range limits are currently set, true if at least one bound is set.

# `getValue`

```elixir
-spec getValue(This) -> wx:wx_datetime() when This :: wxDatePickerCtrl().
```

Returns the currently entered date.

For a control with `wxDP_ALLOWNONE` style the returned value may be invalid if no date is
entered, otherwise it is always valid.

# `new`

```elixir
-spec new() -> wxDatePickerCtrl().
```

Default constructor.

# `new`

```elixir
-spec new(Parent, Id) -> wxDatePickerCtrl() when Parent :: wxWindow:wxWindow(), Id :: integer().
```

# `new`

```elixir
-spec new(Parent, Id, [Option]) -> wxDatePickerCtrl()
             when
                 Parent :: wxWindow:wxWindow(),
                 Id :: integer(),
                 Option ::
                     {date, wx:wx_datetime()} |
                     {pos, {X :: integer(), Y :: integer()}} |
                     {size, {W :: integer(), H :: integer()}} |
                     {style, integer()} |
                     {validator, wx:wx_object()}.
```

Initializes the object and calls `Create()` (not implemented in wx) with all the
parameters.

# `setRange`

```elixir
-spec setRange(This, Dt1, Dt2) -> ok
                  when This :: wxDatePickerCtrl(), Dt1 :: wx:wx_datetime(), Dt2 :: wx:wx_datetime().
```

Sets the valid range for the date selection.

If `dt1` is valid, it becomes the earliest date (inclusive) accepted by the control. If `dt2`
is valid, it becomes the latest possible date.

Notice that if the current value is not inside the new range, it will be adjusted to lie
inside it, i.e. calling this method can change the control value, however no events are
generated by it.

Remark: If the current value of the control is outside of the newly set range bounds, the
behaviour is undefined.

# `setValue`

```elixir
-spec setValue(This, Dt) -> ok when This :: wxDatePickerCtrl(), Dt :: wx:wx_datetime().
```

Changes the current value of the control.

The date should be valid unless the control was created with `wxDP_ALLOWNONE` style and
included in the currently selected range, if any.

Calling this method does not result in a date change event.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
