Como cambio los colores en rbbtn ? SOLUCIONADO

Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Ruben Fernandez » Sat Jun 26, 2010 12:48 pm

Estimados:

Alguien tendria un ejemplo de como cambiar los colores de un rbbtn usado como boton no en las ribbon

Gracias
Last edited by Ruben Fernandez on Sun Jun 27, 2010 1:53 pm, edited 1 time in total.
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ?

Postby Daniel Garcia-Gil » Sat Jun 26, 2010 4:20 pm

Ruben


Code: Select all  Expand view

#include "fivewin.ch"
#include "ribbon.ch"

function main()
   local oWnd
   local oBtn1, oBtn2, oBtn3, oBtn4
   
   DEFINE WINDOW oWnd
   @ 30, 30 RBBTN oBtn1 PROMPT "&Ok" OF oWnd BORDER SIZE 100, 30 ROUND ROUNDSIZE 2 CENTER ;
            LINECOLORS RGB( 255,255,255 ), RGB( 255, 0, 0);
            GRADIANT { { 0.3, RGB( 254, 154, 128 ), RGB( 254, 154, 128 ) }, ;
                       { 0.7, RGB( 252, 85, 40 ), RGB( 181, 61, 29 ) } }
                       
   oBtn1:bClrGradNormal = { | lPressed | if ( lPressed,;
     { { 1, RGB( 181, 61, 29 ), RGB( 254, 154, 128 ) } },;
     { { 1, RGB( 254, 154, 128 ), RGB( 181, 61, 29 ) } } ) }


   ACTIVATE WINDOW oWnd
   
return nil
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ?

Postby Ruben Fernandez » Sat Jun 26, 2010 6:49 pm

Daniel: Toman el color del fondo del Dialogo, solo cuando paso el raton por encima toman el color, que luego
desaparece cuando vuelvo a sacar el raton.

Alguna otra sugerencia...
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ?

Postby Daniel Garcia-Gil » Sat Jun 26, 2010 8:06 pm

Ruben

a mi me trabaja perfectamente el ejemplo que te puse, podrias colocar el codigo que estas usando de forma que podamos reproducir el mismo error

Normal
Image

Mouse Over
Image

Left Button Down (presionado)
Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ?

Postby Ruben Fernandez » Sun Jun 27, 2010 1:41 am

Daniel: Te dejo el código

REDEFINE RBBTN oBoton2 ID 250 OF oDlg ;
ACTION( lSaleAdd:=.t., oDlg:End()) BITMAP "SALIR2" ;
PROMPT "&Cancelar" LEFT BORDER ROUND ROUNDSIZE 2 ;
LINECOLORS RGB( 255,255,255 ), RGB( 255, 0, 0);
GRADIANT { { 0.3, RGB( 254, 154, 128 ), RGB( 254, 154, 128 ) }, ;
{ 0.7, RGB( 252, 85, 40 ), RGB( 181, 61, 29 ) } }

oBoton2:bClrGradNormal = { | lPressed | if ( lPressed,;
{ { 1, RGB( 181, 61, 29 ), RGB( 254, 154, 128 ) } },;
{ { 1, RGB( 254, 154, 128 ), RGB( 181, 61, 29 ) } } ) }

Gracias...
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ?

Postby Daniel Garcia-Gil » Sun Jun 27, 2010 10:47 am

Ruben...


dentro del recurso debes definir el botton como TRBBTN (tipo custom)
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ?

Postby Ruben Fernandez » Sun Jun 27, 2010 12:22 pm

Daniel: Lo tengo como tu dices, lo que ocurre es que el Dialogo
tiene un brush y esta así: Define Dialog oDlg......Brush oBrush Transparent <<<--- Este Transparent me
evita declarar los SAY que tengo en el dialogo, o sea que me evita hacer un Redefine Say ....Transparent por cada say.

Si saco el Transparent del dialogo funciona bien.

Como puedo hacer para que el boton no sea transparente, si hago oBtn:lTransparent:=.f. el boton sigue transparente.

Gracias
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ?

Postby Daniel Garcia-Gil » Sun Jun 27, 2010 1:03 pm

Ruben.

Cuando usas transparent en el dialogo ese asigna la transparebcia a sus controles hijos a execpcion de algunos, como es el caso de TGET, TXBROWSE, TBTNBMP, etc
te planteo 2 formas de resolverlo
1. sin tocar la clase TDIALOG:
en el ON INT del comando ACTIVATE asignas los controles que no seran transparentes, antes no puedes hacerlo pq el dialogo en si aun no se ha "creado"

Code: Select all  Expand view
ACTIVATE DIALOG oDlg ON INIT oBtn:lTransparent := .F.


