.CM  SCRIPT , Version - 1.1 , last edited by B.Morgeneyer
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1998-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VIN54$
.tt 2 $$$
.TT 3 $$Logical Screen : Help Procedures$1998-06-19$
***********************************************************
.nf

.nf

.nf

    ========== licence begin  GPL
    Copyright (c) 1998-2005 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo


.fo


.fo
.nf
.sp
MODULE  : logical_screen_help_procedures
=========
.sp
Purpose : Procedures for the internal use of the Logical Screen
 
&       if $OS=UNIX
&       define hifmode 1
&       else
&       ifdef WINDOWS
&       define hifmode 1
&       else
&       if $OS=MSDOS
&       define pcmode 1
&       endif
&       endif
&       endif
.CM *-END-* purpose -------------------------------------
.sp
Define  :
 
        PROCEDURE
              i54gpartsdefaults (
                    part   : tin_ls_part;
                    VAR ft : tin_ls_fieldtype);
 
        PROCEDURE
              i54disablescreenpart (
                    sno  : integer;
                    part : tin_ls_part);
 
        PROCEDURE
              i54definelayoutwindow (
                    pos             : tin_ls_position;
                    lines,cols      : integer;
                    VAR description : tin_ls_window;
                    VAR ok          : boolean);
 
        PROCEDURE
              i54setwindowlimits (
                    sno                 : tsp00_Int2;
                    first_lno,first_col : integer;
                    last_lno,last_col   : integer;
                    ft                  : tin_ls_fieldtype);
 
        PROCEDURE
              i54resolvedefaults (
                    part           : tin_ls_part;
                    VAR field_type : tin_ls_fieldtype);
 
        PROCEDURE
              i54fieldtype (
                    VAR ft : tin_ls_fieldtype );
 
        PROCEDURE
              i54terminal_type (
                    VAR typ : tin_terminal_type);
 
        PROCEDURE
              i54initls_pos (
                    VAR ls_pos : tin_ls_position);
&       ifdef PCMODE
 
        PROCEDURE
              i54changewidth (
                    part : tin_ls_part;
                    diff : tsp00_Int2);
&       endif
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              global_variable : VIN01;
 
        VAR
              i01g : tin_global_in_vars;
 
      ------------------------------ 
 
        FROM
              logical_screen_variants : VIN52;
 
        PROCEDURE
              i52fromscreenpos (
                    VAR pos       : tin_ls_position;
                    VAR screenlno : tin_natural;
                    VAR screencol : tin_natural);
 
      ------------------------------ 
 
        FROM
              logical_screen_procedures : VIN53;
 
        PROCEDURE
              i53put1attribute (
                    sno              : tsp00_Int2;
                    field_slno       : integer;
                    field_scol       : integer;
                    VAR ft           : tin_ls_fieldtype;
                    maxcols          : integer;
                    vt_att           : tsp00_ScreenBufAddr);
 
        PROCEDURE
              i53put1field (
                    VAR field        : tin_screenline;
                    length           : integer;
                    sno              : tsp00_Int2;
                    field_slno       : integer;
                    field_scol       : integer;
                    VAR ft           : tin_ls_fieldtype;
                    maxlines,maxcols : integer;
                    vt_screen        : tsp00_ScreenBufAddr;
                    vt_att           : tsp00_ScreenBufAddr);
 
        PROCEDURE
              i53screenaddresses (
                    sno          : tsp00_Int2;
                    VAR screen   : tsp00_ScreenBufAddr;
                    VAR att      : tsp00_ScreenBufAddr;
                    VAR maxlines : tsp00_Int2;
                    VAR maxcols  : tsp00_Int2 );
 
      ------------------------------ 
 
        FROM
              RTE_driver : VEN102;
 
        PROCEDURE
              sqlos (
                    VAR os : tsp00_Os);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              i53put1field;
 
              tsp00_MoveObj tin_screenline
 
        PROCEDURE
              sqlos;
 
              tsp00_Os tsp00_Os
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1986-06-27
.sp
.cp 3
Version : 1998-06-19
.sp
.cp 3
Release :      Date : 1998-06-19
.sp
***********************************************************
.pa
.cp 10
.fo
.oc _/1
Specification:
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      (* internal field attributes *)
      ls_black       = 6;
