FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE Border on cells
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
XBROWSE Border on cells
Posted: Mon Jul 16, 2018 07:40 AM

Mr. Nages, can i draw a border with a specific color and width around a cell but only on cells with edit-functions (get, listbox, etc.)

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE Border on cells
Posted: Mon Jul 16, 2018 09:51 AM

You need to use oCol:bPaintText and paint the text and border of the cells the way you want.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Border on cells
Posted: Sat Aug 11, 2018 10:14 AM

Mr. Rao, can you please provide a sample, that show only the border different to the normal view (Text, Data,..) of the cell.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Thu Apr 11, 2019 08:24 AM
Günther,

still a solution needed :-)

You need to use oCol:bPaintText and paint the text and border of the cells the way you want.


A border around each cell or only around the column :-)
( uses different colours as well on age ranges )



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Border on cells
Posted: Thu Apr 11, 2019 09:15 AM

Uwe, I use a adapted version from class xbrowse. But i must every new FWH adapting new. The border with specific width and color are shown only on edit-cells and can differ any column.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Thu Apr 11, 2019 08:34 PM
Günther ,

The border with specific width and color are shown only on edit-cells
and can differ any column.


if it is the solution You are looking for -> different colors and pensize I will provide the code.
I think a border of the complete column ( edit ) is needed ?

Only functions are used, NO change of xBrowse.prg is needed :
COL_RECT( oBrw, hDC, 2, 255, 3, .F. ) // column-number, pencolor, pensize, lData
It is done using GDIPLUS, doesn't use < oCol:bPaintText >
If lData = .T. the border starts and ends with the data-area, header and footer are not included.
You can adjust the top and bottom-line ( make them not visible if needed )



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Border on cells
Posted: Fri Apr 12, 2019 09:26 AM

Uwe, i will show the border only around the actual cell to edit and only if this cell has focus!

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Fri Apr 12, 2019 01:35 PM
Günther,

I tested painting a border on a defined cell.

The function will include 3 solutions

1. border on column with only data-area
2. border on column with header and footer
3. border on focused cell

i will show the border only around the actual cell to edit and only if this cell has focus!


I still need the status got- and lost-focus of the cell to draw or delete the border.
Painting and deleting cell-borders is working :-) .

for a selected cell something like:

:bGotfocus := {|nRow, nCol|...
:bLostfocus := {|nRow, nCol|...

or is it possible to use :

METHOD GotFocus( hCtlFocus ) INLINE ( ::oActive := Self, ::GotFocus( hCtlFocus ),;
If( GetParent( hCtlFocus ) != ::hWnd, ::Refresh( .f. ),) )

METHOD LostFocus( hCtlFocus ) INLINE ( ::LostFocus( hCtlFocus ),;
If( GetParent( hCtlFocus ) != ::hWnd, ::Refresh( .f. ), ) )



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Fri Apr 12, 2019 11:42 PM
Finished :-) :-)

added to a existing sample

Autofocus on first column
Border deleted loosing the focus
You can use rounded as well or changing the bordercolor and pensize



You can download the complete source and running exe

http://www.pflegeplus.com/DOWNLOADS/Border.zip

maybe You must delete this line :

oBrw:lHoverSelect := .T. // autofocus

Code (fw): Select all Collapse
#include "fivewin.ch"

STATIC lDel := .F., nColRow := 1

FUNCTION MAIN()
local oWnd, oBrw, oFont, oBold

USE WWONDERS NEW

DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-12
DEFINE FONT oBold NAME "VERDANA" SIZE 0,-13 BOLD

DEFINE WINDOW oWnd TITLE "Image and Text in same cell"
oWnd:SetFont( oFont )

@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "WWONDERS" ;
      COLUMNS "NAME","DETAILS" COLSIZES 200, 250 ;
      LINES NOBORDER

WITH OBJECT oBrw
    :nRowHeight := 200

    oBrw:bChange := { || MOVEBORDER( oBrw ) }
        oBrw:lHoverSelect   := .T. // autofocus

    WITH OBJECT :aCols[ 1 ]
        :bStrImage     := { || FIELD->IMAGE }
        :oDataFont     := oBold
        :nDataStrAlign := AL_CENTER + AL_BOTTOM
        :nDataBmpAlign := AL_CENTER
        :aImgRect      := { nil, nil, -40, nil }
    END
      //
    :CreateFromCode()
END
oWnd:oClient   := oBrw

