Core Function FontDialog

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
m (1 revision)
 
(3 intermediate revisions by one user not shown)
Line 17: Line 17:
 
Success: Returns array with details.
 
Success: Returns array with details.
  
Failure: Returns empty array.
+
Failure: Returns null (the user pressing cancel also returns null).
  
 
=== Remarks ===
 
=== Remarks ===
Line 44: Line 44:
 
if($Strikeout) $Flags |= @fontStrikeout;
 
if($Strikeout) $Flags |= @fontStrikeout;
 
if($Underline) $Flags |= @FontUnderline;
 
if($Underline) $Flags |= @FontUnderline;
$NewFont = GUICreateFont($Name, $Size, $Flags);
+
$NewFont = GUICreate("Font", $Name, $Size, $Flags);
 
// Example of setting this font to a GUI control
 
// Example of setting this font to a GUI control
 
//GUISetProp($mObj, "Font", $NewFont);
 
//GUISetProp($mObj, "Font", $NewFont);
Line 72: Line 72:
 
if($Strikeout) $Flags |= @fontStrikeout;
 
if($Strikeout) $Flags |= @fontStrikeout;
 
if($Underline) $Flags |= @FontUnderline;
 
if($Underline) $Flags |= @FontUnderline;
$NewFont = GUICreateFont($Name, $Size, $Flags);
+
$NewFont = GUICreate("Font", $Name, $Size, $Flags);
 
// Example of setting this font to a GUI control
 
// Example of setting this font to a GUI control
 
//GUISetProp($mObj, "Font", $NewFont);
 
//GUISetProp($mObj, "Font", $NewFont);

Latest revision as of 12:37, 14 June 2015

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 null (the user pressing cancel also returns null).

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 = GUICreate("Font", $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 = GUICreate("Font", $Name, $Size, $Flags);
	// Example of setting this font to a GUI control
	//GUISetProp($mObj, "Font", $NewFont);
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox