Wx.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« wxGUI.pm ↑ Summary
1 package Aut::UI::Wx;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Locale::Framework;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use Aut::UI::wxGUI;
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use Aut;
7 use Aut::Ticket;
8 use Wx qw(:everything);
9  
10 our $VERSION='0.02';
11  
12 #####################################################
13 # Instantiation/Initialization
14 #####################################################
15  
16 sub new {
17 my $class=shift;
18 my $parent=shift;
19 my $self;
20  
21 if (defined $parent) {
22 $self->{"parent"}=$parent;
23 }
24 else {
25 $self->{"parent"}=undef;
26 }
27  
28 $self->{"levels"}=undef;
29 $self->{"admin"}=undef;
30  
31 bless $self,$class;
32 return $self;
33 }
34  
35 sub initialize {
36 my $self=shift;
37 my $levels=shift;
38 my $adminlevel=shift;
39  
40 $self->{"levels"}=$levels;
41 $self->{"admin"}=$adminlevel;
42 }
43  
44 sub levels {
45 my $self=shift;
46 return @{$self->{"levels"}};
47 }
48  
49 #####################################################
50 # Messages
51 #####################################################
52  
53 sub message_ok {
54 my $self=shift;
55 my $text=shift;
56 my $title=shift;
57 my $parent=shift;
58  
59 if (not defined $title) { $title=_T("Alert"); }
60 if (not defined $parent) { $parent=$self->{"parent"}; }
61
62 #my $dlg=new __Aut__Msg($parent,-1,$title);
63 #$dlg->set_label($text);
64 #$dlg->ShowModal();
65 #$dlg->Destroy();
66 Wx::MessageBox( $text, $title, wxOK|wxCENTRE, $parent );
67 }
68  
69 sub message {
70
71 }
72  
73 #####################################################
74 # Password/account related
75 #####################################################
76  
77 sub ask_pass {
78 my $self=shift;
79 my $aut=shift;
80 my $text=shift;
81 my $title=shift;
82 my $parent=shift;
83 my $pass;
84  
85 if (not defined $title) { $title=_T("Give password"); }
86 if (not defined $parent) { $parent=$self->{"parent"}; }
87  
88 my $dlg=new __Aut__Entry($parent,-1,$title);
89  
90 $dlg->set_label($text);
91 $dlg->SetTitle($title);
92 if ($dlg->ShowModal()==wxID_OK) {
93 $pass=$dlg->get_value();
94 if ($pass eq "") {
95 $pass=undef;
96 }
97 }
98 else {
99 $pass=undef;
100 }
101  
102 $dlg->Destroy();
103  
104 return $pass;
105 }
106  
107 sub login {
108 my $self=shift;
109 my $aut=shift;
110 my $title=shift;
111 my $parent=shift;
112  
113 if (not defined $title) { $title=_T("Login"); }
114 if (not defined $parent) { $parent=$self->{"parent"}; }
115  
116 my $dlg=new __Aut__dlgLogin($parent,-1,$title);
117 $dlg->set_aut($aut);
118 $dlg->set_ui($self);
119  
120  
121 $dlg->ShowModal();
122  
123 my $ticket=$dlg->ticket();
124  
125 $dlg->Destroy();
126  
127 return $ticket;
128 }
129  
130 sub logout {
131 my $self=shift;
132 my $aut=shift;
133 my $ticket=shift;
134 $ticket->invalidate();
135 return 1;
136 }
137  
138 sub change_pass {
139 my $self=shift;
140 my $aut=shift;
141 my $ticket=shift;
142 my $title=shift;
143 my $parent=shift;
144  
145 if (not defined $title) { $title=_T("Change Password"); }
146 if (not defined $parent) { $parent=$self->{"parent"}; }
147  
148 my $dlg=new __Aut__ChangePass($parent,-1,$title);
149 $dlg->set_aut($aut);
150 $dlg->set_ui($self);
151 $dlg->set_account($ticket->account());
152 $dlg->set_ticket($ticket);
153  
154 $dlg->ShowModal();
155  
156 $dlg->Destroy();
157 }
158  
159 #####################################################
160 # Administration
161 #####################################################
162  
163 sub admin {
164 my $self=shift;
165 my $aut=shift;
166 my $ticket=shift;
167 my $title=shift;
168 my $parent=shift;
169  
170 if (not defined $title) { $title=_T("Account Administration"); }
171 if (not defined $parent) { $parent=$self->{"parent"}; }
172  
173 my $dlg=new __Aut__AdminAccounts($parent,-1,$title);
174 $dlg->set_aut($aut);
175 $dlg->set_ui($self);
176 $dlg->set_ticket($ticket);
177  
178 if ($dlg->initialize()) {
179 $dlg->ShowModal();
180 }
181  
182 $dlg->Destroy();
183 }
184  
185 1;
186 __END__
« wxGUI.pm ↑ Summary