Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

alxsts
Colaborador
Colaborador
Mensagens: 3092
Registrado em: 12 Ago 2008 15:50
Localização: São Paulo-SP-Brasil

Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Mensagem por alxsts »

Olá!

Há poucos dias havia uma dúvida relacionada ao assunto deste tópico. Não pude responder na hora e, quando fui responder, o tópico havia sumido. Estranho...

De qualquer forma, segue a resposta:
oTBColumn:defColor
Array holding numeric indexes into the color table of TBrowse

Info
Data type: A Default: {1,2,1,1}

Description
The instance variable :defColor contains an array of four numeric values. They are used as indexes into the color string stored in the instance variable :colorSpec of the TBrowse object containing a TBColumn object. The first element selects the color for normal data display, the second highlights a data cell (the browse cursor), the third selects the color for the column heading and the fourth is used for the column footing. Note that :colorBlock overrides :defColor.
Exemplo funcional onde é possível exibir ou esconder as colunas do TBrowse():

Código: Selecionar todos

/*
 * demonstration/test code for TBrowse class
 *
 * Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
 *
 */

/* UTF-8 */

#include "inkey.ch"
#include "button.ch"
#include "setcurs.ch"
#include "box.ch"

#ifdef __HARBOUR__
   #define _DRAW_1 hb_UTF8ToStr( "Γö£" )
   #define _DRAW_2 hb_UTF8ToStr( "Γöñ" )
   #define _DRAW_3 hb_UTF8ToStrBox( "ΓöÉ ΓöîΓöÇ" )
   #define _DRAW_4 hb_UTF8ToStrBox( "Γöÿ ΓööΓöÇ" )
   #define _DRAW_5 hb_UTF8ToStrBox( "Γöé Γöé" )
   #define _DRAW_6 hb_UTF8ToStrBox( "ΓöÉ ΓöîΓöÇΓöñHIDEΓö£ΓöÇ" )
   #define _DRAW_7 hb_UTF8ToStrBox( "Γòû ΓòôΓöÇΓöñHIDEΓö£ΓöÇ" )
   #define _DRAW_8 hb_UTF8ToStrBox( "Γò£ ΓòÖΓöÇ" )
   #define _DRAW_9 hb_UTF8ToStrBox( "Γòæ Γòæ" )
#else
   #define _DRAW_1 Chr( 195 )
   #define _DRAW_2 Chr( 180 )
   #define _DRAW_3 Chr( 191 ) + " " + Chr( 218 ) + Chr( 196 )
   #define _DRAW_4 Chr( 217 ) + " " + Chr( 192 ) + Chr( 196 )
   #define _DRAW_5 Chr( 179 ) + " " + Chr( 179 )
   #define _DRAW_6 Chr( 191 ) + " " + Chr( 218 ) + Chr( 196 ) + "HIDE" + Chr( 195 ) + Chr( 196 )
   #define _DRAW_7 Chr( 183 ) + " " + Chr( 214 ) + Chr( 196 ) + "HIDE" + Chr( 195 ) + Chr( 196 )
   #define _DRAW_8 Chr( 189 ) + " " + Chr( 211 ) + Chr( 196 )
   #define _DRAW_9 Chr( 186 ) + " " + Chr( 186 )
   #define hb_keyCode( n ) Asc( n )
#endif

PROCEDURE Main()

   STATIC s_nCount := 0
   STATIC s_nPos   := 1
   STATIC s_nSize  := 100

   LOCAL nTop, nLeft, nBottom, nRight
   LOCAL cColor
   LOCAL oBrw, oCol1, oCol2, oCol3, oCol4
   LOCAL nKey, nCol

   nTop    := 2
   nLeft   := 10
   nBottom := 20
   nRight  := 70
   cColor  := "W+/R,G+/BR,RG+/B,BG+/G,N/GR,GR+/BG,B/GR*"

   Set( _SET_DATEFORMAT, "yyyy-mm-dd" )

   // enable mouse events in CL53/Harbour
#ifdef _SET_EVENTMASK
   Set( _SET_EVENTMASK, INKEY_ALL )
   MSetCursor( .T. )
#endif


   CLS
#ifdef HB_B_DOUBLE_SINGLE_UNI
   DispBox( nTop, nLeft, nBottom, nRight, HB_B_DOUBLE_SINGLE_UNI, cColor )
#else
   DispBox( nTop, nLeft, nBottom, nRight, B_DOUBLE_SINGLE, cColor )
