| 1 | package Tk::TreeGraph; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use vars qw($VERSION @ISA); | ||
| 5 | |||
| 6 | use Carp ; | ||
| 7 | use Tk::Derived ; | ||
| 8 | use Tk::Canvas ; | ||
| 9 | use Tk::Frame; | ||
| 10 | use AutoLoader qw/AUTOLOAD/ ; | ||
| 11 | |||
| 12 | |||
| 13 | @ISA = qw(Tk::Derived Tk::Canvas); | ||
| 14 | |||
| 15 | $VERSION = sprintf "%d.%03d", q$Revision: 1.30 $ =~ /(\d+)\.(\d+)/; | ||
| 16 | |||
| 17 | Tk::Widget->Construct('TreeGraph'); | ||
| 18 | |||
| 19 | sub InitObject { | ||
| 20 | my ($dw,$args) = @_ ; | ||
| 21 | |||
| 22 | # this should get a reasonable default ... | ||
| 23 | my $defc = $dw->parent->cget('-foreground'); | ||
| 24 | $dw->ConfigSpecs ( | ||
| 25 | '-shortcutColor' => ['PASSIVE', undef, undef, 'orange' ], | ||
| 26 | '-shortcutStyle' => ['PASSIVE', undef, undef, 'straight' ], | ||
| 27 | '-animation' => ['PASSIVE', undef, undef, 0 ], | ||
| 28 | '-nodeColor' => ['PASSIVE', undef, undef, $defc ], | ||
| 29 | '-nodeFill' => ['PASSIVE', undef, undef, undef ], | ||
| 30 | '-arrowColor' => ['PASSIVE', undef, undef, $defc ], | ||
| 31 | '-nodeTextColor' => ['PASSIVE', undef, undef, $defc ], | ||
| 32 | '-labelColor' => ['PASSIVE', undef, undef, $defc ], | ||
| 33 | |||
| 34 | # add node Id to text | ||
| 35 | '-nodeTag' => ['PASSIVE', undef, undef, 1 ], | ||
| 36 | # use this to tune the shape of nodes and arrows | ||
| 37 | '-arrowDeltaY' => ['PASSIVE', undef, undef, 40 ], | ||
| 38 | '-branchSeparation' => ['PASSIVE', undef, undef, 120 ], | ||
| 39 | '-x_start' => ['PASSIVE', undef, undef, 40 ], | ||
| 40 | '-y_start' => ['PASSIVE', undef, undef, 100 ], | ||
| 41 | ); | ||
| 42 | |||
| 43 | # bind button <1> on nodes to select a version | ||
| 44 | $dw->bind ('node', | ||
| 45 | '<1>' => sub {$dw->toggleNode(color => 'blue')}); | ||
| 46 | |||
| 47 | $dw->{currentBranch} = 'b000'; | ||
| 48 | $dw->{column}{$dw->{currentBranch}} = 0; | ||
| 49 | |||
| 50 | $dw->SUPER::InitObject($args) ; | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | __END__ |