FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in Tbrush
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bug in Tbrush
Posted: Tue May 31, 2011 02:53 PM
In brush.prg there is the following line:

Code (fw): Select all Collapse
if ( nAt := AScan( ::aBrushes, {|oBrush| Self == oBrush } ) ) > 0


But we can't compare brushes at this point because some of the properties of the current brush have not been assigned yet (ie. ::aGrad).

One of the results is that the new GRADIENT clause doesn't work if there are brushes already defined.

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Tbrush
Posted: Tue May 31, 2011 03:43 PM

Thanks for pointing out the bug.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Tbrush
Posted: Wed Jun 01, 2011 04:45 AM

One of the results is that the new GRADIENT clause doesn't work if there are brushes already defined.


There seems to be no problem in creating any number of gradient brushes.

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

static aGrad1  := { { .4, CLR_BLUE, CLR_WHITE }, { .6, CLR_WHITE, CLR_BLUE } }
static aGrad2  := { { 0.50, 14853684, 16314573 }, { 0.50, 16314573, 14853684 } }
static aGrad3  := { { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
                    { 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } }
static aGrad4  := { { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
                    { 0.75, RGB( 255, 215,  84 ), RGB( 255, 233, 162 ) } }

static aGrdBrush[ 4 ]

function Main()

   local oWnd, oBar

   DEFINE BRUSH aGrdBrush[ 1 ] GRADIENT aGrad1
   DEFINE BRUSH aGrdBrush[ 2 ] GRADIENT aGrad2
   DEFINE BRUSH aGrdBrush[ 3 ] GRADIENT aGrad3
   DEFINE BRUSH aGrdBrush[ 4 ] GRADIENT aGrad4

   ? Len( TBrush():aBrushes )

   DEFINE WINDOW oWnd BRUSH aGrdBrush[ 1 ] MDI ;
      TITLE "Gradient Brushes"

   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Child" ACTION NewChild()
   SET MESSAGE OF oWnd TO '' 2007

   ACTIVATE WINDOW oWnd

   ? Len( TBrush():aBrushes )

   AEval( aGrdBrush, { |o| o:End() } )

   ? Len( TBrush():aBrushes )

return nil

static function NewChild()

   static nBrush  := 1

   local oWnd

   nBrush   := If( nBrush == 4, 1, ++nBrush )

   DEFINE WINDOW oWnd MDICHILD OF WndMain() ;
      BRUSH aGrdBrush[ nBrush ]
   ACTIVATE WINDOW oWnd

return nil


Four gradient brushes are created and can be used and reused in any manner.

But the problem arises when new brushes are created with the same image with different resize modes, after creating a non-resizble brush with that image. This will be fixed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Tbrush
Posted: Wed Jun 01, 2011 10:04 AM
Please try:

Code (fw): Select all Collapse
   DEFINE BRUSH aGrdBrush[ 1 ] //GRADIENT aGrad1
   DEFINE BRUSH aGrdBrush[ 2 ] GRADIENT aGrad2
   DEFINE BRUSH aGrdBrush[ 3 ] GRADIENT aGrad3
   DEFINE BRUSH aGrdBrush[ 4 ] GRADIENT aGrad4


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Tbrush
Posted: Wed Jun 01, 2011 10:00 PM

Thanks, Yes.
I noticed this too.
Fixed now.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Tbrush
Posted: Wed Jun 01, 2011 10:59 PM

Thank you. One more problem: ::nResizeMode is 0 by default. It should be 1.

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Tbrush
Posted: Wed Jun 01, 2011 11:59 PM

This is the logic adopted:

nResizeMode is not relevant for solid and style brushes, but only to those which depend on bitmaps, including gradients.

Default mode for all bitmap brushes, except gradients, is TILED mode. nResizeMode = 0 is the default tiled mode. This is the traditional way. nResizeMode = 1 means STRETCH and nResizeMode = 2 means RESIZE. Optionally, one of these two modes can be selected in case of Images, at the time of creation of the brush. RESIZE mode retains the aspect ratio, while STRETCH does not. In case of RESIZE, one of the dimensions fits the window client size while the other may exceed.

Gradient brushes are always to be stretched, i.e., the entire window client area is to be filled. Size of the bitmap created is exactly the same as the client area of the window.

By default the gradient type is Vertical, which is represented by nResizeMode = 1 and optional HORIZONTAL mode is represented by 2. When a brush is created for gradient, we are setting the default to 1 ( vertical ) in the New() method, unless HORIZ clause is specified.

Hope this explains. Welcome your suggestions.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Tbrush
Posted: Thu Jun 02, 2011 08:00 AM

No, what I'm trying to say is that the default for gradient brushes is currently 0 that means != 1 and therefore horizontal. Please test.

EMG

Continue the discussion