#endif
   oBrw := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 )
   DispOutAt( nTop + 3,    nLeft,  _DRAW_1, cColor )
   DispOutAt( nTop + 3,    nRight, _DRAW_2, cColor )
   DispOutAt( nBottom - 2, nLeft,  _DRAW_1, cColor )
   DispOutAt( nBottom - 2, nRight, _DRAW_2, cColor )

   oBrw:colorSpec := cColor
   oBrw:headSep := _DRAW_3
   oBrw:footSep := _DRAW_4
   oBrw:colSep  := _DRAW_5

   oBrw:SkipBlock     := {| n | hb_idleSleep( 0.2 ), ;
      n := iif( n < 0, Max( n, 1 - s_nPos ), ;
      Min( s_nSize - s_nPos, n ) ), ;
      s_nPos += n, n }
   oBrw:GoTopBlock    := {|| s_nPos := 1 }
   oBrw:GoBottomBlock := {|| s_nPos := s_nSize }

   oCol1 := TBColumnNew( "COL;1;", {|| s_nPos } )
   oCol1:defColor := { 2, 1, 3, 4 }
   oCol1:footing := "position"
   oCol1:colorBlock := {| val | { val % 5 + 1, val % 3 + 2 } }

   oCol2 := TBColumnNew( "COL;2",  {|| s_nCount++ } )
   oCol2:defColor := { 3, 4, 5, 6 }
   oCol2:footing := "counter"
   oCol2:headSep := _DRAW_6

   oCol3 := TBColumnNew( "COL 3",  {|| s_nPos % 3 == 0 } )
   oCol3:defColor := { 5, 6, 2, 3 }
   oCol3:footing := "logical"
   oCol3:picture := "@YR [Y]"  // Clipper wrongly calculate the size here
   oCol3:headSep := _DRAW_7
   oCol3:footSep := _DRAW_8
   oCol3:colSep  := _DRAW_9

   oCol4 := TBColumnNew( "   SHOW;   ALL",  {|| Date() - s_nPos } )
   oCol4:defColor := { 6, 3, 4, 2 }
   oCol4:footing := "date"

   oBrw:addColumn( oCol1 )
   oBrw:addColumn( oCol2 )
   oBrw:addColumn( oCol3 )
   oBrw:addColumn( oCol4 )

   // start at bottom
   oBrw:goBottom()

   WHILE .T.
      WHILE ! oBrw:stabilize() .AND. NextKey() == 0
      ENDDO
      nKey := Inkey( 0 )
      IF nKey == K_ESC
         EXIT
      ELSEIF nKey == K_INS
         oBrw:colorRect( { oBrw:rowPos, 1, oBrw:rowPos, 4 }, { 7, 6 } )
      ELSEIF nKey == K_DEL
         oBrw:refreshCurrent()
      ELSEIF nKey >= hb_keyCode( "0" ) .AND. nKey <= hb_keyCode( "3" )
         oBrw:freeze := nKey - hb_keyCode( "0" )
      ELSEIF nKey == K_LBUTTONDOWN .AND. ;
            oBrw:HitTest( MRow(), MCol() ) == HTHEADSEP .AND. ;
            ( ( nCol := oBrw:mColPos ) == 2 .OR. nCol == 3 )
         IF nCol == 2
            oCol2:width := 0
         ELSE
            oCol3:width := 0
         ENDIF
         oBrw:configure()
      ELSEIF nKey == K_LBUTTONDOWN .AND. ;
            oBrw:HitTest( MRow(), MCol() ) == HTHEADING .AND. ;
            oBrw:mColPos == 4
         oCol2:width := 10
         oCol3:width := 7
         oBrw:configure()
      ELSE
         oBrw:applyKey( nKey )
      ENDIF
   ENDDO

   RETURN

#ifndef __HARBOUR__

PROCEDURE hb_idleSleep( n )

   n += Seconds()
   WHILE Seconds() < n
   ENDDO

   RETURN

#endif
[]´s
Alexandre Santos (AlxSts)
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Mensagem por JoséQuintas »

tbrowse.png
Acabei resolvendo de outro jeito, e apaguei as mensagens.
Quando não tem mensagem adicional, o autor consegue excluir.

Obrigado.
Revertendo tudo pra testar.
Só minha lista de cores.... que não servia pra título.... vou ter que rever.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Mensagem por JoséQuintas »

Voltei nisso hoje, não estou conseguindo acertar a cor do header.
O que define as cores é esta função.

Código: Selecionar todos

FUNCTION SetColorTbrowse()

   LOCAL cSetColorFocus

   cSetColorFocus := SetColorFocus()

   // row, selected, header, footer, others
   RETURN "7/1," + cSetColorFocus + ",0/7,0/7,0/7,7/8,12/1,14/1,3/1"
Mas a 3 não está entrando.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Mensagem por JoséQuintas »

tbrowsecolor.png
Respondi pra mim mesmo, de novo kkkkk

Mas ainda acertando aqui.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Cor no cabeçalho de coluna do TBrowse() - Tópico desapareceu

Mensagem por JoséQuintas »

tbrowse.png
Só lembrando:
Meu tbrowse tem uma cor a mais: a cor das barras
Tá como pull request pendente no harbour 3.2 há vários anos, então, só eu tenho.

ficou assim o default:

Código: Selecionar todos

FUNCTION SetBrowse( oTBrowse, oBrowse )

   LOCAL oElement, oThisColumn

   oBrowse:HeadSep    := Chr(196)
   oBrowse:FootSep    := Chr(196)
   oBrowse:ColSep     := Chr(179)
   oBrowse:cSepColor  := SetColorTbrowseFrame()
   oBrowse:ColorSpec  := SetColorTBrowse()
   FOR EACH oElement IN oTBrowse
      oThisColumn := tbColumnNew( oElement[ 1 ], oElement[ 2 ] )
      oThisColumn:DefColor := { 3, 3, 3, 3 }
      IF Len( oElement ) > 2
         oThisColumn:ColorBlock := oElement[ 3 ]
         IF Len( oElement ) > 3
            oThisColumn:Cargo := oElement[ 4 ]
         ENDIF
      ENDIF
      oBrowse:AddColumn( oThisColumn )
   NEXT

   RETURN Nil
Agora definindo o DefColor, além do ColorBlock, fazer o que....
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Responder