oWnd:nHeight   := 700

oBrw:bPainted := < |hDC|   
  // CELL_BORDER( oBrw, hDC, nColumn, nRow, nRGBColor, nCellPen, lDel )
      CELL_BORDER( oBrw, hDC, 1, nColRow, 255, 10, lDel )
RETURN NIL
>

ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont, oBold

RETURN NIL

//----------------------------

FUNCTION MOVEBORDER( oBrw )

IF oBrw:nColSel = 1
    lDel := .T.
    oBrw:Refresh()
    lDel := .F.
    nColRow := oBrw:nRowSel
ELSE
    lDel := .T.
ENDIF
oBrw:Refresh()

RETURN NIL

// -------------

FUNCTION CELL_BORDER( oBrw, hDC, nCol, nRow, nRGBColor, nCellPen, lDel )
LOCAL oGraphics := Graphics():New( hDC ) 
LOCAL nRed      := nRGBRed( nRGBColor )
LOCAL nGreen    := nRGBGreen( nRGBColor )
LOCAL nBlue     := nRGBBlue( nRGBColor )
LOCAL oPen      := Pen():New( 255, nRed, nGreen, nBlue, nCellPen )
LOCAL aRect     := oBrw:aCellCoor( nRow, nCol ) // --> { nTop, nLeft, nBottom, nRight }
LOCAL nLeft     := oBrw:aCols[ nCol ]:nDisplayCol - nCellPen 
LOCAL nWidth    := oBrw:ColAtPos( nCol ):nWidth() + nCellPen + 3 
LOCAL nHeight   := oBrw:nRowHeight + nCellPen + 3

IF lDel = .F.
    oGraphics:DrawRect( oPen,  ,nLeft, aRect[1] - nCellPen +2, nWidth, nHeight ) 
ELSE
    oGraphics:DrawRect( oPen,  ,nLeft, aRect[1] - nCellPen, 0, 0 ) 
ENDIF

oPen:Destroy()
oGraphics:Destroy()

RETURN NIL


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Sat Apr 13, 2019 08:43 AM
A extended test :

For the test You need the new :

oBrw:lHoverSelect := .T. // autofocus

1. using multiple columns
2. different forms and colors for each column
3. select if You want to show a border only on focused cell or all defined edit-cells on row-focus




regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Border on cells
Posted: Sat Apr 13, 2019 09:49 AM

Uwe, thank you!!! I will test and report.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Sat Apr 13, 2019 10:33 AM
Günther,

I hope it will work for You
I think I will create a little painter with a source-generator.

testing glowing borders :-)



Another question :
did You try to compile < TGDIPLUS.cpp > :-)
For any reason I don't get it working.
I want to test the new texture-brush - solution.
Maybe You have a link sample ?


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: XBROWSE Border on cells
Posted: Sat Apr 13, 2019 11:24 AM

Uwe, maybe you have not switched the compiler to C++! Add the switch -P to your compiler. (Borland)

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Sat Apr 13, 2019 11:36 AM
Günther,

# maybe you have not switched the compiler to C++!
# Add the switch -P to your compiler. (Borland)


Yes it is missing :-)

IF EXIST MAIN.res echo MAIN.res >> b32.bc
$(BCDIR)\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
Günther,

# $(BCDIR)\bin\ilink32 -Gn -aa -Tpe -s @b32.bc
del b32.bc

.PRG.OBJ:
$(HBDIR)\bin\harbour $< /N /W /Oobj\ /I$(FWDIR)\include;$(HBDIR)\include > clip.log
$(BCDIR)\bin\bcc32 -c -tWM -I$(HBDIR)\include -oobj\$& obj\$&.c

.C.OBJ:
echo -c -tWM -D__HARBOUR__ -DHB_API_MACROS > tmp
echo -I$(HBDIR)\include;$(FWDIR)\include >> tmp
$(BCDIR)\bin\bcc32 -oobj\$& @tmp $&.c
del tmp

MAIN.res : MAIN.rc
$(BCDIR)\bin\brc32.exe -r MAIN.rc

Just tested and works :-) :-)

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBROWSE Border on cells
Posted: Sun Apr 14, 2019 08:27 PM
Günther,

I created a new example to test any combination.
Some improvements are done to reduce the code-size

1. solid line or glow
2. position : outside cell, covering celllines or inside
3. a possible transparent level
4. corners rounded if selected
5. different pensizes



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.