Page 1 of 2

XBROWSE Border on cells

PostPosted: Mon Jul 16, 2018 7:40 am
by byte-one
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.)

Re: XBROWSE Border on cells

PostPosted: Mon Jul 16, 2018 9:51 am
by nageswaragunupudi
You need to use oCol:bPaintText and paint the text and border of the cells the way you want.

Re: XBROWSE Border on cells

PostPosted: Sat Aug 11, 2018 10:14 am
by byte-one
Mr. Rao, can you please provide a sample, that show only the border different to the normal view (Text, Data,..) of the cell.

Re: XBROWSE Border on cells

PostPosted: Thu Apr 11, 2019 8:24 am
by ukoenig
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 )

Image

regards
Uwe :?:

Re: XBROWSE Border on cells

PostPosted: Thu Apr 11, 2019 9:15 am
by byte-one
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.

Re: XBROWSE Border on cells

PostPosted: Thu Apr 11, 2019 8:34 pm
by ukoenig
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 )

Image

regards
Uwe :?:

Re: XBROWSE Border on cells

PostPosted: Fri Apr 12, 2019 9:26 am
by byte-one
Uwe, i will show the border only around the actual cell to edit and only if this cell has focus!

Re: XBROWSE Border on cells

PostPosted: Fri Apr 12, 2019 1:35 pm
by ukoenig
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, ::Super:GotFocus( hCtlFocus ),;
If( GetParent( hCtlFocus ) != ::hWnd, ::Super:Refresh( .f. ),) )

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

Image

regards
Uwe :D

Re: XBROWSE Border on cells

PostPosted: Fri Apr 12, 2019 11:42 pm
by ukoenig
Finished :D :D

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

Image

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: Select all  Expand view


#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 :D

Re: XBROWSE Border on cells

PostPosted: Sat Apr 13, 2019 8:43 am
by ukoenig
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


Image

regards
Uwe :D

Re: XBROWSE Border on cells

PostPosted: Sat Apr 13, 2019 9:49 am
by byte-one
Uwe, thank you!!! I will test and report.

Re: XBROWSE Border on cells

PostPosted: Sat Apr 13, 2019 10:33 am
by ukoenig
Günther,

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

testing glowing borders :idea:

Image

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 :D

Re: XBROWSE Border on cells

PostPosted: Sat Apr 13, 2019 11:24 am
by byte-one
Uwe, maybe you have not switched the compiler to C++! Add the switch -P to your compiler. (Borland)

Re: XBROWSE Border on cells

PostPosted: Sat Apr 13, 2019 11:36 am
by ukoenig
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 :D :D

regards
Uwe :?

Re: XBROWSE Border on cells

PostPosted: Sun Apr 14, 2019 8:27 pm
by ukoenig
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

Image

regards
Uwe :D