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
|
package Demeter::UI::Athena::GroupList;
use strict;
use warnings;
use Wx qw(:everything);
use Wx::Event qw(EVT_COMBOBOX);
use base 'Wx::ComboBox';
sub new {
my ($class, $parent, $app, $exclude_self, $exclude_none) = @_;
my $this = $class->SUPER::new($parent, -1, q{None}, wxDefaultPosition, [180,-1], ['None'], wxCB_READONLY );
$this->fill($app, $exclude_self, $exclude_none);
$this->SetSelection(0);
$this->{callback} = sub{};
EVT_COMBOBOX($parent, $this, sub{&{$this->{callback}}});
return $this;
};
sub fill {
my ($self, $app, $exclude_self, $exclude_none) = @_;
return if not exists $app->{main};
return if not exists $app->{main}->{list};
return if not $app->{main}->{list}->GetCount;
$self->Clear;
$self->Append('None') if not $exclude_none;
my $current = $app->current_data;
my @groups = ();
foreach my $i (0 .. $app->{main}->{list}->GetCount-1) {
my $data = $app->{main}->{list}->GetIndexedData($i);
next if ($exclude_self and ($current->group eq $data->group));
my $index = $self->Append($data->name);
$self->SetClientData($self->GetCount-1, $data);
#print join("|", $self->GetCount-1, $data), $/;
};
};
1;
=head1 NAME
Demeter::UI::Athena::GroupList - A group selection widget
=head1 VERSION
This documentation refers to Demeter version 0.9.26.
=head1 SYNOPSIS
This module provides a group election widget based on a normal
Wx::ComboBox. This provides a C<fill> method for populating the
ComboBox with the contents of the group list. The method takes flags
for including or excluding the current group or an entry that says
"None".
=head1 DEPENDENCIES
Wx::ComboBox, obviously.
Demeter's dependencies are in the F<Build.PL> file.
=head1 BUGS AND LIMITATIONS
Please report problems to the Ifeffit Mailing List
(L<http://cars9.uchicago.edu/mailman/listinfo/ifeffit/>)
Patches are welcome.
=head1 AUTHOR
Bruce Ravel, L<http://bruceravel.github.io/home>
L<http://bruceravel.github.io/demeter/>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2006-2019 Bruce Ravel (L<http://bruceravel.github.io/home>). All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlgpl>.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=cut
|