App-PLab

 view release on metacpan or  search on metacpan

bin/ManCen  view on Meta::CPAN

      $cenname = $w-> win_extname( $cenname);
      if ( open F, "< $cenname") {
         $w-> {extraPoints} = $w-> rpt_read( *F);
         close F;
      }
   }
}

sub win_closeextras
{
   my $w = $_[0];
   $w-> SUPER::win_closeextras;
   $w-> rptex_clear();
}

sub win_extraschanged
{
   my $w = $_[0];
   $w-> win_untemp;
   $w-> SUPER::win_extraschanged;
   $w-> sb_points();
}


sub win_extpathchanged
{
   my $w = $_[0];
   if ( defined $w-> {file}) {
      my $i;
      my @pt = defined $w-> {points} ? @{$w->{points}} : ();
      $w-> win_closeextras;
      $w-> win_closeframe;
      $w-> win_newframe;
      for ( $i = 0; $i < scalar @pt; $i += 2) {
         $w-> rpt_add( $pt[$i], $pt[ $i+1]);
      }
      $w-> win_newextras;
      $w-> win_extraschanged;
      $w-> IV-> repaint;
   }
}

sub on_create
{
   my $self = $_[0];
   my $w    = $_[0];
   $self-> SUPER::on_create;
   $self-> {dataExt} = 'cen';

   $self-> win_pointerchanged();
   my $scale = $::application-> uiScaling;
   $scale = 1 if $scale < 1;

   my $tb  = $self-> ToolBar;
   my $cck = $tb-> insert( Label =>
      origin      => [ 120 * $scale, 1],
      size        => [ $tb-> width - 138 * $scale, 36 * $scale],
      name        => 'PointRef',
      text        => '0:0',
      growMode    => gm::Client,
      transparent => 1,
      color       => $self-> {ini}-> {Color_Label},
      alignment   => ta::Right,
      valignment  => ta::Center,
      font        => { style => fs::Bold },
   );
   $tb-> insert( Widget =>
      origin      => [ $tb-> width - 18 * $scale, 1],
      size        => [ 16 * $scale, 36 * $scale],
      transparent => 1,
      growMode    => gm::Right,
      name        => 'Lookup',
      onPaint     => sub {
         my ( $self, $canvas) = @_;
         my ( $x, $y) = $canvas-> size;
         $canvas-> color( $w-> {ini}-> {Color_Label});
         my @pt = $w-> {ini}-> {forwardLookup} ? (
            0, 0.6, 0.5, 0.6, 0.5, 0.75, 0.9, 0.5, 0.5, 0.25, 0.5, 0.4, 0, 0.4
         ) : (
            0.9, 0.6, 0.9, 0.4, 0.5, 0.4, 0.5, 0.25, 0, 0.5, 0.5, 0.75, 0.5, 0.6
         );
         my $i;
         for ( $i = 0; $i < scalar @pt; $i+=2) {
            $pt[$i]   *= $x;
            $pt[$i+1] *= $y;
         }
         $canvas-> fillpoly( \@pt );
      },
   );
}

sub win_pointerchanged
{
   my  $w = $_[0];

   if ( $w-> {ini}-> {StdPointerShape}) {
      $w-> IV-> pointer( cr::Arrow);
      return;
   }

   my $color = $w-> {ini}-> {Color_Pointer};
   my ( $cx, $cy) = ( $::application-> get_system_value( sv::XPointer), $::application-> get_system_value( sv::YPointer));
   my $ic = Prima::Image-> create(
      width  => $cx,
      height => $cy,
      type   => im::Mono,
      palette => [0,0,0, $color & 0xFF, ( $color >> 8) & 0xFF, ( $color >> 16) & 0xFF],
   );
   $ic-> begin_paint;
   $ic-> color( cl::Black);
   $ic-> bar( 0, 0, $cx, $cx);
   $ic-> color( $color ? $color : cl::White);
   my ( $c2x, $c2y) = ( int($cx/2), int($cy/2));
   $ic-> line( 0, $c2y, $c2x - 2, $c2y);
   $ic-> line( $c2x + 2, $c2y, $cx - 1, $c2y);
   $ic-> line( $c2x, 0, $c2x, $c2y - 2);
   $ic-> line( $c2x, $c2y + 2, $c2x, $cy - 1);
   $ic-> end_paint;
   my $mc = Prima::Image-> create(
      width  => $cx,
      height => $cy,
      type   => im::BW,
      preserveType  => 1,
   );
   $mc-> begin_paint;
   $mc-> color( cl::White);
   $mc-> bar( 0, 0, $cx, $cx);
   if ( $color) {
      $mc-> color( cl::Black);
      $mc-> line( 0, $c2y, $c2x - 2, $c2y);



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