NAME
Tk::TM::wApp - Tk Transaction Manager Application Window. See Tk::TM::Lib for main descriptions and principles.
SYNOPSIS
use Tk::TM::wApp;
use DBI;
my $mw =new Tk::TM::wApp;
$mw->setscr(0,'Login');
$mw->setscr(0,'Screen 1', \&Screen1);
$mw->setscr(1,'Screen 1.1', \&Screen1_1);
$mw->setscr(0,'Screen 2', \&Screen2);
$mw->Start();
Tk::MainLoop;
..............................
sub Screen1_1 { # two subs - for screen and for data object
my ($self, $cmd, $opt, $mst) =@_;
return(1) if $cmd =~/stop/;
my $wgt=$self->{-wgscr}->tmTable(
-rowcount=>10
,-colspecs=>[['Col1' ,'Entry']
,['Col2' ,'Entry']
,['Col3' ,'Entry']
,['Col4' ,'Entry']]
)->pack;
my $do;
if (!$self->{-dos}) {
$do =new Tk::TM::DataObject();
$self->{-dos} =[$do];
}
else {
$do =$self->{-dos}->[0];
}
my $rwm =$mst->{-dos}->[0]->dsRowDta();
my $flt =$rwm->[0];
$self->{-title} =$flt;
$do->set(-wgtbl=>$wgt
,-mdedt=>0
,-cbdbRead=>
sub{$_[0]->DBICmd("select * from table where field=?",$flt)}
);
$do->Retrieve('#reread')
}
..............................
sub Screen1_2 { # unified sub for screen with single data object
my ($self, $cmd, $opt, $row, $fld, $wg, $dta, $new) =(shift, shift, @_);
if ($cmd eq 'stop') {
return(1)
}
elsif ($cmd eq 'start') {
my $wgt=$self->{-wgscr}->tmTable(
-rowcount=>10
,-colspecs=>[['Name','Entry']]
)->pack;
my $do;
if (!$self->{-dos}) {
$do =new Tk::TM::DataObject();
$self->{-dos} =[$do];
}
else {
$do =$self->{-dos}->[0];
}
my $rwm =$row->{-dos}->[0]->dsRowDta();
$do->{-parm}->{XXX} =$rwm->[0];
$self->{-title} =$do->{-parm}->{dsn};
$do->set(-wgtbl=>$wgt
,-mdedt=>0
,-cbcmd=>\&DataSources
);
$do->Retrieve('#reread')
}
elsif ($cmd eq 'dbRead') {
$self->dsRowFeedAll("select...", $self->{-parm}->{XXX})
}
else {return $self->doDefault($cmd, @_)}
}
..............................
DESCRIPTION
This module implements application window with Tk Transaction Manager features. Tk::TM::wApp
is level above Tk::TM::Lib
, see there other descriptions and principles. There is no need to call 'use' for Tk::TM::Lib
, this is done by using Tk::TM::wApp
.
The components of application window are:
Data editing bar menu with toolbar, implemented with Tk::TM::wgMenu
(tmMenu
widget).
Navigation pane with list of screen names to open, implemented with Tk::Tree
.
Screen pane for widgets of application screens, implemented with Tk::Frame
.
PARAMETERS
Tk parameters of Tk::TM::wApp
window may be set via configure
Tk
method. They may be all parameters of Tk::MainWindow
.
TM parameters may be accessed via set
method of Tk::TM
. They are: -wgmnu
, -wglst
, -wgscr
, -title
, -mdlst
, -parm
-mdlst = 'lst' || 'tree'
Mode of navigation between application screens. Default is 'tree', that means that detail screen should be opened for it`s master screen and if master was previously used. Mode 'lst' means that screens are using -parm
values filled in 'stop' command of screen`s sub or doEnd
event of data object.
-parm = {}
Programmer`s parameters. This hash is also accessible via parameter -parm
of tmMenu
widget (Tk::TM::wgMenu
), accessible via -wgmnu
.
-title = $mw->cget(-title)
Title of application, the first part of window`s title. Other parts are combined for current application`s screen. Default value is title of the window.
-wglst
Widget with list of all available application screens. This is navigation pane of application. Tk::Tree
is used.
-wgmnu
Menu and toolbar for data editing. tmMenu
widget (Tk::TM::wgMenu
) is used.
-wgscr
Widget for application screens, to create application widgets inside it. Tk::Frame
widget is used.
METHODS
Common object methods as new
, initialize
, set
are described under Tk::TM::Lib
.
Special methods are setscr
, Start
.
setscr (level, title, ?sub, ?opt)
Defines screen of application. Level is number of nest of screen in tree, where 0 is top level. Sub is code to create widgets and data objects of screen. Opt is options (scalar or ref), used within sub. Special title 'Login' is used for predefined login screen.
Start
Opens the first screen of application.
CALLBACK INTERFACE
- \&callback (self, command, opt, parent)
-
setscr
method defines callback to start and stop application screen. Parameters are description of this screen, command ('start' or 'stop'), option string, description of parent screen.The command is string 'start' or 'stop'.
The descriptions are hash references with entries
-cbcmd
,-cbnme
,-dos
,-opt
,-wgapp
,-wgmnu
,-wgscr
,-label
,-title
,-parm
- start
-
Start performance of screen. If
-dos
is not defined, this is the first open of screen. - stop
-
Stop performance of screen. The operation may be declared with 'return(1)' only.
- -cbcmd
-
Reference to this callback sub.
- -cbnme
-
Name of this callback sub for dynamic loading.
- -dos
-
Reference to list of data objects of screen. Callback should set it. At the first open of the screen this is not defined.
- -label
-
Label of the screen as displayed in
-wglst
. Title of application window is combined with title of application, label of the screen, title of the screen (described below at-title
) - -opt
-
Options, defined with
setscr
. - -parm
-
Programmer`s parameters of screen, hash.
- -title
-
Title of the screen, represents data displayed on screen. This is the third part of application window title. Other parts are the title of the application and the label of the screen
-label
. - -wgapp
-
Application window, provided by
Tk::wApp
. - -wgmnu
-
Application`s menu bar, provided by
Tk::wApp
. - -wgscr
-
Widget for application screen, to create application widgets inside it. Provided by
Tk::wApp
.Tk::Frame
widget is used.
VERSION
AUTHOR
Andrew V Makarow <makarow@mail.com>, Denis E Medvedyuk <demed@mail.com>
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 138:
You can't have =items (as at line 149) unless the first thing after the =over is an =item
- Around line 199:
You can't have =items (as at line 207) unless the first thing after the =over is an =item