268 lines
9.1 KiB
Plaintext
268 lines
9.1 KiB
Plaintext
*--------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
|
|
*--------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
*< FOXBIN2PRG: Version="1.21" SourceFile="gridsort.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
|
|
*
|
|
*
|
|
DEFINE CLASS gridsort AS custom
|
|
*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />
|
|
|
|
*<DefinedPropArrayMethod>
|
|
*m: delidx && Delete IDX files if you use a Table
|
|
*m: gridsort && Sort the column Ascending and Descending
|
|
*m: readme && Read Me First
|
|
*m: settooltip
|
|
*m: showmenu && show a menu containing the name of all column and let user choose to see what he/she wants
|
|
*p: ctooltip
|
|
*p: isdelidx
|
|
*p: ocolumnreference
|
|
*</DefinedPropArrayMethod>
|
|
|
|
*<PropValue>
|
|
ctooltip =
|
|
isdelidx = .T.
|
|
Name = "gridsort"
|
|
ocolumnreference = .NULL.
|
|
Tag = ""
|
|
*</PropValue>
|
|
|
|
PROCEDURE delidx && Delete IDX files if you use a Table
|
|
***************************************************
|
|
* Method........: DelIdx
|
|
* Description...: This method automatically delete Idx files if you use thisa class with a table and set isdelidx to .T.
|
|
* Date..........: 10 January 2006
|
|
* Author........: Ali Mohammad Hosein zadeh
|
|
***************************************************
|
|
RETURN
|
|
|
|
fnum=Adir(fnames,'*.idx')
|
|
For i=1 To fnum
|
|
If 'THISFORM'$Upper(fnames(i,1))
|
|
Delete File Fullpath(fnames(i,1))
|
|
Endif
|
|
Endfor
|
|
|
|
ENDPROC
|
|
|
|
PROCEDURE Destroy
|
|
If This.isdelidx
|
|
This.delidx
|
|
Endif
|
|
|
|
ENDPROC
|
|
|
|
PROCEDURE gridsort && Sort the column Ascending and Descending
|
|
***************************************************
|
|
* Method........: GridSort
|
|
* Description...: This method sort the column that you click
|
|
* Date..........: 02 October 2005
|
|
* Update........: 10 December 2005
|
|
* Author........: Ali Mohammad Hosein zadeh
|
|
***************************************************
|
|
Parameters ocolumn
|
|
Private cobj,fname,fldname,ccount,cstr,nstr,cname
|
|
*!* Procces to get the path to form
|
|
LOCAL lcFname, llReorder
|
|
llReorder = .F.
|
|
|
|
*!* 21.11.2006
|
|
*!* mutu.marius
|
|
&& daca nu se transmite nimic - se ordoneaza dupa ultima coloana ordonata
|
|
IF (PCOUNT() = 0 OR TYPE('oColumn') # 'O') AND !ISNULL(this.oColumnreference)
|
|
oColumn = this.oColumnreference
|
|
llReorder = .T.
|
|
ENDIF
|
|
|
|
IF TYPE('oColumn') # 'O'
|
|
RETURN
|
|
ENDIF
|
|
|
|
IF ISNULL(oColumn)
|
|
RETURN
|
|
ENDIF
|
|
|
|
&& se retine ultima coloana ordonata
|
|
this.oColumnreference = oColumn
|
|
|
|
cstr='ocolumn.'
|
|
nstr=''
|
|
cname=''
|
|
Do While .T.
|
|
cstr=cstr+'parent.'
|
|
nstr=cstr+'baseclass'
|
|
If &nstr='Form'
|
|
Exit
|
|
Else
|
|
nstr=cstr+'name'
|
|
cname=&nstr+'.'+cname
|
|
Endif
|
|
Enddo
|
|
*!* Make a temporary name for Idx file
|
|
cobj='ThisForm.'+cname+ocolumn.Name+"."+ocolumn.CurrentControl+".ControlSource"
|
|
fname = Strtran(cobj,'.','')
|
|
lcfname=ADDBS(SYS(2023)) + fname
|
|
*!* Assign field name to fldname
|
|
fldname=&cobj
|
|
*!* Assign The number or columns to ccount
|
|
cobj="ThisForm."+cname+"COLUMNCOUNT"
|
|
ccount=&cobj
|
|
*!* CLEAR any column's picture
|
|
For i=1 To ccount
|
|
cobj="ThisForm."+cname+"columns("+Alltrim(Str(i))+").header1.picture=''"
|
|
&cobj
|
|
ENDFOR
|
|
*!* Find out if it's first click or DESCENDING order
|
|
If Empty(ocolumn.Tag) OR (ocolumn.Tag="Down" AND !llReorder) OR (llReorder AND ocolumn.Tag="Up")
|
|
*!* INDEX ON field
|
|
IF TYPE(fldname) = 'C'
|
|
lcIndexName = 'left(' + fldname + ', 90)'
|
|
INDEX on &lcIndexName To (lcfname)
|
|
ELSE
|
|
Index On &fldname To (lcfname)
|
|
ENDIF
|
|
*!* SAVE order of column
|
|
ocolumn.Tag="Up"
|
|
*!* Assign the picture
|
|
cobj="ThisForm."+cname+ocolumn.Name+".header1.picture='up.bmp'"
|
|
&cobj
|
|
*!* FINALLY set order
|
|
Set Order To (fname)
|
|
Else
|
|
*!* INDEX ON field
|
|
IF TYPE(fldname) = 'C'
|
|
lcIndexName = 'left(' + fldname + ', 90)'
|
|
INDEX on &lcIndexName To (lcfname)
|
|
ELSE
|
|
Index On &fldname To (lcfname)
|
|
ENDIF
|
|
*!* SAVE order of column
|
|
ocolumn.Tag="Down"
|
|
*!* Assign the picture
|
|
cobj="ThisForm."+cname+ocolumn.Name+".header1.picture='down.bmp'"
|
|
&cobj
|
|
*!* FINALLY set order
|
|
Set Order To (fname) Descending
|
|
Endif
|
|
*!* Refresh the grid
|
|
Go Top
|
|
cobj="ThisForm."+cname+"Refresh"
|
|
&cobj
|
|
|
|
|
|
ENDPROC
|
|
|
|
PROCEDURE Init
|
|
*!* Set Classlib To Locfile('wizbtns','vcx')
|
|
*!* Set Procedure To Locfile('gridproc','prg')
|
|
|
|
ENDPROC
|
|
|
|
PROCEDURE readme && Read Me First
|
|
* **********************************************************************************************
|
|
* GridSort.vcx - Ali Mohammad Hosein Zadeh - info@binyazprograms.com - 10 January 2006 *
|
|
* **********************************************************************************************
|
|
* Updated : 10 January 2006
|
|
* Updated : 10 December 2005
|
|
* **********************************************************************************************
|
|
* Description:
|
|
* ------------
|
|
* A class for Visual FoxPro 8.0,9.0 that do many things for your grid.
|
|
*
|
|
* Class exposes the following methods :
|
|
* ------------------------------------
|
|
* GridSort - Sort the columns ascending or descending automatically
|
|
* SetToolTip - Sets the column's tooltip to it's ControlSource
|
|
* ShowMenu - Show the main menu that you can hide or show colums and you can filter the table or cursor
|
|
* DelIdx - For internal use.Delete Idx files if you use this class with a table and set isdelidx=.T.
|
|
*
|
|
* How to use :
|
|
* ------------
|
|
* Grid Sort :
|
|
* It's enough to write this line in the header's click event:
|
|
* ThisForm.gridsort1.gridsort(This.Parent)
|
|
* SetToolTip :
|
|
* It's enough to write this line in the MouseMove of the column you want :
|
|
* ThisForm.gridsort1.settooltip(This,nXCoord,nYCoord)
|
|
* ShowMenu :
|
|
* It's enough to write this line in the RightClick of the grid you want :
|
|
* Thisform.gridsort1.showmenu(This)
|
|
*
|
|
* Limitations & Disclaimer:
|
|
* -------------------------
|
|
* I authorize gridsort.vcx to be used by anyone for anything in which you would like to use it.
|
|
* Feel free to modify, hack, fold, spindle, mutilate or otherwise alter this class library
|
|
* any way you see fit. You may freely distribute this class library and may even tell
|
|
* your boss that you wrote it, just please don't post it back to the web with your name on it.
|
|
* This class library appears to function correctly but has not been extensively tested.
|
|
*
|
|
* Please E-Mail me if you have any questions, comments, improvements, suggestions, bugs found,
|
|
* bugs fixed or just to say "looky, I'm using it!".
|
|
*
|
|
* **********************************************************************************************
|
|
ENDPROC
|
|
|
|
PROCEDURE settooltip
|
|
***************************************************
|
|
* Method........: SetToolTip
|
|
* Description...: This method sets the column's tooltip that you pass
|
|
* Date..........: 10 January 2006
|
|
* Author........: Ali Mohammad Hosein zadeh
|
|
***************************************************
|
|
Lparameters ocolumn,x,Y
|
|
Local nRelRow_Out, nRelCol_Out,nWhere_Out
|
|
ocolumn.Parent.SetFocus()
|
|
ocolumn.Parent.Gridhittest(x,Y,@nWhere_Out,@nRelRow_Out,@nRelCol_Out)
|
|
ocolumn.Parent.ActivateCell(nRelRow_Out, nRelCol_Out)
|
|
If This.ctooltip<>Eval("ocolumn." + ocolumn.CurrentControl + ".value")
|
|
This.ctooltip=ocolumn.Parent.ToolTipText
|
|
ocolumn.Parent.ToolTipText=Eval("alltrim(ocolumn." + ocolumn.CurrentControl + ".value)")
|
|
Endif
|
|
|
|
ENDPROC
|
|
|
|
PROCEDURE showmenu && show a menu containing the name of all column and let user choose to see what he/she wants
|
|
***************************************************
|
|
* Method........: ShowMenu
|
|
* Description...: Show the main menu
|
|
* Date..........: 10 January 2006
|
|
* Author........: Ali Mohammad Hosein zadeh
|
|
***************************************************
|
|
Parameters ogrid
|
|
If Type("ogrid")<>"O"
|
|
Return
|
|
ENDIF
|
|
|
|
Dimension nmenus(ogrid.ColumnCount,2)
|
|
|
|
For i=1 To ogrid.ColumnCount
|
|
nmenus(i,1)=ogrid.Columns(i).header1.Caption
|
|
nmenus(i,2)=ogrid.Columns(i).Visible
|
|
ENDFOR
|
|
|
|
Define Popup popmenus SHORTCUT Relative From Mrow(),Mcol()
|
|
|
|
Define Bar 1 Of popmenus Prompt "All"
|
|
Define Bar 2 Of popmenus Prompt "Costum"
|
|
Define Bar 3 Of popmenus Prompt "\-"
|
|
|
|
Set Mark Of Bar 1 Of popmenus Empty(Filter())
|
|
Set Mark Of Bar 2 Of popmenus !Empty(Filter())
|
|
|
|
On Selection Bar 1 Of popmenus Do All In gridproc
|
|
On Selection Bar 2 Of popmenus Do custom_filter In gridproc
|
|
|
|
For i=4 To Alen(nmenus,1)+3
|
|
Define Bar i Of popmenus Prompt nmenus(i-3,1)
|
|
Set Mark Of Bar i Of popmenus To nmenus(i-3,2)
|
|
cstr="ogrid.Columns("+Alltrim(Str(i-3))+").visible=!ogrid.Columns("+Alltrim(Str(i-3))+").visible"
|
|
On Selection Bar i Of popmenus &cstr
|
|
ENDFOR
|
|
|
|
ogrid.Refresh
|
|
|
|
Activate Popup popmenus
|
|
|
|
ENDPROC
|
|
|
|
ENDDEFINE
|