• No results found

Using the calendar control

In document pfcug (Page 184-192)

You use u_calendar (the PFC calendar control) to provide a drop-down calendar for date values in any of the following:

• U_dw-based DataWindow control:

• U_em-based EditMask control:

Users enter dates by clicking on the drop-down calendar, automatically entering the selected date in the associated field. They change months by clicking the >> and << buttons and can also navigate the calendar with keyboard arrow keys.

By default, all days appear with the same characteristics. You can specify a different color for Saturdays and Sundays as well as whether Saturdays and Sundays should appear bold. The calendar also allows you to highlight holidays and other marked days.

The PFC calendar control includes functions that allow you to control certain aspects of calendar behavior. For example, you call the of_SetInitialValue function to control whether the drop-down calendar initializes blank fields with the current date when it first displays.

Using a drop-down calendar with a DataWindow control

The drop-down calendar works with DataWindow columns that have a date data type and are registered with u_calendar.

Depending on the registration option, the calendar displays when a registered column gets focus, when the user clicks the drop-down arrow, or when your code calls the pfc_DDCalendar event.

Controlling the visual cue To control the visual cue that displays in a DataWindow column for which the drop-down calendar is enabled, you supply an argument to the of_Register function:

Column edit styles When the service converts columns to the DropDownListBox edit style, properties that do not apply to

DropDownListBoxes are lost. So you typically use the drop-down calendar with columns that already use the DropDownListBox edit style, calling of_Register passing NONE.

v To use a drop-down calendar with DataWindow columns:

1 Find which date DataWindow columns are appropriate for use with a drop-down calendar. For example, a requested delivery date column might use a drop-down calendar. These columns must use the

DropDownListBox, Edit, or EditMask edit style.

2 Place a u_dw-based DataWindow control on the window or user object. 3 Enable the drop-down calendar by calling the u_dw

of_SetDropdownCalendar function (this example is from a DataWindow Constructor event):

this.of_SetDropDownCalendar(TRUE)

4 Register columns one by one or all at once by calling the of_Register function. Of_Register includes an optional argument specifying the drop-down style:

this.iuo_calendar.of_Register("salary" & this.iuo_calendar.NONE)

Argument Result

NONE If the column uses the:

• DropDownListBox edit style, the calendar displays automatically when the column gets the focus • Edit or EditMask edit style, the calendar displays

when you call the pf_DDCalendar event DDLB Of_Register converts all registered columns to the

DropDownListBox edit style. The calendar displays when the user clicks the down arrow, which disappears when the calendar displays

DDLB_WITHARROW Of_Register converts all registered columns to the DropDownListBox edit style. The calendar displays when the user clicks the down arrow, which remains when the calendar displays

Using custom visual user objects

5 (Optional) Establish the font style and color for weekend days:

this.iuo_calendar.of_SetSaturdayBold(TRUE) this.iuo_calendar.of_SetSaturdayColor & (RGB(0, 255, 0)) this.iuo_calendar.of_SetSundayBold(TRUE) this.iuo_calendar.of_SetSundayColor & (RGB(0, 255, 0))

6 (Optional) Establish a list of holidays with their font style and color (this example shows holidays for one year only):

Date ld_holidays[11] ld_holidays[1] = 1997-01-01 ld_holidays[2] = 1997-02-17 ld_holidays[3] = 1997-04-21 ld_holidays[4] = 1997-05-26 ld_holidays[5] = 1997-07-04 ld_holidays[6] = 1997-09-01 ld_holidays[7] = 1997-10-13 ld_holidays[8] = 1997-11-27 ld_holidays[9] = 1997-11-28 ld_holidays[10] = 1997-12-25 ld_holidays[11] = 1997-12-26 ... this.iuo_calendar.of_SetHoliday(ld_holidays) this.iuo_calendar.of_SetHolidayBold(TRUE) this.iuo_calendar.of_SetHolidayColor & (RGB(0, 255, 0))

7 (Optional) Establish a list of marked days with their font style and color:

Date ld_holidays[11], ld_marked_days[12] ld_marked_days[1] = 1996-06-13 ld_marked_days[2] = 1996-03-16 ld_marked_days[3] = 1996-09-23 ld_marked_days[4] = 1996-09-14 ld_marked_days[5] = 1997-06-13 ld_marked_days[6] = 1997-03-16 ld_marked_days[7] = 1997-09-23 ld_marked_days[8] = 1997-09-14 ld_marked_days[9] = 1998-06-13 ld_marked_days[10] = 1998-03-16 ld_marked_days[11] = 1998-09-23 ld_marked_days[12] = 1998-09-14 ...

