changeset 204:6aeaf24018d7

more D2 examples fixes
author eldar
date Mon, 13 Jul 2009 23:16:08 +0000
parents d3383b16f1d7
children 3dadfee97421
files demos/interview/CMakeLists.txt examples/draganddrop/dropsite/dropsitewindow.d examples/layouts/basiclayouts/dialog.d examples/layouts/basiclayouts/main.d examples/layouts/borderlayout/CMakeLists.txt examples/layouts/borderlayout/borderlayout.d examples/layouts/borderlayout/borderlayout_d1.d examples/layouts/borderlayout/main.d examples/layouts/borderlayout/window.d qt/d2/qt/core/QRect.d qt/d2/qt/core/QRectF.d
diffstat 11 files changed, 596 insertions(+), 343 deletions(-) [+]
line wrap: on
line diff
--- a/demos/interview/CMakeLists.txt	Mon Jul 13 17:27:34 2009 +0000
+++ b/demos/interview/CMakeLists.txt	Mon Jul 13 23:16:08 2009 +0000
@@ -1,1 +1,1 @@
- build_example(interview DETECT_DEPENDS main.d RESOURCES interview.qrc)
+build_example(interview DETECT_DEPENDS main.d RESOURCES interview.qrc)
--- a/examples/draganddrop/dropsite/dropsitewindow.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/draganddrop/dropsite/dropsitewindow.d	Mon Jul 13 23:16:08 2009 +0000
@@ -41,9 +41,13 @@
 
 module dropsitewindow;
 
-import tango.text.Util;
-import tango.text.Ascii;
-import tango.text.convert.Format;
+version(Tango) {
+    import tango.text.Util;
+    import tango.text.Ascii;
+    import tango.text.convert.Format: format = Format;
+} else {
+    import std.string;
+}
 
 import qt.gui.QWidget;
 import qt.gui.QLabel;
--- a/examples/layouts/basiclayouts/dialog.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/basiclayouts/dialog.d	Mon Jul 13 23:16:08 2009 +0000
@@ -56,108 +56,110 @@
 import qt.gui.QComboBox;
 import qt.gui.QSpinBox;
 
-import tango.text.convert.Format;
-
+version(Tango)
+    import tango.text.convert.Format: format = Format;
+else
+    import std.string;
 
 class Dialog : public QDialog
 {
-	this()
-	{
-		createMenu();
-		createHorizontalGroupBox();
-		createGridGroupBox();
-		createFormGroupBox();
+    this()
+    {
+        createMenu();
+        createHorizontalGroupBox();
+        createGridGroupBox();
+        createFormGroupBox();
 
-		bigEditor = new QTextEdit;
-		bigEditor.setPlainText(tr("This widget takes up all the remaining space in the top-level layout."));
+        bigEditor = new QTextEdit;
+        bigEditor.setPlainText(tr("This widget takes up all the remaining space in the top-level layout."));
 
-		buttonBox = new QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel);
+        buttonBox = new QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel);
 
-		buttonBox.accepted.connect(&this.accept);
-		buttonBox.rejected.connect(&this.reject);
+        buttonBox.accepted.connect(&this.accept);
+        buttonBox.rejected.connect(&this.reject);
 
-		QVBoxLayout mainLayout = new QVBoxLayout;
+        QVBoxLayout mainLayout = new QVBoxLayout;
 
-		mainLayout.setMenuBar(menuBar);
+        mainLayout.setMenuBar(menuBar);
 
-		mainLayout.addWidget(horizontalGroupBox);
-		mainLayout.addWidget(gridGroupBox);
-		mainLayout.addWidget(formGroupBox);
-		mainLayout.addWidget(bigEditor);
-		mainLayout.addWidget(buttonBox);
+        mainLayout.addWidget(horizontalGroupBox);
+        mainLayout.addWidget(gridGroupBox);
+        mainLayout.addWidget(formGroupBox);
+        mainLayout.addWidget(bigEditor);
+        mainLayout.addWidget(buttonBox);
 
-		setLayout(mainLayout);
+        setLayout(mainLayout);
 
-		setWindowTitle(tr("Basic Layouts"));
-	}
+        setWindowTitle(tr("Basic Layouts"));
+    }
 
-	void createMenu()
-	{
-		menuBar = new QMenuBar;
+    void createMenu()
+    {
+        menuBar = new QMenuBar;
 
-		fileMenu = new QMenu(tr("&File"), this);
-		exitAction = fileMenu.addAction(tr("E&xit"));
-		menuBar.addMenu(fileMenu);
+        fileMenu = new QMenu(tr("&File"), this);
+        exitAction = fileMenu.addAction(tr("E&xit"));
+        menuBar.addMenu(fileMenu);
 
-		exitAction.triggered.connect(&this.accept);
-	}
+        exitAction.triggered.connect(&this.accept);
+    }
 
