Function to get theme colors

Missing or incomplete OpenText Gupta product features? Discuss it here!
micsto
Germany
Posts: 986
Joined: 07 Mar 2017, 16:07
Location: Germany

Function to get theme colors

Post by micsto » 22 Jan 2010, 12:21

Dear Unify team,

I'd like to have a function to get theme colors, in particular the colors used in tables.
Without themes, it was easy to get the relevant colors with GetSysColor:

Code: Select all

COLORREF MTBLSUBCLASS::GetDefaultColorNoTheme( int iColorIndex )
{
   COLORREF clr = RGB( 0, 0, 0 );

   switch( iColorIndex )
   {
   case GDC_HDR_BKGND:
      clr = (COLORREF)GetSysColor( COLOR_3DFACE );
      break;

   case GDC_HDR_LINE:
      clr = (COLORREF)GetSysColor( COLOR_3DSHADOW );
      break;

   case GDC_HDR_3DHL:
      clr = (COLORREF)GetSysColor( COLOR_3DHILIGHT );
      break;

   case GDC_CELL_LINE:
      clr = Ctd.ColorGet( m_hWndTbl, COLOR_IndexWindowText );
      break;
   }

   return clr;
}
With themes, I have to determine the colors manually. That's very time consuming!
Second problem, if a new theme is introduced or colors change in a new release, again I have to determine the new/changed colors manually and must modify the internal M!Table function:

Code: Select all

COLORREF MTBLSUBCLASS::GetDefaultColor( int iColorIndex )
{
   COLORREF clr = RGB( 0, 0, 0 );

#ifdef CTD5x

   if ( QueryFlags( MTBL_FLAG_IGNORE_TD_THEME_COLORS ) )
   {
      clr = GetDefaultColorNoTheme( iColorIndex );
   }
   else
   {
      int iTheme = Ctd.ThemeGet( );

      switch( iColorIndex )
      {
      case GDC_HDR_BKGND:
         switch( iTheme )
         {
         case THEME_Office2007_R1:
            clr = RGB( 205, 205, 205 );
            break;
         case THEME_Office2007_R2_LunaBlue:
         case THEME_Office2007_R3_LunaBlue:
            clr = RGB( 191, 219, 255 );
            break;
         case THEME_Office2007_R2_Obsidian:
         case THEME_Office2007_R3_Obsidian:
            clr = RGB( 173, 174, 189 );
            break;
         case THEME_Office2007_R2_Silver:
         case THEME_Office2007_R3_Silver:
            clr = RGB( 244, 247, 251 );
            break;
         default:
            clr = GetDefaultColorNoTheme( iColorIndex );
         }
         break;

      case GDC_HDR_LINE:
         switch( iTheme )
         {
         case THEME_Office2007_R1:
            clr = RGB( 124, 101, 101 );
            break;
         case THEME_Office2007_R2_LunaBlue:
         case THEME_Office2007_R3_LunaBlue:
            clr = RGB( 0, 107, 245 );
            break;
         case THEME_Office2007_R2_Obsidian:
         case THEME_Office2007_R3_Obsidian:
            clr = RGB( 79, 82, 119 );
            break;
         case THEME_Office2007_R2_Silver:
         case THEME_Office2007_R3_Silver:
            clr = RGB( 74, 127, 197 );
            break;
         default:
            clr = GetDefaultColorNoTheme( iColorIndex );
         }
         break;

      case GDC_HDR_3DHL:
         switch( iTheme )
         {
         case THEME_Office2007_R1:
            clr = RGB( 242, 242, 242 );
            break;
         case THEME_Office2007_R2_LunaBlue:
         case THEME_Office2007_R3_LunaBlue:
            clr = RGB( 239, 246, 255 );
            break;
         case THEME_Office2007_R2_Obsidian:
         case THEME_Office2007_R3_Obsidian:
            clr = RGB( 234, 234, 238 );
            break;
         case THEME_Office2007_R2_Silver:
         case THEME_Office2007_R3_Silver:
            clr = RGB( 252, 253, 254 );
            break;
         default:
            clr = GetDefaultColorNoTheme( iColorIndex );
         }
         break;

      case GDC_CELL_LINE:
         switch( iTheme )
         {
         case THEME_Office2000:
         case THEME_NativeXP:
            clr = RGB( 128, 128, 128 );
            break;
         case THEME_Office2007_R1:
            clr = RGB( 153, 153, 153 );
            break;
         case THEME_Office2007_R2_LunaBlue:
         case THEME_Office2007_R3_LunaBlue:
            clr = RGB( 79, 156, 254 );
            break;
         case THEME_Office2007_R2_Obsidian:
         case THEME_Office2007_R3_Obsidian:
            clr = RGB( 122, 124, 148 );
            break;
         case THEME_Office2007_R2_Silver:
         case THEME_Office2007_R3_Silver:
            clr = RGB( 153, 180, 217 );
            break;
         default:
            clr = RGB( 112, 112, 112 );
         }
         break;
      }
   }

#else
   clr = GetDefaultColorNoTheme( iColorIndex );
#endif;

   return clr;
}
I already posted this request some time ago in the TD 5.1 forum, but there was no answer from Unify.

Regards
Michael

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3388
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Function to get theme colors

Post by Dave Rabelink » 22 Jan 2010, 16:48

+1 from me !
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Jeff Luther

Re: Function to get theme colors

Post by Jeff Luther » 22 Jan 2010, 19:30

Michael and Dave: FYI, I've added this as a 'new feature' SAL function here: TD-9351

micsto
Germany
Posts: 986
Joined: 07 Mar 2017, 16:07
Location: Germany

Re: Function to get theme colors

Post by micsto » 25 Jan 2010, 15:14

Thanks Jeff...

Return to “Enhancement suggestions”

Who is online

Users browsing this forum: [Ccbot] and 0 guests