this.iuo_calendar.of_SetMarkedDay(ld_marked_days) this.iuo_calendar.of_SetMarkedDayBold(TRUE) this.iuo_calendar.of_SetMarkedDayColor & (RGB(255, 0, 0))

Ensuring consistency

To ensure that all users see the same calendar display, define display characteristics, holidays, and marked days in the u_calendar (extension- level object) Constructor event.

8 (Optional) Call additional functions as necessary to customize calendar behavior: this.iuo_calendar.of_SetAlwaysRedraw(TRUE) this.iuo_calendar.of_SetInitialValue(TRUE) Displaying the calendar programmatically

You can also display the drop-down calendar programmatically. This works with all of_SetRegister options and is required for Edit and EditMask columns when using the NONE option.

v To display the drop-down calendar programmatically:

1 Place a u_dw-based DataWindow control on the window or user object. 2 Enable the drop-down calendar by calling the u_dw

of_SetDropdownCalendar function (this example is from a DataWindow Constructor event):

this.of_SetDropDownCalendar(TRUE)

3 Register columns to be displayed programmatically by calling the of_Register function. Of_Register includes an argument specifying the drop-down style. Programmatic display works best with the NONE style but can be used with any drop-down style:

this.iuo_calendar.of_Register("start_date" & this.iuo_calendar.NONE)

4 Define a user event or visual control (such as a command button) that sets focus in the DataWindow control and calls the u_dw pfc_DDCalendar event: IF dw_1.SetColumn("start_date") = 1 THEN dw_1.Event pfc_DDCalendar( ) END IF Using a drop-down calendar with an EditMask control

You can use a drop-down calculator with EditMask controls that use the date option type.

Using custom visual user objects

v To use a drop-down calendar with an EditMask control:

1 Place a u_em-based EditMask control on the window or user object. 2 Enable the drop-down calendar by calling the u_em

of_SetDropdownCalendar function (this example is from an EditMask Constructor event):

this.of_SetDropDownCalendar(TRUE)

3 (Optional) Establish the font style and color for weekend days:

this.iuo_calendar.of_SetSaturdayBold(TRUE) this.iuo_calendar.of_SetSaturdayColor & (RGB(0, 255, 0)) this.iuo_calendar.of_SetSundayBold(TRUE) this.iuo_calendar.of_SetSundayColor & (RGB(0, 255, 0))

4 (Optional) Establish a list of holidays with their font style and color (this example shows holidays for one year only):

Date ld_holidays[11] ld_holidays[1] = 1997-01-01 ld_holidays[2] = 1997-02-17 ld_holidays[3] = 1997-04-21 ld_holidays[4] = 1997-05-26 ld_holidays[5] = 1997-07-04 ld_holidays[6] = 1997-09-01 ld_holidays[7] = 1997-10-13 ld_holidays[8] = 1997-11-27 ld_holidays[9] = 1997-11-28 ld_holidays[10] = 1997-12-25 ld_holidays[11] = 1997-12-26 ... this.iuo_calendar.of_SetHoliday(ld_holidays) this.iuo_calendar.of_SetHolidayBold(TRUE) this.iuo_calendar.of_SetHolidayColor & (RGB(0, 255, 0))

5 (Optional) Establish a list of marked days with their font style and color:

Date ld_holidays[11], ld_marked_days[12] ld_marked_days[1] = 1996-06-13

ld_marked_days[2] = 1996-03-16 ld_marked_days[3] = 1996-09-23 ld_marked_days[4] = 1996-09-14 ld_marked_days[5] = 1997-06-13

ld_marked_days[6] = 1997-03-16 ld_marked_days[7] = 1997-09-23 ld_marked_days[8] = 1997-09-14 ld_marked_days[9] = 1998-06-13 ld_marked_days[10] = 1998-03-16 ld_marked_days[11] = 1998-09-23 ld_marked_days[12] = 1998-09-14 ... this.iuo_calendar.of_SetMarkedDay(ld_marked_days) this.iuo_calendar.of_SetMarkedDayBold(TRUE) this.iuo_calendar.of_SetMarkedDayColor & (RGB(255, 0, 0))

6 (Optional) Call additional functions as necessary to customize calendar behavior:

