Function SVC_SubClass_DropDown(Service, Param1, Param2, Param3, Param4)

/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to 
    be copied without written permission from SRP Computer Solutions, Inc. 

    Name    	:   SVC Subclass Dropdown

    Description : 

    Tags		:	[SRP]

    Parameters  : 
        CtrlId	 [in] -- Control that contains the dropdown															
	    Type	 [in] -- Dropdown in (E)dittable or Edit(L)ine														
	    Cell	 [in] -- Sub-class control if necessary																
	    Params   [in] -- Any additional parameters						
	    List	[out] -- The full list if needed by the calling program	

    History (Date, Initials, Notes) 
        04/11/06    fjt		Initial development
        11/03/09	fjt		Moved to IR/EPI
				
********************************************************************************************************/ 

$insert SRP_APP_INSERTS
$insert SERVICE_INSERT

Declare subroutine	Btree.Extract, Update_Index
Declare function	SRP_Sort_Array, SRP_Rotate_Array, SRP_Reorder_Array

GoSub Init
Begin Case
	Case Type EQ "Sched Events"			; GoSub Scheduler_Events
		
End Case
If Data then GoSub Finalize

Return Ans
	
	
!----- INTERNAL ROUTINES --------------------------------------------------------------------------------


Init:
	Transfer Service to Type
	Transfer Param1  to CtrlId
	Transfer Param2  to Cell
	Transfer Param3  to Params
	Transfer Param4  to List
	
	ProgId  = Get_Property(CtrlId, "OLE.ProgID")
	Vals	= ""
	List	= ""
	Data	= ""
	LenPos  = 1
	
	MasterCol   = Params<1>
	Cols		= Params<2>
	AutoFillCol = Params<3>
	ResetOnly   = Params<4>
	
	If Cols			else Cols = "L":@STM:300:@TM:"R":@STM:100
	If AutoFillCol	else AutoFillCol = 1
	If ResetOnly EQ "" then ResetOnly = No$
	
	Show = No$
	SortOrder = "AL1":@FM:"AL1"
return


Finalize:
	// Sort
	!!! Data = SRP_Sort_Array(Data, SortOrder, 0)
	List = Data
	Swap @VM with @STM in Data
	Swap @FM with @TM  in Data
	
	Vals<2, 2> = Cols			;// Column Settings
	Vals<2, 3> = Data			;// Data
	Vals<2, 4> = MasterCol		;// Master Column Number - The column containing the return values    
	Vals<2, 5> = True$			;// Autofill - Boolean If true, then autofill is enabled    
	Vals<2, 6> = False$			;// Case Sensitive Autofill - Boolean If true, then autofill is case sensitive 
	Vals<2, 7> = 25				;// Number of Visible Rows - Integer The number of viewable rows at a time    
	Vals<2, 8> = False$			;// Fire OnOptionClick - Boolean If true, fire the OnOptionClick when user presses dropdown button    
	Vals<2, 9> = True$			;// Filtered Autofill - Boolean If true, reduce the list to only those items that partially match the current contents    
	Vals<2,10> = Show			;// Show Dropdown Immediately - Boolean If true, shows the dropdown as soon as user enters edit mode    
	Vals<2,11> = False$			;// LIST Format - Boolean If true, then the data is in LIST format and not ARRAY format    
	Vals<2,12> = AutoFillCol	;// Autofill Column Number - The column against which autofill is performed    
	Vals<2,13> = True$			;// Hide When Empty - Boolean If true, then the dropdown hides when the user clears the cell
	Vals<2,14> = True$			;// Normal Navigation - Boolean If true, then the up/down/pgup/pgdown keys navigate to other cells when the drop down is hidden    
	* Vals<2,15> = ""			;// Show Only When Empty - Boolean If true and Show Immediately is true, then the dropdown only shows immediately when the cell's contents are empty    
	* Vals<2,16> = ""			;// No Show Autofill - Boolean If true, then the drop down does not appear during autofill
	Vals<2,17> = True$			;// Clear the selection in the popup whenever the user presses backspace or delete during autofill
	
	Begin Case
		
		Case (ProgID _EQC "SRP.EditTable.1")
			Vals<1> = "Combo"
			Set_Property(CtrlId, "OLE.CellType[":Cell:"]", Vals)
		
		Case (ProgID EQ "" and ResetOnly EQ Yes$)
			Convert "." to ";" in CtrlId
			Set_Property(@Window:".OLE_SUBCLASS", "OLE.ComboData[":CtrlId:"]", Data)
		
		Case (ProgID EQ "")
			Vals<1> = 1
			Handle = Get_Property(CtrlId, "HANDLE")
			rv = Send_Message(@Window:".OLE_SUBCLASS", "OLE.Subclass", Handle, CtrlID)
			Convert "." to ";" in CtrlId
			Set_Property(@Window:".OLE_SUBCLASS", "OLE.Combo[":CtrlId:"]", Vals)
			
	End Case
return


!----- DROPDOWN DATA TYPES ------------------------------------------------------------------------------


Scheduler_Events:
    Cols        = "L":@STM:250
    AutoFillCol = 1
	MasterCol   = 1
	SortOrder   = "AL1"
	
	Array = ""
    Array<-1> = "Annual P.M."
    Array<-1> = "Bell Jar Charge"
    Array<-1> = "CTC Change"
    Array<-1> = "Down for Engineering Testing"
    Array<-1> = "Down to Maintenance"
    Array<-1> = "Down – No Material"
    Array<-1> = "Open"
    Array<-1> = "Scrubber Work"
    Array<-1> = "Semi Annual PM"
	Array<-1> = "Tube Change"
	Array<-1> = 'Conversion to 4"'
	Array<-1> = 'Conversion to 5"'
	Array<-1> = 'Conversion to 6"'
	Array<-1> = 'Conversion to 8"'
	Array<-1> = 'Conversion to AP'
	Array<-1> = 'Conversion to RP'
			
    Convert @FM to @VM in Array
    Data = Array
return


