class SCHEDCOL(parentObj, name) of CONTAINER(parentObj, name) custom
   with (this)
      left = 86
      top = 28
      width = 216
      height = 226
      metric = 6	// Pixels
      borderStyle = 2	// None
   endwith

 

   this.EMPLOYEECOMBO = new COMBOBOX(this)
   with (this.EMPLOYEECOMBO)
      onLeftMouseUp = {;this.parent.container_onGotFocus()}
      height = 20
      left = 0
      top = 0
      width = 214
      fontSize = 8
      colorNormal = "N/white"
      dataSource = form.datamod1.employees1.rowset.fields["name"]
      onChange = {;this.parent.grid1.setFocus();this.parent.onChange()}
      pageno = 0
      style = 2	// DropDown
      dropDownHeight = 132
   endwith

   this.DateButton = new TEXTLABEL(this)
   with (this.DateButton)
      onleftMouseUp = {;this.parent.container_onGotFocus()}
      height = 16
      left = 0
      top = 23
      width = 214
      text = "Sat June 28 1998"
      colorNormal = "black/silver"
      fontSize = 8
      borderStyle = 1	// Raised
      pageno = 0
   endwith


   this.GRID1 = new GRID(this)
   with(this.GRID1)
      onGotFocus = {;this.parent.container_onGotFocus()}
      bgColor = "gray"
      cellHeight = 17
      hasIndicator = false
      rowSelect = true
      allowEditing = false
      allowAddRows = false
      hScrollbar = 0
      vScrollbar = 0
      pageno = 0
      borderStyle = 3 //lowered
      height = 180
      left = 0
      top = 42
      width = 214
   endwith

   /////// Method;    Register /////////////////////////////////////////
   /////// Purpose:   Does datalink, accepts object to notify
   ///////  Notes:	 Call this in the Open() or readModal() of parent form
   ///////				 Also takes 2 "OtherCols", which are the other two
   ///////				 columns in the scheduler, so that when one gets focus,
   ///////				 the others lose it automatically. See SetFocus()

   function Register(nSeqNumber,OtherCol1, OtherCol2, oCalendar)

      ////// Store references to other two columns
      ////// and get a sequence for this one (1,2,3)
      this.cSeqNumber = str(nSeqNumber,1)
      this.OtherCol1  = OtherCol1
      this.OtherCol2  = OtherCol2
      this.oCalendar  = oCalendar 
      this.date = date() // create date property of this container
      this.dateButton.text = cdow(this.date)+' '+;
                             cMonth(this.date)+' '+;
                             str(day(this.date),2)+' '+;
                             str(year(this.date),4)
  
   ////// This method datlinks this container to a SchedTemp rowset
   function Datalink(rSchedTemp)  

      this.rSched = rSchedTemp // rowset for datalink to temp table
    

      this.grid1.dataLink = this.rSched // link to temp table row
      this.grid1.columns["Column1"] = new GRIDCOLUMN( this.grid1)
      this.grid1.columns["Column1"].dataLink = this.rSched.fields["type"+this.cSeqNumber]
      this.grid1.columns["Column1"].editorType = 1	// EntryField
      this.grid1.columns["Column1"].width = 58

      this.grid1.columns["Column2"] = new GRIDCOLUMN(this.grid1)
      this.grid1.columns["Column2"].dataLink = this.rSched.fields["fullname"+this.cSeqNumber]
      this.grid1.columns["Column2"].editorType = 1	// EntryField
      this.grid1.columns["Column2"].width = 200

      
      with (this.grid1.columns["Column1"].editorControl)
         fontSize = 8
         colorNormal = 'white/gray'
      endwith

      with (this.grid1.columns["Column1"].headingControl)
         // Fires "focus" on this container when header clicked
         onLeftMouseUp = {;this.parent.parent.container_OnGotFocus()}
         fontSize = 8
         fontBold = false
         value = "Type"
      endwith

      with (this.grid1.columns["Column2"].editorControl)
         fontSize = 8
         colornormal = 'white/gray'
      endwith

      with (this.grid1.columns["Column2"].headingControl)
         // Fires "focus" on this container when header clicked
         onLeftMouseUp = {;this.parent.parent.container_OnGotFocus()}
         fontSize = 8
         fontBold = false
         value = "With Whom"
      endwith


   /////// Method:	setDate ////////////////////////////////////////////
   /////// Purpose:	gets fired by calendar change and changes the date
   ///////           of this schedule colmn /////////////////////////////

   function setDate(dNewDate)

      this.date = dNewDate
      this.dateButton.text = cdow(this.date)+' '+;
                             cMonth(this.date)+' '+;
                             str(day(this.date),2)+' '+;
                             str(year(this.date),4)
    
      this.onChange()

   /////// Method: 	OnChange ////////////////////////////////////////
   /////// Purpose:	Changes /////////////////
   /////// Called		By the onChange event of combobox and the ////////////
   /////// 				calendar /////////////////////////////////////////////

 
   function OnChange ///// always called through container
      ////// Reload this 
      this.load()
      return true


   function Load

      ////// if no loader object exists
      if type('this.loader') # 'O'
         ////// Create loader object
         set proc to SchedLoad.cc additive
         this.loader = new SchedLoad()
      endif

      // Pad out combobox value
      cEmployee = substr(this.employeeCombo.value+space(24),1,24)

      // reload schedtemp.dbf
      this.loader.loadTempFile(cEmployee,this.date,;
                               val(this.cSeqNumber))
      this.rSched.refreshControls()


   ////// Method:		container_onGotFocus //////////////////////////
   ////// Purpose:	changes color, changes active appointment,
   //////				changes form.oCurrentSchedcol
   function container_onGotFocus

      ////// register as sole owner of Calendar
      if type('form.oCurrentSchedCol') # 'O' or ;
         form.oCurrentSchedCol # this

         this.oCalendar.registerOwners((this), true)

         this.EMPLOYEECOMBO.colorNormal = 'WindowText/0xc2e7f8'

         with(this.grid1)
           bgColor = '0xc2e7f8'
           COLUMNS["Column1"].editorControl.colorNormal = 'WindowText/0xc2e7f8'
           COLUMNS["Column2"].editorControl.colorNormal = 'WindowText/0xc2e7f8'
         endWith

         ////// Decommission the other two columns
     
         this.otherCol1.container_OnLostFocus()
         this.otherCol2.container_onLostFocus() 
             
      endif

      with (form.dataMod1)
      ///// Find children. 
         bm = schedTemp1.rowset.bookmark()
         schedTemp1.rowset.goto(bm)
         schedTemp1.rowset.refreshControls()
         appoints1.rowset.setRange(schedTemp1.rowset.fields["AppointKey"+this.cSeqNumber].value)

         ////// update task button bar
         if (not appoints1.rowset.endOfSet)
            if type('form.ToggleButtons1') = 'O'
               form.toggleButtons1.setTask(appoints1.rowset.fields["type"].value)
            endif
         else
            appoints1.rowset.last()
            appoints1.rowset.next()
            contacts1.rowset.last()
            contacts1.rowset.next()
         endif
      endwith    

      //////  Refresh linked controls
      form.oCurrentSchedCol = this
      return true

   ////// Method: 	Container_onLostFocus ///////////////////////
   ////// Purpose:	Restores this column to "unselected" ////////
   function container_onLostFocus
      this.EMPLOYEECOMBO.colorNormal = 'black/white'

      with(this.grid1)
        COLUMNS["Column1"].editorControl.colorNormal = 'white/gray'
        COLUMNS["Column2"].editorControl.colorNormal = 'white/gray'
        bgcolor = 'gray'
      endWith
      return true

   ////// Method: 	enable() /////////////////////////////////////
   ////// Purpose:	enables or disables controls in this container
   ////// Param		bEnable (turn on or off)
   ////// Call:		Always through container

   function enable(bEnable)
       
       this.employeeCombo.enabled = bEnable
       this.grid1.enabled = bEnable

       return true

   function unRegister
      this.otherCol1 = null
      this.otherCol2 = null
      this.oCalendar = null
      this.rSched = null
      return true

endclass
