| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################# |
|
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxListCtrl.pm |
|
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for Wx::ListCtrl |
|
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
|
5
|
|
|
|
|
|
|
## Modified by: |
|
6
|
|
|
|
|
|
|
## Created: 12/09/2001 |
|
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxListCtrl.pm 2468 2008-09-08 20:55:33Z szabgab $ |
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2001, 2003-2004, 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::wxListCtrl; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1335
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
16
|
1
|
|
|
1
|
|
606
|
use Wx::DemoModules::lib::Utility; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
58
|
|
|
17
|
1
|
|
|
1
|
|
4
|
use base qw(Wx::ListCtrl); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
541
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Wx qw(:icon wxTheApp :listctrl); |
|
20
|
|
|
|
|
|
|
use Wx::Event |
|
21
|
|
|
|
|
|
|
qw(EVT_LIST_BEGIN_DRAG EVT_LIST_BEGIN_RDRAG |
|
22
|
|
|
|
|
|
|
EVT_LIST_BEGIN_LABEL_EDIT EVT_LIST_END_LABEL_EDIT EVT_LIST_DELETE_ITEM |
|
23
|
|
|
|
|
|
|
EVT_LIST_DELETE_ALL_ITEMS |
|
24
|
|
|
|
|
|
|
EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED EVT_LIST_KEY_DOWN |
|
25
|
|
|
|
|
|
|
EVT_LIST_ITEM_ACTIVATED EVT_LIST_COL_CLICK EVT_CHAR |
|
26
|
|
|
|
|
|
|
EVT_MENU |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
|
30
|
|
|
|
|
|
|
my $class = shift; |
|
31
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
32
|
|
|
|
|
|
|
$self->create_menu; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub create_image_lists { |
|
38
|
|
|
|
|
|
|
my $images_sm = Wx::ImageList->new( 16, 16, 1 ); |
|
39
|
|
|
|
|
|
|
my $images_no = Wx::ImageList->new( 32, 32, 1 ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$images_sm->Add( Wx::GetWxPerlIcon( 1 ) ); |
|
42
|
|
|
|
|
|
|
$images_sm->Add( resize_to( wxTheApp->GetStdIcon( wxICON_EXCLAMATION ), |
|
43
|
|
|
|
|
|
|
16 ) ); |
|
44
|
|
|
|
|
|
|
$images_sm->Add( resize_to( wxTheApp->GetStdIcon( wxICON_ERROR ), 16 ) ); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$images_no->Add( Wx::GetWxPerlIcon() ); |
|
47
|
|
|
|
|
|
|
$images_no->Add( wxTheApp->GetStdIcon( wxICON_HAND ) ); |
|
48
|
|
|
|
|
|
|
$images_no->Add( wxTheApp->GetStdIcon( wxICON_EXCLAMATION ) ); |
|
49
|
|
|
|
|
|
|
$images_no->Add( wxTheApp->GetStdIcon( wxICON_ERROR ) ); |
|
50
|
|
|
|
|
|
|
$images_no->Add( wxTheApp->GetStdIcon( wxICON_QUESTION ) ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return ( $images_sm, $images_no ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub bind_events { |
|
56
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# bind events |
|
59
|
|
|
|
|
|
|
EVT_LIST_BEGIN_DRAG( $listctrl, $listctrl, \&OnBeginDrag); |
|
60
|
|
|
|
|
|
|
EVT_LIST_BEGIN_RDRAG( $listctrl, $listctrl, \&OnBeginRDrag ); |
|
61
|
|
|
|
|
|
|
EVT_LIST_BEGIN_LABEL_EDIT( $listctrl, $listctrl, \&OnBeginLabelEdit ); |
|
62
|
|
|
|
|
|
|
EVT_LIST_END_LABEL_EDIT( $listctrl, $listctrl, \&OnEndLabelEdit ); |
|
63
|
|
|
|
|
|
|
EVT_LIST_DELETE_ITEM( $listctrl, $listctrl, \&OnDeleteItem ); |
|
64
|
|
|
|
|
|
|
EVT_LIST_DELETE_ALL_ITEMS( $listctrl, $listctrl, \&OnDeleteAllItems ); |
|
65
|
|
|
|
|
|
|
EVT_LIST_ITEM_SELECTED( $listctrl, $listctrl, \&OnSelected ); |
|
66
|
|
|
|
|
|
|
EVT_LIST_ITEM_DESELECTED( $listctrl, $listctrl, \&OnDeselected ); |
|
67
|
|
|
|
|
|
|
EVT_LIST_KEY_DOWN( $listctrl, $listctrl, \&OnListKeyDown ); |
|
68
|
|
|
|
|
|
|
EVT_LIST_ITEM_ACTIVATED( $listctrl, $listctrl, \&OnActivated ); |
|
69
|
|
|
|
|
|
|
EVT_LIST_COL_CLICK( $listctrl, $listctrl, \&OnColClick ); |
|
70
|
|
|
|
|
|
|
EVT_CHAR( $listctrl, \&OnChar ); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub create_menu { |
|
74
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $top = Wx::GetTopLevelParent( $listctrl ); |
|
77
|
|
|
|
|
|
|
my $menu = Wx::Menu->new; |
|
78
|
|
|
|
|
|
|
EVT_MENU( $top, $menu->Append( -1, "Toggle first selection" ), |
|
79
|
|
|
|
|
|
|
sub { $listctrl->on_toggle_first } ); |
|
80
|
|
|
|
|
|
|
EVT_MENU( $top, $menu->Append( -1, "Deselect all" ), |
|
81
|
|
|
|
|
|
|
sub { $listctrl->on_deselect_all } ); |
|
82
|
|
|
|
|
|
|
EVT_MENU( $top, $menu->Append( -1, "Select all" ), |
|
83
|
|
|
|
|
|
|
sub { $listctrl->on_select_all } ); |
|
84
|
|
|
|
|
|
|
$menu->AppendSeparator; |
|
85
|
|
|
|
|
|
|
EVT_MENU( $top, $menu->Append( -1, "Sort" ), |
|
86
|
|
|
|
|
|
|
sub { $listctrl->on_sort } ); |
|
87
|
|
|
|
|
|
|
$menu->AppendSeparator; |
|
88
|
|
|
|
|
|
|
EVT_MENU( $top, $menu->Append( -1, "Delete all items" ), |
|
89
|
|
|
|
|
|
|
sub { $listctrl->on_delete_all } ); |
|
90
|
|
|
|
|
|
|
$listctrl->{menu} = [ '&List Control', $menu ]; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub menu { @{$_[0]->{menu}} } |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub on_toggle_first { |
|
98
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $state = $listctrl->GetItemState( 0, wxLIST_STATE_SELECTED ); |
|
101
|
|
|
|
|
|
|
my $newState = $state ? 0 : wxLIST_STATE_SELECTED; |
|
102
|
|
|
|
|
|
|
$listctrl->SetItemState( 0, $newState, wxLIST_STATE_SELECTED ); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub on_deselect_all { |
|
106
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
foreach ( 0 .. $listctrl->GetItemCount - 1 ) { |
|
109
|
|
|
|
|
|
|
$listctrl->SetItemState( $_, 0, wxLIST_STATE_SELECTED ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub on_select_all { |
|
114
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
foreach ( 0 .. $listctrl->GetItemCount - 1 ) { |
|
117
|
|
|
|
|
|
|
$listctrl->SetItemState( $_, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $sort_order = 'asc'; |
|
122
|
|
|
|
|
|
|
sub on_sort { |
|
123
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
if( $sort_order eq 'asc' ) { |
|
126
|
|
|
|
|
|
|
$sort_order = 'desc'; |
|
127
|
|
|
|
|
|
|
$listctrl->SortItems( sub { $_[0] < $_[1] } ); |
|
128
|
|
|
|
|
|
|
} else { |
|
129
|
|
|
|
|
|
|
$sort_order = 'asc'; |
|
130
|
|
|
|
|
|
|
$listctrl->SortItems( sub { $_[1] < $_[0] } ); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub on_delete_all { |
|
135
|
|
|
|
|
|
|
my( $listctrl ) = @_; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$listctrl->DeleteAllItems; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub OnColClick { |
|
141
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Wx::LogMessage( "OnClumnClick at %d.", $event->GetColumn ); |
|
144
|
|
|
|
|
|
|
$event->Skip; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub OnBeginDrag { |
|
148
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Wx::LogMessage( "OnBeginDrag ad ( %d, %d ).", |
|
151
|
|
|
|
|
|
|
$event->GetPoint->x, $event->GetPoint->y ); |
|
152
|
|
|
|
|
|
|
$event->Skip; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub OnBeginRDrag { |
|
156
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Wx::LogMessage( "OnBeginRDrag ad ( %d, %d ).", |
|
159
|
|
|
|
|
|
|
$event->GetPoint->x, $event->GetPoint->y ); |
|
160
|
|
|
|
|
|
|
$event->Skip; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub OnBeginLabelEdit { |
|
164
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Wx::LogMessage( "OnBeginLabelEdit: %s", |
|
167
|
|
|
|
|
|
|
$event->GetItem->GetText ); |
|
168
|
|
|
|
|
|
|
$event->Skip; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub OnEndLabelEdit { |
|
172
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Wx::LogMessage( "OnBeginLabelEdit: %s", |
|
175
|
|
|
|
|
|
|
$event->GetItem->GetText ); |
|
176
|
|
|
|
|
|
|
$event->Skip; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub OnDeleteItem { |
|
180
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnDeleteItem" ); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub OnDeleteAllItems { |
|
186
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnDeleteAllItems" ); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub OnSelected { |
|
192
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnSelected" ); |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub OnDeselected { |
|
198
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnDeselected" ); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub OnActivated { |
|
204
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnActivated" ); |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub OnListKeyDown { |
|
210
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
LogEvent( $listctrl, $event, "OnListKeyDown" ); |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub OnChar { |
|
216
|
|
|
|
|
|
|
my( $listctrl, $event ) = @_; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Wx::LogMessage( "OnChar" ); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub LogEvent { |
|
222
|
|
|
|
|
|
|
my( $listctrl, $event, $name ) = @_; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Wx::LogMessage( "Item %d: %s ( item text = %s, data = %d )", |
|
225
|
|
|
|
|
|
|
$event->GetIndex(), $name, |
|
226
|
|
|
|
|
|
|
$event->GetText(), $event->GetData() ); |
|
227
|
|
|
|
|
|
|
$event->Skip; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub tags { [ 'controls/listctrl', 'wxListCtrl' ] } |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
package Wx::DemoModules::wxListCtrl::Report; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
use strict; |
|
235
|
|
|
|
|
|
|
use base qw(Wx::ListView Wx::DemoModules::wxListCtrl); |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
use Wx qw(:listctrl wxDefaultPosition wxDefaultSize); |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub new { |
|
240
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
241
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, |
|
242
|
|
|
|
|
|
|
wxDefaultSize, wxLC_REPORT ); |
|
243
|
|
|
|
|
|
|
$self->bind_events; |
|
244
|
|
|
|
|
|
|
$self->create_menu; |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
my @names = ( "Cheese", "Apples", "Oranges" ); |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my( $small, $normal ) = $self->create_image_lists; |
|
249
|
|
|
|
|
|
|
$self->AssignImageList( $small, wxIMAGE_LIST_SMALL ); |
|
250
|
|
|
|
|
|
|
$self->AssignImageList( $normal, wxIMAGE_LIST_NORMAL ); |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
$self->InsertColumn( 0, "Type" ); |
|
253
|
|
|
|
|
|
|
$self->InsertColumn( 1, "Amount" ); |
|
254
|
|
|
|
|
|
|
$self->InsertColumn( 2, "Price" ); |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
foreach my $i ( 0 .. 50 ) { |
|
257
|
|
|
|
|
|
|
my $t = ( rand() * 100 ) % 3; |
|
258
|
|
|
|
|
|
|
my $q = int( rand() * 100 ); |
|
259
|
|
|
|
|
|
|
my $idx = $self->InsertImageStringItem( $i, $names[$t], 0 ); |
|
260
|
|
|
|
|
|
|
$self->SetItemData( $idx, $i ); |
|
261
|
|
|
|
|
|
|
$self->SetItem( $idx, 1, $q ); |
|
262
|
|
|
|
|
|
|
$self->SetItem( $idx, 2, $q * ( $t + 1 ) ); |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
return $self; |
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/listctrl) } |
|
269
|
|
|
|
|
|
|
sub title { 'Report' } |
|
270
|
|
|
|
|
|
|
sub file { __FILE__ } |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
package Wx::DemoModules::wxListCtrl::Virtual; |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
use strict; |
|
275
|
|
|
|
|
|
|
use base qw(Wx::ListCtrl Wx::DemoModules::wxListCtrl); |
|
276
|
|
|
|
|
|
|
use Wx qw(:listctrl wxRED wxBLUE wxITALIC_FONT |
|
277
|
|
|
|
|
|
|
wxDefaultPosition wxDefaultSize); |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub new { |
|
280
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
281
|
|
|
|
|
|
|
my $self = $class->SUPER::new |
|
282
|
|
|
|
|
|
|
( $parent, -1, wxDefaultPosition, wxDefaultSize, |
|
283
|
|
|
|
|
|
|
wxLC_REPORT | wxLC_VIRTUAL ); |
|
284
|
|
|
|
|
|
|
$self->bind_events; |
|
285
|
|
|
|
|
|
|
$self->create_menu; |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
my( $small, $normal ) = $self->create_image_lists; |
|
288
|
|
|
|
|
|
|
$self->AssignImageList( $small, wxIMAGE_LIST_SMALL ); |
|
289
|
|
|
|
|
|
|
$self->AssignImageList( $normal, wxIMAGE_LIST_NORMAL ); |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
$self->InsertColumn( 0, "Column 1" ); |
|
292
|
|
|
|
|
|
|
$self->InsertColumn( 1, "Column 2" ); |
|
293
|
|
|
|
|
|
|
$self->InsertColumn( 2, "Column 3" ); |
|
294
|
|
|
|
|
|
|
$self->InsertColumn( 3, "Column 4" ); |
|
295
|
|
|
|
|
|
|
$self->InsertColumn( 4, "Column 5" ); |
|
296
|
|
|
|
|
|
|
$self->SetItemCount( 100000 ); |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
return $self; |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub OnGetItemText { |
|
302
|
|
|
|
|
|
|
my( $self, $item, $column ) = @_; |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
return "( $item, $column )"; |
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub OnGetItemAttr { |
|
308
|
|
|
|
|
|
|
my( $self, $item ) = @_; |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
my $attr = Wx::ListItemAttr->new; |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
if( $item % 2 == 0 ) { $attr->SetTextColour( wxRED ) } |
|
313
|
|
|
|
|
|
|
if( $item % 3 == 0 ) { $attr->SetBackgroundColour( wxBLUE ) } |
|
314
|
|
|
|
|
|
|
if( $item % 5 == 0 ) { $attr->SetFont( wxITALIC_FONT ) } |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
return $attr; |
|
317
|
|
|
|
|
|
|
} |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub OnGetItemImage { |
|
320
|
|
|
|
|
|
|
my( $self, $item ) = @_; |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
return 0; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub OnGetItemColumnImage { |
|
326
|
|
|
|
|
|
|
my( $self, $item, $column ) = @_; |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
return $column % 3; |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/listctrl) } |
|
332
|
|
|
|
|
|
|
sub title { 'Virtual' } |
|
333
|
|
|
|
|
|
|
sub file { __FILE__ } |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
package Wx::DemoModules::wxListCtrl::List; |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
use strict; |
|
338
|
|
|
|
|
|
|
use base qw(Wx::ListView Wx::DemoModules::wxListCtrl); |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
use Wx qw(:listctrl wxDefaultPosition wxDefaultSize); |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
sub new { |
|
343
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
344
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, |
|
345
|
|
|
|
|
|
|
wxDefaultSize, wxLC_LIST ); |
|
346
|
|
|
|
|
|
|
$self->bind_events; |
|
347
|
|
|
|
|
|
|
$self->create_menu; |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
foreach my $i ( 0 .. 40 ) { |
|
350
|
|
|
|
|
|
|
my $idx = $self->InsertStringItem( $i, "Item $i" ); |
|
351
|
|
|
|
|
|
|
$self->SetItemData( $idx, $i ); |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
return $self; |
|
355
|
|
|
|
|
|
|
} |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/listctrl) } |
|
358
|
|
|
|
|
|
|
sub title { 'Text' } |
|
359
|
|
|
|
|
|
|
sub file { __FILE__ } |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
package Wx::DemoModules::wxListCtrl::Icon; |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
use strict; |
|
364
|
|
|
|
|
|
|
use base qw(Wx::ListView Wx::DemoModules::wxListCtrl); |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
use Wx qw(:listctrl wxDefaultPosition wxDefaultSize); |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub new { |
|
369
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
370
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, |
|
371
|
|
|
|
|
|
|
wxDefaultSize, wxLC_ICON ); |
|
372
|
|
|
|
|
|
|
$self->bind_events; |
|
373
|
|
|
|
|
|
|
$self->create_menu; |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
my( $small, $normal ) = $self->create_image_lists; |
|
376
|
|
|
|
|
|
|
$self->AssignImageList( $small, wxIMAGE_LIST_SMALL ); |
|
377
|
|
|
|
|
|
|
$self->AssignImageList( $normal, wxIMAGE_LIST_NORMAL ); |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
foreach my $i ( 0 .. 7 ) { |
|
380
|
|
|
|
|
|
|
my $idx = $self->InsertImageItem( $i, $i % 5 ); |
|
381
|
|
|
|
|
|
|
$self->SetItemData( $idx, $i ); |
|
382
|
|
|
|
|
|
|
} |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
return $self; |
|
385
|
|
|
|
|
|
|
} |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/listctrl) } |
|
388
|
|
|
|
|
|
|
sub title { 'Icon' } |
|
389
|
|
|
|
|
|
|
sub file { __FILE__ } |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
package Wx::DemoModules::wxListCtrl::IconText; |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
use strict; |
|
394
|
|
|
|
|
|
|
use base qw(Wx::ListView Wx::DemoModules::wxListCtrl); |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
use Wx qw(:listctrl wxDefaultPosition wxDefaultSize); |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub new { |
|
399
|
|
|
|
|
|
|
my( $class, $parent ) = @_; |
|
400
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, |
|
401
|
|
|
|
|
|
|
wxDefaultSize, wxLC_ICON ); |
|
402
|
|
|
|
|
|
|
$self->bind_events; |
|
403
|
|
|
|
|
|
|
$self->create_menu; |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
my( $small, $normal ) = $self->create_image_lists; |
|
406
|
|
|
|
|
|
|
$self->AssignImageList( $small, wxIMAGE_LIST_SMALL ); |
|
407
|
|
|
|
|
|
|
$self->AssignImageList( $normal, wxIMAGE_LIST_NORMAL ); |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
foreach my $i ( 0 .. 7 ) { |
|
410
|
|
|
|
|
|
|
my $idx = $self->InsertStringImageItem( $i, "Item $i", $i % 5 ); |
|
411
|
|
|
|
|
|
|
$self->SetItemData( $idx, $i ); |
|
412
|
|
|
|
|
|
|
} |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
return $self; |
|
415
|
|
|
|
|
|
|
} |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
sub add_to_tags { qw(controls/listctrl) } |
|
418
|
|
|
|
|
|
|
sub title { 'Icon and Text' } |
|
419
|
|
|
|
|
|
|
sub file { __FILE__ } |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
1; |