FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Antonio, Example colors and themes
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 01: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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02: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:

Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02: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.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02:29 PM

Very good my dear friend. Super many thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02:31 PM

Hello Giovanny,

Impressive- Respect!

Best regard,

Otto

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02: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?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 02:50 PM
Enrico Maria Giordano 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 (fw): Select all Collapse
ACTIVATE DIA... ;
   ON INIT(  CTRLS_COLORS_DLG( oDlg ) )
Code (fw): Select all Collapse
   FUNCTION CTRLS_COLORS_DLG(f_oDlgContainer)
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 03: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 03: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?

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 03:54 PM
This is my sample (to compile with theme manifest):
Code (fw): Select all Collapse
#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
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 04: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 (fw): Select all Collapse
   Local oColorSys := COLOR_SYS_OBJ()
  
   Redefine Say id 100 Prompt "Testando" color oColorSys:nClrStaticTextCharBG, oColorSys:nClrBackGround
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 04: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?

Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 04: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:
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 04:49 PM
Master Enrico, simple example. Continue... Get the other functions from Giovanny's class, and test them. Your imagination is your limit.
Code (fw): Select all Collapse
#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Antonio, Example colors and themes
Posted: Thu Dec 15, 2022 05: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?