Mercurial > projects > dwt-addons
view dwtx/draw2d/ColorConstants.d @ 98:95307ad235d9
Added Draw2d code, still work in progress
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 00:52:14 +0200 |
parents | |
children | 0de61c6f08ca |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Port to the D programming language: * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwtx.draw2d.ColorConstants; import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; import tango.core.sync.Mutex; import dwt.DWT; import dwt.graphics.Color; import dwt.widgets.Display; /** * A collection of color-related constants. */ public struct ColorConstants { class SystemColorFactory { private static Color getColor(int which) { Display display = Display.getCurrent(); if (display !is null) return display.getSystemColor(which); display = Display.getDefault(); Color result; scope Mutex mutex = new Mutex; display.syncExec(dgRunnable( { synchronized (mutex) { result = Display.getCurrent().getSystemColor(which); } } )); synchronized (mutex) { return result; } } } /** * @see DWT#COLOR_WIDGET_HIGHLIGHT_SHADOW */ static const Color buttonLightest; /** * @see DWT#COLOR_WIDGET_BACKGROUND */ static const Color button; /** * @see DWT#COLOR_WIDGET_NORMAL_SHADOW */ static const Color buttonDarker; /** * @see DWT#COLOR_WIDGET_DARK_SHADOW */ static const Color buttonDarkest; /** * @see DWT#COLOR_LIST_BACKGROUND */ static const Color listBackground; /** * @see DWT#COLOR_LIST_FOREGROUND */ static const Color listForeground; /** * @see DWT#COLOR_WIDGET_BACKGROUND */ static const Color menuBackground; /** * @see DWT#COLOR_WIDGET_FOREGROUND */ static const Color menuForeground; /** * @see DWT#COLOR_LIST_SELECTION */ static const Color menuBackgroundSelected; /** * @see DWT#COLOR_LIST_SELECTION_TEXT */ static const Color menuForegroundSelected; /** * @see DWT#COLOR_TITLE_BACKGROUND */ static const Color titleBackground; /** * @see DWT#COLOR_TITLE_BACKGROUND_GRADIENT */ static const Color titleGradient; /** * @see DWT#COLOR_TITLE_FOREGROUND */ static const Color titleForeground; /** * @see DWT#COLOR_TITLE_INACTIVE_FOREGROUND */ static const Color titleInactiveForeground; /** * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND */ static const Color titleInactiveBackground; /** * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT */ static const Color titleInactiveGradient; /** * @see DWT#COLOR_INFO_FOREGROUND */ static const Color tooltipForeground; /** * @see DWT#COLOR_INFO_BACKGROUND */ static const Color tooltipBackground; /* * Misc. colors */ /** One of the pre-defined colors */ static const Color white; /** One of the pre-defined colors */ static const Color lightGray; /** One of the pre-defined colors */ static const Color gray; /** One of the pre-defined colors */ static const Color darkGray; /** One of the pre-defined colors */ static const Color black; /** One of the pre-defined colors */ static const Color red; /** One of the pre-defined colors */ static const Color orange; /** One of the pre-defined colors */ static const Color yellow; /** One of the pre-defined colors */ static const Color green; /** One of the pre-defined colors */ static const Color lightGreen; /** One of the pre-defined colors */ static const Color darkGreen; /** One of the pre-defined colors */ static const Color cyan; /** One of the pre-defined colors */ static const Color lightBlue; /** One of the pre-defined colors */ static const Color blue; /** One of the pre-defined colors */ static const Color darkBlue; static this(){ buttonLightest = SystemColorFactory.getColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); button = SystemColorFactory.getColor(DWT.COLOR_WIDGET_BACKGROUND); buttonDarker = SystemColorFactory.getColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); buttonDarkest = SystemColorFactory.getColor(DWT.COLOR_WIDGET_DARK_SHADOW); listBackground = SystemColorFactory.getColor(DWT.COLOR_LIST_BACKGROUND); listForeground = SystemColorFactory.getColor(DWT.COLOR_LIST_FOREGROUND); menuBackground = SystemColorFactory.getColor(DWT.COLOR_WIDGET_BACKGROUND); menuForeground = SystemColorFactory.getColor(DWT.COLOR_WIDGET_FOREGROUND); menuBackgroundSelected = SystemColorFactory.getColor(DWT.COLOR_LIST_SELECTION); menuForegroundSelected = SystemColorFactory.getColor(DWT.COLOR_LIST_SELECTION_TEXT); titleBackground = SystemColorFactory.getColor(DWT.COLOR_TITLE_BACKGROUND); titleGradient = SystemColorFactory.getColor(DWT.COLOR_TITLE_BACKGROUND_GRADIENT); titleForeground = SystemColorFactory.getColor(DWT.COLOR_TITLE_FOREGROUND); titleInactiveForeground = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_FOREGROUND); titleInactiveBackground = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND); titleInactiveGradient = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); tooltipForeground = SystemColorFactory.getColor(DWT.COLOR_INFO_FOREGROUND); tooltipBackground = SystemColorFactory.getColor(DWT.COLOR_INFO_BACKGROUND); white = new Color(null, 255, 255, 255); lightGray = new Color(null, 192, 192, 192); gray = new Color(null, 128, 128, 128); darkGray = new Color(null, 64, 64, 64); black = new Color(null, 0, 0, 0); red = new Color(null, 255, 0, 0); orange = new Color(null, 255, 196, 0); yellow = new Color(null, 255, 255, 0); green = new Color(null, 0, 255, 0); lightGreen = new Color(null, 96, 255, 96); darkGreen = new Color(null, 0, 127, 0); cyan = new Color(null, 0, 255, 255); lightBlue = new Color(null, 127, 127, 255); blue = new Color(null, 0, 0, 255); darkBlue = new Color(null, 0, 0, 127); } }