# Implementation of NoteBook widget.
# Derived from NoteBook.tcl in Tix 4.0
# Contributed by Rajappa Iyer <rsi@earthling.net>
# Hacked by Nick for 'menu' traversal.
$VERSION = '3.024'; # $Id: //depot/Tk8/Tixish/NoteBook.pm#24 $
use base qw(Tk::Derived Tk::NBFrame);
Tk
::Widget
->Construct('NoteBook');
# class binding does not work right due to extra level of
$mw->bind($class,'<ButtonPress-1>', ['MouseDown',Ev
('x'),Ev
('y')]);
$mw->bind($class,'<ButtonRelease-1>', ['MouseUp',Ev
('x'),Ev
('y')]);
$mw->bind($class,'<B1-Motion>', ['MouseDown',Ev
('x'),Ev
('y')]);
$mw->bind($class,'<Left>', ['FocusNext','prev']);
$mw->bind($class,'<Right>', ['FocusNext','next']);
$mw->bind($class,'<Return>', 'SetFocusByKey');
$mw->bind($class,'<space>', 'SetFocusByKey');
return shift->{'topchild'};
$w->SUPER::Populate
($args);
$w->ConfigSpecs(-ipadx
=> ['PASSIVE', 'ipadX', 'Pad', 0],
-ipady
=> ['PASSIVE', 'ipadY', 'Pad', 0],
-takefocus
=> ['SELF', 'takeFocus', 'TakeFocus', 0],
-dynamicgeometry
=> ['PASSIVE', 'dynamicGeometry', 'DynamicGeometry', 0]);
$w->bind('<Configure>','MasterGeomProc');
$args->{-relief
} = 'raised';
#---------------------------
#---------------------------
$w->{'_pages_'} = {} unless exists $w->{'_pages_'};
return delete $h->{$name};
my ($w, $child, %args) = @_;
croak
("$child already exists") if defined $w->page_widget($child);
my $f = Tk
::Frame
->new($w,Name
=> $child,-relief
=> 'raised');
my $ccmd = delete $args{-createcmd
};
my $rcmd = delete $args{-raisecmd
};
$f->{-createcmd
} = Tk
::Callback
->new($ccmd) if (defined $ccmd);
$f->{-raisecmd
} = Tk
::Callback
->new($rcmd) if (defined $rcmd);
# create default bindings
$f->bind('<Configure>',[$w,'ClientGeomProc','-configure', $f]);
$f->bind('<Destroy>', [$w,'delete',$child,1]);
$w->page_widget($child,$f);
push(@
{$w->{'windows'}}, $child);
$w->SUPER::add
($child,%args);
return unless defined $child;
if ($w->pagecget($child, -state) eq 'normal')
my $childw = $w->page_widget($child);
if (defined $childw->{-createcmd
})
$childw->{-createcmd
}->Call($childw);
delete $childw->{-createcmd
};
# hide the original visible window
my $oldtop = $w->{'topchild'};
if (defined($oldtop) && ($oldtop ne $child))
$w->page_widget($oldtop)->UnmapWindow;
$w->{'topchild'} = $child;
my $cW = $myW - $w->{'pad-x1'} - $w->{'pad-x2'} - 2 * (defined $w->{-ipadx
} ?
$w->{-ipadx
} : 0);
my $cH = $myH - $w->{'pad-y1'} - $w->{'pad-y2'} - 2 * (defined $w->{-ipady
} ?
$w->{-ipady
} : 0);
my $cX = $w->{'pad-x1'} + (defined $w->{-ipadx
} ?
$w->{-ipadx
} : 0);
my $cY = $w->{'pad-y1'} + (defined $w->{-ipady
} ?
$w->{-ipady
} : 0);
$childw->MoveResizeWindow($cX, $cY, $cW, $cH);
if ((not defined $oldtop) || ($oldtop ne $child))
if (defined $childw->{-raisecmd
})
$childw->{-raisecmd
}->Call($childw);
my ($w, $child, %args) = @_;
my $childw = $w->page_widget($child);
my $ccmd = delete $args{-createcmd
};
my $rcmd = delete $args{-raisecmd
};
$childw->{-createcmd
} = Tk
::Callback
->new($ccmd) if (defined $ccmd);
$childw->{-raisecmd
} = Tk
::Callback
->new($rcmd) if (defined $rcmd);
$w->SUPER::pageconfigure
($child, %args) if (keys %args);
return @
{$w->{'windows'}};
my ($w, $child, $opt) = @_;
my $childw = $w->page_widget($child);
return $childw->{-createcmd
} if ($opt =~ /-createcmd/);
return $childw->{-raisecmd
} if ($opt =~ /-raisecmd/);
return $w->SUPER::pagecget
($child, $opt);
carp
"page $child does not exist";
my ($w, $child, $destroy) = @_;
my $childw = $w->page_widget($child,undef);
$childw->bind('<Destroy>', undef);
@
{$w->{'windows'}} = grep($_ !~ /$child/, @
{$w->{'windows'}});
$w->SUPER::delete($child);
# see if the child to be deleted was the top child
if ((defined $w->{'topchild'}) && ($w->{'topchild'} eq $child))
$w->raise($w->{'windows'}[0]);
carp
"page $child does not exist" unless $destroy;
#---------------------------------------
#---------------------------------------
my $name = $w->identify($x, $y);
my $name = $w->identify($x, $y);
($name eq $w->{'down'}) &&
($w->pagecget($name, -state) eq 'normal')) {
if (not defined $w->info('focus')) {
$name = $w->info('active');
$name = $w->info('focus' . $dir);
my $name = $w->info('focus');
if ($w->pagecget($name, -state) eq 'normal') {
foreach $page (@
{$w->{'windows'}}) {
my $i = $w->pagecget($page, -underline
);
my $c = substr($page, $i, 1);
if ($w->pagecget($page, -state) ne 'disabled') {
# This is called by TraveseToMenu when an <Alt-Keypress> occurs
foreach $page (@
{$w->{'windows'}}) {
my $i = $w->pagecget($page, -underline
);
my $l = $w->pagecget($page, -label
);
next if (not defined $l);
my $c = substr($l, $i, 1);
if ($w->pagecget($page, -state) ne 'disabled') {
$w->{'resize'} = 0 unless (defined $w->{'resize'});
my ($w, $flag, $client) = @_;
$w->QueueResize if (Tk
::Exists
($w));
if ($flag =~ /-lostslave/)
carp
"Geometry Management Error: Another geometry manager has taken control of $client. This error is usually caused because a widget has been created in the wrong frame: it should have been created inside $client instead of $w";
$w->afterIdle(['Resize', $w]) unless ($w->{'resize'}++);
return unless Tk
::Exists
($w) && $w->{'nWindows'} && $w->{'resize'};
my ($tW, $tH) = $w->geometryinfo;
$w->{'pad-y1'} = $tH + (defined $w->{'-ipadx'} ?
$w->{'-ipadx'} : 0) + 1;
my $reqW = $w->{-width
} || 0;
my $reqH = $w->{-height
} || 0;
if ((not defined $w->{-dynamicgeometry
}) ||
($w->{-dynamicgeometry
} == 0)) {
foreach $childw ($w->page_widget)
my $cW = $childw->ReqWidth;
my $cH = $childw->ReqHeight;
$reqW = $cW if ($reqW < $cW);
$reqH = $cH if ($reqH < $cH);
if (defined $w->{'topchild'}) {
my $topw = $w->page_widget($w->{'topchild'});
$reqH = $topw->ReqHeight;
$reqW += $w->{'pad-x1'} + $w->{'pad-x2'} + 2 * (defined $w->{-ipadx
} ?
$w->{-ipadx
} : 0);
$reqH += $w->{'pad-y1'} + $w->{'pad-y2'} + 2 * (defined $w->{-ipady
} ?
$w->{-ipady
} : 0);
$reqW = ($reqW > $w->{'minW'}) ?
$reqW : $w->{'minW'};
$reqH = ($reqH > $w->{'minH'}) ?
$reqH : $w->{'minH'};
if (($w->ReqWidth != $reqW) ||
($w->ReqHeight != $reqH)) {
$w->{'counter'} = 0 if (not defined $w->{'counter'});
if ($w->{'counter'} < 50) {
$w->GeometryRequest($reqW, $reqH);
$w->afterIdle([$w,'Resize']);
$w->raise($w->{'topchild'} || ${$w->{'windows'}}[0]);