2. Modificar la clase TDIALOG
y asignale la execpcion en em METHOD INITIATE
cambia estas lineas
Code: Select all  Expand view

#ifdef __HARBOUR__
      AEval( ::aControls,;
             { | o | If( ! Upper( o:ClassName() ) $ ;
             "TGET;TMULTIGET;TBTNBMP;TCOMBOBOX;TWBROWSE;TCBROWSE;TXBROWSE;TLISTBOX;TRBTN" .and. ;
               ! o:IsKindOf( 'TXBROWSE' ),;
                         o:lTransparent := .t.,) } )
#else
      AEval( ::aControls,;
             { | o | If( ! Upper( o:ClassName() ) $ ;
             "TGET;TMULTIGET;TBTNBMP;TCOMBOBOX;TWBROWSE;TCBROWSE;TXBROWSE;TLISTBOX;TRBTN",;
                         o:lTransparent := .t.,) } )
#endif
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Ruben Fernandez » Sun Jun 27, 2010 1:53 pm

Daniel: GRACIAS, funcionando.
Por el momento le asignare la clausola en el on init, luego vere si se puede asignarle los colores con SkinButtons()...

Gracias de nuevo.
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Raymundo Islas M. » Mon Jun 28, 2010 6:04 pm

Ruben,

Perdona que pregunte algo ya que cerraste tu tema.


Daniel : Si cambio los colores directamente a la clase, para que todos los botones manejen el mismo color (degradado) afectaria a los botones que tengo en la ribbon ?? o es otra clase aparte ?


Saludos
FWH 10.6 + xHarbour + Borland 582
User avatar
Raymundo Islas M.
 
Posts: 592
Joined: Tue Mar 14, 2006 11:34 pm
Location: Acapulco, Gro. MEXICO

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Ruben Fernandez » Mon Jun 28, 2010 7:17 pm

Raymundo: No hay problema, peguntando se aprende.

Creo que si cambias los colores desde la clase, cambiaran los colores de los botones de la ribbon.

Para asegurarte podrías hacer una prueba, aunque creo que hay que esperar que se puedan usar con SkinButtons()

Saludos
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Daniel Garcia-Gil » Mon Jun 28, 2010 8:17 pm

Raymundo Islas M. wrote:Daniel : Si cambio los colores directamente a la clase, para que todos los botones manejen el mismo color (degradado) afectaria a los botones que tengo en la ribbon ?? o es otra clase aparte ?


Si efectivamente se cambian todos los colores...

Ruben Fernandez wrote:Para asegurarte podrías hacer una prueba, aunque creo que hay que esperar que se puedan usar con SkinButtons()

Ruben, SkinButtons es una funcion que trabaja sobre los botones propios de window (los qu eno sproporciona el api), la clase TRBtn, TBtnBmp son propias de fivewin, por lo tanto, dicha funcion no trabaja sobre estas clases
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Daniel Garcia-Gil » Mon Jun 28, 2010 9:06 pm

Ruben...

Te dejo un ejemplo de como implementar tu propia clase SkinButton

http://www.sitasoft.net/fivewin/samples/rbskin.zip

Code: Select all  Expand view

#include "fivewin.ch"
#include "ribbon.ch"

#define SKIN_DEFAULT  1
#define SKIN_RED      2
#define SKIN_GREEN    3
#define SKIN_GRAY     4


function main()
   local oWnd
   local oBtn1, oBtn2, oBtn3
   local aSkin := Array( 4 )
   
   
   BuildSkin( aSkin )
   DEFINE WINDOW oWnd

   @ 30, 30 RBBTN oBtn1 PROMPT "&Ok" OF oWnd BORDER SIZE 100, 30 ROUND ROUNDSIZE 2 CENTER
   
   @ 70, 30 RBBTN oBtn2 PROMPT "&Ok" OF oWnd BORDER SIZE 100, 30 ROUND ROUNDSIZE 2 CENTER
   
   @ 110, 30 RBBTN oBtn3 PROMPT "&Ok" OF oWnd BORDER SIZE 100, 30 ROUND ROUNDSIZE 2 CENTER ;
             ACTION ( aSkin[ SKIN_DEFAULT ]:SetSkin( oBtn1 ), oBtn1:Refresh() )
       

   aSkin[ SKIN_RED ]:SetSkin( oBtn1 )
   aSkin[ SKIN_GREEN ]:SetSkin( oBtn2 )
   aSkin[ SKIN_GRAY ]:SetSkin( oBtn3 )

   ACTIVATE WINDOW oWnd
   
return nil


