Antonio, Example colors and themes

Antonio, Example colors and themes

Postby Giovany Vecchi » Thu Dec 15, 2022 1:46 pm

Hello Antonio. I made the color management example I have.
Initially I started doing these routines with the purpose of creating a class to manage themes. The logic is easy to understand.
In this class I use only 3 themes, but it could have infinite themes already registered. The challenge now is the parameterization of all controls (Ribbon, xBrowse, DataPick etc) and I believe that with this example I am posting it will serve as a basis for fivewin to obtain these routines in the future.
For now the controls call is only in the tDialog class. It would have to call from the tWindow classes for windows to parameterize the controls in it.
Attached is an example with the sources:

https://www.sendspace.com/file/ouc5e2

Image
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 2:13 pm

I see that comboboxes are not themed. I would like to know how do you set a background color for themed comboboxes, as in your example below, please:

Image
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Antonio, Example colors and themes

Postby Giovany Vecchi » Thu Dec 15, 2022 2:18 pm

Hi Enrico. In combobox I have 2 ways to apply the colors:
1-Apply without removing the characteristics of Themed
2-Apply removing the characteristics of Themed
In mode 1 only the combobox body is shown in color.
In mode 2 every combobox is displayed

Download the example I posted and see the sources.
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Antonio, Example colors and themes

Postby karinha » Thu Dec 15, 2022 2:29 pm

Very good my dear friend. Super many thanks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7829
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Antonio, Example colors and themes

Postby Otto » Thu Dec 15, 2022 2:31 pm

Hello Giovanny,
Impressive- Respect!

Best regard,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 2:38 pm

Giovany Vecchi wrote:Hi Enrico. In combobox I have 2 ways to apply the colors:
1-Apply without removing the characteristics of Themed
2-Apply removing the characteristics of Themed
In mode 1 only the combobox body is shown in color.
In mode 2 every combobox is displayed

Download the example I posted and see the sources.


I'm interested in mode 1. But I don't understand what is the relevant code. I only need to color comboboxes background. Is there a simple way?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Antonio, Example colors and themes

Postby karinha » Thu Dec 15, 2022 2:50 pm

Enrico Maria Giordano wrote:
Giovany Vecchi wrote:Hi Enrico. In combobox I have 2 ways to apply the colors:
1-Apply without removing the characteristics of Themed
2-Apply removing the characteristics of Themed
In mode 1 only the combobox body is shown in color.
In mode 2 every combobox is displayed

Download the example I posted and see the sources.


I'm interested in mode 1. But I don't understand what is the relevant code. I only need to color comboboxes background. Is there a simple way?


Master Enrico:

Code: Select all  Expand view  RUN

ACTIVATE DIA... ;
   ON INIT(  CTRLS_COLORS_DLG( oDlg ) )
 


Code: Select all  Expand view  RUN

   FUNCTION CTRLS_COLORS_DLG(f_oDlgContainer)
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7829
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Antonio, Example colors and themes

Postby Antonio Linares » Thu Dec 15, 2022 3:00 pm

Dear Giovany,

Many thanks!

I have saved a copy here:
https://github.com/FiveTechSoft/FWH_tools/blob/master/giovany_tsttheme.zip
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 3:45 pm

It doesn't work for me. The dropdownlist part of the comboboxes is colored but the select item is not. What am I doing wrong?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 3:54 pm

This is my sample (to compile with theme manifest):

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := ""

    DEFINE DIALOG oDlg

    @ 1, 1 COMBOBOX cVar;
           SIZE 100, 13;
           ITEMS { "Test1", "Test2", "Test3" }

    ACTIVATE DIALOG oDlg;
             ON INIT ( COLOR_SYS_INIT( 1, .F., .F., 1, 0 ),;
                       CTRLS_COLORS_DLG( oDlg ) );
             CENTER

    RETURN NIL
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Antonio, Example colors and themes

Postby Giovany Vecchi » Thu Dec 15, 2022 4:28 pm

Hello Enrico, put option 2 in the parameter
COLOR_SYS_INIT( 1, .F., .F., 2, 0 )

The COLOR_SYS_INIT function is called only once at startup.
To select the theme colors in some control that you want to use differently, you create a variable object ex:


Code: Select all  Expand view  RUN

   Local oColorSys := COLOR_SYS_OBJ()
 
   Redefine Say id 100 Prompt "Testando" color oColorSys:nClrStaticTextCharBG, oColorSys:nClrBackGround

 
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 4:39 pm

With option 2 the combobox is not themed. I want it themed. Can you change my sample to set the background color of a themed combobox? Is it possible at all?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Antonio, Example colors and themes

Postby Giovany Vecchi » Thu Dec 15, 2022 4:44 pm

Enrico I tried every way and I couldn't. This also happens with RadioButtons and CheckBox.
Windows assumes the control appearance and I haven't found a way to change this.
I'm now leaving it to the forum experts :lol: :lol:
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Antonio, Example colors and themes

