Problem with the text in the Head of the Tbrowse

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
jorge_riv
Posts: 86
Joined: Thu Nov 22, 2018 2:20 pm
DBs Used: DBF, MySQL,SQL SERVER, Oracle.

Problem with the text in the Head of the Tbrowse

Post by jorge_riv »

I define 3 fonts, 1 for Cells, 1 for Head and 1 for when I move to another cell.
It doesn't change the font of the head, it takes the font of the cell.
I send an example.
Thank you
Help

#include "minigui.ch"
#include "tsbrowse.ch"

STATIC aFont := {}

MEMVAR oBrw_1

FUNCTION Main()
LOCAL cDbf := 'HCBAS070.dbf'

REQUEST DBFCDX , DBFFPT

SET CENTURY ON
SET DELETED ON

DEFINE FONT Font_Tsb_Cell FONTNAME "Arial" SIZE 10 BOLD
DEFINE FONT Font_Tsb_Head FONTNAME "Times New Roman" SIZE 15 BOLD
DEFINE FONT Font_Tsb_Line FONTNAME "Comic Sans MS" SIZE 12 BOLD

AAdd( aFont, GetFontHandle( "Font_Tsb_Cell" ) )
AAdd( aFont, GetFontHandle( "Font_Tsb_Head" ) )
AAdd( aFont, GetFontHandle( "Font_Tsb_Line" ) )

USE (cDbf) ALIAS 'B1' SHARED READONLY NEW

DEFINE WINDOW Form_0 At 0,0 WIDTH 600 HEIGHT 400 ;
TITLE 'TsBrowse sample' ;
ICON 'lupa.ico' MAIN NOMAXIMIZE NOSIZE

DEFINE TBROWSE oBrw AT 30,90 WIDTH This.Width-300 ;
HEIGHT This.Height-60 ALIAS 'B1' SELECTOR .T. GRID
oBrw:hFont := GetFontHandle("Font_Tsb_Cell" ) // 1-cells font
oBrw:hFontHead := GetFontHandle("Font_Tsb_Head" ) // 2-header font
CreateBrowse( oBrw, 'B1' )
END TBROWSE

END WINDOW

CENTER WINDOW Form_0
ACTIVATE WINDOW Form_0
*
RELEASE FONT Font_Tsb_Cell
RELEASE FONT Font_Tsb_Head
RELEASE FONT Font_Tsb_Line
*
RETURN Nil
**********
*

***************
FUNCTION CreateBrowse( cBrw, cAlias )
***************
LOCAL aHead := { 'COD', 'STATE' }
LOCAL aSize := { 50, 250 }, n
*
ADD COLUMN TO oBrw HEADER aHead[1] ;
SIZE aSize[1] ;
DATA FieldWBlock("PRO", Select(cAlias)) ;
ALIGN DT_CENTER, DT_CENTER ;
NAME PRO

ADD COLUMN TO oBrw HEADER aHead[2] ;
SIZE aSize[2] ;
DATA FieldWBlock("NOM", Select(cAlias)) ;
ALIGN DT_LEFT, DT_CENTER ;
NAME NOM

TsbColor( oBrw )

oBrw:nLineStyle := LINES_ALL
oBrw:ResetVScroll( .T. )
oBrw:oHScroll:SetRange( 0, 0 )

For n := 1 To oBrw:nColCount()
oBrw:aColumns[ n ]:lFixLite := TRUE
oBrw:ChangeFont( aFont[1], n, 1 )
oBrw:ChangeFont( aFont[2], n, 2 )
*oBrw:aColumns[ n ]:hFont := aFont[1]
*oBrw:aColumns[ n ]:hFontHead := aFont[2]
Next

oBrw:ChangeFont( {|| IF( oBrw:lDrawSelect, aFont[3], aFont[1] ) },, )
*
oBrw:LoadFields(.T.)
oBrw:lNoGrayBar := .F.
oBrw:nWheelLines := 1
oBrw:nColOrder := 1
oBrw:nHeightCell += 5
oBrw:nHeightHead := 30
oBrw:lNoResetPos := .F.

oBrw:nClrLine := BLACK
oBrw:ResetVScroll()

RETURN Nil
**********
*

STATIC FUNCTION TsbColor( oBrw )
********************
WITH OBJECT oBrw

// Text color in grid
:SetColor( { 1 }, { { || RGB( 0, 0, 0 )}})

/// Grid backcoloroBrw
:SetColor( { 2 }, { { || RGB( 230, 240, 255 )}})

// Header font color
:SetColor( { 3 }, { RGB( 255, 255, 255 )})

// Header backcolor
:SetColor( { 4 }, { { || { RGB( 43, 149, 168 ), RGB( 0, 54, 94 )}}})
* :SetColor ( { 4}, { RGB(81,78,242) } )

// Text color of cursor in grid
:SetColor( { 5 }, { { || RGB( 0, 0, 255 )}})

// Cursor backcolor
:SetColor( { 6 }, { { || { RGB( 255, 255, 74 ), RGB( 240, 240, 0 )}}})

// Inactive cursor backcolor
:SetColor( { 12 }, { { || { RGB( 128, 128, 128 ), RGB( 250, 250, 250 )}}})

// Text color of inactive cursor in grid
:SetColor( { 11 }, { { || RGB( 0, 0, 0 )}})

END WITH
RETURN Nil
**********
*
Attachments
Prueba.rar
(819.52 KiB) Downloaded 91 times
User avatar
AUGE_OHR
Posts: 2108
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Problem with the text in the Head of the Tbrowse

Post by AUGE_OHR »

hi,

you are using Extend Version so i´m not sure if you get a Answer in HMG Forum
try it here https://groups.google.com/forum/#!forum/minigui-forum
have fun
Jimmy
User avatar
gfilatov
Posts: 1101
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Problem with the text in the Head of the Tbrowse

Post by gfilatov »

Hi Jorge,

Please try the updated sample below :arrow:

Code: Select all

#include "minigui.ch"
#include "tsbrowse.ch"

STATIC aFont := {}

MEMVAR oBrw_1

FUNCTION Main()
LOCAL cDbf := 'HCBAS070.dbf'

REQUEST DBFCDX , DBFFPT

SET CENTURY ON
SET DELETED ON

DEFINE FONT Font_Tsb_Cell FONTNAME "Arial"           SIZE 10 BOLD
DEFINE FONT Font_Tsb_Head FONTNAME "Times New Roman" SIZE 15 BOLD
DEFINE FONT Font_Tsb_Line FONTNAME "Comic Sans MS"   SIZE 12 BOLD

AAdd( aFont, GetFontHandle( "Font_Tsb_Cell" ) )
AAdd( aFont, GetFontHandle( "Font_Tsb_Head" ) )
AAdd( aFont, GetFontHandle( "Font_Tsb_Line" ) )

USE (cDbf) ALIAS 'B1' SHARED READONLY NEW

DEFINE WINDOW Form_0 At 0,0 WIDTH 600 HEIGHT 400 ;
          TITLE 'TsBrowse sample' ;
          ICON 'lupa.ico' MAIN NOMAXIMIZE NOSIZE

  DEFINE TBROWSE oBrw AT 30,90 WIDTH This.Width-250 ;
                 HEIGHT This.Height-60 ALIAS 'B1' SELECTOR .T.  GRID 
//    oBrw:hFont     := GetFontHandle("Font_Tsb_Cell" ) // 1-cells font
//    oBrw:hFontHead := aFont[2] // 2-header font
    CreateBrowse( oBrw, 'B1' )
  END TBROWSE

END WINDOW

CENTER WINDOW Form_0
ACTIVATE WINDOW Form_0
*
RELEASE FONT Font_Tsb_Cell
RELEASE FONT Font_Tsb_Head
RELEASE FONT Font_Tsb_Line
*
RETURN Nil
**********
*

***************
FUNCTION CreateBrowse( cBrw, cAlias )
***************
LOCAL aHead := { 'COD', 'STATE' }
LOCAL aSize := { 50, 250 }, n
*
ADD COLUMN TO oBrw HEADER aHead[1]                 ;
           SIZE aSize[1]                           ;
           DATA FieldWBlock("PRO", Select(cAlias)) ;
           ALIGN DT_CENTER, DT_CENTER                ;
           NAME PRO

ADD COLUMN TO oBrw HEADER aHead[2]                 ;
           SIZE aSize[2]                           ;
           DATA FieldWBlock("NOM", Select(cAlias)) ;
           ALIGN DT_LEFT, DT_CENTER                ;
           NAME NOM

TsbColor( oBrw )    

oBrw:nLineStyle := LINES_ALL
oBrw:ResetVScroll( .T. ) 
oBrw:lNoHScroll := .T.
*oBrw:oHScroll:SetRange( 0, 0 ) 

For n := 1 To oBrw:nColCount()
  oBrw:aColumns[ n ]:lFixLite := TRUE
*  oBrw:ChangeFont( aFont[1], n, 1 )
*  oBrw:ChangeFont( aFont[2], n, 2 )
*oBrw:aColumns[ n ]:hFont     := aFont[1]
oBrw:ChangeFont( {|| IF( oBrw:lDrawSelect, aFont[3], aFont[1] ) },n,1 )
oBrw:aColumns[ n ]:hFontHead := aFont[2]
Next

*
*oBrw:LoadFields(.T.)      
oBrw:lNoGrayBar := .F.
oBrw:nWheelLines := 1 
oBrw:nColOrder   := 1
oBrw:nHeightCell += 8
oBrw:nHeightHead := 30
oBrw:lNoResetPos := .F.

oBrw:nClrLine := BLACK
*oBrw:ResetVScroll()

RETURN Nil
**********
*

STATIC FUNCTION TsbColor( oBrw )
********************
WITH OBJECT oBrw

 // Text color in grid
 :SetColor( {  1 },  { { || RGB( 0, 0, 0 )}})

  ///  Grid backcoloroBrw
  :SetColor( {  2 }, { { || RGB( 230, 240, 255 )}}) 

  //  Header font color
  :SetColor( { 3 }, { RGB( 255, 255, 255 )}) 

  // Header backcolor
  :SetColor( { 4 }, { { || { RGB( 43, 149, 168 ), RGB( 0, 54, 94 )}}}) 
*  :SetColor ( { 4}, { RGB(81,78,242) } )  

  // Text color of cursor in grid
  :SetColor( {  5 }, { { || RGB( 0, 0, 255 )}}) 

  // Cursor backcolor
  :SetColor( { 6 }, { { || { RGB( 255, 255,  74 ), RGB( 240, 240, 0 )}}}) 

  // Inactive cursor backcolor
  :SetColor( { 12 }, { { || { RGB( 128, 128, 128 ), RGB( 250, 250, 250 )}}})

  // Text color of inactive cursor in grid
  :SetColor( { 11 },  { { || RGB( 0, 0,   0 )}}) 

END WITH 
RETURN Nil
**********
*
Hope that helps :idea:
Attachments
tbrowse.png
tbrowse.png (33.17 KiB) Viewed 922 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
jorge_riv
Posts: 86
Joined: Thu Nov 22, 2018 2:20 pm
DBs Used: DBF, MySQL,SQL SERVER, Oracle.

Re: Problem with the text in the Head of the Tbrowse

Post by jorge_riv »

Thank you so much gfilatov
Now it works perfect.
Hugs
Post Reply