summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl.straw/lib/Win32/Exe/ResourceEntry/Id.pm
blob: 39e35b4000df8dc80fc0beed06fd7eb932c0e2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# $File: //local/member/autrijus/Win32-Exe/lib/Win32/Exe/ResourceEntry/Id.pm $ $Author: autrijus $
# $Revision: #6 $ $Change: 1130 $ $Date: 2004-02-17T15:40:29.640821Z $

package Win32::Exe::ResourceEntry::Id;

use strict;
use base 'Win32::Exe::ResourceEntry';
use constant SUBFORMAT => (
    Id		    => 'V',
);
use constant RESOURCE_TYPES => [qw(
    _		CURSOR		BITMAP		ICON	    MENU
    DIALOG	STRING		FONTDIR		FONT	    ACCELERATOR
    RCDATA	MESSAGETABLE	GROUP_CURSOR	_	    GROUP_ICON
    _		VERSION		DLGINCLUDE	_	    PLUGPLAY
    VXD		ANICURSOR	ANIICON		HTML        MANIFEST
)];
use constant RT_TO_ID => {
    map { ('RT_'.RESOURCE_TYPES->[$_] => $_) }
	(0 .. $#{+RESOURCE_TYPES})
};
use constant ID_TO_RT => { reverse %{+RT_TO_ID} };

sub Name {
    my ($self) = @_;
    my $id = $_[0]->Id;
    $id = $self->id_to_rt($id) if $self->parent->depth < 1;
    return "#$id";
}

sub SetName {
    my ($self, $name) = @_;
    $name =~ s/^#//;
    $self->SetId( $self->rt_to_id($name) );
}

sub id_to_rt {
    my ($self, $id) = @_;
    return(+ID_TO_RT->{$id} || $id);
}

sub rt_to_id {
    my ($self, $rt) = @_;
    return(+RT_TO_ID->{$rt} || $rt);
}

1;