brush on PANEL

brush on PANEL

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby ukoenig » 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

Image

Image

best regards
Uwe :D
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

Re: brush on PANEL

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby nageswaragunupudi » Sat Dec 17, 2016 3:40 am

Code: Select all  Expand view
aGrad := { .... your gradient array }
DEFINE BRUSH oBrush GRADIENT aGrad
oPanel:SetBrush( oBrush )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby Silvio.Falconi » Sat Dec 17, 2016 12:14 pm

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby Silvio.Falconi » Mon Dec 19, 2016 1: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 1:58 pm

You are right.
Let me check.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 2:17 pm

Please try this
Code: Select all  Expand view
  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
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby ukoenig » Mon Dec 19, 2016 2:18 pm

I couldn't detect anything wrong on panel-brushpainting.
The only thing is, I'm still working on splitter-panel-adjustments

Image

Code: Select all  Expand view


// 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 :D
Last edited by ukoenig on Mon Dec 19, 2016 2:29 pm, edited 6 times 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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 2: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
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 2:47 pm

Please make this modification in tpanel.prg:

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


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


Now you can try Gradient brushes and resizeable image brushes:
Here is a sample using simple Splitter
Code: Select all  Expand view

#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
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby Silvio.Falconi » Mon Dec 19, 2016 3:03 pm

Please On dialog not run ok

Image

Code: Select all  Expand view

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 3: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
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: brush on PANEL

Postby Silvio.Falconi » Mon Dec 19, 2016 6: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: brush on PANEL

Postby nageswaragunupudi » Mon Dec 19, 2016 9: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
User avatar
nageswaragunupudi
 
Posts: 10471
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests