xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
date_time_picker.h
Go to the documentation of this file.
1
4#pragma once
5#include <chrono>
6#include "control.h"
8
10namespace xtd {
12 namespace forms {
23 public:
26
30 virtual date_time_picker_format format() const {return format_;}
36
39 virtual std::chrono::system_clock::time_point max_date() const {return max_date_;}
43 virtual control& max_date(std::chrono::system_clock::time_point max_date);
47 virtual control& max_date(time_t max_date) {return this->max_date(std::chrono::system_clock::from_time_t(max_date));}
51 virtual control& max_date(const std::tm& max_date) {
52 std::tm internal_max_date = max_date;
53 return this->max_date(mktime(&internal_max_date));
54 }
58 virtual control& max_date(int32_t year, int32_t month, int32_t day) {
59 std::tm internal_max_date = {};
60 internal_max_date.tm_year = year - 1900;
61 internal_max_date.tm_mon = month - 1;
62 internal_max_date.tm_mday = day;
63 return max_date(mktime(&internal_max_date));
64 }
68 virtual control& max_date(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second) {
69 std::tm internal_max_date = {};
70 internal_max_date.tm_year = year - 1900;
71 internal_max_date.tm_mon = month - 1;
72 internal_max_date.tm_mday = day;
73 internal_max_date.tm_hour = hour;
74 internal_max_date.tm_min = minute;
75 internal_max_date.tm_sec = second;
76 return max_date(mktime(&internal_max_date));
77 }
78
81 virtual std::chrono::system_clock::time_point min_date() const {return max_date_;}
85 virtual control& min_date(std::chrono::system_clock::time_point min_date);
89 virtual control& min_date(time_t min_date) {return this->min_date(std::chrono::system_clock::from_time_t(min_date));}
93 virtual control& min_date(const std::tm& min_date) {
94 std::tm internal_min_date = min_date;
95 return this->min_date(mktime(&internal_min_date));
96 }
100 virtual control& min_date(int32_t year, int32_t month, int32_t day) {
101 std::tm internal_min_date = {};
102 internal_min_date.tm_year = year - 1900;
103 internal_min_date.tm_mon = month - 1;
104 internal_min_date.tm_mday = day;
105 return min_date(mktime(&internal_min_date));
106 }
110 virtual control& min_date(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second) {
111 std::tm internal_min_date = {};
112 internal_min_date.tm_year = year - 1900;
113 internal_min_date.tm_mon = month - 1;
114 internal_min_date.tm_mday = day;
115 internal_min_date.tm_hour = hour;
116 internal_min_date.tm_min = minute;
117 internal_min_date.tm_sec = second;
118 return min_date(mktime(&internal_min_date));
119 }
120
123 virtual std::chrono::system_clock::time_point value() const {return value_;}
126 virtual control& value(std::chrono::system_clock::time_point value);
129 virtual control& value(time_t value) {return this->value(std::chrono::system_clock::from_time_t(value));}
132 virtual control& value(const std::tm& value) {
133 std::tm internal_value = value;
134 return this->value(mktime(&internal_value));
135 }
138 virtual control& value(int32_t year, int32_t month, int32_t day) {
139 std::tm internal_value = {};
140 internal_value.tm_year = year - 1900;
141 internal_value.tm_mon = month - 1;
142 internal_value.tm_mday = day;
143 return value(mktime(&internal_value));
144 }
147 virtual control& value(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second) {
148 std::tm internal_value = {};
149 internal_value.tm_year = year - 1900;
150 internal_value.tm_mon = month - 1;
151 internal_value.tm_mday = day;
152 internal_value.tm_hour = hour;
153 internal_value.tm_min = minute;
154 internal_value.tm_sec = second;
155 return value(mktime(&internal_value));
156 }
157
158 drawing::size default_size() const override {return {100, 25};}
159
163
164 protected:
165 forms::create_params create_params() const override;
166
167 drawing::color default_back_color() const override {return xtd::forms::theme_colors::current_theme().window();}
168
169 drawing::color default_fore_color() const override {return xtd::forms::theme_colors::current_theme().window_text();}
170
173 virtual void on_value_changed(const event_args& e);
174
175 void on_handle_created(const event_args& e) override;
176
177 void wnd_proc(message& message) override;
178
179 private:
180 void wm_click(message& message);
181 date_time_picker_format format_ = date_time_picker_format::long_format;
182 std::chrono::system_clock::time_point max_date_ = std::chrono::system_clock::time_point::max();
183 std::chrono::system_clock::time_point min_date_ = std::chrono::system_clock::time_point::min();
184 std::chrono::system_clock::time_point value_ = std::chrono::system_clock::now();
185 };
186 }
187}
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:39
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:25
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents an event.
Definition event.h:21
Defines the base class for controls, which are components with visual representation.
Definition control.h:67
Represents a picker control that displays available date time along with controls.
Definition date_time_picker.h:22
void wnd_proc(message &message) override
Processes Windows messages.
virtual control & min_date(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second)
Sets the minimum date and time that can be selected in the control.
Definition date_time_picker.h:110
virtual date_time_picker_format format() const
Gets the format of the date and time displayed in the control.
Definition date_time_picker.h:30
virtual std::chrono::system_clock::time_point value() const
Gets the date/time value assigned to the control.
Definition date_time_picker.h:123
virtual std::chrono::system_clock::time_point min_date() const
Gets the minimum date and time that can be selected in the control.
Definition date_time_picker.h:81
virtual control & value(const std::tm &value)
Sets the date/time value assigned to the control.
Definition date_time_picker.h:132
virtual void on_value_changed(const event_args &e)
Raises the date_time_picker::value_changed event.
virtual control & max_date(time_t max_date)
Sets the maximum date and time that can be selected in the control.
Definition date_time_picker.h:47
virtual control & format(date_time_picker_format format)
Sets the format of the date and time displayed in the control.
virtual control & min_date(std::chrono::system_clock::time_point min_date)
Sets the minimum date and time that can be selected in the control.
drawing::size default_size() const override
Gets the default size of the control.
Definition date_time_picker.h:158
virtual control & max_date(int32_t year, int32_t month, int32_t day)
Sets the maximum date and time that can be selected in the control.
Definition date_time_picker.h:58
virtual control & max_date(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second)
Sets the maximum date and time that can be selected in the control.
Definition date_time_picker.h:68
virtual std::chrono::system_clock::time_point max_date() const
Gets the maximum date and time that can be selected in the control.
Definition date_time_picker.h:39
virtual control & min_date(const std::tm &min_date)
Sets the minimum date and time that can be selected in the control.
Definition date_time_picker.h:93
virtual control & value(int32_t year, int32_t month, int32_t day)
Sets the date/time value assigned to the control.
Definition date_time_picker.h:138
virtual control & max_date(std::chrono::system_clock::time_point max_date)
Sets the maximum date and time that can be selected in the control.
date_time_picker()
Initializes a new instance of the date_time_picker class.
virtual control & value(std::chrono::system_clock::time_point value)
Sets the date/time value assigned to the control.
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
drawing::color default_fore_color() const override
Gets the default foreground color of the control.
Definition date_time_picker.h:169
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition date_time_picker.h:167
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
virtual control & max_date(const std::tm &max_date)
Sets the maximum date and time that can be selected in the control.
Definition date_time_picker.h:51
virtual control & value(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second)
Sets the date/time value assigned to the control.
Definition date_time_picker.h:147
virtual control & min_date(int32_t year, int32_t month, int32_t day)
Sets the minimum date and time that can be selected in the control.
Definition date_time_picker.h:100
virtual control & value(time_t value)
Sets the date/time value assigned to the control.
Definition date_time_picker.h:129
virtual control & min_date(time_t min_date)
Sets the minimum date and time that can be selected in the control.
Definition date_time_picker.h:89
Implements a Windows message.
Definition message.h:25
Contains xtd::forms::control control.
Contains xtd::forms::date_time_picker_format enum class.
event< date_time_picker, event_handler > value_changed
Occurs when the value of the value property changes.
Definition date_time_picker.h:162
#define forms_export_
Define shared library export.
Definition forms_export.h:13
date_time_picker_format
Specifies the date and time format the date_time_picker control displays.
Definition date_time_picker_format.h:18
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17