About
DateTimeControl is the CustomGui element that represents a DateTimeData. DateTimeData handles date and time, see page_manual_customdata_datetimedata::
In a GeDialog it is represented by two fields, one for the date, the other for the time. Both fields can be displayed or only one.
A "now" button can also be added to defines the stored DateTimeData to the actual date/time.
The gadget can be maximized and show a calendar and a clock.
Usage with a GeDialog
DateTimeControl can be added and used in a GeDialog, more information in GeDialog Manual.
Add a DateTimeControl.
This example shows how to add a DateTimeControl in GeDialog::CreateLayout() using GeDialog::AddCustomGui().
BaseContainer settings;
#define DATETIME_GUI
DateTime custom GUI ID.
Definition: customgui_datetime.h:19
#define DATETIME_DATE_CONTROL
::Bool true, if it is a calendar.
Definition: customgui_datetime.h:28
#define DATETIME_TIME_CONTROL
::Bool true, if it is a clock.
Definition: customgui_datetime.h:27
#define DATETIME_SHOW_LABELS
::Bool true, to show the "Date" and "Time" labels if the GUI is collapsed.
Definition: customgui_datetime.h:31
#define DATETIME_NOW_BUTTON
::Bool true, to add "Now" button.
Definition: customgui_datetime.h:29
Int32 SizePix(Int32 pixels)
Definition: c4d_gui.h:3234
@ BFV_TOP
Aligned to the top. 1<<0.
Definition: gui.h:304
@ BFH_LEFT
Aligned to the left. 1<<3.
Definition: gui.h:312
Access
Accessing the value of a DateTimeControl CustomGui gadget is done by using a pointer to this gadget, or by using GeDialog::FindCustomGui() if it has been added with GeDialog::AddCustomGui().
DateTime can be retrieved by using the function DateTimeControl::GetDateTime().
DateTimeControl* dateTimeGadget =
static_cast<DateTimeControl*
>(FindCustomGui(dateTimeID,
DATETIME_GUI));
if (dateTimeGadget == nullptr)
return false;
const DateTime myDateTime = dateTimeGadget->GetDateTime();
String myTimeAsString =
FormatTime(
"%A %d %B %G", myDateTime);
String FormatTime(const char *pszFormat, const DateTime &t)
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170
#define FormatString(...)
Definition: string.h:2218
Setting the value of the gadget is done through a pointer to the gadget and the function DateTimeControl::SetDateTime().
const DateTime timeToSet(1955, 10, 28, 15, 00, 00);
DateTimeControl* dateTimeGadget =
static_cast<DateTimeControl*
>(FindCustomGui(dateTimeID,
DATETIME_GUI));
if (dateTimeGadget == nullptr)
return false;
dateTimeGadget->SetDateTime(timeToSet, true, false);
Usage with a parameter description
DateTimeControl can also be used as a description of a parameter. For a description, a parameter has to be added and the custom GUI defined. See DateTimeData Manual for more details.
Resource
For a description and a dialog resource file, the symbol to add is: DATETIME
For common flags see page_description_resource::section_descriptionresource_elementflags.
For DateTimeControl flags, see DATETIME.
See Description Resource for more information about description resource.
See Dialog Resource for more information about dialog resource.
Settings
Settings can be defined for extra functionality. Some only make sense in a description.
See page_customgui_resource for a description of the common settings.
See Description Settings Manual for more information about settings.
- ::DESC_CUSTOMGUI should be set to CUSTOMGUI_DATETIME Set the CustomGUI gadget type (only for descriptions).
- DATETIME_NOW_BUTTON set to true to add the Now button.
- DATETIME_TIME_CONTROL set to true to show the Time field.
- DATETIME_DATE_CONTROL set to true to show the Date field.
- DATETIME_NO_SECONDS set to true to not show seconds.
- DATETIME_SHOW_LABELS set to true to show the "Date" and "Time" labels if the GUI is collapsed.
- ::DESC_GUIOPEN set to true if the maximized GUI is shown by default.
- ::DESC_ANIMATE_MIX Parameter is animatable, but needs to know the left and right data element (only for description).
Data Type handled
DateTimeControl can handle DateTimeData. For more information, see DateTimeData Manual.
Further Reading