of_drawmonth


pfcmain.pbl   >   pfc_u_calendar   >   of_drawmonth   

Full name pfc_u_calendar.of_drawmonth
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_drawmonth(date)

Name Datatype
No Data

Name Datatype
lb_holidaybold Boolean
lb_markeddaybold Boolean
lb_saturdaybold Boolean
lb_sundaybold Boolean
ldt_holiday Date[]
ldt_markedday Date[]
ldt_special Date
li_cell Integer
li_day Integer
li_daycount Integer
li_days Integer[12]
li_daysinmonth Integer
li_FirstDayNum Integer
li_loop Integer
li_month Integer
li_upperbound Integer
li_weight Integer
li_year Integer
ll_holidaycolor Long
ll_markeddaycolor Long
ll_saturdaycolor Long
ll_sundaycolor Long
ls_cell String
ls_modifyexp String
ls_monthname String

protected function integer of_drawmonth (date ad_date);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_DrawMonth
//
//	Access:    Protected
//
//	Arguments:
// 	ad_date A Date containing the month to draw.
//
//	Returns:  Integer
//		1 if it succeeds and -1 if an error occurs.
//
//	Description:  Draws the requested month.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	6.0   Initial version
//	7.0	Removed an invalid comparison to date(‘50/50/1900’)).  The comparison 
//			is no longer needed.  Post 5.0.03 PowerBuilder date type cannot contain 
//			an  invalid date with an exception of a null value.
//
//			
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer 	li_month
Integer 	li_year
Integer 	li_day
Integer	li_loop, li_daycount
Integer	li_upperbound
Integer  li_FirstDayNum, li_cell, li_daysinmonth
Integer	li_days[12]={31,28,31,30,31,30,31,31,30,31,30,31}
Date		ldt_special
String	ls_monthname
String	ls_cell
Integer	li_weight
String	ls_modifyexp
Date		ldt_holiday[], ldt_markedday[]
Boolean  lb_sundaybold, lb_saturdaybold, lb_holidaybold, lb_markeddaybold
Long		ll_sundaycolor, ll_saturdaycolor, ll_holidaycolor, ll_markeddaycolor

//Get appropriate information.
of_GetHoliday(ldt_holiday)
of_GetMarkedday(ldt_markedday)
lb_sundaybold = of_IsSundayBold()
lb_saturdaybold = of_IsSaturdayBold()
lb_holidaybold = of_IsHolidayBold()
lb_markeddaybold = of_IsMarkeddayBold()
ll_sundaycolor = of_GetSundayColor()
ll_saturdaycolor = of_GetSaturdayColor()
ll_holidaycolor = of_GetHolidayColor()
ll_markeddaycolor = of_GetMarkeddayColor()		

// Check the argument(s).
If IsNull(ad_date) Then
	Return -1
End If			 
							 
//Set Pointer to an Hourglass and turn off redrawing of Calendar
SetPointer(Hourglass!)
SetRedraw(dw_cal,FALSE)

//Initialize local values.
li_year = Year(ad_date)
li_month = Month(ad_date)
li_day = Day(ad_date)

//If appropriate, insert a row into the script datawindow
If dw_cal.RowCount()=0 Then
	dw_cal.InsertRow(0)
ElseIf dw_cal.RowCount()> 0 Then
	dw_cal.Reset()
	dw_cal.InsertRow(0)
End If

//Set the Title.
ls_monthname = inv_datetime.of_MonthName(li_month)
dw_cal.Object.st_month.text = ls_monthname + " " + string(li_year)

//--Determine the number of days in the month.--
// Get the number of days per month for a non leap year.
li_daysinmonth = li_days[li_month]
// Check for a leap year.
If li_month=2 Then
	If ( (Mod(li_year,4) = 0 And Mod(li_year,100) <> 0) Or (Mod(li_year,400) = 0) ) Then
		li_daysinmonth = 29
	End If
End If

//-- Update the DataWindow object to display the desired month --.
//Find the weekday for the first day in the month.
li_FirstDayNum = DayNumber(Date(li_year, li_month, 1))
//Blank cells prior to the first day of the month.
For li_loop = 1 to li_FirstDayNum
	dw_cal.SetItem(1,li_loop,"")
Next
//Set the day number on the the appropriate cells.
For li_loop = 1 to li_daysinmonth
	li_daycount = li_FirstDayNum + li_loop - 1
	dw_cal.SetItem(1,li_daycount,String(li_loop))
Next
//Blank cells after the last day of the month.
For li_loop = li_daycount +1 to 42 
	dw_cal.SetItem(1,li_loop,"") 
Next

// Restore all cells back to default color and fontweight.
ls_modifyexp = ''
For li_loop = 1 to 42
	ls_modifyexp += "cell"+string(li_loop)+".Color='"+string(il_fontcolor)+"' " + &
						 "cell"+string(li_loop)+".Font.Weight='"+string(ii_normalfontweight)+"' "
Next
dw_cal.Modify(ls_modifyexp)

// Mark Sundays.
ls_modifyexp = ''
If lb_sundaybold Then li_weight = ii_boldfontweight &
						Else li_weight = ii_normalfontweight
For li_loop = 1 to 36 step 7
	ls_modifyexp += "cell"+string(li_loop)+".Color='"+string(ll_sundaycolor)+"' " + &
						 "cell"+string(li_loop)+".Font.Weight='"+string(li_weight)+"' "
Next
dw_cal.Modify(ls_modifyexp)

// Mark Saturdays.
ls_modifyexp = ''
If lb_saturdaybold Then li_weight = ii_boldfontweight &
						Else li_weight = ii_normalfontweight
For li_loop = 7 to 42 step 7
	ls_modifyexp += "cell"+string(li_loop)+".Color='"+string(ll_saturdaycolor)+"' " + &
						 "cell"+string(li_loop)+".Font.Weight='"+string(li_weight)+"' "
Next
dw_cal.Modify(ls_modifyexp)

// Mark holidays for this month.
ls_modifyexp = ''
li_upperbound = UpperBound(ldt_holiday)
If li_upperbound > 0 Then
	If lb_holidaybold Then li_weight = ii_boldfontweight &
							Else li_weight = ii_normalfontweight
	For li_loop = 1 to li_upperbound
		ldt_special = ldt_holiday[li_loop]
		If Year(ldt_special)=Year(ad_date) And Month(ldt_special)=Month(ad_date) Then
			li_FirstDayNum = DayNumber(Date(Year(ldt_special), Month(ldt_special), 1))
			ls_cell = 'cell'+string(li_FirstDayNum + Day(ldt_special) - 1)
			ls_modifyexp += ls_cell+".Color='"+string(ll_holidaycolor)+"' " + &
								 ls_cell+".Font.Weight='"+string(li_weight)+"' "
		End If
	Next
	If Len(Trim(ls_modifyexp)) > 0 Then
		dw_cal.Modify(ls_modifyexp)
	End If
End If

// Mark special days for this month.
ls_modifyexp = ''
li_upperbound = UpperBound(ldt_markedday)
If li_upperbound > 0 Then
	If lb_markeddaybold Then li_weight = ii_boldfontweight &
								Else li_weight = ii_normalfontweight
	For li_loop = 1 to li_upperbound
		ldt_special = ldt_markedday[li_loop]
		If Year(ldt_special)=Year(ad_date) And Month(ldt_special)=Month(ad_date) Then
			li_FirstDayNum = DayNumber(Date(Year(ldt_special), Month(ldt_special), 1))
			ls_cell = 'cell'+string(li_FirstDayNum + Day(ldt_special) - 1)
			ls_modifyexp += ls_cell+".Color='"+string(ll_markeddaycolor)+"' " + &
								 ls_cell+".Font.Weight='"+string(li_weight)+"' "
		End If
	Next
	If Len(Trim(ls_modifyexp)) > 0 Then
		dw_cal.Modify(ls_modifyexp)
	End If
End If

//Turn back redraw.
dw_cal.SetRedraw(TRUE)

Return 1

end function

     
Name Owner
pfc_u_calendar.of_setdate pfc_u_calendar

     
Name Owner
dragobject.setredraw dragobject
dragobject.setredraw dragobject
datawindow.insertrow datawindow
datawindow.modify datawindow
datawindow.reset datawindow
datawindow.rowcount datawindow
datawindow.setitem datawindow
systemfunctions.date systemfunctions
systemfunctions.day systemfunctions
systemfunctions.daynumber systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.len systemfunctions
systemfunctions.mod systemfunctions
systemfunctions.month systemfunctions
systemfunctions.setpointer systemfunctions
systemfunctions.string systemfunctions
systemfunctions.trim systemfunctions
systemfunctions.upperbound systemfunctions
systemfunctions.year systemfunctions
pfc_n_cst_datetime.of_monthname pfc_n_cst_datetime
pfc_u_calendar.of_IsHolidayBold pfc_u_calendar
pfc_u_calendar.of_IsMarkeddayBold pfc_u_calendar
pfc_u_calendar.of_IsSundayBold pfc_u_calendar
pfc_u_calendar.of_IsSaturdayBold pfc_u_calendar
pfc_u_calendar.of_GetHolidayColor pfc_u_calendar
pfc_u_calendar.of_GetMarkeddayColor pfc_u_calendar
pfc_u_calendar.of_GetSaturdayColor pfc_u_calendar
pfc_u_calendar.of_GetSundayColor pfc_u_calendar
pfc_u_calendar.of_getholiday pfc_u_calendar
pfc_u_calendar.of_getmarkedday pfc_u_calendar

     
Full name
pfc_u_calendar

     
Name Scope
No Data