[opendemo-cvs] CVS: opendemo/tools/odcut OdGui.pm,1.4,1.5
Status: Beta
Brought to you by:
girlich
From: Uwe G. <gi...@us...> - 2005-02-09 18:12:20
|
Update of /cvsroot/opendemo/opendemo/tools/odcut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3924 Modified Files: OdGui.pm Log Message: Implemented Cut List Up and Cut List Down Cut List Copy copies at the current position and not at the end Index: OdGui.pm =================================================================== RCS file: /cvsroot/opendemo/opendemo/tools/odcut/OdGui.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OdGui.pm 8 Feb 2005 21:13:26 -0000 1.4 --- OdGui.pm 9 Feb 2005 18:12:11 -0000 1.5 *************** *** 42,45 **** --- 42,47 ---- EVT_BUTTON($self,$self->{cutListCopy},\&OnCutListCopy); + EVT_BUTTON($self,$self->{cutListDown},\&OnCutListDown); + EVT_BUTTON($self,$self->{cutListUp},\&OnCutListUp); EVT_BUTTON($self,$self->{cutListDelete},\&OnCutListDelete); *************** *** 55,82 **** ! sub OnCutListDelete($) { ! my $self = shift; ! my $grid = $self->{gridCut}; ! my $remove = 0; ! do { ! $remove = 0; ! my @rows = $grid->GetSelectedRows(); ! foreach my $row (@rows) { ! $grid->DeleteRows($row,1,1); ! $remove++; ! # It is much to dangerous to delete more than ! # one row. ! last; ! } ! } while ($remove); } ! sub gridAddRow($@) { my $grid = shift; ! $grid->AppendRows(1, 1); ! my $row = $grid->GetNumberRows() - 1; my $col = 0; foreach my $value (@_) { --- 57,77 ---- ! sub gridGetRow($$) { ! my $grid = shift; ! my $row = shift; ! my @values = (); ! for (my $col=0;$col<$grid->GetNumberRows();$col++) { ! # printf STDERR "(%d,%d)\n", $row, $col; ! $values[$col] = $grid->GetCellValue($row,$col); ! } ! return @values; } ! sub gridSetRow($$@) { my $grid = shift; ! my $row = shift; my $col = 0; foreach my $value (@_) { *************** *** 88,91 **** --- 83,146 ---- + sub gridAddRow($@) + { + my $grid = shift; + $grid->AppendRows(1, 1); + my $row = $grid->GetNumberRows() - 1; + gridSetRow($grid,$row,@_); + } + + + sub gridInsertRow($$@) + { + my $grid = shift; + my $row = shift; + $grid->InsertRows($row, 1, 1); + gridSetRow($grid,$row,@_); + } + + + sub gridExchangeRows($$$) + { + my ($grid, $row1, $row2) = @_; + + my @copy = gridGetRow($grid,$row1); + gridSetRow($grid,$row1,gridGetRow($grid,$row2)); + gridSetRow($grid,$row2,@copy); + } + + + sub cutListExchangeRel($$) + { + my ($self,$rel) = @_; + my $grid = $self->{gridCut}; + my @rows = $grid->GetSelectedRows(); + if (@rows) { + my $row1 = $rows[0]; + my $row2 = $row1 + $rel; + if ( + $row1>=0 && $row2>=0 && + $row1<$grid->GetNumberRows() && $row2<$grid->GetNumberRows()) { + gridExchangeRows($grid,$row1,$row2); + $grid->SelectRow($row2, 0); + } + } + } + + + sub OnCutListUp($) + { + my $self = shift; + $self->cutListExchangeRel(-1); + } + + + sub OnCutListDown($) + { + my $self = shift; + $self->cutListExchangeRel(1); + } + + sub OnCutListCopy($) { *************** *** 95,109 **** if (@rows) { my $row = $rows[0]; ! gridAddRow($grid, ! ! $grid->GetCellValue($row,0), ! $grid->GetCellValue($row,1), ! $grid->GetCellValue($row,2), ! $grid->GetCellValue($row,3) ! ); } } { my $prevdir; --- 150,184 ---- if (@rows) { my $row = $rows[0]; ! gridInsertRow( ! $grid, ! $row+1, ! $grid->GetCellValue($row,0), ! $grid->GetCellValue($row,1), ! $grid->GetCellValue($row,2), ! $grid->GetCellValue($row,3) ! ); } } + sub OnCutListDelete($) + { + my $self = shift; + my $grid = $self->{gridCut}; + my $remove = 0; + do { + $remove = 0; + my @rows = $grid->GetSelectedRows(); + foreach my $row (@rows) { + $grid->DeleteRows($row,1,1); + $remove++; + # It is much to dangerous to delete more than + # one row. + last; + } + } while ($remove); + } + + { my $prevdir; *************** *** 181,188 **** my @files = getSelectedFiles($gridFiles); foreach my $filename (@files) { ! printf STDERR "selected is $filename\n"; foreach my $file ($output->get_files()) { if ($filename eq $file->name()) { ! gridAddRow($gridCut, $file->name(),0,$file->snapshotc()-1,1); } } --- 256,269 ---- my @files = getSelectedFiles($gridFiles); foreach my $filename (@files) { ! # printf STDERR "selected is $filename\n"; foreach my $file ($output->get_files()) { if ($filename eq $file->name()) { ! gridAddRow( ! $gridCut, ! $file->name(), ! 0, ! $file->snapshotc()-1, ! 1 ! ); } } |