| 1 | # Copyright 2004 by Audrey Tang <cpan@audreyt.org> | ||
| 2 | |||
| 3 | package Win32::Exe::IconFile; | ||
| 4 | |||
| 5 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 5 | ▶ | use base 'Win32::Exe::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 5 | ▶ | use constant FORMAT => ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | Magic => 'a2', | ||
| 9 | Type => 'v', | ||
| 10 | Count => 'v', | ||
| 11 | 'Resource::Icon' => [ 'a16', '{$Count}', 1 ], | ||
| 12 | Data => 'a*', | ||
| 13 | 5 | ); | |
| 14 | 5 | ▶ | use constant DEFAULT_ARGS => ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | Magic => "\0\0", | ||
| 16 | Type => 1, | ||
| 17 | Count => 0, | ||
| 18 | Data => '', | ||
| 19 | 5 | ); | |
| 20 | 5 | ▶ | use constant DISPATCH_FIELD => 'Magic'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 5 | ▶ | use constant DISPATCH_TABLE => ( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||
| 22 | "\0\0" => '', | ||
| 23 | "MZ" => '__BASE__', | ||
| 24 | 0 | ▶ | '*' => sub { die "Invalid icon file header: $_[1]" }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 25 | 5 | ); | |
| 26 | |||
| 27 | 20 | ▶ | sub icons { |
|
Subroutine
icons: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 28 | 20 | my $self = shift; | |
| 29 | 20 | $self->members(@_); | |
| 30 | } | ||
| 31 | |||
| 32 | 6 | ▶ | sub set_icons { |
|
Subroutine
set_icons: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 33 | 6 | my ($self, $icons) = @_; | |
| 34 | 6 | $self->SetCount(scalar @$icons); | |
| 35 | 6 | $self->set_members('Resource::Icon' => $icons); | |
| 36 | 6 | $self->refresh; | |
| 37 | |||
| 38 | 6 | foreach my $idx (0 .. $#{$icons}) { | |
| 39 | 12 | $self->icons->[$idx]->SetImageOffset(length($self->dump)); | |
| 40 | 12 | $self->SetData( $self->Data . $icons->[$idx]->Data ); | |
| 41 | } | ||
| 42 | |||
| 43 | 6 | $self->refresh; | |
| 44 | } | ||
| 45 | |||
| 46 | 6 | ▶ | sub dump_iconfile { |
|
Subroutine
dump_iconfile: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 47 | 6 | my $self = shift; | |
| 48 | 6 | my @icons = $self->icons; | |
| 49 | 6 | my $obj = $self->require_class('IconFile')->new; | |
| 50 | 6 | $obj->set_icons(\@icons); | |
| 51 | 6 | return $obj->dump; | |
| 52 | } | ||
| 53 | |||
| 54 | 0 | ▶ | sub write_iconfile { |
|
Subroutine
write_iconfile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 55 | 0 | my ($self, $filename) = @_; | |
| 56 | 0 | $self->write_file($filename, $self->dump_iconfile); | |
| 57 | } | ||
| 58 | |||
| 59 | 5 | 1; | |