#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"
#include "report.ch"
Function test()
local oDlg,oDbf,oFont
local oBar,aBtnBar:=array(8)
local aBtnBrow
local nBottom := 27.2
local nRight := 89
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local nHt := nBottom * DLG_CHARPIX_H
oDbf :=TDatabase():Open( , "Customer", "DBFCDX", .T. )
oDbf:setorder(1)
oDbf:Gotop()
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
TiTle "test"
@ 110,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE oDbf AUTOCOLS ;
AUTOSORT FONT oFont;
NOBORDER CELL LINES
WITH OBJECT oBrw
:nRowHeight := 25
:l2007 := .F.
:l2015 := .T.
:lRecordSelector := .F.
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nStretchCol := STRETCHCOL_WIDEST
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:lAllowSizings := .F.
:lDrawBorder := .t.
:nClrBorder := Rgb(195,195,185)
:bClrStd := { || { CLR_BLACK, If( oBrw:KeyNo % 2 == 0, CLR_WHITE,RGB(243,243,238)) } }
END
WITH OBJECT oBrw
:bLClicked := { || ;
If( oBrw:IsSelectedRow(), ;
Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw), ;
Btnbar(2,oDlg:oBar,oDlg,oDbf,oBrw)) }
:SetMultiSelectCol()
:CreateFromCode()
END
@ 85, 10 BTNBMP aBtnBrow ;
FLAT SIZE 80, 20 OF oDlg PIXEL ;
PROMPT "Select menu" ;
NOROUND ;
ACTION ::ShowPopUp( { |oBtn| MenuContextual(oBtn,oBrw,oDbf,oDlg) } )
ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( Btnbar(0,oBar,oDlg,oDbf,oBrw),;
Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw),;
ChangeButtons( oDlg:oBar ) )
RETURN NIL
//---------------------------------------------------------------------------------//
Function Btnbar(nBar,oBar,oDlg,oDbf,oBrw) // ,aBtnBar
local aBtnBar
local x
if Valtype( oBar ) = "O"
For x := Len( oBar:aControls ) to 1 step - 1
oBar:Del( x )
Next x
endif
Do case
case nbar = 0
DEFINE BUTTONBAR oBar OF oDlg SIZE 80,70 TOP NOBORDER 2015
case nbar = 1
aBtnBar := array(6)
DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "New" ACTION NIL
DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Modify" ACTION NIL
DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Duplicate" ACTION NIL
DEFINE BUTTON aBtnBar[4] OF oBar PROMPT "Del" ACTION NIL
DEFINE BUTTON aBtnBar[5] OF oBar PROMPT "Print" action oBrw:Report( )
DEFINE BUTTON aBtnBar[6] OF oBar PROMPT "HElp" ACTION NIL BTNRIGHT
case nbar = 2
aBtnBar := array(3)
DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "Del" ACTION NIL
DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Print" action oBrw:Report( )
DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Help" ACTION NIL BTNRIGHT
endcase
return oBar
//-------------------------------------------------------------------------------//
function ChangeButtons( oBar )
AEval( oBar:aControls, { | oCtrl | oCtrl:nTop += 4, oCtrl:nHeight -= 4 } )
return .T.
//-------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------//
Function MenuContextual(oControl,oBrw,oDbf,oParent)
local oMenu
MENU oMenu POPUP
if oBrw:IsSelectedRow()
MENUITEM "Deselect row" action (oBrw:SelectRow( 0 ) , Btnbar(1,oParent:oBar,oParent,oDbf,oBrw))
else
MENUITEM "Select row" action (oBrw:SelectRow( 2 ), Btnbar(2,oParent:oBar,oParent,oDbf,oBrw) )
endif
SEPARATOR
MENUITEM "Print" action oBrw:Report( )
ENDMENU
return oMenu
//-------------------------------------------------------------------------------//