FUNCTION BuildSkin( aSkin )
   
   
   //default skin
   aSkin[ SKIN_DEFAULT ] = TSkinRBtn():New()
   
   //skin red
   aSkin[ SKIN_RED ] = TSkinRBtn():New()
   aSkin[ SKIN_RED ]:nClrBoxIn  = RGB( 255,255,255 )
   aSkin[ SKIN_RED ]:nClrBoxOut = RGB( 255, 0, 0)
   aSkin[ SKIN_RED ]:aGradiant  = { { 0.3, RGB( 254, 154, 128 ), RGB( 254, 154, 128 ) }, ;
                                    { 0.7, RGB( 252, 85, 40 ), RGB( 181, 61, 29 ) } }  
   aSkin[ SKIN_RED ]:bClrGradNormal = { | lPressed | if ( lPressed,;
                                        { { 1, RGB( 181, 61, 29 ), RGB( 254, 154, 128 ) } },;
                                        { { 1, RGB( 254, 154, 128 ), RGB( 181, 61, 29 ) } } ) }                                    

   //skin green
   aSkin[ SKIN_GREEN ] = TSkinRBtn():New()
   aSkin[ SKIN_GREEN ]:nClrBoxIn  = RGB( 255,255,255 )
   aSkin[ SKIN_GREEN ]:nClrBoxOut = RGB( 100, 200, 100 )
   aSkin[ SKIN_GREEN ]:aGradiant  = { { 0.3, RGB( 150, 255, 150 ), RGB( 150, 255, 150 ) }, ;
                                    { 0.7, RGB( 180, 230, 100  ), RGB( 200, 255, 200 ) } }  
   aSkin[ SKIN_GREEN ]:bClrGradNormal = { | lPressed | if ( lPressed,;
                                        { { 1, RGB( 200, 255, 200 ), RGB( 110, 255, 110 ) } },;
                                        { { 1, RGB( 110, 255, 110 ), RGB( 200, 255, 200 ) } } ) }  

   //skin green
   aSkin[ SKIN_GRAY ] = TSkinRBtn():New()
   aSkin[ SKIN_GRAY ]:nClrBoxIn  = RGB( 200,200,200 )
   aSkin[ SKIN_GRAY ]:nClrBoxOut = RGB( 100, 100, 100 )
   aSkin[ SKIN_GRAY ]:aGradiant  = { { 0.3, RGB( 200, 200, 200 ), RGB( 200, 200, 200 ) }, ;
                                    { 0.7, RGB( 200, 200, 200  ), RGB( 100, 100, 100 ) } }  
   aSkin[ SKIN_GRAY ]:bClrGradNormal = { | lPressed | if ( lPressed,;
                                        { { 1, RGB( 200, 200, 200 ), RGB( 100, 100, 100 ) } },;
                                        { { 1, RGB( 100, 100, 100 ), RGB( 200, 200, 200 ) } } ) }    
   
RETURN NIL

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

#define BLUE0               RGB( 218, 229, 243 )      
#define BLUE1               RGB( 199, 216, 237 )
#define BLUEBOX0            RGB( 141, 178, 227 )      
#define BLUEBOX2            RGB( 237, 242, 248 )

CLASS TSkinRBtn

   DATA   bClrGradNormal
   DATA   aClrGradOver
   DATA   bClrGradSubOver
   DATA   aClrGradUnder
   DATA   aClrGradBack
   DATA   aGradiant
   DATA   bClrText
   DATA   bClrGradSelectPress
   DATA   bClrGradSelect
   DATA   aClrGradBtnGr
   DATA   nClrBoxIn, nClrBoxOut
   
   METHOD New( bClrGradNormal, aClrGradOver, bClrGradSubOver, aClrGradUnder,;
               aClrGradBack, aGradiant, bClrText, bClrGradSelectPress, bClrGradSelect,;
               aClrGradBtnGr )
               
   METHOD SetSkin( oRBtn )              
               
ENDCLASS

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

