summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/internal/qt/QtSWTConverter.java
blob: e67a631c3807de846ae007138660ec1beec91cab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*******************************************************************************
 * Copyright (c) 2009, 2010 compeople AG 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:
 *    compeople AG - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.internal.qt;

import com.trolltech.qt.core.QPoint;
import com.trolltech.qt.core.QRect;
import com.trolltech.qt.core.QSize;
import com.trolltech.qt.gui.QColor;
import com.trolltech.qt.gui.QRegion;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;

/**
 * @author J�rgen Becker
 * 
 */
public class QtSWTConverter {

	private QtSWTConverter() {
		// utility class
	}

	public static Rectangle convert(QRect rect) {
		if (rect == null) {
			return null;
		}
		return new Rectangle(rect.x(), rect.y(), rect.width(), rect.height());
	}

	public static QRect convert(Rectangle rect) {
		if (rect == null) {
			return null;
		}
		return new QRect(rect.x, rect.y, rect.width, rect.height);
	}

	public static Point convert(QSize size) {
		if (size == null) {
			return null;
		}
		return new Point(size.width(), size.height());
	}

	public static Point convert(QPoint point) {
		if (point == null) {
			return null;
		}
		return new Point(point.x(), point.y());
	}

	public static Point convertPosition(QRect rect) {
		if (rect == null) {
			return null;
		}
		return new Point(rect.x(), rect.y());
	}

	public static Point convertSize(QRect rect) {
		if (rect == null) {
			return null;
		}
		return new Point(rect.width(), rect.height());
	}

	public static QPoint convert(Point point) {
		if (point == null) {
			return null;
		}
		return new QPoint(point.x, point.y);
	}

	public static QColor convert(Color color) {
		if (color == null) {
			return null;
		}
		return new QColor(color.getRed(), color.getGreen(), color.getBlue());
	}

	public static Color convert(QColor color) {
		if (color == null) {
			return null;
		}
		return new Color(null, color.red(), color.green(), color.blue());
	}

	public static QRegion convert(Region region) {
		if (region == null) {
			return null;
		}
		return new QRegion(convert(region.getBounds()));
	}

	public static Rectangle convert(QRegion region) {
		if (region == null) {
			return null;
		}
		return convert(region.boundingRect());
	}
}