of_AddPicture


pfcdwsrv.pbl   >   pfc_n_cst_dssrv_report   >   of_AddPicture   

Full name pfc_n_cst_dssrv_report.of_AddPicture
Access protected
Extend of string
Return value string
Prototype protected function string of_AddPicture(string,string,alignment,vtextalign,integer,integer,border,boolean)

Name Datatype
No Data

Name Datatype
li_CurrentHeight Integer
li_DwWidth Integer
li_Height Integer
li_Width Integer
ls_Border String
ls_Modify String
ls_Return String
ls_Undo String

protected function string of_AddPicture (string as_filename, string as_band, alignment aal_halign, vtextalign avta_valign, integer ai_x, integer ai_y, border abo_border, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_AddPicture
//
//	Access:  protected
//
//	Arguments:
//	as_FileName				The name of the BMP file.
//	as_Band					The band to add the picture to.
//	aal_HAlign					The horizontal position of the object (Left!, Right!, Center!).
//	avta_VAlign				The vertical position of the object (Bottom!, Top!, VCenter!).
//	ai_X							The X location of the BMP being placed.
//	ai_Y							The Y location of the BMP being placed.
//	abo_Border				The border to place around the object added (NoBorder!, 
//									ShadowBox!, Box!, ResizeBorder!, Underline!, Lowered!, 
//									Raised!).
//	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:	Add a picture object to any band of a datawindow.  It will be placed on
//						top of any existing objects.  This protected function does all the work.
//						Overloaded public functions should be called.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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, ls_Undo, ls_Border
Integer	li_Height, li_Width, li_CurrentHeight, li_DwWidth

// Verify that DataWindow units are either PowerBuild Units or Pixels
If ids_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

// Determine the DataWindow Modify parameters
Choose Case abo_Border
	Case NoBorder!
		ls_Border = "0"
	Case ShadowBox!
		ls_Border = "1"
	Case Box!
		ls_Border = "2"
	Case ResizeBorder!
		ls_Border = "3"
	Case Underline!
		ls_Border = "4"
	Case Lowered!
		ls_Border = "5"
	Case Raised!
		ls_Border = "6"
End Choose

// Calculate the height and width of the new object
If of_GetPictureSize(as_FileName, li_Height, li_Width) = -1 Then Return "Error!  Error calculating size"
If ids_requestor.Describe("Datawindow.Units") = "1" Then
	// Convert PB Units to pixels
	li_Height = UnitsToPixels(li_Height, YUnitsToPixels!)
	li_Width = UnitsToPixels(li_Width, XUnitsToPixels!)
End if

// Determine if the original objects should be shifted
If Not IsNull(aal_HAlign) Then
	If avta_VAlign <> VCenter! Then
		// Adding or inserting the object
		// Get original band height
		li_CurrentHeight = Integer(ids_requestor.Describe("Datawindow." + as_Band + ".Height"))

		// If inserting at the top, then shift original objects down
		If avta_VAlign = Top! Then
			ls_Modify = ls_Modify + of_ShiftBand(as_Band, 0, (li_Height + 1), False)
			ls_Undo = is_Undo[ii_UndoLevel]
			ii_UndoLevel --
		Else
			// Set new band height
			ls_Modify = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight + li_Height + 1)
			ls_Undo = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight)
		End if

		ElseIf aal_HAlign = Left! Then
		// Shift band objects right
		ls_Modify = ls_Modify + of_ShiftBand(as_Band, (li_Width + 10), 0, False)
		ls_Undo = is_Undo[ii_UndoLevel]
		ii_UndoLevel --
	End if

	// Determine X and Y position
	If aal_HAlign = Left! Then
		ai_X = 1
	Else
		// Determine the width of the datawindow
		li_dwWidth = of_GetWidth()
		If aal_HAlign = Center! Then
			ai_X = (li_dwWidth - li_Width) / 2
		ElseIf avta_VAlign = VCenter! Then
			ai_X = li_DwWidth + 10
		Else
			ai_X = li_dwWidth - li_Width
		End if
	End if

	If avta_VAlign = Top! Then
		ai_Y = 1
	ElseIf avta_VAlign = Bottom! Then
		ai_Y = li_CurrentHeight + 1
	Else
		ai_Y = (li_CurrentHeight - li_Height) / 2
	End if
End If

// Build modify statement
ls_Modify = ls_Modify + " create bitmap(band=" + as_Band + &
			" filename='" + as_FileName + "'" + &
			" x='" + String(ai_X) + "'" + &
			" y='" + String(ai_Y) + "'" + &
			" height='" + String(li_Height) + "'" + &
			" width='" + String(li_Width) + "'" + &
			" border='" + ls_Border + "'" + &
			" name=add_obj_" + String(ii_ObjectNum) + ")"

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

ii_ObjectNum ++

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

Return ls_Return

end function

     
Name Owner
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddPicture pfc_n_cst_dssrv_report

     
Name Owner
datastore.describe datastore
datastore.modify datastore
systemfunctions.fileexists systemfunctions
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.string systemfunctions
systemfunctions.unitstopixels systemfunctions
pfc_n_cst_dssrv_report.of_getpicturesize pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_ShiftBand pfc_n_cst_dssrv_report
pfc_n_cst_dssrv.of_getwidth pfc_n_cst_dssrv

     
Full name
No Data

     
Name Scope
No Data