Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package HTMLProjectCreator;
2
 
3
# ************************************************************
4
# Description   : An HTML project creator to display all settings
5
# Author        : Justin Michel & Chad Elliott
6
# Create Date   : 8/25/2003
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
use File::Basename;
15
 
16
use ProjectCreator;
17
 
18
use vars qw(@ISA);
19
@ISA = qw(ProjectCreator);
20
 
21
# ************************************************************
22
# Data Section
23
# ************************************************************
24
 
25
my($style_indent) = .5;
26
 
27
# ************************************************************
28
# Subroutine Section
29
# ************************************************************
30
 
31
sub file_sorter {
32
  my($self)  = shift;
33
  my($left)  = shift;
34
  my($right) = shift;
35
  return lc($left) cmp lc($right);
36
}
37
 
38
 
39
sub convert_slashes {
40
  #my($self) = shift;
41
  return 0;
42
}
43
 
44
 
45
sub label_nodes {
46
  my($self)  = shift;
47
  my($hash)  = shift;
48
  my($nodes) = shift;
49
  my($level) = shift;
50
 
51
  foreach my $key (sort keys %$hash) {
52
    push(@$nodes, [$level, $key]);
53
    $self->label_nodes($$hash{$key}, $nodes, $level + 1);
54
  }
55
}
56
 
57
 
58
sub count_levels {
59
  my($self)    = shift;
60
  my($hash)    = shift;
61
  my($current) = shift;
62
  my($count)   = shift;
63
 
64
  foreach my $key (keys %$hash) {
65
    $self->count_levels($$hash{$key}, $current + 1, $count);
66
  }
67
  if ($current > $$count) {
68
    $$count = $current;
69
  }
70
}
71
 
72
 
73
sub fill_value {
74
  my($self)  = shift;
75
  my($name)  = shift;
76
  my($value) = undef;
77
 
78
  if ($name eq 'inheritance_nodes') {
79
    ## Get the nodes with numeric labels for the level
80
    my(@nodes) = ();
81
    $self->label_nodes($self->get_inheritance_tree(), \@nodes, 0);
82
 
83
    ## Push each node onto the value array
84
    $value = [];
85
    for(my $i = 0; $i <= $#nodes; ++$i) {
86
      my($file) = $nodes[$i]->[1];
87
      my($dir)  = $self->mpc_dirname($file);
88
      my($base) = basename($file);
89
 
90
      ## Relative paths do not work at all in a web browser
91
      if ($dir eq '.') {
92
        $file = $base;
93
      }
94
 
95
      my($path) = ($base eq $file ? $self->getcwd() . '/' : '');
96
      my($name) = undef;
97
 
98
      if ($i == 0) {
99
        ## If this is the first node, then replace the base filename
100
        ## with the actual project name.
101
        $name = $self->project_name();
102
      }
103
      else {
104
        ## This is a base project, so we use the basename and
105
        ## remove the file extension.
106
        $name = $base;
107
        $name =~ s/\.[^\.]+$//;
108
      }
109
 
110
      ## Create the div and a tags.
111
      push(@$value, '<a href="file://' . $path . $file .
112
                    '" onClick="return popup(this, \'Project File\')" ' .
113
                    'target=_blank>' .
114
                    '<div class="tree' . $nodes[$i]->[0] . '">' .
115
                     $name . '</div></a>');
116
    }
117
  }
118
  elsif ($name eq 'tree_styles') {
119
    ## Count the number of levels deep the inheritance goes
120
    my($count) = 0;
121
    $self->count_levels($self->get_inheritance_tree(), 0, \$count);
122
 
123
    my($margin) = 0;
124
    my($start)  = 100;
125
    my($max)    = 255;
126
    my($inc)    = ($count ne 0 ? int(($max - $start) / $count) : $max);
127
 
128
    ## Push each tree style onto the value array
129
    $value = [];
130
    for(my $i = 0; $i < $count; ++$i) {
131
      push(@$value, ".tree$i { background-color: #" .
132
                    sprintf("%02x%02x%02x", 0, $start, $start) . ';' .
133
                    ($margin != 0 ? " margin-left: $margin" . 'in;' : '') .
134
                    ' }');
135
      $start += $inc;
136
      $margin += $style_indent;
137
    }
138
  }
139
 
140
  return $value;
141
}
142
 
143
 
144
sub project_file_extension {
145
  #my($self) = shift;
146
  return '.html';
147
}
148
 
149
 
150
1;