METHOD New( bClrGradNormal, aClrGradOver, bClrGradSubOver, aClrGradUnder,;
               aClrGradBack, aGradiant, bClrText, bClrGradSelectPress, bClrGradSelect,;
               aClrGradBtnGr, nClrBoxIn, nClrBoxOut, nRound ) CLASS TSkinRBtn
   
   DEFAULT aGradiant := { {0.3, BLUE0, BLUE0 }, { 0.7, BLUE1, BLUE0 } }
   
   DEFAULT nClrBoxOut := BLUEBOX0, nClrBoxIn := BLUEBOX2
           
   DEFAULT bClrGradNormal := { | lPressed | if ( lPressed,;
     { ;
      { 1/3, nRGB( 254, 215, 169 ), nRGB( 251, 179, 99 ) } , ;
      { 2/3, nRGB( 250, 155,  50 ), nRGB( 253, 239,  173 ) } ;
     },;
     {;
      { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 147 ) } , ;
      { 2/3, nRGB( 255, 215,  86 ), nRGB( 255, 231,  153 ) } ;
     } ) }

   DEFAULT bClrGradSubOver := { | lPressed | if ( lPressed,;
     { ;
      { 2/3, nRGB( 248, 187, 107 ), nRGB( 253, 171, 98 ) } , ;
      { 1/3, nRGB( 253, 154,  63 ), nRGB( 255, 164,  64 ) };
     },;
     {;
       { 2/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 147 ) } , ;
       { 1/3, nRGB( 255, 215,  86 ), nRGB( 255, 231,  153 ) };
      } ) }
         
   DEFAULT aClrGradUnder := {|| { {1 , nRGB( 248,186,107), nRGB( 255, 253, 222 ) } } }
   
   DEFAULT aClrGradOver := {|| { {1 , nRGB( 255,215,84), nRGB( 255, 253, 222 ) } } }
     
   DEFAULT aClrGradBack := { { 1 , nRGB( 255, 253, 222 ), nRGB( 255, 253, 222 ) } }
         
   DEFAULT bClrGradSelect := {| lSelected | if( lSelected ,;
    { ;
        {1/3, nRGB( 253,212,168 ), nRGB( 251,178,99 ) },;
      {2/3, nRGB( 250,157,52 ), nRGB( 252,234,163 ) };
    },;
    { ;
        {1/3, nRGB( 245,177,110 ), nRGB( 243,165,89 ) },;
      {2/3, nRGB( 216,136,52 ), nRGB( 249,202,98 ) } ;
    } ) }      

   DEFAULT bClrGradSelectPress := {| lPressed | if( lPressed ,;
    { ;
      { 1/3, nRGB( 248, 187, 107 ), nRGB( 253, 171, 98 ) } , ;
      { 2/3, nRGB( 253, 154,  63 ), nRGB( 255, 164,  64 ) };
    },;
    { ;
        {1/3, nRGB( 245,177,110 ), nRGB( 243,165,89 ) },;
      {2/3, nRGB( 216,136,52 ), nRGB( 249,202,98 ) } ;
    } ) }      
    
    DEFAULT aClrGradBtnGr := {|| ;
    { ;
      { 1/3, nRGB( 200, 219, 238 ), nRGB( 201, 221, 246 ) } , ;
      { 2/3, nRGB( 192, 212, 237 ), nRGB( 208, 225, 247 ) };
    } }

    
   ::bClrGradNormal = bClrGradNormal
   ::aClrGradOver   = aClrGradOver
   ::bClrGradSubOver= bClrGradSubOver
   ::aClrGradUnder  = aClrGradUnder
   ::aClrGradBack   = aClrGradBack
   ::bClrGradSelect = bClrGradSelect
   ::bClrGradSelectPress = bClrGradSelectPress
   ::aClrGradBtnGr  = aClrGradBtnGr
   ::aGradiant      = aGradiant
   ::nClrBoxIn      = nClrBoxIn
   ::nClrBoxOut     = nClrBoxOut
   
   
RETURN Self              

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

METHOD SetSkin( oRBtn ) CLASS TSkinRBtn

   IF oRBtn:hBack != NIL
     DeleteObject( oRBtn:hBack )
     oRBtn:hBack = NIL
   ENDIF

   oRBtn:bClrGradNormal       = ::bClrGradNormal    
   oRBtn:aClrGradOver         = ::aClrGradOver      
   oRBtn:bClrGradSubOver      = ::bClrGradSubOver    
   oRBtn:aClrGradUnder        = ::aClrGradUnder      
   oRBtn:aClrGradBack         = ::aClrGradBack      
   oRBtn:bClrGradSelect       = ::bClrGradSelect    
   oRBtn:bClrGradSelectPress  = ::bClrGradSelectPress
   oRBtn:aClrGradBtnGr        = ::aClrGradBtnGr      
   oRBtn:aGradiant            = ::aGradiant          
   oRBtn:nClrBoxIn            = ::nClrBoxIn
   oRBtn:nClrBoxOut           = ::nClrBoxOut  
   
RETURN NIL
 


Image

Cambiandolo dinamicamente (en tiempo de ejecucion)
Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como cambio los colores en rbbtn ? SOLUCIONADO

Postby Ruben Fernandez » Tue Jun 29, 2010 12:23 am

Daniel: simplemente ESPECTACULAR.

Muchas gracias por tu tiempo.
Gracias y Saludos
Ruben Fernandez - Uruguay
FWH 11.06, Harbour, Borland 5.82
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 24 guests