-	void createHorizontalGroupBox()
-	{
-		horizontalGroupBox = new QGroupBox(tr("Horizontal layout"));
-		QHBoxLayout layout = new QHBoxLayout;
+    void createHorizontalGroupBox()
+    {
+        horizontalGroupBox = new QGroupBox(tr("Horizontal layout"));
+        QHBoxLayout layout = new QHBoxLayout;
 
-		for (int i = 0; i < NumButtons; ++i) {
-			buttons[i] = new QPushButton(Format(tr("Button {}"), i + 1));
-			layout.addWidget(buttons[i]);
-		}
-		horizontalGroupBox.setLayout(layout);
-	}
+        for (int i = 0; i < NumButtons; ++i) {
+            buttons[i] = new QPushButton(format(tr("Button {}"), i + 1));
+            layout.addWidget(buttons[i]);
+        }
+        horizontalGroupBox.setLayout(layout);
+    }
 
-	void createGridGroupBox()
-	{
-		gridGroupBox = new QGroupBox(tr("Grid layout"));
-		QGridLayout layout = new QGridLayout;
+    void createGridGroupBox()
+    {
+        gridGroupBox = new QGroupBox(tr("Grid layout"));
+        QGridLayout layout = new QGridLayout;
 
-		for (int i = 0; i < NumGridRows; ++i) {
-			labels[i] = new QLabel(Format(tr("Line {}:"), i + 1));
-			lineEdits[i] = new QLineEdit;
-			layout.addWidget(labels[i], i + 1, 0);
-			layout.addWidget(lineEdits[i], i + 1, 1);
-		}
+        for (int i = 0; i < NumGridRows; ++i) {
+            labels[i] = new QLabel(format(tr("Line {}:"), i + 1));
+            lineEdits[i] = new QLineEdit;
+            layout.addWidget(labels[i], i + 1, 0);
+            layout.addWidget(lineEdits[i], i + 1, 1);
+        }
 
-		smallEditor = new QTextEdit;
-		smallEditor.setPlainText(tr("This widget takes up about two thirds of the grid layout."));
-		layout.addWidget(smallEditor, 0, 2, 4, 1);
+        smallEditor = new QTextEdit;
+        smallEditor.setPlainText(tr("This widget takes up about two thirds of the grid layout."));
+        layout.addWidget(smallEditor, 0, 2, 4, 1);
 
-		layout.setColumnStretch(1, 10);
-		layout.setColumnStretch(2, 20);
-		gridGroupBox.setLayout(layout);
-	}
+        layout.setColumnStretch(1, 10);
+        layout.setColumnStretch(2, 20);
+        gridGroupBox.setLayout(layout);
+    }
 
-	void createFormGroupBox()
-	{
-		formGroupBox = new QGroupBox(tr("Form layout"));
-		QFormLayout layout = new QFormLayout;
-		layout.addRow(new QLabel(tr("Line 1:")), new QLineEdit);
-		layout.addRow(new QLabel(tr("Line 2, long text:")), new QComboBox);
-		layout.addRow(new QLabel(tr("Line 3:")), new QSpinBox);
-		formGroupBox.setLayout(layout);
-	}
+    void createFormGroupBox()
+    {
+        formGroupBox = new QGroupBox(tr("Form layout"));
+        QFormLayout layout = new QFormLayout;
+        layout.addRow(new QLabel(tr("Line 1:")), new QLineEdit);
+        layout.addRow(new QLabel(tr("Line 2, long text:")), new QComboBox);
+        layout.addRow(new QLabel(tr("Line 3:")), new QSpinBox);
+        formGroupBox.setLayout(layout);
+    }
 
-	enum { NumGridRows = 3, NumButtons = 4 };
+    enum { NumGridRows = 3, NumButtons = 4 };
 
-	QMenuBar menuBar;
-	QGroupBox horizontalGroupBox;
-	QGroupBox gridGroupBox;
-	QGroupBox formGroupBox;
-	QTextEdit smallEditor;
-	QTextEdit bigEditor;
-	QLabel[NumGridRows] labels;
-	QLineEdit[NumGridRows] lineEdits;
-	QPushButton[NumButtons] buttons;
-	QDialogButtonBox buttonBox;
+    QMenuBar menuBar;
+    QGroupBox horizontalGroupBox;
+    QGroupBox gridGroupBox;
+    QGroupBox formGroupBox;
+    QTextEdit smallEditor;
+    QTextEdit bigEditor;
+    QLabel[NumGridRows] labels;
+    QLineEdit[NumGridRows] lineEdits;
+    QPushButton[NumButtons] buttons;
+    QDialogButtonBox buttonBox;
 
-	QMenu fileMenu;
-	QAction exitAction;
+    QMenu fileMenu;
+    QAction exitAction;
 }
--- a/examples/layouts/basiclayouts/main.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/basiclayouts/main.d	Mon Jul 13 23:16:08 2009 +0000
@@ -47,7 +47,7 @@
 
 int main(string[] args)
 {
-	scope app = new QApplication(args);
-	scope dialog = new Dialog;
-	return dialog.exec();
+    scope app = new QApplication(args);
+    scope dialog = new Dialog;
+    return dialog.exec();
 }
--- a/examples/layouts/borderlayout/CMakeLists.txt	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/borderlayout/CMakeLists.txt	Mon Jul 13 23:16:08 2009 +0000
@@ -1,1 +1,1 @@
-build_example(borderlayout main.d borderlayout.d window.d)
\ No newline at end of file
+build_example(borderlayout DETECT_DEPENDS main.d)
\ No newline at end of file
--- a/examples/layouts/borderlayout/borderlayout.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/borderlayout/borderlayout.d	Mon Jul 13 23:16:08 2009 +0000
@@ -52,193 +52,193 @@
 {
 public:
 
-	enum Position { West, North, South, East, Center };
+    enum Position { West, North, South, East, Center };
 
-	this(QWidget parent, int margin = 0, int spacing = -1)
-	{
-		super(parent);
-		setMargin(margin);
-		setWidgetSpacing(spacing);
-	}
+    this(QWidget parent, int margin = 0, int spacing = -1)
+    {
+        super(parent);
+        setMargin(margin);
+        setWidgetSpacing(spacing);
+    }
 
-	this(int spacing = -1)
-	{
-		setWidgetSpacing(spacing);
-	}
+    this(int spacing = -1)
+    {
+        setWidgetSpacing(spacing);
+    }
 
-	~this()
-	{
-		QLayoutItem l = takeAt(0);
-		while (l) {
-			delete l;
-			l = takeAt(0);
-		}
-	}
+    ~this()
+    {
+        QLayoutItem l = takeAt(0);
+        while (l) {
+            delete l;
+            l = takeAt(0);
+        }
+    }
 
-	void addItem(IQLayoutItem item)
-	{
-		add(item, Position.West);
-	}
+    void addItem(IQLayoutItem item)
+    {
+        add(item, Position.West);
+    }
 
-	void addWidget(QWidget widget, Position position)
-	{
-		add(cast(IQLayoutItem) new QWidgetItem(widget), position);
-	}
+    void addWidget(QWidget widget, Position position)
+    {
+        add(cast(IQLayoutItem) new QWidgetItem(widget), position);
+    }
 
-	int expandingDirections()
-	{
-		return Qt.Horizontal | Qt.Vertical;
-	}
+    int expandingDirections()
+    {
+        return Qt.Horizontal | Qt.Vertical;
+    }
 
-	bool hasHeightForWidth()
-	{
-		return false;
-	}
+    bool hasHeightForWidth()
+    {
+        return false;
+    }
 
-	int count()
-	{
-		return list.length;
-	}
+    int count()
+    {
+        return list.length;
+    }
 
-	QLayoutItem itemAt(int index)
-	{
-		if(index >= 0 && index < list.length) 
-			return list[index].item;
-		else
-			return null;
-	}
+    QLayoutItem itemAt(int index)
+    {
+        if(index >= 0 && index < list.length) 
+            return list[index].item;
+        else
+            return null;
+    }
 
-	QSize minimumSize()
-	{
-		return calculateSize(SizeType.MinimumSize);
-	}
+    QSize minimumSize()
+    {
+        return calculateSize(SizeType.MinimumSize);
+    }
 
-	void setGeometry(QRect rect)
-	{
-		ItemWrapper center = null;
-		int eastWidth = 0;
-		int westWidth = 0;
-		int northHeight = 0;
-		int southHeight = 0;
-		int centerHeight = 0;
-		int i;
+    void setGeometry(const QRect rect)
+    {
+        ItemWrapper center = null;
+        int eastWidth = 0;
+        int westWidth = 0;
+        int northHeight = 0;
+        int southHeight = 0;
+        int centerHeight = 0;
+        int i;
 
-		super.setGeometry(rect);
+        super.setGeometry(rect);
 
-		for (i = 0; i < list.length; ++i) {
-			ItemWrapper wrapper = list[i];
-			IQLayoutItem item = wrapper.item;
-			Position position = wrapper.position;
+        for (i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            IQLayoutItem item = wrapper.item;
+            Position position = wrapper.position;
 
-			if (position == Position.North) {
-				item.setGeometry(QRect(rect.x(), northHeight, rect.width(),
-					    item.sizeHint().height()));
+            if (position == Position.North) {
+                item.setGeometry(QRect(rect.x(), northHeight, rect.width(),
+                        item.sizeHint().height()));
 
-				northHeight += item.geometry().height() + widgetSpacing();
-			} else if (position == Position.South) {
-				item.setGeometry(QRect(item.geometry().x(),
-					    item.geometry().y(), rect.width(),
-					    item.sizeHint().height()));
+                northHeight += item.geometry().height() + widgetSpacing();
+            } else if (position == Position.South) {
+                item.setGeometry(QRect(item.geometry().x(),
+                        item.geometry().y(), rect.width(),
+                        item.sizeHint().height()));
 
-				southHeight += item.geometry().height() + widgetSpacing();
+                southHeight += item.geometry().height() + widgetSpacing();
 
-				item.setGeometry(QRect(rect.x(),
-				      rect.y() + rect.height() - southHeight + widgetSpacing(),
-				      item.geometry().width(),
-				      item.geometry().height()));
-			} else if (position == Position.Center) {
-				center = wrapper;
-			}
-		}
+                item.setGeometry(QRect(rect.x(),
+                      rect.y() + rect.height() - southHeight + widgetSpacing(),
+                      item.geometry().width(),
+                      item.geometry().height()));
+            } else if (position == Position.Center) {
+                center = wrapper;
+            }
+        }
 
-		centerHeight = rect.height() - northHeight - southHeight;
+        centerHeight = rect.height() - northHeight - southHeight;
 
-		for (i = 0; i < list.length; ++i) {
-			ItemWrapper wrapper = list[i];
-			IQLayoutItem item = wrapper.item;
-			Position position = wrapper.position;
+        for (i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            IQLayoutItem item = wrapper.item;
+            Position position = wrapper.position;
 
-			if (position == Position.West) {
-				item.setGeometry(QRect(rect.x() + westWidth, northHeight,
-					    item.sizeHint().width(), centerHeight));
+            if (position == Position.West) {
+                item.setGeometry(QRect(rect.x() + westWidth, northHeight,
+                        item.sizeHint().width(), centerHeight));
 
-				westWidth += item.geometry().width() + widgetSpacing();
-			} else if (position == Position.East) {
-				item.setGeometry(QRect(item.geometry().x(), item.geometry().y(),
-					    item.sizeHint().width(), centerHeight));
+                westWidth += item.geometry().width() + widgetSpacing();
+            } else if (position == Position.East) {
+                item.setGeometry(QRect(item.geometry().x(), item.geometry().y(),
+                        item.sizeHint().width(), centerHeight));
 
-				eastWidth += item.geometry().width() + widgetSpacing();
+                eastWidth += item.geometry().width() + widgetSpacing();
 
-				item.setGeometry(QRect(
-				      rect.x() + rect.width() - eastWidth + widgetSpacing(),
-				      northHeight, item.geometry().width(),
-				      item.geometry().height()));
-			}
-		}
+                item.setGeometry(QRect(
+                      rect.x() + rect.width() - eastWidth + widgetSpacing(),
+                      northHeight, item.geometry().width(),
+                      item.geometry().height()));
+            }
+        }
 
-		if (center)
-			center.item.setGeometry(QRect(westWidth, northHeight,
-				rect.width() - eastWidth - westWidth,
-				centerHeight));
-	}
+        if (center)
+            center.item.setGeometry(QRect(westWidth, northHeight,
+                rect.width() - eastWidth - westWidth,
+                centerHeight));
+    }
 
-	QSize sizeHint()
-	{
-		return calculateSize(SizeType.SizeHint);
-	}
+    QSize sizeHint()
+    {
+        return calculateSize(SizeType.SizeHint);
+    }
 
-	QLayoutItem takeAt(int index)
-	{
-		if (index >= 0 && index < list.length) {
-			ItemWrapper layoutStruct = list[index];
-			return layoutStruct.item;
-		}
-		return null;
-	}
+    QLayoutItem takeAt(int index)
+    {
+        if (index >= 0 && index < list.length) {
+            ItemWrapper layoutStruct = list[index];
+            return layoutStruct.item;
+        }
+        return null;
+    }
 
-	void add(IQLayoutItem item, Position position)
-	{
-		list ~= new ItemWrapper(item, position);
-	}
+    void add(IQLayoutItem item, Position position)
+    {
+        list ~= new ItemWrapper(item, position);
+    }
 
 private:
 
-	class ItemWrapper
-	{
-		this(IQLayoutItem i, Position p)
-		{
-			item = i;
-			position = p;
-		}
+    class ItemWrapper
+    {
+        this(IQLayoutItem i, Position p)
+        {
+            item = i;
+            position = p;
+        }
 
-		IQLayoutItem item;
-		Position position;
-	};
+        IQLayoutItem item;
+        Position position;
+    };
 
-	enum SizeType { MinimumSize, SizeHint };
+    enum SizeType { MinimumSize, SizeHint };
 
-	QSize calculateSize(SizeType sizeType)
-	{
-		QSize totalSize;
+    QSize calculateSize(SizeType sizeType)
+    {
+        QSize totalSize;
 
-		for (int i = 0; i < list.length; ++i) {
-			ItemWrapper wrapper = list[i];
-			Position position = wrapper.position;
-			QSize itemSize;
+        for (int i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            Position position = wrapper.position;
+            QSize itemSize;
 
-			if (sizeType == SizeType.MinimumSize)
-				itemSize = wrapper.item.minimumSize();
-			else // (sizeType == SizeHint)
-				itemSize = wrapper.item.sizeHint();
+            if (sizeType == SizeType.MinimumSize)
+                itemSize = wrapper.item.minimumSize();
+            else // (sizeType == SizeHint)
+                itemSize = wrapper.item.sizeHint();
 
-			if (position == Position.North || position == Position.South || position == Position.Center)
-				totalSize.setHeight(totalSize.height + itemSize.height);
-			
-			if (position == Position.West || position == Position.East || position == Position.Center)
-				totalSize.setWidth(totalSize.width + itemSize.width);
-		}
-		return totalSize;
-	}
+            if (position == Position.North || position == Position.South || position == Position.Center)
+                totalSize.setHeight(totalSize.height + itemSize.height);
+            
+            if (position == Position.West || position == Position.East || position == Position.Center)
+                totalSize.setWidth(totalSize.width + itemSize.width);
+        }
+        return totalSize;
+    }
 
-	ItemWrapper[] list;
+    ItemWrapper[] list;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/layouts/borderlayout/borderlayout_d1.d	Mon Jul 13 23:16:08 2009 +0000
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+module borderlayout;
+
+
+import qt.gui.QLayout;
+import qt.gui.QWidgetItem;
+import qt.gui.QTextBrowser;
+import qt.core.QSize;
+import qt.core.QRect;
+
+
+class BorderLayout : public QLayout
+{
+public:
+
+    enum Position { West, North, South, East, Center };
+
+    this(QWidget parent, int margin = 0, int spacing = -1)
+    {
+        super(parent);
+        setMargin(margin);
+        setWidgetSpacing(spacing);
+    }
+
+    this(int spacing = -1)
+    {
+        setWidgetSpacing(spacing);
+    }
+
+    ~this()
+    {
+        QLayoutItem l = takeAt(0);
+        while (l) {
+            delete l;
+            l = takeAt(0);
+        }
+    }
+
+    void addItem(IQLayoutItem item)
+    {
+        add(item, Position.West);
+    }
+
+    void addWidget(QWidget widget, Position position)
+    {
+        add(cast(IQLayoutItem) new QWidgetItem(widget), position);
+    }
+
+    int expandingDirections()
+    {
+        return Qt.Horizontal | Qt.Vertical;
+    }
+
+    bool hasHeightForWidth()
+    {
+        return false;
+    }
+
+    int count()
+    {
+        return list.length;
+    }
+
+    QLayoutItem itemAt(int index)
+    {
+        if(index >= 0 && index < list.length) 
+            return list[index].item;
+        else
+            return null;
+    }
+
+    QSize minimumSize()
+    {
+        return calculateSize(SizeType.MinimumSize);
+    }
+
+    void setGeometry(QRect rect)
+    {
+        ItemWrapper center = null;
+        int eastWidth = 0;
+        int westWidth = 0;
+        int northHeight = 0;
+        int southHeight = 0;
+        int centerHeight = 0;
+        int i;
+
+        super.setGeometry(rect);
+
+        for (i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            IQLayoutItem item = wrapper.item;
+            Position position = wrapper.position;
+
+            if (position == Position.North) {
+                item.setGeometry(QRect(rect.x(), northHeight, rect.width(),
+                        item.sizeHint().height()));
+
+                northHeight += item.geometry().height() + widgetSpacing();
+            } else if (position == Position.South) {
+                item.setGeometry(QRect(item.geometry().x(),
+                        item.geometry().y(), rect.width(),
+                        item.sizeHint().height()));
+
+                southHeight += item.geometry().height() + widgetSpacing();
+
+                item.setGeometry(QRect(rect.x(),
+                      rect.y() + rect.height() - southHeight + widgetSpacing(),
+                      item.geometry().width(),
+                      item.geometry().height()));
+            } else if (position == Position.Center) {
+                center = wrapper;
+            }
+        }
+
+        centerHeight = rect.height() - northHeight - southHeight;
+
+        for (i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            IQLayoutItem item = wrapper.item;
+            Position position = wrapper.position;
+
+            if (position == Position.West) {
+                item.setGeometry(QRect(rect.x() + westWidth, northHeight,
+                        item.sizeHint().width(), centerHeight));
+
+                westWidth += item.geometry().width() + widgetSpacing();
+            } else if (position == Position.East) {
+                item.setGeometry(QRect(item.geometry().x(), item.geometry().y(),
+                        item.sizeHint().width(), centerHeight));
+
+                eastWidth += item.geometry().width() + widgetSpacing();
+
+                item.setGeometry(QRect(
+                      rect.x() + rect.width() - eastWidth + widgetSpacing(),
+                      northHeight, item.geometry().width(),
+                      item.geometry().height()));
+            }
+        }
+
+        if (center)
+            center.item.setGeometry(QRect(westWidth, northHeight,
+                rect.width() - eastWidth - westWidth,
+                centerHeight));
+    }
+
+    QSize sizeHint()
+    {
+        return calculateSize(SizeType.SizeHint);
+    }
+
+    QLayoutItem takeAt(int index)
+    {
+        if (index >= 0 && index < list.length) {
+            ItemWrapper layoutStruct = list[index];
+            return layoutStruct.item;
+        }
+        return null;
+    }
+
+    void add(IQLayoutItem item, Position position)
+    {
+        list ~= new ItemWrapper(item, position);
+    }
+
+private:
+
+    class ItemWrapper
+    {
+        this(IQLayoutItem i, Position p)
+        {
+            item = i;
+            position = p;
+        }
+
+        IQLayoutItem item;
+        Position position;
+    };
+
+    enum SizeType { MinimumSize, SizeHint };
+
+    QSize calculateSize(SizeType sizeType)
+    {
+        QSize totalSize;
+
+        for (int i = 0; i < list.length; ++i) {
+            ItemWrapper wrapper = list[i];
+            Position position = wrapper.position;
+            QSize itemSize;
+
+            if (sizeType == SizeType.MinimumSize)
+                itemSize = wrapper.item.minimumSize();
+            else // (sizeType == SizeHint)
+                itemSize = wrapper.item.sizeHint();
+
+            if (position == Position.North || position == Position.South || position == Position.Center)
+                totalSize.setHeight(totalSize.height + itemSize.height);
+            
+            if (position == Position.West || position == Position.East || position == Position.Center)
+                totalSize.setWidth(totalSize.width + itemSize.width);
+        }
+        return totalSize;
+    }
+
+    ItemWrapper[] list;
+}
--- a/examples/layouts/borderlayout/main.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/borderlayout/main.d	Mon Jul 13 23:16:08 2009 +0000
@@ -47,9 +47,9 @@
 
 int main(string[] args)
 {
-	scope app = new QApplication(args);
-	scope window = new Window;
-	window.show();
-	return app.exec();
+    scope app = new QApplication(args);
+    scope window = new Window;
+    window.show();
+    return app.exec();
 }
 
--- a/examples/layouts/borderlayout/window.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/examples/layouts/borderlayout/window.d	Mon Jul 13 23:16:08 2009 +0000
@@ -45,36 +45,39 @@
 import qt.gui.QWidget;
 import qt.gui.QLabel;
 
-import borderlayout;
+version(D_Version2)
+    import borderlayout;
+else
+    import borderlayout_d1;
 
 
 class Window : public QWidget
 {
 public:
 
-	this()
-	{
-		QTextBrowser centralWidget = new QTextBrowser;
-		centralWidget.setPlainText(tr("Central widget"));
+    this()
+    {
+        QTextBrowser centralWidget = new QTextBrowser;
+        centralWidget.setPlainText(tr("Central widget"));
 
-		BorderLayout layout = new BorderLayout;
-		layout.addWidget(centralWidget, BorderLayout.Position.Center);
-		layout.addWidget(createLabel("North"), BorderLayout.Position.North);
-		layout.addWidget(createLabel("West"), BorderLayout.Position.West);
-		layout.addWidget(createLabel("East 1"), BorderLayout.Position.East);
-		layout.addWidget(createLabel("East 2") , BorderLayout.Position.East);
-		layout.addWidget(createLabel("South"), BorderLayout.Position.South);
-		setLayout(layout);
+        BorderLayout layout = new BorderLayout;
+        layout.addWidget(centralWidget, BorderLayout.Position.Center);
+        layout.addWidget(createLabel("North"), BorderLayout.Position.North);
+        layout.addWidget(createLabel("West"), BorderLayout.Position.West);
+        layout.addWidget(createLabel("East 1"), BorderLayout.Position.East);
+        layout.addWidget(createLabel("East 2") , BorderLayout.Position.East);
+        layout.addWidget(createLabel("South"), BorderLayout.Position.South);
+        setLayout(layout);
 
-		setWindowTitle(tr("Border Layout"));
-	}
+        setWindowTitle(tr("Border Layout"));
+    }
 
 private:
 
-	QLabel createLabel(char[] text)
-	{
-		QLabel label = new QLabel(text);
-		label.setFrameStyle(QFrame.Box | QFrame.Raised);
-		return label;
-	}
+    QLabel createLabel(string text)
+    {
+        QLabel label = new QLabel(text);
+        label.setFrameStyle(QFrame.Box | QFrame.Raised);
+        return label;
+    }
 }
--- a/qt/d2/qt/core/QRect.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/qt/d2/qt/core/QRect.d	Mon Jul 13 23:16:08 2009 +0000
@@ -41,31 +41,31 @@
         y2 = (y1+asize.height() - 1);
     }
 
