|
of_AddText
|
|
Full name
|
pfc_n_cst_dssrv_report.of_AddText
|
Access
|
protected
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
protected function string of_AddText(string,string,alignment,vtextalign,integer,integer,border,boolean,boolean,boolean,string,integer,fontcharset,lon
|
Name
|
Datatype
|
li_Cnt
|
Integer
|
li_CurrentHeight
|
Integer
|
li_dwWidth
|
Integer
|
li_Height
|
Integer
|
li_Line
|
Integer
|
li_NewLines
|
Integer
|
li_Shift
|
Integer
|
li_Width
|
Integer
|
lnv_String
|
n_cst_string
|
ls_Line
|
String[]
|
ls_Modify
|
String
|
ls_Return
|
String
|
ls_Undo
|
String
|
protected function string of_AddText (string as_text, string as_band, alignment aal_halign, vtextalign avta_valign, integer ai_x, integer ai_y, border abo_border, boolean ab_bold, boolean ab_italic, boolean ab_underline, string as_fontface, integer ai_fontsize, fontcharset afc_charset, long al_color, long al_backcolor, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_AddText
//
// Access: protected
//
// Arguments:
// as_Text The text to be added.
// as_Band The band to add it to.
// aal_HAlign The horizontal alignment of the object.
// avta_VAlign The vertical alignment of the object.
// ai_X The X position of the object.
// ai_Y The Y position of the object.
// abo_Border The border to place around the object added (NoBorder!,
// ShadowBox!, Box!, ResizeBorder!, Underline!, Lowered!
// Raised!).
// 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.
// afc_CharSet The character set to use (Ansi!, DefaultCharSet!, Symbol!,
// Shiftjis!, OEM!)
// al_Color The color of the object.
// al_BackColor The background color of the object.
// 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! Error calculating size" - Returned an error calculating the object size
//
// Description: Add a text object to any band of a datawindow. 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_Line[]
Integer li_NewLines, li_CurrentHeight, li_dwWidth, li_Shift, &
li_Cnt, li_Line, li_Height, li_Width
n_cst_string lnv_String
// Verify that DataWindow units are either PowerBuild Units or Pixels
If ids_requestor.Object.DataWindow.Units > "1" Then Return "Error! Invalid DW Unit"
// Calculate the height, width and position of the new object
li_NewLines = of_GetTextSizePos(as_Text, as_Band, aal_HAlign, avta_VAlign, ab_Bold, &
ab_Italic, ab_Underline, as_FontFace, ai_FontSize, li_Height, &
li_Width, ai_X, ai_Y)
If li_NewLines = -1 Then Return "Error! Error calculating size"
// Shift existing objects as necessary
If Not IsNull(aal_HAlign) Then
If avta_VAlign <> VCenter! Then
// Adding or inserting the text
// Get original band height and Datawindow color
li_CurrentHeight = Integer(ids_requestor.Describe("Datawindow." + as_Band + ".Height"))
// Calculate the new height of the band
li_Shift = (li_Height * (li_NewLines + 0.4))
// If inserting, then shift original header down
If avta_VAlign = Top! Then
ls_Modify = ls_Modify + of_ShiftBand(as_Band, 0, li_Shift, False)
ls_Undo = is_Undo[ii_UndoLevel]
ii_UndoLevel --
Else
// Set new band height
ls_Modify = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight + li_Shift)
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
End If
// Build modify statement
ls_Modify = ls_Modify + of_BuildTextModify("text", as_Text, as_Band, ai_X, ai_Y, li_Height, li_Width, &
abo_Border, ab_Bold, ab_Italic, ab_Underline, &
as_FontFace, ai_FontSize, afc_CharSet, al_Color, al_BackColor)
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