xtd 0.2.0
month_calendar.h
Go to the documentation of this file.
1 #pragma once
5 #include "application.h"
6 #include "control.h"
8 #include "day.h"
9 #include "menu.h"
10 #include "selection_range.h"
11 #include <xtd/chrono>
12 
14 namespace xtd {
16  namespace forms {
38  class forms_export_ month_calendar : public control {
39  struct data;
40 
41  public:
44  enum class hit_area {
46  nowhere,
48  title_background,
50  title_month,
52  title_year,
54  next_month_button,
56  prev_month_button,
58  calendar_background,
60  date,
62  next_month_date,
64  prev_month_date,
68  week_numbers,
70  today_link
71  };
72 
76  class hit_test_info final : public xtd::object {
77  public:
79  hit_test_info(const hit_test_info&) = default;
80  hit_test_info& operator =(const hit_test_info&) = default;
82 
86 
89  const xtd::drawing::point& point() const noexcept;
90 
94  const xtd::date_time& time() const noexcept;
95 
96  private:
97  friend class xtd::forms::month_calendar;
99 
101  xtd::drawing::point point_;
102  xtd::date_time time_;
103  };
104 
107 
113  month_calendar();
115 
118 
122  std::vector<xtd::date_time> annually_bolded_dates() const noexcept;
127  month_calendar& annually_bolded_dates(const std::vector<xtd::date_time>& value);
128 
132  std::vector<xtd::date_time> bolded_dates() const noexcept;
137  month_calendar& bolded_dates(const std::vector<xtd::date_time>& value);
138 
142  const xtd::drawing::size& calendar_dimensions() const noexcept;
148 
151  xtd::forms::day first_day_of_week() const noexcept;
156 
159  xtd::date_time max_date() const noexcept;
164 
170  uint32 max_selection_count() const noexcept;
178 
181  xtd::date_time min_date() const noexcept;
186 
190  std::vector<xtd::date_time> monthly_bolded_dates() const noexcept;
195  month_calendar& monthly_bolded_dates(const std::vector<xtd::date_time>& value);
196 
203  xtd::date_time selection_end() const noexcept;
212 
224 
231  xtd::date_time selection_start() const noexcept;
240 
244  bool show_today() const noexcept;
249  month_calendar& show_today(bool value);
250 
254  bool show_today_circle() const noexcept;
259  month_calendar& show_today_circle(bool value);
260 
263  bool show_week_numbers() const noexcept;
267  month_calendar& show_week_numbers(bool value);
268 
272  xtd::drawing::size single_month_size() const noexcept;
273 
277  xtd::drawing::color title_back_color() const noexcept;
283 
286  xtd::drawing::color title_fore_color() const noexcept;
291 
295  const xtd::date_time& today_date() const noexcept;
301 
304  bool today_date_set() const noexcept;
305 
309  xtd::drawing::color trailing_fore_color() const noexcept;
316 
318 
324 
330 
332 
338  void add_annually_bolded_date(const xtd::date_time& date);
339 
344  void add_bolded_date(const xtd::date_time& date);
345 
350  void add_monthly_bolded_date(const xtd::date_time& date);
351 
352  using control::create;
359  static month_calendar create(const forms::selection_range& selection_range, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
367  static month_calendar create(const date_time& selection_start, const date_time& selection_end, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
375  static month_calendar create(const control& parent, const forms::selection_range& selection_range, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
384  static month_calendar create(const control& parent, const date_time& selection_start, const date_time& selection_end, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
385 
395 
400 
405 
410 
415 
419  void remove_bolded_dates(const xtd::date_time& date);
420 
425 
431 
435  void set_date(const xtd::date_time& date);
436 
442  void set_selection_range(const xtd::date_time& date1, const xtd::date_time& date2);
443 
444  xtd::ustring to_string() const noexcept override;
445 
448  void update_bolded_dates();
450 
451  protected:
453 
455  xtd::forms::create_params create_params() const noexcept override;
456  xtd::drawing::color default_back_color() const noexcept override;
457  xtd::drawing::color default_fore_color() const noexcept override;
459 
461 
469  virtual void on_date_changed(const xtd::forms::date_range_event_args& e);
470 
477  virtual void on_date_selected(const xtd::forms::date_range_event_args& e);
478 
479  void on_handle_created(const xtd::event_args& e) override;
480  void wnd_proc(xtd::forms::message& message) override;
482 
483  private:
484  void wm_notify_control(xtd::forms::message& message);
485  void wm_date_selected(xtd::forms::message& message);
486  void wm_date_changed(xtd::forms::message& message);
487  void wm_view_changed(xtd::forms::message& message);
488 
489  std::shared_ptr<data> data_;
490  };
491  }
492 }
493 
495 template<> struct xtd::enum_register<xtd::forms::month_calendar::hit_area> {
497 };
void remove_monthly_bolded_dates(const xtd::date_time &date)
Removes the specified date from the list of monthly bold dates.
bool today_date_set() const noexcept
Gets a value indicating whether the xtd::forms::month_calendar::today_date property has been explicit...
void add_annually_bolded_date(const xtd::date_time &date)
Adds a day that is displayed in bold on an annual basis in the month calendar.
void remove_all_monthly_bolded_dates()
Removes all the monthly bold dates.
The specified point is over a week number. This occurs only if the xtd::forms::month_calendar::show_w...
const xtd::drawing::size & calendar_dimensions() const noexcept
Gets the number of columns and rows of months displayed.
Represents a date selection range in a month calendar control.
Definition: selection_range.h:36
void remove_all_bolded_dates()
Removes all the nonrecurring bold dates.
Contains xtd::forms::application class.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
virtual void on_date_selected(const xtd::forms::date_range_event_args &e)
Raises the xtd::forms::month_calendar::date_selected event.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
virtual void on_date_changed(const xtd::forms::date_range_event_args &e)
Raises the xtd::forms::month_calendar::date_changed event.
void set_calendar_dimensions(int32 x, int32 y)
Sets the number of columns and rows of months to display.
Contains information about an area of a xtd::forms::month_calendar control. This class cannot be inhe...
Definition: month_calendar.h:76
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
std::vector< xtd::date_time > monthly_bolded_dates() const noexcept
Gets the array of xtd::date_time objects that determine which monthly days to bold.
Specifies that the top edge of the control is defined.
xtd::drawing::color title_fore_color() const noexcept
Gets a value indicating the foreground color of the title area of the calendar.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
The specified point is in a month&#39;s title bar, over the year value.
month_calendar()
Initializes a new instance of the month_calendar class.
virtual const xtd::ustring & name() const noexcept
Gets the name of the control.
xtd::drawing::color trailing_fore_color() const noexcept
Gets a value indicating the color of days in months that are not fully displayed in the control...
xtd::drawing::color default_fore_color() const noexcept override
Gets the default foreground color of the control.
The specified point is over the background of a month&#39;s title.
Encapsulates the information needed when creating a control.
Definition: create_params.h:27
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Specifies that the left edge of the control is defined.
Contains xtd::forms::day enum class.
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1063
std::vector< std::pair< enum_t, xtd::ustring > > enum_collection
Represents a pair of an enum_t value and a string of an enum of type enum_t.
Definition: enum_collection.h:19
static control create(const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create a specified control with specified location, size, and name.
day_of_week
Specifies the day of the week.
Definition: day_of_week.h:23
static month_calendar create(const forms::selection_range &selection_range, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create an xtd::forms::month_calendar with specified location, size, and name...
void remove_all_annually_bolded_dates()
Removes all the annually bold dates.
xtd::forms::selection_range selection_range() const noexcept
Gets the selected range of dates for a month calendar control.
Contains xtd::forms::date_range_event_handler event handler.
The specified point is over a date from the previous month (partially displayed at the top of the cur...
bool show_week_numbers() const noexcept
Gets a value indicating whether the month calendar control displays week numbers (1-52) to the left o...
void on_handle_created(const xtd::event_args &e) override
Raises the xtd::forms::control::handle_created event.
xtd::date_time min_date() const noexcept
Gets the minimum date that can be selected in the control.
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:45
xtd::date_time selection_start() const noexcept
Gets the start date of the selected range of dates.
Represents an event.
Definition: event.h:21
xtd::drawing::color default_back_color() const noexcept override
Gets the default background color of the control.
std::vector< xtd::date_time > annually_bolded_dates() const noexcept
Gets the array of xtd::date_time objects that determines which annual days are displayed in bold...
bool show_today_circle() const noexcept
Gets a value indicating whether today&#39;s date is identified with a circle or a square.
event< month_calendar, xtd::forms::date_range_event_handler > date_changed
Occurs when the date selected in the xtd::forms::month_calendar changes.
Definition: month_calendar.h:323
Represents a control that displays a month calendar.
Definition: month_calendar.h:38
The specified point is in a month&#39;s title bar, over a month name.
Represents an instant in time, typically expressed as a date and time of day.
Definition: date_time.h:78
xtd::forms::month_calendar::hit_test_info hit_test(int32 x, int32 y) const
Returns a xtd::forms::month_calendar::hit_test_info with information on which portion of a month cale...
xtd::drawing::size single_month_size() const noexcept
Gets the minimum size to display one month of the calendar.
hit_area
Defines constants that represent areas in a xtd::forms::month_calendar control.
Definition: month_calendar.h:44
day
Specifies the day of the week.
Definition: day.h:19
Provides data for the xtd::forms::month_calendar::date_changed or xtd::forms::month_calendar::date_se...
Definition: date_range_event_args.h:28
The date_time_picker control displays the date/time value in the time format set by the user&#39;s operat...
Implements a Windows message.
Definition: message.h:26
uint32 max_selection_count() const noexcept
Gets the maximum number of days that can be selected in a month calendar control. ...
void add_bolded_date(const xtd::date_time &date)
Adds a day to be displayed in bold in the month calendar.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
const xtd::date_time & today_date() const noexcept
Gets the value that is used by xtd::forms::month_calendar as today&#39;s date.
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
void remove_bolded_dates(const xtd::date_time &date)
Removes the specified date from the list of the nonrecurring bold dates.
The specified point is over the button at the upper-right corner of the control. If the user clicks h...
Contains xtd::forms::selection_range control.
The specified point is over a day abbreviation ("Fri", for example). The System.Windows.Forms.xtd::forms::month_calendar::hit_test_info .xtd::forms::month_calendar::hit_test_info::time property of System.Windows.Forms.xtd::forms::month_calendar::hit_test_info is set to January 1, 0001.
The specified point is either not on the month calendar control, or it is in an inactive portion of t...
xtd::date_time selection_end() const noexcept
Gets the end date of the selected range of dates.
The specified point is over a date from the next month (partially displayed at the top of the current...
void remove_annually_bolded_dates(const xtd::date_time &date)
Removes the specified date from the list of annually bold dates.
Contains xtd::forms::control control.
The specified point is on the today link at the bottom of the month calendar control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
The specified point is on a date within the calendar. The System.Windows.Forms.xtd::forms::month_cale...
xtd::drawing::color title_back_color() const noexcept
Gets a value indicating the background color of the title area of the calendar.
void update_bolded_dates()
Repaints the bold dates to reflect the dates set in the lists of bold dates.
std::vector< xtd::date_time > bolded_dates() const noexcept
Gets the array of xtd::date_time bjects that determines which nonrecurring dates are displayed in bol...
The specified point is over the button at the upper-left corner of the control. If the user clicks he...
Specifies that both the x and y coordinates of the control are defined.
void set_date(const xtd::date_time &date)
Sets a date as the currently selected date.
void add_monthly_bolded_date(const xtd::date_time &date)
Adds a day that is displayed in bold on a monthly basis in the month calendar.
bool show_today() const noexcept
Gets a value indicating whether the date represented by the xtd::today_date property is displayed at ...
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239
event< month_calendar, xtd::forms::date_range_event_handler > date_selected
Occurs when the user makes an explicit date selection using the mouse.
Definition: month_calendar.h:328
xtd::date_time max_date() const noexcept
Gets the maximum date that can be selected in the control.
void wnd_proc(xtd::forms::message &message) override
Processes Windows messages.
void set_selection_range(const xtd::date_time &date1, const xtd::date_time &date2)
Sets the selected dates in a month calendar control to the specified date range.
xtd::forms::day first_day_of_week() const noexcept
Gets the first day of the week as displayed in the month calendar.
size_t size
Represents a size of any object in bytes.
Definition: types.h:195
Provides the registration struct for enumerations.
Definition: enum_register.h:36