$VERSION
= 0.03;
Construct Tk::Widget
'PodViewerFull'
;
sub
Populate {
my
(
$self
,
$args
) =
@_
;
$self
->SUPER::Populate(
$args
);
my
@bpack
= (
-side
=>
'left'
,
-padx
=> 2,
-pady
=> 2);
my
@bopt
= (
-relief
=>
'flat'
);
my
$txt
=
$self
->Subwidget(
'txt'
);
my
$toolframe
=
$self
->Frame->
pack
(
-before
=>
$txt
,
-fill
=>
'x'
,
-padx
=> 2,
-pady
=> 2,
);
$self
->Advertise(
'Toolbar'
,
$toolframe
);
my
$prev
=
$toolframe
->Button(
@bopt
,
-text
=>
'<- Previous'
,
-command
=> [
'previous'
,
$self
],
)->
pack
(
@bpack
);
my
$next
=
$toolframe
->Button(
@bopt
,
-text
=>
'-> Next'
,
-command
=> [
'next'
,
$self
],
)->
pack
(
@bpack
);
my
$zmin
=
$toolframe
->Button(
@bopt
,
-text
=>
'+ Zoom'
,
-command
=> [
'zoomIn'
,
$self
],
)->
pack
(
@bpack
);
my
$zmout
=
$toolframe
->Button(
@bopt
,
-text
=>
'- Zoom'
,
-command
=> [
'zoomOut'
,
$self
],
)->
pack
(
@bpack
);
my
$zmreset
=
$toolframe
->Button(
@bopt
,
-text
=>
'0 Zoom'
,
-command
=> [
'zoomReset'
,
$self
],
)->
pack
(
@bpack
);
my
$searchbar
=
$self
->Frame;
$self
->Advertise(
'Searchbar'
,
$searchbar
);
my
$case
=
'-case'
;
my
$find
=
''
;
my
$reg
=
'-exact'
;
$searchbar
->Label(
-text
=>
'Find'
,
)->
pack
(
@bpack
);
my
$search
=
$searchbar
->Entry(
-textvariable
=> \
$find
,
)->
pack
(
@bpack
,
-expand
=> 1,
-fill
=>
'x'
);
$self
->Advertise(
'Search'
,
$search
);
$search
->
bind
(
'<Escape>'
, [
$self
,
'searchClose'
]);
$search
->
bind
(
'<Return>'
,
sub
{
$self
->FindNext(
'-forward'
,
$reg
,
$case
,
$find
) });
$searchbar
->Button(
-text
=>
'Next'
,
-command
=>
sub
{
$self
->FindNext(
'-forward'
,
$reg
,
$case
,
$find
) },
)->
pack
(
@bpack
);
$searchbar
->Button(
-text
=>
'Previous'
,
-command
=>
sub
{
$self
->FindNext(
'-backward'
,
$reg
,
$case
,
$find
) },
)->
pack
(
@bpack
);
$searchbar
->Button(
-text
=>
'All'
,
-command
=>
sub
{
$self
->FindAll(
$reg
,
$case
,
$find
) },
)->
pack
(
@bpack
);
$searchbar
->Checkbutton(
-text
=>
'Case'
,
-onvalue
=>
'-case'
,
-offvalue
=>
'-nocase'
,
-variable
=> \
$case
,
)->
pack
(
@bpack
);
$searchbar
->Checkbutton(
-text
=>
'Reg'
,
-onvalue
=>
'-regexp'
,
-offvalue
=>
'-exact'
,
-variable
=> \
$reg
,
)->
pack
(
@bpack
);
$searchbar
->Button(
-text
=>
'Close'
,
-command
=> [
'searchClose'
,
$self
],
)->
pack
(
@bpack
);
$txt
->
bind
(
'<Control-f>'
, [
$self
,
'searchPop'
]);
$self
->ConfigSpecs(
-nextimage
=> [{
-image
=>
$next
}],
-previmage
=> [{
-image
=>
$prev
}],
-zoominimage
=> [{
-image
=>
$zmin
}],
-zoomoutimage
=> [{
-image
=>
$zmout
}],
-zoomresetimage
=> [{
-image
=>
$zmreset
}],
);
$self
->Delegates(
'FindAll'
=>
$txt
,
'FindNext'
=>
$txt
,
DEFAULT
=>
$self
,
);
}
sub
searchClose {
my
$self
=
shift
;
my
$searchbar
=
$self
->Subwidget(
'Searchbar'
);
$searchbar
->packForget
if
$searchbar
->ismapped;
$self
->Subwidget(
'txt'
)->focus;
}
sub
searchPop {
my
$self
=
shift
;
my
$searchbar
=
$self
->Subwidget(
'Searchbar'
);
$searchbar
->
pack
(
-fill
=>
'x'
,
-padx
=> 2,
-pady
=> 2)
unless
$searchbar
->ismapped;
$self
->Subwidget(
'Search'
)->focus;
}
1;