| 1 | # Copyright 2004, 2010 by Audrey Tang <cpan@audreyt.org> | ||||||||||
| 2 | |||||||||||
| 3 | package Win32::Exe::Resource::GroupIcon; | ||||||||||
| 4 | |||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | ▶ | use base 'Win32::Exe::Resource'; | ||||||||
|
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' => [ 'a14', '{$Count}', 1 ], | ||||||||||
| 12 | 5 | ); | |||||||||
| 13 | 5 | ▶ | use constant DEFAULT_ARGS => ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | Magic => "\0\0", | ||||||||||
| 15 | Type => 1, | ||||||||||
| 16 | Count => 0, | ||||||||||
| 17 | 5 | ); | |||||||||
| 18 | 5 | ▶ | use constant DELEGATE_SUBS => ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 'IconFile' => [ 'dump_iconfile', 'write_iconfile' ], | ||||||||||
| 20 | 5 | ); | |||||||||
| 21 | |||||||||||
| 22 | 10 | ▶ | sub icons { | ||||||||
|
Subroutine
icons: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 23 | 10 | my $self = shift; | |||||||||
| 24 | 10 | $self->members(@_); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 4 | ▶ | sub set_icons { | ||||||||
|
Subroutine
set_icons: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||
| 28 | 4 | my ($self, $icons) = @_; | |||||||||
| 29 | |||||||||||
| 30 | 4 | $self->SetCount(scalar @$icons); | |||||||||
| 31 | 4 | $self->set_members('Resource::Icon' => $icons); | |||||||||
| 32 | |||||||||||
| 33 | 4 | ▶ | my $rsrc = $self->first_parent('Resources') or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | # get the existing resource icon ids | ||||||||||
| 36 | |||||||||||
| 37 | 4 | my %existids = (); | |||||||||
| 38 | 4 | for my $groupicon ($rsrc->objects('GroupIcon')) { | |||||||||
| 39 | 4 | for my $icon ( $groupicon->icons ) { | |||||||||
| 40 | 6 | my $id = $icon->Id; | |||||||||
| 41 | 6 | $existids{$id} = 1; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 4 | my $nextid = 0; | |||||||||
| 46 | 4 | foreach my $idx (0 .. $#{$icons}) { | |||||||||
| 47 | 6 | $nextid ++; | |||||||||
| 48 | 0 | ▶ | while(exists($existids{$nextid})) { $nextid ++; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 6 | my $icon = $self->icons->[$idx]; | |||||||||
| 50 | 6 | $icon->SetId($nextid); | |||||||||
| 51 | 6 | $rsrc->insert($self->icon_name($icon->Id), $icons->[$idx]); | |||||||||
| 52 | } | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 8 | ▶ | sub substr { | ||||||||
|
Subroutine
substr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 56 | 8 | my ($self, $id) = @_; | |||||||||
| 57 | 8 | my $section = $self->first_parent('Resources'); | |||||||||
| 58 | 8 | return $section->res_data($self->icon_name($id)); | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 14 | ▶ | sub icon_name { | ||||||||
|
Subroutine
icon_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 62 | 14 | my ($self, $id) = @_; | |||||||||
| 63 | 14 | my @icon_name = split("/", $self->PathName, -1); | |||||||||
| 64 | 14 | $icon_name[1] = "#RT_ICON"; | |||||||||
| 65 | 14 | $icon_name[2] = "#$id"; | |||||||||
| 66 | 14 | return join("/", @icon_name); | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 5 | 1; | |||||||||