FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour brush on PANEL
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
brush on PANEL
Posted: Tue Dec 13, 2016 10:57 AM

is it possible create a brush gradient on a Panel (Tpanel) ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: brush on PANEL
Posted: Wed Dec 14, 2016 11:36 AM
Silvio,

is it possible create a brush gradient on a Panel (Tpanel)


YES
You can switch from COLOR to GRADIENT.
I still need to define the gradient-calculation ( adjustment ) for changing the vertical size of panel 2 and 3





best 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: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: brush on PANEL
Posted: Fri Dec 16, 2016 11:46 AM

can you make a sample ?
define brush oBrush...........

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Sat Dec 17, 2016 03:40 AM
Code (fw): Select all Collapse
aGrad := { .... your gradient array }
DEFINE BRUSH oBrush GRADIENT aGrad
oPanel:SetBrush( oBrush )
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: brush on PANEL
Posted: Sat Dec 17, 2016 12:14 PM

thanks

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 01:47 PM

I tried with

       aGrad :={ { 1, CLR_BLUE, CLR_WHITE } }
        DEFINE BRUSH oBrush GRADIENT aGrad
        oPanel:=TPanel(5,215,155,305,oDlg)
        oPanel:SetBrush( oBrush )

I see all black!!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 01:58 PM

You are right.
Let me check.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 02:17 PM
Please try this
Code (fw): Select all Collapse
   aGrad :={ { 1, CLR_BLUE, CLR_WHITE } }
   DEFINE BRUSH oBrush GRADIENT aGrad

   DEFINE WINDOW oWnd

   oPanel:=TPanel(5,215,155,305,oWnd)
   oPanel:SetBrush( oBrush )
   oBrush:Resize( oPanel )

   ACTIVATE WINDOW oWnd CENTERED
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 02:18 PM
I couldn't detect anything wrong on panel-brushpainting.
The only thing is, I'm still working on splitter-panel-adjustments



Code (fw): Select all Collapse
// at startup
// ------------
IF cBrush = "C" // color
    oPanel1:SetColor( "W/R" )
    oPanel2:SetColor( "W/G" )
    oPanel3:SetColor( "W/B" )
ELSE // gradient, brush, image
    PANELBRUSH( oPanel1, 1, cBrush )
    PANELBRUSH( oPanel2, 2, cBrush ) 
    PANELBRUSH( oPanel3, 3, cBrush ) 
ENDIF

// ---- on button-action

@ 110, nBtnleft button "Gradient" size 130, 40 pixel ;
ACTION (    cBrush := "G", ;
    PANELBRUSH( oPanel1, 1, cBrush, , oPanel1:nHeight ), ;
    PANELBRUSH( oPanel2, 2, cBrush, , oPanel2:nHeight ), ;
    PANELBRUSH( oPanel3, 3, cBrush, , oPanel3:nHeight ) ) ;
OF oWnd

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

FUNCTION PANELBRUSH( oPanel, nPanel, cBrush, cImage, nHeight )
LOCAL hDC, hBmp, hBmpOld, oBrush
LOCAL aRect := GETCLIENTRECT( oPanel:hWnd ) 
LOCAL aColors  

IF cBrush = "C" .or. cBrush = "G" // colors used for defined color- and gradient-background
    IF nPanel = 1
        aColors := { { 1, 16777215, 255 } }
    ELSEIF nPanel = 2
        aColors := { { 1, 16777215, 32768 } }
    ELSEIF nPanel = 3
        aColors := { { 1, 16777215, 16711680 } }
    ENDIF
ENDIF
IF cBrush = "G"
    // MsgAlert( nHeight, "Panel-height" )
    hDC = CREATECOMPATIBLEDC( oPanel:GetDC() )
    hBmp = CREATECOMPATIBLEBITMAP( oPanel:hDC, oPanel:nWidth, nHeight )
    hBmpOld = SELECTOBJECT( hDC, hBmp )
    GRADIENTFILL( hDC, 0, 0, oPanel:nHeight, oPanel:nWidth, aColors )
    oBrush = TBrush():New( ,,,, hBmp )
    oPanel:SetBrush( oBrush )

    AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )

    RELEASE BRUSH oBrush

    SELECTOBJECT( hDC, hBmpOld )

    DELETEDC( hDC )

    oPanel:ReleaseDC()
ENDIF
IF cBrush = "B"
    DEFINE BRUSH oBrush FILE cImage
    oPanel:SetBrush( oBrush )

    AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )

    RELEASE BRUSH oBrush
ENDIF
IF cBrush = "I"
    DEFINE IMAGE oImage FILE cImage
    oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) ) 
    oImage:End()

    oPanel:SetBrush( oBrush )

    AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )

    RELEASE BRUSH oBrush
ENDIF

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: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 02:20 PM

Mr Uwe

