File: SpreadsheetHideRows

package info (click to toggle)
libtk-tablematrix-perl 1.22-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,624 kB
  • ctags: 1,274
  • sloc: ansic: 15,026; perl: 3,376; makefile: 156; sh: 16
file content (110 lines) | stat: -rwxr-xr-x 2,875 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/perl
# Example of Tk::TableMatrix::SpreadsheetHideRows widget:
#   Table display with hidden detail data
#
# This example displays made-up average temperature data
#  for different time periods (quarter and months), and regions.

# Updated to have more spans. 3/8/06. Fully expanding Row 2 and the
#    lower level Rows should look ok, with the spans restoring back
#    to where they were.

use Tk;

use Tk::TableMatrix::SpreadsheetHideRows;

my $top = MainWindow->new;

my $arrayVar = {};

my @rawdata = (qw/ 
Quarter	Month	Region	State	AvgTemp	
1	--	South	--	39	
2	--	South	--	61	
3	--	South	--	65	
4	--	South	--	45	
/);



foreach my $row  (0..4){
	foreach my $col (0..5){
		next if( $col == 0);
			
		$arrayVar->{"$row,$col"} = shift @rawdata;
	}
}


my $expandData = {
	1 => { data => [ [ '','','Jan', 'South','--',33],
	                 [ '','','Feb', 'South','--',38],
	                 [ '','','Mar', 'South','--',45],
			 ],
	       tag => 'detail',		
	       expandData => {
	       			1 => { data => [ [ '','','', '','Texas',35],
				        	  [ '','','', '','Ok',36],
				        	  [ '','','', '','Ark',37],
						 ],
				       tag => 'detail2',
				       },
	       			2 => { data => [ [ '','','', '','Texas',41],
				        	  [ '','','', '','Ok',42],
				        	  [ '','','', '','Ark',43],
						 ],
				       tag => 'detail2',
				       },
	       			3 => { data => [ [ '','','', '','Texas',51],
				        	  [ '','','', '','Ok',52],
				        	  [ '','','', '','Ark',53],
						 ],
				       tag => 'detail2',
				       },
			      },
	       },
	       
	2 => { data => [ [ '','','Apr', 'South','--',55],
	        	 [ '','','May', 'South','--',61],
	        	 [ '','','Jun', 'South','--',68],
	        	 ],
	       tag => 'detail',
	       spans => [ 1 => '0,1'],
	       expandData => {
	       			2 => { data => [ [ '','','', '','Texas',58],
				        	  [ '','','', '','Ok',65],
				        	  [ '','','', '','Ark',60],
						 ],
				       tag => 'detail2',
				       }
			      }
	       },
	 4 => { data => [['','Sorry, Detail Data Not Available Until Next month']],
	 	tag => 'detail',
		spans => [ 1 => '0,3']
		},
	       
	};

my $t = $top->Scrolled('SpreadsheetHideRows', -rows => 5, -cols => 6, 
                              -width => 6, -height => 6,
			      -titlerows => 1, -titlecols => 1,
			      -variable => $arrayVar,
			      -selectmode => 'extended',
			      -resizeborders => 'both',
			      -selectorCol => 0,
			      -expandData => $expandData
			     #  -state => 'disabled'
			    #  -colseparator => "\t",
			    #  -rowseparator => "\n"
                    );

# Tags for the detail data:
$t->tagConfigure('detail', -bg => 'palegreen', -relief => 'sunken');
$t->tagConfigure('detail2', -bg => 'lightskyblue1', -relief => 'sunken');



$t->pack(-expand => 1, -fill => 'both');

Tk::MainLoop;