#include "fivewin.ch"
#include 'xbrowse.ch'
#include "constant.ch"
Function test()
local oDlg
local cSection:="ARCHIVIO"
local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "test.ini"
local cMese := GetIni( cInifile, cSection,"Mesi", "111111111101" )
local oLbxMesi
local aMesi := {"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto",;
"Settembre", "Ottobre", "Novembre", "Dicembre"}
local cTitle:="test Custom xbrowse"
local oBtnOk,oBtnClose,oBtnHelp
local nBottom := 35
local nRight := 90
local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight := nBottom * DLG_CHARPIX_H
local oBtnLbx:=array(2)
local nRow,nCol
local oGrp:=array(1)
local aTitleLbx:={"Mesi"}
local n,oFont,oBold
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 12
DEFINE FONT oBold NAME "MS Sans Serif" SIZE 0, 12 BOLD
DEFINE DIALOG oDlg ;
SIZE nWidth, nHeight PIXEL ;
TITLE cTitle //STYLE WS_POPUP
nRow:=121
nCol:=5
@ nrow-6, nCol GROUP oGrp[1] TO nRow+11,nCol+79 PIXEL of oDlg TRANSPARENT
@ nRow,nCol+2 Say aTitleLbx[1] Size 40,10 PIXEL of oDlg Font oBold
nCol+=60
@ nRow ,nCol BTNBMP oBtnLbx[1] FILENAME".\bitmaps\ok.png" ;
of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.t.) NOBORDER
nCol+=10
@ nRow ,nCol BTNBMP oBtnLbx[2] FILENAME".\bitmaps\no.png";
of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.f.) NOBORDER
oLbxMesi:=TXbrCheck():New(132, 5, 80, 110, oDlg)
oLbxMesi:HasBorder(.f.) // nStyle(WS_NOBORDER)
oLbxMesi:setarray(aMesi)
oLbxMesi:SetMultiSelectCol()
oLbxMesi:aCols[1]:cHeader := i18n("Mesi")
oLbxMesi:aCols[1]:nWidth := 100
oLbxMesi:CreateFromCode()
For n=1 to len(aMesi)
* oLbxMesi:aSelected[n]:= IIF( SubStr(cMese, n, 1)== "1",.t.,.f.)
next
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBtnOk:nTop := oRect:nBottom - 40
oBtnOK:nLeft := oRect:nRight - 310
oBtnClose:nTop := oRect:nBottom - 40
oBtnClose:nLeft := oRect:nRight - 210
oBtnHelp:nTop := oRect:nBottom - 40
oBtnHelp:nLeft := oRect:nRight - 110
return nil
>
@ 100,10 BUTTON oBtnok PROMPT "OK" of oDlg SIZE 45,15 DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 100,10 BUTTON oBtnClose PROMPT "EXIT" of oDlg SIZE 45,15 CANCEL ACTION ( oDlg:end( IDCANCEL ) )
@ 100,10 BUTTON oBtnHelp PROMPT "HELP" of oDlg SIZE 45,15 CANCEL ACTION NIL
ACTIVATE DIALOG oDlg center ;
ON INIT (eval(oDlg:bResized) )
IF oDlg:nresult == IDOK
cMese:=""
for n=1 to 12
cmese+= IIf(oBrwMesi:aselected[n]=.t.,"1","0")
Next
//saving
WritePProString(cSection,"Mesi",cMese,cInifile)
ENDIF
RETURN NIL
//-----------------------------------------------------------------------//
Static Function Select_all(oLbx,lValue)
If lvalue
oLbx:SelectRow( 4 ) // Select all
else
oLbx:SelectRow( 0 ) // clear all i.e., select none
Endif
return nil
//--------------------------------------------------------------------------//
//------------------------ CLASS CustomBrowse ...........................//
CLASS TXbrCheck FROM TXBrowse
CLASSDATA lRegistered AS LOGICAL
METHOD New (nRow, nCol, nWidth, nHeight, oWnd)
METHOD aInfo()
ENDCLASS
METHOD New(nRow, nCol, nWidth, nHeight, oWnd) CLASS TXbrCheck
local lPixel:=.t.
::nTop := nRow * If( lPixel, 1, BRSE_CHARPIX_H ) // 14
::nLeft := nCol * If( lPixel, 1, BRSE_CHARPIX_W ) //8
::oWnd := oWnd
if nWidth != nil
if nWidth <= 0
::nRightMargin := -nWidth
if ::oWnd:IsKindOf( "TDIALOG" ) .and. Empty( ::oWnd:hWnd ) .and. !::oWnd:lTruePixel
::nRightMargin *= 2
endif
else
::nRight := ::nLeft + nWidth - 1
endif
endif
if nHeight != nil
if nHeight <= 0
::nBottomMargin := -nHeight
if ::oWnd:IsKindOf( "TDIALOG" ) .and. Empty( ::oWnd:hWnd ) .and. !::oWnd:lTruePixel
::nBottomMargin *= 2
endif
else
::nBottom := ::nTop + nHeight - 1
endif
endif
::nMarqueeStyle := MARQSTYLE_NOMARQUEE
::nColDividerStyle := LINESTYLE_LIGHTGRAY
::lColDividerComplete := .t.
::lRecordSelector := .f.
::lHScroll := .f.
::lVScroll := .f.
::nHeaderHeight := 20
::nRowHeight := 17
::l2007 := .f.
::nStretchCol := -1
::lDrawBorder := .t.
::lHeader := .f.
::nRecSelColor := nRgb( 245,244,234)
* ::SetMultiSelectCol()
return ::SuPer:New()
METHOD aInfo() CLASS TXbrCheck
local aInfo := {}
local n
local nLen:= Len( ::aSelected )
for n := 1 to nLen
aadd( aInfo, ::aselected[n] )
next
return aInfo
function GetIni( cIni, cSection, cEntry, xDefault )
local oIni
local xVar := xDefault
INI oIni FILE cIni
get xVar ;
SECTION cSection ;
ENTRY cEntry ;
default xDefault ;
OF oIni
ENDINI
return xVar
Function setcheckbrw(oLbx)
WITH OBJECT oLbx
:nMarqueeStyle := MARQSTYLE_NOMARQUEE
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:lColDividerComplete := .t.
:lRecordSelector := .f.
:lHScroll := .f.
:lVScroll := .f.
:nHeaderHeight := 20
:nRowHeight := 17
:l2007 := .f.
:nStretchCol := -1
:lDrawBorder := .t.
:lHeader := .f.
:nRecSelColor := nRgb( 245,244,234)
:SetMultiSelectCol()
:CreateFromCode()
END
return nil