1*8622218dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*8622218dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*8622218dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*8622218dSAndrew Rist * distributed with this work for additional information 6*8622218dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*8622218dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*8622218dSAndrew Rist * "License"); you may not use this file except in compliance 9*8622218dSAndrew Rist * with the License. You may obtain a copy of the License at 10*8622218dSAndrew Rist * 11*8622218dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*8622218dSAndrew Rist * 13*8622218dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*8622218dSAndrew Rist * software distributed under the License is distributed on an 15*8622218dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*8622218dSAndrew Rist * KIND, either express or implied. See the License for the 17*8622218dSAndrew Rist * specific language governing permissions and limitations 18*8622218dSAndrew Rist * under the License. 19*8622218dSAndrew Rist * 20*8622218dSAndrew Rist *************************************************************/ 21*8622218dSAndrew Rist 22*8622218dSAndrew Rist 23cdf0e10cSrcweir package org.openoffice.accessibility; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole; 26cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 27cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext; 28cdf0e10cSrcweir import com.sun.star.java.XJavaVM; 29cdf0e10cSrcweir import com.sun.star.uno.*; 30cdf0e10cSrcweir 31cdf0e10cSrcweir import org.openoffice.java.accessibility.*; 32cdf0e10cSrcweir 33cdf0e10cSrcweir import java.lang.reflect.InvocationTargetException; 34cdf0e10cSrcweir import java.lang.reflect.Method; 35cdf0e10cSrcweir 36cdf0e10cSrcweir import javax.accessibility.*; 37cdf0e10cSrcweir 38cdf0e10cSrcweir 39cdf0e10cSrcweir public class WindowsAccessBridgeAdapter { 40cdf0e10cSrcweir private static Method registerVirtualFrame; 41cdf0e10cSrcweir private static Method revokeVirtualFrame; 42cdf0e10cSrcweir private static java.util.Hashtable frameMap; 43cdf0e10cSrcweir getProcessID()44cdf0e10cSrcweir protected static native byte[] getProcessID(); 45cdf0e10cSrcweir createMapping(long jvmaccess)46cdf0e10cSrcweir protected static native boolean createMapping(long jvmaccess); 47cdf0e10cSrcweir 48cdf0e10cSrcweir // On Windows all native frames must be registered to the access bridge. 49cdf0e10cSrcweir // Therefor the bridge exports two methods that we try to find here. attach(XComponentContext xComponentContext)50cdf0e10cSrcweir protected static void attach(XComponentContext xComponentContext) { 51cdf0e10cSrcweir try { 52cdf0e10cSrcweir Class bridge = Class.forName( 53cdf0e10cSrcweir "com.sun.java.accessibility.AccessBridge"); 54cdf0e10cSrcweir Class[] parameterTypes = { 55cdf0e10cSrcweir javax.accessibility.Accessible.class, Integer.class 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir if (bridge != null) { 59cdf0e10cSrcweir registerVirtualFrame = bridge.getMethod("registerVirtualFrame", 60cdf0e10cSrcweir parameterTypes); 61cdf0e10cSrcweir revokeVirtualFrame = bridge.getMethod("revokeVirtualFrame", 62cdf0e10cSrcweir parameterTypes); 63cdf0e10cSrcweir 64cdf0e10cSrcweir // load the native dll 65cdf0e10cSrcweir System.loadLibrary("java_uno_accessbridge"); 66cdf0e10cSrcweir 67cdf0e10cSrcweir Object any = xComponentContext.getValueByName( 68cdf0e10cSrcweir "/singletons/com.sun.star.java.theJavaVirtualMachine"); 69cdf0e10cSrcweir 70cdf0e10cSrcweir if (AnyConverter.isObject(any)) { 71cdf0e10cSrcweir XJavaVM xJavaVM = (XJavaVM) UnoRuntime.queryInterface(XJavaVM.class, 72cdf0e10cSrcweir AnyConverter.toObject(new Type(XJavaVM.class), any)); 73cdf0e10cSrcweir 74cdf0e10cSrcweir if (xJavaVM != null) { 75cdf0e10cSrcweir any = xJavaVM.getJavaVM(getProcessID()); 76cdf0e10cSrcweir 77cdf0e10cSrcweir if (AnyConverter.isLong(any)) { 78cdf0e10cSrcweir createMapping(AnyConverter.toLong(any)); 79cdf0e10cSrcweir frameMap = new java.util.Hashtable(); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir } 82cdf0e10cSrcweir } 83cdf0e10cSrcweir } 84cdf0e10cSrcweir } catch (NoSuchMethodException e) { 85cdf0e10cSrcweir System.err.println("ERROR: incompatible AccessBridge found: " + 86cdf0e10cSrcweir e.getMessage()); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // Forward this exception to UNO to indicate that the service will 89cdf0e10cSrcweir // not work correctly. 90cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException( 91cdf0e10cSrcweir "incompatible AccessBridge class: " + e.getMessage()); 92cdf0e10cSrcweir } catch (java.lang.SecurityException e) { 93cdf0e10cSrcweir System.err.println("ERROR: no access to AccessBridge: " + 94cdf0e10cSrcweir e.getMessage()); 95cdf0e10cSrcweir 96cdf0e10cSrcweir // Forward this exception to UNO to indicate that the service will not work correctly. 97cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException( 98cdf0e10cSrcweir "Security exception caught: " + e.getMessage()); 99cdf0e10cSrcweir } catch (ClassNotFoundException e) { 100cdf0e10cSrcweir // Forward this exception to UNO to indicate that the service will not work correctly. 101cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException( 102cdf0e10cSrcweir "ClassNotFound exception caught: " + e.getMessage()); 103cdf0e10cSrcweir } catch (IllegalArgumentException e) { 104cdf0e10cSrcweir System.err.println("IllegalArgumentException caught: " + 105cdf0e10cSrcweir e.getMessage()); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // Forward this exception to UNO to indicate that the service will not work correctly. 108cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException( 109cdf0e10cSrcweir "IllegalArgumentException caught: " + e.getMessage()); 110cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 111cdf0e10cSrcweir System.err.println("UNO IllegalArgumentException caught: " + 112cdf0e10cSrcweir e.getMessage()); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // Forward this exception to UNO to indicate that the service will not work correctly. 115cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException( 116cdf0e10cSrcweir "UNO IllegalArgumentException caught: " + e.getMessage()); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir } 119cdf0e10cSrcweir isAttached()120cdf0e10cSrcweir protected static boolean isAttached() { 121cdf0e10cSrcweir return frameMap != null; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir getAccessibleWrapper(XAccessible xAccessible)124cdf0e10cSrcweir protected static Accessible getAccessibleWrapper(XAccessible xAccessible) { 125cdf0e10cSrcweir Accessible a = null; 126cdf0e10cSrcweir 127cdf0e10cSrcweir try { 128cdf0e10cSrcweir XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir if (xAccessibleContext != null) { 131cdf0e10cSrcweir switch (xAccessibleContext.getAccessibleRole()) { 132cdf0e10cSrcweir case AccessibleRole.LIST: 133cdf0e10cSrcweir a = (Accessible) AccessibleObjectFactory.getAccessibleComponent(xAccessible); 134cdf0e10cSrcweir if (a != null) { 135cdf0e10cSrcweir a = new ListProxy(a.getAccessibleContext()); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir break; 138cdf0e10cSrcweir 139cdf0e10cSrcweir case AccessibleRole.MENU: 140cdf0e10cSrcweir 141cdf0e10cSrcweir Accessible tmp = (Accessible) AccessibleObjectFactory.getAccessibleComponent(xAccessible); 142cdf0e10cSrcweir if (tmp != null) { 143cdf0e10cSrcweir AccessibleContext ac = tmp.getAccessibleContext(); 144cdf0e10cSrcweir 145cdf0e10cSrcweir if (ac != null) { 146cdf0e10cSrcweir a = new PopupMenuProxy(ac); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir break; 151cdf0e10cSrcweir 152cdf0e10cSrcweir case AccessibleRole.TOOL_TIP: 153cdf0e10cSrcweir a = PopupWindow.create(xAccessible); 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir 156cdf0e10cSrcweir default: 157cdf0e10cSrcweir a = (Accessible) AccessBridge.getTopWindow(xAccessible); 158cdf0e10cSrcweir break; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir return a; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir /** Registers a native frame at the Java AccessBridge for Windows */ registerTopWindow(int handle, XAccessible xAccessible)168cdf0e10cSrcweir public static void registerTopWindow(int handle, XAccessible xAccessible) { 169cdf0e10cSrcweir Integer hwnd = new Integer(handle); 170cdf0e10cSrcweir 171cdf0e10cSrcweir if (!frameMap.contains(hwnd)) { 172cdf0e10cSrcweir if (Build.DEBUG) { 173cdf0e10cSrcweir System.err.println("Native frame " + hwnd + " of role " + 174cdf0e10cSrcweir AccessibleRoleAdapter.getAccessibleRole(xAccessible) + 175cdf0e10cSrcweir " has been opened"); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir Accessible a = getAccessibleWrapper(xAccessible); 179cdf0e10cSrcweir 180cdf0e10cSrcweir if (a != null) { 181cdf0e10cSrcweir Object[] args = { a, hwnd }; 182cdf0e10cSrcweir 183cdf0e10cSrcweir frameMap.put(hwnd, a); 184cdf0e10cSrcweir 185cdf0e10cSrcweir if (Build.DEBUG) { 186cdf0e10cSrcweir System.err.println("registering native frame " + hwnd); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir try { 190cdf0e10cSrcweir registerVirtualFrame.invoke(null, args); 191cdf0e10cSrcweir } catch (IllegalAccessException e) { 192cdf0e10cSrcweir System.err.println("IllegalAccessException caught: " + 193cdf0e10cSrcweir e.getMessage()); 194cdf0e10cSrcweir } catch (IllegalArgumentException e) { 195cdf0e10cSrcweir System.err.println("IllegalArgumentException caught: " + 196cdf0e10cSrcweir e.getMessage()); 197cdf0e10cSrcweir } catch (InvocationTargetException e) { 198cdf0e10cSrcweir System.err.println("InvokationTargetException caught: " + 199cdf0e10cSrcweir e.getMessage()); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir } 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir /** Revokes a native frame at the Java AccessBridge for Windows */ revokeTopWindow(int handle, XAccessible xAccessible)206cdf0e10cSrcweir public static void revokeTopWindow(int handle, XAccessible xAccessible) { 207cdf0e10cSrcweir Integer hwnd = new Integer(handle); 208cdf0e10cSrcweir 209cdf0e10cSrcweir Accessible a = (Accessible) frameMap.remove(hwnd); 210cdf0e10cSrcweir 211cdf0e10cSrcweir if (a != null) { 212cdf0e10cSrcweir Object[] args = { a, hwnd }; 213cdf0e10cSrcweir 214cdf0e10cSrcweir if (Build.DEBUG) { 215cdf0e10cSrcweir System.err.println("revoking native frame " + hwnd); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir try { 219cdf0e10cSrcweir revokeVirtualFrame.invoke(null, args); 220cdf0e10cSrcweir } catch (IllegalAccessException e) { 221cdf0e10cSrcweir System.err.println("IllegalAccessException caught: " + 222cdf0e10cSrcweir e.getMessage()); 223cdf0e10cSrcweir } catch (IllegalArgumentException e) { 224cdf0e10cSrcweir System.err.println("IllegalArgumentException caught: " + 225cdf0e10cSrcweir e.getMessage()); 226cdf0e10cSrcweir } catch (InvocationTargetException e) { 227cdf0e10cSrcweir System.err.println("InvokationTargetException caught: " + 228cdf0e10cSrcweir e.getMessage()); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir if (a instanceof PopupWindow) { 233cdf0e10cSrcweir PopupWindow toolTipWindow = (PopupWindow) a; 234cdf0e10cSrcweir toolTipWindow.removeAll(); 235cdf0e10cSrcweir toolTipWindow.dispose(); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir protected static class PopupMenuProxy extends AccessibleContext 240cdf0e10cSrcweir implements Accessible, AccessibleComponent { 241cdf0e10cSrcweir AccessibleContext menu; 242cdf0e10cSrcweir AccessibleComponent menuComponent; 243cdf0e10cSrcweir int x = 0; int y = 0; int width = 0; int height = 0; 244cdf0e10cSrcweir PopupMenuProxy(AccessibleContext ac)245cdf0e10cSrcweir PopupMenuProxy(AccessibleContext ac) { 246cdf0e10cSrcweir menu = ac; 247cdf0e10cSrcweir menuComponent = menu.getAccessibleComponent(); 248cdf0e10cSrcweir 249cdf0e10cSrcweir /** calculate the bounding rectangle by iterating over the 250cdf0e10cSrcweir * the children. 251cdf0e10cSrcweir */ 252cdf0e10cSrcweir int x2 = 0; int y2 = 0; 253cdf0e10cSrcweir int count = ac.getAccessibleChildrenCount(); 254cdf0e10cSrcweir for (int i = 0; i < count; i++) { 255cdf0e10cSrcweir Accessible a = menu.getAccessibleChild(i); 256cdf0e10cSrcweir 257cdf0e10cSrcweir if (a != null) { 258cdf0e10cSrcweir AccessibleContext childAC = a.getAccessibleContext(); 259cdf0e10cSrcweir 260cdf0e10cSrcweir if (childAC != null) { 261cdf0e10cSrcweir AccessibleComponent comp = ac.getAccessibleComponent(); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if (comp != null) { 264cdf0e10cSrcweir java.awt.Point p = comp.getLocationOnScreen(); 265cdf0e10cSrcweir java.awt.Dimension d = comp.getSize(); 266cdf0e10cSrcweir 267cdf0e10cSrcweir if (p != null && d != null) { 268cdf0e10cSrcweir if (p.x < x) { 269cdf0e10cSrcweir x = p.x; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir if (p.y < y) { 272cdf0e10cSrcweir y = p.y; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir if (p.x + d.width > x2) { 275cdf0e10cSrcweir x2 = p.x + d.width; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir if (p.y + d.height > y2) { 278cdf0e10cSrcweir y2 = p.y + d.height; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir } 281cdf0e10cSrcweir } 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir width = x2 - x; 287cdf0e10cSrcweir height = y2 - y; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleContext()291cdf0e10cSrcweir public javax.accessibility.AccessibleContext getAccessibleContext() { 292cdf0e10cSrcweir return this; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleComponent()296cdf0e10cSrcweir public javax.accessibility.AccessibleComponent getAccessibleComponent() { 297cdf0e10cSrcweir return this; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir /** Returns the AccessibleText associated with this object */ getAccessibleText()301cdf0e10cSrcweir public javax.accessibility.AccessibleText getAccessibleText() { 302cdf0e10cSrcweir return menu.getAccessibleText(); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleStateSet()306cdf0e10cSrcweir public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { 307cdf0e10cSrcweir return menu.getAccessibleStateSet(); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir getLocale()310cdf0e10cSrcweir public java.util.Locale getLocale() { 311cdf0e10cSrcweir return menu.getLocale(); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir getAccessibleIndexInParent()314cdf0e10cSrcweir public int getAccessibleIndexInParent() { 315cdf0e10cSrcweir return -1; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir getAccessibleChildrenCount()318cdf0e10cSrcweir public int getAccessibleChildrenCount() { 319cdf0e10cSrcweir return menu.getAccessibleChildrenCount(); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir getAccessibleChild(int i)322cdf0e10cSrcweir public javax.accessibility.Accessible getAccessibleChild(int i) { 323cdf0e10cSrcweir return menu.getAccessibleChild(i); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir getAccessibleRole()326cdf0e10cSrcweir public javax.accessibility.AccessibleRole getAccessibleRole() { 327cdf0e10cSrcweir return javax.accessibility.AccessibleRole.POPUP_MENU; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir /* 331cdf0e10cSrcweir * AccessibleComponent 332cdf0e10cSrcweir */ addFocusListener(java.awt.event.FocusListener fl)333cdf0e10cSrcweir public void addFocusListener(java.awt.event.FocusListener fl) { 334cdf0e10cSrcweir menuComponent.addFocusListener(fl); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir removeFocusListener(java.awt.event.FocusListener fl)337cdf0e10cSrcweir public void removeFocusListener(java.awt.event.FocusListener fl) { 338cdf0e10cSrcweir menuComponent.removeFocusListener(fl); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir /** Returns the background color of the object */ getBackground()342cdf0e10cSrcweir public java.awt.Color getBackground() { 343cdf0e10cSrcweir return menuComponent.getBackground(); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir setBackground(java.awt.Color c)346cdf0e10cSrcweir public void setBackground(java.awt.Color c) { 347cdf0e10cSrcweir // Not supported by UNO accessibility API 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir /** Returns the foreground color of the object */ getForeground()351cdf0e10cSrcweir public java.awt.Color getForeground() { 352cdf0e10cSrcweir return menuComponent.getForeground(); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir setForeground(java.awt.Color c)355cdf0e10cSrcweir public void setForeground(java.awt.Color c) { 356cdf0e10cSrcweir menuComponent.setForeground(c); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir getCursor()359cdf0e10cSrcweir public java.awt.Cursor getCursor() { 360cdf0e10cSrcweir return menuComponent.getCursor(); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir setCursor(java.awt.Cursor cursor)363cdf0e10cSrcweir public void setCursor(java.awt.Cursor cursor) { 364cdf0e10cSrcweir menuComponent.setCursor(cursor); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir getFont()367cdf0e10cSrcweir public java.awt.Font getFont() { 368cdf0e10cSrcweir return menuComponent.getFont(); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir setFont(java.awt.Font f)371cdf0e10cSrcweir public void setFont(java.awt.Font f) { 372cdf0e10cSrcweir menuComponent.setFont(f); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir getFontMetrics(java.awt.Font f)375cdf0e10cSrcweir public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { 376cdf0e10cSrcweir return menuComponent.getFontMetrics(f); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir isEnabled()379cdf0e10cSrcweir public boolean isEnabled() { 380cdf0e10cSrcweir return menuComponent.isEnabled(); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir setEnabled(boolean b)383cdf0e10cSrcweir public void setEnabled(boolean b) { 384cdf0e10cSrcweir menuComponent.setEnabled(b); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir isVisible()387cdf0e10cSrcweir public boolean isVisible() { 388cdf0e10cSrcweir return menuComponent.isVisible(); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir setVisible(boolean b)391cdf0e10cSrcweir public void setVisible(boolean b) { 392cdf0e10cSrcweir menuComponent.setVisible(b); 393cdf0e10cSrcweir } 394cdf0e10cSrcweir isShowing()395cdf0e10cSrcweir public boolean isShowing() { 396cdf0e10cSrcweir return menuComponent.isShowing(); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir contains(java.awt.Point p)399cdf0e10cSrcweir public boolean contains(java.awt.Point p) { 400cdf0e10cSrcweir java.awt.Dimension d = getSize(); 401cdf0e10cSrcweir 402cdf0e10cSrcweir if (Build.DEBUG) { 403cdf0e10cSrcweir System.err.println("PopupMenuProxy.containsPoint(" + p.x + "," + 404cdf0e10cSrcweir p.y + ") returns " + 405cdf0e10cSrcweir (((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && 406cdf0e10cSrcweir (p.y < d.height)) ? "true" : "false")); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir if ((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && 410cdf0e10cSrcweir (p.y < d.height)) { 411cdf0e10cSrcweir return true; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir return false; 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir /** Returns the location of the object on the screen. */ getLocationOnScreen()418cdf0e10cSrcweir public java.awt.Point getLocationOnScreen() { 419cdf0e10cSrcweir return new java.awt.Point(x,y); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir /** Gets the location of this component in the form of a point specifying the component's top-left corner */ getLocation()423cdf0e10cSrcweir public java.awt.Point getLocation() { 424cdf0e10cSrcweir // This object represents a toplevel, so this is the same as getLocationOnScreen() 425cdf0e10cSrcweir return getLocationOnScreen(); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir /** Moves this component to a new location */ setLocation(java.awt.Point p)429cdf0e10cSrcweir public void setLocation(java.awt.Point p) { 430cdf0e10cSrcweir // Not supported by UNO accessibility API 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir /** Gets the bounds of this component in the form of a Rectangle object */ getBounds()434cdf0e10cSrcweir public java.awt.Rectangle getBounds() { 435cdf0e10cSrcweir return new java.awt.Rectangle(x, y, width, height); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir /** Moves and resizes this component to conform to the new bounding rectangle r */ setBounds(java.awt.Rectangle r)439cdf0e10cSrcweir public void setBounds(java.awt.Rectangle r) { 440cdf0e10cSrcweir // Not supported by UNO accessibility API 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir /** Returns the size of this component in the form of a Dimension object */ getSize()444cdf0e10cSrcweir public java.awt.Dimension getSize() { 445cdf0e10cSrcweir return new java.awt.Dimension(width, height); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir /** Resizes this component so that it has width d.width and height d.height */ setSize(java.awt.Dimension d)449cdf0e10cSrcweir public void setSize(java.awt.Dimension d) { 450cdf0e10cSrcweir // Not supported by UNO accessibility API 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir /** Returns the Accessible child, if one exists, contained at the local 454cdf0e10cSrcweir * coordinate Point 455cdf0e10cSrcweir */ getAccessibleAt(java.awt.Point p)456cdf0e10cSrcweir public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { 457cdf0e10cSrcweir java.awt.Point p2 = menuComponent.getLocationOnScreen(); 458cdf0e10cSrcweir return menuComponent.getAccessibleAt( 459cdf0e10cSrcweir new java.awt.Point(p.x + x - p2.x, p.y + y - p2.y)); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir isFocusTraversable()462cdf0e10cSrcweir public boolean isFocusTraversable() { 463cdf0e10cSrcweir return menuComponent.isFocusTraversable(); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir requestFocus()466cdf0e10cSrcweir public void requestFocus() { 467cdf0e10cSrcweir menuComponent.requestFocus(); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir protected static class ListProxy extends AccessibleContext 472cdf0e10cSrcweir implements Accessible, AccessibleComponent { 473cdf0e10cSrcweir AccessibleContext list; 474cdf0e10cSrcweir AccessibleComponent listComponent; 475cdf0e10cSrcweir ListProxy(AccessibleContext ac)476cdf0e10cSrcweir ListProxy(AccessibleContext ac) { 477cdf0e10cSrcweir list = ac; 478cdf0e10cSrcweir listComponent = list.getAccessibleComponent(); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleContext()482cdf0e10cSrcweir public javax.accessibility.AccessibleContext getAccessibleContext() { 483cdf0e10cSrcweir return this; 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleComponent()487cdf0e10cSrcweir public javax.accessibility.AccessibleComponent getAccessibleComponent() { 488cdf0e10cSrcweir return this; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir /** Returns the AccessibleSelection associated with this object */ getAccessibleSelection()492cdf0e10cSrcweir public javax.accessibility.AccessibleSelection getAccessibleSelection() { 493cdf0e10cSrcweir return list.getAccessibleSelection(); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleStateSet()497cdf0e10cSrcweir public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { 498cdf0e10cSrcweir return list.getAccessibleStateSet(); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir getLocale()501cdf0e10cSrcweir public java.util.Locale getLocale() { 502cdf0e10cSrcweir return list.getLocale(); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir getAccessibleIndexInParent()505cdf0e10cSrcweir public int getAccessibleIndexInParent() { 506cdf0e10cSrcweir return -1; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir getAccessibleChildrenCount()509cdf0e10cSrcweir public int getAccessibleChildrenCount() { 510cdf0e10cSrcweir return list.getAccessibleChildrenCount(); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir getAccessibleChild(int i)513cdf0e10cSrcweir public javax.accessibility.Accessible getAccessibleChild(int i) { 514cdf0e10cSrcweir return list.getAccessibleChild(i); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir getAccessibleRole()517cdf0e10cSrcweir public javax.accessibility.AccessibleRole getAccessibleRole() { 518cdf0e10cSrcweir return javax.accessibility.AccessibleRole.LIST; 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir /* 522cdf0e10cSrcweir * AccessibleComponent 523cdf0e10cSrcweir */ addFocusListener(java.awt.event.FocusListener fl)524cdf0e10cSrcweir public void addFocusListener(java.awt.event.FocusListener fl) { 525cdf0e10cSrcweir listComponent.addFocusListener(fl); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir removeFocusListener(java.awt.event.FocusListener fl)528cdf0e10cSrcweir public void removeFocusListener(java.awt.event.FocusListener fl) { 529cdf0e10cSrcweir listComponent.removeFocusListener(fl); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir /** Returns the background color of the object */ getBackground()533cdf0e10cSrcweir public java.awt.Color getBackground() { 534cdf0e10cSrcweir return listComponent.getBackground(); 535cdf0e10cSrcweir } 536cdf0e10cSrcweir setBackground(java.awt.Color c)537cdf0e10cSrcweir public void setBackground(java.awt.Color c) { 538cdf0e10cSrcweir // Not supported by UNO accessibility API 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir /** Returns the foreground color of the object */ getForeground()542cdf0e10cSrcweir public java.awt.Color getForeground() { 543cdf0e10cSrcweir return listComponent.getForeground(); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir setForeground(java.awt.Color c)546cdf0e10cSrcweir public void setForeground(java.awt.Color c) { 547cdf0e10cSrcweir listComponent.setForeground(c); 548cdf0e10cSrcweir } 549cdf0e10cSrcweir getCursor()550cdf0e10cSrcweir public java.awt.Cursor getCursor() { 551cdf0e10cSrcweir return listComponent.getCursor(); 552cdf0e10cSrcweir } 553cdf0e10cSrcweir setCursor(java.awt.Cursor cursor)554cdf0e10cSrcweir public void setCursor(java.awt.Cursor cursor) { 555cdf0e10cSrcweir listComponent.setCursor(cursor); 556cdf0e10cSrcweir } 557cdf0e10cSrcweir getFont()558cdf0e10cSrcweir public java.awt.Font getFont() { 559cdf0e10cSrcweir return listComponent.getFont(); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir setFont(java.awt.Font f)562cdf0e10cSrcweir public void setFont(java.awt.Font f) { 563cdf0e10cSrcweir listComponent.setFont(f); 564cdf0e10cSrcweir } 565cdf0e10cSrcweir getFontMetrics(java.awt.Font f)566cdf0e10cSrcweir public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { 567cdf0e10cSrcweir return listComponent.getFontMetrics(f); 568cdf0e10cSrcweir } 569cdf0e10cSrcweir isEnabled()570cdf0e10cSrcweir public boolean isEnabled() { 571cdf0e10cSrcweir return listComponent.isEnabled(); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir setEnabled(boolean b)574cdf0e10cSrcweir public void setEnabled(boolean b) { 575cdf0e10cSrcweir listComponent.setEnabled(b); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir isVisible()578cdf0e10cSrcweir public boolean isVisible() { 579cdf0e10cSrcweir return listComponent.isVisible(); 580cdf0e10cSrcweir } 581cdf0e10cSrcweir setVisible(boolean b)582cdf0e10cSrcweir public void setVisible(boolean b) { 583cdf0e10cSrcweir listComponent.setVisible(b); 584cdf0e10cSrcweir } 585cdf0e10cSrcweir isShowing()586cdf0e10cSrcweir public boolean isShowing() { 587cdf0e10cSrcweir return listComponent.isShowing(); 588cdf0e10cSrcweir } 589cdf0e10cSrcweir contains(java.awt.Point p)590cdf0e10cSrcweir public boolean contains(java.awt.Point p) { 591cdf0e10cSrcweir return listComponent.contains(p); 592cdf0e10cSrcweir } 593cdf0e10cSrcweir 594cdf0e10cSrcweir /** Returns the location of the object on the screen. */ getLocationOnScreen()595cdf0e10cSrcweir public java.awt.Point getLocationOnScreen() { 596cdf0e10cSrcweir return listComponent.getLocationOnScreen(); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir 599cdf0e10cSrcweir /** Gets the location of this component in the form of a point specifying 600cdf0e10cSrcweir * the component's top-left corner 601cdf0e10cSrcweir */ getLocation()602cdf0e10cSrcweir public java.awt.Point getLocation() { 603cdf0e10cSrcweir // This object represents a toplevel object, so getLocation() should 604cdf0e10cSrcweir // return the same as getLocationOnScreen(). 605cdf0e10cSrcweir return getLocationOnScreen(); 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir /** Moves this component to a new location */ setLocation(java.awt.Point p)609cdf0e10cSrcweir public void setLocation(java.awt.Point p) { 610cdf0e10cSrcweir // Not supported by UNO accessibility API 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir /** Gets the bounds of this component in the form of a Rectangle object */ getBounds()614cdf0e10cSrcweir public java.awt.Rectangle getBounds() { 615cdf0e10cSrcweir java.awt.Point p = getLocationOnScreen(); 616cdf0e10cSrcweir java.awt.Dimension d = getSize(); 617cdf0e10cSrcweir return new java.awt.Rectangle(p.x, p.y, d.width, d.height); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir /** Moves and resizes this component to conform to the new bounding rectangle r */ setBounds(java.awt.Rectangle r)621cdf0e10cSrcweir public void setBounds(java.awt.Rectangle r) { 622cdf0e10cSrcweir // Not supported by UNO accessibility API 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir /** Returns the size of this component in the form of a Dimension object */ getSize()626cdf0e10cSrcweir public java.awt.Dimension getSize() { 627cdf0e10cSrcweir return listComponent.getSize(); 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir /** Resizes this component so that it has width d.width and height d.height */ setSize(java.awt.Dimension d)631cdf0e10cSrcweir public void setSize(java.awt.Dimension d) { 632cdf0e10cSrcweir // Not supported by UNO accessibility API 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir /** Returns the Accessible child, if one exists, contained at the local 636cdf0e10cSrcweir * coordinate Point 637cdf0e10cSrcweir */ getAccessibleAt(java.awt.Point p)638cdf0e10cSrcweir public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { 639cdf0e10cSrcweir return listComponent.getAccessibleAt(p); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir isFocusTraversable()642cdf0e10cSrcweir public boolean isFocusTraversable() { 643cdf0e10cSrcweir return listComponent.isFocusTraversable(); 644cdf0e10cSrcweir } 645cdf0e10cSrcweir requestFocus()646cdf0e10cSrcweir public void requestFocus() { 647cdf0e10cSrcweir listComponent.requestFocus(); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir } 651