-    bool isNull() // const
+    bool isNull() const
     { return x2 == x1 - 1 && y2 == y1 - 1; }
 
-    bool isEmpty() // const
+    bool isEmpty() const
     { return x1 > x2 || y1 > y2; }
 
-    bool isValid() // const
+    bool isValid() const
     { return x1 <= x2 && y1 <= y2; }
 
-    int left() // const
+    int left() const
     { return x1; }
 
-    int top() // const
+    int top() const
     { return y1; }
 
-    int right() // const
+    int right() const
     { return x2; }
 
-    int bottom() // const
+    int bottom() const
     { return y2; }
 
-    int x() // const
+    int x() const
     { return x1; }
 
-    int y() // const
+    int y() const
     { return y1; }
 
     void left(int pos)
@@ -110,28 +110,28 @@
     void setY(int ay)
     { y1 = ay; }
 
-    QPoint topLeft() // const
+    QPoint topLeft() const
     { return QPoint(x1, y1); }
 
-    QPoint bottomRight() // const
+    QPoint bottomRight() const
     { return QPoint(x2, y2); }
 
-    QPoint topRight() // const
+    QPoint topRight() const
     { return QPoint(x2, y1); }
 
-    QPoint bottomLeft() // const
+    QPoint bottomLeft() const
     { return QPoint(x1, y2); }
 
