Mercurial > projects > dwt2
view org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Insets.d @ 120:536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
===D2===
* added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements
used these templates to work with strict type storage rules of dmd-2.053
* com.ibm.icu now also compilable with D2, but not tested yet
* small fixes
Snippet288 - shared data is in TLS
===Phobos===
* fixed critical bugs in Phobos implemention
completely incorrect segfault prone fromStringz (Linux's port ruthless killer)
terrible, incorrect StringBuffer realization (StyledText killer)
* fixed small bugs as well
Snippet72 - misprint in the snippet
* implemented missed functionality for Phobos
ByteArrayOutputStream implemented (image loading available)
formatting correctly works for all DWT's cases
As a result, folowing snippets now works with Phobos (Snippet### - what is fixed):
Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting
Snippet48, 282 - crash on image loading
Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText
Snippet244 - hang-up
===Tango===
* few changes for the latest Tango trunc-r5661
* few small performance improvments
===General===
* implMissing-s for only one version changed to implMissingInTango/InPhobos
* incorrect calls to Format in toString-s fixed
* fixed loading \uXXXX characters in ResourceBundle
* added good UTF-8 support for StyledText, TextLayout (Win32) and friends
UTF functions revised and tested. It is now in java.nonstandard.*Utf modules
StyledText and TextLayout (Win32) modules revised for UTF-8 support
* removed small diferences in most identical files in *.swt.* folders
*.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32
now 179 of 576 (~31%) files in *.swt.* folders are fully identical
* Win32: snippets now have right subsystem, pretty icons and native system style controls
* small fixes in snippets
Snippet44 - it's not Snippet44
Snippet212 - functions work with different images and offsets arrays
Win32: Snippet282 - crash on close if the button has an image
Snippet293 - setGrayed is commented
and others
Win32: As a result, folowing snippets now works
Snippet68 - color doesn't change
Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above)
Snippet193 - no tabel headers
author | Denis Shelomovskij <verylonglogin.reg@gmail.com> |
---|---|
date | Sat, 09 Jul 2011 15:50:20 +0300 |
parents | 6f068362a363 |
children |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2000, 2005 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 org.eclipse.draw2d.geometry.Insets; import java.lang.all; /** * Stores four integers for top, left, bottom, and right measurements. */ public class Insets : Cloneable/+, java.io.Serializable+/ { /** distance from left */ public int left; /** distance from top*/ public int top; /** distance from bottom*/ public int bottom; /** distance from right */ public int right; static final long serialVersionUID = 1; /** * Constructs an Insets with all zeroes. * @since 2.0 */ public this() { } /** * Constructs a new Insets with initial values the same as the provided Insets. * @param i The insets to copy. * @since 2.0 */ public this(Insets i) { this(i.top, i.left, i.bottom, i.right); } /** * Constructs a new Insets with all the sides set to the speicifed value. * @param i Value applied to all sides of new Insets. * @since 2.0 */ public this(int i) { this(i, i, i, i); } /** * Creates a new Insets with the specified top, left, bottom, and right values. * @param top Value of the top space. * @param left Value of the left space. * @param bottom Value of the bottom space. * @param right Value of the right space. * @since 2.0 */ public this(int top, int left, int bottom, int right) { this.top = top; this.left = left; this.bottom = bottom; this.right = right; } /** * Adds the values of the specified Insets to this Insets' values. * @return <code>this</code> for convenience * @param insets the Insets being added * @since 2.0 */ public Insets add(Insets insets) { top += insets.top; bottom += insets.bottom; left += insets.left; right += insets.right; return this; } /** * Test for equality. * The Insets are equal if their top, left, bottom, and * right values are equivalent. * * @param o Object being tested for equality. * @return true if all values are the same. * @since 2.0 */ public override int opEquals(Object o) { if (auto i = cast(Insets)o ) { return i.top is top && i.bottom is bottom && i.left is left && i.right is right; } return false; } /** * Creates an Insets representing the sum of this Insets with the specified Insets. * @param insets Insets to be added * @return A new Insets * @since 2.0 */ public Insets getAdded(Insets insets) { return (new Insets(this)).add(insets); } /** * Returns the height for this Insets, equal to <code>top</code> + <code>bottom</code>. * @return The sum of top + bottom * @see #getWidth() * @since 2.0 */ public int getHeight() { return top + bottom; } /** * Creates a new Insets with transposed values. * Top and Left are transposed. * Bottom and Right are transposed. * @return New Insets with the transposed values. * @since 2.0 */ public Insets getTransposed() { return (new Insets(this)).transpose(); } /** * Returns the width for this Insets, equal to <code>left</code> + <code>right</code>. * @return The sum of left + right * @see #getHeight() * @since 2.0 */ public int getWidth() { return left + right; } /** * @see java.lang.Object#toHash() */ public override hash_t toHash() { return top * 7 + left * 2 + bottom * 31 + right * 37; } /** * Returns true if all values are 0. * @return true if all values are 0 * @since 2.0 */ public bool isEmpty() { return (left is 0 && right is 0 && top is 0 && bottom is 0); } /** * @return String representation. * @since 2.0 */ public override String toString() { return Format( "Insets(t={}, l={}, b={}, r={})", top, left, bottom, right ); } /** * Transposes this object. Top and Left are exchanged. Bottom and Right are exchanged. * Can be used in orientation changes. * @return <code>this</code> for convenience * @since 2.0 */ public Insets transpose() { int temp = top; top = left; left = temp; temp = right; right = bottom; bottom = temp; return this; } }