DBR/Admin/Window/MainMenu.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 60 CC 1 SCAR 6.9
CC
1
Cov
0%
BUILD
2.0
listbox_select
2.0
BEGIN
2.0
CRAP 2.0
1  
2 # the contents of this file are Copyright (c) 2004-2009 David Blood
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation.
6  
7 package DBR::Admin::Window::MainMenu;
8  
9  
10  
11 use strict;
12 use Class::Std;
13 use Data::Dumper;
14  
15 ## fix
16 use lib '/drj/tools/perl-dbr/lib';
17 use DBR::Admin::Window;
18 use DBR::Admin::Window::EnumList;
19 use DBR::Admin::Window::SchemaList;
20  
21 use vars qw($VERSION $PKG);
22  
23 $VERSION = 1.0;
24  
25 $PKG = __PACKAGE__;
26  
27 use base qw(DBR::Admin::Window);
28  
29  
30 {
31  
32 my %menu_labels = (
33 'DBR::Admin::Window::SchemaList' => 'Schemas',
34 'DBR::Admin::Window::EnumList' => 'Enums'
35 );
36 my @menu_values = keys %menu_labels;
37  
38 ####################
39 sub BUILD {
40  
41 my ($self, $ident, $_args) = @_;
42  
43  
44 my $listbox = $self->get_win->add(
45 'mainMenulist', 'Listbox',
46 -y => 2,
47 -width => 15,
48 -height => 4,
49 -values => \@menu_values,
50 -labels => \%menu_labels,
51 -onchange => sub { $self->listbox_select(shift); },
52 );
53  
54 $listbox->draw();
55  
56 my $title = q# ____ ____ ____ _ _ _
57 | _ \| __ )| _ \ / \ __| |_ __ ___ (_)_ __
58 | | | | _ \| |_) | / _ \ / _` | '_ ` _ \| | '_ \
59 | |_| | |_) | _ < / ___ \ (_| | | | | | | | | | |
60 |____/|____/|_| \_\ /_/ \_\__,_|_| |_| |_|_|_| |_|#;
61  
62 my $label = $self->get_win->add(
63 "instructions_label", 'Label',
64 -text => "$title\n\nGlobal keys:
65 Control-Q: Quit
66 Tab: next input widget
67 Enter or right-arrow: select
68 Up/Down arrows: previous/next item in current input widget
69 Mouse supported depending on OS (Linux - probably, Mac - probably not)",
70 -y => 7,
71 );
72  
73 $label->draw;
74  
75  
76  
77  
78
79  
80 $listbox->focus();
81 $listbox->onFocus(sub {$listbox->clear_selection});
82  
83 }
84  
85 #######################
86 sub listbox_select {
87 my ($self, $_args) = @_;
88  
89 #print STDERR Dumper ':' . $_args->get() . ':';
90 my $class = $_args->get();
91  
92 # print STDERR "$class->new({ id => $menu_labels{$_args->get}, parent => $self->get_win() });\n";
93 # print STDERR Dumper $self->get_win();
94  
95 $class->new({ id => $menu_labels{$_args->get}, parent => $self->get_win, parent_title => ucfirst($self->get_id) });
96
97  
98 }
99  
100 }
101  
102 1;