comparison dwtx/draw2d/ArrowButton.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
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.ArrowButton;
14
15 import dwt.dwthelper.utils;
16
17 import dwtx.draw2d.geometry.Insets;
18 import dwtx.draw2d.Button;
19 import dwtx.draw2d.Orientable;
20 import dwtx.draw2d.Triangle;
21 import dwtx.draw2d.MarginBorder;
22 import dwtx.draw2d.ColorConstants;
23
24 /**
25 * A Button which displays a triangle pointing in a specified direction. This class is
26 * used by the {@link ScrollBar} figure.
27 */
28 public class ArrowButton
29 : Button
30 , Orientable
31 {
32
33 /**
34 * Constructs a default ArrowButton with the arrow pointing north.
35 *
36 * @since 2.0
37 */
38 public this() {
39 createTriangle();
40 setRequestFocusEnabled(false);
41 setFocusTraversable(false);
42 }
43
44 /**
45 * Constructs an ArrowButton with the arrow having the direction given in the input.
46 * The direction can be one of many directional constants defined in
47 * {@link PositionConstants}.
48 *
49 * @param direction Direction of the arrow
50 * @since 2.0
51 */
52 public this(int direction) {
53 this();
54 setDirection(direction);
55 }
56
57 /**
58 * Contructs a triangle with a black background pointing north, and sets it as the
59 * contents of the button.
60 *
61 * @since 2.0
62 */
63 protected void createTriangle() {
64 Triangle tri = new Triangle();
65 tri.setOutline(true);
66 tri.setBackgroundColor(ColorConstants.listForeground);
67 tri.setForegroundColor(ColorConstants.listForeground);
68 tri.setBorder(new MarginBorder(new Insets(2)));
69 setContents(tri);
70 }
71
72 /**
73 * @see dwtx.draw2d.Orientable#setDirection(int)
74 */
75 public void setDirection(int value) {
76 setChildrenDirection(value);
77 }
78
79 /**
80 * @see dwtx.draw2d.Orientable#setOrientation(int)
81 */
82 public void setOrientation(int value) {
83 setChildrenOrientation(value);
84 }
85
86 }