this.iuo_calendar.of_SetAlwaysRedraw(TRUE) this.iuo_calendar.of_SetInitialValue(TRUE)

7 Define a user event or visual control (such as a picture button) that displays the drop-down calendar by calling the u_em pfc_DDCalendar event:

em_1.Event pfc_DDCalendar( )

Establishing weekend

display options The PFC calendar control allows you to specify distinct colors and/or bold for Saturdays and Sundays.

v To establish weekend display options:

1 Specify whether Saturdays appear in bold by calling the of_SetSaturdayBold function:

this.iuo_calendar.of_SetSaturdayBold(TRUE)

2 Specify a color for Saturdays by calling the of_SetSaturdayColor function:

this.iuo_calendar.of_SetSaturdayColor & (RGB(0, 255, 0))

3 Specify whether Sundays appear in bold by calling the of_SetSundayBold function:

this.iuo_calendar.of_SetSundayBold(TRUE)

4 Specify a color for Sundays by calling the of_SetSundayColor function:

this.iuo_calendar.of_SetSundayColor & (RGB(0, 255, 0))

Using custom visual user objects

Establishing holidays

and marked days The PFC calendar control allows you to establish a set of holidays and a set of marked days. You can specify distinct colors and/or bold for holidays and marked days. Specify dates for more than one year

Users can navigate through multiple years in the PFC calendar control. You should specify holidays and marked days to handle as many years as needed.

v To establish holidays and marked days:

1 Establish arrays containing the lists of holidays and marked days:

Date ld_holidays[11], ld_marked_days[12] ld_holidays[1] = 1997-01-01 ld_holidays[2] = 1997-02-17 ld_holidays[3] = 1997-04-21 ld_holidays[4] = 1997-05-26 ld_holidays[5] = 1997-07-04 ld_holidays[6] = 1997-09-01 ld_holidays[7] = 1997-10-13 ld_holidays[8] = 1997-11-27 ld_holidays[9] = 1997-11-28 ld_holidays[10] = 1997-12-25 ld_holidays[11] = 1997-12-26 ld_marked_days[1] = 1996-06-13 ld_marked_days[2] = 1996-03-16 ld_marked_days[3] = 1996-09-23 ld_marked_days[4] = 1996-09-14 ld_marked_days[5] = 1997-06-13 ld_marked_days[6] = 1997-03-16 ld_marked_days[7] = 1997-09-23 ld_marked_days[8] = 1997-09-14 ld_marked_days[9] = 1998-06-13 ld_marked_days[10] = 1998-03-16 ld_marked_days[11] = 1998-09-23 ld_marked_days[12] = 1998-09-14

2 After enabling the calendar for the DataWindow or EditMask control, establish the list of holidays by calling the of_SetHoliday function:

this.iuo_calendar.of_SetHoliday(ld_holidays)

3 Establish holiday display options as necessary:

this.iuo_calendar.of_SetHolidayColor & (RGB(0, 255, 0))

4 Establish the list of marked days by calling the of_SetMarkedDay function:

this.iuo_calendar.of_SetMarkedDay(ld_marked_days)

5 Establish marked day options as necessary:

this.iuo_calendar.of_SetMarkedDayBold(TRUE) this.iuo_calendar.of_SetMarkedDayColor & (RGB(255, 0, 0))

Setting calendar

options The PFC calendar control provides options that you can set to control calendar behavior: Close on click Controls whether the drop-down calendar closes when

the user clicks a date:

this.of_SetDropDownCalendar(TRUE) ...

this.iuo_calendar.of_SetCloseOnDClick(TRUE)

Close on double-click Controls whether the drop-down calendar closes when the user double-clicks a date:

this.of_SetDropDownCalendar(TRUE) ...

this.iuo_calendar.of_SetCloseOnDClick(TRUE)

Date format Controls the format of the date returned by the calendar:

this.of_SetDropDownCalendar(TRUE) ...

this.iuo_calendar.of_SetDateFormat("mm/dd/yy")

This must match the control’s date format

The of_SetDateFormat specification must match the DataWindow column’s edit format or the EditMask’s date mask.

Initialize date Controls whether the calendar initializes blank fields with the current date when the calendar displays:

this.of_SetDropDownCalendar(TRUE) ...

Using custom visual user objects

Use the Constructor event

You typically call the functions that control these behaviors in the u_dw or u_em Constructor event.

In document pfcug (Page 184-192)