*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="scrollcontainer.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS _scrollcontainer AS _container OF "_baza.vcx" 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_sus1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_jos1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adaugaobiect		&& Adauga un obiect la container.
		*m: do_initializeaza
		*m: do_initializeazaobiect
		*m: do_redimensioneaza
		*m: do_scrolldown
		*m: do_scrollup
		*m: do_stergeobiect		&& Sterge un obiect din container.
		*p: cultimulobiect		&& Numele ultimului obiect adaugat.
		*p: nactualheight		&& Distanta de la marginea de sus a ferestrei pana la marginea inferioara a celui mai de jos obiect.
		*p: nactualwidth		&& Distanta de la marginea din stanga a ferestrei pana la marginea din dreapta a celui mai din dreapta obiect.
		*p: nheightoffset		&& Distanta pe verticala dintre doua obiecte.
		*p: nmaxheight		&& Inaltimea maxima vizibila a containerului.
		*p: nmaxwidth		&& Latimea maxima vizibila a containerului.
		*p: nnrobiecte		&& Numarul actual de obiecte din container.
		*p: nnrobiectebottom		&& Numarul de obiecte care se afla sub linia de vizibilitate.
		*p: nnrobiectetop		&& Numarul de obiecte care se afla deasupra liniei de vizibilitate.
		*p: nnrobiectevizibile		&& Numarul maxim de obiecte vizibile la un moment dat.
		*p: nwidthoffset		&& Distanta pe orizontala dintre doua obiecte.
	*</DefinedPropArrayMethod>

	PROTECTED nnrobiectebottom,nnrobiectetop,nnrobiectevizibile
	*<PropValue>
		cultimulobiect = 
		Height = 250
		nactualheight = 0
		nactualwidth = 0
		Name = "_scrollcontainer"
		nheightoffset = 0
		nmaxheight = 0
		nmaxwidth = 0
		nnrobiecte = 0
		nnrobiectebottom = 0
		nnrobiectetop = 0
		nnrobiectevizibile = 0
		nwidthoffset = 0
		Width = 409
	*</PropValue>

	ADD OBJECT 'But_jos1' AS but_jos WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_jos1", ;
		Top = 33, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sus1' AS but_sus WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_sus1", ;
		Top = 4, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE do_adaugaobiect		&& Adauga un obiect la container.
		Lparameters tcNume,tcClasa,toHash
		With This
			If Type('toHash') <> 'O'
				.AddObject(tcNume,tcClasa)
			Else
				.AddObject(tcNume,tcClasa,toHash)
			EndIf
			.nnrobiecte=.nnrobiecte+1
			.&tcNume..Top=.nactualheight+.nheightoffset
			.&tcNume..Left=3
			.nactualheight=.&tcNume..Top+.&tcNume..Height
			Do Case
			Case .nnrobiecte-.nnrobiectetop>.nnrobiectevizibile
				.but_jos1.Visible=.T.
			Case .nnrobiecte<=.nnrobiectevizibile And .nnrobiectetop=0
				.nmaxheight=.nactualheight+.nheightoffset
				.Height=.nmaxheight
			Otherwise
				.but_jos1.Visible=.F.
			Endcase
			.cultimulobiect=tcNume
		Endwith
		
	ENDPROC

	PROCEDURE do_initializeaza
		Lparameters tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		If Type('tnDistantaVObiecte')<>'N'
			tnDistantaVObiecte=0
		Endif
		If Type('tnDistandaOObiecte')<>'N'
			tnDistandaOObiecte=0
		Endif
		
		This.nnrobiectevizibile=tnNrObiecteVizibile
		This.nheightoffset=tnDistantaVObiecte
		This.nwidthoffset=tnDistandaOObiecte
		This.Top=tnTop
		This.Left=tnLeft
		This.Width=tnWidth
		This.BorderWidth=0
	ENDPROC

	PROCEDURE do_initializeazaobiect
		Lparameters tcNume,tcClasa
		With This
			.AddObject(tcNume,tcClasa)
			.nnrobiecte=.nnrobiecte+1
			.&tcNume..Top=.nactualheight+.nheightoffset
			.&tcNume..Left=3
			.nactualheight=.&tcNume..Top+.&tcNume..Height
			Do Case
			Case .nnrobiecte=.nnrobiectevizibile
				.nmaxheight=.nactualheight+.nheightoffset
			Case .nnrobiecte>.nnrobiectevizibile
				.but_jos1.Visible=.T.
				.cultimulobiect=tcNume
			Case .nnrobiectetop=0
				.nmaxheight=.&tcNume..Top+.&tcNume..Height
			Endcase
		Endwith
		
	ENDPROC

	PROCEDURE do_redimensioneaza
		This.Height=This.nmaxheight
		This.but_jos1.Left=This.Width-This.but_jos1.Width
		This.but_sus1.Left=This.Width-This.but_sus1.Width
	ENDPROC

	PROCEDURE do_scrolldown
		With This
			.nnrobiectetop=.nnrobiectetop+1
			lnMinTop=0
			For i=1 To .Objects.Count
				With This.Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top-.Height-This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			.nactualheight=.&lcUltimulObiect..Top+.&lcUltimulObiect..Height
			If lnMinTop<0
				.but_sus1.Visible=.T.
			Endif
			If .&lcUltimulObiect..Top<.nmaxheight
				.but_jos1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_scrollup
		With This
			.nnrobiectetop=.nnrobiectetop-1
			lnMaxTop=0
			lnMinTop=.nmaxheight
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top+.Height+This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
						lnMaxTop=Max(lnMaxTop,.Top+.Height)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			With .&lcUltimulObiect.
				This.nactualheight=.Top+.Height
			Endwith
			If lnMaxTop>.nmaxheight
				.but_jos1.Visible=.T.
			Else
				.but_jos1.Visible=.F.
			Endif
			If lnMinTop>0
				.but_sus1.Visible=.F.
			Else
				.but_sus1.Visible=.T.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_stergeobiect		&& Sterge un obiect din container.
		Lparameters tcNume
		With This
			lcUltimulObiect=[]
			lnMaxHeight=Iif(.nnrobiecte>1,-50000,0)
			lnTopObiectSters=.&tcNume..Top
			lnHeightObiectSters=.&tcNume..Height
			.RemoveObject(tcNume)
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						If Between(lnTopObiectSters,0,.Top)
							.Top=.Top-lnHeightObiectSters-This.nheightoffset
						Else
							If Between(lnTopObiectSters,.Top,0)
								.Top=.Top+lnHeightObiectSters+This.nheightoffset
							Endif
						Endif
						If .Top+.Height>lnMaxHeight
							lcUltimulObiect=.Name
							lnMaxHeight=.Top+.Height
						Endif
					Endif
				Endwith
			Endfor
			.nnrobiectetop=.nnrobiectetop+Iif(lnTopObiectSters<0,-1,0)
			.nnrobiecte=.nnrobiecte-1
			.nactualheight = lnMaxHeight
			If Type("this."+.cultimulobiect)='U'
				.cultimulobiect=lcUltimulObiect
			Endif
			If .nnrobiectetop=0
				.but_sus1.Visible=.F.
			Endif
			If .nnrobiecte<=.nnrobiectevizibile+.nnrobiectetop
				.but_jos1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE Init
		Lparameters tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		DoDefault()
		This.do_initializeaza(tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte)
		This.do_redimensioneaza()
	ENDPROC

	PROCEDURE MouseWheel
		Lparameters nDirection, nShift, nXCoord, nYCoord
		If nDirection>0 And This.but_sus1.Visible
			This.do_scrollup
		Endif
		If nDirection<0 And This.but_jos1.Visible
			This.do_scrolldown
		Endif
		
	ENDPROC

	PROCEDURE Resize
		DoDefault()
		This.do_redimensioneaza()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS _scrollcontainer1201 AS _container OF "_baza.vcx" 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_sus1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_jos1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adaugaobiect		&& Adauga un obiect la container.
		*m: do_initializeaza
		*m: do_redimensioneaza
		*m: do_scrolldown
		*m: do_scrollup
		*m: do_stergeobiect		&& Sterge un obiect din container.
		*p: cultimulobiect		&& Numele ultimului obiect adaugat.
		*p: nactualheight		&& Distanta de la marginea de sus a ferestrei pana la marginea inferioara a celui mai de jos obiect.
		*p: nactualwidth		&& Distanta de la marginea din stanga a ferestrei pana la marginea din dreapta a celui mai din dreapta obiect.
		*p: nheightoffset		&& Distanta pe verticala dintre doua obiecte.
		*p: nmaxheight		&& Inaltimea maxima vizibila a containerului.
		*p: nmaxwidth		&& Latimea maxima vizibila a containerului.
		*p: nnrobiecte		&& Numarul actual de obiecte din container.
		*p: nnrobiectetop		&& Numarul de obiecte care se afla deasupra liniei de vizibilitate.
		*p: nnrobiectevizibile		&& Numarul maxim de obiecte vizibile la un moment dat.
		*p: nwidthoffset		&& Distanta pe orizontala dintre doua obiecte.
	*</DefinedPropArrayMethod>

	*<PropValue>
		cultimulobiect = 
		Height = 250
		nactualheight = 0
		nactualwidth = 0
		Name = "_scrollcontainer"
		nheightoffset = 0
		nmaxheight = 0
		nmaxwidth = 0
		nnrobiecte = 0
		nnrobiectetop = 0
		nnrobiectevizibile = 0
		nwidthoffset = 0
		Width = 409
	*</PropValue>

	ADD OBJECT 'But_jos1' AS but_jos WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_jos1", ;
		Top = 33, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sus1' AS but_sus WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_sus1", ;
		Top = 4, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE do_adaugaobiect		&& Adauga un obiect la container.
		Lparameters tcNume,tcClasa
		With This
			.AddObject(tcNume,tcClasa)
			.nnrobiecte=.nnrobiecte+1
		&&	.nactualheight se modifica la stergere
		*!*		STRTOFILE("Adaugat obiect>>	Actual height:"+ALLTRIM(STR(.nactualheight)),"C:\startroa.txt",1)
			.&tcNume..Top=.nactualheight+.nheightoffset
			.&tcNume..Left=3
		*!*		.&tcNume..AddProperty("nordine_container",.nnrobiecte)
			.nactualheight=.&tcNume..Top+.&tcNume..Height
		*!*		STRTOFILE("; Top:"+ALLTRIM(STR(.&tcNume..Top))+"; nr.obiecte:"+ALLTRIM(STR(.nnrobiecte))+;
		*!*			"; Actual height:"+ALLTRIM(STR(.nactualheight))+CHR(13)+CHR(10),"C:\startroa.txt",1)
			Do Case
			Case .nnrobiecte=.nnrobiectevizibile
				.nmaxheight=.nactualheight+.nheightoffset
			Case .nnrobiecte>.nnrobiectevizibile
				.but_jos1.Visible=.T.
				.cultimulobiect=tcNume
			Case .nnrobiectetop=0
				.nmaxheight=.&tcNume..Top+.&tcNume..Height
		*!*		Case .nnrobiecte=.nnrobiectevizibile-.nnrobiectetop
		*!*			.nmaxheight=.nactualheight+.nheightoffset
		*!*		Case .nnrobiecte-.nnrobiectetop>.nnrobiectevizibile
		*!*			.but_jos1.Visible=.T.
		*!*			.cultimulobiect=tcNume
		*!*		Case .nnrobiecte>.nnrobiectevizibile
		*!*			.but_jos1.Visible=.T.
		*!*			.cultimulobiect=tcNume
		*!*		Case .nnrobiectetop=0
		*!*			.nmaxheight=.&tcNume..Top+.&tcNume..Height
			Endcase
		*!*		If .nactualheight>.nmaxheight
		*!*	*!*			.&tcNume..Visible=.F.
		*!*			.but_jos1.Visible=.T.
		*!*	*!*		Else
		*!*		Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_initializeaza
		Lparameters tnNrObiecteVizibile,tnDistantaVObiecte,tnDistantaOObiecte
		If Type('tnDistantaVObiecte')='U'
			tnDistantaVObiecte=0
		Endif
		If Type('tnDistandaOObiecte')='U'
			tnDistandaOObiecte=0
		Endif
		
		This.nnrobiectevizibile=tnNrObiecteVizibile
		This.nheightoffset=tnDistantaVObiecte
		This.nwidthoffset=tnDistandaOObiecte
		This.BorderWidth=0
	ENDPROC

	PROCEDURE do_redimensioneaza
		This.Height=This.nmaxheight
		This.but_jos1.Left=This.Width-This.but_jos1.Width
		This.but_sus1.Left=This.Width-This.but_sus1.Width
	ENDPROC

	PROCEDURE do_scrolldown
		With This
			.nnrobiectetop=.nnrobiectetop+1
			lnMinTop=0
			For i=1 To .Objects.Count
				With This.Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top-.Height-This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			.nactualheight=.&lcUltimulObiect..Top+.&lcUltimulObiect..Height
			If lnMinTop<0
				.but_sus1.Visible=.T.
			Endif
			If .&lcUltimulObiect..Top<.nmaxheight
				.but_jos1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_scrollup
		With This
			.nnrobiectetop=.nnrobiectetop-1
			lnMaxTop=0
			lnMinTop=.nmaxheight
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top+.Height+This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
						lnMaxTop=Max(lnMaxTop,.Top+.Height)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			With .&lcUltimulObiect.
				This.nactualheight=.Top+.Height
			Endwith
			If lnMaxTop>.nmaxheight
				.but_jos1.Visible=.T.
			Else
				.but_jos1.Visible=.F.
			Endif
			If lnMinTop>0
				.but_sus1.Visible=.F.
			Else
				.but_sus1.Visible=.T.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_stergeobiect		&& Sterge un obiect din container.
		Lparameters tcNume
		With This
			lnMaxHeight=0
			lnTopObiectSters=.&tcNume..Top
			lnHeightObiectSters=.&tcNume..Height
			lcPenultimulObiect=[]
			lnNrObiecteInvizibile=0
			.RemoveObject(tcNume)
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						If .Top>lnTopObiectSters
							.Top=.Top-lnHeightObiectSters-This.nheightoffset
						Else
							If .Top<0
								lnNrObiecteInvizibile=lnNrObiecteInvizibile+1
							Endif
						Endif
		*!*	*!*					If .Top+.Height>lnMaxHeight
		*!*	*!*						lnMaxHeight=.Top+.Height
		*!*	*!*					ENDIF
		*!*					If .nordine_container=This.nnrobiecte-1
		*!*						lcUltimulObiect=.Name
		*!*						lnMaxHeight=.Top+.Height
		*!*					Endif
						If This.nactualheight-lnHeightObiectSters-This.nheightoffset=.Top+.Height
							lcPenultimulObiect=.Name
							lnMaxHeight=.Top+.Height
						Endif
					Endif
				Endwith
			Endfor
			.nnrobiecte=.nnrobiecte-1
			.nactualheight = lnMaxHeight
			If Type("this."+.cultimulobiect)='U'
				.cultimulobiect=lcPenultimulObiect
			Endif
		*!*		STRTOFILE("Sters obiect>>	Top:"+ALLTRIM(STR(lnTopObiectSters))+"; nr.obiecte ramase:"+ALLTRIM(STR(.nnrobiecte))+;
		*!*			"; Actual height:"+ALLTRIM(STR(.nactualheight))+CHR(13)+CHR(10),"C:\startroa.txt",1)		
			If .nnrobiecte=.nnrobiectevizibile And lnNrObiecteInvizibile=0
				.but_jos1.Visible=.F.
				.but_sus1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE Init
		Lparameters tnNrObiecteVizibile,tnDistantaVObiecte,tnDistantaOObiecte
		DoDefault()
		This.do_initializeaza(tnNrObiecteVizibile,tnDistantaVObiecte,tnDistantaOObiecte)
	ENDPROC

	PROCEDURE MouseWheel
		Lparameters nDirection, nShift, nXCoord, nYCoord
		If nDirection>0 And This.but_sus1.Visible
			This.do_scrollup
		Endif
		If nDirection<0 And This.but_jos1.Visible
			This.do_scrolldown
		Endif
		
	ENDPROC

	PROCEDURE Resize
		DoDefault()
		This.do_redimensioneaza()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS _scrollcontainer1301 AS _container OF "_baza.vcx" 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_sus1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_jos1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adaugaobiect		&& Adauga un obiect la container.
		*m: do_initializeaza
		*m: do_initializeazaobiect
		*m: do_redimensioneaza
		*m: do_scrolldown
		*m: do_scrollup
		*m: do_stergeobiect		&& Sterge un obiect din container.
		*p: cultimulobiect		&& Numele ultimului obiect adaugat.
		*p: nactualheight		&& Distanta de la marginea de sus a ferestrei pana la marginea inferioara a celui mai de jos obiect.
		*p: nactualwidth		&& Distanta de la marginea din stanga a ferestrei pana la marginea din dreapta a celui mai din dreapta obiect.
		*p: nheightoffset		&& Distanta pe verticala dintre doua obiecte.
		*p: nmaxheight		&& Inaltimea maxima vizibila a containerului.
		*p: nmaxwidth		&& Latimea maxima vizibila a containerului.
		*p: nnrobiecte		&& Numarul actual de obiecte din container.
		*p: nnrobiectebottom		&& Numarul de obiecte care se afla sub linia de vizibilitate.
		*p: nnrobiectetop		&& Numarul de obiecte care se afla deasupra liniei de vizibilitate.
		*p: nnrobiectevizibile		&& Numarul maxim de obiecte vizibile la un moment dat.
		*p: nwidthoffset		&& Distanta pe orizontala dintre doua obiecte.
	*</DefinedPropArrayMethod>

	PROTECTED nnrobiectebottom,nnrobiectetop,nnrobiectevizibile
	*<PropValue>
		cultimulobiect = 
		Height = 250
		nactualheight = 0
		nactualwidth = 0
		Name = "_scrollcontainer"
		nheightoffset = 0
		nmaxheight = 0
		nmaxwidth = 0
		nnrobiecte = 0
		nnrobiectebottom = 0
		nnrobiectetop = 0
		nnrobiectevizibile = 0
		nwidthoffset = 0
		Width = 409
	*</PropValue>

	ADD OBJECT 'But_jos1' AS but_jos WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_jos1", ;
		Top = 33, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sus1' AS but_sus WITH ;
		Anchor = 8, ;
		Left = 379, ;
		Name = "But_sus1", ;
		Top = 4, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE do_adaugaobiect		&& Adauga un obiect la container.
		Lparameters tcNume,tcClasa
		With This
			.AddObject(tcNume,tcClasa)
			.nnrobiecte=.nnrobiecte+1
			.&tcNume..Top=.nactualheight+.nheightoffset
			.&tcNume..Left=3
			.nactualheight=.&tcNume..Top+.&tcNume..Height
			Do Case
			Case .nnrobiecte-.nnrobiectetop>.nnrobiectevizibile
				.but_jos1.Visible=.T.
			Case .nnrobiecte<=.nnrobiectevizibile
				.nmaxheight=.nactualheight+.nheightoffset
				.Height=.nmaxheight
			Otherwise
				.but_jos1.Visible=.F.
			Endcase
			.cultimulobiect=tcNume
		Endwith
		
	ENDPROC

	PROCEDURE do_initializeaza
		Lparameters tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		If Type('tnDistantaVObiecte')<>'N'
			tnDistantaVObiecte=0
		Endif
		If Type('tnDistandaOObiecte')<>'N'
			tnDistandaOObiecte=0
		Endif
		
		This.nnrobiectevizibile=tnNrObiecteVizibile
		This.nheightoffset=tnDistantaVObiecte
		This.nwidthoffset=tnDistandaOObiecte
		This.Top=tnTop
		This.Left=tnLeft
		This.Width=tnWidth
		This.BorderWidth=0
	ENDPROC

	PROCEDURE do_initializeazaobiect
		Lparameters tcNume,tcClasa
		With This
			.AddObject(tcNume,tcClasa)
			.nnrobiecte=.nnrobiecte+1
			.&tcNume..Top=.nactualheight+.nheightoffset
			.&tcNume..Left=3
			.nactualheight=.&tcNume..Top+.&tcNume..Height
			Do Case
			Case .nnrobiecte=.nnrobiectevizibile
				.nmaxheight=.nactualheight+.nheightoffset
			Case .nnrobiecte>.nnrobiectevizibile
				.but_jos1.Visible=.T.
				.cultimulobiect=tcNume
			Case .nnrobiectetop=0
				.nmaxheight=.&tcNume..Top+.&tcNume..Height
			Endcase
		Endwith
		
	ENDPROC

	PROCEDURE do_redimensioneaza
		This.Height=This.nmaxheight
		This.but_jos1.Left=This.Width-This.but_jos1.Width
		This.but_sus1.Left=This.Width-This.but_sus1.Width
	ENDPROC

	PROCEDURE do_scrolldown
		With This
			.nnrobiectetop=.nnrobiectetop+1
		*!*		.nnrobiectebottom=.nnrobiectebottom-1
			lnMinTop=0
			For i=1 To .Objects.Count
				With This.Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top-.Height-This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			.nactualheight=.&lcUltimulObiect..Top+.&lcUltimulObiect..Height
			If lnMinTop<0
				.but_sus1.Visible=.T.
			Endif
			If .&lcUltimulObiect..Top<.nmaxheight
				.but_jos1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_scrollup
		With This
			.nnrobiectetop=.nnrobiectetop-1
		*!*		.nnrobiectebottom=.nnrobiectebottom+1
			lnMaxTop=0
			lnMinTop=.nmaxheight
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top+.Height+This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
						lnMaxTop=Max(lnMaxTop,.Top+.Height)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			With .&lcUltimulObiect.
				This.nactualheight=.Top+.Height
			Endwith
			If lnMaxTop>.nmaxheight
				.but_jos1.Visible=.T.
			Else
				.but_jos1.Visible=.F.
			Endif
			If lnMinTop>0
				.but_sus1.Visible=.F.
			Else
				.but_sus1.Visible=.T.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_stergeobiect		&& Sterge un obiect din container.
		Lparameters tcNume
		With This
			lnMaxHeight=0
			lnTopObiectSters=.&tcNume..Top
			lnHeightObiectSters=.&tcNume..Height
			lcPenultimulObiect=[]
			lnNrObiecteInvizibile=0
			.RemoveObject(tcNume)
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						If .Top>lnTopObiectSters
							.Top=.Top-lnHeightObiectSters-This.nheightoffset
						Else
							If .Top<0
								lnNrObiecteInvizibile=lnNrObiecteInvizibile+1
							Endif
						Endif
						If This.nactualheight-lnHeightObiectSters-This.nheightoffset=.Top+.Height
							lcPenultimulObiect=.Name
							lnMaxHeight=.Top+.Height
						Endif
					Endif
				Endwith
			Endfor
			.nnrobiecte=.nnrobiecte-1
			.nactualheight = lnMaxHeight
			If Type("this."+.cultimulobiect)='U'
				.cultimulobiect=lcPenultimulObiect
			Endif
			If .nnrobiecte=.nnrobiectevizibile And lnNrObiecteInvizibile=0
				.but_jos1.Visible=.F.
				.but_sus1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE Init
		Lparameters tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		DoDefault()
		This.do_initializeaza(tnNrObiecteVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte)
		This.do_redimensioneaza()
	ENDPROC

	PROCEDURE MouseWheel
		Lparameters nDirection, nShift, nXCoord, nYCoord
		If nDirection>0 And This.but_sus1.Visible
			This.do_scrollup
		Endif
		If nDirection<0 And This.but_jos1.Visible
			This.do_scrolldown
		Endif
		
	ENDPROC

	PROCEDURE Resize
		DoDefault()
		This.do_redimensioneaza()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS _scrollcontainer_col AS _container OF "_baza.vcx" 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="But_sus1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_jos1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adaugaobiect		&& Adauga un obiect la container.
		*m: do_cauta
		*m: do_cautaobiect
		*m: do_initializeaza
		*m: do_initializeazaobiect
		*m: do_redimensioneaza
		*m: do_scrolldown
		*m: do_scrollup
		*m: do_stergeobiect		&& Sterge un obiect din container.
		*m: do_stergeobiecte
		*p: cultimulobiect		&& Numele ultimului obiect adaugat.
		*p: lcoloanemultiple		&& .T.  - daca obiectele sunt aranjate pe mai multe coloane ( in functie de nmaxwidth si de nwidthoffset )
		*p: nactualheight		&& Distanta de la marginea de sus a ferestrei pana la marginea inferioara a celui mai de jos obiect.
		*p: nactualwidth		&& Distanta de la marginea din stanga a ferestrei pana la marginea din dreapta a celui mai din dreapta obiect.
		*p: nheightoffset		&& Distanta pe verticala dintre doua obiecte.
		*p: nmaxheight		&& Inaltimea maxima vizibila a containerului.
		*p: nmaxwidth		&& Latimea maxima vizibila a containerului.
		*p: nnrranduri		&& Numarul actual de randuri din container.
		*p: nnrranduribottom		&& Numarul de randuri care se afla sub linia de vizibilitate.
		*p: nnrranduritop		&& Numarul de randuri care se afla deasupra liniei de vizibilitate.
		*p: nnrrandurivizibile		&& Numarul maxim de randuri vizibile la un moment dat.
		*p: nwidthoffset		&& Distanta pe orizontala dintre doua obiecte.
	*</DefinedPropArrayMethod>

	PROTECTED nactualheight,nactualwidth,nmaxheight,nmaxwidth,nnrranduri,nnrranduribottom,nnrranduritop
	*<PropValue>
		cultimulobiect = 
		Height = 250
		lcoloanemultiple = .F.
		nactualheight = 0
		nactualwidth = 0
		Name = "_scrollcontainer_col"
		nheightoffset = 0
		nmaxheight = 0
		nmaxwidth = 0
		nnrranduri = 0
		nnrranduribottom = 0
		nnrranduritop = 0
		nnrrandurivizibile = 0
		nwidthoffset = 0
		Width = 409
	*</PropValue>

	ADD OBJECT 'But_jos1' AS but_jos WITH ;
		Left = 379, ;
		Name = "But_jos1", ;
		Top = 33, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sus1' AS but_sus WITH ;
		Left = 379, ;
		Name = "But_sus1", ;
		Top = 4, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE do_adaugaobiect		&& Adauga un obiect la container.
		Lparameters tcNume,tcClasa,toHash
		With This
			If Type('toHash') <> 'O'
				.AddObject(tcNume,tcClasa)
			Else
				.AddObject(tcNume,tcClasa,toHash)
			Endif
		
			If .lcoloanemultiple And .nactualwidth + .nwidthoffset + .&tcNume..Width <= .nmaxwidth AND .nactualwidth <> .nwidthoffset
				.&tcNume..Left=.nactualwidth + .nwidthoffset
			Else
				.&tcNume..Left = .nwidthoffset
				.nactualheight = .nactualheight + IIF(.nnrranduri=0,0,.&tcNume..Height+.nheightoffset)
				.nnrranduri = .nnrranduri + 1
			Endif
			.nactualwidth = .&tcNume..Left + .&tcNume..Width
			.&tcNume..Top = .nactualheight
			If Pemstatus(.&tcNume.,[nnrrandsccont],5)
				.&tcNume..nnrrandsccont = .nnrranduri
			Else
				AddProperty(.&tcNume.,[nnrrandsccont],.nnrranduri)
			Endif
			Do Case
			Case .nnrranduri-.nnrranduritop>.nnrrandurivizibile
				.but_jos1.Visible=.T.
			Case .nnrranduri<=.nnrrandurivizibile And .nnrranduritop=0
				.nmaxheight = .nactualheight + IIF(.nnrranduri=0,0,.&tcNume..Height+.nheightoffset)
				.Height=.nmaxheight
			Otherwise
				.but_jos1.Visible=.F.
			Endcase
			.cultimulobiect=tcNume
		Endwith
	ENDPROC

	PROCEDURE do_cauta
		Lparameters tnTip,tcCriteriu,tcClasa
		*!*	tnTip =	1	-	este
		*!*			2	-	incepe cu ...
		Local lcObiect,lcConditieC
		Do Case
		Case tnTip = 1
			lcConditieC = [UPPER(This.Objects(i).Caption) = '] + Upper(tcCriteriu) + [']
		Case tnTip = 2
			lcConditieC = [UPPER(SUBSTR(This.Objects(i).Caption,1,] + Alltrim(Str(Len(tcCriteriu))) + [)) = ] + ;
				['] + Upper(tcCriteriu) + [']
		Endcase
		For i = 1 To This.Objects.Count
			If Upper(This.Objects(i).Class) = Upper(tcClasa)
				If Evaluate(lcConditieC)
					lcObiect = This.Objects(i).Name
					Exit
				Endif
			Endif
		Endfor
		If !Empty(lcObiect)
			This.do_cautaobiect(lcObiect)
		Else
			amessagebox("Nu exista rezultate!",48,"Atentie")
		Endif
	ENDPROC

	PROCEDURE do_cautaobiect
		Lparameters tcNumeObiect
		Local lnNrRand,llVizibil
		lnNrRand = Evaluate([This.] + tcNumeObiect + [.nnrrandsccont])
		llVizibil = This.Visible
		IF llVizibil
			This.Visible = !llVizibil
		ENDIF
		Do While .T.
			Do Case
			Case lnNrRand < This.nnrranduritop + 1
				This.do_scrollup()
			Case lnNrRand > This.nnrranduritop + 1
				This.do_scrolldown()
			Otherwise
				This.&tcNumeObiect..SetFocus()
				Exit
			Endcase
		Enddo
		IF llVizibil
			This.Visible = llVizibil
		ENDIF
	ENDPROC

	PROCEDURE do_initializeaza
		Lparameters tnNrRanduriVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		If Type('tnDistantaVObiecte')<>'N'
			tnDistantaVObiecte=0
		Endif
		If Type('tnDistandaOObiecte')<>'N'
			tnDistandaOObiecte=0
		Endif
		
		This.nnrrandurivizibile=tnNrRanduriVizibile
		This.nheightoffset=tnDistantaVObiecte
		This.nwidthoffset=tnDistantaOObiecte
		This.nactualheight = This.nheightoffset
		This.nactualwidth = This.nwidthoffset
		This.Top=tnTop
		This.Left=tnLeft
		This.Width=tnWidth
		This.BorderWidth=0
	ENDPROC

	PROCEDURE do_initializeazaobiect
		Lparameters tcNume,tcClasa,toHash
		With This
			If Type('toHash') <> 'O'
				.AddObject(tcNume,tcClasa)
			Else
				.AddObject(tcNume,tcClasa,toHash)
			Endif
		
			*!*	am pus .nmaxwidth in loc de .Width
			If .lcoloanemultiple And .nactualwidth + .nwidthoffset + .&tcNume..Width <= .nmaxwidth AND .nactualwidth <> .nwidthoffset
				.&tcNume..Left=.nactualwidth + .nwidthoffset
			Else
				.&tcNume..Left = .nwidthoffset
				.nactualheight = .nactualheight + IIF(.nnrranduri=0,0,.&tcNume..Height+.nheightoffset)
				.nnrranduri = .nnrranduri + 1
			Endif
			.nactualwidth = .&tcNume..Left + .&tcNume..Width
			.&tcNume..Top = .nactualheight
			Do Case
			Case .nnrranduri-.nnrranduritop>.nnrrandurivizibile
				.but_jos1.Visible=.T.
			Case .nnrranduri<=.nnrrandurivizibile And .nnrranduritop=0
				.nmaxheight = .nactualheight  + IIF(.nnrranduri=0,0,.&tcNume..Height+.nheightoffset)
				.Height=.nmaxheight
			Otherwise
				.but_jos1.Visible=.F.
			Endcase
		
		*!*		Do Case
		*!*		Case .nnrobiecte=.nnrrandurivizibile
		*!*			.nmaxheight=.nactualheight+.nheightoffset
		*!*		Case .nnrobiecte>.nnrrandurivizibile
		*!*			.but_jos1.Visible=.T.
		*!*			.cultimulobiect=tcNume
		*!*		Case .nnrobiectetop=0
		*!*			.nmaxheight=.&tcNume..Top+.&tcNume..Height
		*!*		Endcase
		Endwith
		
	ENDPROC

	PROCEDURE do_redimensioneaza
		This.Height=This.nmaxheight
		This.but_jos1.Left=This.Width-This.but_jos1.Width-FLOOR(This.but_jos1.Width/9)
		This.but_sus1.Left=This.Width-This.but_sus1.Width-FLOOR(This.but_sus1.Width/9)
		This.nmaxwidth = This.but_sus1.Left
	ENDPROC

	PROCEDURE do_scrolldown
		With This
			.nnrranduritop=.nnrranduritop+1
			lnMinTop=0
			For i=1 To .Objects.Count
				With This.Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top-.Height-This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			.nactualheight = .&lcUltimulObiect..Top + .&lcUltimulObiect..Height
			If lnMinTop<0
				.but_sus1.Visible=.T.
			Endif
			If .&lcUltimulObiect..Top<.nmaxheight
				.but_jos1.Visible=.F.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_scrollup
		With This
			.nnrranduritop=.nnrranduritop-1
			lnMaxTop=0
			lnMinTop=.nmaxheight
			For i=1 To .Objects.Count
				With .Objects(i)
					If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
						.Top=.Top+.Height+This.nheightoffset
						lnMinTop=Min(lnMinTop,.Top)
						lnMaxTop=Max(lnMaxTop,.Top+.Height)
					Endif
				Endwith
			Endfor
			lcUltimulObiect=.cultimulobiect
			With .&lcUltimulObiect.
				This.nactualheight=.Top+.Height
			Endwith
			If lnMaxTop>.nmaxheight
				.but_jos1.Visible=.T.
			Else
				.but_jos1.Visible=.F.
			Endif
			If lnMinTop>0
				.but_sus1.Visible=.F.
			Else
				.but_sus1.Visible=.T.
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE do_stergeobiect		&& Sterge un obiect din container.
		*!*	Lparameters tcNume
		*!*	With This
		*!*		lcUltimulObiect=[]
		*!*		lnMaxHeight=Iif(.nnrobiecte>1,-50000,0)
		*!*		lnTopObiectSters=.&tcNume..Top
		*!*		lnHeightObiectSters=.&tcNume..Height
		*!*		.RemoveObject(tcNume)
		*!*		For i=1 To .Objects.Count
		*!*			With .Objects(i)
		*!*				If !Inlist(Upper(Alltrim(.Class)),[BUT_SUS],[BUT_JOS])
		*!*					If Between(lnTopObiectSters,0,.Top)
		*!*						.Top=.Top-lnHeightObiectSters-This.nheightoffset
		*!*					Else
		*!*						If Between(lnTopObiectSters,.Top,0)
		*!*							.Top=.Top+lnHeightObiectSters+This.nheightoffset
		*!*						Endif
		*!*					Endif
		*!*					If .Top+.Height>lnMaxHeight
		*!*						lcUltimulObiect=.Name
		*!*						lnMaxHeight=.Top+.Height
		*!*					Endif
		*!*				Endif
		*!*			Endwith
		*!*		Endfor
		*!*		.nnrobiectetop=.nnrobiectetop+Iif(lnTopObiectSters<0,-1,0)
		*!*		.nnrobiecte=.nnrobiecte-1
		*!*		.nactualheight = lnMaxHeight
		*!*		If Type("this."+.cultimulobiect)='U'
		*!*			.cultimulobiect=lcUltimulObiect
		*!*		Endif
		*!*		If .nnrobiectetop=0
		*!*			.but_sus1.Visible=.F.
		*!*		Endif
		*!*		If .nnrobiecte<=.nnrrandurivizibile+.nnrobiectetop
		*!*			.but_jos1.Visible=.F.
		*!*		Endif
		*!*	Endwith
		
	ENDPROC

	PROCEDURE do_stergeobiecte
		Lparameters tcClasaObiect
		Local i,j
		j = 0
		With This
			Dimension laObiecte[.Objects.Count]
			For i=1 To .Objects.Count
				With .Objects(i)
					If Upper(Alltrim(.Class)) = Upper(Alltrim(tcClasaObiect))
						j = j + 1
						laObiecte[j] = Upper(.Name)
					Endif
				Endwith
			Endfor
		Endwith
		For i = 1 To j
			This.RemoveObject(laObiecte[i])
		Endfor
		*!*	resetare
		This.nactualheight = This.nheightoffset
		This.nactualwidth = This.nwidthoffset
		This.nmaxheight = 0
		This.but_jos1.Visible = .F.
		This.but_sus1.Visible = .F.
		This.nnrranduri = 0
		This.nnrranduritop = 0
		RELEASE laObiecte
	ENDPROC

	PROCEDURE Init
		Lparameters tnNrRanduriVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte
		DoDefault()
		tnNrRanduriVizibile = Iif(Empty(tnNrRanduriVizibile),This.nnrrandurivizibile,tnNrRanduriVizibile)
		tnTop = Iif(Empty(tnTop),This.Top,tnTop)
		tnLeft = Iif(Empty(tnLeft),This.Left,tnLeft)
		tnWidth = Iif(Empty(tnWidth),This.Width,tnWidth)
		tnDistantaVObiecte = Iif(Empty(tnDistantaVObiecte),This.nwidthoffset,tnDistantaVObiecte)
		tnDistantaOObiecte = Iif(Empty(tnDistantaOObiecte),This.nheightoffset,tnDistantaOObiecte)
		This.do_initializeaza(tnNrRanduriVizibile,tnTop,tnLeft,tnWidth,tnDistantaVObiecte,tnDistantaOObiecte)
		This.do_redimensioneaza()
	ENDPROC

	PROCEDURE MouseWheel
		Lparameters nDirection, nShift, nXCoord, nYCoord
		If nDirection>0 And This.but_sus1.Visible
			This.do_scrollup
		Endif
		If nDirection<0 And This.but_jos1.Visible
			This.do_scrolldown
		Endif
		
	ENDPROC

	PROCEDURE Resize
		DoDefault()
		This.do_redimensioneaza()
		
	ENDPROC

ENDDEFINE
