xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
date_time_picker.h
1 #pragma once
2 #include <chrono>
3 #include "control.h"
4 #include "date_time_picker_format.h"
5 
7 namespace xtd {
9  namespace forms {
10  class date_time_picker : public control {
11  public:
13 
14  virtual date_time_picker_format format() const {return format_;}
16 
17  virtual std::chrono::system_clock::time_point max_date() const {return max_date_;}
18  virtual control& max_date(std::chrono::system_clock::time_point max_date);
19  virtual control& max_date(time_t max_date) {return this->max_date(std::chrono::system_clock::from_time_t(max_date));}
20  virtual control& max_date(const std::tm& max_date) {
21  std::tm internal_max_date = max_date;
22  return this->max_date(mktime(&internal_max_date));
23  }
24 
25  virtual std::chrono::system_clock::time_point min_date() const {return max_date_;}
26  virtual control& min_date(std::chrono::system_clock::time_point min_date);
27  virtual control& min_date(time_t min_date) {return this->min_date(std::chrono::system_clock::from_time_t(min_date));}
28  virtual control& min_date(const std::tm& min_date) {
29  std::tm internal_min_date = min_date;
30  return this->min_date(mktime(&internal_min_date));
31  }
32 
33  virtual std::chrono::system_clock::time_point value() const {return value_;}
34  virtual control& value(std::chrono::system_clock::time_point value);
35  virtual control& value(time_t value) {return this->value(std::chrono::system_clock::from_time_t(value));}
36  virtual control& value(const std::tm& value) {
37  std::tm internal_value = value;
38  return this->value(mktime(&internal_value));
39  }
40 
41  drawing::size default_size() const override {return{100, 25};}
42 
43  event<date_time_picker, event_handler<control&>> value_changed;
44 
45  protected:
46  forms::create_params create_params() const override;
47 
49 
50  drawing::color default_fore_color() const override {return drawing::system_colors::window_text();}
51 
52  virtual void on_value_changed(const event_args& e);
53 
54  void on_handle_created(const event_args& e) override;
55 
59  void wnd_proc(message& message) override;
60 
61  private:
62  void wm_click(message& message);
64  std::chrono::system_clock::time_point max_date_ = std::chrono::system_clock::time_point::max();
65  std::chrono::system_clock::time_point min_date_ = std::chrono::system_clock::time_point::min();
66  std::chrono::system_clock::time_point value_ = std::chrono::system_clock::now();
67  };
68  }
69 }
Definition: date_time_picker.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
static xtd::drawing::color window_text()
void wnd_proc(message &message) override
Processes Windows messages.
Definition: message.h:10
The date_time_picker control displays the date/time value in the long date format set by the user&#39;s o...
Defines the base class for controls, which are components with visual representation.
Definition: control.h:59
forms::create_params create_params() const override
Gets the required creation parameters when the control handle is created.
date_time_picker_format
Specifies the date and time format the date_time_picker control displays.
Definition: date_time_picker_format.h:10
static xtd::drawing::color window()
drawing::color default_back_color() const override
Gets the default background color of the control.
Definition: date_time_picker.h:48