What is the better choice ? (Brushes) for xBrowse

Post Reply
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

What is the better choice ? (Brushes) for xBrowse

Post by ukoenig »

Hello,

There are two ways, to define a Background-Brush for xBrowse

1.

oBrw:SetBackGround( TBrush():New( ,, BLUSTONE.BMP ) )

must i release this brush ?

2.

STATIC FUNCTION BRW_BACKGRD( oBrw )
Local oBrush

DEFINE BRUSH oBrush FILENAME "BLUSTONE.BMP"
oBrw:SetBackGround( oBrush )
RELEASE BRUSH oBrush

oBrw:Refresh() // Refresh needed ?

return nil

What is the better choise to use ?
( to be used as source-code for the tools )

Regards
Uwe :lol:
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.
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

2. is the right choice.

1. oBrush is not released. Must be released by the programmer.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Brush for xBrowse

Post by ukoenig »

Antonio,

thank you very much, i will add choice 2 to the source.

The function is added to the Version 1c
download :

http://www.pflegeplus.com/fw_downloads/BRWTools1.zip

I still found out something else :
1. I have row-colors ( lightblue / white )
2. I paint a brush and then a cell-bitmap on top of it.
The cell-bitmap-background shows the color from the
rows, i have painted before ( lightblue and white ).
It seems, the row-colors still exists from the painting before
and the background-brush is shown on top of it.
Maybe there is a special way, to delete the old colours, before the brush is painted ?
It might be a runtime-problem ( it is not the normal way, somebody
defines brushes ).
Cell-bitmaps on the first color-selection, are shown correctly.
I could try, to do a new preview in a extra window.
I think, it will work there. It is the same problem, like painting a Col on Rows in a different color
and then trying to repaint the rows to delete the Column-color.
Maybe a solution of < SetBackGround( ) > for colors ?

I changed the Brush-function and added < SetBackGround( ) >,
but no difference.
I think < SetBackGround( ) > works only with brushes and not with colors.

Code: Select all | Expand


STATIC FUNCTION BRW_BACKGRD( oLbx0 )
Local oBrush

oLbx0:SetBackGround( )   // !!!!!!!!

DEFINE BRUSH oBrush FILENAME LOGO1
oLbx0:SetBackGround( oBrush )
RELEASE BRUSH oBrush

oLbx0:Refresh()

return nil




Image

Regards
Uwe :lol:
Last edited by ukoenig on Sun Aug 31, 2008 9:21 pm, edited 1 time in total.
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.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

>
I think < SetBackGround( ) > works only with brushes and not wth colors.
>
Yes

Changing colors is simple. Change oBrw:bClrStd ( and obrw:setcolor)

SetBackGround is provided for transparent painting over a brush
Regards

G. N. Rao.
Hyderabad, India
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Uwe,

In the first row the bitmaps are properly painted with "transparent" borders, but in the next rows, they are not.

It may be a xbrowse bug, we are going to review it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Uwe,

METHOD PaintData() CLASS TXBrwColumn is using this code:

Code: Select all | Expand

      if lStretch
         ...
      else
         PalBmpDraw( hDC, nBmpRow, nBmpCol,;
                     aBitmap[ BITMAP_HANDLE ],;
                     aBitmap[ BITMAP_PALETTE ],;
                     aBitmap[ BITMAP_WIDTH ],;
                     aBitmap[ BITMAP_HEIGHT ];
                     ,, .t., aColors[ 2 ] )
      endif

so it looks as TransBmp() is not used if lStretch is false (by default). Please replace that section of code with this one and try it again:

Code: Select all | Expand

         nOldColor  := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
         TransBmp( aBitmap[ BITMAP_HANDLE ], aBitmap[ BITMAP_WIDTH ], aBitmap[ BITMAP_HEIGHT ],;
                   aBitmap[ BITMAP_ZEROCLR ], hDC, nRectCol, nRow, Min( nRectWidth,::oBrw:BrwWidth() - nRectCol - 4 ), ;
                   nRectHeight - nRow )
         SetBkColor( hDC, nOldcolor )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Transparent Brush

Post by ukoenig »

Antonio,

It must be inside the stretch-part of xBrowse-column.
The cell-picture is shown transparent with the background of the brush.
That is OK now, but something else is wrong with the dimensions
after the changes : the bitmaps are shown stretched.
For me, it was a nice practical-test, how to use the tools testing any changes done in the xbrowse-class.

Image

Regards
Uwe :lol:
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.
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Cell-Picture on Brush

