// Using Windows 7 row selection colors in xbrowse
#include 'fivewin.ch'
#include 'xbrowse.ch'
request dbfcdx
function Main()
local oDlg, oBrw, oFont
local oBtn1,oBtn2
local oDbf
oDbf:= TCustomer():New()
oDbf:SetOrder(1)
oDbf:gotop()
// USE CUSTOMER ALIAS CUST
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
FONT oFont TITLE 'XBrowse Gradient Rows'
@ 30, 10 XBROWSE oBrw OF oDlg SIZE 300, 200 PIXEL ;
AUTOCOLS DATASOURCE oDbf NOBORDER
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLWIN7
oBrw:CreateFromCode()
oBrw:bRClicked := {|nRow,nCol| Display_Menu(oDlg,nRow,nCol,oDbf,oBrw) }
@ 8, oBrw:nWidth-200 BTNBMP oBtn1;
FLAT SIZE 60, 12 OF oDlg PIXEL ;
PROMPT "btn1" RIGHT ;
COLOR CLR_BLACK,nRgb(238,236,219) ;
BITMAP "SOR_TDW" NOROUND ;
ACTION ::ShowPopUp( { | oBtn,nRow,nCol | Menu_btn1(oBtn,oBrw,oDbf,nRow,ncol,oDlg) } )
@ 8, oBrw:nWidth-100 BTNBMP oBtn2;
FLAT SIZE 60, 12 OF oDlg PIXEL ;
PROMPT "btn2" RIGHT ;
COLOR CLR_BLACK,nRgb(238,236,219) ;
BITMAP "SOR_TDW" NOROUND ;
ACTION ::ShowPopUp( { |oBtn| MenuContextual(oBtn,oBrw,oDbf,oDlg) } )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//---------------------------------------------------------------------------------//
Function Display_Menu(oParent,nRow,nCol,oDbf,oBrw)
local oMenu
MENU oMenu POPUP
MENUITEM "al primo record " +space(6)+ CHR(VK_TAB) + "Ctrl+Home";
MESSAGE "Mostra la lista dal primo record";
RESOURCE "GRID_TOP";
ACTION oBrw:KeyDown(VK_HOME, 0) WHEN oDbf:OrdKeyCount() > 0
MENUITEM "a pagina prec. " +space(6)+ CHR(VK_TAB) + "Pag. Sù";
MESSAGE "Mostra la lista della pagina precedente";
RESOURCE "GRID_PREVIOUS";
ACTION oBrw:KeyDown(VK_PRIOR, 0) WHEN oDbf:OrdKeyCount() > 0
MENUITEM "al precedente record " +space(6)+ CHR(VK_TAB) + "Indietro";
MESSAGE "Mostra la lista muovendosi al record precedente ";
RESOURCE "GRID_UP";
ACTION oBrw:KeyDown(VK_UP, 0) WHEN oDbf:OrdKeyCount() > 0
MENUITEM "avanti di un record " + CHR(VK_TAB) +space(6)+ "Avanti";
MESSAGE "Mostra la lista muovendosi al record avanti";
RESOURCE "GRID_DOWN";
ACTION oBrw:KeyDown(VK_DOWN, 0) WHEN oDbf:OrdKeyCount() > 0
MENUITEM "a pag. avanti " +space(6)+ CHR(VK_TAB) + "Pag. Giù";
MESSAGE "Mostra la lista della pagina avanti";
RESOURCE "GRID_NEXT";
ACTION oBrw:KeyDown(VK_NEXT, 0) WHEN oDbf:OrdKeyCount() > 0
MENUITEM "all'ultimo record " +space(6)+ CHR(VK_TAB) + "Ctrl+End";
MESSAGE "Mostra la lista all'ultimo record";
RESOURCE "GRID_BOTTOM";
ACTION oBrw:KeyDown(VK_END, 0) WHEN oDbf:OrdKeyCount() > 0
ENDMENU
ACTIVATE POPUP oMenu OF oParent AT oBrw:nTop+nRow, oBrw:nLeft+nCol
RETURN (NIL)
//---------------------------------------------------------------------------------//
Function Menu_btn1(oBtn,oBrw,oDbf,nRow,ncol,oDlg)
local oPop
local oCol, cPrompt
local nFor, nLen
local cPrvGrp := ""
local oGrpMenu
local lChecked
nLen := Len( oBrw:aCols )
MENU oPop POPUP
//-----------------------------------init-from xbrowse--------------------//
for nFor := 1 to nLen
oCol := oBrw:aCols[ nFor ]
if !( IfNil( oCol:cGrpHdr, "" ) == cPrvGrp )
if ! Empty( cPrvGrp )
ENDMENU
oGrpMenu := nil
endif
if ! Empty( oCol:cGrpHdr )
MENUITEM oCol:cGrpHdr BOLD
MENU
MENUITEM oGrpMenu PROMPT oCol:cGrpHdr BOLD ;
ACTION ( lChecked := oMenuItem:lChecked, ;
AEval( oMenuItem:Cargo, ;
{ |o| If( lChecked, o:Hide(), o:Show() ) } ) )
oGrpMenu:Cargo := {}
SEPARATOR
endif
cPrvGrp := IfNil( oCol:cGrpHdr, "" )
endif
MenuAddItem( If( Empty( oCol:cHeader ), "Col-" + cValToChar( nFor ), oCol:cHeader ), ;
nil, !oCol:lHide, ;
( Len(oBrw:aDisplay) != 1 .or. ocol:nPos != 1 ), ;
{ |o| If( o:Cargo:lHide, o:Cargo:Show(), o:Cargo:Hide() ) } ):Cargo := oCol
if oGrpMenu != nil
AAdd( oGrpMenu:Cargo, oCol )
if !oCol:lHide
oGrpMenu:lChecked := .t.
endif
endif
next
//------------------------------------end from xbrowse--------------------//
SEPARATOR
MenuItem "Posizione Colonne" action nil
ENDMENU
return oPop
//------------------------------------------------------------------------//
Function MenuContextual(oBtn,oBrw,oDbf,oDlg)
local oMenu,oCol, cPrompt
local nFor, nLen
local cPrvGrp := ""
local oGrpMenu
local lChecked
nLen := Len( oBrw:aCols )
MENU oMenu POPUP
if oBrw:IsSelectedRow()
MENUITEM "Deseleziona la riga corrente" action (oBrw:SelectRow( 0 ))
MENUITEM "Deseleziona tutto" action (oBrw:SelectRow( 0 ))
MENUITEM "Stampa le righe selezionate" action NIL
MENUITEM "Esporta le righe selezionate" action NIL
else
MENUITEM "Seleziona la riga corrente" action ( oBrw:SelectRow( 2 ) )
MENUITEM "Seleziona tutto" action (oBrw:SelectRow( 4 ) )
MENUITEM "Stampa" action NIL
If lExport
MENUITEM "Esporta" action NIL
Endif
endif
MENUITEM "Colonne"
MENU
//--------------------------------------------------------//
for nFor := 1 to nLen
oCol := oBrw:aCols[ nFor ]
if !( IfNil( oCol:cGrpHdr, "" ) == cPrvGrp )
if ! Empty( cPrvGrp )
ENDMENU
oGrpMenu := nil
endif
if ! Empty( oCol:cGrpHdr )
MENUITEM oCol:cGrpHdr BOLD
MENU
MENUITEM oGrpMenu PROMPT oCol:cGrpHdr BOLD ;
ACTION ( lChecked := oMenuItem:lChecked, ;
AEval( oMenuItem:Cargo, ;
{ |o| If( lChecked, o:Hide(), o:Show() ) } ) )
oGrpMenu:Cargo := {}
SEPARATOR
endif
cPrvGrp := IfNil( oCol:cGrpHdr, "" )
endif
MenuAddItem( If( Empty( oCol:cHeader ), "Col-" + cValToChar( nFor ), oCol:cHeader ), ;
nil, !oCol:lHide, ;
( Len(oBrw:aDisplay) != 1 .or. ocol:nPos != 1 ), ;
{ |o| If( o:Cargo:lHide, o:Cargo:Show(), o:Cargo:Hide() ) } ):Cargo := oCol
if oGrpMenu != nil
AAdd( oGrpMenu:Cargo, oCol )
if !oCol:lHide
oGrpMenu:lChecked := .t.
endif
endif
next
SEPARATOR
MenuItem "Posizione Colonne" ACTION NIL //
//--------------------------------------------------------//
ENDMENU
ENDMENU
return oMenu
CLASS TXData from TDataBase
DATA cDbfPath INIT cFilePath( ExeName() ) + ".\"
ENDCLASS
CLASS TCustomer from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TCustomer
Default lShared := .t.
::Super:Open(,::cDbfPath + "Customer" ,"DBFCDX", lShared)
if ::Used()
::setOrder(1)
::GoTop()
endif
return Self