|
of_SetFont
|
|
Full name
|
pfc_n_cst_dssrv_report.of_SetFont
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_SetFont(string,integer,fontfamily,fontpitch,boolean,boolean,boolean,string,string,boolean)
|
Name
|
Datatype
|
li_Count
|
Integer
|
li_NumObjects
|
Integer
|
li_Undo
|
Integer
|
lnv_String
|
n_cst_string
|
ls_FontFace
|
String
|
ls_FontFamily
|
String
|
ls_FontPitch
|
String
|
ls_FontSize
|
String
|
ls_FontWeight
|
String
|
ls_Italic
|
String
|
ls_Modify
|
String
|
ls_Objects
|
String[]
|
ls_OldFamily
|
String
|
ls_OldItalic
|
String
|
ls_OldPitch
|
String
|
ls_OldUnderline
|
String
|
ls_OldWeight
|
String
|
ls_Return
|
String
|
ls_Underline
|
String
|
ls_Undo
|
String
|
public function string of_SetFont (string as_fontface, integer ai_fontsize, fontfamily aff_fontfamily, fontpitch afp_fontpitch, boolean ab_bold, boolean ab_italic, boolean ab_underline, string as_name, string as_band, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_SetFont
//
// Access: public
//
// Arguments:
// as_FontFace The font to use (i.e. "MS Sans Serif")
// ai_FontSize The point size of the font.
// aff_FontFamily The font family (AnyFont!, Roman!, Swiss!, Modern!,
// Script!, Decorative!)
// afp_FontPitch The pitch of the font (Default!, Fixed!, Variable!)
// ab_Bold True - Bold, False - Normal.
// ab_Italic True - Yes, False - No.
// ab_Underline True - Yes, False - No.
// as_Name The name of the object to change, "*" will cause all
// objects in the band to be changed.
// as_Band The band in which to change the objecs, "*" will call
// the entire datawindow to be changed. This argument is
// ignored if a name is passed in as_Name.
// 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.
//
// Description: Change the font of an object in 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_FontFace, ls_Modify, ls_Objects[], ls_Undo, ls_FontSize, &
ls_FontFamily, ls_OldFamily, ls_FontPitch, ls_OldPitch, ls_FontWeight, &
ls_OldWeight, ls_Italic, ls_OldItalic, ls_Underline, ls_OldUnderline, ls_Return
Integer li_NumObjects, li_Count, li_Undo
n_cst_string lnv_String
// Determine the DataWindow Modify parameters
Choose Case aff_FontFamily
Case AnyFont!
ls_FontFamily = "0"
Case Roman!
ls_FontFamily = "1"
Case Swiss!
ls_FontFamily = "2"
Case Modern!
ls_FontFamily = "3"
Case Script!
ls_FontFamily = "4"
Case Decorative!
ls_FontFamily = "5"
End Choose
Choose Case afp_FontPitch
Case Default!
ls_FontPitch = "0"
Case Fixed!
ls_FontPitch = "1"
Case Variable!
ls_FontPitch = "2"
End Choose
If ab_Bold Then
ls_FontWeight = "700"
Else
ls_FontWeight = "400"
End If
If ab_Italic Then
ls_Italic = "1"
Else
ls_Italic = "0"
End If
If ab_Underline Then
ls_Underline = "1"
Else
ls_Underline = "0"
End If
If as_Name = "*" Then
// All visible objects in the as_Band band are to be changed
li_NumObjects = of_GetObjects(ls_Objects, "*", as_Band, True)
li_Undo = ii_UndoLevel
For li_Count = 1 To li_NumObjects
// Call this function for each object
ls_Modify = ls_Modify + of_SetFont(as_FontFace, ai_FontSize, aff_FontFamily, &
afp_FontPitch, ab_Bold, ab_Italic, ab_Underline, &
ls_Objects[li_Count], "", False)
Next
// Combine each object's undo statement into one
li_Undo ++
For li_Count = (li_Undo + 1) To ii_UndoLevel
is_Undo[li_Undo] = is_Undo[li_Undo] + " " + is_Undo[li_Count]
Next
ii_UndoLevel = li_Undo
Else
ls_FontSize = ids_requestor.Describe(as_Name + ".Font.Height")
If Not IsNumber(ls_FontSize) Then
// This is not a text or column object
Return ""
End if
// Change font size
If Not IsNull(ai_FontSize) And ai_FontSize <> Integer(ls_FontSize) Then
ls_Modify = " " + as_Name + ".Font.Height='-" + String(ai_FontSize) + "'"
ls_Undo = " " + as_Name + ".Font.Height='" + ls_FontSize + "'"
End if
// Change font face
If Not IsNull(as_FontFace) Then
ls_FontFace = ids_requestor.Describe(as_Name + ".Font.Face")
If as_FontFace <> ls_FontFace Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Face='" + as_FontFace + "'"
ls_Undo = ls_Undo + as_Name + ".Font.Face='" + ls_FontFace + "'"
End if
End if
// Change font family
If Not IsNull(aff_FontFamily) Then
ls_OldFamily = ids_requestor.Describe(as_Name + ".Font.Family")
If ls_FontFamily <> ls_OldFamily Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Family='" + ls_FontFamily + "'"
ls_Undo = ls_Undo + as_Name + ".Font.Family='" + ls_OldFamily + "'"
End if
End if
// Change font pitch
If Not IsNull(afp_FontPitch) Then
ls_OldPitch = ids_requestor.Describe(as_Name + ".Font.Pitch")
If ls_FontPitch <> ls_OldPitch Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Pitch='" + ls_FontPitch + "'"
ls_Undo = ls_Undo + as_Name + ".Font.Pitch='" + ls_OldPitch + "'"
End if
End if
// Change font weight
If Not IsNull(ab_Bold) Then
ls_OldWeight = ids_requestor.Describe(as_Name + ".Font.Weight")
If ls_FontWeight <> ls_OldWeight Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Weight='" + ls_FontWeight + "'"
ls_Undo = ls_Undo + " " + as_Name + ".Font.Weight='" + ls_OldWeight + "'"
End if
End if
// Change italic
If Not IsNull(ab_Italic) Then
If ids_requestor.Describe(as_Name + ".Font.Italic") <> "1" Then
ls_OldItalic = "0"
Else
ls_OldItalic = "1"
End If
If ls_Italic <> ls_OldItalic Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Italic='" + ls_Italic + "'"
ls_Undo = ls_Undo + " " + as_Name + ".Font.Italic='" + ls_OldItalic + "'"
End if
End if
// Change underline
If Not IsNull(ab_Underline) Then
If ids_requestor.Describe(as_Name + ".Font.Underline") <> "1" Then
ls_OldUnderline = "0"
Else
ls_OldUnderline = "1"
End If
If ls_Underline <> ls_OldUnderline Then
ls_Modify = ls_Modify + " " + as_Name + ".Font.Underline='" + ls_Underline + "'"
ls_Undo = ls_Undo + " " + as_Name + ".Font.Underline='" + ls_OldUnderline + "'"
End if
End if
ls_Undo = lnv_string.of_GlobalReplace (ls_Undo, "~"", "")
ii_UndoLevel ++
is_Undo[ii_UndoLevel] = ls_Undo
End if
If ab_Execute Then
ls_Return = ids_requestor.Modify(ls_Modify)
Else
ls_Return = ls_Modify
End if
Return ls_Return
end function