NAME
LibUI::FontButton - Button-like Control that Opens a Font Chooser when Clicked
SYNOPSIS
use LibUI ':all';
use LibUI::VBox;
use LibUI::Window;
use LibUI::FontButton;
Init && die;
my $window = LibUI::Window->new( 'Font Picker', 320, 100, 0 );
$window->setMargined( 1 );
my $box = LibUI::VBox->new();
my $text = LibUI::FontButton->new();
$box->append( $text, 1 );
$text->onChanged(
sub {
my $f = shift->font;
# Some enum values don't have a 1:1 equiv with CSS but...
printf <<'', $f->{weight}, $f->{italic}, $f->{size}, $f->{family};
html {
font: %s %s %spt "%s";
}
},
undef
);
$window->setChild($box);
$window->onClosing(
sub {
Quit();
return 1;
},
undef
);
$window->show;
Main();
DESCRIPTION
A control with a button-like control that opens a font chooser when clicked.
Functions
Not a lot here but... well, it's just a simple widget.
new( )
my $font = LibUI::FontButton->new( );
Creates a new font button.
The default font is determined by the OS defaults.
font( ... )
my $desc = $font->font;
Returns the selected font.
Note: Make sure to call freeFont()
to free all allocated resources within the returned font.
onChanged( ... )
sub new_font {
my ($ctrl, $data) = @_;
my $font = $ctrl->font;
...;
}
$font->onChanged( \&new_font, undef );
Registers a callback for when the font is changed.
Expected parameters include:
$callback
- CodeRef that should expect the following:$data
- user data to be passed to the callback
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>