Post by ukoenig »

Antonio,

i had to change your source a little bit :

Code: Select all | Expand


nOldColor  := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
TransBmp( aBitmap[ BITMAP_HANDLE ], aBitmap[ BITMAP_WIDTH ], ;
aBitmap[ BITMAP_HEIGHT ],;
aBitmap[ BITMAP_ZEROCLR ], hDC, nRectCol, nRow, ;
aBitmap[ BITMAP_WIDTH ], ;
aBitmap[ BITMAP_HEIGHT ] )
SetBkColor( hDC, nOldcolor )



Image

but there is still something wrong with the bmp in the selected row
and the 1. line, where the row-cursor has been ( row 1 )
as i added the cell bitmaps.
( in the 1. line, i added a help-book, it is yellow now ).

Regards
Uwe :lol:
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.
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Uwe,

Yes, if the column uses oCol:lBmpStretch then its properly painted.

That should point us to get a proper fix, thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Dear Uwe,

This seems to be the right code. Please test it and let us know your results, thanks! :-)

In Method PaintData()

Code: Select all | Expand

      if lStretch
         nOldColor  := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
         TransBmp( aBitmap[ BITMAP_HANDLE ], aBitmap[ BITMAP_WIDTH ], aBitmap[ BITMAP_HEIGHT ],;
                   aBitmap[ BITMAP_ZEROCLR ], hDC, nRectCol, nRow, Min( nRectWidth,::oBrw:BrwWidth() - nRectCol - 4 ), ;
                   nRectHeight - nRow )
         SetBkColor( hDC, nOldcolor )
      else
         nOldColor := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
         TransBmp( aBitmap[ BITMAP_HANDLE ], aBitmap[ BITMAP_WIDTH ], aBitmap[ BITMAP_HEIGHT ],;
                   aBitmap[ BITMAP_ZEROCLR ], hDC, nBmpCol, nBmpRow, aBitmap[ BITMAP_WIDTH ], ;
                   aBitmap[ BITMAP_HEIGHT ] )
         SetBkColor( hDC, nOldColor )
      endif

Many thanks for your feedback!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Cell-Bitmaps on Brush

Post by ukoenig »

Antonio,

I replaced the source and it looks much better now.

The start-screen looks OK, but the cell-bitmaps in browsers
without having the focus, dont show the bitmap on cursor-positions.
It is shown correct, after leaving the record.

Image

Moving from Top to another record,
shows a wrong bitmap on the old position.

Image

Color-changing of the selected row works and shows the cell-bitmap.

Image

With your changes and keeping these lines,
the cell-bitmaps in browsers without focus are shown correct
and the row with focus in the testbrowser also shows the cell-bitmap.
Only the cell-bitmaps without focus are wrong.

PalBmpDraw( hDC, nBmpRow, nBmpCol,;
aBitmap[ BITMAP_HANDLE ],;
aBitmap[ BITMAP_PALETTE ],;
aBitmap[ BITMAP_WIDTH ],;
aBitmap[ BITMAP_HEIGHT ];
,, .t., aColors[ 2 ] )

Image


Regards
Uwe :lol:
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.
User avatar
Patrick Mast
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio Linares wrote:1. oBrush is not released. Must be released by the programmer.

Code: Select all | Expand

REDEFINE BITMAP oBtn ID 307 NAME "LIJST" OF oDlg
oBtn:oCursor:=TCursor():New(,"HAND")

Do we have to manualy end oBtn:oCursor in this case?

Patrick
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Patrick,

In that case, no, because the control will destroy it.

Remember not to share the same cursor for different controls, because it a control destroys it, it will be no longer valid for the other controls.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Patrick Mast
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Antonio Linares wrote:In that case, no, because the control will destroy it.

Remember not to share the same cursor for different controls, because it a control destroys it, it will be no longer valid for the other controls.

Ok, thank you for the info.

Patrick
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Some FWH (GDI) objects that consume many GDI memory use a DATA as a counter, so they can be reused. i.e: fonts, brushes.

So if we do:

DEFINE BRUSH oBrush COLOR CLR_WHITE // brush counter is 1

DEFINE WINDOW oWnd BRUSH oBrush // brush counter is 2

ACTIVATE WINDOW oWnd // when we close this window, the brush counter will be decreased in 1, but as it is higher than zero, it will not be destroyed

oBrush:End() // the brush counter is decreased and reaches zero, so it is finally destroyed.

This way, the same brush can be used for different objects, and it will be valid until its counter reaches zero.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply