of_ShiftBand


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv_report   >   of_ShiftBand   

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

Name Datatype
No Data

Name Datatype
li_Count Integer
li_CurrentHeight Integer
li_NumObjects Integer
li_OriginalX Integer
li_OriginalY Integer
li_X Integer
li_Y Integer
ls_Modify String
ls_Objects String[]
ls_Return String
ls_Undo String

public function string of_ShiftBand (string as_band, integer ai_xunits, integer ai_yunits, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_ShiftBand
//
//	Access:  public
//
//	Arguments:
//	as_Band					The band to shift, pass "*" to shift the entire datawindow.
//	ai_XUnits					The number of horizontal units to shift the objects right, 
//									pass a negative number to shift left.
//	ai_YUnits					The number of vertical units to shift the objects down, 
//									pass a negative number to shift up.
//	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 the following error:
//					"Error!  Invalid DataWindow Shift"	-	Attempted to shift the object beyond
//																			the top or left side of the page (X or
//																			Y became negative)
//
//	Description:	Shift the objects in the given band of the datawindow horizontally
//						or vertically a specified number of units.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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_Objects[], ls_Modify, ls_Undo, ls_Return
Integer	li_CurrentHeight, li_NumObjects, li_Count, li_X, li_OriginalX, li_Y, li_OriginalY

// If band is being shifted up or down, change the height of the band
If Abs(ai_YUnits) > 0 Then
	If as_Band <> "*" Then
		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow." + as_Band + ".Height"))
		ls_Modify = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight + ai_YUnits)
		ls_Undo = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight)

	Else	// Shift all bands
		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow.Header.Height"))
		ls_Modify = "Datawindow.Header.Height=" + String(li_CurrentHeight + ai_YUnits)
		ls_Undo = "Datawindow.Header.Height=" + String(li_CurrentHeight)

		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow.Detail.Height"))
		ls_Modify = "Datawindow.Detail.Height=" + String(li_CurrentHeight + ai_YUnits)
		ls_Undo = ls_Undo + " Datawindow.Detail.Height=" + String(li_CurrentHeight)

		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow.Footer.Height"))
		ls_Modify = "Datawindow.Footer.Height=" + String(li_CurrentHeight + ai_YUnits)
		ls_Undo = ls_Undo + " Datawindow.Footer.Height=" + String(li_CurrentHeight)

		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow.Summary.Height"))
		ls_Modify = "Datawindow.Summary.Height=" + String(li_CurrentHeight + ai_YUnits)
		ls_Undo = ls_Undo + " Datawindow.Summary.Height=" + String(li_CurrentHeight)
	End if
End if

// Get the names of all the visible objects in the datawindow band
li_NumObjects = of_GetObjects(ls_Objects, "*", as_Band, True)

For li_Count = 1 To li_NumObjects

	// Determine if the object is a line
	If idw_Requestor.Describe(ls_Objects[li_Count] + ".type") = "line" Then
		// Lines have X1, Y1 and X2, Y2 attributes
		If abs(ai_XUnits) > 0 Then
			li_OriginalX = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".x1"))
			li_X = li_OriginalX + ai_XUnits

			// Check for shifting beyond the left side of the page
			If li_X < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".x1='" + String(li_X) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".x1='" + String(li_OriginalX) + "'"

			// Change the X2 attribute
			li_OriginalX = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".x2"))
			li_X = li_OriginalX + ai_XUnits

			// Check for shifting beyond the left side of the page
			If li_X < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".x2='" + String(li_X) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".x2='" + String(li_OriginalX) + "'"
		End if
		If abs(ai_YUnits) > 0 Then
			li_OriginalY = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".y1"))
			li_Y = li_OriginalY + ai_YUnits

			// Check for shifting beyond the top of the page
			If li_Y < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".y1='" + String(li_Y) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".y1='" + String(li_OriginalY) + "'"

			// Change the Y2 attribute
			li_OriginalY = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".y2"))
			li_Y = li_OriginalY + ai_YUnits

			// Check for shifting beyond the top of the page
			If li_Y < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".y2='" + String(li_Y) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".y2='" + String(li_OriginalY) + "'"
		End if

	Else	// all other objects have only one X and Y attribute
		If abs(ai_XUnits) > 0 Then
			li_OriginalX = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".x"))
			li_X = li_OriginalX + ai_XUnits

			// Check for shifting beyond the left side of the page
			If li_X < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".x='" + String(li_X) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".x='" + String(li_OriginalX) + "'"
		End if
		If abs(ai_YUnits) > 0 Then
			li_OriginalY = Integer(idw_Requestor.Describe(ls_Objects[li_Count] + ".y"))
			li_Y = li_OriginalY + ai_YUnits

			// Check for shifting beyond the top of the page
			If li_Y < 0 Then
				Return "Error!  Invalid DataWindow Shift"
			End if

			ls_Modify = ls_Modify + " " + ls_Objects[li_Count] + ".y='" + String(li_Y) + "'"
			ls_Undo = ls_Undo + " " + ls_Objects[li_Count] + ".y='" + String(li_OriginalY) + "'"
		End if
	End if
Next

ii_UndoLevel ++
is_Undo[ii_UndoLevel] = ls_Undo

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_AddPicture pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddText pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddLine pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_ShiftBand pfc_n_cst_dwsrv_report

     
Name Owner
datawindow.describe datawindow
datawindow.modify datawindow
systemfunctions.abs systemfunctions
systemfunctions.integer systemfunctions
systemfunctions.string systemfunctions
pfc_n_cst_dwsrv.of_getobjects pfc_n_cst_dwsrv

     
Full name
No Data

     
Name Scope
No Data