&     ifdef PCMODE
      ls_b_normal    = 7;
      ls_b_enhanced  = 8;
      ls_b_invisible = 9;
      ls_b_inverse   = 10;
      ls_b_blink     = 11;
&     endif
 
 
(*------------------------------*) 
 
PROCEDURE
      i54fieldtype (
            VAR ft : tin_ls_fieldtype );
 
BEGIN
WITH ft DO
    BEGIN
    field_att := cin_ls_normal;
    fieldmode := [  ] ;
    END;
(*ENDWITH*) 
END; (* i54fieldtype *)
 
(*------------------------------*) 
 
PROCEDURE
      i54gpartsdefaults (
            part   : tin_ls_part;
            VAR ft : tin_ls_fieldtype);
 
BEGIN
(* implement this later *)
(* IF  (part >= ls_header)
      AND (part <= cin_ls_sysline)
      THEN
      ft := i01g^.ls.defaults [ sno  ] [  part  ]
      ELSE *)
i54fieldtype( ft );
i54resolvedefaults (part, ft);
END; (* i54gpartsdefaults *)
 
(*------------------------------*) 
 
PROCEDURE
      i54disablescreenpart (
            sno  : integer;
            part : tin_ls_part);
 
BEGIN
WITH i01g^.ls.description [ sno ]  [ part  ] DO
    BEGIN
    first_line := 0;
    last_line := 0;
    first_col := 0;
    last_col := 0;
    END;
(*ENDWITH*) 
END; (* i54disablescreenpart *)
 
(*------------------------------*) 
 
PROCEDURE
      i54definelayoutwindow (
            pos             : tin_ls_position;
            lines,cols      : integer;
            VAR description : tin_ls_window;
            VAR ok          : boolean);
 
VAR
      line,col              : tin_natural;
      line_limit,cols_limit : tin_natural;
 
BEGIN
ok := true;
WITH description DO
    IF  lines = 0
    THEN
        BEGIN
        first_line := 0;
        first_col := 0;
        last_col := 0;
        last_line := 0;
        END
    ELSE
        BEGIN
        i52fromscreenpos(pos,line,col);
        get_limits(pos.screen_part,pos.screen_nr,line_limit,cols_limit);
        ok := (line <= line_limit) AND (col <= cols_limit);
        IF  ok
        THEN
            BEGIN
            first_line := line;
            first_col := col;
            IF  first_col = 1
            THEN
                first_col := 2;
            (*ENDIF*) 
            last_col := first_col + cols - 1;
            IF  last_col > cols_limit
            THEN
                last_col := cols_limit;
            (*ENDIF*) 
            last_line := first_line + lines - 1;
            IF  last_line > line_limit
            THEN
                last_line := line_limit;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        END;
    (*ENDIF*) 
(*ENDWITH*) 
END; (* i54definelayoutwindow *)
 
(*------------------------------*) 
 
PROCEDURE
      get_limits (
            part           : tin_ls_part;
            sno            : integer;
            VAR line_limit : tin_natural;
            VAR cols_limit : tin_natural);
 
BEGIN
IF  part = cin_ls_whole_screen
THEN
    BEGIN
    line_limit := i01g^.vt.desc.num_of_lines;
    cols_limit := i01g^.vt.desc.num_of_cols;
    END
ELSE
    BEGIN
    IF  i01g^.ls.nr_screens = 1
    THEN
        sno := 1;
    (*ENDIF*) 
    line_limit := i01g^.ls.description [sno]  [part] .last_line;
    cols_limit := i01g^.ls.description [sno]  [part] .last_col;
&   ifndef WINDOWS
    IF  part = cin_ls_workarea
    THEN
        line_limit := line_limit + 1;
&   endif
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* get_limits *)
 
(*------------------------------*) 
 
PROCEDURE
      i54setwindowlimits (
            sno                 : tsp00_Int2;
            first_lno,first_col : integer;
            last_lno,last_col   : integer;
            ft                  : tin_ls_fieldtype);
 
VAR
      lno       : integer;
      frameline : tin_screenline;
      black_ft  : tin_ls_fieldtype;
      screen    : tsp00_ScreenBufAddr;
      att       : tsp00_ScreenBufAddr;
      maxlines  : tsp00_Int2;
      maxcols   : tsp00_Int2;
 
