
// Copyright 1997
// Black Dirt Software
// All rights reserved

public class bdcGrid extends Control {
    private   int         rows = 2;
    private   int         cols = 2;
    private   int         fixedRows = 1;
    private   int         fixedCols = 1;
    private   int         gridLineWidth = 1;

    private   boolean     gridLines = true;
    private   boolean     highLight = true;


    /////////////////////////////////
    // Component Definition Methods
    //////////////////////////////////


    public void initialize(Control c) {
      super.initialize(c);
      this.setType("Grid");
      this.setJavaType("Grid"); //set to class name for Grid you use
      this.getGridInfo();
    }




    // declareString is used to declare the component
    // the resulting line will be something like:
    // Button thisButton = new Button("OK");

    public String declareString() {
        // comment out button code, but  leave as a model
        //  return ("    Button  " + this.getName() + " = new Button(" +  "\"" + this.getCaption() + "\"" + "); "  );
        return ("// declare Grid called " + this.getName() +"\n" + "//   Grid " + this.getName() + " = new Grid();");
    }
                                                      

    // controlArrayInitString is similar to declareString, but is used when
    // the original component was part of a control array
    // thisButton[2] = new Button("OK");

    public String controlArrayInitString() {
        // comment out button code, but  leave as a model
        // return ("      " + this.getName() + "[" + getIndex() + "] = new Button(" + "\"" +  this.getCaption() + "\""  + ");"  );

         return (" //    " + this.getName() + "[" + getIndex() + "] = new Grid();"  );

    }

    // addString adds the component to the container
    // defaultAddString is in the parent Control class
    // defaultAddString adds and reshapes the component
    // add(thisButton);
    // thisButton.reshape(1,1,30,30)
    // 

    public String addString( Control cParent) {
        // comment out button code, but  leave as a model
        // return (defaultAddString(cParent));

        String returnString;
        returnString =  "// add the grid \n";
        returnString = returnString + "// rows = " + rows + "\n";
        returnString = returnString + "// cols = " + cols + "\n";
        returnString = returnString + "// fixedRows = " + fixedRows + "\n";
        returnString = returnString + "// fixedCols = " + fixedCols + "\n";
        returnString = returnString + "// gridLineWidth = " + gridLineWidth + "\n";
        returnString = returnString + "// gridLines = " + gridLines + "\n";
        returnString = returnString + "// highLight = " + highLight + "\n";
        return(returnString);
    }

    public void getGridInfo( ) {
      java.util.Enumeration thisInfo;
      ControlData cd;
      ToolkitInfo thisToolkitInfo;
      String  value;      
      String  property;

      property = new String();
      value = new String();

      thisToolkitInfo = new ToolkitInfo();
      

      thisInfo = ControlInfo.elements();
      while(thisInfo.hasMoreElements()){
          cd = (ControlData) thisInfo.nextElement();
          property = cd.getProperty();
          value = cd.getValue();

          if (property.equals("Rows")) {
              rows = new Integer(value).intValue();
//              System.out.println("rows " + rows);
          }
          else if (property.equals("Cols")) {
            cols = new Integer(value).intValue();
          }

          else if (property.equals("FixedRows")) {
              fixedRows = new Integer(value).intValue();
          }
          else if (property.equals("FixedCols")) {
            fixedCols = new Integer(value).intValue();
          }
          else if (property.equals("GridLineWidth")) {
            gridLineWidth = new Integer(value).intValue();
          }

          else if (property.equals("GridLines")) {
            if (value.equals("0")){
               gridLines = false;
            }
            else {
               gridLines = true;
            }
          }
          else if (property.equals("HighLight")) {
            if (value.equals("0")){
               highLight = false;
            }
            else {
               highLight = true;
            }
          }
      } // end while
    }   // end getGridInfo

}
