Date and Time Selector
 

 < Home   < Developers   < Development Support   < Documentation

8 Date and Time Selector


 Table of Contents  |  < Previous  |  Next >  |  Index
   
   

Title -
Palm OS® Programmer's API Reference

Part I: User Interface

8 Date and Time Selector

Date and Time Selections Data Structures

SelectDayType

DaySelectorType

HMSTime

Date and Time Selection Functions

DayDrawDays

DayDrawDaySelector

DayHandleEvent

SelectDay

SelectDayV10

SelectOneTime

SelectTime

SelectTimeV33

SelectTimeZone

       

The Palm OS® UI provides two system resources for accepting date and time input values. These resources are dialog boxes that contain UI gadgetry for entering dates and times. The Palm OS UI also provides routines to manage the interaction with these resources. This chapter describes those functions.

The API described in this chapter is declared in the header files Day.h, SelDay.h, SelTime.h, and SelTimeZone.h.

Date and Time Selections Data Structures

SelectDayType

  
typedef enum { 
  selectDayByDay,     // return d/m/y 
  selectDayByWeek,  // return d/m/y with d as
                     // same day of the week 
  selectDayByMonth // return d/m/y with d as
                    // same day of the month 
} SelectDayType; 

DaySelectorType

  
typedef struct DaySelectorType { 
  RectangleType  bounds; 
  Boolean        visible; 
  UInt8          reserved1; 
  Int16         visibleMonth; // month actually
                                // displayed 
  Int16          visibleYear;  // year actually
                                 // displayed 
  DateTimeType   selected; 
  SelectDayType  selectDayBy; 
  UInt8          reserved2; 
} DaySelectorType; 

HMSTime

typedef struct { 
  UInt8 hours; 
  UInt8 minutes; 
  UInt8 seconds; 
  UInt8 reserved; 
} HMSTime; 

Date and Time Selection Functions

DayDrawDays

Purpose

Draw only the days-of-the-month portion of a day selector control object.

Prototype

void DayDrawDays (const DaySelectorType *selectorP)

Parameters

-> selectorPPointer to the control object to draw.

Result

Nothing.

Comments

This function is used when the year or month changes. Only drawing the portion of the control that presents the days of the month avoids the flicker that would occur if the week titles were redrawn.

See Also

DayDrawDaySelector

DayDrawDaySelector

Purpose

Draw a day selector control object on screen.

Prototype

void DayDrawDaySelector (const DaySelectorType *selectorP)

Parameters

-> selectorPPointer to the control object to draw.

Result

Nothing.

Comments

The control is drawn only if it is usable.

See Also

DayDrawDays

DayHandleEvent

Purpose

Handle event in the specified control. This routine handles two types of events, penDownEvent and ctlEnterEvent.

Prototype

Boolean DayHandleEvent (DaySelectorType *selectorP, const EventType *pEvent)

Parameters

-> selectorPPointer to control object.
-> pEventPointer to an EventType structure.

Result

true if the event was handled or false if it was not.

Posts a daySelectEvent with information on whether to use the date.

Comments

A date is used if the user selects a day in the visible month.

When this routine receives a penDownEvent, it checks if the pen position is within the bounds of the control object. If it is, a dayEnterEvent is added to the event queue and the routine exits.

When this routine receives a dayEnterEvent, it checks that the control id in the event record matches the id of the control specified. If they match, this routine will track the pen until it comes up in the bounds in which case daySelectEvent is sent.

If the pen exits the bounds a dayExitEvent is sent.

SelectDay

Purpose

Display a form showing a date; allow user to select a different date.

Prototype

Boolean SelectDay (const SelectDayType selectDayBy, Int16 *month, Int16 *day, Int16 *year, const Char *title)

Parameters

selectDayByThe method by which the user should choose the day. Possible values are selectDayByDay,selectDayByWeek, and selectDayByMonth. See SelectDayType
<-> month, day, yearMonth, day, and year selected.
-> titleString title for the dialog.

Result

true if the OK button was pressed. If true, month, day, and year contain the new date.

Compatibility

Implemented only if 2.0 New Feature Set is present.

See Also

SelectDayV10

SelectDayV10

Purpose

Display a form showing a date, allow user to select a different date.

Prototype

Boolean SelectDayV10 (Int16 *month, Int16 *day, Int16 *year, const Char *title)

Parameters

<-> month, day, yearMonth, day, and year selected. The initial values passed in these parameters must be valid.
-> titleString title for the dialog.

Result

Returns true if the OK button was pressed. In that case, the parameters passed are changed.

Compatibility

This function corresponds to the 1.0 version of SelectDay.

See Also

SelectDay

SelectOneTime

Purpose

Display a form showing the time and allow the user to select a different time.

Prototype

Boolean SelectOneTime (Int16 *hour, Int16 *minute, const Char *titleP)

Parameters

<-> hourThe hour selected in the form.
<-> minuteThe minute selected in the form.
-> titlePA pointer to a string to display as the title. Doesn't change as the function executes.

Result

Returns true if the user selects OK and false otherwise. If true is returned, the values in hour and minute have probably been changed.

Comments

