Mercurial > projects > dwt-addons
diff dwtx/draw2d/ColorConstants.d @ 102:0de61c6f08ca
Reduce static ctors
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 03:07:30 +0200 |
parents | 95307ad235d9 |
children | 2d6540440fe6 |
line wrap: on
line diff
--- a/dwtx/draw2d/ColorConstants.d Sun Aug 03 02:17:46 2008 +0200 +++ b/dwtx/draw2d/ColorConstants.d Sun Aug 03 03:07:30 2008 +0200 @@ -25,7 +25,6 @@ */ public struct ColorConstants { -class SystemColorFactory { private static Color getColor(int which) { Display display = Display.getCurrent(); if (display !is null) @@ -42,155 +41,316 @@ return result; } } -} /** * @see DWT#COLOR_WIDGET_HIGHLIGHT_SHADOW */ -static const Color buttonLightest; +private static Color buttonLightest_; +public static Color buttonLightest(){ + if( buttonLightest_ is null ){ + buttonLightest_ = getColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); + } + return buttonLightest_; +} /** * @see DWT#COLOR_WIDGET_BACKGROUND */ -static const Color button; +private static Color button_; +public static Color button(){ + if( button_ is null ){ + button_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + } + return button_; +} /** * @see DWT#COLOR_WIDGET_NORMAL_SHADOW */ -static const Color buttonDarker; +private static Color buttonDarker_; +public static Color buttonDarker(){ + if( buttonDarker_ is null ){ + buttonDarker_ = getColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); + } + return buttonDarker_; +} /** * @see DWT#COLOR_WIDGET_DARK_SHADOW */ -static const Color buttonDarkest; +private static Color buttonDarkest_; +public static Color buttonDarkest(){ + if( buttonDarkest_ is null ){ + buttonDarkest_ = getColor(DWT.COLOR_WIDGET_DARK_SHADOW); + } + return buttonDarkest_; +} /** * @see DWT#COLOR_LIST_BACKGROUND */ -static const Color listBackground; +private static Color listBackground_; +public static Color listBackground(){ + if( listBackground_ is null ){ + listBackground_ = getColor(DWT.COLOR_LIST_BACKGROUND); + } + return listBackground_; +} /** * @see DWT#COLOR_LIST_FOREGROUND */ -static const Color listForeground; +private static Color listForeground_; +public static Color listForeground(){ + if( listForeground_ is null ){ + listForeground_ = getColor(DWT.COLOR_LIST_FOREGROUND); + } + return listForeground_; +} /** * @see DWT#COLOR_WIDGET_BACKGROUND */ -static const Color menuBackground; +private static Color menuBackground_; +public static Color menuBackground(){ + if( menuBackground_ is null ){ + menuBackground_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + } + return menuBackground_; +} /** * @see DWT#COLOR_WIDGET_FOREGROUND */ -static const Color menuForeground; +private static Color menuForeground_; +public static Color menuForeground(){ + if( menuForeground_ is null ){ + menuForeground_ = getColor(DWT.COLOR_WIDGET_FOREGROUND); + } + return menuForeground_; +} /** * @see DWT#COLOR_LIST_SELECTION */ -static const Color menuBackgroundSelected; +private static Color menuBackgroundSelected_; +public static Color menuBackgroundSelected(){ + if( menuBackgroundSelected_ is null ){ + menuBackgroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION); + } + return menuBackgroundSelected_; +} /** * @see DWT#COLOR_LIST_SELECTION_TEXT */ -static const Color menuForegroundSelected; +private static Color menuForegroundSelected_; +public static Color menuForegroundSelected(){ + if( menuForegroundSelected_ is null ){ + menuForegroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION_TEXT); + } + return menuForegroundSelected_; +} /** * @see DWT#COLOR_TITLE_BACKGROUND */ -static const Color titleBackground; +private static Color titleBackground_; +public static Color titleBackground(){ + if( titleBackground_ is null ){ + titleBackground_ = getColor(DWT.COLOR_TITLE_BACKGROUND); + } + return titleBackground_; +} /** * @see DWT#COLOR_TITLE_BACKGROUND_GRADIENT */ -static const Color titleGradient; +private static Color titleGradient_; +public static Color titleGradient(){ + if( titleGradient_ is null ){ + titleGradient_ = getColor(DWT.COLOR_TITLE_BACKGROUND_GRADIENT); + } + return titleGradient_; +} /** * @see DWT#COLOR_TITLE_FOREGROUND */ -static const Color titleForeground; +private static Color titleForeground_; +public static Color titleForeground(){ + if( titleForeground_ is null ){ + titleForeground_ = getColor(DWT.COLOR_TITLE_FOREGROUND); + } + return titleForeground_; +} /** * @see DWT#COLOR_TITLE_INACTIVE_FOREGROUND */ -static const Color titleInactiveForeground; +private static Color titleInactiveForeground_; +public static Color titleInactiveForeground(){ + if( titleInactiveForeground_ is null ){ + titleInactiveForeground_ = getColor(DWT.COLOR_TITLE_INACTIVE_FOREGROUND); + } + return titleInactiveForeground_; +} /** * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND */ -static const Color titleInactiveBackground; +private static Color titleInactiveBackground_; +public static Color titleInactiveBackground(){ + if( titleInactiveBackground_ is null ){ + titleInactiveBackground_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND); + } + return titleInactiveBackground_; +} /** * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT */ -static const Color titleInactiveGradient; +private static Color titleInactiveGradient_; +public static Color titleInactiveGradient(){ + if( titleInactiveGradient_ is null ){ + titleInactiveGradient_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); + } + return titleInactiveGradient_; +} /** * @see DWT#COLOR_INFO_FOREGROUND */ -static const Color tooltipForeground; +private static Color tooltipForeground_; +public static Color tooltipForeground(){ + if( tooltipForeground_ is null ){ + tooltipForeground_ = getColor(DWT.COLOR_INFO_FOREGROUND); + } + return tooltipForeground_; +} /** * @see DWT#COLOR_INFO_BACKGROUND */ -static const Color tooltipBackground; +private static Color tooltipBackground_; +public static Color tooltipBackground(){ + if( tooltipBackground_ is null ){ + tooltipBackground_ = getColor(DWT.COLOR_INFO_BACKGROUND); + } + return tooltipBackground_; +} /* * Misc. colors */ /** One of the pre-defined colors */ -static const Color white; +private static Color white_; +public static Color white(){ + if( white_ is null ){ + white_ = new Color(null, 255, 255, 255); + } + return white_; +} /** One of the pre-defined colors */ -static const Color lightGray; +private static Color lightGray_; +public static Color lightGray(){ + if( lightGray_ is null ){ + lightGray_ = new Color(null, 192, 192, 192); + } + return lightGray_; +} /** One of the pre-defined colors */ -static const Color gray; +private static Color gray_; +public static Color gray(){ + if( gray_ is null ){ + gray_ = new Color(null, 128, 128, 128); + } + return gray_; +} /** One of the pre-defined colors */ -static const Color darkGray; +private static Color darkGray_; +public static Color darkGray(){ + if( darkGray_ is null ){ + darkGray_ = new Color(null, 64, 64, 64); + } + return darkGray_; +} /** One of the pre-defined colors */ -static const Color black; +private static Color black_; +public static Color black(){ + if( black_ is null ){ + black_ = new Color(null, 0, 0, 0); + } + return black_; +} /** One of the pre-defined colors */ -static const Color red; +private static Color red_; +public static Color red(){ + if( red_ is null ){ + red_ = new Color(null, 255, 0, 0); + } + return red_; +} /** One of the pre-defined colors */ -static const Color orange; +private static Color orange_; +public static Color orange(){ + if( orange_ is null ){ + orange_ = new Color(null, 255, 196, 0); + } + return orange_; +} /** One of the pre-defined colors */ -static const Color yellow; +private static Color yellow_; +public static Color yellow(){ + if( yellow_ is null ){ + yellow_ = new Color(null, 255, 255, 0); + } + return yellow_; +} /** One of the pre-defined colors */ -static const Color green; +private static Color green_; +public static Color green(){ + if( green_ is null ){ + green_ = new Color(null, 0, 255, 0); + } + return green_; +} /** One of the pre-defined colors */ -static const Color lightGreen; +private static Color lightGreen_; +public static Color lightGreen(){ + if( lightGreen_ is null ){ + lightGreen_ = new Color(null, 96, 255, 96); + } + return lightGreen_; +} /** One of the pre-defined colors */ -static const Color darkGreen; +private static Color darkGreen_; +public static Color darkGreen(){ + if( darkGreen_ is null ){ + darkGreen_ = new Color(null, 0, 127, 0); + } + return darkGreen_; +} /** One of the pre-defined colors */ -static const Color cyan; +private static Color cyan_; +public static Color cyan(){ + if( cyan_ is null ){ + cyan_ = new Color(null, 0, 255, 255); + } + return cyan_; +} /** One of the pre-defined colors */ -static const Color lightBlue; +private static Color lightBlue_; +public static Color lightBlue(){ + if( lightBlue_ is null ){ + lightBlue_ = new Color(null, 127, 127, 255); + } + return lightBlue_; +} /** One of the pre-defined colors */ -static const Color blue; +private static Color blue_; +public static Color blue(){ + if( blue_ is null ){ + blue_ = new Color(null, 0, 0, 255); + } + return blue_; +} /** One of the pre-defined colors */ -static const Color darkBlue; - +private static Color darkBlue_; +public static Color darkBlue(){ + if( darkBlue_ is null ){ + darkBlue_ = new Color(null, 0, 0, 127); + } + return 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); -} }