Postby karinha » Thu Dec 15, 2022 4:49 pm

Master Enrico, simple example. Continue... Get the other functions from Giovanny's class, and test them. Your imagination is your limit.

Code: Select all  Expand view  RUN

#include "Fivewin.ch"

FUNCTION Main()

   LOCAL oDlg, oCbx, oSayItem, oSayAt, oFont
   LOCAL cItem := ""
   LOCAL aRect := {}

   SET _3DLOOK ON

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 20

   DEFINE DIALOG oDlg TITLE "Test ComboBox Witn Color" FROM 110, 1 TO 450, 600 ;
      PIXEL FONT oFont COLOR CLR_BLACK, CLR_WHITE TRANSPARENT

   oDlg:lHelPicon := .F.

   @ 10, 10 COMBOBOX oCbx VAR cItem ITEMS { "Testing", "this", "ComboBox" }  ;
      SIZE 200, 460 OF oDlg PIXEL HEIGHTGET 50

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT( CTRLS_COLORS_DLG( oDlg ) )

   oFont:End()

RETURN NIL

FUNCTION CTRLS_COLORS_DLG( f_oDlgContainer )

   LOCAL lc_aCtrls := {}, lc_iFor := 0
   LOCAL lc_aItemsRadio := {}

   lc_aCtrls := f_oDlgContainer:aControls

   FOR lc_iFor := 1 TO Len( lc_aCtrls )

      IF ValType( lc_aCtrls[ lc_iFor ] ) == "O"

         IF lc_aCtrls[ lc_iFor ]:ClassName() == "TRADIO"

            /*
            AEval( lc_aCtrls[ lc_iFor ]:oRadMenu:aItems, ;
               {| _oRadId | { SetWindowTheme( _oRadId:hWnd, "", "" ), ;
               _oRadId:SetColor( st_oColorSys:nClrnRadioCheckBoxTxt, st_oColorSys:nClrBackGround ) } } )
            */


            aEval( lc_aCtrls[lc_iFor]:oRadMenu:aItems,                 ;
                   {|_oRadId|{ SetWindowTheme( _oRadId:hWnd, "", "" ), ;
                   _oRadId:SetColor( CLR_CYAN, CLR_WHITE ) } } )

         ELSEIF lc_aCtrls[ lc_iFor ]:ClassName() == "TCHECKBOX"

            SetWindowTheme( lc_aCtrls[ lc_iFor ]:hWnd, "", "" )
            Ctl3DLook( lc_aCtrls[ lc_iFor ]:hWnd, .F. )

            //lc_aCtrls[ lc_iFor ]:SetColor( st_oColorSys:nClrnRadioCheckBoxTxt, st_oColorSys:nClrBackGround )
            // G_COLOR_SYS( 31 ), G_COLOR_SYS( 1 )
            lc_aCtrls[ lc_iFor ]:SetColor( CLR_CYAN, CLR_WHITE )

         ELSEIF lc_aCtrls[ lc_iFor ]:ClassName() $ "TGET"

            //IF st_oColorSys:lGetsActiveColors

               // lc_aCtrls[ lc_iFor ]:SetColor( st_oColorSys:nClrGetTxtDis, st_oColorSys:nClrGetPaneDis )
               lc_aCtrls[ lc_iFor ]:SetColor( CLR_CYAN, CLR_WHITE )

            //ENDIF

         ELSEIF lc_aCtrls[ lc_iFor ]:ClassName() $ "TCOMBOBOX"

            //IF st_oColorSys:nComboBoxActiveColors > 0

            //   IF st_oColorSys:nComboBoxActiveColors == 2
            //      SetWindowTheme( lc_aCtrls[ lc_iFor ]:hWnd, "", "" )
            //      Ctl3DLook( lc_aCtrls[ lc_iFor ]:hWnd, .F. )
            //   ENDIF

            //   lc_aCtrls[ lc_iFor ]:oGet:SetColor( st_oColorSys:nClrGetTxtDis, st_oColorSys:nClrGetPaneDis )
            //    lc_aCtrls[lc_iFor]:SetColorFocus(st_oColorSys:nClrComboBoxFore) // user future
            //    lc_aCtrls[ lc_iFor ]:SetColor( st_oColorSys:nClrComboBoxFore, st_oColorSys:nClrComboBoxBack )

               lc_aCtrls[ lc_iFor ]:SetColor( CLR_MAGENTA, CLR_WHITE )

            //ENDIF

         ELSEIF lc_aCtrls[ lc_iFor ]:ClassName() $ "TLISTBOX;TTREEVIEW;TBAR"

            //IF st_oColorSys:nOthersActiveColors > 0
            //   IF st_oColorSys:nOthersActiveColors == 2
            //      SetWindowTheme( lc_aCtrls[ lc_iFor ]:hWnd, "", "" )
            //      Ctl3DLook( lc_aCtrls[ lc_iFor ]:hWnd, .F. )
            //   ENDIF
               //lc_aCtrls[ lc_iFor ]:SetColor( st_oColorSys:nClrOthersCtrlFore, st_oColorSys:nClrOthersCtrlBack )
               lc_aCtrls[ lc_iFor ]:SetColor( CLR_CYAN, CLR_WHITE )
           // ENDIF

         ELSEIF lc_aCtrls[ lc_iFor ]:ClassName() $ "TFOLDEREX"
            /*
            IF st_oColorSys:nOthersActiveColors > 0
               IF st_oColorSys:nOthersActiveColors == 2
                  SetWindowTheme( lc_aCtrls[ lc_iFor ]:hWnd, "", "" )
                  Ctl3DLook( lc_aCtrls[ lc_iFor ]:hWnd, .F. )
               ENDIF
               lc_aCtrls[ lc_iFor ]:aGradSel      := {  { 0.15, SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 30 ), SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 30 ) }, ;
                  { 0.85, st_oColorSys:nClrOthersCtrlBack, st_oColorSys:nClrOthersCtrlBack } }
               lc_aCtrls[ lc_iFor ]:aGradUnsel    := {  { 0.15, SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 10, .T. ), SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 10, .T. ) }, ;
                  { 0.85, st_oColorSys:nClrOthersCtrlBack, st_oColorSys:nClrOthersCtrlBack } }
               lc_aCtrls[ lc_iFor ]:aGradOverUnSel := {  { 0.15, st_oColorSys:nClrOthersCtrlBack, st_oColorSys:nClrOthersCtrlBack }, ;
                  { 0.85, SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 30 ), SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 30 ) } }
               lc_aCtrls[ lc_iFor ]:aGradOver     := {  { 0.15, SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 40 ), SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 40 ) }, ;
                  { 0.85, SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 40 ), SetBrightColor( st_oColorSys:nClrOthersCtrlBack, 40 ) } }

               lc_aCtrls[ lc_iFor ]:bClrText := {| o, n |  If( O:aEnable[ n ], ;
                  st_oColorSys:nClrOthersCtrlFore, ;
                  GetSysColor( COLOR_GRAYTEXT ) ) }

            ENDIF
            */


         ENDIF

      ENDIF

   NEXT

