line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxGridER.pm |
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for wxGrid editors and renderers |
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 05/06/2003 |
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxGridER.pm 2378 2008-04-26 04:21:45Z mdootson $ |
8
|
|
|
|
|
|
|
## Copyright: (c) 2003, 2006 Mattia Barbon |
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
11
|
|
|
|
|
|
|
############################################################################# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Wx::DemoModules::wxGridER; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1639
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
16
|
1
|
|
|
1
|
|
7
|
use base 'Wx::Grid'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
754
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $longtext = join ' ', qw(Multiple lines of text are displayed |
19
|
|
|
|
|
|
|
wrapped in the cell. AutoSize is set on to |
20
|
|
|
|
|
|
|
display the contents); |
21
|
|
|
|
|
|
|
my @editors_renderers = |
22
|
|
|
|
|
|
|
( [ 'Default editor and renderer', 'Test 1', undef ], |
23
|
|
|
|
|
|
|
[ 'Float editor', '1.00', sub { Wx::GridCellFloatEditor->new }, |
24
|
|
|
|
|
|
|
'Float renderer', '2.13', sub { Wx::GridCellFloatRenderer->new( 12, 7 ) }, |
25
|
|
|
|
|
|
|
], |
26
|
|
|
|
|
|
|
[ 'Bool editor', '1', sub { Wx::GridCellBoolEditor->new }, |
27
|
|
|
|
|
|
|
'Bool renderer', '1', sub { Wx::GridCellBoolRenderer->new }, |
28
|
|
|
|
|
|
|
], |
29
|
|
|
|
|
|
|
[ 'Number editor', '14', sub { Wx::GridCellNumberEditor->new( 12, 20 ) }, |
30
|
|
|
|
|
|
|
'Number renderer', '12', sub { Wx::GridCellNumberRenderer->new }, |
31
|
|
|
|
|
|
|
], |
32
|
|
|
|
|
|
|
[ 'Choice editor', 'Test', sub { Wx::GridCellChoiceEditor->new( [qw(This Is a Test) ] ) }, |
33
|
|
|
|
|
|
|
], |
34
|
|
|
|
|
|
|
[ 'Auto Wrap editor', $longtext, sub { Wx::GridCellAutoWrapStringEditor->new }, |
35
|
|
|
|
|
|
|
'Auto Wrap renderer', $longtext, sub { Wx::GridCellAutoWrapStringRenderer->new }, |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
[ 'Enum editor', 2, sub { Wx::GridCellEnumEditor->new( 'First,Second,Third,Fourth,Fifth' ) }, |
38
|
|
|
|
|
|
|
# unluckily Enum renderer requires a custom grid table to work |
39
|
|
|
|
|
|
|
], |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
44
|
|
|
|
|
|
|
my $this = $class->SUPER::new( $parent, -1 ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$this->CreateGrid( 2 * @editors_renderers + 1, 7 ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# set every cell read-only |
49
|
|
|
|
|
|
|
for my $x ( 1 .. $this->GetNumberCols ) { # cols |
50
|
|
|
|
|
|
|
for my $y ( 1 .. $this->GetNumberRows ) { # rows |
51
|
|
|
|
|
|
|
$this->SetReadOnly( $y, $x, 1 ); # rows, cols |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$this->SetColSize( 0, 20 ); |
56
|
|
|
|
|
|
|
$this->SetColSize( 1, 150 ); |
57
|
|
|
|
|
|
|
$this->SetColSize( 2, 150 ); |
58
|
|
|
|
|
|
|
$this->SetColSize( 3, 20 ); |
59
|
|
|
|
|
|
|
$this->SetColSize( 4, 150 ); |
60
|
|
|
|
|
|
|
$this->SetColSize( 5, 100 ); |
61
|
|
|
|
|
|
|
$this->SetColSize( 6, 20 ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $row = 1; |
64
|
|
|
|
|
|
|
foreach my $er ( @editors_renderers ) { |
65
|
|
|
|
|
|
|
if( $er->[0] ) { |
66
|
|
|
|
|
|
|
eval { |
67
|
|
|
|
|
|
|
$this->SetCellEditor( $row, 2, &{$er->[2]} ) if $er->[2]; |
68
|
|
|
|
|
|
|
$this->SetCellOverflow( $row, 2, 0); |
69
|
|
|
|
|
|
|
$this->SetCellValue( $row, 1, $er->[0] ); |
70
|
|
|
|
|
|
|
$this->SetCellValue( $row, 2, $er->[1] ); |
71
|
|
|
|
|
|
|
$this->SetReadOnly( $row, 2, 0 ); |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
if( $er->[3] ) { |
75
|
|
|
|
|
|
|
eval { |
76
|
|
|
|
|
|
|
$this->SetCellRenderer( $row, 5, &{$er->[5]} ) if $er->[5]; |
77
|
|
|
|
|
|
|
$this->SetCellOverflow( $row, 5, 0); |
78
|
|
|
|
|
|
|
$this->SetCellValue( $row, 4, $er->[3] ); |
79
|
|
|
|
|
|
|
$this->SetCellValue( $row, 5, $er->[4] ); |
80
|
|
|
|
|
|
|
$this->SetReadOnly( $row, 5, 0 ); |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
$this->AutoSizeRow( $row, 1 ); |
84
|
|
|
|
|
|
|
$row += 2; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $this; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub add_to_tags { 'controls/grid' } |
91
|
|
|
|
|
|
|
sub title { 'Editors and renderers' } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |