49 assert(this->min_year <= this->max_year);
53 if (initial_date == 0) initial_date =
_date;
74 default: NOT_REACHED();
77 for (uint i = 0; i < 31; i++) {
80 selected = this->date.
day;
84 for (uint i = 0; i < 12; i++) {
87 selected = this->date.
month;
91 for (
Year i = this->min_year; i <= this->
max_year; i++) {
96 selected = this->date.
year;
110 for (uint i = 0; i < 31; i++) {
116 for (uint i = 0; i < 12; i++) {
127 d.width += padding.width;
128 d.height += padding.height;
161 this->date.
day = index;
165 this->date.
month = index;
169 this->date.
year = index;
203 _nested_set_date_widgets,
lengthof(_nested_set_date_widgets)
218 new SetDateWindow(&_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback);
Functions related to OTTD's strings.
ResizeInfo resize
Resize information.
static WindowDesc _set_date_desc(WDP_CENTER, NULL, 0, 0, WC_SET_DATE, WC_NONE, 0, _nested_set_date_widgets, lengthof(_nested_set_date_widgets))
Description of the date setting window.
Window * parent
Parent window.
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.
High level window description.
int left
x position of left edge of the window
Functions related to dates.
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Compute the initial position of the window.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback)
Create the new 'set date' window.
int top
y position of top edge of the window
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
static T max(const T a, const T b)
Returns the maximum of two values.
Functions, definitions and such used only by the GUI.
Year min_year
The minimum year in the year dropdown.
T * Append(uint to_add=1)
Append an item and return it.
Data structure for an opened window.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Simple vector template class, with automatic delete.
Definition of base types and functions in a cross-platform compatible way.
Data structure to convert between Date and triplet (year, month, and day).
Window to select a date graphically by using dropdowns.
A number of safeguards to prevent using unsafe methods.
void ShowSetDateWindow(Window *parent, int window_number, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback)
Create the new 'set date' window.
Set date; Window numbers:
void SetDateCallback(const Window *w, Date date)
Callback for when a date has been chosen.
#define lengthof(x)
Return the length of an fixed size array.
static T min(const T a, const T b)
Returns the minimum of two values.
Types related to the drop down widget.
YearMonthDay date
The currently selected date.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
void ShowDateDropDown(int widget)
Helper function to construct the dropdown.
SetDateCallback * callback
Callback to call when a date has been selected.
Functions related to the graphical selection of a date.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
static const NWidgetPart _nested_set_date_widgets[]
Widgets for the date setting window.
Coordinates of a point in 2D.
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
int32 Date
The type to store our dates in.
Year max_year
The maximum year (inclusive) in the year dropdown.
int width
width of the window (number of pixels to the right in x direction)
int32 WindowNumber
Number to differentiate different windows of the same class.
WindowNumber window_number
Window number within the window class.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Window functions not directly related to making/drawing windows.
String list item with parameters.
Date _date
Current date in days (day counter)
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Dimensions (a width and height) of a rectangle in 2D.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
int height
Height of the window (number of pixels down in y direction)
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.