and I wanted to give the possibility to display an otree in the same xbrowse
the user has to select the tree through a popup menu where I enter all the fields that the tree could do
for example with the archive above in the dialog the tree can be created if all the records have the same province ( FIELD->Prov)
or in an article archive I could make the tree for the category and for another type of data
for example on archive you see on picture I can order for FIELD->PROV
and make a tree for the record have the same field->prov
the end user would have to switch between simple xbrowse and tree xbrowse
I made asmall test but not work good
- Code: Select all Expand view RUN
- #include "FiveWin.ch"
#include "xbrowse.ch"
#include "constant.ch"
REQUEST DBFCDX
function Main()
local oDlg, oBrw,oBarDialog,oGroup
local nBottom := 27.2
local nRight := 89
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local nHt := nBottom * DLG_CHARPIX_H
local aCols := { ;
{ "FIRST", "First" ,, 200, },;
{ "LAST", "Last" ,, 200, },;
{ "CITY", "City" ,, 100, },;
{ "STATE", "State" ,, 80, } }
local bOnSkip := { || oDbf:skip() }
RddSetDefault( "DBFCDX" )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
oDbf:=TCustomer():New()
oDbf:setorder(1)
oDbf:Gotop()
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
FONT oFont TiTle "DBF shown as a tree with XBrowse" COLOR CLR_BLACK, RGB( 245,245,235) ;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX)
DEFINE BUTTONBAR oBarDialog OF oDlg SIZE 80,70 TOP NOBORDER 2015
@ 10, 700 BTNBMP oGroup Prompt "Group" ;
FLAT SIZE 80, 20 OF oDlg PIXEL ;
BITMAP "combo.bmp" RIGHT NOROUND;
ACTION ::ShowPopUp( { |oBtn| changeBrowse( oBtn,oBrw,oDbf ) } )
@ 110,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg NOBORDER
oBrw:SetTree( BuildTree(oDbf), { "open", "close", "go" },bOnSkip)
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "First"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "Last"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 3 ] HEADER "Street"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 4 ] HEADER "City"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 5 ] HEADER "State"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 6 ] HEADER "Zip"
MyStyleBrowse(oBrw)
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "State & City"
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oGroup:nTop := oRect:ntop+81
oGroup:nLeft := oRect:nLeft+10
RETURN nil
>
ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( oDlg:resize() )
return nil
static function changeBrowse( oBtn,oBrw,oDbf )
local oPop
MENU oPop POPUP
MENUITEM "Maketree" action MakeTree(oDbf,oBrw)
SEPARATOR
MENUITEM "Makexbrowse" action MakeBrowse(oBrw,oDbf)
ENDMENU
RETURN oPop
Function MakeBrowse(oBrw,oDbf)
local aCols := { ;
{ "FIRST", "First" ,, 200, },;
{ "LAST", "Last" ,, 200, },;
{ "CITY", "City" ,, 100, },;
{ "STATE", "State" ,, 80, } }
oBrw:SetoDbf( oDbf,aCols)
MyStyleBrowse(oBrw)
oBrw:refresh()
return nil
Function MakeTree(oDbf,oBrw)
local bOnSkip := { || oDbf:skip() }
local aCols := { ;
{ "FIRST", "First" ,, 200, },;
{ "LAST", "Last" ,, 200, },;
{ "CITY", "City" ,, 100, },;
{ "STATE", "State" ,, 80, } }
oDbf:setorder("State")
oDbf:Gotop()
oBrw:SetTree( BuildTree(oDbf), { "open", "close", "go" },bOnSkip)
return nil
Function MyStyleBrowse(oBrw)
local nColorHeader := RGB( 245,245,235)
local nColorFooter := RGB( 245,245,235)
local nColorPigiama := RGB(243,243,238)
WITH OBJECT oBrw
:nRowHeight := 28
: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)
:bRecSelHeader := ""
:bClrSelFocus := { || {,rgb(255,255,224)}}
:bClrRowFocus := { || {, rgb(255,255,224)}}
:nRecSelColor := nRgb( 245,244,234)
:bClrHeader := {|| { ,nColorHeader } }
:bClrFooter := {|| { ,nColorFooter } }
:bClrStd := { || { CLR_BLACK, If( oBrw:KeyNo % 2 == 0, CLR_WHITE,nColorPigiama ) } }
END
return nil
static function BuildTree(oDbf)
local oTree, cState
TREE oTree
while ! oDbf:Eof()
if Empty( cState )
_TreeItem( oDbf:State ):Cargo := { Space( 20 ), Space( 20 ),Space( 20 ), Space( 20 ),Space( 20 ), Space( 20 ) }
TREE
cState = oDbf:State
else
if cState != oDbf:State
ENDTREE
cState = oDbf:State
_TreeItem( oDbf:State ):Cargo := { Space( 20 ), Space( 20 ),Space( 20 ), Space( 20 ),Space( 20 ), Space( 20 ) }
TREE
endif
endif
if oDbf:State == cState
_TreeItem( oDbf:City ):Cargo := { oDbf:First, oDbf:Last, oDbf:street,oDbf:city,oDbf:state,oDbf:zip }
endif
oDbf:skip()
enddo
ENDTREE
ENDTREE
oDbf:gotop()
return oTree
//------------open the dbf
CLASS TXData from TDatabase
ENDCLASS
CLASS TCustomer from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TCustomer
Default lShared := .t.
::super:New(,"customer" ,"DBFCDX", lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self