-    QPoint center() // const
+    QPoint center() const
     { return QPoint((x1+x2)/2, (y1+y2)/2); }
 
-    int width() // const
+    int width() const
     { return  x2 - x1 + 1; }
 
-    int height() // const
+    int height() const
     { return  y2 - y1 + 1; }
 
-    QSize size() // const
+    QSize size() const
     { return QSize(width(), height()); }
 
     void translate(int dx, int dy)
@@ -150,10 +150,10 @@
         y2 += p.y();
     }
 
-    QRect translated(int dx, int dy) // const
+    QRect translated(int dx, int dy) const
     { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); }
 
-    QRect translated(ref QPoint p) // const
+    QRect translated(ref QPoint p) const
     { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); }
 
     void moveTo(int ax, int ay)
@@ -214,7 +214,7 @@
         moveBottom(p.y());
     }
 
-    void getRect(int *ax, int *ay, int *aw, int *ah) // const
+    void getRect(int *ax, int *ay, int *aw, int *ah) const
     {
         *ax = x1;
         *ay = y1;
@@ -230,7 +230,7 @@
         y2 = (ay + ah - 1);
     }
 
-    void getCoords(int *xp1, int *yp1, int *xp2, int *yp2) // const
+    void getCoords(int *xp1, int *yp1, int *xp2, int *yp2) const
     {
         *xp1 = x1;
         *yp1 = y1;
@@ -246,7 +246,7 @@
         y2 = yp2;
     }
 
