1 // Copyright 2007 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); You may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by 6 // applicable law or agreed to in writing, software distributed under the 7 // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 8 // OF ANY KIND, either express or implied. See the License for the specific 9 // language governing permissions and limitations under the License. 10 11 package com.google.scrollview.events; 12 13 import com.google.scrollview.ui.SVWindow; 14 15 /** 16 * The SVEvent is a structure which holds the actual values of a message to be 17 * transmitted. It corresponds to the client structure defined in scrollview.h 18 * 19 * @author wanke@google.com 20 */ 21 public class SVEvent { 22 SVEventType type; // What kind of event. 23 SVWindow window; // Window event relates to. 24 int x; // Coords of click or selection. 25 int y; 26 int xSize; // Size of selection. 27 int ySize; 28 int commandId; 29 String parameter; // Any string that might have been passed as argument. 30 31 /** 32 * A "normal" SVEvent. 33 * 34 * @param t The type of the event as specified in SVEventType (e.g. 35 * SVET_CLICK) 36 * @param w The window the event corresponds to 37 * @param x1 X position of the mouse at the time of the event 38 * @param y1 Y position of the mouse at the time of the event 39 * @param x2 X selection size at the time of the event 40 * @param y2 Y selection size at the time of the event 41 * @param p A parameter associated with the event (e.g. keyboard input) 42 */ SVEvent(SVEventType t, SVWindow w, int x1, int y1, int x2, int y2, String p)43 public SVEvent(SVEventType t, SVWindow w, int x1, int y1, int x2, int y2, 44 String p) { 45 type = t; 46 window = w; 47 x = x1; 48 y = y1; 49 xSize = x2; 50 ySize = y2; 51 commandId = 0; 52 parameter = p; 53 } 54 55 /** 56 * An event which issues a command (like clicking on a item in the menubar). 57 * 58 * @param eventtype The type of the event as specified in SVEventType 59 * (usually SVET_MENU or SVET_POPUP) 60 * @param svWindow The window the event corresponds to 61 * @param commandid The associated id with the command (given by the client 62 * on construction of the item) 63 * @param value A parameter associated with the event (e.g. keyboard input) 64 */ SVEvent(SVEventType eventtype, SVWindow svWindow, int commandid, String value)65 public SVEvent(SVEventType eventtype, SVWindow svWindow, int commandid, 66 String value) { 67 type = eventtype; 68 window = svWindow; 69 70 parameter = value; 71 x = 0; 72 y = 0; 73 xSize = 0; 74 ySize = 0; 75 commandId = commandid; 76 } 77 78 /** 79 * This is the string representation of the message, which is what will 80 * actually be transferred over the network. 81 */ 82 @Override toString()83 public String toString() { 84 return (window.hash + "," + type.ordinal() + "," + x + "," + y + "," 85 + xSize + "," + ySize + "," + commandId + "," + parameter); 86 } 87 } 88