DBR/Admin/Window.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 50 CC 4 SCAR 18.3
CC
4
Cov
0%
close
12.0
BUILD
6.0
BEGIN
2.0
CRAP 6.2
1 # the contents of this file are Copyright (c) 2004-2009 David Blood
2 # This program is free software; you can redistribute it and/or
3 # modify it under the terms of the GNU General Public License as
4 # published by the Free Software Foundation.
5  
6  
7  
8 package DBR::Admin::Window;
9  
10 use strict;
11 use Class::Std;
12 use Data::Dumper;
13  
14  
15 use vars qw($VERSION $PKG);
16  
17 $VERSION = 1.0;
18  
19 $PKG = __PACKAGE__;
20  
21 {
22 #######################
23 # member data
24 my %parent_of : ATTR( :get<parent> :set<parent>);
25 my %id_of : ATTR( :get<id> :set<id>);
26 my %win_of : ATTR( :get<win> :set<win>);
27  
28 ##########################
29 sub BUILD {
30  
31 my ($self, $ident, $_args) = @_;
32  
33 my $w = $_args->{parent}->root->add(
34 $_args->{id}, 'Window',
35 -border => 1,
36 -y => 1,
37 -bfg => 'green',
38 -title => ucfirst($_args->{id}),
39 -titlereverse => 0,
40 );
41  
42  
43 my $close_label = ($_args->{parent_title} ? "Back To " . $_args->{parent_title} : 'Close');
44 $w->add(
45 'close', 'Buttonbox',
46 -buttons => [
47 {
48 -label => "< $close_label >",
49 -value => 1,
50 -shortcut => 1 ,
51 -onpress => sub {$self->close}
52
53 }
54 ]
55 );
56  
57 $self->set_parent($_args->{parent}->root);
58 $self->set_win($w);
59 $self->set_id($_args->{id});
60  
61 $w->focus();
62 }
63  
64 ###################
65 sub close {
66  
67 my ($self, $_args) = @_;
68  
69 if ($self->get_id eq 'DBR Admin Main Menu') {
70 my $return = $self->get_win->root->dialog(
71 -message => "Do you really want to quit?",
72 -title => "Are you sure???",
73 -buttons => ['yes', 'no'],
74
75 );
76  
77 exit(0) if $return;
78 }
79  
80 $self->get_parent->delete($self->get_id);
81 $self->get_parent->draw();
82 $self->get_parent->focus();
83 }
84  
85  
86  
87  
88  
89 }
90  
91  
92  
93  
94  
95 1;