Mercurial > projects > dwt-addons
diff dwtx/jface/viewers/ColumnWeightData.d @ 10:b6c35faf97c8
Viewers
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 31 Mar 2008 00:47:19 +0200 |
parents | |
children | 7ffeace6c47f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtx/jface/viewers/ColumnWeightData.d Mon Mar 31 00:47:19 2008 +0200 @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwtx.jface.viewers.ColumnWeightData; + +import dwtx.jface.viewers.ColumnLayoutData; + +import dwtx.core.runtime.Assert; + +import dwt.dwthelper.utils; + +/** + * Describes the width of a table column in terms of a weight, + * a minimum width, and whether the column is resizable. + * <p> + * This class may be instantiated; it is not intended to be subclassed. + * </p> + */ +public class ColumnWeightData : ColumnLayoutData { + + /** + * Default width of a column (in pixels). + */ + public static const int MINIMUM_WIDTH = 20; + + /** + * The column's minimum width in pixels. + */ + public int minimumWidth; + + /** + * The column's weight. + */ + public int weight; + + /** + * Creates a resizable column width with the given weight and a default + * minimum width. + * + * @param weight the weight of the column + */ + public this(int weight) { + this(weight, true); + } + + /** + * Creates a resizable column width with the given weight and minimum width. + * + * @param weight the weight of the column + * @param minimumWidth the minimum width of the column in pixels + */ + public this(int weight, int minimumWidth) { + this(weight, minimumWidth, true); + } + + /** + * Creates a column width with the given weight and minimum width. + * + * @param weight the weight of the column + * @param minimumWidth the minimum width of the column in pixels + * @param resizable <code>true</code> if the column is resizable, + * and <code>false</code> if size of the column is fixed + */ + public this(int weight, int minimumWidth, bool resizable) { + super(resizable); + Assert.isTrue(weight >= 0); + Assert.isTrue(minimumWidth >= 0); + this.weight = weight; + this.minimumWidth = minimumWidth; + } + + /** + * Creates a column width with the given weight and a default + * minimum width. + * + * @param weight the weight of the column + * @param resizable <code>true</code> if the column is resizable, + * and <code>false</code> if size of the column is fixed + */ + public this(int weight, bool resizable) { + this(weight, MINIMUM_WIDTH, resizable); + } +}