I am creating an application for management of motor vehicles.
I want on xbrowse on fiels color show the real color I selected
see the picture pls.
#include "FiveWin.ch"
#include "xbrowse.ch"
// xbrowse imagen button get
function main()
local oDlg, oBrw
local aArray := {}
local uVal
local nI
local oGet
local nWdGet := 0
for nI = 1 to 20
aadd( aArray, { StrZero(nI,2),;
"Row:"+StrZero(nI,2)+" Col:02",;
"Row:"+StrZero(nI,2)+" Col:03",;
"Row:"+StrZero(nI,2)+" Col:04",;
"Row:"+StrZero(nI,2)+" Col:05",;
"Row:"+StrZero(nI,2)+" Col:06" } )
next
DEFINE DIALOG oDlg Title "Test xBrowse " size 700,300
oBrw:= txbrowse():new( oDlg )
oBrw:nRowHeight := 25
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:SetArray( aArray )
oBrw:CreateFromCode()
oBrw:aCols[ 2 ]:bClrStd := {|o| ChangeColor( o, oBrw ) }
oBrw:aCols[ 2 ]:bClrSelFocus := {|o| ChangeColor( o, oBrw ) }
oDlg:oClient := oBrw
ACTIVATE DIALOG oDlg center on init oDlg:Resize()
return nil
function ChangeColor( oCol, oBrw )
local aClrs := eval( oBrw:bClrStd )
DO CASE
CASE oBrw:aRow[ 1 ] == "01"
aClrs[ 2 ] := CLR_GREEN
CASE oBrw:aRow[ 1 ] == "02"
aClrs[ 2 ] := CLR_YELLOW
CASE oBrw:aRow[ 1 ] == "03"
aClrs[ 2 ] := CLR_BLUE
CASE oBrw:aRow[ 1 ] == "04"
aClrs[ 2 ] := CLR_CYAN
OTHERWISE
aClrs[ 2 ] := CLR_HRED
ENDCASE
return aClrs
METHOD Select( nOperation ) CLASS TXBrowse
local uBook, uCurRow, uOldRow, uTemp
local aTemp
local nAt, nLen
local lRefresh
if ::nMarqueeStyle != MARQSTYLE_HIGHLROWMS
return nil
endif
if VALTYPE ( Eval( ::bSelected, Self ) ) != "L" //daniel
msgalert( "Invalid CodeBlock ::bSelected", "FiveWin, Class TXBrowse" ) //daniel
return nil //daniel
endif //daniel
DEFAULT nOperation := 1
do case
case nOperation == 0 // delete all
if Len( ::aSelected ) == 1 .and. Eval( ::bBookMark ) == ::aSelected[ 1 ]
lRefresh := .f.
else
lRefresh := .t.
endif
::aSelected := {}
if ! Empty( ::nSaveMarq )
::nMarqueeStyle := ::nSaveMarq
::nSaveMarq := nil
endif
if lRefresh
// ::lRefreshOnlyData := .t.
::GetDC()
::Super:Refresh( .t. ) // ::Paint()
::ReleaseDC()
endif
case nOperation == 1 .or. ( Len( ::aSelected ) == 0 .and. nOperation != 4 )// Add current
uBook := Eval( ::bBookMark )
nAt := Ascan( ::aSelected, uBook )
if nAt == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uBook )
::DrawLine( .t. )
endif
case nOperation == 2 // Swap key (Ctrl+LClick)
uBook := Eval( ::bBookMark )
nAt := Ascan( ::aSelected, uBook )
if nAt > 0
::DrawLine( .f. )
::aSelected[ nAt ] := Atail( ::aSelected )
Asize( ::aSelected, Len( ::aSelected ) - 1 )
else
if Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, Eval( ::bBookMark ))
::DrawLine( .t. )
endif //daniel
endif
case nOperation == 3 // Shift & lclick
uBook := Eval( ::bBookMark )
uCurRow := ::KeyNo()
Eval( ::bBookMark, Atail( ::aSelected ) )
uOldRow := ::KeyNo()
if uOldRow != uCurRow
::aSelected := { Atail( ::aSelected ) }
if uCurRow > uOldRow
CursorWait()
do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Eof()
If Ascan( ::aSelected, uTemp ) == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uTemp )
Endif
::Skip( 1 ) // Eval( ::bSkip, 1 )
enddo
CursorArrow()
else
CursorWait()
do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Bof()
If Ascan( ::aSelected, uTemp ) == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uTemp )
endif
::Skip( -1 ) // Eval( ::bSkip, -1 )
enddo
CursorArrow()
endif
if Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uBook )
endif
Eval( ::bBookMark, uBook )
// ::lRefreshOnlyData := .t.
::GetDC()
::Paint()
::ReleaseDC()
else
Eval( ::bBookMark, uBook )
endif
case nOperation == 4 // Select all
uBook := Eval( ::bBookMark )
::aSelected := Array( ::KeyCount() )
nAt := 1
nLen := ::nLen
aTemp := ::aSelected
CursorWait()
Eval( ::bGotop )
do while nAt <= nLen //.and. !Eval( ::bEof )
if Eval( ::bSelected, Self ) //daniel
aTemp[ nAt++ ] := Eval( ::bBookMark )
endif
::Skip( 1 ) //Eval( ::bSkip, 1 )
enddo
Eval( ::bBookMark, uBook )
CursorArrow()
// ::lRefreshOnlyData := .t.
::GetDC()
::Paint()
::ReleaseDC()
end case
return nil
#include "FiveWin.ch"
#include "xbrowse.ch"
// xbrowse imagen button get
function main()
local oDlg, oBrw
local aArray := {}
local uVal
local nI
local oGet
local nWdGet := 0
for nI = 1 to 20
aadd( aArray, { StrZero(nI,2),;
"Row:"+StrZero(nI,2)+" Col:02",;
"Row:"+StrZero(nI,2)+" Col:03",;
"Row:"+StrZero(nI,2)+" Col:04",;
"Row:"+StrZero(nI,2)+" Col:05",;
"Row:"+StrZero(nI,2)+" Col:06" } )
next
DEFINE DIALOG oDlg Title "Test xBrowse III " size 700,300
oBrw:= txbrowse():new( oDlg )
oBrw:nRowHeight := 25
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS //MARQSTYLE_HIGHLCELL //
oBrw:SetArray( aArray )
oBrw:CreateFromCode()
oBrw:bSelected := {| o | if( ChangeColor( o, oBrw )[ 2 ] == CLR_HRED, .t., .f.) }
oBrw:aCols[ 2 ]:bClrStd := {|o| ChangeColor( o, oBrw ) }
oBrw:aCols[ 2 ]:bClrSelFocus := {|o| ChangeColor( o, oBrw ) }
oDlg:oClient := oBrw
ACTIVATE DIALOG oDlg center on init oDlg:Resize()
return nil
function ChangeColor( oCol, oBrw )
local aClrs := eval( oBrw:bClrStd )
DO CASE
CASE oBrw:aRow[ 1 ] == "01"
aClrs[ 2 ] := CLR_GREEN
CASE oBrw:aRow[ 1 ] == "02"
aClrs[ 2 ] := CLR_YELLOW
CASE oBrw:aRow[ 1 ] == "03"
aClrs[ 2 ] := CLR_BLUE
CASE oBrw:aRow[ 1 ] == "04"
aClrs[ 2 ] := CLR_CYAN
OTHERWISE
aClrs[ 2 ] := CLR_HRED
ENDCASE
return aClrs
#include "FiveWin.ch"
#include "xbrowse.ch"
// xbrowse imagen button get
static aCellSelected
function main()
local oDlg, oBrw
local aArray := {}
local uVal
local nI
local oGet, oBtn
local nWdGet := 0
for nI = 1 to 20
aadd( aArray, { StrZero(nI,2),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ),;
SPACE( 5 ) } )
next
DEFINE DIALOG oDlg Title "Test xBrowse III " size 700,300
oBrw:= txbrowse():new( oDlg )
oBrw:nRowHeight := 25
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL //MARQSTYLE_HIGHLROWMS //
oBrw:SetArray( aArray )
oBrw:CreateFromCode()
AEVAL( oBrw:aCols, { |o| o:bPopUp := { |o| ColMenu( o ) } } )
AEval( oBrw:aCols, { | oCol | oCol:bClrStd := {| | ChangeColor( oBrw ) } }, 2 )
for nI = 2 to len( oBrw:aCols )
oBrw:aCols[ nI ]:bClrStd := GenCodeColor( oBrw, nI )
next
oDlg:oClient := oBrw
ACTIVATE DIALOG oDlg center on init oDlg:Resize()
return nil
Function GenCodeColor( oBrw, nI )
return {|| ChangeColor( oBrw, nI ) }
function ChangeColor( oBrw, n )
local aClrs := { CLR_BLACK, GetSysColor( 5 )}
local j
local bClrStd
DO CASE
CASE oBrw:aRow[ n ] == space( 4 )
aClrs := { CLR_HRED, CLR_HRED }
CASE oBrw:aRow[ n ] == space( 3 )
aClrs := { CLR_BLUE, CLR_BLUE }
CASE oBrw:aRow[ n ] == SPACE( 5 )
aClrs := { CLR_WHITE, CLR_WHITE }
ENDCASE
return aClrs
static function ColMenu( ocol )
local oPop
MENU oPop POPUP 2007
menuitem "Selected" action( oCol:Value( space( 3 ) ), oCol:oBrw:Refresh() )
menuitem "Unseleced" action( oCol:Value(space( 5 ) ), oCol:oBrw:Refresh() )
menuitem "Active" action( oCol:Value( SPACE( 4 ) ), oCol:oBrw:Refresh() )
ENDMENU
return oPop
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 72 guests