OpenTTD Source  20240919-master-gdf0233f4c2
date_gui.cpp File Reference
#include "stdafx.h"
#include "strings_func.h"
#include "timer/timer_game_economy.h"
#include "window_func.h"
#include "window_gui.h"
#include "date_gui.h"
#include "core/geometry_func.hpp"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "widgets/date_widget.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

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

Functions

void ShowSetDateWindow (Window *parent, int window_number, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data)
 Create the new 'set date' window. More...
 

Variables

static constexpr NWidgetPart _nested_set_date_widgets []
 Widgets for the date setting window. More...
 
static WindowDesc _set_date_desc (WDP_CENTER, nullptr, 0, 0, WC_SET_DATE, WC_NONE, 0, _nested_set_date_widgets)
 Description of the date setting window.
 

Detailed Description

Graphical selection of a date.

Definition in file date_gui.cpp.

Function Documentation

◆ ShowSetDateWindow()

void ShowSetDateWindow ( Window parent,
int  window_number,
TimerGameEconomy::Date  initial_date,
TimerGameEconomy::Year  min_year,
TimerGameEconomy::Year  max_year,
SetDateCallback callback,
void *  callback_data 
)

Create the new 'set date' window.

Parameters
window_numbernumber for the window
parentthe parent window, i.e. if this closes we should close too
initial_datethe initial date to show
min_yearthe minimum year to show in the year dropdown
max_yearthe maximum year (inclusive) to show in the year dropdown
callbackthe callback to call once a date has been selected
callback_dataextra callback data

Definition at line 216 of file date_gui.cpp.

References _set_date_desc, CloseWindowByClass(), and WC_SET_DATE.

Variable Documentation

◆ _nested_set_date_widgets

constexpr NWidgetPart _nested_set_date_widgets[]
staticconstexpr
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_DATE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PANEL, COLOUR_BROWN),
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_SD_DAY), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_DATE_DAY_TOOLTIP),
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_SD_MONTH), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_DATE_MONTH_TOOLTIP),
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_SD_YEAR), SetFill(1, 0), SetDataTip(STR_JUST_INT, STR_DATE_YEAR_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_SD_SET_DATE), SetMinimalSize(100, 12), SetDataTip(STR_DATE_SET_DATE, STR_DATE_SET_DATE_TOOLTIP),
}

Widgets for the date setting window.

Definition at line 177 of file date_gui.cpp.

SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1183
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1193
WID_SD_MONTH
@ WID_SD_MONTH
Dropdown for the month.
Definition: date_widget.h:16
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:526
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:114
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1311
WID_SD_YEAR
@ WID_SD_YEAR
Dropdown for the year.
Definition: date_widget.h:17
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1262
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
WID_SD_SET_DATE
@ WID_SD_SET_DATE
Actually set the date.
Definition: date_widget.h:18
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:81
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1139
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1204
WID_SD_DAY
@ WID_SD_DAY
Dropdown for the day.
Definition: date_widget.h:15
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72