FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ButtonBar style 2015
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ButtonBar style 2015
Posted: Tue May 10, 2016 02:56 PM
By default, we can use only 2 colors.
1) Normal color
2) Mouse Over or Pressed

If we want to have 3 colors
1) Normal Color
2) Pressed
3) Mouse Over
please try this sample and adopt:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Btntest()

   local oWnd

   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oWnd:oBar SIZE 32,32 2015

   oWnd:oBar:bClrGrad   := < |lInvert, oBtn|
      if oBtn != nil .and. oBtn:IsKindOf( "TBTNBMP" ) .and. oBtn:lPressed
         return { { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ; // Any clr grad of your choice
                  { 2/3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  }
      elseif lInvert
         return { { 1, RGB( 145, 201, 247 ), RGB( 145, 201, 247 ) } } // 2015 : invert
      endif
      return { { 1, RGB( 244, 244, 245 ), RGB( 244, 244, 245 ) } }    // 2015 normal
      >

   DEFINE BUTTON OF oWnd:oBar FILE "\fwh\bitmaps\16x16\new2.bmp"    ACTION BtnAction( This )
   DEFINE BUTTON OF oWnd:oBar FILE "\fwh\bitmaps\16x16\open3.bmp"   ACTION BtnAction( This )
   DEFINE BUTTON OF oWnd:oBar FILE "\fwh\bitmaps\16x16\zoom2.bmp"   ACTION BtnAction( This )
   DEFINE BUTTON OF oWnd:oBar FILE "\fwh\bitmaps\16x16\printer.bmp" ACTION BtnAction( This )

   ACTIVATE WINDOW oWnd CENTERED

return nil

static function BtnAction( oBtn )

   AEval( oBtn:oWnd:aControls, { |o| If( o:IsKindOf( "TBTNBMP" ), o:lPressed := .f., nil ) } )
   oBtn:lPressed := .t.
   oBtn:oWnd:Refresh()

return nil




In the above, button 3 is pressed earlier and mouse is now over 1st button.
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ButtonBar style 2015
Posted: Tue May 10, 2016 03:46 PM

Thanks Mr Rao this sample is good.. go to make a test to my app!!!

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: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ButtonBar style 2015
Posted: Tue May 10, 2016 04:05 PM
Dear Mr Rao,
I have a oBar and on this I have two oBar

DEFINE BUTTONBAR oBar OF ::oWndMain 3D SIZE 26, 84

oBar:bLClicked := { || NIL }
oBar:bRClicked := { || NIL }

@ -1, -1 BUTTONBAR ::oBar1 OF oBar 3D SIZE oBar:nWidth - 1, 29 ;
BUTTONSIZE 26, 27

//sample button
DEFINE BUTTON RESOURCE "RTFNEW" OF ::oBar1 GROUP ;
MESSAGE "Creates a new document" ;
TOOLTIP "New" NOBORDER ;
ACTION ::RTFNew()


::bLClicked := { || NIL }
::bRClicked := { || NIL }

AEval( ::aControls, { |x| x:oCursor := oCursor } )

@ 26, -1 BUTTONBAR ::oBar2 OF oBar 3D SIZE oBar:nWidth - 1, 29 ;
BUTTONSIZE 26, 27



//sample button
DEFINE BUTTON RESOURCE "RTFNEW" OF ::oBar1 GROUP ;
MESSAGE "Creates a new document" ;
TOOLTIP "New" NOBORDER ;
ACTION ::RTFNew()


::bLClicked := { || NIL }
::bRClicked := { || NIL }

AEval( ::aControls, { |x| x:oCursor := oCursor, ;
x:nLeft += 219, x:nRight += 219 } )


::=.t.
::=.t.
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: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ButtonBar style 2015
Posted: Tue May 10, 2016 04:24 PM
Mr Rao taking your test I made some modification ( as I have on my app)

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

function Btntest()

   local oWnd,oCursor
   DEFINE CURSOR oCursor HAND

   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oBar SIZE 26, 84 2015


   oBar:bLClicked := { || NIL }
   oBar:bRClicked := { || NIL }

   @ -1, -1 BUTTONBAR oBar1 OF oBar 3D SIZE oBar:nWidth - 1, 29 ;
            BUTTONSIZE 26, 27

   oBar1:l2015:=.t.

    oBar1:bClrGrad   := < |lInvert, oBtn|
      if oBtn != nil .and. oBtn:IsKindOf( "TBTNBMP" ) .and. oBtn:lPressed
         return { { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ; // Any clr grad of your choice
                  { 2/3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  }
      elseif lInvert
         return { { 1, RGB( 145, 201, 247 ), RGB( 145, 201, 247 ) } } // 2015 : invert
      endif
      return { { 1, RGB( 244, 244, 245 ), RGB( 244, 244, 245 ) } }    // 2015 normal
      >




   DEFINE BUTTON OF oBar1 FILE "c:\work\fwh\bitmaps\16x16\new2.bmp"    ACTION BtnAction( This )
   DEFINE BUTTON OF oBar1 FILE "c:\work\fwh\bitmaps\16x16\open3.bmp"   ACTION BtnAction( This )


   oBar1:bLClicked := { || NIL }
   oBar1:bRClicked := { || NIL }

   AEval( oBar1:aControls, { |x| x:oCursor := oCursor } )

   @ 26, -1 BUTTONBAR oBar2 OF oBar 3D SIZE oBar:nWidth - 1, 29 ;
            BUTTONSIZE 26, 27

  oBar2:l2015:=.t.

     oBar2:bClrGrad   := < |lInvert, oBtn|
      if oBtn != nil .and. oBtn:IsKindOf( "TBTNBMP" ) .and. oBtn:lPressed
         return { { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ; // Any clr grad of your choice
                  { 2/3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  }
      elseif lInvert
         return { { 1, RGB( 145, 201, 247 ), RGB( 145, 201, 247 ) } } // 2015 : invert
      endif
      return { { 1, RGB( 244, 244, 245 ), RGB( 244, 244, 245 ) } }    // 2015 normal
      >





    DEFINE BUTTON OF oBar2 FILE "c:\work\fwh\bitmaps\16x16\zoom2.bmp"   ACTION BtnAction( This )
   DEFINE BUTTON OF oBar2 FILE "c:\work\fwh\bitmaps\16x16\printer.bmp" ACTION BtnAction( This )






   ACTIVATE WINDOW oWnd CENTERED

return nil

static function BtnAction( oBtn )

   AEval( oBtn:oWnd:aControls, { |o| If( o:IsKindOf( "TBTNBMP" ), o:lPressed := .f., nil ) } )
   oBtn:lPressed := .t.
   oBtn:oWnd:Refresh()

return nil




and it seems run ok ...
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: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ButtonBar style 2015
Posted: Tue May 10, 2016 05:00 PM
Thanks Mr Rao



It was what I wanted to do
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

Continue the discussion