# SetDateWindow Struct Reference

Window to select a date graphically by using dropdowns. More...

Inheritance diagram for SetDateWindow:

## Public Member Functions
| SetDateWindow (const WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback)
| Create the new 'set date' window.
virtual Point | OnInitialPosition (const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
| Compute the initial position of the window.
void | ShowDateDropDown (int widget)
| Helper function to construct the dropdown.
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
| Update size and resize step of a widget in the window.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
virtual void | OnPaint ()
| The window must be repainted.
virtual void | OnClick (Point pt, int widget)
| A click with the left mouse button has been made on the window.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
## Data Fields
SetDateCallback * | callback
| Callback to call when a date has been selected.
YearMonthDay | date
| The currently selected date.
Year | min_year
| The minimum year in the year dropdown.
Year | max_year
| The maximum year (inclusive) in the year dropdown.

## Detailed Description

Window to select a date graphically by using dropdowns.

Definition at line 33 of file date_gui.cpp.

## Constructor & Destructor Documentation

SetDateWindow::SetDateWindow | ( | const WindowDesc * | desc,
|  | WindowNumber | window_number,
|  | Window * | parent,
|  | Date | initial_date,
|  | Year | min_year,
|  | Year | max_year,
|  | SetDateCallback * | callback |
| ) |  |  | `[inline]`

Create the new 'set date' window.

Parameters:

  | desc | the window description
  | window_number | number of the window
  | parent | the parent window, i.e. if this closes we should close too
  | initial_date | the initial date to show
  | min_year | the minimum year to show in the year dropdown
  | max_year | the maximum year (inclusive) to show in the year dropdown
  | callback | the callback to call once a date has been selected

Definition at line 49 of file date_gui.cpp.

References _date, Clamp(), ConvertDateToYMD(), date, Window::InitNested(), and YearMonthDay::year.

## Member Function Documentation

virtual Point SetDateWindow::OnInitialPosition | ( | const WindowDesc * | desc,
|  | int16 | sm_width,
|  | int16 | sm_height,
|  | int | window_number |
| ) |  |  | `[inline, virtual]`

Compute the initial position of the window.

Parameters:

  | *desc | The pointer to the WindowDesc of the window to create.
  | sm_width | Smallest width of the window.
  | sm_height | Smallest height of the window.
  | window_number | The window number of the new window.

Returns:
  Initial position of the top-left corner of the window.

Reimplemented from Window.

Definition at line 64 of file date_gui.cpp.

References Window::height, Window::left, Window::parent, Window::top, and Window::width.

void SetDateWindow::ShowDateDropDown | ( | int | widget | ) | `[inline]`

Helper function to construct the dropdown.

Parameters:

  | widget | the dropdown widget to create the dropdown for

Definition at line 74 of file date_gui.cpp.

References date, YearMonthDay::day, max_year, min_year, YearMonthDay::month, SDW_DAY, SDW_MONTH, SDW_YEAR, DropDownListParamStringItem::SetParam(), ShowDropDownList(), and YearMonthDay::year.

Referenced by OnClick().

virtual void SetDateWindow::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize |
| ) |  |  | `[inline, virtual]`

Update size and resize step of a widget in the window.

After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.

Parameters:

  | widget | Widget number.
  | size | Size of the widget.
  | padding | Recommended amount of space between the widget content and the widget edge.
  | fill | Fill step of the widget.
  | resize | Resize step of the widget.

Reimplemented from Window.

Definition at line 109 of file date_gui.cpp.

References GetStringBoundingBox(), Dimension::height, max_year, maxdim(), min_year, SDW_DAY, SDW_MONTH, SDW_YEAR, SetDParam(), and Dimension::width.

virtual void SetDateWindow::SetStringParameters | ( | int | widget | ) | const`[inline, virtual]`

Initialize string parameters for a widget.

Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

Definition at line 140 of file date_gui.cpp.

References date, YearMonthDay::day, YearMonthDay::month, SDW_DAY, SDW_MONTH, SDW_YEAR, SetDParam(), and YearMonthDay::year.

virtual void SetDateWindow::OnPaint | ( |  | ) | `[inline, virtual]`

The window must be repainted.

Note:
  This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

Definition at line 149 of file date_gui.cpp.

References Window::DrawWidgets().

virtual void SetDateWindow::OnClick | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[inline, virtual]`

A click with the left mouse button has been made on the window.

Parameters:

  | pt | the point inside the window that has been clicked.
  | widget | the clicked widget.

Reimplemented from Window.

Definition at line 154 of file date_gui.cpp.

References callback, ConvertYMDToDate(), date, Window::parent, SDW_DAY, SDW_MONTH, SDW_SET_DATE, SDW_YEAR, ShowDateDropDown(), and YearMonthDay::year.

virtual void SetDateWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 170 of file date_gui.cpp.

References date, YearMonthDay::day, YearMonthDay::month, SDW_DAY, SDW_MONTH, SDW_YEAR, Window::SetDirty(), and YearMonthDay::year.

The documentation for this struct was generated from the following file:

- src/date_gui.cpp