Core Function FontDialog

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> FontDialog( <font> ) </pre> === Description === Allows the user to select a font and allows you to get the Name, size, bold etc values. === Parameters === ==== Font ===...")
 
(Example)
Line 32: Line 32:
 
// Display font information
 
// Display font information
 
print( "Name '$Name' \n" .
 
print( "Name '$Name' \n" .
"Size '$Size' \n" .
+
"Size '$Size' \n" .
"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
+
"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
+
"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
+
"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
+
"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
);
+
);
 
// Create a new GUI font using this information
 
// Create a new GUI font using this information
 
my $Flags = 0;
 
my $Flags = 0;
Line 60: Line 60:
 
// Display font information
 
// Display font information
 
print( "Name '$Name' \n" .
 
print( "Name '$Name' \n" .
"Size '$Size' \n" .
+
"Size '$Size' \n" .
"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
+
"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
+
"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
+
"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
+
"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
);
+
);
 
// Create a new GUI font using this information
 
// Create a new GUI font using this information
 
my $Flags = 0;
 
my $Flags = 0;

Revision as of 19:39, 11 December 2011

FontDialog( <font> )

Contents

Description

Allows the user to select a font and allows you to get the Name, size, bold etc values.

Parameters

Font

Optional; A font to use as the default font see examples.

Return Value

Success: Returns array with details.

Failure: Returns empty array.

Remarks

Example

Select a font print its details and optionally place it on a control

my $Value = FontDialog();
if($Value)
{
	my List ( $Name, $Size, $Bold, $Italic, $Strikeout, $Underline ) = $Value;
	// Display font information
	print(	"Name '$Name' \n" .
		"Size '$Size' \n" .
		"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
		"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
		"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
		"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
		);
	// Create a new GUI font using this information
	my $Flags = 0;
	if($Bold) $Flags |= @fontBold;
	if($Italic) $Flags |= @fontItalic;
	if($Strikeout) $Flags |= @fontStrikeout;
	if($Underline) $Flags |= @FontUnderline;
	$NewFont = GUICreateFont($Name, $Size, $Flags);
	// Example of setting this font to a GUI control
	//GUISetProp($mObj, "Font", $NewFont);
}

Same as before but this time set the DEFAULT font of the font dialog to be same as a controls font

// Set your control here and the font in the dialog will use its font as default
my $Value = FontDialog(GUIGetProp($mObj, "Font"));
if($Value)
{
	my List ( $Name, $Size, $Bold, $Italic, $Strikeout, $Underline ) = $Value;
	// Display font information
	print(	"Name '$Name' \n" .
		"Size '$Size' \n" .
		"Bold '" . ($Bold ? "TRUE" : "FALSE") . "' \n" .
		"Italic '" . ($Italic ? "TRUE" : "FALSE") . "' \n" .
		"Strikeout '" . ($Strikeout ? "TRUE" : "FALSE") . "' \n" .
		"Underline '" . ($Underline ? "TRUE" : "FALSE") . "' \n"
		);
	// Create a new GUI font using this information
	my $Flags = 0;
	if($Bold) $Flags |= @fontBold;
	if($Italic) $Flags |= @fontItalic;
	if($Strikeout) $Flags |= @fontStrikeout;
	if($Underline) $Flags |= @FontUnderline;
	$NewFont = GUICreateFont($Name, $Size, $Flags);
	// Example of setting this font to a GUI control
	//GUISetProp($mObj, "Font", $NewFont);
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox