Debian Codegraph @

Tk/Configure.pm

raw
1 package Tk::Configure;
2 use vars qw($VERSION);
3 $VERSION = '4.009'; # $Id: //depot/Tkutf8/Tk/Configure.pm#8 $
4
5 use Carp;
6
7
8 # Class that handles cget/configure for options that
9 # need translating from public form
10 # e.g. $cw->configure(-label => 'fred')
11 # into $cw->subwiget('label')->configure(-text => 'fred')
12 # Should probably do something clever with regexp's here
13
14
15 sub new
16 {
17 my ($class,@args) = @_;
18 unshift(@args,'configure','cget') if (@args < 3);
19 return bless \@args,$class;
20 }
21
22 sub cget
23 {
24 croak('Wrong number of args to cget') unless (@_ == 2);
25 my ($alias,$key) = @_;
26 my ($set,$get,$widget,@args) = @$alias;
27 $widget->$get(@args);
28 }
29
30 sub configure
31 {
32 my $alias = shift;
33 shift if (@_);
34 my ($set,$get,$widget,@args) = @$alias;
35 if (wantarray)
36 {
37 my @results;
38 eval { @results = $widget->$set(@args,@_) };
39 croak($@) if $@;
40 return @results;
41 }
42 else
43 {
44 my $results;
45 eval { $results = $widget->$set(@args,@_) };
46 croak($@) if $@;
47 return $results;
48 }
49 }
50
51 *TIESCALAR = \&new;
52 *TIEHASH = \&new;
53
54 sub FETCH
55 {
56 my $alias = shift;
57 my ($set,$get,$widget,@args) = @$alias;
58 return $widget->$get(@args,@_);
59 }
60
61 sub STORE
62 {
63 my $alias = shift;
64 my ($set,$get,$widget,@args) = @$alias;
65 $widget->$set(@args,@_);
66 }
67
68 1;