CodeManager

 view release on metacpan or  search on metacpan

lib/Prima/CodeManager/Label.pm  view on Meta::CPAN


		( exists $p-> {left} && exists $p-> {right})
	);
	$p-> {autoHeight} = 0 if

		! exists $p-> {autoHeight} and (
		exists $p-> {height} ||

		exists $p-> {size} ||

		exists $p-> {rect} ||

		( exists $p-> {top} && exists $p-> {bottom})
	);
	$self-> SUPER::profile_check_in( $p, $default);
	my $vertical = exists $p-> {vertical} ?

		$p-> {vertical} :

		$default-> { vertical};

	$self->{lineSpace} = $p->{lineSpace} || 0;
}

sub init
{
	my $self = shift;
	my %profile = $self-> SUPER::init(@_);
	$self-> { alignment}     = $profile{ alignment};
	$self-> { valignment}    = $profile{ valignment};
	$self-> { autoHeight}    = $profile{ autoHeight};
	$self-> { autoWidth}     = $profile{ autoWidth};
	$self-> { wordWrap}      = $profile{ wordWrap};
	$self-> { focusLink}     = $profile{ focusLink};
	$self-> { showAccelChar} = $profile{ showAccelChar};
	$self-> { showPartial}   = $profile{ showPartial};
	$self-> { lineSpace}     = $profile{ lineSpace};
	$self-> check_auto_size;
	return %profile;
}

sub on_paint
{
	my ($self,$canvas) = @_;
	my @size = $canvas-> size;
	my @clr;
	if ( $self-> enabled) {
		if ( $self-> focused) {
			@clr = ($self-> hiliteColor, $self-> hiliteBackColor);
		} else {

			@clr = ($self-> color, $self-> backColor);

		}
	} else {

		@clr = ($self-> disabledColor, $self-> disabledBackColor);

	}

	unless ( $self-> transparent) {
		$canvas-> color( $clr[1]);
		$canvas-> bar(0,0,@size);
	}

	my $fh = $canvas-> font-> height + $self->{lineSpace};
	my $ta = $self-> {alignment};
	my $wx = $self-> {widths};
	my $ws = $self-> {words};
	my ($starty,$ycommon) = (0, scalar @{$ws} * $fh);

	if ( $self-> {valignment} == ta::Top)  {

		$starty = $size[1] - $fh;
	} elsif ( $self-> {valignment} == ta::Bottom) {

		$starty = $ycommon - $fh;
	} else {

		$starty = ( $size[1] + $ycommon)/2 - $fh;

	}

	my $y   = $starty;
	my $tl  = $self-> {tildeLine};
	my $i;
	my $paintLine = !$self-> {showAccelChar} && defined($tl) && $tl < scalar @{$ws};

	unless ( $self-> enabled) {
		$canvas-> color( $self-> light3DColor);
		for ( $i = 0; $i < scalar @{$ws}; $i++) {
			my $x = 0;
			if ( $ta == ta::Center) {

				$x = ( $size[0] - $$wx[$i]) / 2;

			} elsif ( $ta == ta::Right) {

				$x = $size[0] - $$wx[$i];

			}
			$canvas-> text_out( $$ws[$i], $x + 1, $y - 1);
			$y -= $fh;
		}
		$y   = $starty;
		if ( $paintLine) {
			my $x = 0;
			if ( $ta == ta::Center) {

				$x = ( $size[0] - $$wx[$tl]) / 2;

			} elsif ( $ta == ta::Right) {

				$x = $size[0] - $$wx[$tl];

			}
			$canvas-> line(

				$x + $self-> {tildeStart} + 1, $starty - $fh * $tl - 1,
				$x + $self-> {tildeEnd} + 1,   $starty - $fh * $tl - 1
			);



( run in 0.857 second using v1.01-cache-2.11-cpan-39bf76dae61 )