routine PART.CTRL given DLG.FIELD, DLG.PTR yielding STATUS
''
''    AUTHOR: Steve Bailey
''    CREATED: 2-23-96
''    DESCRIPTION:
''        Control routine for the dialog box which allows the user to set
''        attributes of parts of the chart.
''

define DLG.FIELD as a text variable
define DLG.PTR as a pointer variable
define STATUS as an integer variable

define DATASET.ID, PART.ID, FILLSTYLE, LINESTYLE, LINEWIDTH, MARKTYPE,
       TEXTFONT, TEXTPTSIZE, TEXTWEIGHT, TEXTSLANT, PART.COLOR
        as integer variables
define TEXTFAMILY as text variables
define PARTS as a 1-dim text array

'' get attributes of the chart
let PART.ID    = DDVAL.A(DFIELD.F("PARTS", DLG.PTR))
let DATASET.ID = DDVAL.A(DFIELD.F("DATASET ID", DLG.PTR))
let PART.COLOR = DDVAL.A(DFIELD.F("COLOR", DLG.PTR))
let FILLSTYLE  = DDVAL.A(DFIELD.F("FILLSTYLE", DLG.PTR))
let LINESTYLE  = DDVAL.A(DFIELD.F("LINESTYLE", DLG.PTR))
let LINEWIDTH  = DDVAL.A(DFIELD.F("LINEWIDTH", DLG.PTR))
let MARKTYPE   = DDVAL.A(DFIELD.F("MARKTYPE", DLG.PTR))
let TEXTFONT   = DDVAL.A(DFIELD.F("TEXTFONT", DLG.PTR))
let TEXTFAMILY = DTVAL.A(DFIELD.F("TEXTFAMILY", DLG.PTR))
let TEXTPTSIZE = DDVAL.A(DFIELD.F("TEXTPTSIZE", DLG.PTR))
let TEXTWEIGHT = DDVAL.A(DFIELD.F("TEXTWEIGHT", DLG.PTR))
let TEXTSLANT  = DDVAL.A(DFIELD.F("TEXTSLANT", DLG.PTR))
 
let STATUS = 0

'' check to see which button in the dialog was pressed. Call the appropriate
'' routines to set chart attributes using the data in the dialog
select case DLG.FIELD
  case "INITIALIZE"
      '' fill in a list box containing names of all parts
    reserve PARTS(*) as 16
    let PARTS(.CHART.TITLE) = "Title"
    let PARTS(.CHART.X.TITLE) = "X axis title"
    let PARTS(.CHART.Y.TITLE) = "Y axis title"
    let PARTS(.CHART.Y2.TITLE) = "Y2 axis title"
    let PARTS(.CHART.X.AXIS) = "X axis"
    let PARTS(.CHART.Y.AXIS) = "Y axis"
    let PARTS(.CHART.Y2.AXIS) = "Y2 axis"
    let PARTS(.CHART.X.NUMBERING) = "X numbering"
    let PARTS(.CHART.Y.NUMBERING) = "Y numbering"
    let PARTS(.CHART.Y2.NUMBERING) = "Y2 numbering"
    let PARTS(.CHART.X.GRID) = "X grid lines"
    let PARTS(.CHART.Y.GRID) = "Y grid lines"
    let PARTS(.CHART.Y2.GRID) = "Y2 grid lines"
    let PARTS(.CHART.BORDER) = "Border"
    let PARTS(.CHART.LEGEND) = "Legend text"
    let PARTS(.CHART.DATASET) = "Data set"

    let DARY.A(DFIELD.F("PARTS", DLG.PTR)) = PARTS(*)

  case "APPLY"

      '' set all global style attributes
    call LINESTYLE.R(LINESTYLE)
    call LINEWIDTH.R(LINEWIDTH)
    call FILLSTYLE.R(FILLSTYLE)
    call MARKTYPE.R(MARKTYPE)
    call TEXTSYSFONT.R(TEXTFAMILY, TEXTPTSIZE, TEXTWEIGHT, TEXTSLANT)
    call TEXTFONT.R(TEXTFONT)  '' must be called AFTER TEXTSYSFONT.R
    
      '' the partstyle routine will use the current primitive styles set
      '' up above
    call SET.GRAPH.PARTSTYLE.R(CHART.PTR, PART.ID, DATASET.ID)

    call SET.GRAPH.PARTCOLOR.R(CHART.PTR, PART.ID, DATASET.ID, PART.COLOR)

    display CHART.PTR

  case "RETURN"
    let STATUS = 1

  default
endselect

return
end
