10
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2006 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.jface.viewers.ColumnWeightData;
|
|
14
|
|
15 import dwtx.jface.viewers.ColumnLayoutData;
|
|
16
|
|
17 import dwtx.core.runtime.Assert;
|
|
18
|
|
19 import dwt.dwthelper.utils;
|
|
20
|
|
21 /**
|
|
22 * Describes the width of a table column in terms of a weight,
|
|
23 * a minimum width, and whether the column is resizable.
|
|
24 * <p>
|
|
25 * This class may be instantiated; it is not intended to be subclassed.
|
|
26 * </p>
|
|
27 */
|
|
28 public class ColumnWeightData : ColumnLayoutData {
|
|
29
|
|
30 /**
|
|
31 * Default width of a column (in pixels).
|
|
32 */
|
|
33 public static const int MINIMUM_WIDTH = 20;
|
|
34
|
|
35 /**
|
|
36 * The column's minimum width in pixels.
|
|
37 */
|
|
38 public int minimumWidth;
|
|
39
|
|
40 /**
|
|
41 * The column's weight.
|
|
42 */
|
|
43 public int weight;
|
|
44
|
|
45 /**
|
|
46 * Creates a resizable column width with the given weight and a default
|
|
47 * minimum width.
|
|
48 *
|
|
49 * @param weight the weight of the column
|
|
50 */
|
|
51 public this(int weight) {
|
|
52 this(weight, true);
|
|
53 }
|
|
54
|
|
55 /**
|
|
56 * Creates a resizable column width with the given weight and minimum width.
|
|
57 *
|
|
58 * @param weight the weight of the column
|
|
59 * @param minimumWidth the minimum width of the column in pixels
|
|
60 */
|
|
61 public this(int weight, int minimumWidth) {
|
|
62 this(weight, minimumWidth, true);
|
|
63 }
|
|
64
|
|
65 /**
|
|
66 * Creates a column width with the given weight and minimum width.
|
|
67 *
|
|
68 * @param weight the weight of the column
|
|
69 * @param minimumWidth the minimum width of the column in pixels
|
|
70 * @param resizable <code>true</code> if the column is resizable,
|
|
71 * and <code>false</code> if size of the column is fixed
|
|
72 */
|
|
73 public this(int weight, int minimumWidth, bool resizable) {
|
|
74 super(resizable);
|
|
75 Assert.isTrue(weight >= 0);
|
|
76 Assert.isTrue(minimumWidth >= 0);
|
|
77 this.weight = weight;
|
|
78 this.minimumWidth = minimumWidth;
|
|
79 }
|
|
80
|
|
81 /**
|
|
82 * Creates a column width with the given weight and a default
|
|
83 * minimum width.
|
|
84 *
|
|
85 * @param weight the weight of the column
|
|
86 * @param resizable <code>true</code> if the column is resizable,
|
|
87 * and <code>false</code> if size of the column is fixed
|
|
88 */
|
|
89 public this(int weight, bool resizable) {
|
|
90 this(weight, MINIMUM_WIDTH, resizable);
|
|
91 }
|
|
92 }
|