The issue is with Gradient brushes and probably with resizeble brushes also.
I am looking into it.
For now, my above example works with Gradient brushes.
I shall simplify the process soon

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 02:47 PM
Please make this modification in tpanel.prg:

In the METHOD Paint(), please locate these lines:
Code (fw): Select all Collapse
   else
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
   endif


Please modify the code as below:
Code (fw): Select all Collapse
   else
      ::PaintBack( ::hDC )
      //FillRect( ::hDC, GetClientRect( ::hWnd ), ::hBrush )
   endif


Now you can try Gradient brushes and resizeable image brushes:
Here is a sample using simple Splitter
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "splitter.ch"

function Main()

   local oWnd, oPanel1, oPanel2, oBrush1, oBrush2, oSplit

   DEFINE BRUSH oBrush1 FILE "c:\fwh\bitmaps\sea.bmp" STRETCH
   DEFINE BRUSH oBrush2 FILE "c:\fwh\bitmaps\hires\office.bmp" STRETCH

   DEFINE WINDOW oWnd

   oPanel1  := TPanel():New( 0,0,200,900, oWnd )
   oPanel2  := TPanel():New( 204,0,500,900, oWnd )

   oPanel1:SetBrush( oBrush1 )
   oPanel2:SetBrush( oBrush2 )

   @ 200,0  SPLITTER oSplit ;
            HORIZONTAL ;
            PREVIOUS CONTROLS oPanel1 ;
            HINDS CONTROLS oPanel2 ;
            TOP MARGIN 80 ;
            BOTTOM MARGIN 80 ;
            SIZE 500, 4  PIXEL ;
            OF oWnd ;
            _3DLOOK

   oWnd:nWidth    := 500
   oWnd:nHeight   := 600

   ACTIVATE WINDOW oWnd CENTERED ON RESIZE oSplit:AdjClient()

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 03:03 PM
Please On dialog not run ok



Code (fw): Select all Collapse
Function test()
local oDlg,oFont aGrad
Local oPanel
Local nLevel:= 1
Local cFrtipo:= 1
Local nFrcolore:= 1


 DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8
   DEFINE DIALOG oDlg FROM 100, 100 TO 454,714;
                 STYLE DS_MODALFRAME + WS_POPUPWINDOW + WS_VISIBLE + WS_DLGFRAME + 4;
                 TITLE cTitle PIXEL FONT oFont

 aGrad := { { 0.5, 10899511, 16443068 }, { 0.5, 16443068, 10899511 } }
            DEFINE BRUSH oBrush GRADIENT aGrad
            oPanel:=TPanel(5,215,155,305,oDlg)
            oPanel:SetBrush( oBrush )
            oBrush:Resize( oPanel )

 ACTIVATE DIALOG oDlg;
                   ON INIT (Show_Raccoglitore(oPanel,nLevel,cFrtipo,nFrcolore))
return  nil
//-------------------------------------------------------------------------------------------------//

Function Function Show_Raccoglitore(oPanel,nLevel,cFrtipo,nFrcolore)
 Local oBmp
   local aBmpFaldoni:= { ".\bitmaps\png\imgFolderArancione.png"  ,;
                      ".\bitmaps\png\imgFolderBlu.png"        ,;
                      ".\bitmaps\png\imgFolderCiano.png"      ,;
                      ".\bitmaps\png\imgFolderGiallo.png"     ,;
                      ".\bitmaps\png\imgFolderGrigio.png"     ,;
                      ".\bitmaps\png\imgFolderMarrone.png"    ,;
                      ".\bitmaps\png\imgFolderNero.png"       ,;
                      ".\bitmaps\png\imgFolderRosa.png"       ,;
                      ".\bitmaps\png\imgFolderRosso.png"      ,;
                      ".\bitmaps\png\imgFolderVerde.png"      ,;
                      ".\bitmaps\png\imgFolderViola.png"   }



 @ 2,10 BTNBMP oBmp OF oPanel ;
                  SIZE (nLarghezzaRaccoglitori),(nAltezzaRaccoglitori) PIXEL TRANSPARENT ;
                  Prompt str2lines(alltrim(cFrtipo)," ")  ;
                  NOBORDER ;
                  Filename aBmpFaldoni[nFrcolore]   ;
                  CENTER ACTION NIL


 return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 03:18 PM

Mr Silvio

Please modify tpanel.prg as I suggested above.
Now it will work on windows and dialogs also.

Please remove
oBrush:Resize( oPanel ) from your code.
This is not required after we modify tpanel class.

We are including this change in FWH 16.12

Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 06:18 PM

Sorry ,
I have another Tpanel.prg because I have another paint method

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: brush on PANEL
Posted: Mon Dec 19, 2016 09:30 PM
Silvio.Falconi wrote:Sorry ,
I have another Tpanel.prg because I have another paint method

Is it an older version?
Regards



G. N. Rao.

Hyderabad, India