of_SetBackground


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv_report   >   of_SetBackground   

Full name pfc_n_cst_dwsrv_report.of_SetBackground
Access public
Extend of string
Return value string
Prototype public function string of_SetBackground(string,boolean,integer,integer,integer,integer,boolean)

Name Datatype
No Data

Name Datatype
li_Height Integer
li_Width Integer
ls_Modify String
ls_Return String

public function string of_SetBackground (string as_filename, boolean ab_sizetofit, integer ai_x, integer ai_y, integer ai_height, integer ai_width, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_SetBackground
//
//	Access:  public
//
//	Arguments:
//	as_FileName				The name of the file containing the bitmap to display.
//	ab_SizeToFit				True - set the width of the picture to be the width of the
//									DataWindow and use the ai_Height/ai_Width ratio to
//									calculate the height (ai_X, ai_Y, ai_Height, and ai_Width
//									will be ignored).
//									False - use ai_X, aiY, ai_Height, and ai_Width.
//	ai_X							The X location of the bitmap being placed, it will be
//									centered horizontally if 0 is passed.
//	ai_Y							The Y location of the bitmap being placed, it will be
//									centered vertically if 0 is passed.
//	ai_Height					The height of the bitmap being placed, it will be calculated
//									if 0 is passed.
//	ai_Width					The width of the bitmap being placed, it will be calculated
//									if 0 is passed.
//	ab_Execute				True - execute the Modify command,
//									False - build the command but do not execute it
//
//	Returns:		String
//					The output of the Modify command (the error text or "") if True
//					was passed for ab_Execute; the text of the Modify command
//					to add the object if False was passed.  Or one of the following errors:
//					"Error!  Invalid DW Unit"			-	DataWindow Unit is not PB Units or Pixels
//					"Error!  File not found"				-	The picture file does not exist
//					"Error!  Error calculating size"	-	Returned an error calculating the object size
//
//	Description:	Place a picture in the background of the DataWindow.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

String	ls_Return, ls_Modify
Integer	li_Height, li_Width

// Verify that DataWindow units are either PowerBuild Units or Pixels
If idw_Requestor.Object.DataWindow.Units > "1" Then Return "Error!  Invalid DW Unit"

// Verify that the file exists
If Not FileExists(as_FileName) Then
	Return "Error!  File not found"
End if

If ab_SizeToFit  Or ai_Height = 0 Or ai_Width = 0 Then
	// Calculate the size of the picture
	If of_GetPictureSize(as_FileName, ai_Height, ai_Width) = -1 Then Return "Error!  Error calculating size"
	If idw_Requestor.Describe("Datawindow.Units") = "1" Then
		// Convert PB units to pixels
		ai_Height = UnitsToPixels(ai_Height, YUnitsToPixels!)
		ai_Width = UnitsToPixels(ai_Width, XUnitsToPixels!)
	End if
End If

If ab_SizeToFit Then
	// Calculate the height and width
	// Width = the width of the datawindow - whitespace
	// whitespace is the X value
	li_Width = of_GetWidth() - (ai_X * 2)
	li_Height = li_Width * (ai_Height / ai_Width)
Else
	li_Height = ai_Height
	li_Width = ai_Width
End if

// Determine the X and Y values
If ai_X = 0 Then
	// Center the bmp horizontally
	ai_X = (of_GetWidth() - li_Width) / 2
End If

If ai_Y = 0 Then
	// Center the bmp vertically
	ai_Y = (of_GetHeight() - li_Height) / 2
End If

// Build modify statement to create the picture object
ls_Modify = ls_Modify + " create bitmap(band=background" + &
			" filename='" + as_FileName + "'" + &
			" x='" + String(ai_X) + "' y='" + String(ai_Y) +"'" + &
			" height='" + String(li_Height) + "' width='" + String(li_Width) + "'" + &
			" name=add_obj_" + String(ii_ObjectNum) + ")"

ii_UndoLevel ++
is_Undo[ii_UndoLevel] = "destroy add_obj_" + String(ii_ObjectNum)

ii_ObjectNum ++

If ab_Execute Then
	ls_Return = idw_Requestor.Modify(ls_Modify)
Else
	ls_Return = ls_Modify
End if

Return ls_Return

end function

     
Name Owner
pfc_n_cst_dwsrv_report.of_SetBackground pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_SetBackground pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_SetBackground pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_SetBackground pfc_n_cst_dwsrv_report

     
Name Owner
datawindow.describe datawindow
datawindow.modify datawindow
systemfunctions.fileexists systemfunctions
systemfunctions.string systemfunctions
systemfunctions.unitstopixels systemfunctions
pfc_n_cst_dwsrv.of_getheight pfc_n_cst_dwsrv
pfc_n_cst_dwsrv.of_getwidth pfc_n_cst_dwsrv
pfc_n_cst_dwsrv_report.of_getpicturesize pfc_n_cst_dwsrv_report

     
Full name
No Data

     
Name Scope
No Data