Tk/HashViewer.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 61 CC 1 SCAR 6.9
CC
1
Cov
0%
ClassInit
2.0
Populate
2.0
cme_object
2.0
CRAP 2.0
1 #
2 # This file is part of Config-Model-TkUI
3 #
4 # This software is Copyright (c) 2008-2021 by Dominique Dumont.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package Config::Model::Tk::HashViewer 1.382;
11  
12 use strict;
13 use warnings;
14 use Carp;
15  
16 use base qw/Tk::Frame Config::Model::Tk::AnyViewer/;
17 use subs qw/menu_struct/;
18  
19 Construct Tk::Widget 'ConfigModelHashViewer';
20  
21 my @fbe1 = qw/-fill both -expand 1/;
22 my @fxe1 = qw/-fill x -expand 1/;
23 my @fx = qw/-fill x /;
24  
25 sub ClassInit {
26 my ( $cw, $args ) = @_;
27  
28 # ClassInit is often used to define bindings and/or other
29 # resources shared by all instances, e.g., images.
30  
31 # cw->Advertise(name=>$widget);
32 }
33  
34 sub Populate {
35 my ( $cw, $args ) = @_;
36 my $hash = $cw->{hash} = delete $args->{-item}
37 || die "HashViewer: no -item, got ", keys %$args;
38 my $path = delete $args->{-path}
39 || die "HashViewer: no -path, got ", keys %$args;
40 my $cme_font = delete $args->{-font};
41  
42 $cw->add_header( View => $hash )->pack(@fx);
43  
44 my $inst = $hash->instance;
45  
46 my $elt_frame = $cw->Frame(qw/-relief raised -borderwidth 2/)->pack(@fbe1);
47 my $str = $hash->element_name . ' ' . $hash->get_type . ' elements';
48 $elt_frame->Label( -text => $str )->pack();
49  
50 my $rt = $elt_frame->Scrolled(
51 'ROText',
52 -scrollbars => 'oe',
53 -height => 10,
54 )->pack(@fbe1);
55  
56 foreach my $c ( $hash->fetch_all_indexes ) {
57 $rt->insert( 'end', $c . "\n" );
58 }
59  
60 $cw->add_annotation($hash)->pack(@fx);
61 $cw->add_warning( $hash, 'view' )->pack(@fx);
62 $cw->add_summary($hash)->pack(@fx);
63 $cw->add_description($hash)->pack(@fbe1);
64  
65 $cw->add_info_button()->pack( -side => 'left', @fxe1 );
66 $cw->add_editor_button($path)->pack( -side => 'right', @fxe1 );
67  
68 $cw->ConfigSpecs(-font => [['SELF','DESCENDANTS'], 'font','Font', $cme_font ],);
69  
70 $cw->SUPER::Populate($args);
71 }
72  
73 sub cme_object {
74 my $cw = shift;
75 return $cw->{hash};
76 }
77  
78 1;