Subversion Repositories gelsvn

Rev

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