1 /*******************************************************************************
2 * Copyright (c) 2000, 2016 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.widgets;
16 import org.eclipse.swt.graphics.*;
19 * Instances of this class are descriptions of monitors.
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>
27 public final class Monitor {
29 int x, y, width, height;
30 int clientX, clientY, clientWidth, clientHeight;
34 * Prevents uninitialized instances from being created outside the package.
40 * Compares the argument to the receiver, and returns true
41 * if they represent the <em>same</em> object using a class
42 * specific comparison.
44 * @param object the object to compare with this object
45 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
50 public boolean equals (Object object) {
51 if (object == this) return true;
52 if (!(object instanceof Monitor)) return false;
53 Monitor monitor = (Monitor) object;
54 return handle == monitor.handle;
58 * Returns a rectangle describing the receiver's size and location
59 * relative to its device. Note that on multi-monitor systems the
60 * origin can be negative.
62 * @return the receiver's bounding rectangle
64 public Rectangle getBounds () {
65 return new Rectangle (x, y, width, height);
69 * Returns a rectangle which describes the area of the
70 * receiver which is capable of displaying data.
72 * @return the client area
74 public Rectangle getClientArea () {
75 return new Rectangle (clientX, clientY, clientWidth, clientHeight);
79 * Returns the zoom value for the monitor
81 * @return monitor's zoom value
85 public int getZoom () {
89 void setBounds (Rectangle rect) {
96 void setClientArea (Rectangle rect) {
99 clientWidth = rect.width;
100 clientHeight = rect.height;
104 * Returns an integer hash code for the receiver. Any two
105 * objects that return <code>true</code> when passed to
106 * <code>equals</code> must return the same value for this
109 * @return the receiver's hash
111 * @see #equals(Object)
115 public int hashCode () {
116 return (int)/*64*/handle;