Home | History | Annotate | Download | only in draw2d
      1 /*******************************************************************************
      2  * Copyright (c) 2011 Google, Inc.
      3  * All rights reserved. This program and the accompanying materials
      4  * are made available under the terms of the Eclipse Public License v1.0
      5  * which accompanies this distribution, and is available at
      6  * http://www.eclipse.org/legal/epl-v10.html
      7  *
      8  * Contributors:
      9  *    Google, Inc. - initial API and implementation
     10  *******************************************************************************/
     11 package org.eclipse.wb.draw2d;
     12 
     13 import org.eclipse.swt.SWT;
     14 import org.eclipse.swt.graphics.Color;
     15 import org.eclipse.swt.widgets.Display;
     16 
     17 /**
     18  * A collection of color-related constants.
     19  *
     20  * @author lobas_av
     21  * @coverage gef.draw2d
     22  */
     23 public interface IColorConstants {
     24   /**
     25    * System color used to paint highlight shadow areas.
     26    */
     27   Color buttonLightest = Utils.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
     28   /**
     29    * System color used to paint background areas.
     30    */
     31   Color button = Utils.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
     32   /**
     33    * System color used to paint normal shadow areas.
     34    */
     35   Color buttonDarker = Utils.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
     36 //  /**
     37 //   * System color used to paint dark shadow areas.
     38 //   */
     39 //  Color buttonDarkest = Utils.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
     40   /**
     41    * System color used to paint list background areas.
     42    */
     43   Color listBackground = Utils.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
     44   /**
     45    * System color used to paint list foreground areas.
     46    */
     47   Color listForeground = Utils.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
     48   /**
     49    * System color used to paint list selection area.
     50    */
     51   Color listSelection = Utils.getSystemColor(SWT.COLOR_LIST_SELECTION);
     52   /**
     53    * System color used to paint list selection text.
     54    */
     55   Color listSelectionText = Utils.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
     56   /**
     57    * System color used to paint tooltip text.
     58    */
     59   Color tooltipForeground = Utils.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
     60   /**
     61    * System color used to paint tooltip background areas.
     62    */
     63   Color tooltipBackground = Utils.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
     64   /**
     65    * Miscellaneous colors.
     66    */
     67   Color lightGray = new Color(null, 192, 192, 192);
     68   Color gray = new Color(null, 128, 128, 128);
     69   Color darkGray = new Color(null, 64, 64, 64);
     70   Color black = new Color(null, 0, 0, 0);
     71   Color lightBlue = new Color(null, 127, 127, 255);
     72   Color darkBlue = new Color(null, 0, 0, 127);
     73 
     74   ////////////////////////////////////////////////////////////////////////////
     75   //
     76   // Utils
     77   //
     78   ////////////////////////////////////////////////////////////////////////////
     79   /**
     80    * Internal helper.
     81    */
     82   public static class Utils {
     83     /**
     84      * Invokes {@link Display#getSystemColor(int)} in UI thread.
     85      */
     86     private static Color getSystemColor(final int id) {
     87       final Color[] color = new Color[1];
     88       final Display display = Display.getDefault();
     89       display.syncExec(new Runnable() {
     90         @Override
     91         public void run() {
     92           color[0] = display.getSystemColor(id);
     93         }
     94       });
     95       return color[0];
     96     }
     97   }
     98 }