/*  *//* "Header Information" */
/*--------------------------------------------------------------------*/
/*                                                                    */
/* $VER: GfxTable 0.4 (12 Jun 1994)                                   */ 
/*                                                                    */
/* AUTHOR                                                             */
/*    P. Billing                                                      */
/*                                                                    */
/* NAME                                                               */
/*    GfxTable                                                        */
/*                                                                    */
/*                                                                    */
/* FUNCTION                                                           */
/*    Arexx-Script for Final Writer                                   */
/*    Draw even spaced vertical and horizontal lines                  */
/*                                                                    */
/*                                                                    */
/* INPUTS                                                             */
/*                                                                    */
/*                                                                    */
/*                                                                    */
/* $HISTORY:                                                          */
/*                                                                    */
/* 12 Jun 1994 : 0.4 :   User Spacing added                           */
/* 12 Jun 1994 : 0.3 :   Works with line spacing                      */
/* 12 Jun 1994 : 0.2 :   It works with tabs                           */
/* 12 Jun 1994 : 0.1 :   First attempt                                */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*  */

/*  */ /* "Requestor Info" */
Options Results
CurrentObject
objectId.1 = Result
IF objectID.1 = 0 THEN EXIT

GetDisplayPrefs Measure
Measurement = result
DisplayPrefs Measure Metric
num = 2

test = 0
IF test = 0 THEN DO
  result = ""
  RequestText '"Tables" "Columns: 0 = Nil  Rows: 1 = Text Spacing" ""'
  answer = result
  Col = Word(answer, 1)
  Row = Word(answer, 2)
END
ELSE DO
  answer = 1
  Col = 5
  row = 7
END

IF answer = "" THEN DO
  
/*--------------------------------------------------------------------*/
/*                      re set ruler IF altered                       */
/*--------------------------------------------------------------------*/
  DisplayPrefs Measure Measurement
  
  EXIT
END

/*  */

/*  *//* "Box and Page info" */

/*--------------------------------------------------------------------*/
/*                  Find out the Type of the object.                  */
/*--------------------------------------------------------------------*/

GetObjectType ObjectID.1
objectType = Result

IF ObjectType = 4 | ObjectType = 5 THEN DO
  
/*--------------------------------------------------------------------*/
/*    Get the coordinates and parameters for the selected object.     */
/*--------------------------------------------------------------------*/
  GetObjectCoords ObjectID.1
  coords = Result
  page_no = Word(coords, 1)
  le      = Word(coords, 2)
  tp      = Word(coords, 3)
  wi      = Word(coords, 4)
  he      = Word(coords, 5)
  
  GetObjectParams ObjectID.1 TextFlow FlowDist LineWt LineColor Fill FillColor Linked Display
  PARSE VAR result tf fd wt lc fi fc lk di
  params = TextFlow tf FlowDist fd LineWt wt LineColor lc Fill fi FillColor fc Linked lk Display di
  unlock
END

GetSectionSetup inside
ins = result
GraphicTool
/*  */

/*  *//* "Work out position of lines and Draw" */

/*--------------------------------------------------------------------*/
/*                        Draw Vertical lines                         */
/*--------------------------------------------------------------------*/
IF Col > 1 THEN DO
  
  adj = wi/col
  ShowMessage  1 1 '"Click on the type of Tab you"
  "would like. There are 3 available"
  ""
  "Left""Decimal""Right"'
  tab_type = result

  SELECT
    WHEN tab_type = 1 THEN DO 
                      tab = "left"
                      adj2 = .1
                    END
    WHEN tab_type = 2 THEN DO
                      tab = "decimal"
                      adj2 = (adj/3)*2
                      print(adj adj/3 adj2)
                    END
    WHEN tab_type = 3 THEN DO 
                      tab = "right"
                      adj2 = adj - .1
                    END
    OTHERWISE
  END
  tab_position = le - ins + adj2
  
  DO x = 1 TO Col
    SetTab tab_position tab
    tab_position = tab_position + adj
  END
  x1 = le + adj
  x2 = x1
  y1 = tp
  y2 = tp + he
  DO x = 1 TO Col-1
    DrawL(page_no x1 y1 x2 y2)
    x1 = x1 + adj
    x2 = x1
  END
END

/*--------------------------------------------------------------------*/
/*                       Draw Horizontal lines                        */
/*--------------------------------------------------------------------*/
IF Row > 0 | upper(Row) = "U" THEN DO
  IF row = 1 THEN DO
    Status LineHeight
    adj = result
    Row = he%adj
    he = adj*Row
  END
  IF upper(Row) = "U" THEN DO
    RequestText '"Row Spacing""Type in Spacing in cm."""'
    adj = result
    IF adj ~= "" THEN DO
      Row = he%adj
      he  = adj*Row
    END
  END
  
/*--------------------------------------------------------------------*/
/*    adjust original box TO make it an exact size of the spacing     */
/*--------------------------------------------------------------------*/
  coords = Page Page_no Left le Top tp Width wi Height He
  SetObjectCoords ObjectID.1 coords
  adj = he/row
  
  x1 = le
  x2 = le + wi
  y1 = tp + adj
  y2 = y1
  DO x = 1 TO Row-1
    DrawL(page_no x1 y1 x2 y2)
    y1 = y1 + adj
    y2 = y1
  END
END
redraw

/*  */

/*  *//* "Group and EXIT" */

DO x = 1 TO num
  SelectObject ObjectID.x multiple
END
group
lock
SelectObject
/*--------------------------------------------------------------------*/
/*                      re set ruler IF altered                       */
/*--------------------------------------------------------------------*/
DisplayPrefs Measure Measurement

EXIT

print:
    type (arg(1))
    newparagraph
RETURN tt
/*  */

/*  *//* "Draw Line" */

DrawL:
    DrawLine page_no x1 y1 x2 y2
    ObjectID.num = Result
    SetObjectParams ObjectID.num params
    num = num + 1
RETURN d
/*  */