-    QRect adjusted(int xp1, int yp1, int xp2, int yp2) // const
+    QRect adjusted(int xp1, int yp1, int xp2, int yp2) const
     { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); }
 
     void adjust(int dx1, int dy1, int dx2, int dy2)
@@ -269,12 +269,12 @@
         y2 = (s.height() + y1 - 1);
     }
 
-    bool contains(int ax, int ay, bool aproper) // const
+    bool contains(int ax, int ay, bool aproper) const
     {
         return contains(QPoint(ax, ay), aproper);
     }
 
-    bool contains(int ax, int ay) // const
+    bool contains(int ax, int ay) const
     {
         return contains(QPoint(ax, ay), false);
     }
@@ -291,12 +291,12 @@
         return this;
     }
 
-    QRect intersected(ref QRect other) // const
+    QRect intersected(ref QRect other) const
     {
         return this & other;
     }
 
-    QRect united(ref QRect r) // const
+    QRect united(ref QRect r) const
     {
         return this | r;
     }
@@ -314,28 +314,28 @@
         qtd_QRect_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
-    public final QRect opAnd(ref QRect r) {
-        return qtd_QRect_operator_and_QRect(&this, &r);
+    public final QRect opAnd(ref QRect r) const {
+        return qtd_QRect_operator_and_QRect(cast(void*)&this, &r);
     }
 
-    public final QRect opOr(ref QRect r) {
-        return qtd_QRect_operator_or_QRect(&this, &r);
+    public final QRect opOr(ref QRect r) const {
+        return qtd_QRect_operator_or_QRect(cast(void*)&this, &r);
     }
 
-    public final bool contains(QPoint p, bool proper = false) {
-        return qtd_QRect_contains_QPoint_bool(&this, &p, proper);
+    public final bool contains(QPoint p, bool proper = false) const {
+        return qtd_QRect_contains_QPoint_bool(cast(void*)&this, &p, proper);
     }
 
-    public final bool contains(QRect r, bool proper = false) {
-        return qtd_QRect_contains_QRect_bool(&this, &r, proper);
+    public final bool contains(QRect r, bool proper = false) const {
+        return qtd_QRect_contains_QRect_bool(cast(void*)&this, &r, proper);
     }
     
-    public final bool intersects(QRect r) {
-        return qtd_QRect_intersects_QRect(&this, &r);
+    public final bool intersects(QRect r) const {
+        return qtd_QRect_intersects_QRect(cast(void*)&this, &r);
     }
 
-    public final QRect normalized() {
-        return qtd_QRect_normalized(&this);
+    public final QRect normalized() const {
+        return qtd_QRect_normalized(cast(void*)&this);
     }
     
 private:
--- a/qt/d2/qt/core/QRectF.d	Mon Jul 13 17:27:34 2009 +0000
+++ b/qt/d2/qt/core/QRectF.d	Mon Jul 13 23:16:08 2009 +0000
@@ -50,43 +50,43 @@
         h = r.height();
     }
 
-    bool isNull() // conts
+    bool isNull() const
     { return qIsNull(w) && qIsNull(h); }
 
-    bool isEmpty() // conts
+    bool isEmpty() const
     { return w <= 0. || h <= 0.; }
 
-    bool isValid() // conts
+    bool isValid() const
     { return w > 0. && h > 0.; }
 
-    qreal x() // conts
+    qreal x() const
     { return xp; }
 
-    qreal y() // conts
+    qreal y() const
     { return yp; }
 
-    qreal left() // const
+    qreal left() const
     { return xp; }
     
-    qreal top() // const
+    qreal top() const
     { return yp; }
     
-    qreal right() // const
+    qreal right() const
     { return xp + w; }
     
-    qreal bottom() // const
+    qreal bottom() const
     { return yp + h; }
     
-    QPointF topLeft() // const
+    QPointF topLeft() const
     { return QPointF(xp, yp); }
     
-    QPointF bottomRight() // const
+    QPointF bottomRight() const
     { return QPointF(xp+w, yp+h); }
     
-    QPointF topRight() // const
+    QPointF topRight() const
     { return QPointF(xp+w, yp); }
     
-    QPointF bottomLeft() // const
+    QPointF bottomLeft() const
     { return QPointF(xp, yp+h); }
     
     void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
@@ -105,7 +105,7 @@
 
     void setBottomRight(ref QPointF p) { setRight(p.x()); setBottom(p.y()); }
 
-    QPointF center() // conts
+    QPointF center() const
     { return QPointF(xp + w/2, yp + h/2); }
 
     void moveLeft(qreal pos) { xp = pos; }
@@ -126,13 +126,13 @@
 
     void moveCenter(ref QPointF p) { xp = p.x() - w/2; yp = p.y() - h/2; }
 
-    qreal width() // conts
+    qreal width() const
     { return w; }
 
-    qreal height() // conts
+    qreal height() const
     { return h; }
 
-    QSizeF size() // conts
+    QSizeF size() const
     { return QSizeF(w, h); }
 
     void translate(qreal dx, qreal dy)
@@ -159,13 +159,13 @@
         yp = p.y();
     }
 
-    QRectF translated(qreal dx, qreal dy) // conts
+    QRectF translated(qreal dx, qreal dy) const
     { return QRectF(xp + dx, yp + dy, w, h); }
 
-    QRectF translated(ref QPointF p) // conts
+    QRectF translated(ref QPointF p) const
     { return QRectF(xp + p.x(), yp + p.y(), w, h); }
 
-    void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) // conts
+    void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const
     {
         *ax = this.xp;
         *ay = this.yp;
@@ -181,7 +181,7 @@
         this.h = aah;
     }
 
-    void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) // conts
+    void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const
     {
         *xp1 = xp;
         *yp1 = yp;
@@ -200,7 +200,7 @@
     void adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
     { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
 
-    QRectF adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) // conts
+    QRectF adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const
     { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
 
     void setWidth(qreal aw) // for convenience
@@ -227,7 +227,7 @@
         h = s.height();
     }
     
-    bool contains(qreal ax, qreal ay) // conts
+    bool contains(qreal ax, qreal ay) const
     {
         return contains(QPointF(ax, ay));
     }
@@ -244,12 +244,12 @@
         return this;
     }
 
-    QRectF intersected(ref QRectF r) // conts
+    QRectF intersected(ref QRectF r) const
     {
         return this & r;
     }
 
-    QRectF united(ref QRectF r) // conts
+    QRectF united(ref QRectF r) const
     {
         return this | r;
     }
@@ -260,29 +260,29 @@
             && qFuzzyCompare(w, r.w) && qFuzzyCompare(h, r.h);
     }
 
-    QRect toRect() // conts
+    QRect toRect() const
     {
         return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
     }
 
-    public final bool contains(QPointF p) {
-        return qtd_QRectF_contains_QPointF(&this, &p);
+    public final bool contains(QPointF p) const {
+        return qtd_QRectF_contains_QPointF(cast(void*)&this, &p);
     }
 
-    public final bool contains(QRectF r) {
-        return qtd_QRectF_contains_QRectF(&this, &r);
+    public final bool contains(QRectF r) const {
+        return qtd_QRectF_contains_QRectF(cast(void*)&this, &r);
     }
 
-    public final bool intersects(QRectF r) {
-        return qtd_QRectF_intersects_QRectF(&this, &r);
+    public final bool intersects(QRectF r) const {
+        return qtd_QRectF_intersects_QRectF(cast(void*)&this, &r);
     }
 
-    public final QRectF normalized() {
-        return qtd_QRectF_normalized(&this);
+    public final QRectF normalized() const {
+        return qtd_QRectF_normalized(cast(void*)&this);
     }
 
-    public final QRectF opAnd(ref QRectF r) {
-        return qtd_QRectF_operator_and_QRectF(&this, &r);
+    public final QRectF opAnd(ref QRectF r) const {
+        return qtd_QRectF_operator_and_QRectF(cast(void*)&this, &r);
     }
 
     public final void writeTo(QDataStream arg__1) {
@@ -293,13 +293,13 @@
         qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
     }
 
-    public final QRectF opOr(ref QRectF r) {
-        return qtd_QRectF_operator_or_QRectF(&this, &r);
+    public final QRectF opOr(ref QRectF r) const {
+        return qtd_QRectF_operator_or_QRectF(cast(void*)&this, &r);
     }
 
-    public final QRect toAlignedRect() // const
+    public final QRect toAlignedRect() const
     {
-        return qtd_QRectF_toAlignedRect(&this);
+        return qtd_QRectF_toAlignedRect(cast(void*)&this);
     }
 
 private: