annotate dwtx/draw2d/ButtonBorder.d @ 103:2d6540440fe6

Replace static ctors with lazy init.
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 17:01:51 +0200
parents 0de61c6f08ca
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module dwtx.draw2d.ButtonBorder;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 import dwt.dwthelper.utils;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 import dwt.graphics.Color;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwtx.draw2d.geometry.Insets;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwtx.draw2d.SchemeBorder;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwtx.draw2d.Border;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import dwtx.draw2d.IFigure;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import dwtx.draw2d.Graphics;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import dwtx.draw2d.Clickable;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 import dwtx.draw2d.ButtonModel;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 import dwtx.draw2d.ColorConstants;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 * Creates a border for a clickable type of figure, which works in conjunction with the
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 * Figure and its model. This border adjusts itself to the various states the model of the
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * figure could be. This border uses an extended {@link SchemeBorder.Scheme Scheme}
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * called {@link ButtonScheme} which provides more information required by border to
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 * handle the the states of the model.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * @see Scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 * @see ButtonScheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 public class ButtonBorder
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 : SchemeBorder
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 alias SchemeBorder.paint paint;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 * Default button border.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * @see SCHEMES#BUTTON
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
47 private static Border BUTTON_;
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
48 public static Border BUTTON(){
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
49 if( BUTTON_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
50 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
51 if( BUTTON_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
52 BUTTON_ = new ButtonBorder(SCHEMES.BUTTON);
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
53 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
54 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
55 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
56 return BUTTON_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
57 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 * Inverted hightlight colors from BUTTON.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 * @see SCHEMES#BUTTON_CONTRAST
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
62 private static Border BUTTON_CONTRAST_;
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
63 public static Border BUTTON_CONTRAST(){
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
64 if( BUTTON_CONTRAST_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
65 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
66 if( BUTTON_CONTRAST_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
67 BUTTON_CONTRAST_ = new ButtonBorder(SCHEMES.BUTTON_CONTRAST);
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
68 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
69 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
70 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
71 return BUTTON_CONTRAST_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
72 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 * Used for scrollbar buttons.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 * @see SCHEMES#BUTTON_SCROLLBAR
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
77 private static Border BUTTON_SCROLLBAR_;
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
78 public static Border BUTTON_SCROLLBAR(){
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
79 if( BUTTON_SCROLLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
80 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
81 if( BUTTON_SCROLLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
82 BUTTON_SCROLLBAR_ = new ButtonBorder(SCHEMES.BUTTON_SCROLLBAR);
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
83 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
84 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
85 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
86 return BUTTON_SCROLLBAR_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
87 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 * Used for toolbar buttons.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 * @see SCHEMES#TOOLBAR
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
92 private static Border TOOLBAR_;
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
93 public static Border TOOLBAR(){
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
94 if( TOOLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
95 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
96 if( TOOLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
97 TOOLBAR_ = new ButtonBorder(SCHEMES.TOOLBAR);
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
98 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
99 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
100 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
101 return TOOLBAR_;
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 * Provides for a scheme to represent the borders of clickable figures like buttons.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 * Though similar to the {@link SchemeBorder.Scheme Scheme} it supports an extra set of
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 * borders for the pressed states.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 public static class ButtonScheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 : Scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 private Color[]
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 highlightPressed = null,
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 shadowPressed = null;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 * Constructs a new button scheme where the input colors are the colors for the
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 * top-left and bottom-right sides of the border. These colors serve as the colors
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 * when the border is in a pressed state too. The width of each side is determined by
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 * the number of colors passed in as input.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 * @param highlight Colors for the top-left sides of the border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 * @param shadow Colors for the bottom-right sides of the border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 public this(Color[] highlight, Color[] shadow) {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 highlightPressed = this.highlight = highlight;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 shadowPressed = this.shadow = shadow;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 init();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 * Constructs a new button scheme where the input colors are the colors for the
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 * top-left and bottom-right sides of the border, for the normal and pressed states.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 * The width of each side is determined by the number of colors passed in as input.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 * @param hl Colors for the top-left sides of the border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 * @param sh Colors for the bottom-right sides of the border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 * @param hlp Colors for the top-left sides of the border when figure is pressed
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 * @param shp Colors for the bottom-right sides of the border when figure is pressed
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 public this(Color[] hl, Color[] sh, Color[] hlp, Color[] shp) {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 highlight = hl;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 shadow = sh;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 highlightPressed = hlp;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 shadowPressed = shp;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 init();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 * Calculates and returns the Insets for this border. The calculations are based on
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 * the number of normal and pressed, highlight and shadow colors.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 * @return The insets for this border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 protected Insets calculateInsets() {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159 int br = 1 + Math.max(getShadow().length, getHighlightPressed().length);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 int tl = Math.max(getHighlight().length, getShadowPressed().length);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 return new Insets(tl, tl, br, br);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 * Calculates and returns the opaque state of this border.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 * <p>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 * Returns false in the following conditions:
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 * <ul>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 * <li> The number of highlight colors is different than the the number of
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 * shadow colors.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 * <li> The number of pressed highlight colors is different than the number of
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 * pressed shadow colors.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 * <li> Any of the highlight and shadow colors are set to <code>null</code>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 * <li> Any of the pressed highlight and shadow colors are set to
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 * <code>null</code>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 * </ul>
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 * This is done so that the entire region under the figure is properly covered.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 * @return The opaque state of this border
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 protected bool calculateOpaque() {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 if (!super.calculateOpaque())
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 return false;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 if (getHighlight().length !is getShadowPressed().length)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 return false;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 if (getShadow().length !is getHighlightPressed().length)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 return false;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 Color [] colors = getHighlightPressed();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 for (int i = 0; i < colors.length; i++)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 if (colors[i] is null)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 return false;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 colors = getShadowPressed();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 for (int i = 0; i < colors.length; i++)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 if (colors[i] is null)
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 return false;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 return true;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201 * Returns the pressed highlight colors of this border.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 * @return Colors as an array of Colors
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 protected Color[] getHighlightPressed() {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207 return highlightPressed;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 * Returns the pressed shadow colors of this border.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 * @return Colors as an array of Colors
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216 protected Color[] getShadowPressed() {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217 return shadowPressed;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 * Interface defining commonly used schemes for the ButtonBorder.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 public struct SCHEMES {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
226 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 * Contrast button scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
229 private static ButtonScheme BUTTON_CONTRAST_;
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
230 static ButtonScheme BUTTON_CONTRAST(){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
231 if( BUTTON_CONTRAST_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
232 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
233 if( BUTTON_CONTRAST_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
234 BUTTON_CONTRAST_ = new ButtonScheme(
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
235 [ColorConstants.button, ColorConstants.buttonLightest],
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
236 DARKEST_DARKER
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
237 );
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
238 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
239 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
240 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
241 return BUTTON_CONTRAST_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
242 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 * Regular button scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
246 private static ButtonScheme BUTTON_;
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
247 static ButtonScheme BUTTON(){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
248 if( BUTTON_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
249 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
250 if( BUTTON_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
251 BUTTON_ = new ButtonScheme(
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
252 [ColorConstants.buttonLightest],
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
253 DARKEST_DARKER
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
254 );
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
255 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
256 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
257 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
258 return BUTTON_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
259 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 * Toolbar button scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
263 private static ButtonScheme TOOLBAR_;
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
264 static ButtonScheme TOOLBAR(){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
265 if( TOOLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
266 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
267 if( TOOLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
268 TOOLBAR_ = new ButtonScheme(
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
269 [ColorConstants.buttonLightest],
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
270 [ColorConstants.buttonDarker]
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
271 );
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
272 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
273 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
274 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
275 return TOOLBAR_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
276 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
278 * Scrollbar button scheme
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279 */
103
2d6540440fe6 Replace static ctors with lazy init.
Frank Benoit <benoit@tionex.de>
parents: 102
diff changeset
280 private static ButtonScheme BUTTON_SCROLLBAR_;
102
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
281 static ButtonScheme BUTTON_SCROLLBAR(){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
282 if( BUTTON_SCROLLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
283 synchronized( ButtonScheme.classinfo ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
284 if( BUTTON_SCROLLBAR_ is null ){
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
285 BUTTON_SCROLLBAR_ = new ButtonScheme(
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
286 [ColorConstants.button, ColorConstants.buttonLightest],
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
287 DARKEST_DARKER,
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
288 [ColorConstants.buttonDarker],
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
289 [ColorConstants.buttonDarker]
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
290 );
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
291 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
292 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
293 }
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
294 return BUTTON_SCROLLBAR_;
0de61c6f08ca Reduce static ctors
Frank Benoit <benoit@tionex.de>
parents: 98
diff changeset
295 }
98
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 * Constructs a ButtonBorder with a predefined button scheme set as its default.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303 public this() {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 setScheme(SCHEMES.BUTTON);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 * Constructs a ButtonBorder with the input ButtonScheme set as its Scheme.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 * @param scheme ButtonScheme for this ButtonBorder.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
311 * @since 2.0
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
312 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
313 public this(ButtonScheme scheme) {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
314 setScheme(scheme);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
315 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
316
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
317 /**
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
318 * Paints this border with the help of the set scheme, the model of the clickable figure,
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
319 * and other inputs. The scheme is used in conjunction with the state of the model to get
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
320 * the appropriate colors for the border.
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
321 *
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
322 * @param figure The Clickable that this border belongs to
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
323 * @param graphics The graphics used for painting
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
324 * @param insets The insets
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
325 */
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
326 public void paint(IFigure figure, Graphics graphics, Insets insets) {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
327 Clickable clickable = cast(Clickable)figure;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
328 ButtonModel model = clickable.getModel();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
329 ButtonScheme colorScheme = cast(ButtonScheme)getScheme();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
330
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
331 if (clickable.isRolloverEnabled() && !model.isMouseOver()
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
332 && !model.isSelected())
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
333 return;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
334
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
335 Color[] tl, br;
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
336 if (model.isSelected() || model.isArmed()) {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
337 tl = colorScheme.getShadowPressed();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
338 br = colorScheme.getHighlightPressed();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
339 } else {
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
340 tl = colorScheme.getHighlight();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
341 br = colorScheme.getShadow();
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
342 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
343
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
344 paint(graphics, figure, insets, tl, br);
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
345 }
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
346
95307ad235d9 Added Draw2d code, still work in progress
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
347 }