of_gettextsizepos


pfcdwsrv.pbl   >   pfc_n_cst_dssrv_report   >   of_gettextsizepos   

Full name pfc_n_cst_dssrv_report.of_gettextsizepos
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_gettextsizepos(string,string,alignment,vtextalign,boolean,boolean,boolean,string,integer,ref integer,ref integer,ref in

Name Datatype
No Data

Name Datatype
li_Cnt Integer
li_CurrentHeight Integer
li_DwWidth Integer
li_Line Integer
li_LineWidth Integer
li_NewLines Integer
lnv_String n_cst_string
ls_Line String[]
ls_Text String
lw_parent window

protected function integer of_gettextsizepos (string as_text, string as_band, alignment aal_halign, vtextalign avta_valign, boolean ab_bold, boolean ab_italic, boolean ab_underline, string as_fontface, integer ai_fontsize, ref integer ai_height, ref integer ai_width, ref integer ai_x, ref integer ai_y);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_GetTextSizePos
//
//	Access:  protected
//
//	Arguments:
//	as_Text						The text whose size and position is to be determined.
//	as_Band					The band the object is being added to.
//	aal_HAlign					The horizontal alignment of the object being placed.
//	avta_Valign				The vertical alignment of the object being placed.
//	ab_Bold						True - Bold, False - Normal.
//	ab_Italic					True - Yes, False - No.
//	ab_Underline				True - Yes, False - No.
//	as_FontFace				The font to use (i.e. "MS Sans Serif")
//	ai_FontSize				The point size of the font.
//	ai_Height					The height of the object, passed by reference.
//	ai_Width					The width of the object, passed by reference.
//	ai_X							The X position of the object, passed by reference.
//	ai_Y							The Y position of the object, passed by reference.
//
//	Returns:		Integer
//					The number of lines in the text object or -1 if an error occurrs.
//
//	Description:	Calculate the size and position of a text object.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
// 5.0.02 Check return value on ParseToArray to exit if no text is passed
//
//////////////////////////////////////////////////////////////////////////////
//
//	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_Line[], ls_Text
Integer			li_NewLines, li_Cnt, li_Line, li_LineWidth, li_CurrentHeight, li_DwWidth
window	lw_parent
n_cst_string	lnv_String

// Calculate the height and width of the new object
// Determine how many new lines are being added
li_NewLines = lnv_string.of_ParseToArray(as_Text, "~r~n", ls_Line)
If li_NewLines <= 0 or IsNull(li_NewLines) Then Return -1

// Find the longest line
For li_Cnt = 1 to li_NewLines
	If Len(ls_Line[li_Cnt]) > li_LineWidth Then
		li_LineWidth = Len(ls_Line[li_Cnt])
		li_Line = li_Cnt
	End if
Next
If Len(ls_Text) < Len(ls_Line[li_Line]) Then
	ls_Text = ls_Line[li_Line]
End if

// Verify that the Platform-Specific Services NVO is in use
If IsNull(inv_Platform) Or Not IsValid(inv_Platform) Then
	// Create the Platform-Specific Functions Service if it is not already created
	f_SetPlatform(inv_Platform, True)
End if

// Call function to calculate the text size
ids_requestor.of_GetParentWindow (lw_parent)
If inv_Platform.of_gettextsize(lw_parent, ls_Text + " ", as_FontFace, &
											ai_FontSize, ab_Bold, ab_Italic, &
											ab_Underline, ai_Height, ai_Width) = -1 Then Return -1

If ids_requestor.Describe("Datawindow.Units") = "0" Then
	// Convert pixels to PB units
	ai_Height = PixelsToUnits(ai_Height, YPixelsToUnits!)
	ai_Width = PixelsToUnits(ai_Width, XPixelsToUnits!)
End if

ai_Height = ai_Height * li_NewLines

// Determine X and Y position
// If aal_HAlign is null, then X and Y are not needed
If IsNull(aal_HAlign) Then Return li_NewLines

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 - ai_Width) / 2
	ElseIf avta_VAlign = VCenter! Then
		ai_X = li_DwWidth + 10
	Else
		ai_X = li_dwWidth - ai_Width
	End if
End if

If avta_VAlign = Top! Then
	ai_Y = 1
Else
	li_CurrentHeight = Integer(ids_requestor.Describe("Datawindow." + as_Band + ".Height"))
	If avta_VAlign = Bottom! Then
		ai_Y = li_CurrentHeight + 1
	Else
		ai_Y = (li_CurrentHeight - ai_Height) / 2
	End If
End if

Return li_NewLines

end function

     
Name Owner
pfc_n_cst_dssrv_report.of_AddCompute pfc_n_cst_dssrv_report
pfc_n_cst_dssrv_report.of_AddText pfc_n_cst_dssrv_report

     
Name Owner
datastore.describe datastore
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.len systemfunctions
systemfunctions.pixelstounits systemfunctions
pfc_n_cst_string.of_parsetoarray pfc_n_cst_string
pfc_n_cst_platform.of_gettextsize pfc_n_cst_platform
f_setplatform.f_setplatform f_setplatform
pfc_n_cst_dssrv.of_getwidth pfc_n_cst_dssrv
pfc_n_ds.of_getparentwindow pfc_n_ds

     
Full name
No Data

     
Name Scope
No Data