/******************************************************************************* * Copyright (c) 2010, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.graphics.*; /** * Instances of this class represent sources of touch input that generate Touch objects. * They also provide information about the input source, which is important for interpreting the * information in the Touch object. *

* Instances of this class can be marked as direct or indirect: *

* * @see Touch * @see Sample code and further information * * @since 3.7 */ public final class TouchSource { long handle; boolean direct; Rectangle bounds; /** * Constructs a new touch source from the given inputs. * * @param direct Is the touch source direct or indirect? * @param height height of the source in points. * @param width width of the source in points. */ TouchSource (long handle, boolean direct, Rectangle bounds) { this.handle = handle; this.direct = direct; this.bounds = bounds; } /** * Returns the type of touch input this source generates, true for direct or false for indirect. * * @return true if the input source is direct, or false otherwise */ public boolean isDirect () { return direct; } /** * Returns the bounding rectangle of the device. For a direct source, this corresponds to the bounds of * the display device in pixels. For an indirect source, this contains the size of the device in points. *

* Note that the x and y values may not necessarily be 0 if the TouchSource is a direct source. * * @return the bounding rectangle of the input source */ public Rectangle getBounds () { return new Rectangle (bounds.x, bounds.y, bounds.width, bounds.height); } /** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ @Override public String toString () { return "TouchSource {handle=" + handle + " direct=" + direct + " bounds=" + bounds + "}"; } }