comparison dwtx/draw2d/FrameBorder.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 2d6540440fe6
comparison
equal deleted inserted replaced
96:b492ba44e44d 98:95307ad235d9
1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
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 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module dwtx.draw2d.FrameBorder;
14
15 import dwt.dwthelper.utils;
16
17 import dwt.graphics.Color;
18 import dwt.graphics.Font;
19 import dwtx.draw2d.CompoundBorder;
20 import dwtx.draw2d.LabeledBorder;
21 import dwtx.draw2d.SchemeBorder;
22 import dwtx.draw2d.ColorConstants;
23 import dwtx.draw2d.TitleBarBorder;
24
25
26 /**
27 * Provides for a frame-like border which contains a title bar for holding the title of a
28 * Figure.
29 */
30 public class FrameBorder
31 : CompoundBorder
32 , LabeledBorder
33 {
34
35 /**
36 * The border scheme that determines the border highlight and shadow colors, as well as
37 * the border width (3).
38 */
39 protected static const SchemeBorder.Scheme
40 SCHEME_FRAME;
41 static this(){
42 SCHEME_FRAME = new SchemeBorder.Scheme(
43 [
44 ColorConstants.button,
45 ColorConstants.buttonLightest,
46 ColorConstants.button
47 ],
48 [
49 ColorConstants.buttonDarkest,
50 ColorConstants.buttonDarker,
51 ColorConstants.button
52 ]
53 );
54 }
55
56 private void instanceInit(){
57 createBorders();
58 }
59
60 /**
61 * Constructs a FrameBorder with its label set to the name of the {@link TitleBarBorder}
62 * class.
63 *
64 * @since 2.0
65 */
66 public this() {
67 instanceInit();
68 }
69
70 /**
71 * Constructs a FrameBorder with the title set to the passed String.
72 *
73 * @param label label or title of the frame.
74 * @since 2.0
75 */
76 public this(String label) {
77 instanceInit();
78 setLabel(label);
79 }
80
81 /**
82 * Creates the necessary borders for this FrameBorder. The inner border is a
83 * {@link TitleBarBorder}. The outer border is a {@link SchemeBorder}.
84 *
85 * @since 2.0
86 */
87 protected void createBorders() {
88 inner = new TitleBarBorder();
89 outer = new SchemeBorder(SCHEME_FRAME);
90 }
91
92 /**
93 * Returns the inner border of this FrameBorder, which contains the label for the
94 * FrameBorder.
95 *
96 * @return the border holding the label.
97 * @since 2.0
98 */
99 protected LabeledBorder getLabeledBorder() {
100 return cast(LabeledBorder)inner;
101 }
102
103 /**
104 * @return the label for this border
105 */
106 public String getLabel() {
107 return getLabeledBorder().getLabel();
108 }
109
110 /**
111 * Sets the label for this border.
112 * @param label the label
113 */
114 public void setLabel(String label) {
115 getLabeledBorder().setLabel(label);
116 }
117
118 /**
119 * Sets the font for this border's label.
120 * @param font the font
121 */
122 public void setFont(Font font) {
123 getLabeledBorder().setFont(font);
124 }
125
126 }