| 1 |
package Tk::HList; |
| 2 |
|
| 3 |
use vars qw($VERSION); |
| 4 |
$VERSION = '4.015'; # was: sprintf '4.%03d', q$Revision: #14 $ =~ /\D(\d+)\s*$/; |
| 5 |
|
| 6 |
use Tk qw(Ev $XS_VERSION); |
| 7 |
|
| 8 |
use base qw(Tk::Widget); |
| 9 |
|
| 10 |
Construct Tk::Widget 'HList'; |
| 11 |
sub Tk::Widget::ScrlHList { shift->Scrolled('HList'=>@_) } |
| 12 |
|
| 13 |
bootstrap Tk::HList; |
| 14 |
|
| 15 |
sub Tk_cmd { \&Tk::hlist } |
| 16 |
|
| 17 |
sub CreateArgs |
| 18 |
{ |
| 19 |
my ($package,$parent,$args) = @_; |
| 20 |
my @result = $package->SUPER::CreateArgs($parent,$args); |
| 21 |
my $columns = delete $args->{-columns}; |
| 22 |
push(@result, '-columns' => $columns) if (defined $columns); |
| 23 |
return @result; |
| 24 |
} |
| 25 |
|
| 26 |
Tk::Methods qw(add addchild anchor column |
| 27 |
delete dragsite dropsite entrycget |
| 28 |
entryconfigure geometryinfo indicator header hide item info |
| 29 |
nearest see select selection show xview yview); |
| 30 |
|
| 31 |
use Tk::Submethods ( 'delete' => [qw(all entry offsprings siblings)], |
| 32 |
'header' => [qw(configure cget create delete exists size)], |
| 33 |
'indicator' => [qw(configure cget create delete exists size)], |
| 34 |
'info' => [qw(anchor bbox children data dragsite |
| 35 |
dropsite exists hidden item next parent prev |
| 36 |
selection)], |
| 37 |
'item' => [qw(configure cget create delete exists)], |
| 38 |
'selection' => [qw(clear get includes set)], |
| 39 |
'anchor' => [qw(clear set)], |
| 40 |
'column' => [qw(width)], |
| 41 |
); |
| 42 |
|
| 43 |
# This is undocumented, but worked until 804.027: |
| 44 |
sub hideEntry { shift->hide('entry', @_) } |
| 45 |
|
| 46 |
sub ClassInit |
| 47 |
{ |
| 48 |
my ($class,$mw) = @_; |
| 49 |
|
| 50 |
$mw->bind($class,'<ButtonPress-1>',[ 'Button1' ] ); |
| 51 |
$mw->bind($class,'<Shift-ButtonPress-1>',[ 'ShiftButton1' ] ); |
| 52 |
$mw->bind($class,'<Control-ButtonRelease-1>','Control_ButtonRelease_1'); |
| 53 |
$mw->bind($class,'<ButtonRelease-1>','ButtonRelease_1'); |
| 54 |
$mw->bind($class,'<Double-ButtonRelease-1>','NoOp'); |
| 55 |
$mw->bind($class,'<B1-Motion>',[ 'Button1Motion' ] ); |
| 56 |
$mw->bind($class,'<B1-Leave>',[ 'AutoScan' ] ); |
| 57 |
|
| 58 |
$mw->bind($class,'<Double-ButtonPress-1>',['Double1']); |
| 59 |
|
| 60 |
$mw->bind($class,'<Control-B1-Motion>','Control_B1_Motion'); |
| 61 |
$mw->bind($class,'<Control-ButtonPress-1>',['CtrlButton1']); |
| 62 |
$mw->bind($class,'<Control-Double-ButtonPress-1>',['CtrlButton1']); |
| 63 |
|
| 64 |
$mw->bind($class,'<B1-Enter>','B1_Enter'); |
| 65 |
|
| 66 |
$mw->bind($class,'<Up>',['UpDown', 'prev']); |
| 67 |
$mw->bind($class,'<Down>',['UpDown', 'next']); |
| 68 |
|
| 69 |
$mw->bind($class,'<Shift-Up>',['ShiftUpDown', 'prev']); |
| 70 |
$mw->bind($class,'<Shift-Down>',['ShiftUpDown', 'next']); |
| 71 |
|
| 72 |
$mw->bind($class,'<Left>', ['LeftRight', 'left']); |
| 73 |
$mw->bind($class,'<Right>',['LeftRight', 'right']); |
| 74 |
|
| 75 |
$mw->PriorNextBind($class); |
| 76 |
$mw->MouseWheelBind($class); |
| 77 |
|
| 78 |
$mw->bind($class,'<Return>', ['KeyboardActivate']); |
| 79 |
$mw->bind($class,'<space>', ['KeyboardBrowse']); |
| 80 |
$mw->bind($class,'<Home>', ['KeyboardHome']); |
| 81 |
$mw->bind($class,'<End>', ['KeyboardEnd']); |
| 82 |
|
| 83 |
$mw->YMouseWheelBind($class); |
| 84 |
$mw->XMouseWheelBind($class); |
| 85 |
|
| 86 |
return $class; |
| 87 |
} |
| 88 |
|
| 89 |
sub Control_ButtonRelease_1 |
| 90 |
{ |
| 91 |
} |
| 92 |
|
| 93 |
sub ButtonRelease_1 |
| 94 |
{ |
| 95 |
my $w = shift; |
| 96 |
my $Ev = $w->XEvent; |
| 97 |
$w->CancelRepeat |
| 98 |
if($w->cget('-selectmode') ne 'dragdrop'); |
| 99 |
$w->ButtonRelease1($Ev); |
| 100 |
} |
| 101 |
|
| 102 |
sub Control_B1_Motion |
| 103 |
{ |
| 104 |
} |
| 105 |
|
| 106 |
sub B1_Enter |
| 107 |
{ |
| 108 |
my $w = shift; |
| 109 |
my $Ev = $w->XEvent; |
| 110 |
$w->CancelRepeat |
| 111 |
if($w->cget('-selectmode') ne 'dragdrop'); |
| 112 |
} |
| 113 |
|
| 114 |
sub Button1 |
| 115 |
{ |
| 116 |
my $w = shift; |
| 117 |
my $Ev = $w->XEvent; |
| 118 |
|
| 119 |
delete $w->{'shiftanchor'}; |
| 120 |
delete $w->{tixindicator}; |
| 121 |
|
| 122 |
$w->focus() if($w->cget('-takefocus')); |
| 123 |
|
| 124 |
my $mode = $w->cget('-selectmode'); |
| 125 |
|
| 126 |
if ($mode eq 'dragdrop') |
| 127 |
{ |
| 128 |
# $w->Send_WaitDrag($Ev->y); |
| 129 |
return; |
| 130 |
} |
| 131 |
|
| 132 |
my $ent = $w->GetNearest($Ev->y, 1); |
| 133 |
|
| 134 |
if (!defined($ent) || !length($ent)) |
| 135 |
{ |
| 136 |
$w->selectionClear; |
| 137 |
$w->anchorClear; |
| 138 |
return; |
| 139 |
} |
| 140 |
|
| 141 |
my @info = $w->info('item',$Ev->x, $Ev->y); |
| 142 |
if (@info) |
| 143 |
{ |
| 144 |
die 'Assert' unless $info[0] eq $ent; |
| 145 |
} |
| 146 |
else |
| 147 |
{ |
| 148 |
@info = $ent; |
| 149 |
} |
| 150 |
|
| 151 |
if (defined($info[1]) && $info[1] eq 'indicator') |
| 152 |
{ |
| 153 |
$w->{tixindicator} = $ent; |
| 154 |
$w->Callback(-indicatorcmd => $ent, '<Arm>'); |
| 155 |
} |
| 156 |
else |
| 157 |
{ |
| 158 |
my $browse = 0; |
| 159 |
|
| 160 |
if ($mode eq 'single') |
| 161 |
{ |
| 162 |
$w->anchorSet($ent); |
| 163 |
} |
| 164 |
elsif ($mode eq 'browse') |
| 165 |
{ |
| 166 |
$w->anchorSet($ent); |
| 167 |
$w->selectionClear; |
| 168 |
$w->selectionSet($ent); |
| 169 |
$browse = 1; |
| 170 |
} |
| 171 |
elsif ($mode eq 'multiple') |
| 172 |
{ |
| 173 |
$w->selectionClear; |
| 174 |
$w->anchorSet($ent); |
| 175 |
$w->selectionSet($ent); |
| 176 |
$browse = 1; |
| 177 |
} |
| 178 |
elsif ($mode eq 'extended') |
| 179 |
{ |
| 180 |
$w->anchorSet($ent); |
| 181 |
$w->selectionClear; |
| 182 |
$w->selectionSet($ent); |
| 183 |
$browse = 1; |
| 184 |
} |
| 185 |
|
| 186 |
if ($browse) |
| 187 |
{ |
| 188 |
$w->Callback(-browsecmd => @info); |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
sub ShiftButton1 |
| 194 |
{ |
| 195 |
my $w = shift; |
| 196 |
my $Ev = $w->XEvent; |
| 197 |
|
| 198 |
my $to = $w->GetNearest($Ev->y, 1); |
| 199 |
|
| 200 |
delete $w->{'shiftanchor'}; |
| 201 |
delete $w->{tixindicator}; |
| 202 |
|
| 203 |
return unless (defined($to) and length($to)); |
| 204 |
|
| 205 |
my $mode = $w->cget('-selectmode'); |
| 206 |
|
| 207 |
if($mode eq 'extended' or $mode eq 'multiple') |
| 208 |
{ |
| 209 |
my $from = $w->info('anchor'); |
| 210 |
if(defined $from) |
| 211 |
{ |
| 212 |
$w->selectionClear; |
| 213 |
$w->selectionSet($from, $to); |
| 214 |
} |
| 215 |
else |
| 216 |
{ |
| 217 |
$w->anchorSet($to); |
| 218 |
$w->selectionClear; |
| 219 |
$w->selectionSet($to); |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
sub GetNearest |
| 225 |
{ |
| 226 |
my ($w,$y,$undefafterend) = @_; |
| 227 |
my $ent = $w->nearest($y); |
| 228 |
if (defined $ent) |
| 229 |
{ |
| 230 |
if ($undefafterend) |
| 231 |
{ |
| 232 |
my $borderwidth = $w->cget('-borderwidth'); |
| 233 |
my $highlightthickness = $w->cget('-highlightthickness'); |
| 234 |
my $bottomy = ($w->infoBbox($ent))[3]; |
| 235 |
$bottomy += $borderwidth + $highlightthickness; |
| 236 |
if ($w->header('exist', 0)) |
| 237 |
{ |
| 238 |
$bottomy += $w->header('height'); |
| 239 |
} |
| 240 |
if ($y > $bottomy) |
| 241 |
{ |
| 242 |
#print "$y > $bottomy\n"; |
| 243 |
return undef; |
| 244 |
} |
| 245 |
} |
| 246 |
my $state = $w->entrycget($ent, '-state'); |
| 247 |
return $ent if (!defined($state) || $state ne 'disabled'); |
| 248 |
} |
| 249 |
return undef; |
| 250 |
} |
| 251 |
|
| 252 |
sub ButtonRelease1 |
| 253 |
{ |
| 254 |
my ($w, $Ev) = @_; |
| 255 |
|
| 256 |
delete $w->{'shiftanchor'}; |
| 257 |
|
| 258 |
my $mode = $w->cget('-selectmode'); |
| 259 |
|
| 260 |
if($mode eq 'dragdrop') |
| 261 |
{ |
| 262 |
# $w->Send_DoneDrag(); |
| 263 |
return; |
| 264 |
} |
| 265 |
|
| 266 |
my ($x, $y) = ($Ev->x, $Ev->y); |
| 267 |
my $ent = $w->GetNearest($y, 1); |
| 268 |
|
| 269 |
if (!defined($ent) and $mode eq 'single') |
| 270 |
{ |
| 271 |
my $ent = $w->info('selection'); |
| 272 |
if (defined $ent) |
| 273 |
{ |
| 274 |
$w->anchorSet($ent); |
| 275 |
} |
| 276 |
} |
| 277 |
return unless (defined($ent) and length($ent)); |
| 278 |
|
| 279 |
if (exists $w->{tixindicator}) |
| 280 |
{ |
| 281 |
return unless delete($w->{tixindicator}) eq $ent; |
| 282 |
my @info = $w->info('item',$Ev->x, $Ev->y); |
| 283 |
if(defined($info[1]) && $info[1] eq 'indicator') |
| 284 |
{ |
| 285 |
$w->Callback(-indicatorcmd => $ent, '<Activate>'); |
| 286 |
} |
| 287 |
else |
| 288 |
{ |
| 289 |
$w->Callback(-indicatorcmd => $ent, '<Disarm>'); |
| 290 |
} |
| 291 |
return; |
| 292 |
} |
| 293 |
|
| 294 |
if($mode eq 'single' || $mode eq 'browse') |
| 295 |
{ |
| 296 |
$w->anchorSet($ent); |
| 297 |
$w->selectionClear; |
| 298 |
$w->selectionSet($ent); |
| 299 |
|
| 300 |
} |
| 301 |
elsif($mode eq 'multiple') |
| 302 |
{ |
| 303 |
$w->selectionSet($ent); |
| 304 |
} |
| 305 |
elsif($mode eq 'extended') |
| 306 |
{ |
| 307 |
$w->selectionSet($ent); |
| 308 |
} |
| 309 |
|
| 310 |
$w->Callback(-browsecmd =>$ent); |
| 311 |
} |
| 312 |
|
| 313 |
sub Button1Motion |
| 314 |
{ |
| 315 |
my $w = shift; |
| 316 |
my $Ev = $w->XEvent; |
| 317 |
return unless defined $Ev; |
| 318 |
|
| 319 |
delete $w->{'shiftanchor'}; |
| 320 |
|
| 321 |
my $mode = $w->cget('-selectmode'); |
| 322 |
|
| 323 |
if ($mode eq 'dragdrop') |
| 324 |
{ |
| 325 |
# $w->Send_StartDrag(); |
| 326 |
return; |
| 327 |
} |
| 328 |
|
| 329 |
my $ent; |
| 330 |
if (defined $w->info('anchor')) |
| 331 |
{ |
| 332 |
$ent = $w->GetNearest($Ev->y); |
| 333 |
} |
| 334 |
else |
| 335 |
{ |
| 336 |
$ent = $w->GetNearest($Ev->y, 1); |
| 337 |
} |
| 338 |
return unless (defined($ent) and length($ent)); |
| 339 |
|
| 340 |
if(exists $w->{tixindicator}) |
| 341 |
{ |
| 342 |
my $event_type = $w->{tixindicator} eq $ent ? '<Arm>' : '<Disarm>'; |
| 343 |
$w->Callback(-indicatorcmd => $w->{tixindicator}, $event_type ); |
| 344 |
return; |
| 345 |
} |
| 346 |
|
| 347 |
if ($mode eq 'single') |
| 348 |
{ |
| 349 |
$w->anchorSet($ent); |
| 350 |
} |
| 351 |
elsif ($mode eq 'multiple' || $mode eq 'extended') |
| 352 |
{ |
| 353 |
my $from = $w->info('anchor'); |
| 354 |
if(defined $from) |
| 355 |
{ |
| 356 |
$w->selectionClear; |
| 357 |
$w->selectionSet($from, $ent); |
| 358 |
} |
| 359 |
else |
| 360 |
{ |
| 361 |
$w->anchorSet($ent); |
| 362 |
$w->selectionClear; |
| 363 |
$w->selectionSet($ent); |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
if ($mode ne 'single') |
| 368 |
{ |
| 369 |
$w->Callback(-browsecmd =>$ent); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
sub Double1 |
| 374 |
{ |
| 375 |
my $w = shift; |
| 376 |
my $Ev = $w->XEvent; |
| 377 |
|
| 378 |
delete $w->{'shiftanchor'}; |
| 379 |
|
| 380 |
my $ent = $w->GetNearest($Ev->y, 1); |
| 381 |
|
| 382 |
return unless (defined($ent) and length($ent)); |
| 383 |
|
| 384 |
$w->anchorSet($ent) |
| 385 |
unless(defined $w->info('anchor')); |
| 386 |
|
| 387 |
$w->selectionSet($ent); |
| 388 |
|
| 389 |
$w->Callback(-command => $ent); |
| 390 |
} |
| 391 |
|
| 392 |
sub CtrlButton1 |
| 393 |
{ |
| 394 |
my $w = shift; |
| 395 |
my $Ev = $w->XEvent; |
| 396 |
|
| 397 |
delete $w->{'shiftanchor'}; |
| 398 |
|
| 399 |
my $ent = $w->GetNearest($Ev->y, 1); |
| 400 |
|
| 401 |
return unless (defined($ent) and length($ent)); |
| 402 |
|
| 403 |
my $mode = $w->cget('-selectmode'); |
| 404 |
|
| 405 |
if($mode eq 'extended') |
| 406 |
{ |
| 407 |
$w->anchorSet($ent) unless( defined $w->info('anchor') ); |
| 408 |
|
| 409 |
if($w->select('includes', $ent)) |
| 410 |
{ |
| 411 |
$w->select('clear', $ent); |
| 412 |
} |
| 413 |
else |
| 414 |
{ |
| 415 |
$w->selectionSet($ent); |
| 416 |
} |
| 417 |
$w->Callback(-browsecmd =>$ent); |
| 418 |
} |
| 419 |
} |
| 420 |
|
| 421 |
sub UpDown |
| 422 |
{ |
| 423 |
my $w = shift; |
| 424 |
my $spec = shift; |
| 425 |
|
| 426 |
my $done = 0; |
| 427 |
my $anchor = $w->info('anchor'); |
| 428 |
|
| 429 |
delete $w->{'shiftanchor'}; |
| 430 |
|
| 431 |
unless( defined $anchor ) |
| 432 |
{ |
| 433 |
$anchor = ($w->info('children'))[0]; |
| 434 |
|
| 435 |
return unless (defined($anchor) and length($anchor)); |
| 436 |
|
| 437 |
if($w->entrycget($anchor, '-state') ne 'disabled') |
| 438 |
{ |
| 439 |
# That's a good anchor |
| 440 |
$done = 1; |
| 441 |
} |
| 442 |
else |
| 443 |
{ |
| 444 |
# We search for the first non-disabled entry (downward) |
| 445 |
$spec = 'next'; |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
my $ent = $anchor; |
| 450 |
|
| 451 |
# Find the prev/next non-disabled entry |
| 452 |
# |
| 453 |
while(!$done) |
| 454 |
{ |
| 455 |
$ent = $w->info($spec, $ent); |
| 456 |
last unless( defined $ent ); |
| 457 |
next if( $w->entrycget($ent, '-state') eq 'disabled' ); |
| 458 |
next if( $w->info('hidden', $ent) ); |
| 459 |
last; |
| 460 |
} |
| 461 |
|
| 462 |
unless( defined $ent ) |
| 463 |
{ |
| 464 |
$w->yview('scroll', $spec eq 'prev' ? -1 : 1, 'unit'); |
| 465 |
return; |
| 466 |
} |
| 467 |
|
| 468 |
$w->anchorSet($ent); |
| 469 |
$w->see($ent); |
| 470 |
|
| 471 |
if($w->cget('-selectmode') ne 'single') |
| 472 |
{ |
| 473 |
$w->selectionClear; |
| 474 |
$w->selection('set', $ent); |
| 475 |
$w->Callback(-browsecmd =>$ent); |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
sub ShiftUpDown |
| 480 |
{ |
| 481 |
my $w = shift; |
| 482 |
my $spec = shift; |
| 483 |
|
| 484 |
my $mode = $w->cget('-selectmode'); |
| 485 |
|
| 486 |
return $w->UpDown($spec) |
| 487 |
if($mode eq 'single' || $mode eq 'browse'); |
| 488 |
|
| 489 |
my $anchor = $w->info('anchor'); |
| 490 |
|
| 491 |
return $w->UpDown($spec) unless (defined($anchor) and length($anchor)); |
| 492 |
|
| 493 |
my $done = 0; |
| 494 |
|
| 495 |
$w->{'shiftanchor'} = $anchor unless( $w->{'shiftanchor'} ); |
| 496 |
|
| 497 |
my $ent = $w->{'shiftanchor'}; |
| 498 |
|
| 499 |
while( !$done ) |
| 500 |
{ |
| 501 |
$ent = $w->info($spec, $ent); |
| 502 |
last unless( defined $ent ); |
| 503 |
next if( $w->entrycget($ent, '-state') eq 'disabled' ); |
| 504 |
next if( $w->info('hidden', $ent) ); |
| 505 |
last; |
| 506 |
} |
| 507 |
|
| 508 |
unless( $ent ) |
| 509 |
{ |
| 510 |
$w->yview('scroll', $spec eq 'prev' ? -1 : 1, 'unit'); |
| 511 |
return; |
| 512 |
} |
| 513 |
|
| 514 |
$w->selectionClear; |
| 515 |
$w->selection('set', $anchor, $ent); |
| 516 |
$w->see($ent); |
| 517 |
|
| 518 |
$w->{'shiftanchor'} = $ent; |
| 519 |
|
| 520 |
$w->Callback(-browsecmd =>$ent); |
| 521 |
} |
| 522 |
|
| 523 |
sub LeftRight |
| 524 |
{ |
| 525 |
my $w = shift; |
| 526 |
my $spec = shift; |
| 527 |
|
| 528 |
delete $w->{'shiftanchor'}; |
| 529 |
|
| 530 |
my $anchor = $w->info('anchor'); |
| 531 |
|
| 532 |
unless(defined $anchor) |
| 533 |
{ |
| 534 |
$anchor = ($w->info('children'))[0] |
| 535 |
} |
| 536 |
unless(defined $anchor) |
| 537 |
{ |
| 538 |
$anchor = ''; |
| 539 |
} |
| 540 |
|
| 541 |
my $done = 0; |
| 542 |
my $ent = $anchor; |
| 543 |
|
| 544 |
while(!$done) |
| 545 |
{ |
| 546 |
my $e = $ent; |
| 547 |
|
| 548 |
if($spec eq 'left') |
| 549 |
{ |
| 550 |
$ent = $w->info('parent', $e); |
| 551 |
|
| 552 |
$ent = $w->info('prev', $e) |
| 553 |
unless(defined $ent && $w->entrycget($ent, '-state') ne 'disabled') |
| 554 |
} |
| 555 |
else |
| 556 |
{ |
| 557 |
$ent = ($w->info('children', $e))[0]; |
| 558 |
|
| 559 |
$ent = $w->info('next', $e) |
| 560 |
unless(defined $ent && $w->entrycget($ent, '-state') ne 'disabled') |
| 561 |
} |
| 562 |
|
| 563 |
last unless( defined $ent ); |
| 564 |
last if($w->entrycget($ent, '-state') ne 'disabled'); |
| 565 |
} |
| 566 |
|
| 567 |
unless( defined $ent ) |
| 568 |
{ |
| 569 |
$w->xview('scroll', $spec eq 'left' ? -1 : 1, 'unit'); |
| 570 |
return; |
| 571 |
} |
| 572 |
|
| 573 |
$w->anchorSet($ent); |
| 574 |
$w->see($ent); |
| 575 |
|
| 576 |
if($w->cget('-selectmode') ne 'single') |
| 577 |
{ |
| 578 |
$w->selectionClear; |
| 579 |
$w->selectionSet($ent); |
| 580 |
|
| 581 |
$w->Callback(-browsecmd =>$ent); |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
sub KeyboardHome |
| 586 |
{ |
| 587 |
my $w = shift; |
| 588 |
$w->yview('moveto' => 0); |
| 589 |
$w->xview('moveto' => 0); |
| 590 |
} |
| 591 |
|
| 592 |
sub KeyboardEnd |
| 593 |
{ |
| 594 |
my $w = shift; |
| 595 |
$w->yview('moveto' => 1); |
| 596 |
$w->xview('moveto' => 0); |
| 597 |
} |
| 598 |
|
| 599 |
sub KeyboardActivate |
| 600 |
{ |
| 601 |
my $w = shift; |
| 602 |
|
| 603 |
my $anchor = $w->info('anchor'); |
| 604 |
|
| 605 |
return unless (defined($anchor) and length($anchor)); |
| 606 |
|
| 607 |
if($w->cget('-selectmode')) |
| 608 |
{ |
| 609 |
$w->selectionClear; |
| 610 |
$w->selectionSet($anchor); |
| 611 |
} |
| 612 |
|
| 613 |
$w->Callback(-command => $anchor); |
| 614 |
} |
| 615 |
|
| 616 |
sub KeyboardBrowse |
| 617 |
{ |
| 618 |
my $w = shift; |
| 619 |
|
| 620 |
my $anchor = $w->info('anchor'); |
| 621 |
|
| 622 |
return unless (defined($anchor) and length($anchor)); |
| 623 |
|
| 624 |
if ($w->indicatorExists($anchor)) |
| 625 |
{ |
| 626 |
$w->Callback(-indicatorcmd => $anchor); |
| 627 |
} |
| 628 |
|
| 629 |
if($w->cget('-selectmode')) |
| 630 |
{ |
| 631 |
$w->selectionClear; |
| 632 |
$w->selectionSet($anchor); |
| 633 |
} |
| 634 |
$w->Callback(-browsecmd =>$anchor); |
| 635 |
} |
| 636 |
|
| 637 |
sub AutoScan |
| 638 |
{ |
| 639 |
my ($w,$x,$y) = @_; |
| 640 |
|
| 641 |
return if ($w->cget('-selectmode') eq 'dragdrop'); |
| 642 |
if (@_ < 3) |
| 643 |
{ |
| 644 |
my $Ev = $w->XEvent; |
| 645 |
return unless defined $Ev; |
| 646 |
$y = $Ev->y; |
| 647 |
$x = $Ev->x; |
| 648 |
} |
| 649 |
|
| 650 |
if($y >= $w->height) |
| 651 |
{ |
| 652 |
$w->yview('scroll', 1, 'units'); |
| 653 |
} |
| 654 |
elsif($y < 0) |
| 655 |
{ |
| 656 |
$w->yview('scroll', -1, 'units'); |
| 657 |
} |
| 658 |
elsif($x >= $w->width) |
| 659 |
{ |
| 660 |
$w->xview('scroll', 2, 'units'); |
| 661 |
} |
| 662 |
elsif($x < 0) |
| 663 |
{ |
| 664 |
$w->xview('scroll', -2, 'units'); |
| 665 |
} |
| 666 |
else |
| 667 |
{ |
| 668 |
return; |
| 669 |
} |
| 670 |
$w->RepeatId($w->SUPER::after(50,[ AutoScan => $w, $x, $y ])); |
| 671 |
$w->Button1Motion; |
| 672 |
} |
| 673 |
|
| 674 |
sub children |
| 675 |
{ |
| 676 |
# Tix has core-tk window(s) which are not a widget(s) |
| 677 |
# the generic code returns these as an "undef" |
| 678 |
my $w = shift; |
| 679 |
my @info = grep(defined($_),$w->winfo('children')); |
| 680 |
@info; |
| 681 |
} |
| 682 |
|
| 683 |
sub BalloonInfo |
| 684 |
{ |
| 685 |
my ($listbox,$balloon,$X,$Y,@opt) = @_; |
| 686 |
my $e = $listbox->XEvent; |
| 687 |
return if !$e; |
| 688 |
my $path = $listbox->GetNearest($e->y, 1); |
| 689 |
$path = '' unless defined($path); |
| 690 |
foreach my $opt (@opt) |
| 691 |
{ |
| 692 |
my $info = $balloon->GetOption($opt,$listbox); |
| 693 |
if ($opt =~ /^-(statusmsg|balloonmsg)$/ |
| 694 |
&& UNIVERSAL::isa($info,'HASH')) |
| 695 |
{ |
| 696 |
$balloon->Subclient($path); |
| 697 |
if (defined $info->{$path}) |
| 698 |
{ |
| 699 |
return $info->{$path}; |
| 700 |
} |
| 701 |
return ''; |
| 702 |
} |
| 703 |
return $info if (defined $info); |
| 704 |
} |
| 705 |
return ''; |
| 706 |
} |
| 707 |
|
| 708 |
1; |