Use this function instead of SelectTime if you want to display a dialog that specifies a single point in time, not a range of time from start to end.

Compatibility

Implemented only if 3.1 New Feature Set is present.

See Also

SelectTimeV33

SelectTime

Purpose

Display a form showing a start and end time. Allow the user to select a different time.

Prototype

Boolean SelectTime (TimeType *startTimeP, TimeType * EndTimeP, Boolean untimed, const Char *titleP, Int16 startOfDay, Int16 endOfDay, Int16 startOfDisplay)

Parameters

<-> startTimeP, EndTimePPointers to values of type TimeType. Pass values to display in these two parameters. If the user makes a selection and taps the OK button, the selected values are returned here.
-> untimedPass in true to indicate that no time is selected. If the user sets the time to no time then startTimeP and EndTimeP are both set to the constant noTime (-1).
-> titlePA pointer to a string to display as the title. Doesn't change as the function executes.
-> startOfDayThe hour that the hour list displays at its top. To see earlier hours, the user can scroll the list up. The value must be between 0 to 12, inclusive.
-> endOfDayThe hour used when the "All Day" button is selected.
-> startOfDisplayFirst hour initially visible.

Result

Returns true if the user selects OK and false otherwise. If true is returned, the values in hour and minute have probably been changed.

Comments

This version of SelectTime adds the endOfDay and startOfDisplay functionality.

Compatibility

Implemented if 3.5 New Feature Set is present.

See Also

SelectDay, SelectOneTime

SelectTimeV33

Purpose

Display a form showing the time and allow the user to select a different time.

This function is obsolete and should not be used.

Prototype

Boolean SelectTimeV33 (TimeType *startTimeP, TimeType *EndTimeP, Boolean untimed, const Char *titleP, Int16 startOfDay)

Parameters

<-> startTimeP, EndTimePPointers to values of type TimeType. Pass values to display in these two parameters. If the user makes a selection and taps the OK button, the selected values are returned here.
-> untimedPass in true to indicate that no time is selected. If the user sets the time to no time then startTimeP and EndTimeP are both set to the constant noTime (-1).
-> titlePA pointer to a string to display as the title. Doesn't change as the function executes.
-> startOfDayThe hour that the hour list displays at its top. To see earlier hours, the user can scroll the list up. The value must be between 0 to 12, inclusive.

Result

Returns true if the user selects OK and false otherwise. If true is returned, the values in hour and minute have probably been changed.

Comments


NOTE: Obsolete functions are provided ONLY for backward compatibility; for example, so a 1.0 application will work on 3.x OS releases. New code should not call these routines!

See Also

SelectDay, SelectOneTime

New SelectTimeZone

Purpose

Display a form that allows the user to select a different time zone.

Prototype

Boolean SelectTimeZone (Int16 *ioTimeZoneP, LmLocaleType *ioLocaleInTimeZoneP, const Char *titleP, Boolean showTimes, Boolean anyLocale)

Parameters

<-> ioTimeZonePA pointer to the time zone, given as minutes east of Greenwich Mean Time (GMT). The initial value is used as the initial selection in the form. Upon return, this parameter contains a pointer to the new time zone that the user selected.
<-> ioLocaleInTimeZonePA pointer to a locale (see LmLocaleType) that identifies the time zone country. This parameter is used for countries that share a time zone, such as Canada and Chile.
If the time zone specified by ioTimeZoneP is specific to a particular country, you do not have to initialize this parameter. Instead, set the anyLocale parameter to true to have this parameter ignored upon entry.
-> titlePA string to use as the title for the dialog. Pass NULL to use the default title, which is "Set Time Zone".
-> showTimesIf true, the dialog shows the correct times in both the current and newly selected time zones. If false, the dialog doesn't show the current time. Using false provides a larger area for the list of time zones.
-> anyLocaleIf true, ignore ioLocaleInTimeZoneP upon entry.

Result

Returns true if the user clicked the OK button in the dialog to change the time zone, or false if the user clicked the Cancel button.

Comments

The time zones displayed in the form are listed by country. For this reason, if the time zone specified by ioTimeZoneP is shared by several countries, you need to supply a value for ioLocaleTimeZoneP to identify which country should be selected when the list is first displayed. You can use the constant lmAnyLanguage as the value for the language field of the structure pointed to by this parameter.

If you don't care which value is initially selected, pass true for the anyLocale parameter. In this case, the first country that matches the GMT offset given in ioTimeZoneP is selected.

You might want to use the current time zone stored in the system preferences as the initial value for the ioTimeZoneP parameter. To obtain this time zone, do the following:

Int16 timeZone =  
  (Int16)PrefGetPreference(prefTimeZone);  
CountryType timeZoneCountry = (CountryType) 
  PrefGetPreference(prefTimeZoneCountry); 
LmLocaleType timeZoneLocale; 
Boolean change; 
  
timeZoneLocale.country = timeZoneCountry; 
timeZoneLocale.language = lmAnyLanguage; 
change = SelectTimeZone(&timeZone,  
  &timeZoneLocale, NULL, true, false); 

Compatibility

Implemented if 4.0 New Feature Set is present.