RETURN NIL

FUNCTION SetBrightColor(f_nColorRgb,f_nPercent,f_lNegative)
   Local nColorRgbReturn := 0
   Local nRgbRed, nRgbGreen, nRgbBlue
   
   Default f_nPercent := 30, f_lNegative := .F.
 
   nRgbRed   := nRgbRed(f_nColorRgb)
   nRgbGreen := nRgbGreen(f_nColorRgb)
   nRgbBlue  := nRgbBlue(f_nColorRgb)

   If f_lNegative

      If nRgbRed > 0
         nRgbRed   := Int(nRgbRed-((nRgbRed/100)*f_nPercent))
         If nRgbRed < 0
            nRgbRed := 0
         EndIf
      EndIf
     
      If nRgbGreen > 0
         nRgbGreen   := Int(nRgbGreen-((nRgbGreen/100)*f_nPercent))
         If nRgbGreen < 0
            nRgbGreen := 0
         EndIf
      EndIf
     
      If nRgbBlue > 0
         nRgbBlue   := Int(nRgbBlue-((nRgbBlue/100)*f_nPercent))
         If nRgbBlue < 0
            nRgbBlue := 0
         EndIf
      EndIf

   Else

      If nRgbRed > 0
         nRgbRed   := Int(nRgbRed+((nRgbRed/100)*f_nPercent))
         If nRgbRed > 255
            nRgbRed := 255
         EndIf
      EndIf
     
      If nRgbGreen > 0
         nRgbGreen   := Int(nRgbGreen+((nRgbGreen/100)*f_nPercent))
         If nRgbGreen > 255
            nRgbGreen := 255
         EndIf
      EndIf
     
      If nRgbBlue > 0
         nRgbBlue   := Int(nRgbBlue+((nRgbBlue/100)*f_nPercent))
         If nRgbBlue > 255
            nRgbBlue := 255
         EndIf
      EndIf

   EndIf
   
   nColorRgbReturn := nRgb(nRgbRed, nRgbGreen, nRgbBlue)
 
 Return nColorRgbReturn

// FIN /END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7829
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Antonio, Example colors and themes

Postby Enrico Maria Giordano » Thu Dec 15, 2022 5:41 pm

Giovany Vecchi wrote:Enrico I tried every way and I couldn't. This also happens with RadioButtons and CheckBox.
Windows assumes the control appearance and I haven't found a way to change this.
I'm now leaving it to the forum experts :lol: :lol:


Ok, I was afraid of that. Thank you anyway. Only, I don't understand your example image: I see two themed comboboxes with different background color, or am I wrong?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 55 guests