BEGIN
black_ft.field_att := ls_black;
black_ft.fieldmode := [ ] ;
frameline [1]  := bsp_c1;
i53screenaddresses( sno, screen, att, maxlines, maxcols );
FOR lno := first_lno TO last_lno DO
    (* WITH i01g^.vt,desc DO *)
    BEGIN
    i53put1field(frameline,1,sno, lno,first_col,
          ft,maxlines,maxcols,
          screen, att );
    (* background attribute *)
    i53put1attribute ( sno, lno, first_col+1,
          ft, maxcols,
          att );
    i53put1field(frameline,1, sno, lno,last_col,
          ft,maxlines,maxcols,
          screen, att );
    (* background attribute *)
    (*
          i53put1attribute ( lno, last_col+1,
          black_ft, maxcols,
          att);
          *)
    END;
(*ENDFOR*) 
END; (* i54setwindowlimits *)
 
(*------------------------------*) 
 
PROCEDURE
      i54resolvedefaults (
            part           : tin_ls_part;
            VAR field_type : tin_ls_fieldtype);
 
BEGIN
IF  i01g^.vt.parms.standard_attributes
THEN
    BEGIN
    IF  (part <> cin_ls_workarea)
        AND (part <> cin_ls_basic_window)
        AND (part <> cin_ls_inputarea)
    THEN
        BEGIN
&       ifdef PCMODE
        CASE field_type.field_att OF
            cin_ls_normal  :
                field_type.field_att := ls_b_normal;
            cin_ls_enhanced:
                field_type.field_att := ls_b_enhanced;
            cin_ls_invisible:
                field_type.field_att := ls_b_invisible;
            cin_ls_inverse:
                field_type.field_att := ls_b_inverse;
            cin_ls_blink  :
                field_type.field_att := ls_b_blink;
            OTHERWISE:
            END;
        (*ENDCASE*) 
&       endif
        END;
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* i54resolvedefaults *)
 
(*------------------------------*) 
 
PROCEDURE
      i54terminal_type (
            VAR typ : tin_terminal_type);
 
VAR
      os : tsp00_Os;
 
BEGIN
sqlos ( os );
IF  (os = os_unix) AND (i01g^.vt.desc.labels <> no_sk_labels)
    AND ( [  vt_sk01..vt_sk09 ] <= i01g^.vt.desc.returnkeys )
THEN
    typ := dap4x
ELSE
&   ifndef WINDOWS
    IF  os = os_windows
&       else
        IF ( os = os_windows ) OR ( os = os_win32 ) OR ( os = os_os2)
&       endif
    THEN
        BEGIN
        IF  i01g^.vt.desc.labels <> no_sk_labels
        THEN
            typ := win_terminal
        ELSE
            typ := pc_terminal
        (*ENDIF*) 
        END
    ELSE
        IF  [  vt_pf01..vt_pf12 ] <= i01g^.vt.desc.returnkeys
        THEN
            typ := t_3270
        ELSE
            typ := unknown_terminal;
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
END; (* i54terminal_type *)
 
(*------------------------------*) 
 
PROCEDURE
      i54initls_pos (
            VAR ls_pos : tin_ls_position);
 
BEGIN
WITH ls_pos DO
    BEGIN
    screen_nr := 1;
    screen_part := cin_ls_header;
    sline := 1;
    scol := mxin_id_field + 1;
    END;
(*ENDWITH*) 
END; (* i54initls_pos *)
 
&ifdef PCMODE
(*------------------------------*) 
 
PROCEDURE
      i54changewidth (
            part : tin_ls_part;
            diff : tsp00_Int2);
 
VAR
      i : integer;
 
BEGIN
WITH i01g^.ls DO
    FOR i := 1 TO nr_screens DO
        WITH description [i] [  part  ] DO
            IF  (last_line > 0)
            THEN
                BEGIN
                first_col := first_col + diff;
                last_col := last_col - diff;
                END;
            (*ENDIF*) 
        (*ENDWITH*) 
    (*ENDFOR*) 
(*ENDWITH*) 
END; (* i54changewidth *)
 
&endif
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         77
*-PRETTY-*  lines of code :        322        PRETTYX 3.10 
*-PRETTY-*  lines in file :        539         1997-12-10 
.PA 
