GFtemplate.pm untested

filter: Statementstmt 0.0% 0 / 93 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 28 Podpod 0.0% 0 / 25 totaltotal 0.0% 0 / 191 CC 30 SCAR 46.1
CC
30
Cov
0%
setupContent
306.0
aMB
56.0
aSP
12.0
CRAP 100.8
1 package GFtemplate;
2 use strict;
3 use warnings;
4
5 our $VERSION = '0.10';
6  
7 use Exporter 'import';
8 our @EXPORT = qw<addWidget addVar setScale MainLoop $frame $winScale $winWidth $winHeight $winTitle>;
9 our $frame;
10
11 our $winX=30;
12 our $winY=30;
13 our $winWidth;
14 our $winHeight;
15 our $winTitle="title";
16 our $winScale=6.5;
17
18 # these arrays will contain the widgets each as an arrayref of the parameters
19 my @widgets=();
20 my %iVars=(); #vars for interface operation (e.g.
21 my %oVars=(); #vars for interface creation (e.g. list of options)
22 my %styles;
23
24 my $lastMenuLabel; #bug workaround in menu generator may be needed for submenus
25
26 sub new
27 {
28 my $class = shift;
29 my $self={};
30 bless( $self, $class );
31  
32  
33  
34 return $self;
35 };
36
37 sub MainLoop{ #activate UI
38
39 }
40  
41 # setupContent sets up the initial content before Mainloop can be run.
42 sub setupContent{
43 my ($self, $canvas)=@_; # pass both object as well as the frame element
44 $self ->{"menubar"}=undef; # menu not yet defined
45 my $currentMenu; # undefined menu
46 foreach my $widget (@widgets){ # read each widget data and call gnerator
47 my @params=@$widget;
48 my $wtype=shift @params;
49 if ($wtype eq "btn") {aBt($self, $canvas, @params);}
50 elsif ($wtype eq "textctrl") {aTC($self, $canvas, @params);}
51 elsif ($wtype eq "stattext") {aST($self, $canvas, @params);}
52 elsif ($wtype eq "sp") {aSP($self, $canvas, @params);}
53 elsif ($wtype eq "combo") {aCB($self, $canvas, @params);}
54 elsif ($wtype eq "sp") {aSP($self, $canvas, @params);}
55 elsif ($wtype eq "mb")
56 {
57 if (! $self->{"menubar"}){
58 $self ->{"menubar"} = Gtk3::MenuBar->new;
59 $canvas->put($self ->{"menubar"},0,0);
60 }
61 $currentMenu=aMB($self,$canvas,$currentMenu,@params)
62 }
63 }
64
65 sub aBt{
66 my ($self,$canvas, $id, $label, $location, $size, $action)=@_;# Button generator
67 }
68 sub aTC{
69 my ($self,$canvas, $id, $text, $location, $size, $action)=@_;0# Single line input generator
70 }
71 sub aST{
72 my ($self,$canvas, $id, $text, $location)=@_; #Static text element generator
73 }
74 sub aCB{
75 my ($self,$canvas, $id, $label, $location, $size, $action)=@_; #gnerator for comoboxes
76
77 }
78 sub aMB{
79 my ($self,$canvas,$currentMenu, $id, $label, $type, $action)=@_;
80 if (($lastMenuLabel) &&($label eq $lastMenuLabel)){return $currentMenu} # bug workaround
81 else {$lastMenuLabel=$label}; # in menu generator
82 if ($type eq "menuhead"){
83 $currentMenu="menu".$id;
84 }
85 elsif ($type eq "radio"){
86
87 }
88 elsif ($type eq "check"){
89
90 }
91 elsif ($type eq "separator"){
92
93 }
94 else{
95 if($currentMenu!~m/$label/){
96
97 }
98 }
99 return $currentMenu;
100 }
101 sub aSP{
102 my ($self,$canvas, $id, $panelType, $content, $location, $size)=@_;
103
104 if ($panelType eq "I"){ # Image panels start with I
105
106 }
107 if ($panelType eq "T"){
108
109 }
110 }
111
112
113 }
114  
115
116 #functions for GUIDeFATE to load the widgets into the backend
117 sub addWidget{
118 push (@widgets,shift );
119 }
120 sub addStyle{
121 my ($name,$style)=@_;
122 $styles{$name}=$style;
123 }
124 sub addVar{
125 my ($varName,$value)=@_;
126 $oVars{$varName}=$value;
127 }
128  
129 # Functions for internal use
130 sub getSize{
131 my ($self,$id)=@_;
132 my $found=getItem($self,$id);
133 return ( $found!=-1) ? $widgets[$found][5]:0;
134
135 }
136 sub getLocation{
137 my ($self,$id)=@_;
138 my $found=getItem($self,$id);
139 return ( $found!=-1) ? $widgets[$found][4]:0;
140
141 }
142 sub getItem{
143 my ($self,$id)=@_;
144 $id=~s/[^\d]//g;
145 my $i=0; my $found=-1;
146 while ($i<@widgets){
147 if ($widgets[$i][1]==$id) {
148 $found=$i;
149 }
150 $i++;
151 }
152 return $found;
153 }
154  
155 sub setScale{
156 $winScale=shift;
157 };
158  
159 sub getFrame{
160
161 };
162  
163 # The functions for GUI Interactions
164 #Static Text functions
165 sub setLabel{
166 my ($self,$id,$text)=@_;
167
168 }
169  
170 #Image functions
171 sub setImage{
172 my ($self,$id,$file)=@_;
173  
174 }
175  
176 #Text input functions
177 sub getValue{
178 my ($self,$id)=@_;
179 if ($id =~/TextCtrl/){
180 }
181 else {
182 if (exists $iVars{$id}){
183 return $iVars{$id}
184 }
185 }
186
187 }
188 sub setValue{
189 my ($self,$id,$text)=@_;
190
191 }
192 sub appendValue{
193 my ($self,$id,$text)=@_;
194
195 }
196  
197 #Message box, Fileselector and Dialog Boxes
198 sub showFileSelectorDialog{
199
200 my ($self, $message,$load,$filter) = @_;
201 my $filename;
202  
203 return $filename;
204 };
205 sub showDialog{
206 my ($self, $title, $message,$response,$icon) = @_;
207  
208 };
209
210 # Quit
211 sub quit{
212  
213 }
214 1;
215