| 1 |
/******************************************************************************* |
|---|
| 2 |
* Copyright (c) 2000, 2008 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 dwt.widgets.Monitor; |
|---|
| 14 |
|
|---|
| 15 |
import dwt.graphics.Rectangle; |
|---|
| 16 |
import dwt.internal.win32.WINTYPES; |
|---|
| 17 |
|
|---|
| 18 |
/** |
|---|
| 19 |
* Instances of this class are descriptions of monitors. |
|---|
| 20 |
* |
|---|
| 21 |
* @see Display |
|---|
| 22 |
* @see <a href="http://www.eclipse.org/swt/snippets/#monitor">Monitor snippets</a> |
|---|
| 23 |
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
|---|
| 24 |
* |
|---|
| 25 |
* @since 3.0 |
|---|
| 26 |
*/ |
|---|
| 27 |
public final class Monitor { |
|---|
| 28 |
HMONITOR handle; |
|---|
| 29 |
int x, y, width, height; |
|---|
| 30 |
int clientX, clientY, clientWidth, clientHeight; |
|---|
| 31 |
|
|---|
| 32 |
/** |
|---|
| 33 |
* Prevents uninitialized instances from being created outside the package. |
|---|
| 34 |
*/ |
|---|
| 35 |
this () { |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
/** |
|---|
| 39 |
* Compares the argument to the receiver, and returns true |
|---|
| 40 |
* if they represent the <em>same</em> object using a class |
|---|
| 41 |
* specific comparison. |
|---|
| 42 |
* |
|---|
| 43 |
* @param object the object to compare with this object |
|---|
| 44 |
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
|---|
| 45 |
* |
|---|
| 46 |
* @see #hashCode() |
|---|
| 47 |
*/ |
|---|
| 48 |
public override int opEquals (Object object) { |
|---|
| 49 |
if (object is this) return true; |
|---|
| 50 |
if ( auto mon = cast(dwt.widgets.Monitor.Monitor)object ){ |
|---|
| 51 |
return handle is mon.handle; |
|---|
| 52 |
} |
|---|
| 53 |
return false; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
/** |
|---|
| 57 |
* Returns a rectangle describing the receiver's size and location |
|---|
| 58 |
* relative to its device. Note that on multi-monitor systems the |
|---|
| 59 |
* origin can be negative. |
|---|
| 60 |
* |
|---|
| 61 |
* @return the receiver's bounding rectangle |
|---|
| 62 |
*/ |
|---|
| 63 |
public Rectangle getBounds () { |
|---|
| 64 |
return new Rectangle (x, y, width, height); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
/** |
|---|
| 68 |
* Returns a rectangle which describes the area of the |
|---|
| 69 |
* receiver which is capable of displaying data. |
|---|
| 70 |
* |
|---|
| 71 |
* @return the client area |
|---|
| 72 |
*/ |
|---|
| 73 |
public Rectangle getClientArea () { |
|---|
| 74 |
return new Rectangle (clientX, clientY, clientWidth, clientHeight); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
/** |
|---|
| 78 |
* Returns an integer hash code for the receiver. Any two |
|---|
| 79 |
* objects that return <code>true</code> when passed to |
|---|
| 80 |
* <code>equals</code> must return the same value for this |
|---|
| 81 |
* method. |
|---|
| 82 |
* |
|---|
| 83 |
* @return the receiver's hash |
|---|
| 84 |
* |
|---|
| 85 |
* @see #equals(Object) |
|---|
| 86 |
*/ |
|---|
| 87 |
public override hash_t toHash() { |
|---|
| 88 |
return cast(hash_t)handle; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
} |
|---|