#include <wx/timectrl.h>
This control allows the user to enter time.
It is similar to wxDatePickerCtrl but is used for time, and not date, selection. While GetValue() and SetValue() still work with values of type wxDateTime (because wxWidgets doesn't provide a time-only class), their date part is ignored by this control.
It is only available if wxUSE_TIMEPICKCTRL
is set to 1.
This control currently doesn't have any specific flags.
The following event handler macros redirect the events to member function handlers 'func' with prototypes like:
Event macros for events emitted by this class:
![]() | ![]() | ![]() |
wxMSW appearance | wxGTK appearance | wxMac appearance |
Public Member Functions | |
wxTimePickerCtrl (wxWindow *parent, wxWindowID id, const wxDateTime &dt=wxDefaultDateTime, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTP_DEFAULT, const wxValidator &validator=wxDefaultValidator, const wxString &name="timectrl") | |
Initializes the object and calls Create() with all the parameters. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxDateTime &dt=wxDefaultDateTime, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDP_DEFAULT|wxDP_SHOWCENTURY, const wxValidator &validator=wxDefaultValidator, const wxString &name="timectrl") |
Create the control window. | |
virtual wxDateTime | GetValue () const =0 |
Returns the currently entered time. | |
virtual void | SetValue (const wxDateTime &dt)=0 |
Changes the current value of the control. |
wxTimePickerCtrl::wxTimePickerCtrl | ( | wxWindow * | parent, |
wxWindowID | id, | ||
const wxDateTime & | dt = wxDefaultDateTime , |
||
const wxPoint & | pos = wxDefaultPosition , |
||
const wxSize & | size = wxDefaultSize , |
||
long | style = wxTP_DEFAULT , |
||
const wxValidator & | validator = wxDefaultValidator , |
||
const wxString & | name = "timectrl" |
||
) |
Initializes the object and calls Create() with all the parameters.
bool wxTimePickerCtrl::Create | ( | wxWindow * | parent, |
wxWindowID | id, | ||
const wxDateTime & | dt = wxDefaultDateTime , |
||
const wxPoint & | pos = wxDefaultPosition , |
||
const wxSize & | size = wxDefaultSize , |
||
long | style = wxDP_DEFAULT|wxDP_SHOWCENTURY , |
||
const wxValidator & | validator = wxDefaultValidator , |
||
const wxString & | name = "timectrl" |
||
) |
Create the control window.
This method should only be used for objects created using default constructor.
parent | Parent window, must not be non-NULL. |
id | The identifier for the control. |
dt | The initial value of the control, if an invalid date (such as the default value) is used, the control is set to current time. |
pos | Initial position. |
size | Initial size. If left at default value, the control chooses its own best size by using the height approximately equal to a text control and width large enough to show the time fully. |
style | The window style, should be left at 0 as there are no special styles for this control in this version. |
validator | Validator which can be used for additional checks. |
name | Control name. |
virtual wxDateTime wxTimePickerCtrl::GetValue | ( | ) | const [pure virtual] |
Returns the currently entered time.
The date part of the returned wxDateTime object is always set to today and should be ignored, only the time part is relevant.
virtual void wxTimePickerCtrl::SetValue | ( | const wxDateTime & | dt | ) | [pure virtual] |
Changes the current value of the control.
The date part of dt is ignored, only the time part is displayed in the control. The dt object must however be valid.
Calling this method does not result in a time change event.