Showing the changes to java/pkg/com/sun/java (421 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,89 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | +public class DOMAccessException extends Exception | |
| 29 | +{ | |
| 30 | + /** | |
| 31 | + * Constructs a new DOMAccessException with no detail message. | |
| 32 | + */ | |
| 33 | + public DOMAccessException() | |
| 34 | + { | |
| 35 | + this(null, null); | |
| 36 | + } | |
| 37 | + | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Constructs a new DOMAccessException with the given detail message. | |
| 41 | + * | |
| 42 | + * @param msg Detail message. | |
| 43 | + */ | |
| 44 | + public DOMAccessException(String msg) | |
| 45 | + { | |
| 46 | + this(null, msg); | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Constructs a new DOMAccessException with the given exception as a root clause. | |
| 51 | + * | |
| 52 | + * @param e Exception. | |
| 53 | + */ | |
| 54 | + public DOMAccessException(Exception e) | |
| 55 | + { | |
| 56 | + this(e, null); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Constructs a new DOMAccessException with the given exception as a root clause and the given detail message. | |
| 61 | + * | |
| 62 | + * @param e Exception. | |
| 63 | + * @param msg Detail message. | |
| 64 | + */ | |
| 65 | + public DOMAccessException(Exception e, String msg) | |
| 66 | + { | |
| 67 | + this.ex = e; | |
| 68 | + this.msg = msg; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns the detail message of the error or null if there is no detail message. | |
| 73 | + */ | |
| 74 | + public String getMessage() | |
| 75 | + { | |
| 76 | + return msg; | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Returns the root cause of the error or null if there is none. | |
| 81 | + */ | |
| 82 | + public Throwable getCause() | |
| 83 | + { | |
| 84 | + return ex; | |
| 85 | + } | |
| 86 | + | |
| 87 | + private Throwable ex; | |
| 88 | + private String msg; | |
| 89 | +} | |
| @@ -0,0 +1,40 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | + | |
| 29 | +public interface DOMAccessor | |
| 30 | +{ | |
| 31 | + /** | |
| 32 | + * Returns the Document object of the DOM. | |
| 33 | + */ | |
| 34 | + public org.w3c.dom.Document getDocument(Object obj) throws org.w3c.dom.DOMException; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * Returns a DOMImplementation object. | |
| 38 | + */ | |
| 39 | + public org.w3c.dom.DOMImplementation getDOMImplementation(); | |
| 40 | +} | |
| @@ -0,0 +1,42 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | + | |
| 29 | +public interface DOMAction | |
| 30 | +{ | |
| 31 | + /** | |
| 32 | + * When an object implementing interface DOMAction is passed | |
| 33 | + * to DOMService.invokeAndWait() or DOMService.invokeLater(), | |
| 34 | + * run method is called in the DOM access dispatch thread. | |
| 35 | + * | |
| 36 | + * accessor is used for the DOMAction to access the entry point of | |
| 37 | + * the browser's DOM, if necessary. | |
| 38 | + * | |
| 39 | + * @param accessor DOMAccessor | |
| 40 | + */ | |
| 41 | + public Object run(DOMAccessor accessor); | |
| 42 | +} | |
| @@ -0,0 +1,103 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | +public abstract class DOMService | |
| 29 | +{ | |
| 30 | + /** | |
| 31 | + * Returns new instance of a DOMService. The implementation | |
| 32 | + * of the DOMService returns depends on the setting of the | |
| 33 | + * com.sun.java.browser.dom.DOMServiceProvider property or, | |
| 34 | + * if the property is not set, a platform specific default. | |
| 35 | + * | |
| 36 | + * Throws DOMUnsupportedException if the DOMService is not | |
| 37 | + * available to the obj. | |
| 38 | + * | |
| 39 | + * @param obj Object to leverage the DOMService | |
| 40 | + */ | |
| 41 | + public static DOMService getService(Object obj) | |
| 42 | + throws DOMUnsupportedException | |
| 43 | + { | |
| 44 | + try | |
| 45 | + { | |
| 46 | + String provider = (String) java.security.AccessController.doPrivileged( | |
| 47 | + new sun.security.action.GetPropertyAction("com.sun.java.browser.dom.DOMServiceProvider")); | |
| 48 | + | |
| 49 | + Class clazz = DOMService.class.forName("sun.plugin.dom.DOMService"); | |
| 50 | + | |
| 51 | + return (DOMService) clazz.newInstance(); | |
| 52 | + } | |
| 53 | + catch (Throwable e) | |
| 54 | + { | |
| 55 | + throw new DOMUnsupportedException(e.toString()); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * An empty constructor is provided. Implementations of this | |
| 61 | + * abstract class must provide a public no-argument constructor | |
| 62 | + * in order for the static getService() method to work correctly. | |
| 63 | + * Application programmers should not be able to directly | |
| 64 | + * construct implementation subclasses of this abstract subclass. | |
| 65 | + */ | |
| 66 | + public DOMService() | |
| 67 | + { | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Causes action.run() to be executed synchronously on the | |
| 72 | + * DOM action dispatching thread. This call will block until all | |
| 73 | + * pending DOM actions have been processed and (then) | |
| 74 | + * action.run() returns. This method should be used when an | |
| 75 | + * application thread needs to access the browser's DOM. | |
| 76 | + * It should not be called from the DOMActionDispatchThread. | |
| 77 | + * | |
| 78 | + * Note that if the DOMAction.run() method throws an uncaught | |
| 79 | + * exception (on the DOM action dispatching thread), it's caught | |
| 80 | + * and re-thrown, as an DOMAccessException, on the caller's thread. | |
| 81 | + * | |
| 82 | + * If the DOMAction.run() method throws any DOM security related | |
| 83 | + * exception (on the DOM action dispatching thread), it's caught | |
| 84 | + * and re-thrown, as an DOMSecurityException, on the caller's thread. | |
| 85 | + * | |
| 86 | + * @param action DOMAction. | |
| 87 | + */ | |
| 88 | + public abstract Object invokeAndWait(DOMAction action) throws DOMAccessException; | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Causes action.run() to be executed asynchronously on the | |
| 92 | + * DOM action dispatching thread. This method should be used | |
| 93 | + * when an application thread needs to access the browser's | |
| 94 | + * DOM. It should not be called from the DOMActionDispatchThread. | |
| 95 | + * | |
| 96 | + * Note that if the DOMAction.run() method throws an uncaught | |
| 97 | + * exception (on the DOM action dispatching thread), it will not be | |
| 98 | + * caught and re-thrown on the caller's thread. | |
| 99 | + * | |
| 100 | + * @param action DOMAction. | |
| 101 | + */ | |
| 102 | + public abstract void invokeLater(DOMAction action); | |
| 103 | +} | |
| @@ -0,0 +1,60 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | +public abstract class DOMServiceProvider | |
| 29 | +{ | |
| 30 | + /** | |
| 31 | + * An empty constructor is provided. Implementations should | |
| 32 | + * provide a public constructor so that the DOMService | |
| 33 | + * can instantiate instances of the implementation class. | |
| 34 | + * Application programmers should not be able to directly | |
| 35 | + * construct implementation subclasses of this abstract subclass. | |
| 36 | + * The only way an application should be able to obtain a | |
| 37 | + * reference to a DOMServiceProvider implementation | |
| 38 | + * instance is by using the appropriate methods of the | |
| 39 | + * DOMService. | |
| 40 | + */ | |
| 41 | + public DOMServiceProvider() | |
| 42 | + { | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Returns true if the DOMService can determine the association | |
| 47 | + * between the obj and the underlying DOM in the browser. | |
| 48 | + */ | |
| 49 | + public abstract boolean canHandle(Object obj); | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Returns the Document object of the DOM. | |
| 53 | + */ | |
| 54 | + public abstract org.w3c.dom.Document getDocument(Object obj) throws DOMUnsupportedException; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Returns the DOMImplemenation object of the DOM. | |
| 58 | + */ | |
| 59 | + public abstract org.w3c.dom.DOMImplementation getDOMImplementation(); | |
| 60 | +} | |
| @@ -0,0 +1,89 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.dom; | |
| 27 | + | |
| 28 | + | |
| 29 | +public class DOMUnsupportedException extends Exception | |
| 30 | +{ | |
| 31 | + /** | |
| 32 | + * Constructs a new DOMUnsupportedException with no detail message. | |
| 33 | + */ | |
| 34 | + public DOMUnsupportedException() | |
| 35 | + { | |
| 36 | + this(null, null); | |
| 37 | + } | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Constructs a new DOMUnsupportedException with the given detail message. | |
| 41 | + * | |
| 42 | + * @param msg Detail message. | |
| 43 | + */ | |
| 44 | + public DOMUnsupportedException(String msg) | |
| 45 | + { | |
| 46 | + this(null, msg); | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Constructs a new DOMUnsupportedException with the given exception as a root clause. | |
| 51 | + * | |
| 52 | + * @param e Exception. | |
| 53 | + */ | |
| 54 | + public DOMUnsupportedException(Exception e) | |
| 55 | + { | |
| 56 | + this(e, null); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Constructs a new DOMUnsupportedException with the given exception as a root clause and the given detail message. | |
| 61 | + * | |
| 62 | + * @param e Exception. | |
| 63 | + * @param msg Detail message. | |
| 64 | + */ | |
| 65 | + public DOMUnsupportedException(Exception e, String msg) | |
| 66 | + { | |
| 67 | + this.ex = e; | |
| 68 | + this.msg = msg; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns the detail message of the error or null if there is no detail message. | |
| 73 | + */ | |
| 74 | + public String getMessage() | |
| 75 | + { | |
| 76 | + return msg; | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Returns the root cause of the error or null if there is none. | |
| 81 | + */ | |
| 82 | + public Throwable getCause() | |
| 83 | + { | |
| 84 | + return ex; | |
| 85 | + } | |
| 86 | + | |
| 87 | + private Throwable ex; | |
| 88 | + private String msg; | |
| 89 | +} | |
| @@ -0,0 +1,13 @@ | ||
| 1 | +<../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + DOMAccessException.dis\ | |
| 5 | + DOMAccessor.dis\ | |
| 6 | + DOMAction.dis\ | |
| 7 | + DOMService.dis\ | |
| 8 | + DOMServiceProvider.dis\ | |
| 9 | + DOMUnsupportedException.dis\ | |
| 10 | + | |
| 11 | +DISBIN=$ROOT/java/dis/java/java/com/sun/java/browser/dom | |
| 12 | + | |
| 13 | +<$ROOT/mkfiles/mkjava | |
| @@ -0,0 +1,7 @@ | ||
| 1 | +<../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + dom\ | |
| 5 | + net\ | |
| 6 | + | |
| 7 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,36 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.net; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * | |
| 30 | + * @author Zhengyu Gu | |
| 31 | + */ | |
| 32 | +public interface ProxyInfo { | |
| 33 | + public String getHost(); | |
| 34 | + public int getPort(); | |
| 35 | + public boolean isSocks(); | |
| 36 | +} | |
| @@ -0,0 +1,61 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.net; | |
| 27 | + | |
| 28 | +import java.net.URL; | |
| 29 | +import java.io.IOException; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * | |
| 33 | + * @author Zhengyu Gu | |
| 34 | + */ | |
| 35 | +public class ProxyService extends Object { | |
| 36 | + private static ProxyServiceProvider provider = null; | |
| 37 | + | |
| 38 | + | |
| 39 | + public static void setProvider(ProxyServiceProvider p) | |
| 40 | + throws IOException { | |
| 41 | + if(null == provider) | |
| 42 | + provider = p; | |
| 43 | + else | |
| 44 | + throw new IOException("Proxy service provider has already been set."); | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * <p>The function returns proxy information of the specified URL.</p> | |
| 50 | + * @param url URL | |
| 51 | + * @return returns proxy information. If there is not proxy, returns null | |
| 52 | + * @since 1.4 | |
| 53 | + */ | |
| 54 | + public static ProxyInfo[] getProxyInfo(URL url) | |
| 55 | + throws IOException { | |
| 56 | + if(null == provider) | |
| 57 | + throw new IOException("Proxy service provider is not yet set"); | |
| 58 | + | |
| 59 | + return provider.getProxyInfo(url); | |
| 60 | + } | |
| 61 | +} | |
| @@ -0,0 +1,36 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.browser.net; | |
| 27 | + | |
| 28 | +import java.net.URL; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * | |
| 32 | + * @author Zhengyu Gu | |
| 33 | + */ | |
| 34 | +public interface ProxyServiceProvider { | |
| 35 | + public ProxyInfo[] getProxyInfo(URL url); | |
| 36 | +} | |
| @@ -0,0 +1,10 @@ | ||
| 1 | +<../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + ProxyInfo.dis\ | |
| 5 | + ProxyService.dis\ | |
| 6 | + ProxyServiceProvider.dis\ | |
| 7 | + | |
| 8 | +DISBIN=$ROOT/java/dis/java/java/com/sun/java/browser/net | |
| 9 | + | |
| 10 | +<$ROOT/mkfiles/mkjava | |
| @@ -0,0 +1,8 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + browser\ | |
| 5 | + swing\ | |
| 6 | + util\ | |
| 7 | + | |
| 8 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,33 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * This class is preserved for backward compatibility with JDK 6. | |
| 29 | + * | |
| 30 | + * @deprecated Use {@link javax.swing.Painter} instead. | |
| 31 | + */ | |
| 32 | +public interface Painter<T> extends javax.swing.Painter { | |
| 33 | +} | |
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,220 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing; | |
| 27 | + | |
| 28 | +import sun.awt.EventQueueDelegate; | |
| 29 | +import sun.awt.AppContext; | |
| 30 | +import java.util.Collections; | |
| 31 | +import java.util.Map; | |
| 32 | +import java.util.WeakHashMap; | |
| 33 | +import java.util.concurrent.Callable; | |
| 34 | +import java.applet.Applet; | |
| 35 | +import java.awt.AWTEvent; | |
| 36 | +import java.awt.EventQueue; | |
| 37 | +import java.awt.Component; | |
| 38 | +import java.awt.Container; | |
| 39 | +import java.awt.Window; | |
| 40 | +import javax.swing.JComponent; | |
| 41 | +import javax.swing.RepaintManager; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * A collection of utility methods for Swing. | |
| 45 | + * <p> | |
| 46 | + * <b>WARNING:</b> While this class is public, it should not be treated as | |
| 47 | + * public API and its API may change in incompatable ways between dot dot | |
| 48 | + * releases and even patch releases. You should not rely on this class even | |
| 49 | + * existing. | |
| 50 | + * | |
| 51 | + * This is a second part of sun.swing.SwingUtilities2. It is required | |
| 52 | + * to provide services for JavaFX applets. | |
| 53 | + * | |
| 54 | + */ | |
| 55 | +public class SwingUtilities3 { | |
| 56 | + /** | |
| 57 | + * The {@code clientProperty} key for delegate {@code RepaintManager} | |
| 58 | + */ | |
| 59 | + private static final Object DELEGATE_REPAINT_MANAGER_KEY = | |
| 60 | + new StringBuilder("DelegateRepaintManagerKey"); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Registers delegate RepaintManager for {@code JComponent}. | |
| 64 | + */ | |
| 65 | + public static void setDelegateRepaintManager(JComponent component, | |
| 66 | + RepaintManager repaintManager) { | |
| 67 | + /* setting up flag in AppContext to speed up lookups in case | |
| 68 | + * there are no delegate RepaintManagers used. | |
| 69 | + */ | |
| 70 | + AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY, | |
| 71 | + Boolean.TRUE); | |
| 72 | + | |
| 73 | + component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY, | |
| 74 | + repaintManager); | |
| 75 | + } | |
| 76 | + | |
| 77 | + private static final Map<Container, Boolean> vsyncedMap = | |
| 78 | + Collections.synchronizedMap(new WeakHashMap<Container, Boolean>()); | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Sets vsyncRequested state for the {@code rootContainer}. If | |
| 82 | + * {@code isRequested} is {@code true} then vsynced | |
| 83 | + * {@code BufferStrategy} is enabled for this {@code rootContainer}. | |
| 84 | + * | |
| 85 | + * Note: requesting vsynced painting does not guarantee one. The outcome | |
| 86 | + * depends on current RepaintManager's RepaintManager.PaintManager | |
| 87 | + * and on the capabilities of the graphics hardware/software and what not. | |
| 88 | + * | |
| 89 | + * @param rootContainer topmost container. Should be either {@code Window} | |
| 90 | + * or {@code Applet} | |
| 91 | + * @param isRequested the value to set vsyncRequested state to | |
| 92 | + */ | |
| 93 | + public static void setVsyncRequested(Container rootContainer, | |
| 94 | + boolean isRequested) { | |
| 95 | + assert (rootContainer instanceof Applet) || (rootContainer instanceof Window); | |
| 96 | + if (isRequested) { | |
| 97 | + vsyncedMap.put(rootContainer, Boolean.TRUE); | |
| 98 | + } else { | |
| 99 | + vsyncedMap.remove(rootContainer); | |
| 100 | + } | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * Checks if vsync painting is requested for {@code rootContainer} | |
| 105 | + * | |
| 106 | + * @param rootContainer topmost container. Should be either Window or Applet | |
| 107 | + * @return {@code true} if vsync painting is requested for {@code rootContainer} | |
| 108 | + */ | |
| 109 | + public static boolean isVsyncRequested(Container rootContainer) { | |
| 110 | + assert (rootContainer instanceof Applet) || (rootContainer instanceof Window); | |
| 111 | + return Boolean.TRUE == vsyncedMap.get(rootContainer); | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * Returns delegate {@code RepaintManager} for {@code component} hierarchy. | |
| 116 | + */ | |
| 117 | + public static RepaintManager getDelegateRepaintManager(Component | |
| 118 | + component) { | |
| 119 | + RepaintManager delegate = null; | |
| 120 | + if (Boolean.TRUE == AppContext.getAppContext().get( | |
| 121 | + DELEGATE_REPAINT_MANAGER_KEY)) { | |
| 122 | + while (delegate == null && component != null) { | |
| 123 | + while (component != null | |
| 124 | + && ! (component instanceof JComponent)) { | |
| 125 | + component = component.getParent(); | |
| 126 | + } | |
| 127 | + if (component != null) { | |
| 128 | + delegate = (RepaintManager) | |
| 129 | + ((JComponent) component) | |
| 130 | + .getClientProperty(DELEGATE_REPAINT_MANAGER_KEY); | |
| 131 | + component = component.getParent(); | |
| 132 | + } | |
| 133 | + | |
| 134 | + } | |
| 135 | + } | |
| 136 | + return delegate; | |
| 137 | + } | |
| 138 | + | |
| 139 | + /* | |
| 140 | + * We use maps to avoid reflection. Hopefully it should perform better | |
| 141 | + * this way. | |
| 142 | + */ | |
| 143 | + public static void setEventQueueDelegate( | |
| 144 | + Map<String, Map<String, Object>> map) { | |
| 145 | + EventQueueDelegate.setDelegate(new EventQueueDelegateFromMap(map)); | |
| 146 | + } | |
| 147 | + | |
| 148 | + private static class EventQueueDelegateFromMap | |
| 149 | + implements EventQueueDelegate.Delegate { | |
| 150 | + private final AWTEvent[] afterDispatchEventArgument; | |
| 151 | + private final Object[] afterDispatchHandleArgument; | |
| 152 | + private final Callable<Void> afterDispatchCallable; | |
| 153 | + | |
| 154 | + private final AWTEvent[] beforeDispatchEventArgument; | |
| 155 | + private final Callable<Object> beforeDispatchCallable; | |
| 156 | + | |
| 157 | + private final EventQueue[] getNextEventEventQueueArgument; | |
| 158 | + private final Callable<AWTEvent> getNextEventCallable; | |
| 159 | + | |
| 160 | + @SuppressWarnings("unchecked") | |
| 161 | + public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) { | |
| 162 | + Map<String, Object> methodMap = objectMap.get("afterDispatch"); | |
| 163 | + afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event"); | |
| 164 | + afterDispatchHandleArgument = (Object[]) methodMap.get("handle"); | |
| 165 | + afterDispatchCallable = (Callable<Void>) methodMap.get("method"); | |
| 166 | + | |
| 167 | + methodMap = objectMap.get("beforeDispatch"); | |
| 168 | + beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event"); | |
| 169 | + beforeDispatchCallable = (Callable<Object>) methodMap.get("method"); | |
| 170 | + | |
| 171 | + methodMap = objectMap.get("getNextEvent"); | |
| 172 | + getNextEventEventQueueArgument = | |
| 173 | + (EventQueue[]) methodMap.get("eventQueue"); | |
| 174 | + getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method"); | |
| 175 | + } | |
| 176 | + | |
| 177 | + @Override | |
| 178 | + public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException { | |
| 179 | + afterDispatchEventArgument[0] = event; | |
| 180 | + afterDispatchHandleArgument[0] = handle; | |
| 181 | + try { | |
| 182 | + afterDispatchCallable.call(); | |
| 183 | + } catch (InterruptedException e) { | |
| 184 | + throw e; | |
| 185 | + } catch (RuntimeException e) { | |
| 186 | + throw e; | |
| 187 | + } catch (Exception e) { | |
| 188 | + throw new RuntimeException(e); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + | |
| 192 | + @Override | |
| 193 | + public Object beforeDispatch(AWTEvent event) throws InterruptedException { | |
| 194 | + beforeDispatchEventArgument[0] = event; | |
| 195 | + try { | |
| 196 | + return beforeDispatchCallable.call(); | |
| 197 | + } catch (InterruptedException e) { | |
| 198 | + throw e; | |
| 199 | + } catch (RuntimeException e) { | |
| 200 | + throw e; | |
| 201 | + } catch (Exception e) { | |
| 202 | + throw new RuntimeException(e); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + @Override | |
| 207 | + public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException { | |
| 208 | + getNextEventEventQueueArgument[0] = eventQueue; | |
| 209 | + try { | |
| 210 | + return getNextEventCallable.call(); | |
| 211 | + } catch (InterruptedException e) { | |
| 212 | + throw e; | |
| 213 | + } catch (RuntimeException e) { | |
| 214 | + throw e; | |
| 215 | + } catch (Exception e) { | |
| 216 | + throw new RuntimeException(e); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + } | |
| 220 | +} | |
| @@ -0,0 +1,13 @@ | ||
| 1 | +<../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + plaf\ | |
| 5 | + | |
| 6 | +TARG=\ | |
| 7 | + Painter.dis\ | |
| 8 | + SwingUtilities3.dis\ | |
| 9 | + | |
| 10 | +DISBIN=$ROOT/java/dis/java/java/com/sun/java/swing | |
| 11 | + | |
| 12 | +<$ROOT/mkfiles/mkjava | |
| 13 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,1303 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import java.awt.*; | |
| 28 | +import java.awt.event.*; | |
| 29 | +import java.awt.image.*; | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.colorchooser.*; | |
| 32 | +import javax.swing.event.*; | |
| 33 | +import javax.swing.plaf.*; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * A color chooser panel mimicking that of GTK's: a color wheel showing | |
| 37 | + * hue and a triangle that varies saturation and brightness. | |
| 38 | + * | |
| 39 | + * @author Scott Violet | |
| 40 | + */ | |
| 41 | +class GTKColorChooserPanel extends AbstractColorChooserPanel implements | |
| 42 | + ChangeListener { | |
| 43 | + private static final float PI_3 = (float)(Math.PI / 3); | |
| 44 | + | |
| 45 | + private ColorTriangle triangle; | |
| 46 | + private JLabel lastLabel; | |
| 47 | + private JLabel label; | |
| 48 | + | |
| 49 | + private JSpinner hueSpinner; | |
| 50 | + private JSpinner saturationSpinner; | |
| 51 | + private JSpinner valueSpinner; | |
| 52 | + | |
| 53 | + private JSpinner redSpinner; | |
| 54 | + private JSpinner greenSpinner; | |
| 55 | + private JSpinner blueSpinner; | |
| 56 | + | |
| 57 | + private JTextField colorNameTF; | |
| 58 | + | |
| 59 | + private boolean settingColor; | |
| 60 | + | |
| 61 | + // The colors are mirrored to avoid creep in adjusting an individual | |
| 62 | + // value. | |
| 63 | + private float hue; | |
| 64 | + private float saturation; | |
| 65 | + private float brightness; | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * Convenience method to transfer focus to the next child of component. | |
| 71 | + */ | |
| 72 | + // PENDING: remove this when a variant of this is added to awt. | |
| 73 | + static void compositeRequestFocus(Component component, boolean direction) { | |
| 74 | + if (component instanceof Container) { | |
| 75 | + Container container = (Container)component; | |
| 76 | + if (container.isFocusCycleRoot()) { | |
| 77 | + FocusTraversalPolicy policy = container. | |
| 78 | + getFocusTraversalPolicy(); | |
| 79 | + Component comp = policy.getDefaultComponent(container); | |
| 80 | + if (comp!=null) { | |
| 81 | + comp.requestFocus(); | |
| 82 | + return; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + Container rootAncestor = container.getFocusCycleRootAncestor(); | |
| 86 | + if (rootAncestor!=null) { | |
| 87 | + FocusTraversalPolicy policy = rootAncestor. | |
| 88 | + getFocusTraversalPolicy(); | |
| 89 | + Component comp; | |
| 90 | + | |
| 91 | + if (direction) { | |
| 92 | + comp = policy.getComponentAfter(rootAncestor, container); | |
| 93 | + } | |
| 94 | + else { | |
| 95 | + comp = policy.getComponentBefore(rootAncestor, container); | |
| 96 | + } | |
| 97 | + if (comp != null) { | |
| 98 | + comp.requestFocus(); | |
| 99 | + return; | |
| 100 | + } | |
| 101 | + } | |
| 102 | + } | |
| 103 | + component.requestFocus(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * Returns a user presentable description of this GTKColorChooserPane. | |
| 109 | + */ | |
| 110 | + public String getDisplayName() { | |
| 111 | + return (String)UIManager.get("GTKColorChooserPanel.nameText"); | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * Returns the mnemonic to use with <code>getDisplayName</code>. | |
| 116 | + */ | |
| 117 | + public int getMnemonic() { | |
| 118 | + String m = (String)UIManager.get("GTKColorChooserPanel.mnemonic"); | |
| 119 | + | |
| 120 | + if (m != null) { | |
| 121 | + try { | |
| 122 | + int value = Integer.parseInt(m); | |
| 123 | + | |
| 124 | + return value; | |
| 125 | + } catch (NumberFormatException nfe) {} | |
| 126 | + } | |
| 127 | + return -1; | |
| 128 | + } | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * Character to underline that represents the mnemonic. | |
| 132 | + */ | |
| 133 | + public int getDisplayedMnemonicIndex() { | |
| 134 | + String m = (String)UIManager.get( | |
| 135 | + "GTKColorChooserPanel.displayedMnemonicIndex"); | |
| 136 | + | |
| 137 | + if (m != null) { | |
| 138 | + try { | |
| 139 | + int value = Integer.parseInt(m); | |
| 140 | + | |
| 141 | + return value; | |
| 142 | + } catch (NumberFormatException nfe) {} | |
| 143 | + } | |
| 144 | + return -1; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public Icon getSmallDisplayIcon() { | |
| 148 | + return null; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public Icon getLargeDisplayIcon() { | |
| 152 | + return null; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void uninstallChooserPanel(JColorChooser enclosingChooser) { | |
| 156 | + super.uninstallChooserPanel(enclosingChooser); | |
| 157 | + removeAll(); | |
| 158 | + } | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Builds and configures the widgets for the GTKColorChooserPanel. | |
| 162 | + */ | |
| 163 | + protected void buildChooser() { | |
| 164 | + triangle = new ColorTriangle(); | |
| 165 | + triangle.setName("GTKColorChooserPanel.triangle"); | |
| 166 | + | |
| 167 | + // PENDING: when we straighten out user setting opacity, this should | |
| 168 | + // be changed. | |
| 169 | + label = new OpaqueLabel(); | |
| 170 | + label.setName("GTKColorChooserPanel.colorWell"); | |
| 171 | + label.setOpaque(true); | |
| 172 | + label.setMinimumSize(new Dimension(67, 32)); | |
| 173 | + label.setPreferredSize(new Dimension(67, 32)); | |
| 174 | + label.setMaximumSize(new Dimension(67, 32)); | |
| 175 | + | |
| 176 | + // PENDING: when we straighten out user setting opacity, this should | |
| 177 | + // be changed. | |
| 178 | + lastLabel = new OpaqueLabel(); | |
| 179 | + lastLabel.setName("GTKColorChooserPanel.lastColorWell"); | |
| 180 | + lastLabel.setOpaque(true); | |
| 181 | + lastLabel.setMinimumSize(new Dimension(67, 32)); | |
| 182 | + lastLabel.setPreferredSize(new Dimension(67, 32)); | |
| 183 | + lastLabel.setMaximumSize(new Dimension(67, 32)); | |
| 184 | + | |
| 185 | + hueSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 360, 1)); | |
| 186 | + configureSpinner(hueSpinner, "GTKColorChooserPanel.hueSpinner"); | |
| 187 | + saturationSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); | |
| 188 | + configureSpinner(saturationSpinner, | |
| 189 | + "GTKColorChooserPanel.saturationSpinner"); | |
| 190 | + valueSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); | |
| 191 | + configureSpinner(valueSpinner, "GTKColorChooserPanel.valueSpinner"); | |
| 192 | + redSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); | |
| 193 | + configureSpinner(redSpinner, "GTKColorChooserPanel.redSpinner"); | |
| 194 | + greenSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); | |
| 195 | + configureSpinner(greenSpinner, "GTKColorChooserPanel.greenSpinner"); | |
| 196 | + blueSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); | |
| 197 | + configureSpinner(blueSpinner, "GTKColorChooserPanel.blueSpinner"); | |
| 198 | + | |
| 199 | + colorNameTF = new JTextField(8); | |
| 200 | + | |
| 201 | + setLayout(new GridBagLayout()); | |
| 202 | + | |
| 203 | + add(this, "GTKColorChooserPanel.hue", hueSpinner, -1, -1); | |
| 204 | + add(this, "GTKColorChooserPanel.red", redSpinner, -1, -1); | |
| 205 | + add(this, "GTKColorChooserPanel.saturation", saturationSpinner, -1,-1); | |
| 206 | + add(this, "GTKColorChooserPanel.green", greenSpinner, -1, -1); | |
| 207 | + add(this, "GTKColorChooserPanel.value", valueSpinner, -1, -1); | |
| 208 | + add(this, "GTKColorChooserPanel.blue", blueSpinner, -1, -1); | |
| 209 | + | |
| 210 | + add(new JSeparator(SwingConstants.HORIZONTAL), new | |
| 211 | + GridBagConstraints(1, 3, 4, 1, 1, 0, | |
| 212 | + GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, | |
| 213 | + new Insets(14, 0, 0, 0), 0, 0)); | |
| 214 | + | |
| 215 | + add(this, "GTKColorChooserPanel.colorName", colorNameTF, 0, 4); | |
| 216 | + | |
| 217 | + add(triangle, new GridBagConstraints(0, 0, 1, 5, 0, 0, | |
| 218 | + GridBagConstraints.LINE_START, GridBagConstraints.NONE, | |
| 219 | + new Insets(14, 20, 2, 9), 0, 0)); | |
| 220 | + | |
| 221 | + Box hBox = Box.createHorizontalBox(); | |
| 222 | + hBox.add(lastLabel); | |
| 223 | + hBox.add(label); | |
| 224 | + add(hBox, new GridBagConstraints(0, 5, 1, 1, 0, 0, | |
| 225 | + GridBagConstraints.CENTER, GridBagConstraints.NONE, | |
| 226 | + new Insets(0, 0, 0, 0), 0, 0)); | |
| 227 | + | |
| 228 | + add(new JSeparator(SwingConstants.HORIZONTAL), new | |
| 229 | + GridBagConstraints(0, 6, 5, 1, 1, 0, | |
| 230 | + GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, | |
| 231 | + new Insets(12, 0, 0, 0), 0, 0)); | |
| 232 | + } | |
| 233 | + | |
| 234 | + /** | |
| 235 | + * Configures the spinner. | |
| 236 | + */ | |
| 237 | + private void configureSpinner(JSpinner spinner, String name) { | |
| 238 | + spinner.addChangeListener(this); | |
| 239 | + spinner.setName(name); | |
| 240 | + JComponent editor = spinner.getEditor(); | |
| 241 | + if (editor instanceof JSpinner.DefaultEditor) { | |
| 242 | + JFormattedTextField ftf = ((JSpinner.DefaultEditor)editor). | |
| 243 | + getTextField(); | |
| 244 | + | |
| 245 | + ftf.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); | |
| 246 | + } | |
| 247 | + } | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * Adds the widget creating a JLabel with the specified name. | |
| 251 | + */ | |
| 252 | + private void add(Container parent, String key, JComponent widget, | |
| 253 | + int x, int y) { | |
| 254 | + JLabel label = new JLabel(UIManager.getString(key + "Text", | |
| 255 | + getLocale())); | |
| 256 | + String mnemonic = (String)UIManager.get(key + "Mnemonic", getLocale()); | |
| 257 | + | |
| 258 | + if (mnemonic != null) { | |
| 259 | + try { | |
| 260 | + label.setDisplayedMnemonic(Integer.parseInt(mnemonic)); | |
| 261 | + } catch (NumberFormatException nfe) { | |
| 262 | + } | |
| 263 | + String mnemonicIndex = (String)UIManager.get(key + "MnemonicIndex", | |
| 264 | + getLocale()); | |
| 265 | + | |
| 266 | + if (mnemonicIndex != null) { | |
| 267 | + try { | |
| 268 | + label.setDisplayedMnemonicIndex(Integer.parseInt( | |
| 269 | + mnemonicIndex)); | |
| 270 | + } catch (NumberFormatException nfe) { | |
| 271 | + } | |
| 272 | + } | |
| 273 | + } | |
| 274 | + label.setLabelFor(widget); | |
| 275 | + if (x < 0) { | |
| 276 | + x = parent.getComponentCount() % 4; | |
| 277 | + } | |
| 278 | + if (y < 0) { | |
| 279 | + y = parent.getComponentCount() / 4; | |
| 280 | + } | |
| 281 | + GridBagConstraints con = new GridBagConstraints(x + 1, y, 1, 1, 0, 0, | |
| 282 | + GridBagConstraints.FIRST_LINE_END, GridBagConstraints.NONE, | |
| 283 | + new Insets(4, 0, 0, 4), 0, 0); | |
| 284 | + if (y == 0) { | |
| 285 | + con.insets.top = 14; | |
| 286 | + } | |
| 287 | + parent.add(label, con); | |
| 288 | + con.gridx++; | |
| 289 | + parent.add(widget, con); | |
| 290 | + } | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * Refreshes the display from the model. | |
| 294 | + */ | |
| 295 | + public void updateChooser() { | |
| 296 | + if (!settingColor) { | |
| 297 | + lastLabel.setBackground(getColorFromModel()); | |
| 298 | + setColor(getColorFromModel(), true, true, false); | |
| 299 | + } | |
| 300 | + } | |
| 301 | + | |
| 302 | + /** | |
| 303 | + * Resets the red component of the selected color. | |
| 304 | + */ | |
| 305 | + private void setRed(int red) { | |
| 306 | + setRGB(red << 16 | getColor().getGreen() << 8 | getColor().getBlue()); | |
| 307 | + } | |
| 308 | + | |
| 309 | + /** | |
| 310 | + * Resets the green component of the selected color. | |
| 311 | + */ | |
| 312 | + private void setGreen(int green) { | |
| 313 | + setRGB(getColor().getRed() << 16 | green << 8 | getColor().getBlue()); | |
| 314 | + } | |
| 315 | + | |
| 316 | + /** | |
| 317 | + * Resets the blue component of the selected color. | |
| 318 | + */ | |
| 319 | + private void setBlue(int blue) { | |
| 320 | + setRGB(getColor().getRed() << 16 | getColor().getGreen() << 8 | blue); | |
| 321 | + } | |
| 322 | + | |
| 323 | + /** | |
| 324 | + * Sets the hue of the selected color and updates the display if | |
| 325 | + * necessary. | |
| 326 | + */ | |
| 327 | + private void setHue(float hue, boolean update) { | |
| 328 | + setHSB(hue, saturation, brightness); | |
| 329 | + if (update) { | |
| 330 | + settingColor = true; | |
| 331 | + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); | |
| 332 | + settingColor = false; | |
| 333 | + } | |
| 334 | + } | |
| 335 | + | |
| 336 | + /** | |
| 337 | + * Returns the current amount of hue. | |
| 338 | + */ | |
| 339 | + private float getHue() { | |
| 340 | + return hue; | |
| 341 | + } | |
| 342 | + | |
| 343 | + /** | |
| 344 | + * Resets the saturation. | |
| 345 | + */ | |
| 346 | + private void setSaturation(float saturation) { | |
| 347 | + setHSB(hue, saturation, brightness); | |
| 348 | + } | |
| 349 | + | |
| 350 | + /** | |
| 351 | + * Returns the saturation. | |
| 352 | + */ | |
| 353 | + private float getSaturation() { | |
| 354 | + return saturation; | |
| 355 | + } | |
| 356 | + | |
| 357 | + /** | |
| 358 | + * Sets the brightness. | |
| 359 | + */ | |
| 360 | + private void setBrightness(float brightness) { | |
| 361 | + setHSB(hue, saturation, brightness); | |
| 362 | + } | |
| 363 | + | |
| 364 | + /** | |
| 365 | + * Returns the brightness. | |
| 366 | + */ | |
| 367 | + private float getBrightness() { | |
| 368 | + return brightness; | |
| 369 | + } | |
| 370 | + | |
| 371 | + /** | |
| 372 | + * Sets the saturation and brightness and updates the display if | |
| 373 | + * necessary. | |
| 374 | + */ | |
| 375 | + private void setSaturationAndBrightness(float s, float b, boolean update) { | |
| 376 | + setHSB(hue, s, b); | |
| 377 | + if (update) { | |
| 378 | + settingColor = true; | |
| 379 | + saturationSpinner.setValue(Integer.valueOf((int)(s * 255))); | |
| 380 | + valueSpinner.setValue(Integer.valueOf((int)(b * 255))); | |
| 381 | + settingColor = false; | |
| 382 | + } | |
| 383 | + } | |
| 384 | + | |
| 385 | + /** | |
| 386 | + * Resets the rgb values. | |
| 387 | + */ | |
| 388 | + private void setRGB(int rgb) { | |
| 389 | + Color color = new Color(rgb); | |
| 390 | + | |
| 391 | + setColor(color, false, true, true); | |
| 392 | + | |
| 393 | + settingColor = true; | |
| 394 | + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); | |
| 395 | + saturationSpinner.setValue(Integer.valueOf((int)(saturation * 255))); | |
| 396 | + valueSpinner.setValue(Integer.valueOf((int)(brightness * 255))); | |
| 397 | + settingColor = false; | |
| 398 | + } | |
| 399 | + | |
| 400 | + /** | |
| 401 | + * Resets the hsb values. | |
| 402 | + */ | |
| 403 | + private void setHSB(float h, float s, float b) { | |
| 404 | + Color color = Color.getHSBColor(h, s, b); | |
| 405 | + | |
| 406 | + this.hue = h; | |
| 407 | + this.saturation = s; | |
| 408 | + this.brightness = b; | |
| 409 | + setColor(color, false, false, true); | |
| 410 | + | |
| 411 | + settingColor = true; | |
| 412 | + redSpinner.setValue(Integer.valueOf(color.getRed())); | |
| 413 | + greenSpinner.setValue(Integer.valueOf(color.getGreen())); | |
| 414 | + blueSpinner.setValue(Integer.valueOf(color.getBlue())); | |
| 415 | + settingColor = false; | |
| 416 | + } | |
| 417 | + | |
| 418 | + | |
| 419 | + /** | |
| 420 | + * Rests the color. | |
| 421 | + * | |
| 422 | + * @param color new Color | |
| 423 | + * @param updateSpinners whether or not to update the spinners. | |
| 424 | + * @param updateHSB if true, the hsb fields are updated based on the | |
| 425 | + * new color | |
| 426 | + * @param updateModel if true, the model is set. | |
| 427 | + */ | |
| 428 | + private void setColor(Color color, boolean updateSpinners, | |
| 429 | + boolean updateHSB, boolean updateModel) { | |
| 430 | + if (color == null) { | |
| 431 | + color = Color.BLACK; | |
| 432 | + } | |
| 433 | + | |
| 434 | + settingColor = true; | |
| 435 | + | |
| 436 | + if (updateHSB) { | |
| 437 | + float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), | |
| 438 | + color.getBlue(), null); | |
| 439 | + hue = hsb[0]; | |
| 440 | + saturation = hsb[1]; | |
| 441 | + brightness = hsb[2]; | |
| 442 | + } | |
| 443 | + | |
| 444 | + if (updateModel) { | |
| 445 | + ColorSelectionModel model = getColorSelectionModel(); | |
| 446 | + if (model != null) { | |
| 447 | + model.setSelectedColor(color); | |
| 448 | + } | |
| 449 | + } | |
| 450 | + | |
| 451 | + triangle.setColor(hue, saturation, brightness); | |
| 452 | + label.setBackground(color); | |
| 453 | + // Force Integer to pad the string with 0's by adding 0x1000000 and | |
| 454 | + // then removing the first character. | |
| 455 | + String hexString = Integer.toHexString( | |
| 456 | + (color.getRGB() & 0xFFFFFF) | 0x1000000); | |
| 457 | + colorNameTF.setText("#" + hexString.substring(1)); | |
| 458 | + | |
| 459 | + if (updateSpinners) { | |
| 460 | + redSpinner.setValue(Integer.valueOf(color.getRed())); | |
| 461 | + greenSpinner.setValue(Integer.valueOf(color.getGreen())); | |
| 462 | + blueSpinner.setValue(Integer.valueOf(color.getBlue())); | |
| 463 | + | |
| 464 | + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); | |
| 465 | + saturationSpinner.setValue(Integer.valueOf((int)(saturation * 255))); | |
| 466 | + valueSpinner.setValue(Integer.valueOf((int)(brightness * 255))); | |
| 467 | + } | |
| 468 | + settingColor = false; | |
| 469 | + } | |
| 470 | + | |
| 471 | + public Color getColor() { | |
| 472 | + return label.getBackground(); | |
| 473 | + } | |
| 474 | + | |
| 475 | + /** | |
| 476 | + * ChangeListener method, updates the necessary display widgets. | |
| 477 | + */ | |
| 478 | + public void stateChanged(ChangeEvent e) { | |
| 479 | + if (settingColor) { | |
| 480 | + return; | |
| 481 | + } | |
| 482 | + Color color = getColor(); | |
| 483 | + | |
| 484 | + if (e.getSource() == hueSpinner) { | |
| 485 | + setHue(((Number)hueSpinner.getValue()).floatValue() / 360, false); | |
| 486 | + } | |
| 487 | + else if (e.getSource() == saturationSpinner) { | |
| 488 | + setSaturation(((Number)saturationSpinner.getValue()). | |
| 489 | + floatValue() / 255); | |
| 490 | + } | |
| 491 | + else if (e.getSource() == valueSpinner) { | |
| 492 | + setBrightness(((Number)valueSpinner.getValue()). | |
| 493 | + floatValue() / 255); | |
| 494 | + } | |
| 495 | + else if (e.getSource() == redSpinner) { | |
| 496 | + setRed(((Number)redSpinner.getValue()).intValue()); | |
| 497 | + } | |
| 498 | + else if (e.getSource() == greenSpinner) { | |
| 499 | + setGreen(((Number)greenSpinner.getValue()).intValue()); | |
| 500 | + } | |
| 501 | + else if (e.getSource() == blueSpinner) { | |
| 502 | + setBlue(((Number)blueSpinner.getValue()).intValue()); | |
| 503 | + } | |
| 504 | + } | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + /** | |
| 509 | + * Flag indicating the angle, or hue, has changed and the triangle | |
| 510 | + * needs to be recreated. | |
| 511 | + */ | |
| 512 | + private static final int FLAGS_CHANGED_ANGLE = 1 << 0; | |
| 513 | + /** | |
| 514 | + * Indicates the wheel is being dragged. | |
| 515 | + */ | |
| 516 | + private static final int FLAGS_DRAGGING = 1 << 1; | |
| 517 | + /** | |
| 518 | + * Indicates the triangle is being dragged. | |
| 519 | + */ | |
| 520 | + private static final int FLAGS_DRAGGING_TRIANGLE = 1 << 2; | |
| 521 | + /** | |
| 522 | + * Indicates a color is being set and we should ignore setColor | |
| 523 | + */ | |
| 524 | + private static final int FLAGS_SETTING_COLOR = 1 << 3; | |
| 525 | + /** | |
| 526 | + * Indicates the wheel has focus. | |
| 527 | + */ | |
| 528 | + private static final int FLAGS_FOCUSED_WHEEL = 1 << 4; | |
| 529 | + /** | |
| 530 | + * Indicates the triangle has focus. | |
| 531 | + */ | |
| 532 | + private static final int FLAGS_FOCUSED_TRIANGLE = 1 << 5; | |
| 533 | + | |
| 534 | + | |
| 535 | + /** | |
| 536 | + * Class responsible for rendering a color wheel and color triangle. | |
| 537 | + */ | |
| 538 | + private class ColorTriangle extends JPanel { | |
| 539 | + /** | |
| 540 | + * Cached image of the wheel. | |
| 541 | + */ | |
| 542 | + private Image wheelImage; | |
| 543 | + | |
| 544 | + /** | |
| 545 | + * Cached image of the triangle. | |
| 546 | + */ | |
| 547 | + private Image triangleImage; | |
| 548 | + | |
| 549 | + /** | |
| 550 | + * Angle triangle is rotated by. | |
| 551 | + */ | |
| 552 | + private double angle; | |
| 553 | + | |
| 554 | + /** | |
| 555 | + * Boolean bitmask. | |
| 556 | + */ | |
| 557 | + private int flags; | |
| 558 | + | |
| 559 | + /** | |
| 560 | + * X location of selected color indicator. | |
| 561 | + */ | |
| 562 | + private int circleX; | |
| 563 | + /** | |
| 564 | + * Y location of selected color indicator. | |
| 565 | + */ | |
| 566 | + private int circleY; | |
| 567 | + | |
| 568 | + | |
| 569 | + public ColorTriangle() { | |
| 570 | + enableEvents(AWTEvent.FOCUS_EVENT_MASK); | |
| 571 | + enableEvents(AWTEvent.MOUSE_EVENT_MASK); | |
| 572 | + enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); | |
| 573 | + | |
| 574 | + setMinimumSize(new Dimension(getWheelRadius() * 2 + 2, | |
| 575 | + getWheelRadius() * 2 + 2)); | |
| 576 | + setPreferredSize(new Dimension(getWheelRadius() * 2 + 2, | |
| 577 | + getWheelRadius() * 2 + 2)); | |
| 578 | + | |
| 579 | + // We want to handle tab ourself. | |
| 580 | + setFocusTraversalKeysEnabled(false); | |
| 581 | + | |
| 582 | + // PENDING: this should come from the style. | |
| 583 | + getInputMap().put(KeyStroke.getKeyStroke("UP"), "up"); | |
| 584 | + getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "down"); | |
| 585 | + getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "left"); | |
| 586 | + getInputMap().put(KeyStroke.getKeyStroke("RIGHT"), "right"); | |
| 587 | + | |
| 588 | + getInputMap().put(KeyStroke.getKeyStroke("KP_UP"), "up"); | |
| 589 | + getInputMap().put(KeyStroke.getKeyStroke("KP_DOWN"), "down"); | |
| 590 | + getInputMap().put(KeyStroke.getKeyStroke("KP_LEFT"), "left"); | |
| 591 | + getInputMap().put(KeyStroke.getKeyStroke("KP_RIGHT"), "right"); | |
| 592 | + | |
| 593 | + getInputMap().put(KeyStroke.getKeyStroke("TAB"), "focusNext"); | |
| 594 | + getInputMap().put(KeyStroke.getKeyStroke("shift TAB"),"focusLast"); | |
| 595 | + | |
| 596 | + ActionMap map = (ActionMap)UIManager.get( | |
| 597 | + "GTKColorChooserPanel.actionMap"); | |
| 598 | + | |
| 599 | + if (map == null) { | |
| 600 | + map = new ActionMapUIResource(); | |
| 601 | + map.put("left", new ColorAction("left", 2)); | |
| 602 | + map.put("right", new ColorAction("right", 3)); | |
| 603 | + map.put("up", new ColorAction("up", 0)); | |
| 604 | + map.put("down", new ColorAction("down", 1)); | |
| 605 | + map.put("focusNext", new ColorAction("focusNext", 4)); | |
| 606 | + map.put("focusLast", new ColorAction("focusLast", 5)); | |
| 607 | + UIManager.getLookAndFeelDefaults().put( | |
| 608 | + "GTKColorChooserPanel.actionMap", map); | |
| 609 | + } | |
| 610 | + SwingUtilities.replaceUIActionMap(this, map); | |
| 611 | + } | |
| 612 | + | |
| 613 | + /** | |
| 614 | + * Returns the GTKColorChooserPanel. | |
| 615 | + */ | |
| 616 | + GTKColorChooserPanel getGTKColorChooserPanel() { | |
| 617 | + return GTKColorChooserPanel.this; | |
| 618 | + } | |
| 619 | + | |
| 620 | + /** | |
| 621 | + * Gives focus to the wheel. | |
| 622 | + */ | |
| 623 | + void focusWheel() { | |
| 624 | + setFocusType(1); | |
| 625 | + } | |
| 626 | + | |
| 627 | + /** | |
| 628 | + * Gives focus to the triangle. | |
| 629 | + */ | |
| 630 | + void focusTriangle() { | |
| 631 | + setFocusType(2); | |
| 632 | + } | |
| 633 | + | |
| 634 | + /** | |
| 635 | + * Returns true if the wheel currently has focus. | |
| 636 | + */ | |
| 637 | + boolean isWheelFocused() { | |
| 638 | + return isSet(FLAGS_FOCUSED_WHEEL); | |
| 639 | + } | |
| 640 | + | |
| 641 | + /** | |
| 642 | + * Resets the selected color. | |
| 643 | + */ | |
| 644 | + public void setColor(float h, float s, float b) { | |
| 645 | + if (isSet(FLAGS_SETTING_COLOR)) { | |
| 646 | + return; | |
| 647 | + } | |
| 648 | + | |
| 649 | + setAngleFromHue(h); | |
| 650 | + setSaturationAndBrightness(s, b); | |
| 651 | + } | |
| 652 | + | |
| 653 | + /** | |
| 654 | + * Returns the selected color. | |
| 655 | + */ | |
| 656 | + public Color getColor() { | |
| 657 | + return GTKColorChooserPanel.this.getColor(); | |
| 658 | + } | |
| 659 | + | |
| 660 | + /** | |
| 661 | + * Returns the x location of the selected color indicator. | |
| 662 | + */ | |
| 663 | + int getColorX() { | |
| 664 | + return circleX + getIndicatorSize() / 2 - getWheelXOrigin(); | |
| 665 | + } | |
| 666 | + | |
| 667 | + /** | |
| 668 | + * Returns the y location of the selected color indicator. | |
| 669 | + */ | |
| 670 | + int getColorY() { | |
| 671 | + return circleY + getIndicatorSize() / 2 - getWheelYOrigin(); | |
| 672 | + } | |
| 673 | + | |
| 674 | + protected void processEvent(AWTEvent e) { | |
| 675 | + if (e.getID() == MouseEvent.MOUSE_PRESSED || | |
| 676 | + ((isSet(FLAGS_DRAGGING) ||isSet(FLAGS_DRAGGING_TRIANGLE)) && | |
| 677 | + e.getID() == MouseEvent.MOUSE_DRAGGED)) { | |
| 678 | + // Assign focus to either the wheel or triangle and attempt | |
| 679 | + // to drag either the wheel or triangle. | |
| 680 | + int size = getWheelRadius(); | |
| 681 | + int x = ((MouseEvent)e).getX() - size; | |
| 682 | + int y = ((MouseEvent)e).getY() - size; | |
| 683 | + | |
| 684 | + if (!hasFocus()) { | |
| 685 | + requestFocus(); | |
| 686 | + } | |
| 687 | + if (!isSet(FLAGS_DRAGGING_TRIANGLE) && | |
| 688 | + adjustHue(x, y, e.getID() == MouseEvent.MOUSE_PRESSED)) { | |
| 689 | + setFlag(FLAGS_DRAGGING, true); | |
| 690 | + setFocusType(1); | |
| 691 | + } | |
| 692 | + else if (adjustSB(x, y, e.getID() == | |
| 693 | + MouseEvent.MOUSE_PRESSED)) { | |
| 694 | + setFlag(FLAGS_DRAGGING_TRIANGLE, true); | |
| 695 | + setFocusType(2); | |
| 696 | + } | |
| 697 | + else { | |
| 698 | + setFocusType(2); | |
| 699 | + } | |
| 700 | + } | |
| 701 | + else if (e.getID() == MouseEvent.MOUSE_RELEASED) { | |
| 702 | + // Stopped dragging | |
| 703 | + setFlag(FLAGS_DRAGGING_TRIANGLE, false); | |
| 704 | + setFlag(FLAGS_DRAGGING, false); | |
| 705 | + } | |
| 706 | + else if (e.getID() == FocusEvent.FOCUS_LOST) { | |
| 707 | + // Reset the flags to indicate no one has focus | |
| 708 | + setFocusType(0); | |
| 709 | + } | |
| 710 | + else if (e.getID() == FocusEvent.FOCUS_GAINED) { | |
| 711 | + // Gained focus, reassign focus to the wheel if no one | |
| 712 | + // currently has focus. | |
| 713 | + if (!isSet(FLAGS_FOCUSED_TRIANGLE) && | |
| 714 | + !isSet(FLAGS_FOCUSED_WHEEL)) { | |
| 715 | + setFlag(FLAGS_FOCUSED_WHEEL, true); | |
| 716 | + setFocusType(1); | |
| 717 | + } | |
| 718 | + repaint(); | |
| 719 | + } | |
| 720 | + super.processEvent(e); | |
| 721 | + } | |
| 722 | + | |
| 723 | + public void paintComponent(Graphics g) { | |
| 724 | + super.paintComponent(g); | |
| 725 | + | |
| 726 | + // Draw the wheel and triangle | |
| 727 | + int size = getWheelRadius(); | |
| 728 | + int width = getWheelWidth(); | |
| 729 | + Image image = getImage(size); | |
| 730 | + g.drawImage(image, getWheelXOrigin() - size, | |
| 731 | + getWheelYOrigin() - size, null); | |
| 732 | + | |
| 733 | + // Draw the focus indicator for the wheel | |
| 734 | + if (hasFocus() && isSet(FLAGS_FOCUSED_WHEEL)) { | |
| 735 | + g.setColor(Color.BLACK); | |
| 736 | + g.drawOval(getWheelXOrigin() - size, getWheelYOrigin() - size, | |
| 737 | + 2 * size, 2 * size); | |
| 738 | + g.drawOval(getWheelXOrigin() - size + width, getWheelYOrigin()- | |
| 739 | + size + width, 2 * (size - width), 2 * | |
| 740 | + (size - width)); | |
| 741 | + } | |
| 742 | + | |
| 743 | + // Draw a line on the wheel indicating the selected hue. | |
| 744 | + if (Math.toDegrees(Math.PI * 2 - angle) <= 20 || | |
| 745 | + Math.toDegrees(Math.PI * 2 - angle) >= 201) { | |
| 746 | + g.setColor(Color.WHITE); | |
| 747 | + } | |
| 748 | + else { | |
| 749 | + g.setColor(Color.BLACK); | |
| 750 | + } | |
| 751 | + int lineX0 = (int)(Math.cos(angle) * size); | |
| 752 | + int lineY0 = (int)(Math.sin(angle) * size); | |
| 753 | + int lineX1 = (int)(Math.cos(angle) * (size - width)); | |
| 754 | + int lineY1 = (int)(Math.sin(angle) * (size - width)); | |
| 755 | + g.drawLine(lineX0 + size, lineY0 + size, lineX1 + size, | |
| 756 | + lineY1 + size); | |
| 757 | + | |
| 758 | + // Draw the focus indicator on the triangle | |
| 759 | + if (hasFocus() && isSet(FLAGS_FOCUSED_TRIANGLE)) { | |
| 760 | + Graphics g2 = g.create(); | |
| 761 | + int innerR = getTriangleCircumscribedRadius(); | |
| 762 | + int a = (int)(3 * innerR / Math.sqrt(3)); | |
| 763 | + g2.translate(getWheelXOrigin(), getWheelYOrigin()); | |
| 764 | + ((Graphics2D)g2).rotate(angle + Math.PI / 2); | |
| 765 | + g2.setColor(Color.BLACK); | |
| 766 | + g2.drawLine(0, -innerR, a / 2, innerR / 2); | |
| 767 | + g2.drawLine(a / 2, innerR / 2, -a / 2, innerR / 2); | |
| 768 | + g2.drawLine(-a / 2, innerR / 2, 0, -innerR); | |
| 769 | + g2.dispose(); | |
| 770 | + } | |
| 771 | + | |
| 772 | + // Draw the selected color indicator. | |
| 773 | + g.setColor(Color.BLACK); | |
| 774 | + g.drawOval(circleX, circleY, getIndicatorSize() - 1, | |
| 775 | + getIndicatorSize() - 1); | |
| 776 | + g.setColor(Color.WHITE); | |
| 777 | + g.drawOval(circleX + 1, circleY + 1, getIndicatorSize() - 3, | |
| 778 | + getIndicatorSize() - 3); | |
| 779 | + } | |
| 780 | + | |
| 781 | + /** | |
| 782 | + * Returns an image representing the triangle and wheel. | |
| 783 | + */ | |
| 784 | + private Image getImage(int size) { | |
| 785 | + if (!isSet(FLAGS_CHANGED_ANGLE) && wheelImage != null && | |
| 786 | + wheelImage.getWidth(null) == size * 2) { | |
| 787 | + return wheelImage; | |
| 788 | + } | |
| 789 | + if (wheelImage == null || wheelImage.getWidth(null) != size) { | |
| 790 | + wheelImage = getWheelImage(size); | |
| 791 | + } | |
| 792 | + int innerR = getTriangleCircumscribedRadius(); | |
| 793 | + int triangleSize = (int)(innerR * 3.0 / 2.0); | |
| 794 | + int a = (int)(2 * triangleSize / Math.sqrt(3)); | |
| 795 | + if (triangleImage == null || triangleImage.getWidth(null) != a) { | |
| 796 | + triangleImage = new BufferedImage(a, a, | |
| 797 | + BufferedImage.TYPE_INT_ARGB); | |
| 798 | + } | |
| 799 | + Graphics g = triangleImage.getGraphics(); | |
| 800 | + g.setColor(new Color(0, 0, 0, 0)); | |
| 801 | + g.fillRect(0, 0, a, a); | |
| 802 | + g.translate(a / 2, 0); | |
| 803 | + paintTriangle(g, triangleSize, getColor()); | |
| 804 | + g.translate(-a / 2, 0); | |
| 805 | + g.dispose(); | |
| 806 | + | |
| 807 | + g = wheelImage.getGraphics(); | |
| 808 | + g.setColor(new Color(0, 0, 0, 0)); | |
| 809 | + g.fillOval(getWheelWidth(), getWheelWidth(), | |
| 810 | + 2 * (size - getWheelWidth()), | |
| 811 | + 2 * (size - getWheelWidth())); | |
| 812 | + | |
| 813 | + double rotate = Math.toRadians(-30.0) + angle; | |
| 814 | + g.translate(size, size); | |
| 815 | + ((Graphics2D)g).rotate(rotate); | |
| 816 | + g.drawImage(triangleImage, -a / 2, | |
| 817 | + getWheelWidth() - size, null); | |
| 818 | + ((Graphics2D)g).rotate(-rotate); | |
| 819 | + g.translate(a / 2, size - getWheelWidth()); | |
| 820 | + | |
| 821 | + setFlag(FLAGS_CHANGED_ANGLE, false); | |
| 822 | + | |
| 823 | + return wheelImage; | |
| 824 | + } | |
| 825 | + | |
| 826 | + private void paintTriangle(Graphics g, int size, Color color) { | |
| 827 | + float[] colors = Color.RGBtoHSB(color.getRed(), | |
| 828 | + color.getGreen(), | |
| 829 | + color.getBlue(), null); | |
| 830 | + float hue = colors[0]; | |
| 831 | + double dSize = (double)size; | |
| 832 | + for (int y = 0; y < size; y++) { | |
| 833 | + int maxX = (int)(y * Math.tan(Math.toRadians(30.0))); | |
| 834 | + float factor = maxX * 2; | |
| 835 | + if (maxX > 0) { | |
| 836 | + float value = (float)(y / dSize); | |
| 837 | + for (int x = -maxX; x <= maxX; x++) { | |
| 838 | + float saturation = (float)x / factor + .5f; | |
| 839 | + g.setColor(Color.getHSBColor(hue, saturation, value)); | |
| 840 | + g.fillRect(x, y, 1, 1); | |
| 841 | + } | |
| 842 | + } | |
| 843 | + else { | |
| 844 | + g.setColor(color); | |
| 845 | + g.fillRect(0, y, 1, 1); | |
| 846 | + } | |
| 847 | + } | |
| 848 | + } | |
| 849 | + | |
| 850 | + /** | |
| 851 | + * Returns a color wheel image for the specified size. | |
| 852 | + * | |
| 853 | + * @param size Integer giving size of color wheel. | |
| 854 | + * @return Color wheel image | |
| 855 | + */ | |
| 856 | + private Image getWheelImage(int size) { | |
| 857 | + int minSize = size - getWheelWidth(); | |
| 858 | + int doubleSize = size * 2; | |
| 859 | + BufferedImage image = new BufferedImage(doubleSize, doubleSize, | |
| 860 | + BufferedImage.TYPE_INT_ARGB); | |
| 861 | + | |
| 862 | + for (int y = -size; y < size; y++) { | |
| 863 | + int ySquared = y * y; | |
| 864 | + for (int x = -size; x < size; x++) { | |
| 865 | + double rad = Math.sqrt(ySquared + x * x); | |
| 866 | + | |
| 867 | + if (rad < size && rad > minSize) { | |
| 868 | + int rgb = colorWheelLocationToRGB(x, y, rad) | | |
| 869 | + 0xFF000000; | |
| 870 | + image.setRGB(x + size, y + size, rgb); | |
| 871 | + } | |
| 872 | + } | |
| 873 | + } | |
| 874 | + wheelImage = image; | |
| 875 | + return wheelImage; | |
| 876 | + } | |
| 877 | + | |
| 878 | + /** | |
| 879 | + * Adjusts the saturation and brightness. <code>x</code> and | |
| 880 | + * <code>y</code> give the location to adjust to and are relative | |
| 881 | + * to the origin of the wheel/triangle. | |
| 882 | + * | |
| 883 | + * @param x X coordinate on the triangle to adjust to | |
| 884 | + * @param y Y coordinate on the triangle to adjust to | |
| 885 | + * @param checkLoc if true the location is checked to make sure | |
| 886 | + * it is contained in the triangle, if false the location is | |
| 887 | + * constrained to fit in the triangle. | |
| 888 | + * @return true if the location is valid | |
| 889 | + */ | |
| 890 | + boolean adjustSB(int x, int y, boolean checkLoc) { | |
| 891 | + int innerR = getWheelRadius() - getWheelWidth(); | |
| 892 | + boolean resetXY = false; | |
| 893 | + // Invert the axis. | |
| 894 | + y = -y; | |
| 895 | + if (checkLoc && (x < -innerR || x > innerR || y < -innerR || | |
| 896 | + y > innerR)) { | |
| 897 | + return false; | |
| 898 | + } | |
| 899 | + // Rotate to origin and and verify x is valid. | |
| 900 | + int triangleSize = innerR * 3 / 2; | |
| 901 | + double x1 = Math.cos(angle) * x - Math.sin(angle) * y; | |
| 902 | + double y1 = Math.sin(angle) * x + Math.cos(angle) * y; | |
| 903 | + if (x1 < -(innerR / 2)) { | |
| 904 | + if (checkLoc) { | |
| 905 | + return false; | |
| 906 | + } | |
| 907 | + x1 = -innerR / 2; | |
| 908 | + resetXY = true; | |
| 909 | + } | |
| 910 | + else if ((int)x1 > innerR) { | |
| 911 | + if (checkLoc) { | |
| 912 | + return false; | |
| 913 | + } | |
| 914 | + x1 = innerR; | |
| 915 | + resetXY = true; | |
| 916 | + } | |
| 917 | + // Verify y location is valid. | |
| 918 | + int maxY = (int)((triangleSize - x1 - innerR / 2.0) * | |
| 919 | + Math.tan(Math.toRadians(30.0))); | |
| 920 | + if (y1 <= -maxY) { | |
| 921 | + if (checkLoc) { | |
| 922 | + return false; | |
| 923 | + } | |
| 924 | + y1 = -maxY; | |
| 925 | + resetXY = true; | |
| 926 | + } | |
| 927 | + else if (y1 > maxY) { | |
| 928 | + if (checkLoc) { | |
| 929 | + return false; | |
| 930 | + } | |
| 931 | + y1 = maxY; | |
| 932 | + resetXY = true; | |
| 933 | + } | |
| 934 | + // Rotate again to determine value and scale | |
| 935 | + double x2 = Math.cos(Math.toRadians(-30.0)) * x1 - | |
| 936 | + Math.sin(Math.toRadians(-30.0)) * y1; | |
| 937 | + double y2 = Math.sin(Math.toRadians(-30.0)) * x1 + | |
| 938 | + Math.cos(Math.toRadians(-30.0)) * y1; | |
| 939 | + float value = Math.min(1.0f, (float)((innerR - y2) / | |
| 940 | + (double)triangleSize)); | |
| 941 | + float maxX = (float)(Math.tan(Math.toRadians(30)) * (innerR - y2)); | |
| 942 | + float saturation = Math.min(1.0f, (float)(x2 / maxX / 2 + .5)); | |
| 943 | + | |
| 944 | + setFlag(FLAGS_SETTING_COLOR, true); | |
| 945 | + if (resetXY) { | |
| 946 | + setSaturationAndBrightness(saturation, value); | |
| 947 | + } | |
| 948 | + else { | |
| 949 | + setSaturationAndBrightness(saturation, value, x + | |
| 950 | + getWheelXOrigin(),getWheelYOrigin() - y); | |
| 951 | + } | |
| 952 | + GTKColorChooserPanel.this.setSaturationAndBrightness(saturation, | |
| 953 | + value, true); | |
| 954 | + setFlag(FLAGS_SETTING_COLOR, false); | |
| 955 | + return true; | |
| 956 | + } | |
| 957 | + | |
| 958 | + /** | |
| 959 | + * Sets the saturation and brightness. | |
| 960 | + */ | |
| 961 | + private void setSaturationAndBrightness(float s, float b) { | |
| 962 | + int innerR = getTriangleCircumscribedRadius(); | |
| 963 | + int triangleSize = innerR * 3 / 2; | |
| 964 | + double x = b * triangleSize; | |
| 965 | + double maxY = x * Math.tan(Math.toRadians(30.0)); | |
| 966 | + double y = 2 * maxY * s - maxY; | |
| 967 | + x = x - innerR; | |
| 968 | + double x1 = Math.cos(Math.toRadians(-60.0) - angle) * | |
| 969 | + x - Math.sin(Math.toRadians(-60.0) - angle) * y; | |
| 970 | + double y1 = Math.sin(Math.toRadians(-60.0) - angle) * x + | |
| 971 | + Math.cos(Math.toRadians(-60.0) - angle) * y; | |
| 972 | + int newCircleX = (int)x1 + getWheelXOrigin(); | |
| 973 | + int newCircleY = getWheelYOrigin() - (int)y1; | |
| 974 | + | |
| 975 | + setSaturationAndBrightness(s, b, newCircleX, newCircleY); | |
| 976 | + } | |
| 977 | + | |
| 978 | + | |
| 979 | + /** | |
| 980 | + * Sets the saturation and brightness. | |
| 981 | + */ | |
| 982 | + private void setSaturationAndBrightness(float s, float b, | |
| 983 | + int newCircleX, int newCircleY) { | |
| 984 | + newCircleX -= getIndicatorSize() / 2; | |
| 985 | + newCircleY -= getIndicatorSize() / 2; | |
| 986 | + | |
| 987 | + int minX = Math.min(newCircleX, circleX); | |
| 988 | + int minY = Math.min(newCircleY, circleY); | |
| 989 | + | |
| 990 | + repaint(minX, minY, Math.max(circleX, newCircleX) - minX + | |
| 991 | + getIndicatorSize() + 1, Math.max(circleY, newCircleY) - | |
| 992 | + minY + getIndicatorSize() + 1); | |
| 993 | + circleX = newCircleX; | |
| 994 | + circleY = newCircleY; | |
| 995 | + } | |
| 996 | + | |
| 997 | + /** | |
| 998 | + * Adjusts the hue based on the passed in location. | |
| 999 | + * | |
| 1000 | + * @param x X location to adjust to, relative to the origin of the | |
| 1001 | + * wheel | |
| 1002 | + * @param y Y location to adjust to, relative to the origin of the | |
| 1003 | + * wheel | |
| 1004 | + * @param check if true the location is checked to make sure | |
| 1005 | + * it is contained in the wheel, if false the location is | |
| 1006 | + * constrained to fit in the wheel | |
| 1007 | + * @return true if the location is valid. | |
| 1008 | + */ | |
| 1009 | + private boolean adjustHue(int x, int y, boolean check) { | |
| 1010 | + double rad = Math.sqrt(x * x + y * y); | |
| 1011 | + int size = getWheelRadius(); | |
| 1012 | + | |
| 1013 | + if (!check || (rad >= size - getWheelWidth() && rad < size)) { | |
| 1014 | + // Map the location to an angle and reset hue | |
| 1015 | + double angle; | |
| 1016 | + if (x == 0) { | |
| 1017 | + if (y > 0) { | |
| 1018 | + angle = Math.PI / 2.0; | |
| 1019 | + } | |
| 1020 | + else { | |
| 1021 | + angle = Math.PI + Math.PI / 2.0; | |
| 1022 | + } | |
| 1023 | + } | |
| 1024 | + else { | |
| 1025 | + angle = Math.atan((double)y / (double)x); | |
| 1026 | + if (x < 0) { | |
| 1027 | + angle += Math.PI; | |
| 1028 | + } | |
| 1029 | + else if (angle < 0) { | |
| 1030 | + angle += 2 * Math.PI; | |
| 1031 | + } | |
| 1032 | + } | |
| 1033 | + setFlag(FLAGS_SETTING_COLOR, true); | |
| 1034 | + setHue((float)(1.0 - angle / Math.PI / 2), true); | |
| 1035 | + setFlag(FLAGS_SETTING_COLOR, false); | |
| 1036 | + setHueAngle(angle); | |
| 1037 | + setSaturationAndBrightness(getSaturation(), getBrightness()); | |
| 1038 | + return true; | |
| 1039 | + } | |
| 1040 | + return false; | |
| 1041 | + } | |
| 1042 | + | |
| 1043 | + /** | |
| 1044 | + * Rotates the triangle to accomodate the passed in hue. | |
| 1045 | + */ | |
| 1046 | + private void setAngleFromHue(float hue) { | |
| 1047 | + setHueAngle((1.0 - hue) * Math.PI * 2); | |
| 1048 | + } | |
| 1049 | + | |
| 1050 | + /** | |
| 1051 | + * Sets the angle representing the hue. | |
| 1052 | + */ | |
| 1053 | + private void setHueAngle(double angle) { | |
| 1054 | + double oldAngle = this.angle; | |
| 1055 | + | |
| 1056 | + this.angle = angle; | |
| 1057 | + if (angle != oldAngle) { | |
| 1058 | + setFlag(FLAGS_CHANGED_ANGLE, true); | |
| 1059 | + repaint(); | |
| 1060 | + } | |
| 1061 | + } | |
| 1062 | + | |
| 1063 | + /** | |
| 1064 | + * Returns the size of the color indicator. | |
| 1065 | + */ | |
| 1066 | + private int getIndicatorSize() { | |
| 1067 | + return 8; | |
| 1068 | + } | |
| 1069 | + | |
| 1070 | + /** | |
| 1071 | + * Returns the circumscribed radius of the triangle. | |
| 1072 | + */ | |
| 1073 | + private int getTriangleCircumscribedRadius() { | |
| 1074 | + return 72; | |
| 1075 | + } | |
| 1076 | + | |
| 1077 | + /** | |
| 1078 | + * Returns the x origin of the wheel and triangle. | |
| 1079 | + */ | |
| 1080 | + private int getWheelXOrigin() { | |
| 1081 | + return 85; | |
| 1082 | + } | |
| 1083 | + | |
| 1084 | + /** | |
| 1085 | + * Returns y origin of the wheel and triangle. | |
| 1086 | + */ | |
| 1087 | + private int getWheelYOrigin() { | |
| 1088 | + return 85; | |
| 1089 | + } | |
| 1090 | + | |
| 1091 | + /** | |
| 1092 | + * Returns the width of the wheel. | |
| 1093 | + */ | |
| 1094 | + private int getWheelWidth() { | |
| 1095 | + return 13; | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + /** | |
| 1099 | + * Sets the focus to one of: 0 no one, 1 the wheel or 2 the triangle. | |
| 1100 | + */ | |
| 1101 | + private void setFocusType(int type) { | |
| 1102 | + if (type == 0) { | |
| 1103 | + setFlag(FLAGS_FOCUSED_WHEEL, false); | |
| 1104 | + setFlag(FLAGS_FOCUSED_TRIANGLE, false); | |
| 1105 | + repaint(); | |
| 1106 | + } | |
| 1107 | + else { | |
| 1108 | + int toSet = FLAGS_FOCUSED_WHEEL; | |
| 1109 | + int toUnset = FLAGS_FOCUSED_TRIANGLE; | |
| 1110 | + | |
| 1111 | + if (type == 2) { | |
| 1112 | + toSet = FLAGS_FOCUSED_TRIANGLE; | |
| 1113 | + toUnset = FLAGS_FOCUSED_WHEEL; | |
| 1114 | + } | |
| 1115 | + if (!isSet(toSet)) { | |
| 1116 | + setFlag(toSet, true); | |
| 1117 | + repaint(); | |
| 1118 | + setFlag(toUnset, false); | |
| 1119 | + } | |
| 1120 | + } | |
| 1121 | + } | |
| 1122 | + | |
| 1123 | + /** | |
| 1124 | + * Returns the radius of the wheel. | |
| 1125 | + */ | |
| 1126 | + private int getWheelRadius() { | |
| 1127 | + // As far as I can tell, GTK doesn't allow stretching this | |
| 1128 | + // widget | |
| 1129 | + return 85; | |
| 1130 | + } | |
| 1131 | + | |
| 1132 | + /** | |
| 1133 | + * Updates the flags bitmask. | |
| 1134 | + */ | |
| 1135 | + private void setFlag(int flag, boolean value) { | |
| 1136 | + if (value) { | |
| 1137 | + flags |= flag; | |
| 1138 | + } | |
| 1139 | + else { | |
| 1140 | + flags &= ~flag; | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | + /** | |
| 1145 | + * Returns true if a particular flag has been set. | |
| 1146 | + */ | |
| 1147 | + private boolean isSet(int flag) { | |
| 1148 | + return ((flags & flag) == flag); | |
| 1149 | + } | |
| 1150 | + | |
| 1151 | + /** | |
| 1152 | + * Returns the RGB color to use for the specified location. The | |
| 1153 | + * passed in point must be on the color wheel and be relative to the | |
| 1154 | + * origin of the color wheel. | |
| 1155 | + * | |
| 1156 | + * @param x X location to get color for | |
| 1157 | + * @param y Y location to get color for | |
| 1158 | + * @param rad Radius from center of color wheel | |
| 1159 | + * @return integer with red, green and blue components | |
| 1160 | + */ | |
| 1161 | + private int colorWheelLocationToRGB(int x, int y, double rad) { | |
| 1162 | + double angle = Math.acos((double)x / rad); | |
| 1163 | + int rgb; | |
| 1164 | + | |
| 1165 | + if (angle < PI_3) { | |
| 1166 | + if (y < 0) { | |
| 1167 | + // FFFF00 - FF0000 | |
| 1168 | + rgb = 0xFF0000 | Math.min(255, | |
| 1169 | + (int)(255 * angle / PI_3)) << 8; | |
| 1170 | + } | |
| 1171 | + else { | |
| 1172 | + // FF0000 - FF00FF | |
| 1173 | + rgb = 0xFF0000 | Math.min(255, | |
| 1174 | + (int)(255 * angle / PI_3)); | |
| 1175 | + } | |
| 1176 | + } | |
| 1177 | + else if (angle < 2 * PI_3) { | |
| 1178 | + angle -= PI_3; | |
| 1179 | + if (y < 0) { | |
| 1180 | + // 00FF00 - FFFF00 | |
| 1181 | + rgb = 0x00FF00 | Math.max(0, 255 - | |
| 1182 | + (int)(255 * angle / PI_3)) << 16; | |
| 1183 | + } | |
| 1184 | + else { | |
| 1185 | + // FF00FF - 0000FF | |
| 1186 | + rgb = 0x0000FF | Math.max(0, 255 - | |
| 1187 | + (int)(255 * angle / PI_3)) << 16; | |
| 1188 | + } | |
| 1189 | + } | |
| 1190 | + else { | |
| 1191 | + angle -= 2 * PI_3; | |
| 1192 | + if (y < 0) { | |
| 1193 | + // 00FFFF - 00FF00 | |
| 1194 | + rgb = 0x00FF00 | Math.min(255, | |
| 1195 | + (int)(255 * angle / PI_3)); | |
| 1196 | + } | |
| 1197 | + else { | |
| 1198 | + // 0000FF - 00FFFF | |
| 1199 | + rgb = 0x0000FF | Math.min(255, | |
| 1200 | + (int)(255 * angle / PI_3)) << 8; | |
| 1201 | + } | |
| 1202 | + } | |
| 1203 | + return rgb; | |
| 1204 | + } | |
| 1205 | + | |
| 1206 | + /** | |
| 1207 | + * Increments the hue. | |
| 1208 | + */ | |
| 1209 | + void incrementHue(boolean positive) { | |
| 1210 | + float hue = triangle.getGTKColorChooserPanel().getHue(); | |
| 1211 | + | |
| 1212 | + if (positive) { | |
| 1213 | + hue += 1.0f / 360.0f; | |
| 1214 | + } | |
| 1215 | + else { | |
| 1216 | + hue -= 1.0f / 360.0f; | |
| 1217 | + } | |
| 1218 | + if (hue > 1) { | |
| 1219 | + hue -= 1; | |
| 1220 | + } | |
| 1221 | + else if (hue < 0) { | |
| 1222 | + hue += 1; | |
| 1223 | + } | |
| 1224 | + getGTKColorChooserPanel().setHue(hue, true); | |
| 1225 | + } | |
| 1226 | + } | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + /** | |
| 1230 | + * Action class used for colors. | |
| 1231 | + */ | |
| 1232 | + private static class ColorAction extends AbstractAction { | |
| 1233 | + private int type; | |
| 1234 | + | |
| 1235 | + ColorAction(String name, int type) { | |
| 1236 | + super(name); | |
| 1237 | + this.type = type; | |
| 1238 | + } | |
| 1239 | + | |
| 1240 | + public void actionPerformed(ActionEvent e) { | |
| 1241 | + ColorTriangle triangle = (ColorTriangle)e.getSource(); | |
| 1242 | + | |
| 1243 | + if (triangle.isWheelFocused()) { | |
| 1244 | + float hue = triangle.getGTKColorChooserPanel().getHue(); | |
| 1245 | + | |
| 1246 | + switch (type) { | |
| 1247 | + case 0: | |
| 1248 | + case 2: | |
| 1249 | + triangle.incrementHue(true); | |
| 1250 | + break; | |
| 1251 | + case 1: | |
| 1252 | + case 3: | |
| 1253 | + triangle.incrementHue(false); | |
| 1254 | + break; | |
| 1255 | + case 4: | |
| 1256 | + triangle.focusTriangle(); | |
| 1257 | + break; | |
| 1258 | + case 5: | |
| 1259 | + compositeRequestFocus(triangle, false); | |
| 1260 | + break; | |
| 1261 | + } | |
| 1262 | + } | |
| 1263 | + else { | |
| 1264 | + int xDelta = 0; | |
| 1265 | + int yDelta = 0; | |
| 1266 | + | |
| 1267 | + switch (type) { | |
| 1268 | + case 0: | |
| 1269 | + // up | |
| 1270 | + yDelta--; | |
| 1271 | + break; | |
| 1272 | + case 1: | |
| 1273 | + // down | |
| 1274 | + yDelta++; | |
| 1275 | + break; | |
| 1276 | + case 2: | |
| 1277 | + // left | |
| 1278 | + xDelta--; | |
| 1279 | + break; | |
| 1280 | + case 3: | |
| 1281 | + // right | |
| 1282 | + xDelta++; | |
| 1283 | + break; | |
| 1284 | + case 4: | |
| 1285 | + compositeRequestFocus(triangle, true); | |
| 1286 | + return; | |
| 1287 | + case 5: | |
| 1288 | + triangle.focusWheel(); | |
| 1289 | + return; | |
| 1290 | + } | |
| 1291 | + triangle.adjustSB(triangle.getColorX() + xDelta, | |
| 1292 | + triangle.getColorY() + yDelta, true); | |
| 1293 | + } | |
| 1294 | + } | |
| 1295 | + } | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + private class OpaqueLabel extends JLabel { | |
| 1299 | + public boolean isOpaque() { | |
| 1300 | + return true; | |
| 1301 | + } | |
| 1302 | + } | |
| 1303 | +} | |
| @@ -0,0 +1,167 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import javax.swing.plaf.synth.ColorType; | |
| 28 | +import java.awt.Color; | |
| 29 | +import javax.swing.plaf.ColorUIResource; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * @author Scott Violet | |
| 33 | + */ | |
| 34 | +public class GTKColorType extends ColorType { | |
| 35 | + // GTK allows you to specify the foreground and background in a | |
| 36 | + // gtkrc, the rest (dark, mid, light) are calculated from these | |
| 37 | + // values. | |
| 38 | + public static final ColorType LIGHT = new GTKColorType("Light"); | |
| 39 | + public static final ColorType DARK = new GTKColorType("Dark"); | |
| 40 | + public static final ColorType MID = new GTKColorType("Mid"); | |
| 41 | + public static final ColorType BLACK = new GTKColorType("Black"); | |
| 42 | + public static final ColorType WHITE = new GTKColorType("White"); | |
| 43 | + | |
| 44 | + public static final int MAX_COUNT; | |
| 45 | + | |
| 46 | + private static final float[] HLS_COLORS = new float[3]; | |
| 47 | + private static final Object HLS_COLOR_LOCK = new Object(); | |
| 48 | + | |
| 49 | + static { | |
| 50 | + MAX_COUNT = WHITE.getID() + 1; | |
| 51 | + } | |
| 52 | + | |
| 53 | + private static int hlsToRGB(float h, float l, float s) { | |
| 54 | + float m2 = (l <= .5f) ? (l * (1 + s)) : (l + s - l * s); | |
| 55 | + float m1 = 2.0f * l - m2; | |
| 56 | + float r, g, b; | |
| 57 | + | |
| 58 | + if (s == 0.0) { | |
| 59 | + if (h == 0.0) { | |
| 60 | + r = g = b = l; | |
| 61 | + } | |
| 62 | + else { | |
| 63 | + r = g = b = 0; | |
| 64 | + } | |
| 65 | + } | |
| 66 | + else { | |
| 67 | + r = hlsValue(m1, m2, h + 120); | |
| 68 | + g = hlsValue(m1, m2, h); | |
| 69 | + b = hlsValue(m1, m2, h - 120); | |
| 70 | + } | |
| 71 | + return (((int)(r * 255)) << 16) | (((int)(g * 255.0)) << 8) | | |
| 72 | + ((int)(b * 255)); | |
| 73 | + } | |
| 74 | + | |
| 75 | + private static float hlsValue(float n1, float n2, float h) { | |
| 76 | + if (h > 360) { | |
| 77 | + h -= 360; | |
| 78 | + } | |
| 79 | + else if (h < 0) { | |
| 80 | + h += 360; | |
| 81 | + } | |
| 82 | + if (h < 60) { | |
| 83 | + return n1 + (n2 - n1) * h / 60.0f; | |
| 84 | + } | |
| 85 | + else if (h < 180) { | |
| 86 | + return n2; | |
| 87 | + } | |
| 88 | + else if (h < 240) { | |
| 89 | + return n1 + (n2 - n1) * (240.0f - h) / 60.0f; | |
| 90 | + } | |
| 91 | + return n1; | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Converts from RGB color space to HLS colorspace. | |
| 96 | + */ | |
| 97 | + private static float[] rgbToHLS(int rgb, float[] hls) { | |
| 98 | + float r = ((rgb & 0xFF0000) >> 16) / 255.0f; | |
| 99 | + float g = ((rgb & 0xFF00) >> 8) / 255.0f; | |
| 100 | + float b = (rgb & 0xFF) / 255.0f; | |
| 101 | + | |
| 102 | + /* calculate lightness */ | |
| 103 | + float max = Math.max(Math.max(r, g), b); | |
| 104 | + float min = Math.min(Math.min(r, g), b); | |
| 105 | + float l = (max + min) / 2.0f; | |
| 106 | + float s = 0; | |
| 107 | + float h = 0; | |
| 108 | + | |
| 109 | + if (max != min) { | |
| 110 | + float delta = max - min; | |
| 111 | + s = (l <= .5f) ? (delta / (max + min)) : (delta / (2.0f - max -min)); | |
| 112 | + if (r == max) { | |
| 113 | + h = (g - b) / delta; | |
| 114 | + } | |
| 115 | + else if (g == max) { | |
| 116 | + h = 2.0f + (b - r) / delta; | |
| 117 | + } | |
| 118 | + else { | |
| 119 | + h = 4.0f + (r - g) / delta; | |
| 120 | + } | |
| 121 | + h *= 60.0f; | |
| 122 | + if (h < 0) { | |
| 123 | + h += 360.0f; | |
| 124 | + } | |
| 125 | + } | |
| 126 | + if (hls == null) { | |
| 127 | + hls = new float[3]; | |
| 128 | + } | |
| 129 | + hls[0] = h; | |
| 130 | + hls[1] = l; | |
| 131 | + hls[2] = s; | |
| 132 | + return hls; | |
| 133 | + } | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * Creates and returns a new color derived from the passed in color. | |
| 137 | + * The transformation is done in the HLS color space using the specified | |
| 138 | + * arguments to scale. | |
| 139 | + * | |
| 140 | + * @param color Color to alter | |
| 141 | + * @param hFactory Amount to scale the hue | |
| 142 | + * @param lFactor Amount to scale the lightness | |
| 143 | + * @param sFactory Amount to sacle saturation | |
| 144 | + * @return newly created color | |
| 145 | + */ | |
| 146 | + static Color adjustColor(Color color, float hFactor, float lFactor, | |
| 147 | + float sFactor) { | |
| 148 | + float h; | |
| 149 | + float l; | |
| 150 | + float s; | |
| 151 | + | |
| 152 | + synchronized(HLS_COLOR_LOCK) { | |
| 153 | + float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS); | |
| 154 | + h = hls[0]; | |
| 155 | + l = hls[1]; | |
| 156 | + s = hls[2]; | |
| 157 | + } | |
| 158 | + h = Math.min(360, hFactor * h); | |
| 159 | + l = Math.min(1, lFactor * l); | |
| 160 | + s = Math.min(1, sFactor * s); | |
| 161 | + return new ColorUIResource(hlsToRGB(h, l, s)); | |
| 162 | + } | |
| 163 | + | |
| 164 | + protected GTKColorType(String name) { | |
| 165 | + super(name); | |
| 166 | + } | |
| 167 | +} | |
| @@ -0,0 +1,118 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * @author Scott Violet | |
| 29 | + */ | |
| 30 | +public interface GTKConstants { | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Used to indicate a constant is not defined. | |
| 34 | + */ | |
| 35 | + public static final int UNDEFINED = -100; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Java representation of native GtkIconSize enum | |
| 39 | + */ | |
| 40 | + public enum IconSize { | |
| 41 | + INVALID, | |
| 42 | + MENU, | |
| 43 | + SMALL_TOOLBAR, | |
| 44 | + LARGE_TOOLBAR, | |
| 45 | + BUTTON, | |
| 46 | + DND, | |
| 47 | + DIALOG | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Java representation of native GtkTextDirection enum | |
| 52 | + */ | |
| 53 | + public enum TextDirection { | |
| 54 | + NONE, | |
| 55 | + LTR, | |
| 56 | + RTL | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Java representation of native GtkShadowType enum | |
| 61 | + */ | |
| 62 | + public enum ShadowType { | |
| 63 | + NONE, | |
| 64 | + IN, | |
| 65 | + OUT, | |
| 66 | + ETCHED_IN, | |
| 67 | + ETCHED_OUT | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Java representation of native GtkStateType enum | |
| 72 | + */ | |
| 73 | + public enum StateType { | |
| 74 | + NORMAL, | |
| 75 | + ACTIVE, | |
| 76 | + PRELIGHT, | |
| 77 | + SELECTED, | |
| 78 | + INSENSITIVE | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * Java representation of native GtkExpanderStyle enum | |
| 83 | + */ | |
| 84 | + public enum ExpanderStyle { | |
| 85 | + COLLAPSED, | |
| 86 | + SEMI_COLLAPSED, | |
| 87 | + SEMI_EXPANDED, | |
| 88 | + EXPANDED, | |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Java representation of native GtkPositionType enum | |
| 93 | + */ | |
| 94 | + public enum PositionType { | |
| 95 | + LEFT, | |
| 96 | + RIGHT, | |
| 97 | + TOP, | |
| 98 | + BOTTOM | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Java representation of native GtkArrowType enum | |
| 103 | + */ | |
| 104 | + public enum ArrowType { | |
| 105 | + UP, | |
| 106 | + DOWN, | |
| 107 | + LEFT, | |
| 108 | + RIGHT | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Java representation of native GtkOrientation enum | |
| 113 | + */ | |
| 114 | + public enum Orientation { | |
| 115 | + HORIZONTAL, | |
| 116 | + VERTICAL | |
| 117 | + } | |
| 118 | +} | |
| @@ -0,0 +1,635 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.awt.image.*; | |
| 30 | +import java.util.HashMap; | |
| 31 | +import javax.swing.*; | |
| 32 | +import javax.swing.plaf.synth.*; | |
| 33 | + | |
| 34 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType; | |
| 35 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle; | |
| 36 | +import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation; | |
| 37 | +import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType; | |
| 38 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType; | |
| 39 | +import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection; | |
| 40 | + | |
| 41 | +import sun.awt.image.SunWritableRaster; | |
| 42 | +import sun.swing.ImageCache; | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * GTKEngine delegates all painting job to native GTK libraries. | |
| 46 | + * | |
| 47 | + * Painting with GTKEngine looks like this: | |
| 48 | + * First, startPainting() is called. It prepares an offscreen buffer of the | |
| 49 | + * required size. | |
| 50 | + * Then, any number of paintXXX() methods can be called. They effectively ignore | |
| 51 | + * the Graphics parameter and draw to the offscreen buffer. | |
| 52 | + * Finally, finishPainting() should be called. It fills the data buffer passed | |
| 53 | + * in with the image data. | |
| 54 | + * | |
| 55 | + * @author Josh Outwater | |
| 56 | + */ | |
| 57 | +class GTKEngine { | |
| 58 | + | |
| 59 | + final static GTKEngine INSTANCE = new GTKEngine(); | |
| 60 | + | |
| 61 | + /** Size of the image cache */ | |
| 62 | + private static final int CACHE_SIZE = 50; | |
| 63 | + | |
| 64 | + /** This enum mirrors that in gtk2_interface.h */ | |
| 65 | + static enum WidgetType { | |
| 66 | + BUTTON, CHECK_BOX, CHECK_BOX_MENU_ITEM, COLOR_CHOOSER, | |
| 67 | + COMBO_BOX, COMBO_BOX_ARROW_BUTTON, COMBO_BOX_TEXT_FIELD, | |
| 68 | + DESKTOP_ICON, DESKTOP_PANE, EDITOR_PANE, FORMATTED_TEXT_FIELD, | |
| 69 | + HANDLE_BOX, HPROGRESS_BAR, | |
| 70 | + HSCROLL_BAR, HSCROLL_BAR_BUTTON_LEFT, HSCROLL_BAR_BUTTON_RIGHT, | |
| 71 | + HSCROLL_BAR_TRACK, HSCROLL_BAR_THUMB, | |
| 72 | + HSEPARATOR, HSLIDER, HSLIDER_TRACK, HSLIDER_THUMB, HSPLIT_PANE_DIVIDER, | |
| 73 | + INTERNAL_FRAME, INTERNAL_FRAME_TITLE_PANE, IMAGE, LABEL, LIST, MENU, | |
| 74 | + MENU_BAR, MENU_ITEM, MENU_ITEM_ACCELERATOR, OPTION_PANE, PANEL, | |
| 75 | + PASSWORD_FIELD, POPUP_MENU, POPUP_MENU_SEPARATOR, | |
| 76 | + RADIO_BUTTON, RADIO_BUTTON_MENU_ITEM, ROOT_PANE, SCROLL_PANE, | |
| 77 | + SPINNER, SPINNER_ARROW_BUTTON, SPINNER_TEXT_FIELD, | |
| 78 | + SPLIT_PANE, TABBED_PANE, TABBED_PANE_TAB_AREA, TABBED_PANE_CONTENT, | |
| 79 | + TABBED_PANE_TAB, TABLE, TABLE_HEADER, TEXT_AREA, TEXT_FIELD, TEXT_PANE, | |
| 80 | + TITLED_BORDER, | |
| 81 | + TOGGLE_BUTTON, TOOL_BAR, TOOL_BAR_DRAG_WINDOW, TOOL_BAR_SEPARATOR, | |
| 82 | + TOOL_TIP, TREE, TREE_CELL, VIEWPORT, VPROGRESS_BAR, | |
| 83 | + VSCROLL_BAR, VSCROLL_BAR_BUTTON_UP, VSCROLL_BAR_BUTTON_DOWN, | |
| 84 | + VSCROLL_BAR_TRACK, VSCROLL_BAR_THUMB, | |
| 85 | + VSEPARATOR, VSLIDER, VSLIDER_TRACK, VSLIDER_THUMB, | |
| 86 | + VSPLIT_PANE_DIVIDER | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Representation of GtkSettings properties. | |
| 91 | + * When we need more settings we can add them here and | |
| 92 | + * to all implementations of getGTKSetting(). | |
| 93 | + */ | |
| 94 | + static enum Settings { | |
| 95 | + GTK_FONT_NAME, | |
| 96 | + GTK_ICON_SIZES | |
| 97 | + } | |
| 98 | + | |
| 99 | + /* Custom regions are needed for representing regions that don't exist | |
| 100 | + * in the original Region class. | |
| 101 | + */ | |
| 102 | + static class CustomRegion extends Region { | |
| 103 | + /* | |
| 104 | + * TITLED_BORDER Region is mapped to GtkFrame class which can draw | |
| 105 | + * titled borders around components. | |
| 106 | + */ | |
| 107 | + static Region TITLED_BORDER = new CustomRegion("TitledBorder"); | |
| 108 | + | |
| 109 | + private CustomRegion(String name) { | |
| 110 | + super(name, null, false); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + | |
| 115 | + private static HashMap<Region, Object> regionToWidgetTypeMap; | |
| 116 | + private ImageCache cache = new ImageCache(CACHE_SIZE); | |
| 117 | + private int x0, y0, w0, h0; | |
| 118 | + private Graphics graphics; | |
| 119 | + private Object[] cacheArgs; | |
| 120 | + | |
| 121 | + private native void native_paint_arrow( | |
| 122 | + int widgetType, int state, int shadowType, String detail, | |
| 123 | + int x, int y, int width, int height, int arrowType); | |
| 124 | + private native void native_paint_box( | |
| 125 | + int widgetType, int state, int shadowType, String detail, | |
| 126 | + int x, int y, int width, int height, int synthState, int dir); | |
| 127 | + private native void native_paint_box_gap( | |
| 128 | + int widgetType, int state, int shadowType, String detail, | |
| 129 | + int x, int y, int width, int height, | |
| 130 | + int gapSide, int gapX, int gapWidth); | |
| 131 | + private native void native_paint_check( | |
| 132 | + int widgetType, int synthState, String detail, | |
| 133 | + int x, int y, int width, int height); | |
| 134 | + private native void native_paint_expander( | |
| 135 | + int widgetType, int state, String detail, | |
| 136 | + int x, int y, int width, int height, int expanderStyle); | |
| 137 | + private native void native_paint_extension( | |
| 138 | + int widgetType, int state, int shadowType, String detail, | |
| 139 | + int x, int y, int width, int height, int placement); | |
| 140 | + private native void native_paint_flat_box( | |
| 141 | + int widgetType, int state, int shadowType, String detail, | |
| 142 | + int x, int y, int width, int height, boolean hasFocus); | |
| 143 | + private native void native_paint_focus( | |
| 144 | + int widgetType, int state, String detail, | |
| 145 | + int x, int y, int width, int height); | |
| 146 | + private native void native_paint_handle( | |
| 147 | + int widgetType, int state, int shadowType, String detail, | |
| 148 | + int x, int y, int width, int height, int orientation); | |
| 149 | + private native void native_paint_hline( | |
| 150 | + int widgetType, int state, String detail, | |
| 151 | + int x, int y, int width, int height); | |
| 152 | + private native void native_paint_option( | |
| 153 | + int widgetType, int synthState, String detail, | |
| 154 | + int x, int y, int width, int height); | |
| 155 | + private native void native_paint_shadow( | |
| 156 | + int widgetType, int state, int shadowType, String detail, | |
| 157 | + int x, int y, int width, int height, int synthState, int dir); | |
| 158 | + private native void native_paint_slider( | |
| 159 | + int widgetType, int state, int shadowType, String detail, | |
| 160 | + int x, int y, int width, int height, int orientation); | |
| 161 | + private native void native_paint_vline( | |
| 162 | + int widgetType, int state, String detail, | |
| 163 | + int x, int y, int width, int height); | |
| 164 | + private native void native_paint_background( | |
| 165 | + int widgetType, int state, int x, int y, int width, int height); | |
| 166 | + private native Object native_get_gtk_setting(int property); | |
| 167 | + private native void nativeSetRangeValue(int widgetType, double value, | |
| 168 | + double min, double max, | |
| 169 | + double visible); | |
| 170 | + | |
| 171 | + private native void nativeStartPainting(int w, int h); | |
| 172 | + private native int nativeFinishPainting(int[] buffer, int width, int height); | |
| 173 | + private native void native_switch_theme(); | |
| 174 | + | |
| 175 | + static { | |
| 176 | + // Make sure the awt toolkit is loaded so we have access to native | |
| 177 | + // methods. | |
| 178 | + Toolkit.getDefaultToolkit(); | |
| 179 | + | |
| 180 | + // Initialize regionToWidgetTypeMap | |
| 181 | + regionToWidgetTypeMap = new HashMap<Region, Object>(50); | |
| 182 | + regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] { | |
| 183 | + WidgetType.SPINNER_ARROW_BUTTON, | |
| 184 | + WidgetType.COMBO_BOX_ARROW_BUTTON, | |
| 185 | + WidgetType.HSCROLL_BAR_BUTTON_LEFT, | |
| 186 | + WidgetType.HSCROLL_BAR_BUTTON_RIGHT, | |
| 187 | + WidgetType.VSCROLL_BAR_BUTTON_UP, | |
| 188 | + WidgetType.VSCROLL_BAR_BUTTON_DOWN}); | |
| 189 | + regionToWidgetTypeMap.put(Region.BUTTON, WidgetType.BUTTON); | |
| 190 | + regionToWidgetTypeMap.put(Region.CHECK_BOX, WidgetType.CHECK_BOX); | |
| 191 | + regionToWidgetTypeMap.put(Region.CHECK_BOX_MENU_ITEM, | |
| 192 | + WidgetType.CHECK_BOX_MENU_ITEM); | |
| 193 | + regionToWidgetTypeMap.put(Region.COLOR_CHOOSER, WidgetType.COLOR_CHOOSER); | |
| 194 | + regionToWidgetTypeMap.put(Region.FILE_CHOOSER, WidgetType.OPTION_PANE); | |
| 195 | + regionToWidgetTypeMap.put(Region.COMBO_BOX, WidgetType.COMBO_BOX); | |
| 196 | + regionToWidgetTypeMap.put(Region.DESKTOP_ICON, WidgetType.DESKTOP_ICON); | |
| 197 | + regionToWidgetTypeMap.put(Region.DESKTOP_PANE, WidgetType.DESKTOP_PANE); | |
| 198 | + regionToWidgetTypeMap.put(Region.EDITOR_PANE, WidgetType.EDITOR_PANE); | |
| 199 | + regionToWidgetTypeMap.put(Region.FORMATTED_TEXT_FIELD, new WidgetType[] { | |
| 200 | + WidgetType.FORMATTED_TEXT_FIELD, WidgetType.SPINNER_TEXT_FIELD}); | |
| 201 | + regionToWidgetTypeMap.put(GTKRegion.HANDLE_BOX, WidgetType.HANDLE_BOX); | |
| 202 | + regionToWidgetTypeMap.put(Region.INTERNAL_FRAME, | |
| 203 | + WidgetType.INTERNAL_FRAME); | |
| 204 | + regionToWidgetTypeMap.put(Region.INTERNAL_FRAME_TITLE_PANE, | |
| 205 | + WidgetType.INTERNAL_FRAME_TITLE_PANE); | |
| 206 | + regionToWidgetTypeMap.put(Region.LABEL, new WidgetType[] { | |
| 207 | + WidgetType.LABEL, WidgetType.COMBO_BOX_TEXT_FIELD}); | |
| 208 | + regionToWidgetTypeMap.put(Region.LIST, WidgetType.LIST); | |
| 209 | + regionToWidgetTypeMap.put(Region.MENU, WidgetType.MENU); | |
| 210 | + regionToWidgetTypeMap.put(Region.MENU_BAR, WidgetType.MENU_BAR); | |
| 211 | + regionToWidgetTypeMap.put(Region.MENU_ITEM, WidgetType.MENU_ITEM); | |
| 212 | + regionToWidgetTypeMap.put(Region.MENU_ITEM_ACCELERATOR, | |
| 213 | + WidgetType.MENU_ITEM_ACCELERATOR); | |
| 214 | + regionToWidgetTypeMap.put(Region.OPTION_PANE, WidgetType.OPTION_PANE); | |
| 215 | + regionToWidgetTypeMap.put(Region.PANEL, WidgetType.PANEL); | |
| 216 | + regionToWidgetTypeMap.put(Region.PASSWORD_FIELD, | |
| 217 | + WidgetType.PASSWORD_FIELD); | |
| 218 | + regionToWidgetTypeMap.put(Region.POPUP_MENU, WidgetType.POPUP_MENU); | |
| 219 | + regionToWidgetTypeMap.put(Region.POPUP_MENU_SEPARATOR, | |
| 220 | + WidgetType.POPUP_MENU_SEPARATOR); | |
| 221 | + regionToWidgetTypeMap.put(Region.PROGRESS_BAR, new WidgetType[] { | |
| 222 | + WidgetType.HPROGRESS_BAR, WidgetType.VPROGRESS_BAR}); | |
| 223 | + regionToWidgetTypeMap.put(Region.RADIO_BUTTON, WidgetType.RADIO_BUTTON); | |
| 224 | + regionToWidgetTypeMap.put(Region.RADIO_BUTTON_MENU_ITEM, | |
| 225 | + WidgetType.RADIO_BUTTON_MENU_ITEM); | |
| 226 | + regionToWidgetTypeMap.put(Region.ROOT_PANE, WidgetType.ROOT_PANE); | |
| 227 | + regionToWidgetTypeMap.put(Region.SCROLL_BAR, new WidgetType[] { | |
| 228 | + WidgetType.HSCROLL_BAR, WidgetType.VSCROLL_BAR}); | |
| 229 | + regionToWidgetTypeMap.put(Region.SCROLL_BAR_THUMB, new WidgetType[] { | |
| 230 | + WidgetType.HSCROLL_BAR_THUMB, WidgetType.VSCROLL_BAR_THUMB}); | |
| 231 | + regionToWidgetTypeMap.put(Region.SCROLL_BAR_TRACK, new WidgetType[] { | |
| 232 | + WidgetType.HSCROLL_BAR_TRACK, WidgetType.VSCROLL_BAR_TRACK}); | |
| 233 | + regionToWidgetTypeMap.put(Region.SCROLL_PANE, WidgetType.SCROLL_PANE); | |
| 234 | + regionToWidgetTypeMap.put(Region.SEPARATOR, new WidgetType[] { | |
| 235 | + WidgetType.HSEPARATOR, WidgetType.VSEPARATOR}); | |
| 236 | + regionToWidgetTypeMap.put(Region.SLIDER, new WidgetType[] { | |
| 237 | + WidgetType.HSLIDER, WidgetType.VSLIDER}); | |
| 238 | + regionToWidgetTypeMap.put(Region.SLIDER_THUMB, new WidgetType[] { | |
| 239 | + WidgetType.HSLIDER_THUMB, WidgetType.VSLIDER_THUMB}); | |
| 240 | + regionToWidgetTypeMap.put(Region.SLIDER_TRACK, new WidgetType[] { | |
| 241 | + WidgetType.HSLIDER_TRACK, WidgetType.VSLIDER_TRACK}); | |
| 242 | + regionToWidgetTypeMap.put(Region.SPINNER, WidgetType.SPINNER); | |
| 243 | + regionToWidgetTypeMap.put(Region.SPLIT_PANE, WidgetType.SPLIT_PANE); | |
| 244 | + regionToWidgetTypeMap.put(Region.SPLIT_PANE_DIVIDER, new WidgetType[] { | |
| 245 | + WidgetType.HSPLIT_PANE_DIVIDER, WidgetType.VSPLIT_PANE_DIVIDER}); | |
| 246 | + regionToWidgetTypeMap.put(Region.TABBED_PANE, WidgetType.TABBED_PANE); | |
| 247 | + regionToWidgetTypeMap.put(Region.TABBED_PANE_CONTENT, | |
| 248 | + WidgetType.TABBED_PANE_CONTENT); | |
| 249 | + regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB, | |
| 250 | + WidgetType.TABBED_PANE_TAB); | |
| 251 | + regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB_AREA, | |
| 252 | + WidgetType.TABBED_PANE_TAB_AREA); | |
| 253 | + regionToWidgetTypeMap.put(Region.TABLE, WidgetType.TABLE); | |
| 254 | + regionToWidgetTypeMap.put(Region.TABLE_HEADER, WidgetType.TABLE_HEADER); | |
| 255 | + regionToWidgetTypeMap.put(Region.TEXT_AREA, WidgetType.TEXT_AREA); | |
| 256 | + regionToWidgetTypeMap.put(Region.TEXT_FIELD, new WidgetType[] { | |
| 257 | + WidgetType.TEXT_FIELD, WidgetType.COMBO_BOX_TEXT_FIELD}); | |
| 258 | + regionToWidgetTypeMap.put(Region.TEXT_PANE, WidgetType.TEXT_PANE); | |
| 259 | + regionToWidgetTypeMap.put(CustomRegion.TITLED_BORDER, WidgetType.TITLED_BORDER); | |
| 260 | + regionToWidgetTypeMap.put(Region.TOGGLE_BUTTON, WidgetType.TOGGLE_BUTTON); | |
| 261 | + regionToWidgetTypeMap.put(Region.TOOL_BAR, WidgetType.TOOL_BAR); | |
| 262 | + regionToWidgetTypeMap.put(Region.TOOL_BAR_CONTENT, WidgetType.TOOL_BAR); | |
| 263 | + regionToWidgetTypeMap.put(Region.TOOL_BAR_DRAG_WINDOW, | |
| 264 | + WidgetType.TOOL_BAR_DRAG_WINDOW); | |
| 265 | + regionToWidgetTypeMap.put(Region.TOOL_BAR_SEPARATOR, | |
| 266 | + WidgetType.TOOL_BAR_SEPARATOR); | |
| 267 | + regionToWidgetTypeMap.put(Region.TOOL_TIP, WidgetType.TOOL_TIP); | |
| 268 | + regionToWidgetTypeMap.put(Region.TREE, WidgetType.TREE); | |
| 269 | + regionToWidgetTypeMap.put(Region.TREE_CELL, WidgetType.TREE_CELL); | |
| 270 | + regionToWidgetTypeMap.put(Region.VIEWPORT, WidgetType.VIEWPORT); | |
| 271 | + } | |
| 272 | + | |
| 273 | + /** Translate Region and JComponent into WidgetType ordinals */ | |
| 274 | + static WidgetType getWidgetType(JComponent c, Region id) { | |
| 275 | + Object value = regionToWidgetTypeMap.get(id); | |
| 276 | + | |
| 277 | + if (value instanceof WidgetType) { | |
| 278 | + return (WidgetType)value; | |
| 279 | + } | |
| 280 | + | |
| 281 | + WidgetType[] widgets = (WidgetType[])value; | |
| 282 | + if (c == null ) { | |
| 283 | + return widgets[0]; | |
| 284 | + } | |
| 285 | + | |
| 286 | + if (c instanceof JScrollBar) { | |
| 287 | + return (((JScrollBar)c).getOrientation() == JScrollBar.HORIZONTAL) ? | |
| 288 | + widgets[0] : widgets[1]; | |
| 289 | + } else if (c instanceof JSeparator) { | |
| 290 | + JSeparator separator = (JSeparator)c; | |
| 291 | + | |
| 292 | + /* We should return correrct WidgetType if the seperator is inserted | |
| 293 | + * in Menu/PopupMenu/ToolBar. BugID: 6465603 | |
| 294 | + */ | |
| 295 | + if (separator.getParent() instanceof JPopupMenu) { | |
| 296 | + return WidgetType.POPUP_MENU_SEPARATOR; | |
| 297 | + } else if (separator.getParent() instanceof JToolBar) { | |
| 298 | + return WidgetType.TOOL_BAR_SEPARATOR; | |
| 299 | + } | |
| 300 | + | |
| 301 | + return (separator.getOrientation() == JSeparator.HORIZONTAL) ? | |
| 302 | + widgets[0] : widgets[1]; | |
| 303 | + } else if (c instanceof JSlider) { | |
| 304 | + return (((JSlider)c).getOrientation() == JSlider.HORIZONTAL) ? | |
| 305 | + widgets[0] : widgets[1]; | |
| 306 | + } else if (c instanceof JProgressBar) { | |
| 307 | + return (((JProgressBar)c).getOrientation() == JProgressBar.HORIZONTAL) ? | |
| 308 | + widgets[0] : widgets[1]; | |
| 309 | + } else if (c instanceof JSplitPane) { | |
| 310 | + return (((JSplitPane)c).getOrientation() == JSplitPane.HORIZONTAL_SPLIT) ? | |
| 311 | + widgets[1] : widgets[0]; | |
| 312 | + } else if (id == Region.LABEL) { | |
| 313 | + /* | |
| 314 | + * For all ListCellRenderers we will use COMBO_BOX_TEXT_FIELD widget | |
| 315 | + * type because we can get correct insets. List items however won't be | |
| 316 | + * drawn as a text entry (see GTKPainter.paintLabelBackground). | |
| 317 | + */ | |
| 318 | + if (c instanceof ListCellRenderer) { | |
| 319 | + return widgets[1]; | |
| 320 | + } else { | |
| 321 | + return widgets[0]; | |
| 322 | + } | |
| 323 | + } else if (id == Region.TEXT_FIELD) { | |
| 324 | + String name = c.getName(); | |
| 325 | + if (name != null && name.startsWith("ComboBox")) { | |
| 326 | + return widgets[1]; | |
| 327 | + } else { | |
| 328 | + return widgets[0]; | |
| 329 | + } | |
| 330 | + } else if (id == Region.FORMATTED_TEXT_FIELD) { | |
| 331 | + String name = c.getName(); | |
| 332 | + if (name != null && name.startsWith("Spinner")) { | |
| 333 | + return widgets[1]; | |
| 334 | + } else { | |
| 335 | + return widgets[0]; | |
| 336 | + } | |
| 337 | + } else if (id == Region.ARROW_BUTTON) { | |
| 338 | + if (c.getParent() instanceof JScrollBar) { | |
| 339 | + Integer prop = (Integer) | |
| 340 | + c.getClientProperty("__arrow_direction__"); | |
| 341 | + int dir = (prop != null) ? | |
| 342 | + prop.intValue() : SwingConstants.WEST; | |
| 343 | + switch (dir) { | |
| 344 | + case SwingConstants.WEST: | |
| 345 | + return WidgetType.HSCROLL_BAR_BUTTON_LEFT; | |
| 346 | + case SwingConstants.EAST: | |
| 347 | + return WidgetType.HSCROLL_BAR_BUTTON_RIGHT; | |
| 348 | + case SwingConstants.NORTH: | |
| 349 | + return WidgetType.VSCROLL_BAR_BUTTON_UP; | |
| 350 | + case SwingConstants.SOUTH: | |
| 351 | + return WidgetType.VSCROLL_BAR_BUTTON_DOWN; | |
| 352 | + default: | |
| 353 | + return null; | |
| 354 | + } | |
| 355 | + } else if (c.getParent() instanceof JComboBox) { | |
| 356 | + return WidgetType.COMBO_BOX_ARROW_BUTTON; | |
| 357 | + } else { | |
| 358 | + return WidgetType.SPINNER_ARROW_BUTTON; | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + return null; | |
| 363 | + } | |
| 364 | + | |
| 365 | + private static int getTextDirection(SynthContext context) { | |
| 366 | + TextDirection dir = TextDirection.NONE; | |
| 367 | + JComponent comp = context.getComponent(); | |
| 368 | + if (comp != null) { | |
| 369 | + ComponentOrientation co = comp.getComponentOrientation(); | |
| 370 | + if (co != null) { | |
| 371 | + dir = co.isLeftToRight() ? | |
| 372 | + TextDirection.LTR : TextDirection.RTL; | |
| 373 | + } | |
| 374 | + } | |
| 375 | + return dir.ordinal(); | |
| 376 | + } | |
| 377 | + | |
| 378 | + public void paintArrow(Graphics g, SynthContext context, | |
| 379 | + Region id, int state, ShadowType shadowType, ArrowType direction, | |
| 380 | + String detail, int x, int y, int w, int h) { | |
| 381 | + | |
| 382 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 383 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 384 | + native_paint_arrow(widget, state, shadowType.ordinal(), | |
| 385 | + detail, x - x0, y - y0, w, h, direction.ordinal()); | |
| 386 | + } | |
| 387 | + | |
| 388 | + public void paintBox(Graphics g, SynthContext context, | |
| 389 | + Region id, int state, ShadowType shadowType, | |
| 390 | + String detail, int x, int y, int w, int h) { | |
| 391 | + | |
| 392 | + int gtkState = | |
| 393 | + GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 394 | + int synthState = context.getComponentState(); | |
| 395 | + int dir = getTextDirection(context); | |
| 396 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 397 | + native_paint_box(widget, gtkState, shadowType.ordinal(), | |
| 398 | + detail, x - x0, y - y0, w, h, synthState, dir); | |
| 399 | + } | |
| 400 | + | |
| 401 | + public void paintBoxGap(Graphics g, SynthContext context, | |
| 402 | + Region id, int state, ShadowType shadowType, | |
| 403 | + String detail, int x, int y, int w, int h, | |
| 404 | + PositionType boxGapType, int tabBegin, int size) { | |
| 405 | + | |
| 406 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 407 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 408 | + native_paint_box_gap(widget, state, shadowType.ordinal(), detail, | |
| 409 | + x - x0, y - y0, w, h, boxGapType.ordinal(), tabBegin, size); | |
| 410 | + } | |
| 411 | + | |
| 412 | + public void paintCheck(Graphics g, SynthContext context, | |
| 413 | + Region id, String detail, int x, int y, int w, int h) { | |
| 414 | + | |
| 415 | + int synthState = context.getComponentState(); | |
| 416 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 417 | + native_paint_check(widget, synthState, detail, x - x0, y - y0, w, h); | |
| 418 | + } | |
| 419 | + | |
| 420 | + public void paintExpander(Graphics g, SynthContext context, | |
| 421 | + Region id, int state, ExpanderStyle expanderStyle, String detail, | |
| 422 | + int x, int y, int w, int h) { | |
| 423 | + | |
| 424 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 425 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 426 | + native_paint_expander(widget, state, detail, x - x0, y - y0, w, h, | |
| 427 | + expanderStyle.ordinal()); | |
| 428 | + } | |
| 429 | + | |
| 430 | + public void paintExtension(Graphics g, SynthContext context, | |
| 431 | + Region id, int state, ShadowType shadowType, String detail, | |
| 432 | + int x, int y, int w, int h, PositionType placement, int tabIndex) { | |
| 433 | + | |
| 434 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 435 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 436 | + native_paint_extension(widget, state, shadowType.ordinal(), detail, | |
| 437 | + x - x0, y - y0, w, h, placement.ordinal()); | |
| 438 | + } | |
| 439 | + | |
| 440 | + public void paintFlatBox(Graphics g, SynthContext context, | |
| 441 | + Region id, int state, ShadowType shadowType, String detail, | |
| 442 | + int x, int y, int w, int h, ColorType colorType) { | |
| 443 | + | |
| 444 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 445 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 446 | + native_paint_flat_box(widget, state, shadowType.ordinal(), detail, | |
| 447 | + x - x0, y - y0, w, h, | |
| 448 | + context.getComponent().hasFocus()); | |
| 449 | + } | |
| 450 | + | |
| 451 | + public void paintFocus(Graphics g, SynthContext context, | |
| 452 | + Region id, int state, String detail, int x, int y, int w, int h) { | |
| 453 | + | |
| 454 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 455 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 456 | + native_paint_focus(widget, state, detail, x - x0, y - y0, w, h); | |
| 457 | + } | |
| 458 | + | |
| 459 | + public void paintHandle(Graphics g, SynthContext context, | |
| 460 | + Region id, int state, ShadowType shadowType, String detail, | |
| 461 | + int x, int y, int w, int h, Orientation orientation) { | |
| 462 | + | |
| 463 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 464 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 465 | + native_paint_handle(widget, state, shadowType.ordinal(), detail, | |
| 466 | + x - x0, y - y0, w, h, orientation.ordinal()); | |
| 467 | + } | |
| 468 | + | |
| 469 | + public void paintHline(Graphics g, SynthContext context, | |
| 470 | + Region id, int state, String detail, int x, int y, int w, int h) { | |
| 471 | + | |
| 472 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 473 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 474 | + native_paint_hline(widget, state, detail, x - x0, y - y0, w, h); | |
| 475 | + } | |
| 476 | + | |
| 477 | + public void paintOption(Graphics g, SynthContext context, | |
| 478 | + Region id, String detail, int x, int y, int w, int h) { | |
| 479 | + | |
| 480 | + int synthState = context.getComponentState(); | |
| 481 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 482 | + native_paint_option(widget, synthState, detail, x - x0, y - y0, w, h); | |
| 483 | + } | |
| 484 | + | |
| 485 | + public void paintShadow(Graphics g, SynthContext context, | |
| 486 | + Region id, int state, ShadowType shadowType, String detail, | |
| 487 | + int x, int y, int w, int h) { | |
| 488 | + | |
| 489 | + int gtkState = | |
| 490 | + GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 491 | + int synthState = context.getComponentState(); | |
| 492 | + int dir = getTextDirection(context); | |
| 493 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 494 | + native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail, | |
| 495 | + x - x0, y - y0, w, h, synthState, dir); | |
| 496 | + } | |
| 497 | + | |
| 498 | + public void paintSlider(Graphics g, SynthContext context, | |
| 499 | + Region id, int state, ShadowType shadowType, String detail, | |
| 500 | + int x, int y, int w, int h, Orientation orientation) { | |
| 501 | + | |
| 502 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 503 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 504 | + native_paint_slider(widget, state, shadowType.ordinal(), detail, | |
| 505 | + x - x0, y - y0, w, h, orientation.ordinal()); | |
| 506 | + } | |
| 507 | + | |
| 508 | + public void paintVline(Graphics g, SynthContext context, | |
| 509 | + Region id, int state, String detail, int x, int y, int w, int h) { | |
| 510 | + | |
| 511 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 512 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 513 | + native_paint_vline(widget, state, detail, x - x0, y - y0, w, h); | |
| 514 | + } | |
| 515 | + | |
| 516 | + public void paintBackground(Graphics g, SynthContext context, | |
| 517 | + Region id, int state, Color color, int x, int y, int w, int h) { | |
| 518 | + | |
| 519 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 520 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 521 | + native_paint_background(widget, state, x - x0, y - y0, w, h); | |
| 522 | + } | |
| 523 | + | |
| 524 | + private final static ColorModel[] COLOR_MODELS = { | |
| 525 | + // Transparency.OPAQUE | |
| 526 | + new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000), | |
| 527 | + // Transparency.BITMASK | |
| 528 | + new DirectColorModel(25, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000), | |
| 529 | + // Transparency.TRANSLUCENT | |
| 530 | + ColorModel.getRGBdefault(), | |
| 531 | + }; | |
| 532 | + | |
| 533 | + private final static int[][] BAND_OFFSETS = { | |
| 534 | + { 0x00ff0000, 0x0000ff00, 0x000000ff }, // OPAQUE | |
| 535 | + { 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000 }, // BITMASK | |
| 536 | + { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } // TRANSLUCENT | |
| 537 | + }; | |
| 538 | + | |
| 539 | + | |
| 540 | + /** | |
| 541 | + * Paint a cached image identified by its size and a set of additional | |
| 542 | + * arguments, if there's one. | |
| 543 | + * | |
| 544 | + * @return true if a cached image has been painted, false otherwise | |
| 545 | + */ | |
| 546 | + public boolean paintCachedImage(Graphics g, | |
| 547 | + int x, int y, int w, int h, Object... args) { | |
| 548 | + if (w <= 0 || h <= 0) { | |
| 549 | + return true; | |
| 550 | + } | |
| 551 | + | |
| 552 | + // look for cached image | |
| 553 | + Image img = cache.getImage(getClass(), null, w, h, args); | |
| 554 | + if (img != null) { | |
| 555 | + g.drawImage(img, x, y, null); | |
| 556 | + return true; | |
| 557 | + } | |
| 558 | + return false; | |
| 559 | + } | |
| 560 | + | |
| 561 | + /* | |
| 562 | + * Allocate a native offscreen buffer of the specified size. | |
| 563 | + */ | |
| 564 | + public void startPainting(Graphics g, | |
| 565 | + int x, int y, int w, int h, Object... args) { | |
| 566 | + nativeStartPainting(w, h); | |
| 567 | + x0 = x; | |
| 568 | + y0 = y; | |
| 569 | + w0 = w; | |
| 570 | + h0 = h; | |
| 571 | + graphics = g; | |
| 572 | + cacheArgs = args; | |
| 573 | + } | |
| 574 | + | |
| 575 | + /** | |
| 576 | + * Convenience method that delegates to finishPainting() with | |
| 577 | + * caching enabled. | |
| 578 | + */ | |
| 579 | + public void finishPainting() { | |
| 580 | + finishPainting(true); | |
| 581 | + } | |
| 582 | + | |
| 583 | + /** | |
| 584 | + * Called to indicate that painting is finished. We create a new | |
| 585 | + * BufferedImage from the offscreen buffer, (optionally) cache it, | |
| 586 | + * and paint it. | |
| 587 | + */ | |
| 588 | + public void finishPainting(boolean useCache) { | |
| 589 | + DataBufferInt dataBuffer = new DataBufferInt(w0 * h0); | |
| 590 | + // Note that stealData() requires a markDirty() afterwards | |
| 591 | + // since we modify the data in it. | |
| 592 | + int transparency = | |
| 593 | + nativeFinishPainting(SunWritableRaster.stealData(dataBuffer, 0), | |
| 594 | + w0, h0); | |
| 595 | + SunWritableRaster.markDirty(dataBuffer); | |
| 596 | + | |
| 597 | + int[] bands = BAND_OFFSETS[transparency - 1]; | |
| 598 | + WritableRaster raster = Raster.createPackedRaster( | |
| 599 | + dataBuffer, w0, h0, w0, bands, null); | |
| 600 | + | |
| 601 | + ColorModel cm = COLOR_MODELS[transparency - 1]; | |
| 602 | + Image img = new BufferedImage(cm, raster, false, null); | |
| 603 | + if (useCache) { | |
| 604 | + cache.setImage(getClass(), null, w0, h0, cacheArgs, img); | |
| 605 | + } | |
| 606 | + graphics.drawImage(img, x0, y0, null); | |
| 607 | + } | |
| 608 | + | |
| 609 | + /** | |
| 610 | + * Notify native layer of theme change, and flush cache | |
| 611 | + */ | |
| 612 | + public void themeChanged() { | |
| 613 | + synchronized(sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 614 | + native_switch_theme(); | |
| 615 | + } | |
| 616 | + cache.flush(); | |
| 617 | + } | |
| 618 | + | |
| 619 | + /* GtkSettings enum mirrors that in gtk2_interface.h */ | |
| 620 | + public Object getSetting(Settings property) { | |
| 621 | + synchronized(sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 622 | + return native_get_gtk_setting(property.ordinal()); | |
| 623 | + } | |
| 624 | + } | |
| 625 | + | |
| 626 | + /** | |
| 627 | + * Sets up the GtkAdjustment values for the native GtkRange widget | |
| 628 | + * associated with the given region (e.g. SLIDER, SCROLL_BAR). | |
| 629 | + */ | |
| 630 | + void setRangeValue(SynthContext context, Region id, | |
| 631 | + double value, double min, double max, double visible) { | |
| 632 | + int widget = getWidgetType(context.getComponent(), id).ordinal(); | |
| 633 | + nativeSetRangeValue(widget, value, min, max, visible); | |
| 634 | + } | |
| 635 | +} | |
| @@ -0,0 +1,1398 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import java.awt.*; | |
| 28 | +import java.awt.event.*; | |
| 29 | +import java.beans.*; | |
| 30 | +import java.io.File; | |
| 31 | +import java.io.IOException; | |
| 32 | +import java.text.MessageFormat; | |
| 33 | +import java.util.*; | |
| 34 | + | |
| 35 | +import javax.swing.*; | |
| 36 | +import javax.swing.border.*; | |
| 37 | +import javax.swing.filechooser.*; | |
| 38 | +import javax.swing.event.*; | |
| 39 | +import javax.swing.plaf.*; | |
| 40 | +import javax.swing.plaf.basic.BasicDirectoryModel; | |
| 41 | +import javax.swing.table.*; | |
| 42 | +import javax.accessibility.*; | |
| 43 | + | |
| 44 | +import sun.swing.SwingUtilities2; | |
| 45 | + | |
| 46 | +import sun.swing.plaf.synth.*; | |
| 47 | +import sun.swing.FilePane; | |
| 48 | +import sun.awt.shell.ShellFolder; | |
| 49 | + | |
| 50 | +/** | |
| 51 | + * GTK FileChooserUI. | |
| 52 | + * | |
| 53 | + * @author Leif Samuelsson | |
| 54 | + * @author Jeff Dinkins | |
| 55 | + */ | |
| 56 | +class GTKFileChooserUI extends SynthFileChooserUI { | |
| 57 | + | |
| 58 | + // The accessoryPanel is a container to place the JFileChooser accessory component | |
| 59 | + private JPanel accessoryPanel = null; | |
| 60 | + | |
| 61 | + private String newFolderButtonText = null; | |
| 62 | + private String newFolderErrorSeparator = null; | |
| 63 | + private String newFolderErrorText = null; | |
| 64 | + private String newFolderDialogText = null; | |
| 65 | + private String newFolderNoDirectoryErrorTitleText = null; | |
| 66 | + private String newFolderNoDirectoryErrorText = null; | |
| 67 | + | |
| 68 | + private String deleteFileButtonText = null; | |
| 69 | + private String renameFileButtonText = null; | |
| 70 | + | |
| 71 | + private String newFolderButtonToolTipText = null; | |
| 72 | + private String deleteFileButtonToolTipText = null; | |
| 73 | + private String renameFileButtonToolTipText = null; | |
| 74 | + | |
| 75 | + private int newFolderButtonMnemonic = 0; | |
| 76 | + private int deleteFileButtonMnemonic = 0; | |
| 77 | + private int renameFileButtonMnemonic = 0; | |
| 78 | + private int foldersLabelMnemonic = 0; | |
| 79 | + private int filesLabelMnemonic = 0; | |
| 80 | + | |
| 81 | + private String renameFileDialogText = null; | |
| 82 | + private String renameFileErrorTitle = null; | |
| 83 | + private String renameFileErrorText = null; | |
| 84 | + | |
| 85 | + private JComboBox filterComboBox; | |
| 86 | + private FilterComboBoxModel filterComboBoxModel; | |
| 87 | + | |
| 88 | + // From Motif | |
| 89 | + | |
| 90 | + private JPanel rightPanel; | |
| 91 | + private JList directoryList; | |
| 92 | + private JList fileList; | |
| 93 | + | |
| 94 | + private JLabel pathField; | |
| 95 | + private JTextField fileNameTextField; | |
| 96 | + | |
| 97 | + private static final Dimension hstrut3 = new Dimension(3, 1); | |
| 98 | + private static final Dimension vstrut10 = new Dimension(1, 10); | |
| 99 | + | |
| 100 | + private static Dimension prefListSize = new Dimension(75, 150); | |
| 101 | + | |
| 102 | + private static Dimension PREF_SIZE = new Dimension(435, 360); | |
| 103 | + private static Dimension MIN_SIZE = new Dimension(200, 300); | |
| 104 | + | |
| 105 | + private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1); | |
| 106 | + | |
| 107 | + private static Dimension MAX_SIZE = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); | |
| 108 | + | |
| 109 | + private static final Insets buttonMargin = new Insets(3, 3, 3, 3); | |
| 110 | + | |
| 111 | + private String filesLabelText = null; | |
| 112 | + private String foldersLabelText = null; | |
| 113 | + private String pathLabelText = null; | |
| 114 | + private String filterLabelText = null; | |
| 115 | + | |
| 116 | + private int pathLabelMnemonic = 0; | |
| 117 | + private int filterLabelMnemonic = 0; | |
| 118 | + | |
| 119 | + private JComboBox directoryComboBox; | |
| 120 | + private DirectoryComboBoxModel directoryComboBoxModel; | |
| 121 | + private Action directoryComboBoxAction = new DirectoryComboBoxAction(); | |
| 122 | + private JPanel bottomButtonPanel; | |
| 123 | + private GTKDirectoryModel model = null; | |
| 124 | + private Action newFolderAction; | |
| 125 | + private boolean readOnly; | |
| 126 | + private boolean showDirectoryIcons; | |
| 127 | + private boolean showFileIcons; | |
| 128 | + private GTKFileView fileView = new GTKFileView(); | |
| 129 | + private PropertyChangeListener gtkFCPropertyChangeListener; | |
| 130 | + private Action approveSelectionAction = new GTKApproveSelectionAction(); | |
| 131 | + private GTKDirectoryListModel directoryListModel; | |
| 132 | + | |
| 133 | + public GTKFileChooserUI(JFileChooser filechooser) { | |
| 134 | + super(filechooser); | |
| 135 | + } | |
| 136 | + | |
| 137 | + protected ActionMap createActionMap() { | |
| 138 | + ActionMap map = new ActionMapUIResource(); | |
| 139 | + map.put("approveSelection", getApproveSelectionAction()); | |
| 140 | + map.put("cancelSelection", getCancelSelectionAction()); | |
| 141 | + map.put("Go Up", getChangeToParentDirectoryAction()); | |
| 142 | + map.put("fileNameCompletion", getFileNameCompletionAction()); | |
| 143 | + return map; | |
| 144 | + } | |
| 145 | + | |
| 146 | + public String getFileName() { | |
| 147 | + JFileChooser fc = getFileChooser(); | |
| 148 | + String typedInName = fileNameTextField != null ? | |
| 149 | + fileNameTextField.getText() : null; | |
| 150 | + | |
| 151 | + if (!fc.isMultiSelectionEnabled()) { | |
| 152 | + return typedInName; | |
| 153 | + } | |
| 154 | + | |
| 155 | + int mode = fc.getFileSelectionMode(); | |
| 156 | + JList list = mode == JFileChooser.DIRECTORIES_ONLY ? | |
| 157 | + directoryList : fileList; | |
| 158 | + Object[] files = list.getSelectedValues(); | |
| 159 | + int len = files.length; | |
| 160 | + Vector<String> result = new Vector<String>(len + 1); | |
| 161 | + | |
| 162 | + // we return all selected file names | |
| 163 | + for (int i = 0; i < len; i++) { | |
| 164 | + File file = (File)files[i]; | |
| 165 | + result.add(file.getName()); | |
| 166 | + } | |
| 167 | + // plus the file name typed into the text field, if not already there | |
| 168 | + if (typedInName != null && !result.contains(typedInName)) { | |
| 169 | + result.add(typedInName); | |
| 170 | + } | |
| 171 | + | |
| 172 | + StringBuffer buf = new StringBuffer(); | |
| 173 | + len = result.size(); | |
| 174 | + | |
| 175 | + // construct the resulting string | |
| 176 | + for (int i=0; i<len; i++) { | |
| 177 | + if (i > 0) { | |
| 178 | + buf.append(" "); | |
| 179 | + } | |
| 180 | + if (len > 1) { | |
| 181 | + buf.append("\""); | |
| 182 | + } | |
| 183 | + buf.append(result.get(i)); | |
| 184 | + if (len > 1) { | |
| 185 | + buf.append("\""); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + return buf.toString(); | |
| 189 | + } | |
| 190 | + | |
| 191 | + public void setFileName(String fileName) { | |
| 192 | + if (fileNameTextField != null) { | |
| 193 | + fileNameTextField.setText(fileName); | |
| 194 | + } | |
| 195 | + } | |
| 196 | + | |
| 197 | +// public String getDirectoryName() { | |
| 198 | +// return pathField.getText(); | |
| 199 | +// } | |
| 200 | + | |
| 201 | + public void setDirectoryName(String dirname) { | |
| 202 | + pathField.setText(dirname); | |
| 203 | + } | |
| 204 | + | |
| 205 | + public void ensureFileIsVisible(JFileChooser fc, File f) { | |
| 206 | + // PENDING | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void rescanCurrentDirectory(JFileChooser fc) { | |
| 210 | + getModel().validateFileCache(); | |
| 211 | + } | |
| 212 | + | |
| 213 | + public JPanel getAccessoryPanel() { | |
| 214 | + return accessoryPanel; | |
| 215 | + } | |
| 216 | + | |
| 217 | + // *********************** | |
| 218 | + // * FileView operations * | |
| 219 | + // *********************** | |
| 220 | + | |
| 221 | + public FileView getFileView(JFileChooser fc) { | |
| 222 | + return fileView; | |
| 223 | + } | |
| 224 | + | |
| 225 | + private class GTKFileView extends BasicFileView { | |
| 226 | + public GTKFileView() { | |
| 227 | + iconCache = null; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void clearIconCache() { | |
| 231 | + } | |
| 232 | + | |
| 233 | + public Icon getCachedIcon(File f) { | |
| 234 | + return null; | |
| 235 | + } | |
| 236 | + | |
| 237 | + public void cacheIcon(File f, Icon i) { | |
| 238 | + } | |
| 239 | + | |
| 240 | + public Icon getIcon(File f) { | |
| 241 | + return (f != null && f.isDirectory()) ? directoryIcon : fileIcon; | |
| 242 | + } | |
| 243 | + } | |
| 244 | + | |
| 245 | + | |
| 246 | + private void updateDefaultButton() { | |
| 247 | + JFileChooser filechooser = getFileChooser(); | |
| 248 | + JRootPane root = SwingUtilities.getRootPane(filechooser); | |
| 249 | + if (root == null) { | |
| 250 | + return; | |
| 251 | + } | |
| 252 | + | |
| 253 | + if (filechooser.getControlButtonsAreShown()) { | |
| 254 | + if (root.getDefaultButton() == null) { | |
| 255 | + root.setDefaultButton(getApproveButton(filechooser)); | |
| 256 | + getCancelButton(filechooser).setDefaultCapable(false); | |
| 257 | + } | |
| 258 | + } else { | |
| 259 | + if (root.getDefaultButton() == getApproveButton(filechooser)) { | |
| 260 | + root.setDefaultButton(null); | |
| 261 | + } | |
| 262 | + } | |
| 263 | + } | |
| 264 | + | |
| 265 | + protected void doSelectedFileChanged(PropertyChangeEvent e) { | |
| 266 | + super.doSelectedFileChanged(e); | |
| 267 | + File f = (File) e.getNewValue(); | |
| 268 | + if (f != null) { | |
| 269 | + setFileName(getFileChooser().getName(f)); | |
| 270 | + } | |
| 271 | + } | |
| 272 | + | |
| 273 | + protected void doDirectoryChanged(PropertyChangeEvent e) { | |
| 274 | + directoryList.clearSelection(); | |
| 275 | + ListSelectionModel sm = directoryList.getSelectionModel(); | |
| 276 | + if (sm instanceof DefaultListSelectionModel) { | |
| 277 | + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); | |
| 278 | + sm.setAnchorSelectionIndex(0); | |
| 279 | + } | |
| 280 | + fileList.clearSelection(); | |
| 281 | + sm = fileList.getSelectionModel(); | |
| 282 | + if (sm instanceof DefaultListSelectionModel) { | |
| 283 | + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); | |
| 284 | + sm.setAnchorSelectionIndex(0); | |
| 285 | + } | |
| 286 | + | |
| 287 | + File currentDirectory = getFileChooser().getCurrentDirectory(); | |
| 288 | + if (currentDirectory != null) { | |
| 289 | + try { | |
| 290 | + setDirectoryName(ShellFolder.getNormalizedFile((File)e.getNewValue()).getPath()); | |
| 291 | + } catch (IOException ioe) { | |
| 292 | + setDirectoryName(((File)e.getNewValue()).getAbsolutePath()); | |
| 293 | + } | |
| 294 | + if ((getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) && !getFileChooser().isMultiSelectionEnabled()) { | |
| 295 | + setFileName(pathField.getText()); | |
| 296 | + } | |
| 297 | + directoryComboBoxModel.addItem(currentDirectory); | |
| 298 | + directoryListModel.directoryChanged(); | |
| 299 | + } | |
| 300 | + super.doDirectoryChanged(e); | |
| 301 | + } | |
| 302 | + | |
| 303 | + protected void doAccessoryChanged(PropertyChangeEvent e) { | |
| 304 | + if (getAccessoryPanel() != null) { | |
| 305 | + if (e.getOldValue() != null) { | |
| 306 | + getAccessoryPanel().remove((JComponent)e.getOldValue()); | |
| 307 | + } | |
| 308 | + JComponent accessory = (JComponent)e.getNewValue(); | |
| 309 | + if (accessory != null) { | |
| 310 | + getAccessoryPanel().add(accessory, BorderLayout.CENTER); | |
| 311 | + getAccessoryPanel().setPreferredSize(accessory.getPreferredSize()); | |
| 312 | + getAccessoryPanel().setMaximumSize(MAX_SIZE); | |
| 313 | + } else { | |
| 314 | + getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE); | |
| 315 | + getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + } | |
| 319 | + | |
| 320 | + protected void doFileSelectionModeChanged(PropertyChangeEvent e) { | |
| 321 | + directoryList.clearSelection(); | |
| 322 | + rightPanel.setVisible(((Integer)e.getNewValue()).intValue() != JFileChooser.DIRECTORIES_ONLY); | |
| 323 | + | |
| 324 | + super.doFileSelectionModeChanged(e); | |
| 325 | + } | |
| 326 | + | |
| 327 | + protected void doMultiSelectionChanged(PropertyChangeEvent e) { | |
| 328 | + if (getFileChooser().isMultiSelectionEnabled()) { | |
| 329 | + fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
| 330 | + } else { | |
| 331 | + fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
| 332 | + fileList.clearSelection(); | |
| 333 | + } | |
| 334 | + | |
| 335 | + super.doMultiSelectionChanged(e); | |
| 336 | + } | |
| 337 | + | |
| 338 | + protected void doControlButtonsChanged(PropertyChangeEvent e) { | |
| 339 | + super.doControlButtonsChanged(e); | |
| 340 | + | |
| 341 | + JFileChooser filechooser = getFileChooser(); | |
| 342 | + if (filechooser.getControlButtonsAreShown()) { | |
| 343 | + filechooser.add(bottomButtonPanel, BorderLayout.SOUTH); | |
| 344 | + } else { | |
| 345 | + filechooser.remove(bottomButtonPanel); | |
| 346 | + } | |
| 347 | + updateDefaultButton(); | |
| 348 | + } | |
| 349 | + | |
| 350 | + protected void doAncestorChanged(PropertyChangeEvent e) { | |
| 351 | + if (e.getOldValue() == null && e.getNewValue() != null) { | |
| 352 | + // Ancestor was added, set initial focus | |
| 353 | + fileNameTextField.selectAll(); | |
| 354 | + fileNameTextField.requestFocus(); | |
| 355 | + updateDefaultButton(); | |
| 356 | + } | |
| 357 | + | |
| 358 | + super.doAncestorChanged(e); | |
| 359 | + } | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + // ******************************************** | |
| 364 | + // ************ Create Listeners ************** | |
| 365 | + // ******************************************** | |
| 366 | + | |
| 367 | + public ListSelectionListener createListSelectionListener(JFileChooser fc) { | |
| 368 | + return new SelectionListener(); | |
| 369 | + } | |
| 370 | + | |
| 371 | + class DoubleClickListener extends MouseAdapter { | |
| 372 | + JList list; | |
| 373 | + public DoubleClickListener(JList list) { | |
| 374 | + this.list = list; | |
| 375 | + } | |
| 376 | + | |
| 377 | + public void mouseClicked(MouseEvent e) { | |
| 378 | + if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { | |
| 379 | + int index = list.locationToIndex(e.getPoint()); | |
| 380 | + if (index >= 0) { | |
| 381 | + File f = (File) list.getModel().getElementAt(index); | |
| 382 | + try { | |
| 383 | + // Strip trailing ".." | |
| 384 | + f = ShellFolder.getNormalizedFile(f); | |
| 385 | + } catch (IOException ex) { | |
| 386 | + // That's ok, we'll use f as is | |
| 387 | + } | |
| 388 | + if (getFileChooser().isTraversable(f)) { | |
| 389 | + list.clearSelection(); | |
| 390 | + if (getFileChooser().getCurrentDirectory().equals(f)){ | |
| 391 | + rescanCurrentDirectory(getFileChooser()); | |
| 392 | + } else { | |
| 393 | + getFileChooser().setCurrentDirectory(f); | |
| 394 | + } | |
| 395 | + } else { | |
| 396 | + getFileChooser().approveSelection(); | |
| 397 | + } | |
| 398 | + } | |
| 399 | + } | |
| 400 | + } | |
| 401 | + | |
| 402 | + public void mouseEntered(MouseEvent evt) { | |
| 403 | + if (list != null) { | |
| 404 | + TransferHandler th1 = getFileChooser().getTransferHandler(); | |
| 405 | + TransferHandler th2 = list.getTransferHandler(); | |
| 406 | + if (th1 != th2) { | |
| 407 | + list.setTransferHandler(th1); | |
| 408 | + } | |
| 409 | + if (getFileChooser().getDragEnabled() != list.getDragEnabled()) { | |
| 410 | + list.setDragEnabled(getFileChooser().getDragEnabled()); | |
| 411 | + } | |
| 412 | + } | |
| 413 | + } | |
| 414 | + } | |
| 415 | + | |
| 416 | + protected MouseListener createDoubleClickListener(JFileChooser fc, JList list) { | |
| 417 | + return new DoubleClickListener(list); | |
| 418 | + } | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + protected class SelectionListener implements ListSelectionListener { | |
| 423 | + public void valueChanged(ListSelectionEvent e) { | |
| 424 | + if (!e.getValueIsAdjusting()) { | |
| 425 | + JFileChooser chooser = getFileChooser(); | |
| 426 | + JList list = (JList) e.getSource(); | |
| 427 | + | |
| 428 | + if (chooser.isMultiSelectionEnabled()) { | |
| 429 | + File[] files = null; | |
| 430 | + Object[] objects = list.getSelectedValues(); | |
| 431 | + if (objects != null) { | |
| 432 | + if (objects.length == 1 | |
| 433 | + && ((File)objects[0]).isDirectory() | |
| 434 | + && chooser.isTraversable(((File)objects[0])) | |
| 435 | + && (chooser.getFileSelectionMode() != chooser.DIRECTORIES_ONLY | |
| 436 | + || !chooser.getFileSystemView().isFileSystem(((File)objects[0])))) { | |
| 437 | + setDirectorySelected(true); | |
| 438 | + setDirectory(((File)objects[0])); | |
| 439 | + } else { | |
| 440 | + ArrayList<File> fList = new ArrayList<File>(objects.length); | |
| 441 | + for (Object object : objects) { | |
| 442 | + File f = (File) object; | |
| 443 | + if ((chooser.isFileSelectionEnabled() && f.isFile()) | |
| 444 | + || (chooser.isDirectorySelectionEnabled() && f.isDirectory())) { | |
| 445 | + fList.add(f); | |
| 446 | + } | |
| 447 | + } | |
| 448 | + if (fList.size() > 0) { | |
| 449 | + files = fList.toArray(new File[fList.size()]); | |
| 450 | + } | |
| 451 | + setDirectorySelected(false); | |
| 452 | + } | |
| 453 | + } | |
| 454 | + chooser.setSelectedFiles(files); | |
| 455 | + } else { | |
| 456 | + File file = (File)list.getSelectedValue(); | |
| 457 | + if (file != null | |
| 458 | + && file.isDirectory() | |
| 459 | + && chooser.isTraversable(file) | |
| 460 | + && (chooser.getFileSelectionMode() == chooser.FILES_ONLY | |
| 461 | + || !chooser.getFileSystemView().isFileSystem(file))) { | |
| 462 | + | |
| 463 | + setDirectorySelected(true); | |
| 464 | + setDirectory(file); | |
| 465 | + } else { | |
| 466 | + setDirectorySelected(false); | |
| 467 | + if (file != null) { | |
| 468 | + chooser.setSelectedFile(file); | |
| 469 | + } | |
| 470 | + } | |
| 471 | + } | |
| 472 | + } | |
| 473 | + } | |
| 474 | + } | |
| 475 | + | |
| 476 | + | |
| 477 | + // | |
| 478 | + // ComponentUI Interface Implementation methods | |
| 479 | + // | |
| 480 | + public static ComponentUI createUI(JComponent c) { | |
| 481 | + return new GTKFileChooserUI((JFileChooser)c); | |
| 482 | + } | |
| 483 | + | |
| 484 | + public void installUI(JComponent c) { | |
| 485 | + accessoryPanel = new JPanel(new BorderLayout(10, 10)); | |
| 486 | + accessoryPanel.setName("GTKFileChooser.accessoryPanel"); | |
| 487 | + | |
| 488 | + super.installUI(c); | |
| 489 | + } | |
| 490 | + | |
| 491 | + public void uninstallUI(JComponent c) { | |
| 492 | + c.removePropertyChangeListener(filterComboBoxModel); | |
| 493 | + super.uninstallUI(c); | |
| 494 | + | |
| 495 | + if (accessoryPanel != null) { | |
| 496 | + accessoryPanel.removeAll(); | |
| 497 | + } | |
| 498 | + accessoryPanel = null; | |
| 499 | + getFileChooser().removeAll(); | |
| 500 | + } | |
| 501 | + | |
| 502 | + public void installComponents(JFileChooser fc) { | |
| 503 | + super.installComponents(fc); | |
| 504 | + | |
| 505 | + boolean leftToRight = fc.getComponentOrientation().isLeftToRight(); | |
| 506 | + | |
| 507 | + fc.setLayout(new BorderLayout()); | |
| 508 | + fc.setAlignmentX(JComponent.CENTER_ALIGNMENT); | |
| 509 | + | |
| 510 | + // Top row of buttons | |
| 511 | + JPanel topButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); | |
| 512 | + topButtonPanel.setBorder(new EmptyBorder(10, 10, 0, 10)); | |
| 513 | + topButtonPanel.setName("GTKFileChooser.topButtonPanel"); | |
| 514 | + | |
| 515 | + if (!UIManager.getBoolean("FileChooser.readOnly")) { | |
| 516 | + JButton newFolderButton = new JButton(getNewFolderAction()); | |
| 517 | + newFolderButton.setName("GTKFileChooser.newFolderButton"); | |
| 518 | + newFolderButton.setMnemonic(newFolderButtonMnemonic); | |
| 519 | + newFolderButton.setToolTipText(newFolderButtonToolTipText); | |
| 520 | + newFolderButton.setText(newFolderButtonText); | |
| 521 | + topButtonPanel.add(newFolderButton); | |
| 522 | + } | |
| 523 | + JButton deleteFileButton = new JButton(deleteFileButtonText); | |
| 524 | + deleteFileButton.setName("GTKFileChooser.deleteFileButton"); | |
| 525 | + deleteFileButton.setMnemonic(deleteFileButtonMnemonic); | |
| 526 | + deleteFileButton.setToolTipText(deleteFileButtonToolTipText); | |
| 527 | + deleteFileButton.setEnabled(false); | |
| 528 | + topButtonPanel.add(deleteFileButton); | |
| 529 | + | |
| 530 | + RenameFileAction rfa = new RenameFileAction(); | |
| 531 | + JButton renameFileButton = new JButton(rfa); | |
| 532 | + if (readOnly) { | |
| 533 | + rfa.setEnabled(false); | |
| 534 | + } | |
| 535 | + renameFileButton.setText(renameFileButtonText); | |
| 536 | + renameFileButton.setName("GTKFileChooser.renameFileButton"); | |
| 537 | + renameFileButton.setMnemonic(renameFileButtonMnemonic); | |
| 538 | + renameFileButton.setToolTipText(renameFileButtonToolTipText); | |
| 539 | + topButtonPanel.add(renameFileButton); | |
| 540 | + | |
| 541 | + fc.add(topButtonPanel, BorderLayout.NORTH); | |
| 542 | + | |
| 543 | + | |
| 544 | + JPanel interior = new JPanel(); | |
| 545 | + interior.setBorder(new EmptyBorder(0, 10, 10, 10)); | |
| 546 | + interior.setName("GTKFileChooser.interiorPanel"); | |
| 547 | + align(interior); | |
| 548 | + interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS)); | |
| 549 | + | |
| 550 | + fc.add(interior, BorderLayout.CENTER); | |
| 551 | + | |
| 552 | + JPanel comboBoxPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, | |
| 553 | + 0, 0) { | |
| 554 | + public void layoutContainer(Container target) { | |
| 555 | + super.layoutContainer(target); | |
| 556 | + JComboBox comboBox = directoryComboBox; | |
| 557 | + if (comboBox.getWidth() > target.getWidth()) { | |
| 558 | + comboBox.setBounds(0, comboBox.getY(), target.getWidth(), | |
| 559 | + comboBox.getHeight()); | |
| 560 | + } | |
| 561 | + } | |
| 562 | + }); | |
| 563 | + comboBoxPanel.setBorder(new EmptyBorder(0, 0, 4, 0)); | |
| 564 | + comboBoxPanel.setName("GTKFileChooser.directoryComboBoxPanel"); | |
| 565 | + // CurrentDir ComboBox | |
| 566 | + directoryComboBoxModel = createDirectoryComboBoxModel(fc); | |
| 567 | + directoryComboBox = new JComboBox(directoryComboBoxModel); | |
| 568 | + directoryComboBox.setName("GTKFileChooser.directoryComboBox"); | |
| 569 | + directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" ); | |
| 570 | + directoryComboBox.addActionListener(directoryComboBoxAction); | |
| 571 | + directoryComboBox.setMaximumRowCount(8); | |
| 572 | + comboBoxPanel.add(directoryComboBox); | |
| 573 | + interior.add(comboBoxPanel); | |
| 574 | + | |
| 575 | + | |
| 576 | + // CENTER: left, right, accessory | |
| 577 | + JPanel centerPanel = new JPanel(new BorderLayout()); | |
| 578 | + centerPanel.setName("GTKFileChooser.centerPanel"); | |
| 579 | + | |
| 580 | + // SPLIT PANEL: left, right | |
| 581 | + JSplitPane splitPanel = new JSplitPane(); | |
| 582 | + splitPanel.setName("GTKFileChooser.splitPanel"); | |
| 583 | + splitPanel.setDividerLocation((PREF_SIZE.width-8)/2); | |
| 584 | + | |
| 585 | + // left panel - Filter & directoryList | |
| 586 | + JPanel leftPanel = new JPanel(new GridBagLayout()); | |
| 587 | + leftPanel.setName("GTKFileChooser.directoryListPanel"); | |
| 588 | + | |
| 589 | + // Add the Directory List | |
| 590 | + // Create a label that looks like button (should be a table header) | |
| 591 | + TableCellRenderer headerRenderer = new JTableHeader().getDefaultRenderer(); | |
| 592 | + JLabel directoryListLabel = | |
| 593 | + (JLabel)headerRenderer.getTableCellRendererComponent(null, foldersLabelText, | |
| 594 | + false, false, 0, 0); | |
| 595 | + directoryListLabel.setName("GTKFileChooser.directoryListLabel"); | |
| 596 | + leftPanel.add(directoryListLabel, new GridBagConstraints( | |
| 597 | + 0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, | |
| 598 | + GridBagConstraints.HORIZONTAL, | |
| 599 | + new Insets(0, 0, 0, 0), 0, 0)); | |
| 600 | + leftPanel.add(createDirectoryList(), new GridBagConstraints( | |
| 601 | + 0, 1, 1, 1, 1, 1, GridBagConstraints.EAST, | |
| 602 | + GridBagConstraints.BOTH, | |
| 603 | + new Insets(0, 0, 0, 0), 0, 0)); | |
| 604 | + directoryListLabel.setDisplayedMnemonic(foldersLabelMnemonic); | |
| 605 | + directoryListLabel.setLabelFor(directoryList); | |
| 606 | + | |
| 607 | + // create files list | |
| 608 | + rightPanel = new JPanel(new GridBagLayout()); | |
| 609 | + rightPanel.setName("GTKFileChooser.fileListPanel"); | |
| 610 | + | |
| 611 | + headerRenderer = new JTableHeader().getDefaultRenderer(); | |
| 612 | + JLabel fileListLabel = | |
| 613 | + (JLabel)headerRenderer.getTableCellRendererComponent(null, filesLabelText, | |
| 614 | + false, false, 0, 0); | |
| 615 | + fileListLabel.setName("GTKFileChooser.fileListLabel"); | |
| 616 | + rightPanel.add(fileListLabel, new GridBagConstraints( | |
| 617 | + 0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, | |
| 618 | + GridBagConstraints.HORIZONTAL, | |
| 619 | + new Insets(0, 0, 0, 0), 0, 0)); | |
| 620 | + rightPanel.add(createFilesList(), new GridBagConstraints( | |
| 621 | + 0, 1, 1, 1, 1, 1, GridBagConstraints.EAST, | |
| 622 | + GridBagConstraints.BOTH, | |
| 623 | + new Insets(0, 0, 0, 0), 0, 0)); | |
| 624 | + fileListLabel.setDisplayedMnemonic(filesLabelMnemonic); | |
| 625 | + fileListLabel.setLabelFor(fileList); | |
| 626 | + | |
| 627 | + splitPanel.add(leftPanel, leftToRight ? JSplitPane.LEFT : JSplitPane.RIGHT); | |
| 628 | + splitPanel.add(rightPanel, leftToRight ? JSplitPane.RIGHT : JSplitPane.LEFT); | |
| 629 | + centerPanel.add(splitPanel, BorderLayout.CENTER); | |
| 630 | + | |
| 631 | + JComponent accessoryPanel = getAccessoryPanel(); | |
| 632 | + JComponent accessory = fc.getAccessory(); | |
| 633 | + if (accessoryPanel != null) { | |
| 634 | + if (accessory == null) { | |
| 635 | + accessoryPanel.setPreferredSize(ZERO_ACC_SIZE); | |
| 636 | + accessoryPanel.setMaximumSize(ZERO_ACC_SIZE); | |
| 637 | + } else { | |
| 638 | + getAccessoryPanel().add(accessory, BorderLayout.CENTER); | |
| 639 | + accessoryPanel.setPreferredSize(accessory.getPreferredSize()); | |
| 640 | + accessoryPanel.setMaximumSize(MAX_SIZE); | |
| 641 | + } | |
| 642 | + align(accessoryPanel); | |
| 643 | + centerPanel.add(accessoryPanel, BorderLayout.AFTER_LINE_ENDS); | |
| 644 | + } | |
| 645 | + interior.add(centerPanel); | |
| 646 | + interior.add(Box.createRigidArea(vstrut10)); | |
| 647 | + | |
| 648 | + JPanel pathFieldPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, | |
| 649 | + 0, 0)); | |
| 650 | + pathFieldPanel.setBorder(new EmptyBorder(0, 0, 4, 0)); | |
| 651 | + JLabel pathFieldLabel = new JLabel(pathLabelText); | |
| 652 | + pathFieldLabel.setName("GTKFileChooser.pathFieldLabel"); | |
| 653 | + pathFieldLabel.setDisplayedMnemonic(pathLabelMnemonic); | |
| 654 | + align(pathFieldLabel); | |
| 655 | + pathFieldPanel.add(pathFieldLabel); | |
| 656 | + pathFieldPanel.add(Box.createRigidArea(hstrut3)); | |
| 657 | + | |
| 658 | + File currentDirectory = fc.getCurrentDirectory(); | |
| 659 | + String curDirName = null; | |
| 660 | + if (currentDirectory != null) { | |
| 661 | + curDirName = currentDirectory.getPath(); | |
| 662 | + } | |
| 663 | + pathField = new JLabel(curDirName) { | |
| 664 | + public Dimension getMaximumSize() { | |
| 665 | + Dimension d = super.getMaximumSize(); | |
| 666 | + d.height = getPreferredSize().height; | |
| 667 | + return d; | |
| 668 | + } | |
| 669 | + }; | |
| 670 | + pathField.setName("GTKFileChooser.pathField"); | |
| 671 | + align(pathField); | |
| 672 | + pathFieldPanel.add(pathField); | |
| 673 | + interior.add(pathFieldPanel); | |
| 674 | + | |
| 675 | + // add the fileName field | |
| 676 | + fileNameTextField = new JTextField() { | |
| 677 | + public Dimension getMaximumSize() { | |
| 678 | + Dimension d = super.getMaximumSize(); | |
| 679 | + d.height = getPreferredSize().height; | |
| 680 | + return d; | |
| 681 | + } | |
| 682 | + }; | |
| 683 | + | |
| 684 | + pathFieldLabel.setLabelFor(fileNameTextField); | |
| 685 | + | |
| 686 | + Set<AWTKeyStroke> forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys( | |
| 687 | + KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); | |
| 688 | + forwardTraversalKeys = new HashSet<AWTKeyStroke>(forwardTraversalKeys); | |
| 689 | + forwardTraversalKeys.remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)); | |
| 690 | + fileNameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys); | |
| 691 | + | |
| 692 | + fileNameTextField.setName("GTKFileChooser.fileNameTextField"); | |
| 693 | + fileNameTextField.getActionMap().put("fileNameCompletionAction", getFileNameCompletionAction()); | |
| 694 | + fileNameTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "fileNameCompletionAction"); | |
| 695 | + interior.add(fileNameTextField); | |
| 696 | + | |
| 697 | + // Add the filter combo box | |
| 698 | + JPanel panel = new JPanel(); | |
| 699 | + panel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); | |
| 700 | + panel.setBorder(new EmptyBorder(0, 0, 4, 0)); | |
| 701 | + JLabel filterLabel = new JLabel(filterLabelText); | |
| 702 | + filterLabel.setName("GTKFileChooser.filterLabel"); | |
| 703 | + filterLabel.setDisplayedMnemonic(filterLabelMnemonic); | |
| 704 | + panel.add(filterLabel); | |
| 705 | + | |
| 706 | + filterComboBoxModel = createFilterComboBoxModel(); | |
| 707 | + fc.addPropertyChangeListener(filterComboBoxModel); | |
| 708 | + filterComboBox = new JComboBox(filterComboBoxModel); | |
| 709 | + filterComboBox.setRenderer(createFilterComboBoxRenderer()); | |
| 710 | + filterLabel.setLabelFor(filterComboBox); | |
| 711 | + | |
| 712 | + interior.add(Box.createRigidArea(vstrut10)); | |
| 713 | + interior.add(panel); | |
| 714 | + interior.add(filterComboBox); | |
| 715 | + | |
| 716 | + // Add buttons | |
| 717 | + bottomButtonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); | |
| 718 | + bottomButtonPanel.setName("GTKFileChooser.bottomButtonPanel"); | |
| 719 | + align(bottomButtonPanel); | |
| 720 | + | |
| 721 | + JPanel pnButtons = new JPanel(new GridLayout(1, 2, 5, 0)); | |
| 722 | + | |
| 723 | + JButton cancelButton = getCancelButton(fc); | |
| 724 | + align(cancelButton); | |
| 725 | + cancelButton.setMargin(buttonMargin); | |
| 726 | + pnButtons.add(cancelButton); | |
| 727 | + | |
| 728 | + JButton approveButton = getApproveButton(fc); | |
| 729 | + align(approveButton); | |
| 730 | + approveButton.setMargin(buttonMargin); | |
| 731 | + pnButtons.add(approveButton); | |
| 732 | + | |
| 733 | + bottomButtonPanel.add(pnButtons); | |
| 734 | + | |
| 735 | + if (fc.getControlButtonsAreShown()) { | |
| 736 | + fc.add(bottomButtonPanel, BorderLayout.SOUTH); | |
| 737 | + } | |
| 738 | + } | |
| 739 | + | |
| 740 | + protected void installListeners(JFileChooser fc) { | |
| 741 | + super.installListeners(fc); | |
| 742 | + | |
| 743 | + gtkFCPropertyChangeListener = new GTKFCPropertyChangeListener(); | |
| 744 | + fc.addPropertyChangeListener(gtkFCPropertyChangeListener); | |
| 745 | + } | |
| 746 | + | |
| 747 | + private int getMnemonic(String key, Locale l) { | |
| 748 | + return SwingUtilities2.getUIDefaultsInt(key, l); | |
| 749 | + } | |
| 750 | + | |
| 751 | + protected void uninstallListeners(JFileChooser fc) { | |
| 752 | + super.uninstallListeners(fc); | |
| 753 | + | |
| 754 | + if (gtkFCPropertyChangeListener != null) { | |
| 755 | + fc.removePropertyChangeListener(gtkFCPropertyChangeListener); | |
| 756 | + } | |
| 757 | + } | |
| 758 | + | |
| 759 | + private class GTKFCPropertyChangeListener implements PropertyChangeListener { | |
| 760 | + public void propertyChange(PropertyChangeEvent e) { | |
| 761 | + String prop = e.getPropertyName(); | |
| 762 | + if (prop.equals("GTKFileChooser.showDirectoryIcons")) { | |
| 763 | + showDirectoryIcons = Boolean.TRUE.equals(e.getNewValue()); | |
| 764 | + } else if (prop.equals("GTKFileChooser.showFileIcons")) { | |
| 765 | + showFileIcons = Boolean.TRUE.equals(e.getNewValue()); | |
| 766 | + } | |
| 767 | + } | |
| 768 | + } | |
| 769 | + | |
| 770 | + protected void installDefaults(JFileChooser fc) { | |
| 771 | + super.installDefaults(fc); | |
| 772 | + readOnly = UIManager.getBoolean("FileChooser.readOnly"); | |
| 773 | + showDirectoryIcons = | |
| 774 | + Boolean.TRUE.equals(fc.getClientProperty("GTKFileChooser.showDirectoryIcons")); | |
| 775 | + showFileIcons = | |
| 776 | + Boolean.TRUE.equals(fc.getClientProperty("GTKFileChooser.showFileIcons")); | |
| 777 | + } | |
| 778 | + | |
| 779 | + protected void installIcons(JFileChooser fc) { | |
| 780 | + directoryIcon = UIManager.getIcon("FileView.directoryIcon"); | |
| 781 | + fileIcon = UIManager.getIcon("FileView.fileIcon"); | |
| 782 | + } | |
| 783 | + | |
| 784 | + protected void installStrings(JFileChooser fc) { | |
| 785 | + super.installStrings(fc); | |
| 786 | + | |
| 787 | + Locale l = fc.getLocale(); | |
| 788 | + | |
| 789 | + newFolderDialogText = UIManager.getString("FileChooser.newFolderDialogText", l); | |
| 790 | + newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText",l); | |
| 791 | + newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator",l); | |
| 792 | + newFolderButtonText = UIManager.getString("FileChooser.newFolderButtonText", l); | |
| 793 | + newFolderNoDirectoryErrorTitleText = UIManager.getString("FileChooser.newFolderNoDirectoryErrorTitleText", l); | |
| 794 | + newFolderNoDirectoryErrorText = UIManager.getString("FileChooser.newFolderNoDirectoryErrorText", l); | |
| 795 | + deleteFileButtonText = UIManager.getString("FileChooser.deleteFileButtonText", l); | |
| 796 | + renameFileButtonText = UIManager.getString("FileChooser.renameFileButtonText", l); | |
| 797 | + | |
| 798 | + newFolderButtonMnemonic = getMnemonic("FileChooser.newFolderButtonMnemonic", l); | |
| 799 | + deleteFileButtonMnemonic = getMnemonic("FileChooser.deleteFileButtonMnemonic", l); | |
| 800 | + renameFileButtonMnemonic = getMnemonic("FileChooser.renameFileButtonMnemonic", l); | |
| 801 | + | |
| 802 | + newFolderButtonToolTipText = UIManager.getString("FileChooser.newFolderButtonToolTipText", l); | |
| 803 | + deleteFileButtonToolTipText = UIManager.getString("FileChooser.deleteFileButtonToolTipText", l); | |
| 804 | + renameFileButtonToolTipText = UIManager.getString("FileChooser.renameFileButtonToolTipText", l); | |
| 805 | + | |
| 806 | + renameFileDialogText = UIManager.getString("FileChooser.renameFileDialogText", l); | |
| 807 | + renameFileErrorTitle = UIManager.getString("FileChooser.renameFileErrorTitle", l); | |
| 808 | + renameFileErrorText = UIManager.getString("FileChooser.renameFileErrorText", l); | |
| 809 | + | |
| 810 | + foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l); | |
| 811 | + foldersLabelMnemonic = getMnemonic("FileChooser.foldersLabelMnemonic", l); | |
| 812 | + | |
| 813 | + filesLabelText = UIManager.getString("FileChooser.filesLabelText",l); | |
| 814 | + filesLabelMnemonic = getMnemonic("FileChooser.filesLabelMnemonic", l); | |
| 815 | + | |
| 816 | + pathLabelText = UIManager.getString("FileChooser.pathLabelText",l); | |
| 817 | + pathLabelMnemonic = getMnemonic("FileChooser.pathLabelMnemonic", l); | |
| 818 | + | |
| 819 | + filterLabelText = UIManager.getString("FileChooser.filterLabelText", l); | |
| 820 | + filterLabelMnemonic = UIManager.getInt("FileChooser.filterLabelMnemonic"); | |
| 821 | + } | |
| 822 | + | |
| 823 | + protected void uninstallStrings(JFileChooser fc) { | |
| 824 | + super.uninstallStrings(fc); | |
| 825 | + | |
| 826 | + newFolderButtonText = null; | |
| 827 | + deleteFileButtonText = null; | |
| 828 | + renameFileButtonText = null; | |
| 829 | + | |
| 830 | + newFolderButtonToolTipText = null; | |
| 831 | + deleteFileButtonToolTipText = null; | |
| 832 | + renameFileButtonToolTipText = null; | |
| 833 | + | |
| 834 | + renameFileDialogText = null; | |
| 835 | + renameFileErrorTitle = null; | |
| 836 | + renameFileErrorText = null; | |
| 837 | + | |
| 838 | + foldersLabelText = null; | |
| 839 | + filesLabelText = null; | |
| 840 | + | |
| 841 | + pathLabelText = null; | |
| 842 | + | |
| 843 | + newFolderDialogText = null; | |
| 844 | + newFolderErrorText = null; | |
| 845 | + newFolderErrorSeparator = null; | |
| 846 | + } | |
| 847 | + | |
| 848 | + protected JScrollPane createFilesList() { | |
| 849 | + fileList = new JList(); | |
| 850 | + fileList.setName("GTKFileChooser.fileList"); | |
| 851 | + fileList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesLabelText); | |
| 852 | + | |
| 853 | + if (getFileChooser().isMultiSelectionEnabled()) { | |
| 854 | + fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
| 855 | + } else { | |
| 856 | + fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
| 857 | + } | |
| 858 | + | |
| 859 | + fileList.setModel(new GTKFileListModel()); | |
| 860 | + fileList.getSelectionModel().removeSelectionInterval(0, 0); | |
| 861 | + fileList.setCellRenderer(new FileCellRenderer()); | |
| 862 | + fileList.addListSelectionListener(createListSelectionListener(getFileChooser())); | |
| 863 | + fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList)); | |
| 864 | + align(fileList); | |
| 865 | + JScrollPane scrollpane = new JScrollPane(fileList); | |
| 866 | + scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); | |
| 867 | + scrollpane.setName("GTKFileChooser.fileListScrollPane"); | |
| 868 | + scrollpane.setPreferredSize(prefListSize); | |
| 869 | + scrollpane.setMaximumSize(MAX_SIZE); | |
| 870 | + align(scrollpane); | |
| 871 | + return scrollpane; | |
| 872 | + } | |
| 873 | + | |
| 874 | + protected JScrollPane createDirectoryList() { | |
| 875 | + directoryList = new JList(); | |
| 876 | + directoryList.setName("GTKFileChooser.directoryList"); | |
| 877 | + directoryList.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, foldersLabelText); | |
| 878 | + align(directoryList); | |
| 879 | + | |
| 880 | + directoryList.setCellRenderer(new DirectoryCellRenderer()); | |
| 881 | + directoryListModel = new GTKDirectoryListModel(); | |
| 882 | + directoryList.getSelectionModel().removeSelectionInterval(0, 0); | |
| 883 | + directoryList.setModel(directoryListModel); | |
| 884 | + directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList)); | |
| 885 | + directoryList.addListSelectionListener(createListSelectionListener(getFileChooser())); | |
| 886 | + | |
| 887 | + JScrollPane scrollpane = new JScrollPane(directoryList); | |
| 888 | + scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); | |
| 889 | + scrollpane.setName("GTKFileChooser.directoryListScrollPane"); | |
| 890 | + scrollpane.setMaximumSize(MAX_SIZE); | |
| 891 | + scrollpane.setPreferredSize(prefListSize); | |
| 892 | + align(scrollpane); | |
| 893 | + return scrollpane; | |
| 894 | + } | |
| 895 | + | |
| 896 | + protected void createModel() { | |
| 897 | + model = new GTKDirectoryModel(); | |
| 898 | + } | |
| 899 | + | |
| 900 | + public BasicDirectoryModel getModel() { | |
| 901 | + return model; | |
| 902 | + } | |
| 903 | + | |
| 904 | + public Action getApproveSelectionAction() { | |
| 905 | + return approveSelectionAction; | |
| 906 | + } | |
| 907 | + | |
| 908 | + private class GTKDirectoryModel extends BasicDirectoryModel { | |
| 909 | + FileSystemView fsv; | |
| 910 | + private Comparator<File> fileComparator = new Comparator<File>() { | |
| 911 | + public int compare(File o, File o1) { | |
| 912 | + return fsv.getSystemDisplayName(o).compareTo(fsv.getSystemDisplayName(o1)); | |
| 913 | + } | |
| 914 | + }; | |
| 915 | + | |
| 916 | + public GTKDirectoryModel() { | |
| 917 | + super(getFileChooser()); | |
| 918 | + } | |
| 919 | + | |
| 920 | + protected void sort(Vector<? extends File> v) { | |
| 921 | + fsv = getFileChooser().getFileSystemView(); | |
| 922 | + Collections.sort(v, fileComparator); | |
| 923 | + } | |
| 924 | + } | |
| 925 | + | |
| 926 | + protected class GTKDirectoryListModel extends AbstractListModel implements ListDataListener { | |
| 927 | + File curDir; | |
| 928 | + public GTKDirectoryListModel() { | |
| 929 | + getModel().addListDataListener(this); | |
| 930 | + directoryChanged(); | |
| 931 | + } | |
| 932 | + | |
| 933 | + public int getSize() { | |
| 934 | + return getModel().getDirectories().size() + 1; | |
| 935 | + } | |
| 936 | + | |
| 937 | + public Object getElementAt(int index) { | |
| 938 | + return index > 0 ? getModel().getDirectories().elementAt(index - 1): | |
| 939 | + curDir; | |
| 940 | + } | |
| 941 | + | |
| 942 | + public void intervalAdded(ListDataEvent e) { | |
| 943 | + fireIntervalAdded(this, e.getIndex0(), e.getIndex1()); | |
| 944 | + } | |
| 945 | + | |
| 946 | + public void intervalRemoved(ListDataEvent e) { | |
| 947 | + fireIntervalRemoved(this, e.getIndex0(), e.getIndex1()); | |
| 948 | + } | |
| 949 | + | |
| 950 | + // PENDING - this is inefficient - should sent out | |
| 951 | + // incremental adjustment values instead of saying that the | |
| 952 | + // whole list has changed. | |
| 953 | + public void fireContentsChanged() { | |
| 954 | + fireContentsChanged(this, 0, getModel().getDirectories().size()-1); | |
| 955 | + } | |
| 956 | + | |
| 957 | + // PENDING - fire the correct interval changed - currently sending | |
| 958 | + // out that everything has changed | |
| 959 | + public void contentsChanged(ListDataEvent e) { | |
| 960 | + fireContentsChanged(); | |
| 961 | + } | |
| 962 | + | |
| 963 | + private void directoryChanged() { | |
| 964 | + curDir = getFileChooser().getFileSystemView().createFileObject( | |
| 965 | + getFileChooser().getCurrentDirectory(), "."); | |
| 966 | + } | |
| 967 | + } | |
| 968 | + | |
| 969 | + protected class GTKFileListModel extends AbstractListModel implements ListDataListener { | |
| 970 | + public GTKFileListModel() { | |
| 971 | + getModel().addListDataListener(this); | |
| 972 | + } | |
| 973 | + | |
| 974 | + public int getSize() { | |
| 975 | + return getModel().getFiles().size(); | |
| 976 | + } | |
| 977 | + | |
| 978 | + public boolean contains(Object o) { | |
| 979 | + return getModel().getFiles().contains(o); | |
| 980 | + } | |
| 981 | + | |
| 982 | + public int indexOf(Object o) { | |
| 983 | + return getModel().getFiles().indexOf(o); | |
| 984 | + } | |
| 985 | + | |
| 986 | + public Object getElementAt(int index) { | |
| 987 | + return getModel().getFiles().elementAt(index); | |
| 988 | + } | |
| 989 | + | |
| 990 | + public void intervalAdded(ListDataEvent e) { | |
| 991 | + fireIntervalAdded(this, e.getIndex0(), e.getIndex1()); | |
| 992 | + } | |
| 993 | + | |
| 994 | + public void intervalRemoved(ListDataEvent e) { | |
| 995 | + fireIntervalRemoved(this, e.getIndex0(), e.getIndex1()); | |
| 996 | + } | |
| 997 | + | |
| 998 | + // PENDING - this is inefficient - should sent out | |
| 999 | + // incremental adjustment values instead of saying that the | |
| 1000 | + // whole list has changed. | |
| 1001 | + public void fireContentsChanged() { | |
| 1002 | + fireContentsChanged(this, 0, getModel().getFiles().size()-1); | |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + // PENDING - fire the interval changed | |
| 1006 | + public void contentsChanged(ListDataEvent e) { | |
| 1007 | + fireContentsChanged(); | |
| 1008 | + } | |
| 1009 | + } | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + protected class FileCellRenderer extends DefaultListCellRenderer { | |
| 1013 | + public Component getListCellRendererComponent(JList list, Object value, int index, | |
| 1014 | + boolean isSelected, boolean cellHasFocus) { | |
| 1015 | + | |
| 1016 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 1017 | + setText(getFileChooser().getName((File) value)); | |
| 1018 | + if (showFileIcons) { | |
| 1019 | + setIcon(getFileChooser().getIcon((File)value)); | |
| 1020 | + } | |
| 1021 | + return this; | |
| 1022 | + } | |
| 1023 | + } | |
| 1024 | + | |
| 1025 | + protected class DirectoryCellRenderer extends DefaultListCellRenderer { | |
| 1026 | + public Component getListCellRendererComponent(JList list, Object value, int index, | |
| 1027 | + boolean isSelected, boolean cellHasFocus) { | |
| 1028 | + | |
| 1029 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 1030 | + | |
| 1031 | + if (showDirectoryIcons) { | |
| 1032 | + setIcon(getFileChooser().getIcon((File)value)); | |
| 1033 | + setText(getFileChooser().getName((File)value)); | |
| 1034 | + } else { | |
| 1035 | + setText(getFileChooser().getName((File)value) + "/"); | |
| 1036 | + } | |
| 1037 | + return this; | |
| 1038 | + } | |
| 1039 | + } | |
| 1040 | + | |
| 1041 | + public Dimension getPreferredSize(JComponent c) { | |
| 1042 | + Dimension prefSize = new Dimension(PREF_SIZE); | |
| 1043 | + JComponent accessory = getFileChooser().getAccessory(); | |
| 1044 | + if (accessory != null) { | |
| 1045 | + prefSize.width += accessory.getPreferredSize().width + 20; | |
| 1046 | + } | |
| 1047 | + Dimension d = c.getLayout().preferredLayoutSize(c); | |
| 1048 | + if (d != null) { | |
| 1049 | + return new Dimension(d.width < prefSize.width ? prefSize.width : d.width, | |
| 1050 | + d.height < prefSize.height ? prefSize.height : d.height); | |
| 1051 | + } else { | |
| 1052 | + return prefSize; | |
| 1053 | + } | |
| 1054 | + } | |
| 1055 | + | |
| 1056 | + public Dimension getMinimumSize(JComponent x) { | |
| 1057 | + return new Dimension(MIN_SIZE); | |
| 1058 | + } | |
| 1059 | + | |
| 1060 | + public Dimension getMaximumSize(JComponent x) { | |
| 1061 | + return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); | |
| 1062 | + } | |
| 1063 | + | |
| 1064 | + protected void align(JComponent c) { | |
| 1065 | + c.setAlignmentX(JComponent.LEFT_ALIGNMENT); | |
| 1066 | + c.setAlignmentY(JComponent.TOP_ALIGNMENT); | |
| 1067 | + } | |
| 1068 | + | |
| 1069 | + public Action getNewFolderAction() { | |
| 1070 | + if (newFolderAction == null) { | |
| 1071 | + newFolderAction = new NewFolderAction(); | |
| 1072 | + newFolderAction.setEnabled(!readOnly); | |
| 1073 | + } | |
| 1074 | + return newFolderAction; | |
| 1075 | + } | |
| 1076 | + | |
| 1077 | + // | |
| 1078 | + // DataModel for DirectoryComboxbox | |
| 1079 | + // | |
| 1080 | + protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) { | |
| 1081 | + return new DirectoryComboBoxModel(); | |
| 1082 | + } | |
| 1083 | + | |
| 1084 | + /** | |
| 1085 | + * Data model for a type-face selection combo-box. | |
| 1086 | + */ | |
| 1087 | + protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { | |
| 1088 | + Vector<File> directories = new Vector<File>(); | |
| 1089 | + File selectedDirectory = null; | |
| 1090 | + JFileChooser chooser = getFileChooser(); | |
| 1091 | + FileSystemView fsv = chooser.getFileSystemView(); | |
| 1092 | + | |
| 1093 | + public DirectoryComboBoxModel() { | |
| 1094 | + // Add the current directory to the model, and make it the | |
| 1095 | + // selectedDirectory | |
| 1096 | + File dir = getFileChooser().getCurrentDirectory(); | |
| 1097 | + if (dir != null) { | |
| 1098 | + addItem(dir); | |
| 1099 | + } | |
| 1100 | + } | |
| 1101 | + | |
| 1102 | + /** | |
| 1103 | + * Adds the directory to the model and sets it to be selected, | |
| 1104 | + * additionally clears out the previous selected directory and | |
| 1105 | + * the paths leading up to it, if any. | |
| 1106 | + */ | |
| 1107 | + private void addItem(File directory) { | |
| 1108 | + | |
| 1109 | + if (directory == null) { | |
| 1110 | + return; | |
| 1111 | + } | |
| 1112 | + | |
| 1113 | + int oldSize = directories.size(); | |
| 1114 | + directories.clear(); | |
| 1115 | + if (oldSize > 0) { | |
| 1116 | + fireIntervalRemoved(this, 0, oldSize); | |
| 1117 | + } | |
| 1118 | + | |
| 1119 | + // Get the canonical (full) path. This has the side | |
| 1120 | + // benefit of removing extraneous chars from the path, | |
| 1121 | + // for example /foo/bar/ becomes /foo/bar | |
| 1122 | + File canonical; | |
| 1123 | + try { | |
| 1124 | + canonical = fsv.createFileObject(ShellFolder.getNormalizedFile(directory).getPath()); | |
| 1125 | + } catch (IOException e) { | |
| 1126 | + // Maybe drive is not ready. Can't abort here. | |
| 1127 | + canonical = directory; | |
| 1128 | + } | |
| 1129 | + | |
| 1130 | + // create File instances of each directory leading up to the top | |
| 1131 | + File f = canonical; | |
| 1132 | + do { | |
| 1133 | + directories.add(f); | |
| 1134 | + } while ((f = f.getParentFile()) != null); | |
| 1135 | + int newSize = directories.size(); | |
| 1136 | + if (newSize > 0) { | |
| 1137 | + fireIntervalAdded(this, 0, newSize); | |
| 1138 | + } | |
| 1139 | + setSelectedItem(canonical); | |
| 1140 | + } | |
| 1141 | + | |
| 1142 | + public void setSelectedItem(Object selectedDirectory) { | |
| 1143 | + this.selectedDirectory = (File)selectedDirectory; | |
| 1144 | + fireContentsChanged(this, -1, -1); | |
| 1145 | + } | |
| 1146 | + | |
| 1147 | + public Object getSelectedItem() { | |
| 1148 | + return selectedDirectory; | |
| 1149 | + } | |
| 1150 | + | |
| 1151 | + public int getSize() { | |
| 1152 | + return directories.size(); | |
| 1153 | + } | |
| 1154 | + | |
| 1155 | + public Object getElementAt(int index) { | |
| 1156 | + return directories.elementAt(index); | |
| 1157 | + } | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + /** | |
| 1161 | + * Acts when DirectoryComboBox has changed the selected item. | |
| 1162 | + */ | |
| 1163 | + protected class DirectoryComboBoxAction extends AbstractAction { | |
| 1164 | + protected DirectoryComboBoxAction() { | |
| 1165 | + super("DirectoryComboBoxAction"); | |
| 1166 | + } | |
| 1167 | + | |
| 1168 | + public void actionPerformed(ActionEvent e) { | |
| 1169 | + File f = (File)directoryComboBox.getSelectedItem(); | |
| 1170 | + getFileChooser().setCurrentDirectory(f); | |
| 1171 | + } | |
| 1172 | + } | |
| 1173 | + | |
| 1174 | + /** | |
| 1175 | + * Creates a new folder. | |
| 1176 | + */ | |
| 1177 | + private class NewFolderAction extends AbstractAction { | |
| 1178 | + protected NewFolderAction() { | |
| 1179 | + super(FilePane.ACTION_NEW_FOLDER); | |
| 1180 | + } | |
| 1181 | + public void actionPerformed(ActionEvent e) { | |
| 1182 | + if (readOnly) { | |
| 1183 | + return; | |
| 1184 | + } | |
| 1185 | + JFileChooser fc = getFileChooser(); | |
| 1186 | + File currentDirectory = fc.getCurrentDirectory(); | |
| 1187 | + String dirName = JOptionPane.showInputDialog(fc, | |
| 1188 | + newFolderDialogText, newFolderButtonText, | |
| 1189 | + JOptionPane.PLAIN_MESSAGE); | |
| 1190 | + | |
| 1191 | + if (dirName != null) { | |
| 1192 | + if (!currentDirectory.exists()) { | |
| 1193 | + JOptionPane.showMessageDialog(fc, | |
| 1194 | + MessageFormat.format(newFolderNoDirectoryErrorText, dirName), | |
| 1195 | + newFolderNoDirectoryErrorTitleText, JOptionPane.ERROR_MESSAGE); | |
| 1196 | + return; | |
| 1197 | + } | |
| 1198 | + | |
| 1199 | + File newDir = fc.getFileSystemView().createFileObject | |
| 1200 | + (currentDirectory, dirName); | |
| 1201 | + if (newDir == null || !newDir.mkdir()) { | |
| 1202 | + JOptionPane.showMessageDialog(fc, | |
| 1203 | + newFolderErrorText + newFolderErrorSeparator + " \"" + | |
| 1204 | + dirName + "\"", | |
| 1205 | + newFolderErrorText, JOptionPane.ERROR_MESSAGE); | |
| 1206 | + } | |
| 1207 | + fc.rescanCurrentDirectory(); | |
| 1208 | + } | |
| 1209 | + } | |
| 1210 | + } | |
| 1211 | + | |
| 1212 | + private class GTKApproveSelectionAction extends ApproveSelectionAction { | |
| 1213 | + public void actionPerformed(ActionEvent e) { | |
| 1214 | + if (isDirectorySelected()) { | |
| 1215 | + File dir = getDirectory(); | |
| 1216 | + try { | |
| 1217 | + // Strip trailing ".." | |
| 1218 | + if (dir != null) { | |
| 1219 | + dir = ShellFolder.getNormalizedFile(dir); | |
| 1220 | + } | |
| 1221 | + } catch (IOException ex) { | |
| 1222 | + // Ok, use f as is | |
| 1223 | + } | |
| 1224 | + if (getFileChooser().getCurrentDirectory().equals(dir)) { | |
| 1225 | + directoryList.clearSelection(); | |
| 1226 | + fileList.clearSelection(); | |
| 1227 | + ListSelectionModel sm = fileList.getSelectionModel(); | |
| 1228 | + if (sm instanceof DefaultListSelectionModel) { | |
| 1229 | + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); | |
| 1230 | + sm.setAnchorSelectionIndex(0); | |
| 1231 | + } | |
| 1232 | + rescanCurrentDirectory(getFileChooser()); | |
| 1233 | + return; | |
| 1234 | + } | |
| 1235 | + } | |
| 1236 | + super.actionPerformed(e); | |
| 1237 | + } | |
| 1238 | + } | |
| 1239 | + | |
| 1240 | + /** | |
| 1241 | + * Renames file | |
| 1242 | + */ | |
| 1243 | + private class RenameFileAction extends AbstractAction { | |
| 1244 | + protected RenameFileAction() { | |
| 1245 | + super(FilePane.ACTION_EDIT_FILE_NAME); | |
| 1246 | + } | |
| 1247 | + public void actionPerformed(ActionEvent e) { | |
| 1248 | + if (getFileName().equals("")) { | |
| 1249 | + return; | |
| 1250 | + } | |
| 1251 | + JFileChooser fc = getFileChooser(); | |
| 1252 | + File currentDirectory = fc.getCurrentDirectory(); | |
| 1253 | + String newFileName = (String) JOptionPane.showInputDialog | |
| 1254 | + (fc, new MessageFormat(renameFileDialogText).format | |
| 1255 | + (new Object[] { getFileName() }), | |
| 1256 | + renameFileButtonText, JOptionPane.PLAIN_MESSAGE, null, null, | |
| 1257 | + getFileName()); | |
| 1258 | + | |
| 1259 | + if (newFileName != null) { | |
| 1260 | + File oldFile = fc.getFileSystemView().createFileObject | |
| 1261 | + (currentDirectory, getFileName()); | |
| 1262 | + File newFile = fc.getFileSystemView().createFileObject | |
| 1263 | + (currentDirectory, newFileName); | |
| 1264 | + if (oldFile == null || newFile == null || | |
| 1265 | + !getModel().renameFile(oldFile, newFile)) { | |
| 1266 | + JOptionPane.showMessageDialog(fc, | |
| 1267 | + new MessageFormat(renameFileErrorText). | |
| 1268 | + format(new Object[] { getFileName(), newFileName}), | |
| 1269 | + renameFileErrorTitle, JOptionPane.ERROR_MESSAGE); | |
| 1270 | + } else { | |
| 1271 | + setFileName(getFileChooser().getName(newFile)); | |
| 1272 | + fc.rescanCurrentDirectory(); | |
| 1273 | + } | |
| 1274 | + } | |
| 1275 | + } | |
| 1276 | + } | |
| 1277 | + | |
| 1278 | + // | |
| 1279 | + // Renderer for Filter ComboBox | |
| 1280 | + // | |
| 1281 | + protected FilterComboBoxRenderer createFilterComboBoxRenderer() { | |
| 1282 | + return new FilterComboBoxRenderer(); | |
| 1283 | + } | |
| 1284 | + | |
| 1285 | + /** | |
| 1286 | + * Render different filters | |
| 1287 | + */ | |
| 1288 | + public class FilterComboBoxRenderer extends DefaultListCellRenderer implements UIResource { | |
| 1289 | + public String getName() { | |
| 1290 | + // As SynthComboBoxRenderer's are asked for a size BEFORE they | |
| 1291 | + // are parented getName is overriden to force the name to be | |
| 1292 | + // ComboBox.renderer if it isn't set. If we didn't do this the | |
| 1293 | + // wrong style could be used for size calculations. | |
| 1294 | + String name = super.getName(); | |
| 1295 | + if (name == null) { | |
| 1296 | + return "ComboBox.renderer"; | |
| 1297 | + } | |
| 1298 | + return name; | |
| 1299 | + } | |
| 1300 | + | |
| 1301 | + public Component getListCellRendererComponent(JList list, Object value, | |
| 1302 | + int index, boolean isSelected, | |
| 1303 | + boolean cellHasFocus) { | |
| 1304 | + | |
| 1305 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 1306 | + | |
| 1307 | + setName("ComboBox.listRenderer"); | |
| 1308 | + | |
| 1309 | + if (value != null) { | |
| 1310 | + if (value instanceof FileFilter) { | |
| 1311 | + setText(((FileFilter) value).getDescription()); | |
| 1312 | + } | |
| 1313 | + } else { | |
| 1314 | + setText(""); | |
| 1315 | + } | |
| 1316 | + | |
| 1317 | + return this; | |
| 1318 | + } | |
| 1319 | + } | |
| 1320 | + | |
| 1321 | + // | |
| 1322 | + // DataModel for Filter Combobox | |
| 1323 | + // | |
| 1324 | + protected FilterComboBoxModel createFilterComboBoxModel() { | |
| 1325 | + return new FilterComboBoxModel(); | |
| 1326 | + } | |
| 1327 | + | |
| 1328 | + /** | |
| 1329 | + * Data model for filter combo-box. | |
| 1330 | + */ | |
| 1331 | + protected class FilterComboBoxModel extends AbstractListModel | |
| 1332 | + implements ComboBoxModel, PropertyChangeListener { | |
| 1333 | + protected FileFilter[] filters; | |
| 1334 | + | |
| 1335 | + protected FilterComboBoxModel() { | |
| 1336 | + super(); | |
| 1337 | + filters = getFileChooser().getChoosableFileFilters(); | |
| 1338 | + } | |
| 1339 | + | |
| 1340 | + public void propertyChange(PropertyChangeEvent e) { | |
| 1341 | + String prop = e.getPropertyName(); | |
| 1342 | + if (prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { | |
| 1343 | + filters = (FileFilter[]) e.getNewValue(); | |
| 1344 | + fireContentsChanged(this, -1, -1); | |
| 1345 | + } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { | |
| 1346 | + fireContentsChanged(this, -1, -1); | |
| 1347 | + } | |
| 1348 | + } | |
| 1349 | + | |
| 1350 | + public void setSelectedItem(Object filter) { | |
| 1351 | + if (filter != null) { | |
| 1352 | + getFileChooser().setFileFilter((FileFilter) filter); | |
| 1353 | + fireContentsChanged(this, -1, -1); | |
| 1354 | + } | |
| 1355 | + } | |
| 1356 | + | |
| 1357 | + public Object getSelectedItem() { | |
| 1358 | + // Ensure that the current filter is in the list. | |
| 1359 | + // NOTE: we shouldnt' have to do this, since JFileChooser adds | |
| 1360 | + // the filter to the choosable filters list when the filter | |
| 1361 | + // is set. Lets be paranoid just in case someone overrides | |
| 1362 | + // setFileFilter in JFileChooser. | |
| 1363 | + FileFilter currentFilter = getFileChooser().getFileFilter(); | |
| 1364 | + boolean found = false; | |
| 1365 | + if (currentFilter != null) { | |
| 1366 | + for (FileFilter filter : filters) { | |
| 1367 | + if (filter == currentFilter) { | |
| 1368 | + found = true; | |
| 1369 | + } | |
| 1370 | + } | |
| 1371 | + if (found == false) { | |
| 1372 | + getFileChooser().addChoosableFileFilter(currentFilter); | |
| 1373 | + } | |
| 1374 | + } | |
| 1375 | + return getFileChooser().getFileFilter(); | |
| 1376 | + } | |
| 1377 | + | |
| 1378 | + public int getSize() { | |
| 1379 | + if (filters != null) { | |
| 1380 | + return filters.length; | |
| 1381 | + } else { | |
| 1382 | + return 0; | |
| 1383 | + } | |
| 1384 | + } | |
| 1385 | + | |
| 1386 | + public Object getElementAt(int index) { | |
| 1387 | + if (index > getSize() - 1) { | |
| 1388 | + // This shouldn't happen. Try to recover gracefully. | |
| 1389 | + return getFileChooser().getFileFilter(); | |
| 1390 | + } | |
| 1391 | + if (filters != null) { | |
| 1392 | + return filters[index]; | |
| 1393 | + } else { | |
| 1394 | + return null; | |
| 1395 | + } | |
| 1396 | + } | |
| 1397 | + } | |
| 1398 | +} | |
| @@ -0,0 +1,144 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import javax.swing.*; | |
| 28 | +import javax.swing.plaf.synth.*; | |
| 29 | +import java.awt.Color; | |
| 30 | +import java.awt.Graphics; | |
| 31 | +import java.awt.Rectangle; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * @author Joshua Outwater | |
| 35 | + */ | |
| 36 | +class GTKGraphicsUtils extends SynthGraphicsUtils { | |
| 37 | + public void paintText(SynthContext context, Graphics g, String text, | |
| 38 | + int x, int y, int mnemonicIndex) { | |
| 39 | + if (text == null || text.length() <= 0) { | |
| 40 | + // We don't need to paint empty strings | |
| 41 | + return; | |
| 42 | + } | |
| 43 | + | |
| 44 | + if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) { | |
| 45 | + // Metacity handles painting of text on internal frame title, | |
| 46 | + // ignore this. | |
| 47 | + return; | |
| 48 | + } | |
| 49 | + int componentState = context.getComponentState(); | |
| 50 | + if ((componentState & SynthConstants.DISABLED) == | |
| 51 | + SynthConstants.DISABLED){ | |
| 52 | + Color orgColor = g.getColor(); | |
| 53 | + g.setColor(context.getStyle().getColor(context, | |
| 54 | + GTKColorType.WHITE)); | |
| 55 | + x += 1; | |
| 56 | + y += 1; | |
| 57 | + super.paintText(context, g, text, x, y, mnemonicIndex); | |
| 58 | + | |
| 59 | + g.setColor(orgColor); | |
| 60 | + x -= 1; | |
| 61 | + y -= 1; | |
| 62 | + super.paintText(context, g, text, x, y, mnemonicIndex); | |
| 63 | + } | |
| 64 | + else { | |
| 65 | + String themeName = GTKLookAndFeel.getGtkThemeName(); | |
| 66 | + if (themeName != null && themeName.startsWith("blueprint") && | |
| 67 | + shouldShadowText(context.getRegion(), componentState)) { | |
| 68 | + | |
| 69 | + g.setColor(Color.BLACK); | |
| 70 | + super.paintText(context, g, text, x+1, y+1, mnemonicIndex); | |
| 71 | + g.setColor(Color.WHITE); | |
| 72 | + } | |
| 73 | + | |
| 74 | + super.paintText(context, g, text, x, y, mnemonicIndex); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Paints text at the specified location. This will not attempt to | |
| 80 | + * render the text as html nor will it offset by the insets of the | |
| 81 | + * component. | |
| 82 | + * | |
| 83 | + * @param ss SynthContext | |
| 84 | + * @param g Graphics used to render string in. | |
| 85 | + * @param text Text to render | |
| 86 | + * @param bounds Bounds of the text to be drawn. | |
| 87 | + * @param mnemonicIndex Index to draw string at. | |
| 88 | + */ | |
| 89 | + public void paintText(SynthContext context, Graphics g, String text, | |
| 90 | + Rectangle bounds, int mnemonicIndex) { | |
| 91 | + if (text == null || text.length() <= 0) { | |
| 92 | + // We don't need to paint empty strings | |
| 93 | + return; | |
| 94 | + } | |
| 95 | + | |
| 96 | + Region id = context.getRegion(); | |
| 97 | + if ((id == Region.RADIO_BUTTON || | |
| 98 | + id == Region.CHECK_BOX || | |
| 99 | + id == Region.TABBED_PANE_TAB) && | |
| 100 | + (context.getComponentState() & SynthConstants.FOCUSED) != 0) | |
| 101 | + { | |
| 102 | + JComponent source = context.getComponent(); | |
| 103 | + if (!(source instanceof AbstractButton) || | |
| 104 | + ((AbstractButton)source).isFocusPainted()) { | |
| 105 | + | |
| 106 | + // The "bounds" parameter encompasses only the actual text; | |
| 107 | + // when drawing the focus, we need to expand that bounding | |
| 108 | + // box by "focus-line-width" plus "focus-padding". Note that | |
| 109 | + // the layout process for these components will have already | |
| 110 | + // taken these values into account, so there should always | |
| 111 | + // be enough space allocated for drawing the focus indicator. | |
| 112 | + int synthState = context.getComponentState(); | |
| 113 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 114 | + int focusSize = | |
| 115 | + style.getClassSpecificIntValue(context, | |
| 116 | + "focus-line-width", 1); | |
| 117 | + int focusPad = | |
| 118 | + style.getClassSpecificIntValue(context, | |
| 119 | + "focus-padding", 1); | |
| 120 | + int totalFocus = focusSize + focusPad; | |
| 121 | + int x = bounds.x - totalFocus; | |
| 122 | + int y = bounds.y - totalFocus; | |
| 123 | + int w = bounds.width + (2 * totalFocus); | |
| 124 | + int h = bounds.height + (2 * totalFocus); | |
| 125 | + | |
| 126 | + Color color = g.getColor(); | |
| 127 | + GTKPainter.INSTANCE.paintFocus(context, g, id, | |
| 128 | + synthState, "checkbutton", | |
| 129 | + x, y, w, h); | |
| 130 | + g.setColor(color); | |
| 131 | + } | |
| 132 | + } | |
| 133 | + super.paintText(context, g, text, bounds, mnemonicIndex); | |
| 134 | + } | |
| 135 | + | |
| 136 | + private static boolean shouldShadowText(Region id, int state) { | |
| 137 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 138 | + return((gtkState == SynthConstants.MOUSE_OVER) && | |
| 139 | + (id == Region.MENU || | |
| 140 | + id == Region.MENU_ITEM || | |
| 141 | + id == Region.CHECK_BOX_MENU_ITEM || | |
| 142 | + id == Region.RADIO_BUTTON_MENU_ITEM)); | |
| 143 | + } | |
| 144 | +} | |
| @@ -0,0 +1,351 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import java.util.*; | |
| 28 | +import javax.swing.plaf.synth.*; | |
| 29 | +import java.awt.*; | |
| 30 | +import java.awt.image.BufferedImage; | |
| 31 | +import java.lang.reflect.*; | |
| 32 | +import javax.swing.*; | |
| 33 | +import javax.swing.plaf.*; | |
| 34 | +import sun.swing.plaf.synth.*; | |
| 35 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType; | |
| 36 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle; | |
| 37 | +import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation; | |
| 38 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + */ | |
| 42 | +class GTKIconFactory { | |
| 43 | + static final int CHECK_ICON_EXTRA_INSET = 1; | |
| 44 | + static final int DEFAULT_ICON_SPACING = 2; | |
| 45 | + static final int DEFAULT_ICON_SIZE = 13; | |
| 46 | + static final int DEFAULT_TOGGLE_MENU_ITEM_SIZE = 12; // For pre-gtk2.4 | |
| 47 | + | |
| 48 | + private static final String RADIO_BUTTON_ICON = "paintRadioButtonIcon"; | |
| 49 | + private static final String CHECK_BOX_ICON = "paintCheckBoxIcon"; | |
| 50 | + private static final String MENU_ARROW_ICON = "paintMenuArrowIcon"; | |
| 51 | + private static final String CHECK_BOX_MENU_ITEM_CHECK_ICON = | |
| 52 | + "paintCheckBoxMenuItemCheckIcon"; | |
| 53 | + private static final String RADIO_BUTTON_MENU_ITEM_CHECK_ICON = | |
| 54 | + "paintRadioButtonMenuItemCheckIcon"; | |
| 55 | + private static final String TREE_EXPANDED_ICON = "paintTreeExpandedIcon"; | |
| 56 | + private static final String TREE_COLLAPSED_ICON = "paintTreeCollapsedIcon"; | |
| 57 | + private static final String ASCENDING_SORT_ICON = "paintAscendingSortIcon"; | |
| 58 | + private static final String DESCENDING_SORT_ICON = "paintDescendingSortIcon"; | |
| 59 | + private static final String TOOL_BAR_HANDLE_ICON = "paintToolBarHandleIcon"; | |
| 60 | + | |
| 61 | + private static Map<String, DelegatingIcon> iconsPool = | |
| 62 | + Collections.synchronizedMap(new HashMap<String, DelegatingIcon>()); | |
| 63 | + | |
| 64 | + private static DelegatingIcon getIcon(String methodName) { | |
| 65 | + DelegatingIcon result = iconsPool.get(methodName); | |
| 66 | + if (result == null) { | |
| 67 | + if (methodName == TREE_COLLAPSED_ICON || | |
| 68 | + methodName == TREE_EXPANDED_ICON) | |
| 69 | + { | |
| 70 | + result = new SynthExpanderIcon(methodName); | |
| 71 | + | |
| 72 | + } else if (methodName == TOOL_BAR_HANDLE_ICON) { | |
| 73 | + result = new ToolBarHandleIcon(); | |
| 74 | + | |
| 75 | + } else if (methodName == MENU_ARROW_ICON) { | |
| 76 | + result = new MenuArrowIcon(); | |
| 77 | + | |
| 78 | + } else { | |
| 79 | + result = new DelegatingIcon(methodName); | |
| 80 | + } | |
| 81 | + iconsPool.put(methodName, result); | |
| 82 | + } | |
| 83 | + return result; | |
| 84 | + } | |
| 85 | + | |
| 86 | + // | |
| 87 | + // Sort arrow | |
| 88 | + // | |
| 89 | + public static Icon getAscendingSortIcon() { | |
| 90 | + return getIcon(ASCENDING_SORT_ICON); | |
| 91 | + } | |
| 92 | + | |
| 93 | + public static Icon getDescendingSortIcon() { | |
| 94 | + return getIcon(DESCENDING_SORT_ICON); | |
| 95 | + } | |
| 96 | + | |
| 97 | + // | |
| 98 | + // Tree methods | |
| 99 | + // | |
| 100 | + public static SynthIcon getTreeExpandedIcon() { | |
| 101 | + return getIcon(TREE_EXPANDED_ICON); | |
| 102 | + } | |
| 103 | + | |
| 104 | + public static SynthIcon getTreeCollapsedIcon() { | |
| 105 | + return getIcon(TREE_COLLAPSED_ICON); | |
| 106 | + } | |
| 107 | + | |
| 108 | + // | |
| 109 | + // Radio button | |
| 110 | + // | |
| 111 | + public static SynthIcon getRadioButtonIcon() { | |
| 112 | + return getIcon(RADIO_BUTTON_ICON); | |
| 113 | + } | |
| 114 | + | |
| 115 | + // | |
| 116 | + // CheckBox | |
| 117 | + // | |
| 118 | + public static SynthIcon getCheckBoxIcon() { | |
| 119 | + return getIcon(CHECK_BOX_ICON); | |
| 120 | + } | |
| 121 | + | |
| 122 | + // | |
| 123 | + // Menus | |
| 124 | + // | |
| 125 | + public static SynthIcon getMenuArrowIcon() { | |
| 126 | + return getIcon(MENU_ARROW_ICON); | |
| 127 | + } | |
| 128 | + | |
| 129 | + public static SynthIcon getCheckBoxMenuItemCheckIcon() { | |
| 130 | + return getIcon(CHECK_BOX_MENU_ITEM_CHECK_ICON); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public static SynthIcon getRadioButtonMenuItemCheckIcon() { | |
| 134 | + return getIcon(RADIO_BUTTON_MENU_ITEM_CHECK_ICON); | |
| 135 | + } | |
| 136 | + | |
| 137 | + // | |
| 138 | + // ToolBar Handle | |
| 139 | + // | |
| 140 | + public static SynthIcon getToolBarHandleIcon() { | |
| 141 | + return getIcon(TOOL_BAR_HANDLE_ICON); | |
| 142 | + } | |
| 143 | + | |
| 144 | + static void resetIcons() { | |
| 145 | + synchronized (iconsPool) { | |
| 146 | + for (DelegatingIcon di: iconsPool.values()) { | |
| 147 | + di.resetIconDimensions(); | |
| 148 | + } | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + private static class DelegatingIcon extends SynthIcon implements | |
| 153 | + UIResource { | |
| 154 | + private static final Class[] PARAM_TYPES = new Class[] { | |
| 155 | + SynthContext.class, Graphics.class, int.class, | |
| 156 | + int.class, int.class, int.class, int.class | |
| 157 | + }; | |
| 158 | + | |
| 159 | + private Object method; | |
| 160 | + int iconDimension = -1; | |
| 161 | + | |
| 162 | + DelegatingIcon(String methodName ){ | |
| 163 | + this.method = methodName; | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void paintIcon(SynthContext context, Graphics g, | |
| 167 | + int x, int y, int w, int h) { | |
| 168 | + if (context != null) { | |
| 169 | + GTKPainter.INSTANCE.paintIcon(context, g, | |
| 170 | + getMethod(), x, y, w, h); | |
| 171 | + } | |
| 172 | + } | |
| 173 | + | |
| 174 | + public int getIconWidth(SynthContext context) { | |
| 175 | + return getIconDimension(context); | |
| 176 | + } | |
| 177 | + | |
| 178 | + public int getIconHeight(SynthContext context) { | |
| 179 | + return getIconDimension(context); | |
| 180 | + } | |
| 181 | + | |
| 182 | + void resetIconDimensions() { | |
| 183 | + iconDimension = -1; | |
| 184 | + } | |
| 185 | + | |
| 186 | + protected Method getMethod() { | |
| 187 | + if (method instanceof String) { | |
| 188 | + method = resolveMethod((String)method); | |
| 189 | + } | |
| 190 | + return (Method)method; | |
| 191 | + } | |
| 192 | + | |
| 193 | + protected Class[] getMethodParamTypes() { | |
| 194 | + return PARAM_TYPES; | |
| 195 | + } | |
| 196 | + | |
| 197 | + private Method resolveMethod(String name) { | |
| 198 | + try { | |
| 199 | + return GTKPainter.class.getMethod(name, getMethodParamTypes()); | |
| 200 | + } catch (NoSuchMethodException e) { | |
| 201 | + assert false; | |
| 202 | + } | |
| 203 | + return null; | |
| 204 | + } | |
| 205 | + | |
| 206 | + int getIconDimension(SynthContext context) { | |
| 207 | + if (iconDimension >= 0) { | |
| 208 | + return iconDimension; | |
| 209 | + } | |
| 210 | + | |
| 211 | + if (context == null) { | |
| 212 | + return DEFAULT_ICON_SIZE; | |
| 213 | + } | |
| 214 | + | |
| 215 | + Region region = context.getRegion(); | |
| 216 | + GTKStyle style = (GTKStyle) context.getStyle(); | |
| 217 | + iconDimension = style.getClassSpecificIntValue(context, | |
| 218 | + "indicator-size", | |
| 219 | + (region == Region.CHECK_BOX_MENU_ITEM || | |
| 220 | + region == Region.RADIO_BUTTON_MENU_ITEM) ? | |
| 221 | + DEFAULT_TOGGLE_MENU_ITEM_SIZE : DEFAULT_ICON_SIZE); | |
| 222 | + | |
| 223 | + if (region == Region.CHECK_BOX || region == Region.RADIO_BUTTON) { | |
| 224 | + iconDimension += 2 * style.getClassSpecificIntValue(context, | |
| 225 | + "indicator-spacing", DEFAULT_ICON_SPACING); | |
| 226 | + } else if (region == Region.CHECK_BOX_MENU_ITEM || | |
| 227 | + region == Region.RADIO_BUTTON_MENU_ITEM) { | |
| 228 | + iconDimension += 2 * CHECK_ICON_EXTRA_INSET; | |
| 229 | + } | |
| 230 | + return iconDimension; | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + private static class SynthExpanderIcon extends DelegatingIcon { | |
| 235 | + SynthExpanderIcon(String method) { | |
| 236 | + super(method); | |
| 237 | + } | |
| 238 | + | |
| 239 | + public void paintIcon(SynthContext context, Graphics g, int x, int y, | |
| 240 | + int w, int h) { | |
| 241 | + if (context != null) { | |
| 242 | + super.paintIcon(context, g, x, y, w, h); | |
| 243 | + updateSizeIfNecessary(context); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + int getIconDimension(SynthContext context) { | |
| 248 | + updateSizeIfNecessary(context); | |
| 249 | + return (iconDimension == -1) ? DEFAULT_ICON_SIZE : | |
| 250 | + iconDimension; | |
| 251 | + } | |
| 252 | + | |
| 253 | + private void updateSizeIfNecessary(SynthContext context) { | |
| 254 | + if (iconDimension == -1 && context != null) { | |
| 255 | + iconDimension = context.getStyle().getInt(context, | |
| 256 | + "Tree.expanderSize", 10); | |
| 257 | + } | |
| 258 | + } | |
| 259 | + } | |
| 260 | + | |
| 261 | + // GTK has a separate widget for the handle box, to mirror this | |
| 262 | + // we create a unique icon per ToolBar and lookup the style for the | |
| 263 | + // HandleBox. | |
| 264 | + private static class ToolBarHandleIcon extends DelegatingIcon { | |
| 265 | + private static final Class[] PARAM_TYPES = new Class[] { | |
| 266 | + SynthContext.class, Graphics.class, int.class, | |
| 267 | + int.class, int.class, int.class, int.class, Orientation.class, | |
| 268 | + }; | |
| 269 | + | |
| 270 | + private SynthStyle style; | |
| 271 | + | |
| 272 | + public ToolBarHandleIcon() { | |
| 273 | + super(TOOL_BAR_HANDLE_ICON); | |
| 274 | + } | |
| 275 | + | |
| 276 | + protected Class[] getMethodParamTypes() { | |
| 277 | + return PARAM_TYPES; | |
| 278 | + } | |
| 279 | + | |
| 280 | + public void paintIcon(SynthContext context, Graphics g, int x, int y, | |
| 281 | + int w, int h) { | |
| 282 | + if (context != null) { | |
| 283 | + JToolBar toolbar = (JToolBar)context.getComponent(); | |
| 284 | + Orientation orientation = | |
| 285 | + (toolbar.getOrientation() == JToolBar.HORIZONTAL ? | |
| 286 | + Orientation.HORIZONTAL : Orientation.VERTICAL); | |
| 287 | + | |
| 288 | + if (style == null) { | |
| 289 | + style = SynthLookAndFeel.getStyleFactory().getStyle( | |
| 290 | + context.getComponent(), GTKRegion.HANDLE_BOX); | |
| 291 | + } | |
| 292 | + context = new SynthContext(toolbar, GTKRegion.HANDLE_BOX, | |
| 293 | + style, SynthConstants.ENABLED); | |
| 294 | + | |
| 295 | + GTKPainter.INSTANCE.paintIcon(context, g, | |
| 296 | + getMethod(), x, y, w, h, orientation); | |
| 297 | + } | |
| 298 | + } | |
| 299 | + | |
| 300 | + public int getIconWidth(SynthContext context) { | |
| 301 | + if (context == null) { | |
| 302 | + return 10; | |
| 303 | + } | |
| 304 | + if (((JToolBar)context.getComponent()).getOrientation() == | |
| 305 | + JToolBar.HORIZONTAL) { | |
| 306 | + return 10; | |
| 307 | + } else { | |
| 308 | + return context.getComponent().getWidth(); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + | |
| 312 | + public int getIconHeight(SynthContext context) { | |
| 313 | + if (context == null) { | |
| 314 | + return 10; | |
| 315 | + } | |
| 316 | + if (((JToolBar)context.getComponent()).getOrientation() == | |
| 317 | + JToolBar.HORIZONTAL) { | |
| 318 | + return context.getComponent().getHeight(); | |
| 319 | + } else { | |
| 320 | + return 10; | |
| 321 | + } | |
| 322 | + } | |
| 323 | + } | |
| 324 | + | |
| 325 | + private static class MenuArrowIcon extends DelegatingIcon { | |
| 326 | + private static final Class[] PARAM_TYPES = new Class[] { | |
| 327 | + SynthContext.class, Graphics.class, int.class, | |
| 328 | + int.class, int.class, int.class, int.class, ArrowType.class, | |
| 329 | + }; | |
| 330 | + | |
| 331 | + public MenuArrowIcon() { | |
| 332 | + super(MENU_ARROW_ICON); | |
| 333 | + } | |
| 334 | + | |
| 335 | + protected Class[] getMethodParamTypes() { | |
| 336 | + return PARAM_TYPES; | |
| 337 | + } | |
| 338 | + | |
| 339 | + public void paintIcon(SynthContext context, Graphics g, int x, int y, | |
| 340 | + int w, int h) { | |
| 341 | + if (context != null) { | |
| 342 | + ArrowType arrowDir = ArrowType.RIGHT; | |
| 343 | + if (!context.getComponent().getComponentOrientation().isLeftToRight()) { | |
| 344 | + arrowDir = ArrowType.LEFT; | |
| 345 | + } | |
| 346 | + GTKPainter.INSTANCE.paintIcon(context, g, | |
| 347 | + getMethod(), x, y, w, h, arrowDir); | |
| 348 | + } | |
| 349 | + } | |
| 350 | + } | |
| 351 | +} | |
| @@ -0,0 +1,1739 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.awt.event.*; | |
| 30 | +import java.beans.*; | |
| 31 | +import java.io.File; | |
| 32 | +import java.lang.ref.*; | |
| 33 | +import java.security.AccessController; | |
| 34 | +import java.security.PrivilegedAction; | |
| 35 | +import java.util.Locale; | |
| 36 | +import javax.swing.*; | |
| 37 | +import javax.swing.colorchooser.*; | |
| 38 | +import javax.swing.plaf.*; | |
| 39 | +import javax.swing.plaf.synth.*; | |
| 40 | +import javax.swing.text.DefaultEditorKit; | |
| 41 | + | |
| 42 | +import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType; | |
| 43 | +import com.sun.java.swing.plaf.gtk.GTKConstants.StateType; | |
| 44 | +import sun.awt.SunToolkit; | |
| 45 | +import sun.awt.UNIXToolkit; | |
| 46 | +import sun.awt.OSInfo; | |
| 47 | +import sun.security.action.GetPropertyAction; | |
| 48 | +import sun.swing.DefaultLayoutStyle; | |
| 49 | +import sun.swing.SwingUtilities2; | |
| 50 | + | |
| 51 | +/** | |
| 52 | + * @author Scott Violet | |
| 53 | + */ | |
| 54 | +public class GTKLookAndFeel extends SynthLookAndFeel { | |
| 55 | + private static final boolean IS_22; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Whether or not text is drawn antialiased. This keys off the | |
| 59 | + * desktop property 'gnome.Xft/Antialias' and 'gnome.Xft/RGBA' | |
| 60 | + * We should assume ON - or some variation of ON as no GTK desktop | |
| 61 | + * ships with it OFF. | |
| 62 | + */ | |
| 63 | + static Object aaTextInfo; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Solaris, or Linux with Sun JDS in a CJK Locale. | |
| 67 | + * Used to determine if Sun's high quality CJK fonts are present. | |
| 68 | + */ | |
| 69 | + private static boolean isSunCJK; | |
| 70 | + | |
| 71 | + /* | |
| 72 | + * Used to override if system (desktop) text anti-aliasing settings should | |
| 73 | + * be used. The reasons for this are are is that currently its "off" | |
| 74 | + * for CJK locales which is not likely to be a good universal answer, and | |
| 75 | + * also its off for remote display. So this provides an unsupported | |
| 76 | + * way to explicitly request that it be "on". | |
| 77 | + */ | |
| 78 | + private static boolean gtkAAFontSettingsCond; | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Font to use in places where there is no widget. | |
| 82 | + */ | |
| 83 | + private Font fallbackFont; | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * If true, GTKLookAndFeel is inside the <code>initialize</code> | |
| 87 | + * method. | |
| 88 | + */ | |
| 89 | + private boolean inInitialize; | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * If true, PropertyChangeListeners have been installed for the | |
| 93 | + * Toolkit. | |
| 94 | + */ | |
| 95 | + private boolean pclInstalled; | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * StyleFactory needs to be created only the first time. | |
| 99 | + */ | |
| 100 | + private GTKStyleFactory styleFactory; | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Cached theme name. Used by GTKGraphicsUtils | |
| 104 | + */ | |
| 105 | + private static String gtkThemeName = "Default"; | |
| 106 | + | |
| 107 | + static { | |
| 108 | + // Backup for specifying the version, this isn't currently documented. | |
| 109 | + // If you pass in anything but 2.2 you got the 2.0 colors/look. | |
| 110 | + String version = AccessController.doPrivileged( | |
| 111 | + new GetPropertyAction("swing.gtk.version")); | |
| 112 | + if (version != null) { | |
| 113 | + IS_22 = version.equals("2.2"); | |
| 114 | + } | |
| 115 | + else { | |
| 116 | + IS_22 = true; | |
| 117 | + } | |
| 118 | + | |
| 119 | + String language = Locale.getDefault().getLanguage(); | |
| 120 | + boolean cjkLocale = | |
| 121 | + (Locale.CHINESE.getLanguage().equals(language) || | |
| 122 | + Locale.JAPANESE.getLanguage().equals(language) || | |
| 123 | + Locale.KOREAN.getLanguage().equals(language)); | |
| 124 | + | |
| 125 | + if (cjkLocale) { | |
| 126 | + boolean isSunDesktop = false; | |
| 127 | + switch (OSInfo.getOSType()) { | |
| 128 | + case SOLARIS: | |
| 129 | + isSunDesktop = true; | |
| 130 | + break; | |
| 131 | + | |
| 132 | + case LINUX: | |
| 133 | + Boolean val = AccessController.doPrivileged( | |
| 134 | + new PrivilegedAction<Boolean>() { | |
| 135 | + public Boolean run() { | |
| 136 | + File f = new File("/etc/sun-release"); | |
| 137 | + return Boolean.valueOf(f.exists()); | |
| 138 | + } | |
| 139 | + }); | |
| 140 | + isSunDesktop = val.booleanValue(); | |
| 141 | + } | |
| 142 | + if (isSunDesktop && !sun.java2d.SunGraphicsEnvironment.isOpenSolaris) { | |
| 143 | + isSunCJK = true; | |
| 144 | + } | |
| 145 | + } | |
| 146 | + } | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * Returns true if running on system containing at least 2.2. | |
| 150 | + */ | |
| 151 | + static boolean is2_2() { | |
| 152 | + // NOTE: We're currently hard coding to use 2.2. | |
| 153 | + // If we want to support both GTK 2.0 and 2.2, we'll | |
| 154 | + // need to get the major/minor/micro version from the .so. | |
| 155 | + // Refer to bug 4912613 for details. | |
| 156 | + return IS_22; | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * Maps a swing constant to a GTK constant. | |
| 161 | + */ | |
| 162 | + static PositionType SwingOrientationConstantToGTK(int side) { | |
| 163 | + switch (side) { | |
| 164 | + case SwingConstants.LEFT: | |
| 165 | + return PositionType.LEFT; | |
| 166 | + case SwingConstants.RIGHT: | |
| 167 | + return PositionType.RIGHT; | |
| 168 | + case SwingConstants.TOP: | |
| 169 | + return PositionType.TOP; | |
| 170 | + case SwingConstants.BOTTOM: | |
| 171 | + return PositionType.BOTTOM; | |
| 172 | + } | |
| 173 | + assert false : "Unknown orientation: " + side; | |
| 174 | + return PositionType.TOP; | |
| 175 | + } | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * Maps from Synth state to native GTK state using typesafe enumeration | |
| 179 | + * StateType. This is only used by GTKEngine. | |
| 180 | + */ | |
| 181 | + static StateType synthStateToGTKStateType(int state) { | |
| 182 | + StateType result; | |
| 183 | + switch (state) { | |
| 184 | + case SynthConstants.PRESSED: | |
| 185 | + result = StateType.ACTIVE; | |
| 186 | + break; | |
| 187 | + case SynthConstants.MOUSE_OVER: | |
| 188 | + result = StateType.PRELIGHT; | |
| 189 | + break; | |
| 190 | + case SynthConstants.SELECTED: | |
| 191 | + result = StateType.SELECTED; | |
| 192 | + break; | |
| 193 | + case SynthConstants.DISABLED: | |
| 194 | + result = StateType.INSENSITIVE; | |
| 195 | + break; | |
| 196 | + case SynthConstants.ENABLED: | |
| 197 | + default: | |
| 198 | + result = StateType.NORMAL; | |
| 199 | + break; | |
| 200 | + } | |
| 201 | + return result; | |
| 202 | + } | |
| 203 | + | |
| 204 | + /** | |
| 205 | + * Maps from a Synth state to the corresponding GTK state. | |
| 206 | + * The GTK states are named differently than Synth's states, the | |
| 207 | + * following gives the mapping: | |
| 208 | + * <table><tr><td>Synth<td>GTK | |
| 209 | + * <tr><td>SynthConstants.PRESSED<td>ACTIVE | |
| 210 | + * <tr><td>SynthConstants.SELECTED<td>SELECTED | |
| 211 | + * <tr><td>SynthConstants.MOUSE_OVER<td>PRELIGHT | |
| 212 | + * <tr><td>SynthConstants.DISABLED<td>INSENSITIVE | |
| 213 | + * <tr><td>SynthConstants.ENABLED<td>NORMAL | |
| 214 | + * </table> | |
| 215 | + * Additionally some widgets are special cased. | |
| 216 | + */ | |
| 217 | + static int synthStateToGTKState(Region region, int state) { | |
| 218 | + if ((state & SynthConstants.PRESSED) != 0) { | |
| 219 | + if (region == Region.RADIO_BUTTON | |
| 220 | + || region == Region.CHECK_BOX | |
| 221 | + || region == Region.MENU | |
| 222 | + || region == Region.MENU_ITEM | |
| 223 | + || region == Region.RADIO_BUTTON_MENU_ITEM | |
| 224 | + || region == Region.CHECK_BOX_MENU_ITEM | |
| 225 | + || region == Region.SPLIT_PANE) { | |
| 226 | + state = SynthConstants.MOUSE_OVER; | |
| 227 | + } else { | |
| 228 | + state = SynthConstants.PRESSED; | |
| 229 | + } | |
| 230 | + | |
| 231 | + } else if (region == Region.TABBED_PANE_TAB) { | |
| 232 | + if ((state & SynthConstants.DISABLED) != 0) { | |
| 233 | + state = SynthConstants.DISABLED; | |
| 234 | + } | |
| 235 | + else if ((state & SynthConstants.SELECTED) != 0) { | |
| 236 | + state = SynthConstants.ENABLED; | |
| 237 | + } else { | |
| 238 | + state = SynthConstants.PRESSED; | |
| 239 | + } | |
| 240 | + | |
| 241 | + } else if ((state & SynthConstants.SELECTED) != 0) { | |
| 242 | + if (region == Region.MENU) { | |
| 243 | + state = SynthConstants.MOUSE_OVER; | |
| 244 | + } else if (region == Region.RADIO_BUTTON || | |
| 245 | + region == Region.TOGGLE_BUTTON || | |
| 246 | + region == Region.RADIO_BUTTON_MENU_ITEM || | |
| 247 | + region == Region.CHECK_BOX_MENU_ITEM || | |
| 248 | + region == Region.CHECK_BOX || | |
| 249 | + region == Region.BUTTON) { | |
| 250 | + if ((state & SynthConstants.DISABLED) != 0) { | |
| 251 | + state = SynthConstants.DISABLED; | |
| 252 | + } | |
| 253 | + // If the button is SELECTED and is PRELIGHT we need to | |
| 254 | + // make the state MOUSE_OVER otherwise we don't paint the | |
| 255 | + // PRELIGHT. | |
| 256 | + else if ((state & SynthConstants.MOUSE_OVER) != 0) { | |
| 257 | + state = SynthConstants.MOUSE_OVER; | |
| 258 | + } else { | |
| 259 | + state = SynthConstants.PRESSED; | |
| 260 | + } | |
| 261 | + } else { | |
| 262 | + state = SynthConstants.SELECTED; | |
| 263 | + } | |
| 264 | + } | |
| 265 | + | |
| 266 | + else if ((state & SynthConstants.MOUSE_OVER) != 0) { | |
| 267 | + state = SynthConstants.MOUSE_OVER; | |
| 268 | + } | |
| 269 | + else if ((state & SynthConstants.DISABLED) != 0) { | |
| 270 | + state = SynthConstants.DISABLED; | |
| 271 | + } | |
| 272 | + else { | |
| 273 | + if (region == Region.SLIDER_TRACK) { | |
| 274 | + state = SynthConstants.PRESSED; | |
| 275 | + } else { | |
| 276 | + state = SynthConstants.ENABLED; | |
| 277 | + } | |
| 278 | + } | |
| 279 | + return state; | |
| 280 | + } | |
| 281 | + | |
| 282 | + static boolean isText(Region region) { | |
| 283 | + // These Regions treat FOREGROUND as TEXT. | |
| 284 | + return (region == Region.TEXT_FIELD || | |
| 285 | + region == Region.FORMATTED_TEXT_FIELD || | |
| 286 | + region == Region.LIST || | |
| 287 | + region == Region.PASSWORD_FIELD || | |
| 288 | + region == Region.SPINNER || | |
| 289 | + region == Region.TABLE || | |
| 290 | + region == Region.TEXT_AREA || | |
| 291 | + region == Region.TEXT_FIELD || | |
| 292 | + region == Region.TEXT_PANE || | |
| 293 | + region == Region.TREE); | |
| 294 | + } | |
| 295 | + | |
| 296 | + public UIDefaults getDefaults() { | |
| 297 | + // We need to call super for basic's properties file. | |
| 298 | + UIDefaults table = super.getDefaults(); | |
| 299 | + | |
| 300 | + // SynthTabbedPaneUI supports rollover on tabs, GTK does not | |
| 301 | + table.put("TabbedPane.isTabRollover", Boolean.FALSE); | |
| 302 | + | |
| 303 | + // Prevents Synth from setting text AA by itself | |
| 304 | + table.put("Synth.doNotSetTextAA", true); | |
| 305 | + | |
| 306 | + initResourceBundle(table); | |
| 307 | + // For compatability with apps expecting certain defaults we'll | |
| 308 | + // populate the table with the values from basic. | |
| 309 | + initSystemColorDefaults(table); | |
| 310 | + initComponentDefaults(table); | |
| 311 | + installPropertyChangeListeners(); | |
| 312 | + return table; | |
| 313 | + } | |
| 314 | + | |
| 315 | + private void installPropertyChangeListeners() { | |
| 316 | + if(!pclInstalled) { | |
| 317 | + Toolkit kit = Toolkit.getDefaultToolkit(); | |
| 318 | + WeakPCL pcl = new WeakPCL(this, kit, "gnome.Net/ThemeName"); | |
| 319 | + kit.addPropertyChangeListener(pcl.getKey(), pcl); | |
| 320 | + pcl = new WeakPCL(this, kit, "gnome.Gtk/FontName"); | |
| 321 | + kit.addPropertyChangeListener(pcl.getKey(), pcl); | |
| 322 | + pcl = new WeakPCL(this, kit, "gnome.Xft/DPI"); | |
| 323 | + kit.addPropertyChangeListener(pcl.getKey(), pcl); | |
| 324 | + | |
| 325 | + flushUnreferenced(); | |
| 326 | + pclInstalled = true; | |
| 327 | + } | |
| 328 | + } | |
| 329 | + | |
| 330 | + private void initResourceBundle(UIDefaults table) { | |
| 331 | + table.addResourceBundle("com.sun.java.swing.plaf.gtk.resources.gtk"); | |
| 332 | + } | |
| 333 | + | |
| 334 | + protected void initComponentDefaults(UIDefaults table) { | |
| 335 | + // For compatability with apps expecting certain defaults we'll | |
| 336 | + // populate the table with the values from basic. | |
| 337 | + super.initComponentDefaults(table); | |
| 338 | + | |
| 339 | + Integer zero = Integer.valueOf(0); | |
| 340 | + Object zeroBorder = new sun.swing.SwingLazyValue( | |
| 341 | + "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", | |
| 342 | + new Object[] {zero, zero, zero, zero}); | |
| 343 | + Object focusBorder = new GTKStyle.GTKLazyValue( | |
| 344 | + "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder", | |
| 345 | + "getUnselectedCellBorder"); | |
| 346 | + Object focusSelectedBorder = new GTKStyle.GTKLazyValue( | |
| 347 | + "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder", | |
| 348 | + "getSelectedCellBorder"); | |
| 349 | + Object noFocusBorder = new GTKStyle.GTKLazyValue( | |
| 350 | + "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder", | |
| 351 | + "getNoFocusCellBorder"); | |
| 352 | + | |
| 353 | + GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory(); | |
| 354 | + GTKStyle tableStyle = (GTKStyle)factory.getStyle(null, Region.TREE); | |
| 355 | + Color tableBg = tableStyle.getGTKColor(SynthConstants.ENABLED, | |
| 356 | + GTKColorType.TEXT_BACKGROUND); | |
| 357 | + Color tableFocusCellBg = tableStyle.getGTKColor(SynthConstants.ENABLED, | |
| 358 | + GTKColorType.BACKGROUND); | |
| 359 | + Color tableFocusCellFg = tableStyle.getGTKColor(SynthConstants.ENABLED, | |
| 360 | + GTKColorType.FOREGROUND); | |
| 361 | + | |
| 362 | + // The following progress bar size calculations come from | |
| 363 | + // gtkprogressbar.c (version 2.8.20), see MIN_* constants and | |
| 364 | + // the gtk_progress_bar_size_request() method. | |
| 365 | + GTKStyle progStyle = (GTKStyle) | |
| 366 | + factory.getStyle(null, Region.PROGRESS_BAR); | |
| 367 | + int progXThickness = progStyle.getXThickness(); | |
| 368 | + int progYThickness = progStyle.getYThickness(); | |
| 369 | + int hProgWidth = 150 - (progXThickness * 2); | |
| 370 | + int hProgHeight = 20 - (progYThickness * 2); | |
| 371 | + int vProgWidth = 22 - (progXThickness * 2); | |
| 372 | + int vProgHeight = 80 - (progYThickness * 2); | |
| 373 | + | |
| 374 | + Integer caretBlinkRate = Integer.valueOf(500); | |
| 375 | + Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0); | |
| 376 | + | |
| 377 | + Double defaultCaretAspectRatio = new Double(0.025); | |
| 378 | + Color caretColor = table.getColor("caretColor"); | |
| 379 | + Color controlText = table.getColor("controlText"); | |
| 380 | + | |
| 381 | + Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 382 | + "ctrl C", DefaultEditorKit.copyAction, | |
| 383 | + "ctrl V", DefaultEditorKit.pasteAction, | |
| 384 | + "ctrl X", DefaultEditorKit.cutAction, | |
| 385 | + "COPY", DefaultEditorKit.copyAction, | |
| 386 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 387 | + "CUT", DefaultEditorKit.cutAction, | |
| 388 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 389 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 390 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 391 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 392 | + "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 393 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 394 | + "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 395 | + "ctrl LEFT", DefaultEditorKit.previousWordAction, | |
| 396 | + "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, | |
| 397 | + "ctrl RIGHT", DefaultEditorKit.nextWordAction, | |
| 398 | + "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, | |
| 399 | + "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 400 | + "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 401 | + "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 402 | + "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 403 | + "ctrl A", DefaultEditorKit.selectAllAction, | |
| 404 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 405 | + "END", DefaultEditorKit.endLineAction, | |
| 406 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 407 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 408 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 409 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 410 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 411 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 412 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 413 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 414 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 415 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 416 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 417 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 418 | + "ENTER", JTextField.notifyAction, | |
| 419 | + "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 420 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 421 | + }); | |
| 422 | + | |
| 423 | + Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 424 | + "ctrl C", DefaultEditorKit.copyAction, | |
| 425 | + "ctrl V", DefaultEditorKit.pasteAction, | |
| 426 | + "ctrl X", DefaultEditorKit.cutAction, | |
| 427 | + "COPY", DefaultEditorKit.copyAction, | |
| 428 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 429 | + "CUT", DefaultEditorKit.cutAction, | |
| 430 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 431 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 432 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 433 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 434 | + "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 435 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 436 | + "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 437 | + "ctrl LEFT", DefaultEditorKit.beginLineAction, | |
| 438 | + "ctrl KP_LEFT", DefaultEditorKit.beginLineAction, | |
| 439 | + "ctrl RIGHT", DefaultEditorKit.endLineAction, | |
| 440 | + "ctrl KP_RIGHT", DefaultEditorKit.endLineAction, | |
| 441 | + "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction, | |
| 442 | + "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction, | |
| 443 | + "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction, | |
| 444 | + "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction, | |
| 445 | + "ctrl A", DefaultEditorKit.selectAllAction, | |
| 446 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 447 | + "END", DefaultEditorKit.endLineAction, | |
| 448 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 449 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 450 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 451 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 452 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 453 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 454 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 455 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 456 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 457 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 458 | + "ENTER", JTextField.notifyAction, | |
| 459 | + "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 460 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 461 | + }); | |
| 462 | + | |
| 463 | + Object editorMargin = new InsetsUIResource(3,3,3,3); | |
| 464 | + | |
| 465 | + Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 466 | + "ctrl C", DefaultEditorKit.copyAction, | |
| 467 | + "ctrl V", DefaultEditorKit.pasteAction, | |
| 468 | + "ctrl X", DefaultEditorKit.cutAction, | |
| 469 | + "COPY", DefaultEditorKit.copyAction, | |
| 470 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 471 | + "CUT", DefaultEditorKit.cutAction, | |
| 472 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 473 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 474 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 475 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 476 | + "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 477 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 478 | + "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 479 | + "ctrl LEFT", DefaultEditorKit.previousWordAction, | |
| 480 | + "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, | |
| 481 | + "ctrl RIGHT", DefaultEditorKit.nextWordAction, | |
| 482 | + "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, | |
| 483 | + "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 484 | + "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 485 | + "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 486 | + "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 487 | + "ctrl A", DefaultEditorKit.selectAllAction, | |
| 488 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 489 | + "END", DefaultEditorKit.endLineAction, | |
| 490 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 491 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 492 | + | |
| 493 | + "UP", DefaultEditorKit.upAction, | |
| 494 | + "KP_UP", DefaultEditorKit.upAction, | |
| 495 | + "DOWN", DefaultEditorKit.downAction, | |
| 496 | + "KP_DOWN", DefaultEditorKit.downAction, | |
| 497 | + "PAGE_UP", DefaultEditorKit.pageUpAction, | |
| 498 | + "PAGE_DOWN", DefaultEditorKit.pageDownAction, | |
| 499 | + "shift PAGE_UP", "selection-page-up", | |
| 500 | + "shift PAGE_DOWN", "selection-page-down", | |
| 501 | + "ctrl shift PAGE_UP", "selection-page-left", | |
| 502 | + "ctrl shift PAGE_DOWN", "selection-page-right", | |
| 503 | + "shift UP", DefaultEditorKit.selectionUpAction, | |
| 504 | + "shift KP_UP", DefaultEditorKit.selectionUpAction, | |
| 505 | + "shift DOWN", DefaultEditorKit.selectionDownAction, | |
| 506 | + "shift KP_DOWN", DefaultEditorKit.selectionDownAction, | |
| 507 | + "ENTER", DefaultEditorKit.insertBreakAction, | |
| 508 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 509 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 510 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 511 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 512 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 513 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 514 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 515 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 516 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 517 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 518 | + "TAB", DefaultEditorKit.insertTabAction, | |
| 519 | + "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 520 | + "ctrl HOME", DefaultEditorKit.beginAction, | |
| 521 | + "ctrl END", DefaultEditorKit.endAction, | |
| 522 | + "ctrl shift HOME", DefaultEditorKit.selectionBeginAction, | |
| 523 | + "ctrl shift END", DefaultEditorKit.selectionEndAction, | |
| 524 | + "ctrl T", "next-link-action", | |
| 525 | + "ctrl shift T", "previous-link-action", | |
| 526 | + "ctrl SPACE", "activate-link-action", | |
| 527 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 528 | + }); | |
| 529 | + | |
| 530 | + class FontLazyValue implements UIDefaults.LazyValue { | |
| 531 | + private Region region; | |
| 532 | + FontLazyValue(Region region) { | |
| 533 | + this.region = region; | |
| 534 | + } | |
| 535 | + public Object createValue(UIDefaults table) { | |
| 536 | + GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory(); | |
| 537 | + GTKStyle style = (GTKStyle)factory.getStyle(null, region); | |
| 538 | + return style.getFontForState(null); | |
| 539 | + } | |
| 540 | + } | |
| 541 | + | |
| 542 | + Object[] defaults = new Object[] { | |
| 543 | + "ArrowButton.size", Integer.valueOf(13), | |
| 544 | + | |
| 545 | + | |
| 546 | + "Button.defaultButtonFollowsFocus", Boolean.FALSE, | |
| 547 | + "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 548 | + "SPACE", "pressed", | |
| 549 | + "released SPACE", "released", | |
| 550 | + "ENTER", "pressed", | |
| 551 | + "released ENTER", "released" | |
| 552 | + }), | |
| 553 | + "Button.font", new FontLazyValue(Region.BUTTON), | |
| 554 | + "Button.margin", zeroInsets, | |
| 555 | + | |
| 556 | + | |
| 557 | + "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[]{ | |
| 558 | + "SPACE", "pressed", | |
| 559 | + "released SPACE", "released" | |
| 560 | + }), | |
| 561 | + "CheckBox.icon", new GTKStyle.GTKLazyValue( | |
| 562 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 563 | + "getCheckBoxIcon"), | |
| 564 | + "CheckBox.font", new FontLazyValue(Region.CHECK_BOX), | |
| 565 | + "CheckBox.margin", zeroInsets, | |
| 566 | + | |
| 567 | + | |
| 568 | + "CheckBoxMenuItem.arrowIcon", null, | |
| 569 | + "CheckBoxMenuItem.checkIcon", new GTKStyle.GTKLazyValue( | |
| 570 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 571 | + "getCheckBoxMenuItemCheckIcon"), | |
| 572 | + "CheckBoxMenuItem.font", | |
| 573 | + new FontLazyValue(Region.CHECK_BOX_MENU_ITEM), | |
| 574 | + "CheckBoxMenuItem.margin", zeroInsets, | |
| 575 | + "CheckBoxMenuItem.alignAcceleratorText", Boolean.FALSE, | |
| 576 | + | |
| 577 | + | |
| 578 | + "ColorChooser.showPreviewPanelText", Boolean.FALSE, | |
| 579 | + "ColorChooser.panels", new UIDefaults.ActiveValue() { | |
| 580 | + public Object createValue(UIDefaults table) { | |
| 581 | + return new AbstractColorChooserPanel[] { | |
| 582 | + new GTKColorChooserPanel() }; | |
| 583 | + } | |
| 584 | + }, | |
| 585 | + "ColorChooser.font", new FontLazyValue(Region.COLOR_CHOOSER), | |
| 586 | + | |
| 587 | + | |
| 588 | + "ComboBox.ancestorInputMap", | |
| 589 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 590 | + "ESCAPE", "hidePopup", | |
| 591 | + "PAGE_UP", "pageUpPassThrough", | |
| 592 | + "PAGE_DOWN", "pageDownPassThrough", | |
| 593 | + "HOME", "homePassThrough", | |
| 594 | + "END", "endPassThrough", | |
| 595 | + "DOWN", "selectNext", | |
| 596 | + "KP_DOWN", "selectNext", | |
| 597 | + "alt DOWN", "togglePopup", | |
| 598 | + "alt KP_DOWN", "togglePopup", | |
| 599 | + "alt UP", "togglePopup", | |
| 600 | + "alt KP_UP", "togglePopup", | |
| 601 | + "SPACE", "spacePopup", | |
| 602 | + "ENTER", "enterPressed", | |
| 603 | + "UP", "selectPrevious", | |
| 604 | + "KP_UP", "selectPrevious" | |
| 605 | + | |
| 606 | + }), | |
| 607 | + "ComboBox.font", new FontLazyValue(Region.COMBO_BOX), | |
| 608 | + "ComboBox.isEnterSelectablePopup", Boolean.TRUE, | |
| 609 | + | |
| 610 | + | |
| 611 | + "EditorPane.caretForeground", caretColor, | |
| 612 | + "EditorPane.caretAspectRatio", defaultCaretAspectRatio, | |
| 613 | + "EditorPane.caretBlinkRate", caretBlinkRate, | |
| 614 | + "EditorPane.margin", editorMargin, | |
| 615 | + "EditorPane.focusInputMap", multilineInputMap, | |
| 616 | + "EditorPane.font", new FontLazyValue(Region.EDITOR_PANE), | |
| 617 | + | |
| 618 | + | |
| 619 | + "FileChooser.ancestorInputMap", | |
| 620 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 621 | + "ESCAPE", "cancelSelection", | |
| 622 | + "ctrl ENTER", "approveSelection" | |
| 623 | + }), | |
| 624 | + "FileChooserUI", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", | |
| 625 | + | |
| 626 | + | |
| 627 | + "FormattedTextField.caretForeground", caretColor, | |
| 628 | + "FormattedTextField.caretAspectRatio", defaultCaretAspectRatio, | |
| 629 | + "FormattedTextField.caretBlinkRate", caretBlinkRate, | |
| 630 | + "FormattedTextField.focusInputMap", | |
| 631 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 632 | + "ctrl C", DefaultEditorKit.copyAction, | |
| 633 | + "ctrl V", DefaultEditorKit.pasteAction, | |
| 634 | + "ctrl X", DefaultEditorKit.cutAction, | |
| 635 | + "COPY", DefaultEditorKit.copyAction, | |
| 636 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 637 | + "CUT", DefaultEditorKit.cutAction, | |
| 638 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 639 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 640 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 641 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 642 | + "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 643 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 644 | + "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 645 | + "ctrl LEFT", DefaultEditorKit.previousWordAction, | |
| 646 | + "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, | |
| 647 | + "ctrl RIGHT", DefaultEditorKit.nextWordAction, | |
| 648 | + "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, | |
| 649 | + "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 650 | + "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 651 | + "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 652 | + "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 653 | + "ctrl A", DefaultEditorKit.selectAllAction, | |
| 654 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 655 | + "END", DefaultEditorKit.endLineAction, | |
| 656 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 657 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 658 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 659 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 660 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 661 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 662 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 663 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 664 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 665 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 666 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 667 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 668 | + "ENTER", JTextField.notifyAction, | |
| 669 | + "ctrl BACK_SLASH", "unselect", | |
| 670 | + "control shift O", "toggle-componentOrientation", | |
| 671 | + "ESCAPE", "reset-field-edit", | |
| 672 | + "UP", "increment", | |
| 673 | + "KP_UP", "increment", | |
| 674 | + "DOWN", "decrement", | |
| 675 | + "KP_DOWN", "decrement", | |
| 676 | + }), | |
| 677 | + "FormattedTextField.font", | |
| 678 | + new FontLazyValue(Region.FORMATTED_TEXT_FIELD), | |
| 679 | + | |
| 680 | + | |
| 681 | + "InternalFrameTitlePane.titlePaneLayout", | |
| 682 | + new GTKStyle.GTKLazyValue("com.sun.java.swing.plaf.gtk.Metacity", | |
| 683 | + "getTitlePaneLayout"), | |
| 684 | + "InternalFrame.windowBindings", new Object[] { | |
| 685 | + "shift ESCAPE", "showSystemMenu", | |
| 686 | + "ctrl SPACE", "showSystemMenu", | |
| 687 | + "ESCAPE", "hideSystemMenu" }, | |
| 688 | + "InternalFrame.layoutTitlePaneAtOrigin", Boolean.TRUE, | |
| 689 | + "InternalFrame.useTaskBar", Boolean.TRUE, | |
| 690 | + | |
| 691 | + "InternalFrameTitlePane.iconifyButtonOpacity", null, | |
| 692 | + "InternalFrameTitlePane.maximizeButtonOpacity", null, | |
| 693 | + "InternalFrameTitlePane.closeButtonOpacity", null, | |
| 694 | + | |
| 695 | + "Label.font", new FontLazyValue(Region.LABEL), | |
| 696 | + | |
| 697 | + "List.background", tableBg, | |
| 698 | + "List.focusCellHighlightBorder", focusBorder, | |
| 699 | + "List.focusSelectedCellHighlightBorder", focusSelectedBorder, | |
| 700 | + "List.noFocusBorder", noFocusBorder, | |
| 701 | + "List.focusInputMap", | |
| 702 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 703 | + "ctrl C", "copy", | |
| 704 | + "ctrl V", "paste", | |
| 705 | + "ctrl X", "cut", | |
| 706 | + "COPY", "copy", | |
| 707 | + "PASTE", "paste", | |
| 708 | + "CUT", "cut", | |
| 709 | + "control INSERT", "copy", | |
| 710 | + "shift INSERT", "paste", | |
| 711 | + "shift DELETE", "cut", | |
| 712 | + "UP", "selectPreviousRow", | |
| 713 | + "KP_UP", "selectPreviousRow", | |
| 714 | + "shift UP", "selectPreviousRowExtendSelection", | |
| 715 | + "shift KP_UP", "selectPreviousRowExtendSelection", | |
| 716 | + "ctrl shift UP", "selectPreviousRowExtendSelection", | |
| 717 | + "ctrl shift KP_UP", "selectPreviousRowExtendSelection", | |
| 718 | + "ctrl UP", "selectPreviousRowChangeLead", | |
| 719 | + "ctrl KP_UP", "selectPreviousRowChangeLead", | |
| 720 | + "DOWN", "selectNextRow", | |
| 721 | + "KP_DOWN", "selectNextRow", | |
| 722 | + "shift DOWN", "selectNextRowExtendSelection", | |
| 723 | + "shift KP_DOWN", "selectNextRowExtendSelection", | |
| 724 | + "ctrl shift DOWN", "selectNextRowExtendSelection", | |
| 725 | + "ctrl shift KP_DOWN", "selectNextRowExtendSelection", | |
| 726 | + "ctrl DOWN", "selectNextRowChangeLead", | |
| 727 | + "ctrl KP_DOWN", "selectNextRowChangeLead", | |
| 728 | + "LEFT", "selectPreviousColumn", | |
| 729 | + "KP_LEFT", "selectPreviousColumn", | |
| 730 | + "shift LEFT", "selectPreviousColumnExtendSelection", | |
| 731 | + "shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 732 | + "ctrl shift LEFT", "selectPreviousColumnExtendSelection", | |
| 733 | + "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 734 | + "ctrl LEFT", "selectPreviousColumnChangeLead", | |
| 735 | + "ctrl KP_LEFT", "selectPreviousColumnChangeLead", | |
| 736 | + "RIGHT", "selectNextColumn", | |
| 737 | + "KP_RIGHT", "selectNextColumn", | |
| 738 | + "shift RIGHT", "selectNextColumnExtendSelection", | |
| 739 | + "shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 740 | + "ctrl shift RIGHT", "selectNextColumnExtendSelection", | |
| 741 | + "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 742 | + "ctrl RIGHT", "selectNextColumnChangeLead", | |
| 743 | + "ctrl KP_RIGHT", "selectNextColumnChangeLead", | |
| 744 | + "HOME", "selectFirstRow", | |
| 745 | + "shift HOME", "selectFirstRowExtendSelection", | |
| 746 | + "ctrl shift HOME", "selectFirstRowExtendSelection", | |
| 747 | + "ctrl HOME", "selectFirstRowChangeLead", | |
| 748 | + "END", "selectLastRow", | |
| 749 | + "shift END", "selectLastRowExtendSelection", | |
| 750 | + "ctrl shift END", "selectLastRowExtendSelection", | |
| 751 | + "ctrl END", "selectLastRowChangeLead", | |
| 752 | + "PAGE_UP", "scrollUp", | |
| 753 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 754 | + "ctrl shift PAGE_UP", "scrollUpExtendSelection", | |
| 755 | + "ctrl PAGE_UP", "scrollUpChangeLead", | |
| 756 | + "PAGE_DOWN", "scrollDown", | |
| 757 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 758 | + "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 759 | + "ctrl PAGE_DOWN", "scrollDownChangeLead", | |
| 760 | + "ctrl A", "selectAll", | |
| 761 | + "ctrl SLASH", "selectAll", | |
| 762 | + "ctrl BACK_SLASH", "clearSelection", | |
| 763 | + "SPACE", "addToSelection", | |
| 764 | + "ctrl SPACE", "toggleAndAnchor", | |
| 765 | + "shift SPACE", "extendTo", | |
| 766 | + "ctrl shift SPACE", "moveSelectionTo" | |
| 767 | + }), | |
| 768 | + "List.focusInputMap.RightToLeft", | |
| 769 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 770 | + "LEFT", "selectNextColumn", | |
| 771 | + "KP_LEFT", "selectNextColumn", | |
| 772 | + "shift LEFT", "selectNextColumnExtendSelection", | |
| 773 | + "shift KP_LEFT", "selectNextColumnExtendSelection", | |
| 774 | + "ctrl shift LEFT", "selectNextColumnExtendSelection", | |
| 775 | + "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", | |
| 776 | + "ctrl LEFT", "selectNextColumnChangeLead", | |
| 777 | + "ctrl KP_LEFT", "selectNextColumnChangeLead", | |
| 778 | + "RIGHT", "selectPreviousColumn", | |
| 779 | + "KP_RIGHT", "selectPreviousColumn", | |
| 780 | + "shift RIGHT", "selectPreviousColumnExtendSelection", | |
| 781 | + "shift KP_RIGHT", "selectPreviousColumnExtendSelection", | |
| 782 | + "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", | |
| 783 | + "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", | |
| 784 | + "ctrl RIGHT", "selectPreviousColumnChangeLead", | |
| 785 | + "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", | |
| 786 | + }), | |
| 787 | + "List.font", new FontLazyValue(Region.LIST), | |
| 788 | + "List.rendererUseUIBorder", Boolean.FALSE, | |
| 789 | + | |
| 790 | + "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK}, | |
| 791 | + "Menu.arrowIcon", new GTKStyle.GTKLazyValue( | |
| 792 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 793 | + "getMenuArrowIcon"), | |
| 794 | + "Menu.checkIcon", null, | |
| 795 | + "Menu.font", new FontLazyValue(Region.MENU), | |
| 796 | + "Menu.margin", zeroInsets, | |
| 797 | + "Menu.cancelMode", "hideMenuTree", | |
| 798 | + "Menu.alignAcceleratorText", Boolean.FALSE, | |
| 799 | + | |
| 800 | + | |
| 801 | + "MenuBar.windowBindings", new Object[] { | |
| 802 | + "F10", "takeFocus" }, | |
| 803 | + "MenuBar.font", new FontLazyValue(Region.MENU_BAR), | |
| 804 | + | |
| 805 | + | |
| 806 | + "MenuItem.arrowIcon", null, | |
| 807 | + "MenuItem.checkIcon", null, | |
| 808 | + "MenuItem.font", new FontLazyValue(Region.MENU_ITEM), | |
| 809 | + "MenuItem.margin", zeroInsets, | |
| 810 | + "MenuItem.alignAcceleratorText", Boolean.FALSE, | |
| 811 | + | |
| 812 | + | |
| 813 | + "OptionPane.setButtonMargin", Boolean.FALSE, | |
| 814 | + "OptionPane.sameSizeButtons", Boolean.TRUE, | |
| 815 | + "OptionPane.buttonOrientation", new Integer(SwingConstants.RIGHT), | |
| 816 | + "OptionPane.minimumSize", new DimensionUIResource(262, 90), | |
| 817 | + "OptionPane.buttonPadding", new Integer(10), | |
| 818 | + "OptionPane.windowBindings", new Object[] { | |
| 819 | + "ESCAPE", "close" }, | |
| 820 | + "OptionPane.buttonClickThreshhold", new Integer(500), | |
| 821 | + "OptionPane.isYesLast", Boolean.TRUE, | |
| 822 | + "OptionPane.font", new FontLazyValue(Region.OPTION_PANE), | |
| 823 | + | |
| 824 | + "Panel.font", new FontLazyValue(Region.PANEL), | |
| 825 | + | |
| 826 | + "PasswordField.caretForeground", caretColor, | |
| 827 | + "PasswordField.caretAspectRatio", defaultCaretAspectRatio, | |
| 828 | + "PasswordField.caretBlinkRate", caretBlinkRate, | |
| 829 | + "PasswordField.margin", zeroInsets, | |
| 830 | + "PasswordField.focusInputMap", passwordInputMap, | |
| 831 | + "PasswordField.font", new FontLazyValue(Region.PASSWORD_FIELD), | |
| 832 | + | |
| 833 | + | |
| 834 | + "PopupMenu.consumeEventOnClose", Boolean.TRUE, | |
| 835 | + "PopupMenu.selectedWindowInputMapBindings", new Object[] { | |
| 836 | + "ESCAPE", "cancel", | |
| 837 | + "DOWN", "selectNext", | |
| 838 | + "KP_DOWN", "selectNext", | |
| 839 | + "UP", "selectPrevious", | |
| 840 | + "KP_UP", "selectPrevious", | |
| 841 | + "LEFT", "selectParent", | |
| 842 | + "KP_LEFT", "selectParent", | |
| 843 | + "RIGHT", "selectChild", | |
| 844 | + "KP_RIGHT", "selectChild", | |
| 845 | + "ENTER", "return", | |
| 846 | + "SPACE", "return" | |
| 847 | + }, | |
| 848 | + "PopupMenu.selectedWindowInputMapBindings.RightToLeft", | |
| 849 | + new Object[] { | |
| 850 | + "LEFT", "selectChild", | |
| 851 | + "KP_LEFT", "selectChild", | |
| 852 | + "RIGHT", "selectParent", | |
| 853 | + "KP_RIGHT", "selectParent", | |
| 854 | + }, | |
| 855 | + "PopupMenu.font", new FontLazyValue(Region.POPUP_MENU), | |
| 856 | + | |
| 857 | + "ProgressBar.horizontalSize", | |
| 858 | + new DimensionUIResource(hProgWidth, hProgHeight), | |
| 859 | + "ProgressBar.verticalSize", | |
| 860 | + new DimensionUIResource(vProgWidth, vProgHeight), | |
| 861 | + "ProgressBar.font", new FontLazyValue(Region.PROGRESS_BAR), | |
| 862 | + | |
| 863 | + "RadioButton.focusInputMap", | |
| 864 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 865 | + "SPACE", "pressed", | |
| 866 | + "released SPACE", "released", | |
| 867 | + "RETURN", "pressed" | |
| 868 | + }), | |
| 869 | + "RadioButton.icon", new GTKStyle.GTKLazyValue( | |
| 870 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 871 | + "getRadioButtonIcon"), | |
| 872 | + "RadioButton.font", new FontLazyValue(Region.RADIO_BUTTON), | |
| 873 | + "RadioButton.margin", zeroInsets, | |
| 874 | + | |
| 875 | + | |
| 876 | + "RadioButtonMenuItem.arrowIcon", null, | |
| 877 | + "RadioButtonMenuItem.checkIcon", new GTKStyle.GTKLazyValue( | |
| 878 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 879 | + "getRadioButtonMenuItemCheckIcon"), | |
| 880 | + "RadioButtonMenuItem.font", new FontLazyValue(Region.RADIO_BUTTON_MENU_ITEM), | |
| 881 | + "RadioButtonMenuItem.margin", zeroInsets, | |
| 882 | + "RadioButtonMenuItem.alignAcceleratorText", Boolean.FALSE, | |
| 883 | + | |
| 884 | + | |
| 885 | + // These bindings are only enabled when there is a default | |
| 886 | + // button set on the rootpane. | |
| 887 | + "RootPane.defaultButtonWindowKeyBindings", new Object[] { | |
| 888 | + "ENTER", "press", | |
| 889 | + "released ENTER", "release", | |
| 890 | + "ctrl ENTER", "press", | |
| 891 | + "ctrl released ENTER", "release" | |
| 892 | + }, | |
| 893 | + | |
| 894 | + | |
| 895 | + "ScrollBar.squareButtons", Boolean.FALSE, | |
| 896 | + "ScrollBar.thumbHeight", Integer.valueOf(14), | |
| 897 | + "ScrollBar.width", Integer.valueOf(16), | |
| 898 | + "ScrollBar.minimumThumbSize", new Dimension(8, 8), | |
| 899 | + "ScrollBar.maximumThumbSize", new Dimension(4096, 4096), | |
| 900 | + "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE, | |
| 901 | + "ScrollBar.alwaysShowThumb", Boolean.TRUE, | |
| 902 | + "ScrollBar.ancestorInputMap", | |
| 903 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 904 | + "RIGHT", "positiveUnitIncrement", | |
| 905 | + "KP_RIGHT", "positiveUnitIncrement", | |
| 906 | + "DOWN", "positiveUnitIncrement", | |
| 907 | + "KP_DOWN", "positiveUnitIncrement", | |
| 908 | + "PAGE_DOWN", "positiveBlockIncrement", | |
| 909 | + "LEFT", "negativeUnitIncrement", | |
| 910 | + "KP_LEFT", "negativeUnitIncrement", | |
| 911 | + "UP", "negativeUnitIncrement", | |
| 912 | + "KP_UP", "negativeUnitIncrement", | |
| 913 | + "PAGE_UP", "negativeBlockIncrement", | |
| 914 | + "HOME", "minScroll", | |
| 915 | + "END", "maxScroll" | |
| 916 | + }), | |
| 917 | + "ScrollBar.ancestorInputMap.RightToLeft", | |
| 918 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 919 | + "RIGHT", "negativeUnitIncrement", | |
| 920 | + "KP_RIGHT", "negativeUnitIncrement", | |
| 921 | + "LEFT", "positiveUnitIncrement", | |
| 922 | + "KP_LEFT", "positiveUnitIncrement", | |
| 923 | + }), | |
| 924 | + | |
| 925 | + | |
| 926 | + "Spinner.disableOnBoundaryValues", Boolean.TRUE, | |
| 927 | + | |
| 928 | + | |
| 929 | + "ScrollPane.fillUpperCorner", Boolean.TRUE, | |
| 930 | + "ScrollPane.fillLowerCorner", Boolean.TRUE, | |
| 931 | + "ScrollPane.ancestorInputMap", | |
| 932 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 933 | + "RIGHT", "unitScrollRight", | |
| 934 | + "KP_RIGHT", "unitScrollRight", | |
| 935 | + "DOWN", "unitScrollDown", | |
| 936 | + "KP_DOWN", "unitScrollDown", | |
| 937 | + "LEFT", "unitScrollLeft", | |
| 938 | + "KP_LEFT", "unitScrollLeft", | |
| 939 | + "UP", "unitScrollUp", | |
| 940 | + "KP_UP", "unitScrollUp", | |
| 941 | + "PAGE_UP", "scrollUp", | |
| 942 | + "PAGE_DOWN", "scrollDown", | |
| 943 | + "ctrl PAGE_UP", "scrollLeft", | |
| 944 | + "ctrl PAGE_DOWN", "scrollRight", | |
| 945 | + "ctrl HOME", "scrollHome", | |
| 946 | + "ctrl END", "scrollEnd" | |
| 947 | + }), | |
| 948 | + "ScrollPane.ancestorInputMap.RightToLeft", | |
| 949 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 950 | + "ctrl PAGE_UP", "scrollRight", | |
| 951 | + "ctrl PAGE_DOWN", "scrollLeft", | |
| 952 | + }), | |
| 953 | + "ScrollPane.font", new FontLazyValue(Region.SCROLL_PANE), | |
| 954 | + | |
| 955 | + | |
| 956 | + "Separator.insets", zeroInsets, | |
| 957 | + "Separator.thickness", Integer.valueOf(2), | |
| 958 | + | |
| 959 | + | |
| 960 | + "Slider.paintValue", Boolean.TRUE, | |
| 961 | + "Slider.thumbWidth", Integer.valueOf(30), | |
| 962 | + "Slider.thumbHeight", Integer.valueOf(14), | |
| 963 | + "Slider.focusInputMap", | |
| 964 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 965 | + "RIGHT", "positiveUnitIncrement", | |
| 966 | + "KP_RIGHT", "positiveUnitIncrement", | |
| 967 | + "DOWN", "negativeUnitIncrement", | |
| 968 | + "KP_DOWN", "negativeUnitIncrement", | |
| 969 | + "PAGE_DOWN", "negativeBlockIncrement", | |
| 970 | + "LEFT", "negativeUnitIncrement", | |
| 971 | + "KP_LEFT", "negativeUnitIncrement", | |
| 972 | + "UP", "positiveUnitIncrement", | |
| 973 | + "KP_UP", "positiveUnitIncrement", | |
| 974 | + "PAGE_UP", "positiveBlockIncrement", | |
| 975 | + "HOME", "minScroll", | |
| 976 | + "END", "maxScroll" | |
| 977 | + }), | |
| 978 | + "Slider.focusInputMap.RightToLeft", | |
| 979 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 980 | + "RIGHT", "negativeUnitIncrement", | |
| 981 | + "KP_RIGHT", "negativeUnitIncrement", | |
| 982 | + "LEFT", "positiveUnitIncrement", | |
| 983 | + "KP_LEFT", "positiveUnitIncrement", | |
| 984 | + }), | |
| 985 | + "Slider.onlyLeftMouseButtonDrag", Boolean.FALSE, | |
| 986 | + | |
| 987 | + "Spinner.ancestorInputMap", | |
| 988 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 989 | + "UP", "increment", | |
| 990 | + "KP_UP", "increment", | |
| 991 | + "DOWN", "decrement", | |
| 992 | + "KP_DOWN", "decrement", | |
| 993 | + }), | |
| 994 | + "Spinner.font", new FontLazyValue(Region.SPINNER), | |
| 995 | + "Spinner.editorAlignment", JTextField.LEADING, | |
| 996 | + | |
| 997 | + "SplitPane.ancestorInputMap", | |
| 998 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 999 | + "UP", "negativeIncrement", | |
| 1000 | + "DOWN", "positiveIncrement", | |
| 1001 | + "LEFT", "negativeIncrement", | |
| 1002 | + "RIGHT", "positiveIncrement", | |
| 1003 | + "KP_UP", "negativeIncrement", | |
| 1004 | + "KP_DOWN", "positiveIncrement", | |
| 1005 | + "KP_LEFT", "negativeIncrement", | |
| 1006 | + "KP_RIGHT", "positiveIncrement", | |
| 1007 | + "HOME", "selectMin", | |
| 1008 | + "END", "selectMax", | |
| 1009 | + "F8", "startResize", | |
| 1010 | + "F6", "toggleFocus", | |
| 1011 | + "ctrl TAB", "focusOutForward", | |
| 1012 | + "ctrl shift TAB", "focusOutBackward" | |
| 1013 | + }), | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + "SplitPane.size", Integer.valueOf(7), | |
| 1017 | + "SplitPane.oneTouchOffset", Integer.valueOf(2), | |
| 1018 | + "SplitPane.oneTouchButtonSize", Integer.valueOf(5), | |
| 1019 | + "SplitPane.supportsOneTouchButtons", Boolean.FALSE, | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + "TabbedPane.focusInputMap", | |
| 1023 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1024 | + "RIGHT", "navigateRight", | |
| 1025 | + "KP_RIGHT", "navigateRight", | |
| 1026 | + "LEFT", "navigateLeft", | |
| 1027 | + "KP_LEFT", "navigateLeft", | |
| 1028 | + "UP", "navigateUp", | |
| 1029 | + "KP_UP", "navigateUp", | |
| 1030 | + "DOWN", "navigateDown", | |
| 1031 | + "KP_DOWN", "navigateDown", | |
| 1032 | + "ctrl DOWN", "requestFocusForVisibleComponent", | |
| 1033 | + "ctrl KP_DOWN", "requestFocusForVisibleComponent", | |
| 1034 | + "SPACE", "selectTabWithFocus" | |
| 1035 | + }), | |
| 1036 | + "TabbedPane.ancestorInputMap", | |
| 1037 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1038 | + "ctrl TAB", "navigateNext", | |
| 1039 | + "ctrl shift TAB", "navigatePrevious", | |
| 1040 | + "ctrl PAGE_DOWN", "navigatePageDown", | |
| 1041 | + "ctrl PAGE_UP", "navigatePageUp", | |
| 1042 | + "ctrl UP", "requestFocus", | |
| 1043 | + "ctrl KP_UP", "requestFocus", | |
| 1044 | + }), | |
| 1045 | + | |
| 1046 | + "TabbedPane.labelShift", 3, | |
| 1047 | + "TabbedPane.selectedLabelShift", 3, | |
| 1048 | + "TabbedPane.font", new FontLazyValue(Region.TABBED_PANE), | |
| 1049 | + "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 0, 1), | |
| 1050 | + | |
| 1051 | + "Table.scrollPaneBorder", zeroBorder, | |
| 1052 | + "Table.background", tableBg, | |
| 1053 | + "Table.focusCellBackground", tableFocusCellBg, | |
| 1054 | + "Table.focusCellForeground", tableFocusCellFg, | |
| 1055 | + "Table.focusCellHighlightBorder", focusBorder, | |
| 1056 | + "Table.focusSelectedCellHighlightBorder", focusSelectedBorder, | |
| 1057 | + "Table.ancestorInputMap", | |
| 1058 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1059 | + "ctrl C", "copy", | |
| 1060 | + "ctrl V", "paste", | |
| 1061 | + "ctrl X", "cut", | |
| 1062 | + "COPY", "copy", | |
| 1063 | + "PASTE", "paste", | |
| 1064 | + "CUT", "cut", | |
| 1065 | + "control INSERT", "copy", | |
| 1066 | + "shift INSERT", "paste", | |
| 1067 | + "shift DELETE", "cut", | |
| 1068 | + "RIGHT", "selectNextColumn", | |
| 1069 | + "KP_RIGHT", "selectNextColumn", | |
| 1070 | + "shift RIGHT", "selectNextColumnExtendSelection", | |
| 1071 | + "shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 1072 | + "ctrl shift RIGHT", "selectNextColumnExtendSelection", | |
| 1073 | + "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 1074 | + "ctrl RIGHT", "selectNextColumnChangeLead", | |
| 1075 | + "ctrl KP_RIGHT", "selectNextColumnChangeLead", | |
| 1076 | + "LEFT", "selectPreviousColumn", | |
| 1077 | + "KP_LEFT", "selectPreviousColumn", | |
| 1078 | + "shift LEFT", "selectPreviousColumnExtendSelection", | |
| 1079 | + "shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 1080 | + "ctrl shift LEFT", "selectPreviousColumnExtendSelection", | |
| 1081 | + "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 1082 | + "ctrl LEFT", "selectPreviousColumnChangeLead", | |
| 1083 | + "ctrl KP_LEFT", "selectPreviousColumnChangeLead", | |
| 1084 | + "DOWN", "selectNextRow", | |
| 1085 | + "KP_DOWN", "selectNextRow", | |
| 1086 | + "shift DOWN", "selectNextRowExtendSelection", | |
| 1087 | + "shift KP_DOWN", "selectNextRowExtendSelection", | |
| 1088 | + "ctrl shift DOWN", "selectNextRowExtendSelection", | |
| 1089 | + "ctrl shift KP_DOWN", "selectNextRowExtendSelection", | |
| 1090 | + "ctrl DOWN", "selectNextRowChangeLead", | |
| 1091 | + "ctrl KP_DOWN", "selectNextRowChangeLead", | |
| 1092 | + "UP", "selectPreviousRow", | |
| 1093 | + "KP_UP", "selectPreviousRow", | |
| 1094 | + "shift UP", "selectPreviousRowExtendSelection", | |
| 1095 | + "shift KP_UP", "selectPreviousRowExtendSelection", | |
| 1096 | + "ctrl shift UP", "selectPreviousRowExtendSelection", | |
| 1097 | + "ctrl shift KP_UP", "selectPreviousRowExtendSelection", | |
| 1098 | + "ctrl UP", "selectPreviousRowChangeLead", | |
| 1099 | + "ctrl KP_UP", "selectPreviousRowChangeLead", | |
| 1100 | + "HOME", "selectFirstColumn", | |
| 1101 | + "shift HOME", "selectFirstColumnExtendSelection", | |
| 1102 | + "ctrl shift HOME", "selectFirstRowExtendSelection", | |
| 1103 | + "ctrl HOME", "selectFirstRow", | |
| 1104 | + "END", "selectLastColumn", | |
| 1105 | + "shift END", "selectLastColumnExtendSelection", | |
| 1106 | + "ctrl shift END", "selectLastRowExtendSelection", | |
| 1107 | + "ctrl END", "selectLastRow", | |
| 1108 | + "PAGE_UP", "scrollUpChangeSelection", | |
| 1109 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 1110 | + "ctrl shift PAGE_UP", "scrollLeftExtendSelection", | |
| 1111 | + "ctrl PAGE_UP", "scrollLeftChangeSelection", | |
| 1112 | + "PAGE_DOWN", "scrollDownChangeSelection", | |
| 1113 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 1114 | + "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", | |
| 1115 | + "ctrl PAGE_DOWN", "scrollRightChangeSelection", | |
| 1116 | + "TAB", "selectNextColumnCell", | |
| 1117 | + "shift TAB", "selectPreviousColumnCell", | |
| 1118 | + "ENTER", "selectNextRowCell", | |
| 1119 | + "shift ENTER", "selectPreviousRowCell", | |
| 1120 | + "ctrl A", "selectAll", | |
| 1121 | + "ctrl SLASH", "selectAll", | |
| 1122 | + "ctrl BACK_SLASH", "clearSelection", | |
| 1123 | + "ESCAPE", "cancel", | |
| 1124 | + "F2", "startEditing", | |
| 1125 | + "SPACE", "addToSelection", | |
| 1126 | + "ctrl SPACE", "toggleAndAnchor", | |
| 1127 | + "shift SPACE", "extendTo", | |
| 1128 | + "ctrl shift SPACE", "moveSelectionTo", | |
| 1129 | + "F8", "focusHeader" | |
| 1130 | + }), | |
| 1131 | + "Table.ancestorInputMap.RightToLeft", | |
| 1132 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1133 | + "RIGHT", "selectPreviousColumn", | |
| 1134 | + "KP_RIGHT", "selectPreviousColumn", | |
| 1135 | + "shift RIGHT", "selectPreviousColumnExtendSelection", | |
| 1136 | + "shift KP_RIGHT", "selectPreviousColumnExtendSelection", | |
| 1137 | + "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", | |
| 1138 | + "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", | |
| 1139 | + "shift RIGHT", "selectPreviousColumnChangeLead", | |
| 1140 | + "shift KP_RIGHT", "selectPreviousColumnChangeLead", | |
| 1141 | + "LEFT", "selectNextColumn", | |
| 1142 | + "KP_LEFT", "selectNextColumn", | |
| 1143 | + "shift LEFT", "selectNextColumnExtendSelection", | |
| 1144 | + "shift KP_LEFT", "selectNextColumnExtendSelection", | |
| 1145 | + "ctrl shift LEFT", "selectNextColumnExtendSelection", | |
| 1146 | + "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", | |
| 1147 | + "ctrl LEFT", "selectNextColumnChangeLead", | |
| 1148 | + "ctrl KP_LEFT", "selectNextColumnChangeLead", | |
| 1149 | + "ctrl PAGE_UP", "scrollRightChangeSelection", | |
| 1150 | + "ctrl PAGE_DOWN", "scrollLeftChangeSelection", | |
| 1151 | + "ctrl shift PAGE_UP", "scrollRightExtendSelection", | |
| 1152 | + "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection", | |
| 1153 | + }), | |
| 1154 | + "Table.font", new FontLazyValue(Region.TABLE), | |
| 1155 | + "Table.ascendingSortIcon", new GTKStyle.GTKLazyValue( | |
| 1156 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 1157 | + "getAscendingSortIcon"), | |
| 1158 | + "Table.descendingSortIcon", new GTKStyle.GTKLazyValue( | |
| 1159 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 1160 | + "getDescendingSortIcon"), | |
| 1161 | + | |
| 1162 | + "TableHeader.font", new FontLazyValue(Region.TABLE_HEADER), | |
| 1163 | + "TableHeader.alignSorterArrow", Boolean.TRUE, | |
| 1164 | + | |
| 1165 | + "TextArea.caretForeground", caretColor, | |
| 1166 | + "TextArea.caretAspectRatio", defaultCaretAspectRatio, | |
| 1167 | + "TextArea.caretBlinkRate", caretBlinkRate, | |
| 1168 | + "TextArea.margin", zeroInsets, | |
| 1169 | + "TextArea.focusInputMap", multilineInputMap, | |
| 1170 | + "TextArea.font", new FontLazyValue(Region.TEXT_AREA), | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + "TextField.caretForeground", caretColor, | |
| 1174 | + "TextField.caretAspectRatio", defaultCaretAspectRatio, | |
| 1175 | + "TextField.caretBlinkRate", caretBlinkRate, | |
| 1176 | + "TextField.margin", zeroInsets, | |
| 1177 | + "TextField.focusInputMap", fieldInputMap, | |
| 1178 | + "TextField.font", new FontLazyValue(Region.TEXT_FIELD), | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + "TextPane.caretForeground", caretColor, | |
| 1182 | + "TextPane.caretAspectRatio", defaultCaretAspectRatio, | |
| 1183 | + "TextPane.caretBlinkRate", caretBlinkRate, | |
| 1184 | + "TextPane.margin", editorMargin, | |
| 1185 | + "TextPane.focusInputMap", multilineInputMap, | |
| 1186 | + "TextPane.font", new FontLazyValue(Region.TEXT_PANE), | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + "TitledBorder.titleColor", controlText, | |
| 1190 | + "TitledBorder.border", new UIDefaults.LazyValue() { | |
| 1191 | + public Object createValue(UIDefaults table) { | |
| 1192 | + return new GTKPainter.TitledBorder(); | |
| 1193 | + } | |
| 1194 | + }, | |
| 1195 | + | |
| 1196 | + "ToggleButton.focusInputMap", | |
| 1197 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1198 | + "SPACE", "pressed", | |
| 1199 | + "released SPACE", "released" | |
| 1200 | + }), | |
| 1201 | + "ToggleButton.font", new FontLazyValue(Region.TOGGLE_BUTTON), | |
| 1202 | + "ToggleButton.margin", zeroInsets, | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + "ToolBar.separatorSize", new DimensionUIResource(10, 10), | |
| 1206 | + "ToolBar.handleIcon", new UIDefaults.ActiveValue() { | |
| 1207 | + public Object createValue(UIDefaults table) { | |
| 1208 | + return GTKIconFactory.getToolBarHandleIcon(); | |
| 1209 | + } | |
| 1210 | + }, | |
| 1211 | + "ToolBar.ancestorInputMap", | |
| 1212 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1213 | + "UP", "navigateUp", | |
| 1214 | + "KP_UP", "navigateUp", | |
| 1215 | + "DOWN", "navigateDown", | |
| 1216 | + "KP_DOWN", "navigateDown", | |
| 1217 | + "LEFT", "navigateLeft", | |
| 1218 | + "KP_LEFT", "navigateLeft", | |
| 1219 | + "RIGHT", "navigateRight", | |
| 1220 | + "KP_RIGHT", "navigateRight" | |
| 1221 | + }), | |
| 1222 | + "ToolBar.font", new FontLazyValue(Region.TOOL_BAR), | |
| 1223 | + | |
| 1224 | + "ToolTip.font", new FontLazyValue(Region.TOOL_TIP), | |
| 1225 | + | |
| 1226 | + "Tree.padding", Integer.valueOf(4), | |
| 1227 | + "Tree.background", tableBg, | |
| 1228 | + "Tree.drawHorizontalLines", Boolean.FALSE, | |
| 1229 | + "Tree.drawVerticalLines", Boolean.FALSE, | |
| 1230 | + "Tree.rowHeight", Integer.valueOf(-1), | |
| 1231 | + "Tree.scrollsOnExpand", Boolean.FALSE, | |
| 1232 | + "Tree.expanderSize", Integer.valueOf(10), | |
| 1233 | + "Tree.repaintWholeRow", Boolean.TRUE, | |
| 1234 | + "Tree.closedIcon", null, | |
| 1235 | + "Tree.leafIcon", null, | |
| 1236 | + "Tree.openIcon", null, | |
| 1237 | + "Tree.expandedIcon", new GTKStyle.GTKLazyValue( | |
| 1238 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 1239 | + "getTreeExpandedIcon"), | |
| 1240 | + "Tree.collapsedIcon", new GTKStyle.GTKLazyValue( | |
| 1241 | + "com.sun.java.swing.plaf.gtk.GTKIconFactory", | |
| 1242 | + "getTreeCollapsedIcon"), | |
| 1243 | + "Tree.leftChildIndent", Integer.valueOf(2), | |
| 1244 | + "Tree.rightChildIndent", Integer.valueOf(12), | |
| 1245 | + "Tree.scrollsHorizontallyAndVertically", Boolean.FALSE, | |
| 1246 | + "Tree.drawsFocusBorder", Boolean.TRUE, | |
| 1247 | + "Tree.focusInputMap", | |
| 1248 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1249 | + "ctrl C", "copy", | |
| 1250 | + "ctrl V", "paste", | |
| 1251 | + "ctrl X", "cut", | |
| 1252 | + "COPY", "copy", | |
| 1253 | + "PASTE", "paste", | |
| 1254 | + "CUT", "cut", | |
| 1255 | + "control INSERT", "copy", | |
| 1256 | + "shift INSERT", "paste", | |
| 1257 | + "shift DELETE", "cut", | |
| 1258 | + "UP", "selectPrevious", | |
| 1259 | + "KP_UP", "selectPrevious", | |
| 1260 | + "shift UP", "selectPreviousExtendSelection", | |
| 1261 | + "shift KP_UP", "selectPreviousExtendSelection", | |
| 1262 | + "ctrl shift UP", "selectPreviousExtendSelection", | |
| 1263 | + "ctrl shift KP_UP", "selectPreviousExtendSelection", | |
| 1264 | + "ctrl UP", "selectPreviousChangeLead", | |
| 1265 | + "ctrl KP_UP", "selectPreviousChangeLead", | |
| 1266 | + "DOWN", "selectNext", | |
| 1267 | + "KP_DOWN", "selectNext", | |
| 1268 | + "shift DOWN", "selectNextExtendSelection", | |
| 1269 | + "shift KP_DOWN", "selectNextExtendSelection", | |
| 1270 | + "ctrl shift DOWN", "selectNextExtendSelection", | |
| 1271 | + "ctrl shift KP_DOWN", "selectNextExtendSelection", | |
| 1272 | + "ctrl DOWN", "selectNextChangeLead", | |
| 1273 | + "ctrl KP_DOWN", "selectNextChangeLead", | |
| 1274 | + "RIGHT", "selectChild", | |
| 1275 | + "KP_RIGHT", "selectChild", | |
| 1276 | + "LEFT", "selectParent", | |
| 1277 | + "KP_LEFT", "selectParent", | |
| 1278 | + "typed +", "expand", | |
| 1279 | + "typed -", "collapse", | |
| 1280 | + "BACK_SPACE", "moveSelectionToParent", | |
| 1281 | + "PAGE_UP", "scrollUpChangeSelection", | |
| 1282 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 1283 | + "ctrl shift PAGE_UP", "scrollUpExtendSelection", | |
| 1284 | + "ctrl PAGE_UP", "scrollUpChangeLead", | |
| 1285 | + "PAGE_DOWN", "scrollDownChangeSelection", | |
| 1286 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 1287 | + "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 1288 | + "ctrl PAGE_DOWN", "scrollDownChangeLead", | |
| 1289 | + "HOME", "selectFirst", | |
| 1290 | + "shift HOME", "selectFirstExtendSelection", | |
| 1291 | + "ctrl shift HOME", "selectFirstExtendSelection", | |
| 1292 | + "ctrl HOME", "selectFirstChangeLead", | |
| 1293 | + "END", "selectLast", | |
| 1294 | + "shift END", "selectLastExtendSelection", | |
| 1295 | + "ctrl shift END", "selectLastExtendSelection", | |
| 1296 | + "ctrl END", "selectLastChangeLead", | |
| 1297 | + "F2", "startEditing", | |
| 1298 | + "ctrl A", "selectAll", | |
| 1299 | + "ctrl SLASH", "selectAll", | |
| 1300 | + "ctrl BACK_SLASH", "clearSelection", | |
| 1301 | + "ctrl LEFT", "scrollLeft", | |
| 1302 | + "ctrl KP_LEFT", "scrollLeft", | |
| 1303 | + "ctrl RIGHT", "scrollRight", | |
| 1304 | + "ctrl KP_RIGHT", "scrollRight", | |
| 1305 | + "SPACE", "addToSelection", | |
| 1306 | + "ctrl SPACE", "toggleAndAnchor", | |
| 1307 | + "shift SPACE", "extendTo", | |
| 1308 | + "ctrl shift SPACE", "moveSelectionTo" | |
| 1309 | + }), | |
| 1310 | + "Tree.focusInputMap.RightToLeft", | |
| 1311 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1312 | + "RIGHT", "selectParent", | |
| 1313 | + "KP_RIGHT", "selectParent", | |
| 1314 | + "LEFT", "selectChild", | |
| 1315 | + "KP_LEFT", "selectChild", | |
| 1316 | + }), | |
| 1317 | + "Tree.ancestorInputMap", | |
| 1318 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1319 | + "ESCAPE", "cancel" | |
| 1320 | + }), | |
| 1321 | + "Tree.font", new FontLazyValue(Region.TREE), | |
| 1322 | + | |
| 1323 | + "Viewport.font", new FontLazyValue(Region.VIEWPORT) | |
| 1324 | + }; | |
| 1325 | + table.putDefaults(defaults); | |
| 1326 | + | |
| 1327 | + if (fallbackFont != null) { | |
| 1328 | + table.put("TitledBorder.font", fallbackFont); | |
| 1329 | + } | |
| 1330 | + table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); | |
| 1331 | + } | |
| 1332 | + | |
| 1333 | + protected void initSystemColorDefaults(UIDefaults table) { | |
| 1334 | + GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory(); | |
| 1335 | + GTKStyle windowStyle = | |
| 1336 | + (GTKStyle)factory.getStyle(null, Region.INTERNAL_FRAME); | |
| 1337 | + table.put("window", windowStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1338 | + GTKColorType.BACKGROUND)); | |
| 1339 | + table.put("windowText", windowStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1340 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1341 | + | |
| 1342 | + GTKStyle entryStyle = (GTKStyle)factory.getStyle(null, Region.TEXT_FIELD); | |
| 1343 | + table.put("text", entryStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1344 | + GTKColorType.TEXT_BACKGROUND)); | |
| 1345 | + table.put("textText", entryStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1346 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1347 | + table.put("textHighlight", | |
| 1348 | + entryStyle.getGTKColor(SynthConstants.SELECTED, | |
| 1349 | + GTKColorType.TEXT_BACKGROUND)); | |
| 1350 | + table.put("textHighlightText", | |
| 1351 | + entryStyle.getGTKColor(SynthConstants.SELECTED, | |
| 1352 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1353 | + table.put("textInactiveText", | |
| 1354 | + entryStyle.getGTKColor(SynthConstants.DISABLED, | |
| 1355 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1356 | + Object caretColor = | |
| 1357 | + entryStyle.getClassSpecificValue("cursor-color"); | |
| 1358 | + if (caretColor == null) { | |
| 1359 | + caretColor = GTKStyle.BLACK_COLOR; | |
| 1360 | + } | |
| 1361 | + table.put("caretColor", caretColor); | |
| 1362 | + | |
| 1363 | + GTKStyle menuStyle = (GTKStyle)factory.getStyle(null, Region.MENU_ITEM); | |
| 1364 | + table.put("menu", menuStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1365 | + GTKColorType.BACKGROUND)); | |
| 1366 | + table.put("menuText", menuStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1367 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1368 | + | |
| 1369 | + GTKStyle scrollbarStyle = (GTKStyle)factory.getStyle(null, Region.SCROLL_BAR); | |
| 1370 | + table.put("scrollbar", scrollbarStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1371 | + GTKColorType.BACKGROUND)); | |
| 1372 | + | |
| 1373 | + GTKStyle infoStyle = (GTKStyle)factory.getStyle(null, Region.OPTION_PANE); | |
| 1374 | + table.put("info", infoStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1375 | + GTKColorType.BACKGROUND)); | |
| 1376 | + table.put("infoText", infoStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1377 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1378 | + | |
| 1379 | + GTKStyle desktopStyle = (GTKStyle)factory.getStyle(null, Region.DESKTOP_PANE); | |
| 1380 | + table.put("desktop", desktopStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1381 | + GTKColorType.BACKGROUND)); | |
| 1382 | + | |
| 1383 | + // colors specific only for GTK | |
| 1384 | + // It is impossible to create a simple GtkWidget without specifying the | |
| 1385 | + // type. So for GtkWidget we can use any appropriate concrete type of | |
| 1386 | + // wigdet. LABEL in this case. | |
| 1387 | + GTKStyle widgetStyle = (GTKStyle)factory.getStyle(null, Region.LABEL); | |
| 1388 | + Color bg = widgetStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1389 | + GTKColorType.BACKGROUND); | |
| 1390 | + table.put("control", bg); | |
| 1391 | + table.put("controlHighlight", bg); | |
| 1392 | + table.put("controlText", widgetStyle.getGTKColor(SynthConstants.ENABLED, | |
| 1393 | + GTKColorType.TEXT_FOREGROUND)); | |
| 1394 | + table.put("controlLtHighlight", widgetStyle.getGTKColor( | |
| 1395 | + SynthConstants.ENABLED, GTKColorType.LIGHT)); | |
| 1396 | + table.put("controlShadow", widgetStyle.getGTKColor( | |
| 1397 | + SynthConstants.ENABLED, GTKColorType.DARK)); | |
| 1398 | + table.put("controlDkShadow", widgetStyle.getGTKColor( | |
| 1399 | + SynthConstants.ENABLED, GTKColorType.BLACK)); | |
| 1400 | + table.put("light", widgetStyle.getGTKColor( | |
| 1401 | + SynthConstants.ENABLED, GTKColorType.LIGHT)); | |
| 1402 | + table.put("mid", widgetStyle.getGTKColor( | |
| 1403 | + SynthConstants.ENABLED, GTKColorType.MID)); | |
| 1404 | + table.put("dark", widgetStyle.getGTKColor( | |
| 1405 | + SynthConstants.ENABLED, GTKColorType.DARK)); | |
| 1406 | + table.put("black", widgetStyle.getGTKColor( | |
| 1407 | + SynthConstants.ENABLED, GTKColorType.BLACK)); | |
| 1408 | + table.put("white", widgetStyle.getGTKColor( | |
| 1409 | + SynthConstants.ENABLED, GTKColorType.WHITE)); | |
| 1410 | + } | |
| 1411 | + | |
| 1412 | + /** | |
| 1413 | + * Creates the GTK look and feel class for the passed in Component. | |
| 1414 | + */ | |
| 1415 | + public static ComponentUI createUI(JComponent c) { | |
| 1416 | + String key = c.getUIClassID().intern(); | |
| 1417 | + | |
| 1418 | + if (key == "FileChooserUI") { | |
| 1419 | + return GTKFileChooserUI.createUI(c); | |
| 1420 | + } | |
| 1421 | + return SynthLookAndFeel.createUI(c); | |
| 1422 | + } | |
| 1423 | + | |
| 1424 | + /** | |
| 1425 | + * Returns the cached gtkThemeName | |
| 1426 | + */ | |
| 1427 | + static String getGtkThemeName() { | |
| 1428 | + return gtkThemeName; | |
| 1429 | + } | |
| 1430 | + | |
| 1431 | + static boolean isLeftToRight(Component c) { | |
| 1432 | + return c.getComponentOrientation().isLeftToRight(); | |
| 1433 | + } | |
| 1434 | + | |
| 1435 | + public void initialize() { | |
| 1436 | + /* | |
| 1437 | + * We need to call loadGTK() to ensure that the native GTK | |
| 1438 | + * libraries are loaded. It is very unlikely that this call will | |
| 1439 | + * fail (since we've already verified native GTK support in | |
| 1440 | + * isSupportedLookAndFeel()), but we can throw an error in the | |
| 1441 | + * failure situation just in case. | |
| 1442 | + */ | |
| 1443 | + Toolkit toolkit = Toolkit.getDefaultToolkit(); | |
| 1444 | + if (toolkit instanceof UNIXToolkit && | |
| 1445 | + !((UNIXToolkit)toolkit).loadGTK()) | |
| 1446 | + { | |
| 1447 | + throw new InternalError("Unable to load native GTK libraries"); | |
| 1448 | + } | |
| 1449 | + | |
| 1450 | + super.initialize(); | |
| 1451 | + inInitialize = true; | |
| 1452 | + loadStyles(); | |
| 1453 | + inInitialize = false; | |
| 1454 | + | |
| 1455 | + /* | |
| 1456 | + * Check if system AA font settings should be used. | |
| 1457 | + * Sun's JDS (for Linux and Solaris) ships with high quality CJK | |
| 1458 | + * fonts and specifies via fontconfig that these be rendered in | |
| 1459 | + * B&W to take advantage of the embedded bitmaps. | |
| 1460 | + * If is a Sun CJK locale or remote display, indicate by the condition | |
| 1461 | + * variable that in this case the L&F recommends ignoring desktop | |
| 1462 | + * settings. On other Unixes (eg Linux) this doesn't apply. | |
| 1463 | + * REMIND 1: The isSunCJK test is really just a place holder | |
| 1464 | + * until we can properly query fontconfig and use the properties | |
| 1465 | + * set for specific fonts. | |
| 1466 | + * REMIND 2: See comment on isLocalDisplay() definition regarding | |
| 1467 | + * XRender. | |
| 1468 | + */ | |
| 1469 | + gtkAAFontSettingsCond = !isSunCJK && SwingUtilities2.isLocalDisplay(); | |
| 1470 | + aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(gtkAAFontSettingsCond); | |
| 1471 | + } | |
| 1472 | + | |
| 1473 | + static ReferenceQueue<GTKLookAndFeel> queue = new ReferenceQueue<GTKLookAndFeel>(); | |
| 1474 | + | |
| 1475 | + private static void flushUnreferenced() { | |
| 1476 | + WeakPCL pcl; | |
| 1477 | + | |
| 1478 | + while ((pcl = (WeakPCL)queue.poll()) != null) { | |
| 1479 | + pcl.dispose(); | |
| 1480 | + } | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + static class WeakPCL extends WeakReference<GTKLookAndFeel> implements | |
| 1484 | + PropertyChangeListener { | |
| 1485 | + private Toolkit kit; | |
| 1486 | + private String key; | |
| 1487 | + | |
| 1488 | + WeakPCL(GTKLookAndFeel target, Toolkit kit, String key) { | |
| 1489 | + super(target, queue); | |
| 1490 | + this.kit = kit; | |
| 1491 | + this.key = key; | |
| 1492 | + } | |
| 1493 | + | |
| 1494 | + public String getKey() { return key; } | |
| 1495 | + | |
| 1496 | + public void propertyChange(final PropertyChangeEvent pce) { | |
| 1497 | + final GTKLookAndFeel lnf = get(); | |
| 1498 | + | |
| 1499 | + if (lnf == null || UIManager.getLookAndFeel() != lnf) { | |
| 1500 | + // The property was GC'ed, we're no longer interested in | |
| 1501 | + // PropertyChanges, remove the listener. | |
| 1502 | + dispose(); | |
| 1503 | + } | |
| 1504 | + else { | |
| 1505 | + // We are using invokeLater here because we are getting called | |
| 1506 | + // on the AWT-Motif thread which can cause a deadlock. | |
| 1507 | + SwingUtilities.invokeLater(new Runnable() { | |
| 1508 | + public void run() { | |
| 1509 | + String name = pce.getPropertyName(); | |
| 1510 | + /* We are listening for GTK desktop text AA settings: | |
| 1511 | + * "gnome.Xft/Antialias" and "gnome.Xft/RGBA". | |
| 1512 | + * However we don't need to read these here as | |
| 1513 | + * the UIDefaults reads them and this event causes | |
| 1514 | + * those to be reinitialised. | |
| 1515 | + */ | |
| 1516 | + if ("gnome.Net/ThemeName".equals(name)) { | |
| 1517 | + GTKEngine.INSTANCE.themeChanged(); | |
| 1518 | + GTKIconFactory.resetIcons(); | |
| 1519 | + } | |
| 1520 | + lnf.loadStyles(); | |
| 1521 | + Window appWindows[] = Window.getWindows(); | |
| 1522 | + for (int i = 0; i < appWindows.length; i++) { | |
| 1523 | + SynthLookAndFeel.updateStyles(appWindows[i]); | |
| 1524 | + } | |
| 1525 | + } | |
| 1526 | + }); | |
| 1527 | + } | |
| 1528 | + } | |
| 1529 | + | |
| 1530 | + void dispose() { | |
| 1531 | + kit.removePropertyChangeListener(key, this); | |
| 1532 | + } | |
| 1533 | + } | |
| 1534 | + | |
| 1535 | + public boolean isSupportedLookAndFeel() { | |
| 1536 | + Toolkit toolkit = Toolkit.getDefaultToolkit(); | |
| 1537 | + return (toolkit instanceof SunToolkit && | |
| 1538 | + ((SunToolkit)toolkit).isNativeGTKAvailable()); | |
| 1539 | + } | |
| 1540 | + | |
| 1541 | + public boolean isNativeLookAndFeel() { | |
| 1542 | + return true; | |
| 1543 | + } | |
| 1544 | + | |
| 1545 | + public String getDescription() { | |
| 1546 | + return "GTK look and feel"; | |
| 1547 | + } | |
| 1548 | + | |
| 1549 | + public String getName() { | |
| 1550 | + return "GTK look and feel"; | |
| 1551 | + } | |
| 1552 | + | |
| 1553 | + public String getID() { | |
| 1554 | + return "GTK"; | |
| 1555 | + } | |
| 1556 | + | |
| 1557 | + // Subclassed to pass in false to the superclass, we don't want to try | |
| 1558 | + // and load the system colors. | |
| 1559 | + protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative) { | |
| 1560 | + super.loadSystemColors(table, systemColors, false); | |
| 1561 | + } | |
| 1562 | + | |
| 1563 | + private void loadStyles() { | |
| 1564 | + gtkThemeName = (String)Toolkit.getDefaultToolkit(). | |
| 1565 | + getDesktopProperty("gnome.Net/ThemeName"); | |
| 1566 | + | |
| 1567 | + setStyleFactory(getGTKStyleFactory()); | |
| 1568 | + | |
| 1569 | + // If we are in initialize initializations will be | |
| 1570 | + // called later, don't do it now. | |
| 1571 | + if (!inInitialize) { | |
| 1572 | + UIDefaults table = UIManager.getLookAndFeelDefaults(); | |
| 1573 | + initSystemColorDefaults(table); | |
| 1574 | + initComponentDefaults(table); | |
| 1575 | + } | |
| 1576 | + } | |
| 1577 | + | |
| 1578 | + private GTKStyleFactory getGTKStyleFactory() { | |
| 1579 | + | |
| 1580 | + GTKEngine engine = GTKEngine.INSTANCE; | |
| 1581 | + Object iconSizes = engine.getSetting(GTKEngine.Settings.GTK_ICON_SIZES); | |
| 1582 | + if (iconSizes instanceof String) { | |
| 1583 | + if (!configIconSizes((String)iconSizes)) { | |
| 1584 | + System.err.println("Error parsing gtk-icon-sizes string: '" + iconSizes + "'"); | |
| 1585 | + } | |
| 1586 | + } | |
| 1587 | + | |
| 1588 | + // Desktop property appears to have preference over rc font. | |
| 1589 | + Object fontName = Toolkit.getDefaultToolkit().getDesktopProperty( | |
| 1590 | + "gnome.Gtk/FontName"); | |
| 1591 | + | |
| 1592 | + if (!(fontName instanceof String)) { | |
| 1593 | + fontName = engine.getSetting(GTKEngine.Settings.GTK_FONT_NAME); | |
| 1594 | + if (!(fontName instanceof String)) { | |
| 1595 | + fontName = "sans 10"; | |
| 1596 | + } | |
| 1597 | + } | |
| 1598 | + | |
| 1599 | + if (styleFactory == null) { | |
| 1600 | + styleFactory = new GTKStyleFactory(); | |
| 1601 | + } | |
| 1602 | + | |
| 1603 | + Font defaultFont = PangoFonts.lookupFont((String)fontName); | |
| 1604 | + fallbackFont = defaultFont; | |
| 1605 | + styleFactory.initStyles(defaultFont); | |
| 1606 | + | |
| 1607 | + return styleFactory; | |
| 1608 | + } | |
| 1609 | + | |
| 1610 | + private boolean configIconSizes(String sizeString) { | |
| 1611 | + String[] sizes = sizeString.split(":"); | |
| 1612 | + for (int i = 0; i < sizes.length; i++) { | |
| 1613 | + String[] splits = sizes[i].split("="); | |
| 1614 | + | |
| 1615 | + if (splits.length != 2) { | |
| 1616 | + return false; | |
| 1617 | + } | |
| 1618 | + | |
| 1619 | + String size = splits[0].trim().intern(); | |
| 1620 | + if (size.length() < 1) { | |
| 1621 | + return false; | |
| 1622 | + } | |
| 1623 | + | |
| 1624 | + splits = splits[1].split(","); | |
| 1625 | + | |
| 1626 | + if (splits.length != 2) { | |
| 1627 | + return false; | |
| 1628 | + } | |
| 1629 | + | |
| 1630 | + String width = splits[0].trim(); | |
| 1631 | + String height = splits[1].trim(); | |
| 1632 | + | |
| 1633 | + if (width.length() < 1 || height.length() < 1) { | |
| 1634 | + return false; | |
| 1635 | + } | |
| 1636 | + | |
| 1637 | + int w; | |
| 1638 | + int h; | |
| 1639 | + | |
| 1640 | + try { | |
| 1641 | + w = Integer.parseInt(width); | |
| 1642 | + h = Integer.parseInt(height); | |
| 1643 | + } catch (NumberFormatException nfe) { | |
| 1644 | + return false; | |
| 1645 | + } | |
| 1646 | + | |
| 1647 | + if (w > 0 && h > 0) { | |
| 1648 | + int type = GTKStyle.GTKStockIconInfo.getIconType(size); | |
| 1649 | + GTKStyle.GTKStockIconInfo.setIconSize(type, w, h); | |
| 1650 | + } else { | |
| 1651 | + System.err.println("Invalid size in gtk-icon-sizes: " + w + "," + h); | |
| 1652 | + } | |
| 1653 | + } | |
| 1654 | + | |
| 1655 | + return true; | |
| 1656 | + } | |
| 1657 | + | |
| 1658 | + /** | |
| 1659 | + * Returns whether or not the UIs should update their | |
| 1660 | + * <code>SynthStyles</code> from the <code>SynthStyleFactory</code> | |
| 1661 | + * when the ancestor of the Component changes. | |
| 1662 | + * | |
| 1663 | + * @return whether or not the UIs should update their | |
| 1664 | + * <code>SynthStyles</code> from the <code>SynthStyleFactory</code> | |
| 1665 | + * when the ancestor changed. | |
| 1666 | + */ | |
| 1667 | + public boolean shouldUpdateStyleOnAncestorChanged() { | |
| 1668 | + return true; | |
| 1669 | + } | |
| 1670 | + | |
| 1671 | + /** | |
| 1672 | + * {@inheritDoc} | |
| 1673 | + */ | |
| 1674 | + public LayoutStyle getLayoutStyle() { | |
| 1675 | + return GnomeLayoutStyle.INSTANCE; | |
| 1676 | + } | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + /** | |
| 1680 | + * Gnome layout style. From: | |
| 1681 | + * http://developer.gnome.org/projects/gup/hig/2.0/design-window.html#window-layout-spacing | |
| 1682 | + * You'll notice this doesn't do the radiobutton/checkbox border | |
| 1683 | + * adjustments that windows/metal do. This is because gtk doesn't | |
| 1684 | + * provide margins/insets for checkbox/radiobuttons. | |
| 1685 | + */ | |
| 1686 | + private static class GnomeLayoutStyle extends DefaultLayoutStyle { | |
| 1687 | + private static GnomeLayoutStyle INSTANCE = new GnomeLayoutStyle(); | |
| 1688 | + | |
| 1689 | + @Override | |
| 1690 | + public int getPreferredGap(JComponent component1, | |
| 1691 | + JComponent component2, ComponentPlacement type, int position, | |
| 1692 | + Container parent) { | |
| 1693 | + // Checks args | |
| 1694 | + super.getPreferredGap(component1, component2, type, position, | |
| 1695 | + parent); | |
| 1696 | + | |
| 1697 | + switch(type) { | |
| 1698 | + case INDENT: | |
| 1699 | + if (position == SwingConstants.EAST || | |
| 1700 | + position == SwingConstants.WEST) { | |
| 1701 | + // Indent group members 12 pixels to denote hierarchy and | |
| 1702 | + // association. | |
| 1703 | + return 12; | |
| 1704 | + } | |
| 1705 | + // Fall through to related | |
| 1706 | + // As a basic rule of thumb, leave space between user | |
| 1707 | + // interface components in increments of 6 pixels, going up as | |
| 1708 | + // the relationship between related elements becomes more | |
| 1709 | + // distant. For example, between icon labels and associated | |
| 1710 | + // graphics within an icon, 6 pixels are adequate. Between | |
| 1711 | + // labels and associated components, leave 12 horizontal | |
| 1712 | + // pixels. For vertical spacing between groups of components, | |
| 1713 | + // 18 pixels is adequate. | |
| 1714 | + // | |
| 1715 | + // The first part of this is handled automatically by Icon (which | |
| 1716 | + // won't give you 6 pixels). | |
| 1717 | + case RELATED: | |
| 1718 | + if (isLabelAndNonlabel(component1, component2, position)) { | |
| 1719 | + return 12; | |
| 1720 | + } | |
| 1721 | + return 6; | |
| 1722 | + case UNRELATED: | |
| 1723 | + return 12; | |
| 1724 | + } | |
| 1725 | + return 0; | |
| 1726 | + } | |
| 1727 | + | |
| 1728 | + @Override | |
| 1729 | + public int getContainerGap(JComponent component, int position, | |
| 1730 | + Container parent) { | |
| 1731 | + // Checks args | |
| 1732 | + super.getContainerGap(component, position, parent); | |
| 1733 | + // A general padding of 12 pixels is | |
| 1734 | + // recommended between the contents of a dialog window and the | |
| 1735 | + // window borders. | |
| 1736 | + return 12; | |
| 1737 | + } | |
| 1738 | + } | |
| 1739 | +} | |
| @@ -0,0 +1,1497 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import sun.awt.UNIXToolkit; | |
| 28 | + | |
| 29 | +import javax.swing.plaf.synth.*; | |
| 30 | +import java.awt.*; | |
| 31 | +import javax.swing.*; | |
| 32 | +import javax.swing.border.*; | |
| 33 | +import javax.swing.plaf.*; | |
| 34 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType; | |
| 35 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle; | |
| 36 | +import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation; | |
| 37 | +import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType; | |
| 38 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType; | |
| 39 | +import java.lang.reflect.InvocationTargetException; | |
| 40 | +import java.lang.reflect.Method; | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * @author Joshua Outwater | |
| 44 | + * @author Scott Violet | |
| 45 | + */ | |
| 46 | +// Need to support: | |
| 47 | +// default_outside_border: Insets when default. | |
| 48 | +// interior_focus: Indicates if focus should appear inside border, or | |
| 49 | +// outside border. | |
| 50 | +// focus-line-width: Integer giving size of focus border | |
| 51 | +// focus-padding: Integer giving padding between border and focus | |
| 52 | +// indicator. | |
| 53 | +// focus-line-pattern: | |
| 54 | +// | |
| 55 | +class GTKPainter extends SynthPainter { | |
| 56 | + private static final PositionType[] POSITIONS = { | |
| 57 | + PositionType.BOTTOM, PositionType.RIGHT, | |
| 58 | + PositionType.TOP, PositionType.LEFT | |
| 59 | + }; | |
| 60 | + | |
| 61 | + private static final ShadowType SHADOWS[] = { | |
| 62 | + ShadowType.NONE, ShadowType.IN, ShadowType.OUT, | |
| 63 | + ShadowType.ETCHED_IN, ShadowType.OUT | |
| 64 | + }; | |
| 65 | + | |
| 66 | + private final static GTKEngine ENGINE = GTKEngine.INSTANCE; | |
| 67 | + final static GTKPainter INSTANCE = new GTKPainter(); | |
| 68 | + | |
| 69 | + private GTKPainter() { | |
| 70 | + } | |
| 71 | + | |
| 72 | + private String getName(SynthContext context) { | |
| 73 | + return (context.getRegion().isSubregion()) ? null : | |
| 74 | + context.getComponent().getName(); | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void paintCheckBoxBackground(SynthContext context, | |
| 78 | + Graphics g, int x, int y, int w, int h) { | |
| 79 | + paintRadioButtonBackground(context, g, x, y, w, h); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void paintCheckBoxMenuItemBackground(SynthContext context, | |
| 83 | + Graphics g, int x, int y, int w, int h) { | |
| 84 | + paintRadioButtonMenuItemBackground(context, g, x, y, w, h); | |
| 85 | + } | |
| 86 | + | |
| 87 | + // FORMATTED_TEXT_FIELD | |
| 88 | + public void paintFormattedTextFieldBackground(SynthContext context, | |
| 89 | + Graphics g, int x, int y, | |
| 90 | + int w, int h) { | |
| 91 | + paintTextBackground(context, g, x, y, w, h); | |
| 92 | + } | |
| 93 | + | |
| 94 | + // | |
| 95 | + // TOOL_BAR_DRAG_WINDOW | |
| 96 | + // | |
| 97 | + public void paintToolBarDragWindowBackground(SynthContext context, | |
| 98 | + Graphics g, int x, int y, | |
| 99 | + int w, int h) { | |
| 100 | + paintToolBarBackground(context, g, x, y, w, h); | |
| 101 | + } | |
| 102 | + | |
| 103 | + | |
| 104 | + // | |
| 105 | + // TOOL_BAR | |
| 106 | + // | |
| 107 | + public void paintToolBarBackground(SynthContext context, | |
| 108 | + Graphics g, int x, int y, | |
| 109 | + int w, int h) { | |
| 110 | + Region id = context.getRegion(); | |
| 111 | + int state = context.getComponentState(); | |
| 112 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 113 | + int orientation = ((JToolBar)context.getComponent()).getOrientation(); | |
| 114 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 115 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, | |
| 116 | + state, orientation)) | |
| 117 | + { | |
| 118 | + ENGINE.startPainting(g, x, y, w, h, id, state, orientation); | |
| 119 | + ENGINE.paintBox(g, context, id, gtkState, ShadowType.OUT, | |
| 120 | + "handlebox_bin", x, y, w, h); | |
| 121 | + ENGINE.finishPainting(); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + public void paintToolBarContentBackground(SynthContext context, | |
| 127 | + Graphics g, | |
| 128 | + int x, int y, int w, int h) { | |
| 129 | + Region id = context.getRegion(); | |
| 130 | + int orientation = ((JToolBar)context.getComponent()).getOrientation(); | |
| 131 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 132 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, orientation)) { | |
| 133 | + ENGINE.startPainting(g, x, y, w, h, id, orientation); | |
| 134 | + ENGINE.paintBox(g, context, id, SynthConstants.ENABLED, | |
| 135 | + ShadowType.OUT, "toolbar", x, y, w, h); | |
| 136 | + ENGINE.finishPainting(); | |
| 137 | + } | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + // | |
| 142 | + // PASSWORD_FIELD | |
| 143 | + // | |
| 144 | + public void paintPasswordFieldBackground(SynthContext context, | |
| 145 | + Graphics g, int x, int y, | |
| 146 | + int w, int h) { | |
| 147 | + paintTextBackground(context, g, x, y, w, h); | |
| 148 | + } | |
| 149 | + | |
| 150 | + // | |
| 151 | + // TEXT_FIELD | |
| 152 | + // | |
| 153 | + public void paintTextFieldBackground(SynthContext context, Graphics g, | |
| 154 | + int x, int y, int w, int h) { | |
| 155 | + if (getName(context) == "Tree.cellEditor") { | |
| 156 | + paintTreeCellEditorBackground(context, g, x, y, w, h); | |
| 157 | + } else { | |
| 158 | + paintTextBackground(context, g, x, y, w, h); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + // | |
| 163 | + // RADIO_BUTTON | |
| 164 | + // | |
| 165 | + // NOTE: this is called for JCheckBox too | |
| 166 | + public void paintRadioButtonBackground(SynthContext context, | |
| 167 | + Graphics g, int x, int y, | |
| 168 | + int w, int h) { | |
| 169 | + Region id = context.getRegion(); | |
| 170 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 171 | + id, context.getComponentState()); | |
| 172 | + if (gtkState == SynthConstants.MOUSE_OVER) { | |
| 173 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 174 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 175 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 176 | + ENGINE.paintFlatBox(g, context, id, | |
| 177 | + SynthConstants.MOUSE_OVER, ShadowType.ETCHED_OUT, | |
| 178 | + "checkbutton", x, y, w, h, ColorType.BACKGROUND); | |
| 179 | + ENGINE.finishPainting(); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + // | |
| 186 | + // RADIO_BUTTON_MENU_ITEM | |
| 187 | + // | |
| 188 | + // NOTE: this is called for JCheckBoxMenuItem too | |
| 189 | + public void paintRadioButtonMenuItemBackground(SynthContext context, | |
| 190 | + Graphics g, int x, int y, | |
| 191 | + int w, int h) { | |
| 192 | + Region id = context.getRegion(); | |
| 193 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 194 | + id, context.getComponentState()); | |
| 195 | + if (gtkState == SynthConstants.MOUSE_OVER) { | |
| 196 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 197 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 198 | + ShadowType shadow = (GTKLookAndFeel.is2_2() ? | |
| 199 | + ShadowType.NONE : ShadowType.OUT); | |
| 200 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 201 | + ENGINE.paintBox(g, context, id, gtkState, | |
| 202 | + shadow, "menuitem", x, y, w, h); | |
| 203 | + ENGINE.finishPainting(); | |
| 204 | + } | |
| 205 | + } | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + // | |
| 210 | + // LABEL | |
| 211 | + // | |
| 212 | + public void paintLabelBackground(SynthContext context, | |
| 213 | + Graphics g, int x, int y, | |
| 214 | + int w, int h) { | |
| 215 | + String name = getName(context); | |
| 216 | + JComponent c = context.getComponent(); | |
| 217 | + Container container = c.getParent(); | |
| 218 | + | |
| 219 | + if (name == "TableHeader.renderer" || | |
| 220 | + name == "GTKFileChooser.directoryListLabel" || | |
| 221 | + name == "GTKFileChooser.fileListLabel") { | |
| 222 | + | |
| 223 | + paintButtonBackgroundImpl(context, g, Region.BUTTON, "button", | |
| 224 | + x, y, w, h, true, false, false, false); | |
| 225 | + } | |
| 226 | + /* | |
| 227 | + * If the label is a ListCellRenderer and it's in a container | |
| 228 | + * (CellRendererPane) which is in a JComboBox then we paint the label | |
| 229 | + * as a TextField like a gtk_entry for a combobox. | |
| 230 | + */ | |
| 231 | + else if (c instanceof ListCellRenderer && | |
| 232 | + container != null && | |
| 233 | + container.getParent() instanceof JComboBox ) { | |
| 234 | + paintTextBackground(context, g, x, y, w, h); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + // | |
| 239 | + // INTERNAL_FRAME | |
| 240 | + // | |
| 241 | + public void paintInternalFrameBorder(SynthContext context, | |
| 242 | + Graphics g, int x, int y, | |
| 243 | + int w, int h) { | |
| 244 | + Metacity.INSTANCE.paintFrameBorder(context, g, x, y, w, h); | |
| 245 | + } | |
| 246 | + | |
| 247 | + // | |
| 248 | + // DESKTOP_PANE | |
| 249 | + // | |
| 250 | + public void paintDesktopPaneBackground(SynthContext context, | |
| 251 | + Graphics g, int x, int y, | |
| 252 | + int w, int h) { | |
| 253 | + // Does not call into ENGINE for better performance | |
| 254 | + fillArea(context, g, x, y, w, h, ColorType.BACKGROUND); | |
| 255 | + } | |
| 256 | + | |
| 257 | + // | |
| 258 | + // DESKTOP_ICON | |
| 259 | + // | |
| 260 | + public void paintDesktopIconBorder(SynthContext context, | |
| 261 | + Graphics g, int x, int y, | |
| 262 | + int w, int h) { | |
| 263 | + Metacity.INSTANCE.paintFrameBorder(context, g, x, y, w, h); | |
| 264 | + } | |
| 265 | + | |
| 266 | + public void paintButtonBackground(SynthContext context, Graphics g, | |
| 267 | + int x, int y, int w, int h) { | |
| 268 | + String name = getName(context); | |
| 269 | + if (name != null && name.startsWith("InternalFrameTitlePane.")) { | |
| 270 | + Metacity.INSTANCE.paintButtonBackground(context, g, x, y, w, h); | |
| 271 | + | |
| 272 | + } else { | |
| 273 | + AbstractButton button = (AbstractButton)context.getComponent(); | |
| 274 | + boolean paintBG = button.isContentAreaFilled() && | |
| 275 | + button.isBorderPainted(); | |
| 276 | + boolean paintFocus = button.isFocusPainted(); | |
| 277 | + boolean defaultCapable = (button instanceof JButton) && | |
| 278 | + ((JButton)button).isDefaultCapable(); | |
| 279 | + boolean toolButton = (button.getParent() instanceof JToolBar); | |
| 280 | + paintButtonBackgroundImpl(context, g, Region.BUTTON, "button", | |
| 281 | + x, y, w, h, paintBG, paintFocus, defaultCapable, toolButton); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + | |
| 285 | + private void paintButtonBackgroundImpl(SynthContext context, Graphics g, | |
| 286 | + Region id, String detail, int x, int y, int w, int h, | |
| 287 | + boolean paintBackground, boolean paintFocus, | |
| 288 | + boolean defaultCapable, boolean toolButton) { | |
| 289 | + int state = context.getComponentState(); | |
| 290 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 291 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id, state, detail, | |
| 292 | + paintBackground, paintFocus, defaultCapable, toolButton)) { | |
| 293 | + return; | |
| 294 | + } | |
| 295 | + ENGINE.startPainting(g, x, y, w, h, id, state, detail, | |
| 296 | + paintBackground, paintFocus, defaultCapable, toolButton); | |
| 297 | + | |
| 298 | + // Paint the default indicator | |
| 299 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 300 | + if (defaultCapable && !toolButton) { | |
| 301 | + Insets defaultInsets = style.getClassSpecificInsetsValue( | |
| 302 | + context, "default-border", | |
| 303 | + GTKStyle.BUTTON_DEFAULT_BORDER_INSETS); | |
| 304 | + | |
| 305 | + if (paintBackground && (state & SynthConstants.DEFAULT) != 0) { | |
| 306 | + ENGINE.paintBox(g, context, id, SynthConstants.ENABLED, | |
| 307 | + ShadowType.IN, "buttondefault", x, y, w, h); | |
| 308 | + } | |
| 309 | + x += defaultInsets.left; | |
| 310 | + y += defaultInsets.top; | |
| 311 | + w -= (defaultInsets.left + defaultInsets.right); | |
| 312 | + h -= (defaultInsets.top + defaultInsets.bottom); | |
| 313 | + } | |
| 314 | + | |
| 315 | + boolean interiorFocus = style.getClassSpecificBoolValue( | |
| 316 | + context, "interior-focus", true); | |
| 317 | + int focusSize = style.getClassSpecificIntValue( | |
| 318 | + context, "focus-line-width",1); | |
| 319 | + int focusPad = style.getClassSpecificIntValue( | |
| 320 | + context, "focus-padding", 1); | |
| 321 | + | |
| 322 | + int totalFocusSize = focusSize + focusPad; | |
| 323 | + int xThickness = style.getXThickness(); | |
| 324 | + int yThickness = style.getYThickness(); | |
| 325 | + | |
| 326 | + // Render the box. | |
| 327 | + if (!interiorFocus && | |
| 328 | + (state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { | |
| 329 | + x += totalFocusSize; | |
| 330 | + y += totalFocusSize; | |
| 331 | + w -= 2 * totalFocusSize; | |
| 332 | + h -= 2 * totalFocusSize; | |
| 333 | + } | |
| 334 | + | |
| 335 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 336 | + boolean paintBg; | |
| 337 | + if (toolButton) { | |
| 338 | + // Toolbar buttons should only have their background painted | |
| 339 | + // in the PRESSED, SELECTED, or MOUSE_OVER states. | |
| 340 | + paintBg = | |
| 341 | + (gtkState != SynthConstants.ENABLED) && | |
| 342 | + (gtkState != SynthConstants.DISABLED); | |
| 343 | + } else { | |
| 344 | + // Otherwise, always paint the button's background, unless | |
| 345 | + // the user has overridden it and we're in the ENABLED state. | |
| 346 | + paintBg = | |
| 347 | + paintBackground || | |
| 348 | + (gtkState != SynthConstants.ENABLED); | |
| 349 | + } | |
| 350 | + if (paintBg) { | |
| 351 | + ShadowType shadowType = ShadowType.OUT; | |
| 352 | + if ((state & (SynthConstants.PRESSED | | |
| 353 | + SynthConstants.SELECTED)) != 0) { | |
| 354 | + shadowType = ShadowType.IN; | |
| 355 | + } | |
| 356 | + ENGINE.paintBox(g, context, id, gtkState, | |
| 357 | + shadowType, detail, x, y, w, h); | |
| 358 | + } | |
| 359 | + | |
| 360 | + // focus | |
| 361 | + if (paintFocus && (state & SynthConstants.FOCUSED) != 0) { | |
| 362 | + if (interiorFocus) { | |
| 363 | + x += xThickness + focusPad; | |
| 364 | + y += yThickness + focusPad; | |
| 365 | + w -= 2 * (xThickness + focusPad); | |
| 366 | + h -= 2 * (yThickness + focusPad); | |
| 367 | + } else { | |
| 368 | + x -= totalFocusSize; | |
| 369 | + y -= totalFocusSize; | |
| 370 | + w += 2 * totalFocusSize; | |
| 371 | + h += 2 * totalFocusSize; | |
| 372 | + } | |
| 373 | + ENGINE.paintFocus(g, context, id, gtkState, detail, x, y, w, h); | |
| 374 | + } | |
| 375 | + ENGINE.finishPainting(); | |
| 376 | + } | |
| 377 | + } | |
| 378 | + | |
| 379 | + // | |
| 380 | + // ARROW_BUTTON | |
| 381 | + // | |
| 382 | + public void paintArrowButtonForeground(SynthContext context, Graphics g, | |
| 383 | + int x, int y, int w, int h, | |
| 384 | + int direction) { | |
| 385 | + Region id = context.getRegion(); | |
| 386 | + Component c = context.getComponent(); | |
| 387 | + String name = c.getName(); | |
| 388 | + | |
| 389 | + ArrowType arrowType = null; | |
| 390 | + switch (direction) { | |
| 391 | + case SwingConstants.NORTH: | |
| 392 | + arrowType = ArrowType.UP; break; | |
| 393 | + case SwingConstants.SOUTH: | |
| 394 | + arrowType = ArrowType.DOWN; break; | |
| 395 | + case SwingConstants.EAST: | |
| 396 | + arrowType = ArrowType.RIGHT; break; | |
| 397 | + case SwingConstants.WEST: | |
| 398 | + arrowType = ArrowType.LEFT; break; | |
| 399 | + } | |
| 400 | + | |
| 401 | + String detail = "arrow"; | |
| 402 | + if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) { | |
| 403 | + if (arrowType == ArrowType.UP || arrowType == ArrowType.DOWN) { | |
| 404 | + detail = "vscrollbar"; | |
| 405 | + } else { | |
| 406 | + detail = "hscrollbar"; | |
| 407 | + } | |
| 408 | + } else if (name == "Spinner.nextButton" || | |
| 409 | + name == "Spinner.previousButton") { | |
| 410 | + detail = "spinbutton"; | |
| 411 | + } else if (name != "ComboBox.arrowButton") { | |
| 412 | + assert false : "unexpected name: " + name; | |
| 413 | + } | |
| 414 | + | |
| 415 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 416 | + id, context.getComponentState()); | |
| 417 | + ShadowType shadowType = (gtkState == SynthConstants.PRESSED ? | |
| 418 | + ShadowType.IN : ShadowType.OUT); | |
| 419 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 420 | + if (ENGINE.paintCachedImage(g, x, y, w, h, | |
| 421 | + gtkState, name, direction)) { | |
| 422 | + return; | |
| 423 | + } | |
| 424 | + ENGINE.startPainting(g, x, y, w, h, gtkState, name, direction); | |
| 425 | + ENGINE.paintArrow(g, context, id, gtkState, | |
| 426 | + shadowType, arrowType, detail, x, y, w, h); | |
| 427 | + ENGINE.finishPainting(); | |
| 428 | + } | |
| 429 | + } | |
| 430 | + | |
| 431 | + public void paintArrowButtonBackground(SynthContext context, | |
| 432 | + Graphics g, int x, int y, int w, int h) { | |
| 433 | + Region id = context.getRegion(); | |
| 434 | + AbstractButton button = (AbstractButton)context.getComponent(); | |
| 435 | + | |
| 436 | + String name = button.getName(); | |
| 437 | + String detail = "button"; | |
| 438 | + int direction = SwingConstants.CENTER; | |
| 439 | + if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) { | |
| 440 | + Integer prop = (Integer) | |
| 441 | + button.getClientProperty("__arrow_direction__"); | |
| 442 | + direction = (prop != null) ? | |
| 443 | + prop.intValue() : SwingConstants.WEST; | |
| 444 | + switch (direction) { | |
| 445 | + default: | |
| 446 | + case SwingConstants.EAST: | |
| 447 | + case SwingConstants.WEST: | |
| 448 | + detail = "hscrollbar"; | |
| 449 | + break; | |
| 450 | + case SwingConstants.NORTH: | |
| 451 | + case SwingConstants.SOUTH: | |
| 452 | + detail = "vscrollbar"; | |
| 453 | + break; | |
| 454 | + } | |
| 455 | + } else if (name == "Spinner.previousButton") { | |
| 456 | + detail = "spinbutton_down"; | |
| 457 | + } else if (name == "Spinner.nextButton") { | |
| 458 | + detail = "spinbutton_up"; | |
| 459 | + } else if (name != "ComboBox.arrowButton") { | |
| 460 | + assert false : "unexpected name: " + name; | |
| 461 | + } | |
| 462 | + | |
| 463 | + int state = context.getComponentState(); | |
| 464 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 465 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id, | |
| 466 | + state, detail, direction)) | |
| 467 | + { | |
| 468 | + return; | |
| 469 | + } | |
| 470 | + ENGINE.startPainting(g, x, y, w, h, id, | |
| 471 | + state, detail, direction); | |
| 472 | + | |
| 473 | + if (detail.startsWith("spin")) { | |
| 474 | + /* | |
| 475 | + * The ubuntulooks engine (and presumably others) expect us to | |
| 476 | + * first draw the full "spinbutton" background, and then draw | |
| 477 | + * the individual "spinbutton_up/down" buttons on top of that. | |
| 478 | + * Note that it is the state of the JSpinner (not its arrow | |
| 479 | + * button) that determines how we draw this background. | |
| 480 | + */ | |
| 481 | + int spinState = button.getParent().isEnabled() ? | |
| 482 | + SynthConstants.ENABLED : SynthConstants.DISABLED; | |
| 483 | + int mody = (detail == "spinbutton_up") ? y : y-h; | |
| 484 | + int modh = h*2; | |
| 485 | + ENGINE.paintBox(g, context, id, spinState, | |
| 486 | + ShadowType.IN, "spinbutton", | |
| 487 | + x, mody, w, modh); | |
| 488 | + } | |
| 489 | + | |
| 490 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 491 | + ShadowType shadowType = ShadowType.OUT; | |
| 492 | + if ((gtkState & (SynthConstants.PRESSED | | |
| 493 | + SynthConstants.SELECTED)) != 0) | |
| 494 | + { | |
| 495 | + shadowType = ShadowType.IN; | |
| 496 | + } | |
| 497 | + ENGINE.paintBox(g, context, id, gtkState, | |
| 498 | + shadowType, detail, | |
| 499 | + x, y, w, h); | |
| 500 | + | |
| 501 | + ENGINE.finishPainting(); | |
| 502 | + } | |
| 503 | + } | |
| 504 | + | |
| 505 | + | |
| 506 | + // | |
| 507 | + // LIST | |
| 508 | + // | |
| 509 | + public void paintListBackground(SynthContext context, Graphics g, | |
| 510 | + int x, int y, int w, int h) { | |
| 511 | + // Does not call into ENGINE for better performance | |
| 512 | + fillArea(context, g, x, y, w, h, GTKColorType.TEXT_BACKGROUND); | |
| 513 | + } | |
| 514 | + | |
| 515 | + public void paintMenuBarBackground(SynthContext context, Graphics g, | |
| 516 | + int x, int y, int w, int h) { | |
| 517 | + Region id = context.getRegion(); | |
| 518 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 519 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 520 | + return; | |
| 521 | + } | |
| 522 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 523 | + int shadow = style.getClassSpecificIntValue( | |
| 524 | + context, "shadow-type", 2); | |
| 525 | + ShadowType shadowType = SHADOWS[shadow]; | |
| 526 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 527 | + id, context.getComponentState()); | |
| 528 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 529 | + ENGINE.paintBox(g, context, id, gtkState, | |
| 530 | + shadowType, "menubar", x, y, w, h); | |
| 531 | + ENGINE.finishPainting(); | |
| 532 | + } | |
| 533 | + } | |
| 534 | + | |
| 535 | + // | |
| 536 | + // MENU | |
| 537 | + // | |
| 538 | + public void paintMenuBackground(SynthContext context, | |
| 539 | + Graphics g, | |
| 540 | + int x, int y, int w, int h) { | |
| 541 | + paintMenuItemBackground(context, g, x, y, w, h); | |
| 542 | + } | |
| 543 | + | |
| 544 | + // This is called for both MENU and MENU_ITEM | |
| 545 | + public void paintMenuItemBackground(SynthContext context, | |
| 546 | + Graphics g, | |
| 547 | + int x, int y, int w, int h) { | |
| 548 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 549 | + context.getRegion(), context.getComponentState()); | |
| 550 | + if (gtkState == SynthConstants.MOUSE_OVER) { | |
| 551 | + Region id = Region.MENU_ITEM; | |
| 552 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 553 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 554 | + ShadowType shadow = (GTKLookAndFeel.is2_2() ? | |
| 555 | + ShadowType.NONE : ShadowType.OUT); | |
| 556 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 557 | + ENGINE.paintBox(g, context, id, gtkState, shadow, | |
| 558 | + "menuitem", x, y, w, h); | |
| 559 | + ENGINE.finishPainting(); | |
| 560 | + } | |
| 561 | + } | |
| 562 | + } | |
| 563 | + } | |
| 564 | + | |
| 565 | + public void paintPopupMenuBackground(SynthContext context, Graphics g, | |
| 566 | + int x, int y, int w, int h) { | |
| 567 | + Region id = context.getRegion(); | |
| 568 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 569 | + id, context.getComponentState()); | |
| 570 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 571 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState)) { | |
| 572 | + return; | |
| 573 | + } | |
| 574 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState); | |
| 575 | + ENGINE.paintBox(g, context, id, gtkState, | |
| 576 | + ShadowType.OUT, "menu", x, y, w, h); | |
| 577 | + | |
| 578 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 579 | + int xThickness = style.getXThickness(); | |
| 580 | + int yThickness = style.getYThickness(); | |
| 581 | + ENGINE.paintBackground(g, context, id, gtkState, | |
| 582 | + style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND), | |
| 583 | + x + xThickness, y + yThickness, | |
| 584 | + w - xThickness - xThickness, h - yThickness - yThickness); | |
| 585 | + ENGINE.finishPainting(); | |
| 586 | + } | |
| 587 | + } | |
| 588 | + | |
| 589 | + public void paintProgressBarBackground(SynthContext context, | |
| 590 | + Graphics g, | |
| 591 | + int x, int y, int w, int h) { | |
| 592 | + Region id = context.getRegion(); | |
| 593 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 594 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 595 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 596 | + ENGINE.paintBox(g, context, id, SynthConstants.ENABLED, | |
| 597 | + ShadowType.IN, "trough", x, y, w, h); | |
| 598 | + ENGINE.finishPainting(); | |
| 599 | + } | |
| 600 | + } | |
| 601 | + } | |
| 602 | + | |
| 603 | + public void paintProgressBarForeground(SynthContext context, Graphics g, | |
| 604 | + int x, int y, int w, int h, | |
| 605 | + int orientation) { | |
| 606 | + Region id = context.getRegion(); | |
| 607 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 608 | + // Note that we don't call paintCachedImage() here. Since the | |
| 609 | + // progress bar foreground is painted differently for each value | |
| 610 | + // it would be wasteful to try to cache an image for each state, | |
| 611 | + // so instead we simply avoid caching in this case. | |
| 612 | + if (w <= 0 || h <= 0) { | |
| 613 | + return; | |
| 614 | + } | |
| 615 | + ENGINE.startPainting(g, x, y, w, h, id, "fg"); | |
| 616 | + ENGINE.paintBox(g, context, id, SynthConstants.MOUSE_OVER, | |
| 617 | + ShadowType.OUT, "bar", x, y, w, h); | |
| 618 | + ENGINE.finishPainting(false); // don't bother caching the image | |
| 619 | + } | |
| 620 | + } | |
| 621 | + | |
| 622 | + public void paintViewportBorder(SynthContext context, Graphics g, | |
| 623 | + int x, int y, int w, int h) { | |
| 624 | + Region id = context.getRegion(); | |
| 625 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 626 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 627 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 628 | + ENGINE.paintShadow(g, context, id, SynthConstants.ENABLED, | |
| 629 | + ShadowType.IN, "scrolled_window", x, y, w, h); | |
| 630 | + ENGINE.finishPainting(); | |
| 631 | + } | |
| 632 | + } | |
| 633 | + } | |
| 634 | + | |
| 635 | + public void paintSeparatorBackground(SynthContext context, | |
| 636 | + Graphics g, | |
| 637 | + int x, int y, int w, int h, | |
| 638 | + int orientation) { | |
| 639 | + Region id = context.getRegion(); | |
| 640 | + int state = context.getComponentState(); | |
| 641 | + JComponent c = context.getComponent(); | |
| 642 | + | |
| 643 | + /* | |
| 644 | + * Note: In theory, the style's x/y thickness values would determine | |
| 645 | + * the width of the separator content. In practice, however, some | |
| 646 | + * engines will render a line that is wider than the corresponding | |
| 647 | + * thickness value. For example, ubuntulooks reports x/y thickness | |
| 648 | + * values of 1 for separators, but always renders a 2-pixel wide line. | |
| 649 | + * As a result of all this, we need to be careful not to restrict | |
| 650 | + * the w/h values below too much, so that the full thickness of the | |
| 651 | + * rendered line will be captured by our image caching code. | |
| 652 | + */ | |
| 653 | + String detail; | |
| 654 | + if (c instanceof JToolBar.Separator) { | |
| 655 | + /* | |
| 656 | + * GTK renders toolbar separators differently in that an | |
| 657 | + * artificial padding is added to each end of the separator. | |
| 658 | + * The value of 0.2f below is derived from the source code of | |
| 659 | + * gtktoolbar.c in the current version of GTK+ (2.8.20 at the | |
| 660 | + * time of this writing). Specifically, the relevant values are: | |
| 661 | + * SPACE_LINE_DIVISION 10.0 | |
| 662 | + * SPACE_LINE_START 2.0 | |
| 663 | + * SPACE_LINE_END 8.0 | |
| 664 | + * These are used to determine the distance from the top (or left) | |
| 665 | + * edge of the toolbar to the other edge. So for example, the | |
| 666 | + * starting/top point of a vertical separator is 2/10 of the | |
| 667 | + * height of a horizontal toolbar away from the top edge, which | |
| 668 | + * is how we arrive at 0.2f below. Likewise, the ending/bottom | |
| 669 | + * point is 8/10 of the height away from the top edge, or in other | |
| 670 | + * words, it is 2/10 away from the bottom edge, which is again | |
| 671 | + * how we arrive at the 0.2f value below. | |
| 672 | + * | |
| 673 | + * The separator is also centered horizontally or vertically, | |
| 674 | + * depending on its orientation. This was determined empirically | |
| 675 | + * and by examining the code referenced above. | |
| 676 | + */ | |
| 677 | + detail = "toolbar"; | |
| 678 | + float pct = 0.2f; | |
| 679 | + JToolBar.Separator sep = (JToolBar.Separator)c; | |
| 680 | + Dimension size = sep.getSeparatorSize(); | |
| 681 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 682 | + if (orientation == JSeparator.HORIZONTAL) { | |
| 683 | + x += (int)(w * pct); | |
| 684 | + w -= (int)(w * pct * 2); | |
| 685 | + y += (size.height - style.getYThickness()) / 2; | |
| 686 | + } else { | |
| 687 | + y += (int)(h * pct); | |
| 688 | + h -= (int)(h * pct * 2); | |
| 689 | + x += (size.width - style.getXThickness()) / 2; | |
| 690 | + } | |
| 691 | + } else { | |
| 692 | + // For regular/menu separators, we simply subtract out the insets. | |
| 693 | + detail = "separator"; | |
| 694 | + Insets insets = c.getInsets(); | |
| 695 | + x += insets.left; | |
| 696 | + y += insets.top; | |
| 697 | + if (orientation == JSeparator.HORIZONTAL) { | |
| 698 | + w -= (insets.left + insets.right); | |
| 699 | + } else { | |
| 700 | + h -= (insets.top + insets.bottom); | |
| 701 | + } | |
| 702 | + } | |
| 703 | + | |
| 704 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 705 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, | |
| 706 | + state, detail, orientation)) { | |
| 707 | + ENGINE.startPainting(g, x, y, w, h, id, | |
| 708 | + state, detail, orientation); | |
| 709 | + if (orientation == JSeparator.HORIZONTAL) { | |
| 710 | + ENGINE.paintHline(g, context, id, state, | |
| 711 | + detail, x, y, w, h); | |
| 712 | + } else { | |
| 713 | + ENGINE.paintVline(g, context, id, state, | |
| 714 | + detail, x, y, w, h); | |
| 715 | + } | |
| 716 | + ENGINE.finishPainting(); | |
| 717 | + } | |
| 718 | + } | |
| 719 | + } | |
| 720 | + | |
| 721 | + public void paintSliderTrackBackground(SynthContext context, | |
| 722 | + Graphics g, | |
| 723 | + int x, int y, int w,int h) { | |
| 724 | + Region id = context.getRegion(); | |
| 725 | + int state = context.getComponentState(); | |
| 726 | + | |
| 727 | + // For focused sliders, we paint focus rect outside the bounds passed. | |
| 728 | + // Need to adjust for that. | |
| 729 | + boolean focused = ((state & SynthConstants.FOCUSED) != 0); | |
| 730 | + int focusSize = 0; | |
| 731 | + if (focused) { | |
| 732 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 733 | + focusSize = style.getClassSpecificIntValue( | |
| 734 | + context, "focus-line-width", 1) + | |
| 735 | + style.getClassSpecificIntValue( | |
| 736 | + context, "focus-padding", 1); | |
| 737 | + x -= focusSize; | |
| 738 | + y -= focusSize; | |
| 739 | + w += focusSize * 2; | |
| 740 | + h += focusSize * 2; | |
| 741 | + } | |
| 742 | + | |
| 743 | + // The ubuntulooks engine paints slider troughs differently depending | |
| 744 | + // on the current slider value and its component orientation. | |
| 745 | + JSlider slider = (JSlider)context.getComponent(); | |
| 746 | + double value = slider.getValue(); | |
| 747 | + double min = slider.getMinimum(); | |
| 748 | + double max = slider.getMaximum(); | |
| 749 | + double visible = 20; // not used for sliders; any value will work | |
| 750 | + | |
| 751 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 752 | + // Note that we don't call paintCachedImage() here. Since some | |
| 753 | + // engines (e.g. ubuntulooks) paint the slider background | |
| 754 | + // differently for any given slider value, it would be wasteful | |
| 755 | + // to try to cache an image for each state, so instead we simply | |
| 756 | + // avoid caching in this case. | |
| 757 | + if (w <= 0 || h <= 0) { | |
| 758 | + return; | |
| 759 | + } | |
| 760 | + ENGINE.startPainting(g, x, y, w, h, id, state, value); | |
| 761 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 762 | + ENGINE.setRangeValue(context, id, value, min, max, visible); | |
| 763 | + ENGINE.paintBox(g, context, id, gtkState, ShadowType.IN, | |
| 764 | + "trough", x + focusSize, y + focusSize, | |
| 765 | + w - 2 * focusSize, h - 2 * focusSize); | |
| 766 | + if (focused) { | |
| 767 | + ENGINE.paintFocus(g, context, id, SynthConstants.ENABLED, | |
| 768 | + "trough", x, y, w, h); | |
| 769 | + } | |
| 770 | + ENGINE.finishPainting(false); // don't bother caching the image | |
| 771 | + } | |
| 772 | + } | |
| 773 | + | |
| 774 | + public void paintSliderThumbBackground(SynthContext context, | |
| 775 | + Graphics g, int x, int y, int w, int h, int dir) { | |
| 776 | + Region id = context.getRegion(); | |
| 777 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 778 | + id, context.getComponentState()); | |
| 779 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 780 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir)) { | |
| 781 | + Orientation orientation = (dir == JSlider.HORIZONTAL ? | |
| 782 | + Orientation.HORIZONTAL : Orientation.VERTICAL); | |
| 783 | + String detail = (dir == JSlider.HORIZONTAL ? | |
| 784 | + "hscale" : "vscale"); | |
| 785 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir); | |
| 786 | + ENGINE.paintSlider(g, context, id, gtkState, | |
| 787 | + ShadowType.OUT, detail, x, y, w, h, orientation); | |
| 788 | + ENGINE.finishPainting(); | |
| 789 | + } | |
| 790 | + } | |
| 791 | + } | |
| 792 | + | |
| 793 | + // | |
| 794 | + // SPINNER | |
| 795 | + // | |
| 796 | + public void paintSpinnerBackground(SynthContext context, | |
| 797 | + Graphics g, | |
| 798 | + int x, int y, int w, int h) { | |
| 799 | + // This is handled in paintTextFieldBackground | |
| 800 | + } | |
| 801 | + | |
| 802 | + // | |
| 803 | + // SPLIT_PANE_DIVIDER | |
| 804 | + // | |
| 805 | + public void paintSplitPaneDividerBackground(SynthContext context, | |
| 806 | + Graphics g, | |
| 807 | + int x, int y, int w, int h) { | |
| 808 | + Region id = context.getRegion(); | |
| 809 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 810 | + id, context.getComponentState()); | |
| 811 | + JSplitPane splitPane = (JSplitPane)context.getComponent(); | |
| 812 | + Orientation orientation = | |
| 813 | + (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? | |
| 814 | + Orientation.VERTICAL : Orientation.HORIZONTAL); | |
| 815 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 816 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, | |
| 817 | + id, gtkState, orientation)) { | |
| 818 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState, orientation); | |
| 819 | + ENGINE.paintHandle(g, context, id, gtkState, | |
| 820 | + ShadowType.OUT, "paned", x, y, w, h, orientation); | |
| 821 | + ENGINE.finishPainting(); | |
| 822 | + } | |
| 823 | + } | |
| 824 | + } | |
| 825 | + | |
| 826 | + public void paintSplitPaneDragDivider(SynthContext context, | |
| 827 | + Graphics g,int x, int y, int w, int h, | |
| 828 | + int orientation) { | |
| 829 | + paintSplitPaneDividerForeground(context, g, x, y, w, h, orientation); | |
| 830 | + } | |
| 831 | + | |
| 832 | + public void paintTabbedPaneContentBackground(SynthContext context, | |
| 833 | + Graphics g, int x, int y, int w, int h) { | |
| 834 | + JTabbedPane pane = (JTabbedPane)context.getComponent(); | |
| 835 | + int selectedIndex = pane.getSelectedIndex(); | |
| 836 | + PositionType placement = GTKLookAndFeel.SwingOrientationConstantToGTK( | |
| 837 | + pane.getTabPlacement()); | |
| 838 | + | |
| 839 | + int gapStart = 0; | |
| 840 | + int gapSize = 0; | |
| 841 | + if (selectedIndex != -1) { | |
| 842 | + Rectangle tabBounds = pane.getBoundsAt(selectedIndex); | |
| 843 | + | |
| 844 | + if (placement == PositionType.TOP || | |
| 845 | + placement == PositionType.BOTTOM) { | |
| 846 | + | |
| 847 | + gapStart = tabBounds.x - x; | |
| 848 | + gapSize = tabBounds.width; | |
| 849 | + } | |
| 850 | + else { | |
| 851 | + gapStart = tabBounds.y - y; | |
| 852 | + gapSize = tabBounds.height; | |
| 853 | + } | |
| 854 | + } | |
| 855 | + | |
| 856 | + Region id = context.getRegion(); | |
| 857 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 858 | + id, context.getComponentState()); | |
| 859 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 860 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, | |
| 861 | + id, gtkState, placement, gapStart, gapSize)) { | |
| 862 | + ENGINE.startPainting(g, x, y, w, h, | |
| 863 | + id, gtkState, placement, gapStart, gapSize); | |
| 864 | + ENGINE.paintBoxGap(g, context, id, gtkState, ShadowType.OUT, | |
| 865 | + "notebook", x, y, w, h, placement, gapStart, gapSize); | |
| 866 | + ENGINE.finishPainting(); | |
| 867 | + } | |
| 868 | + } | |
| 869 | + } | |
| 870 | + | |
| 871 | + public void paintTabbedPaneTabBackground(SynthContext context, | |
| 872 | + Graphics g, | |
| 873 | + int x, int y, int w, int h, | |
| 874 | + int tabIndex) { | |
| 875 | + Region id = context.getRegion(); | |
| 876 | + int state = context.getComponentState(); | |
| 877 | + int gtkState = ((state & SynthConstants.SELECTED) != 0 ? | |
| 878 | + SynthConstants.ENABLED : SynthConstants.PRESSED); | |
| 879 | + JTabbedPane pane = (JTabbedPane)context.getComponent(); | |
| 880 | + int placement = pane.getTabPlacement(); | |
| 881 | + | |
| 882 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 883 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, | |
| 884 | + id, gtkState, placement, tabIndex)) { | |
| 885 | + PositionType side = POSITIONS[placement - 1]; | |
| 886 | + ENGINE.startPainting(g, x, y, w, h, | |
| 887 | + id, gtkState, placement, tabIndex); | |
| 888 | + ENGINE.paintExtension(g, context, id, gtkState, | |
| 889 | + ShadowType.OUT, "tab", x, y, w, h, side, tabIndex); | |
| 890 | + ENGINE.finishPainting(); | |
| 891 | + } | |
| 892 | + } | |
| 893 | + } | |
| 894 | + | |
| 895 | + // | |
| 896 | + // TEXT_PANE | |
| 897 | + // | |
| 898 | + public void paintTextPaneBackground(SynthContext context, Graphics g, | |
| 899 | + int x, int y, int w, int h) { | |
| 900 | + paintTextAreaBackground(context, g, x, y, w, h); | |
| 901 | + } | |
| 902 | + | |
| 903 | + // | |
| 904 | + // EDITOR_PANE | |
| 905 | + // | |
| 906 | + public void paintEditorPaneBackground(SynthContext context, Graphics g, | |
| 907 | + int x, int y, int w, int h) { | |
| 908 | + paintTextAreaBackground(context, g, x, y, w, h); | |
| 909 | + } | |
| 910 | + | |
| 911 | + // | |
| 912 | + // TEXT_AREA | |
| 913 | + // | |
| 914 | + public void paintTextAreaBackground(SynthContext context, Graphics g, | |
| 915 | + int x, int y, int w, int h) { | |
| 916 | + // Does not call into ENGINE for better performance | |
| 917 | + fillArea(context, g, x, y, w, h, GTKColorType.TEXT_BACKGROUND); | |
| 918 | + } | |
| 919 | + | |
| 920 | + // | |
| 921 | + // TEXT_FIELD | |
| 922 | + // | |
| 923 | + // NOTE: Combobox and Label, Password and FormattedTextField calls this | |
| 924 | + // too. | |
| 925 | + private void paintTextBackground(SynthContext context, Graphics g, | |
| 926 | + int x, int y, int w, int h) { | |
| 927 | + // Text is odd in that it uses the TEXT_BACKGROUND vs BACKGROUND. | |
| 928 | + JComponent c = context.getComponent(); | |
| 929 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 930 | + Region id = context.getRegion(); | |
| 931 | + int state = context.getComponentState(); | |
| 932 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 933 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id, state)) { | |
| 934 | + return; | |
| 935 | + } | |
| 936 | + | |
| 937 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 938 | + int focusSize = 0; | |
| 939 | + boolean interiorFocus = style.getClassSpecificBoolValue( | |
| 940 | + context, "interior-focus", true); | |
| 941 | + if (!interiorFocus && (state & SynthConstants.FOCUSED) != 0) { | |
| 942 | + focusSize = style.getClassSpecificIntValue(context, | |
| 943 | + "focus-line-width",1); | |
| 944 | + x += focusSize; | |
| 945 | + y += focusSize; | |
| 946 | + w -= 2 * focusSize; | |
| 947 | + h -= 2 * focusSize; | |
| 948 | + } | |
| 949 | + | |
| 950 | + int xThickness = style.getXThickness(); | |
| 951 | + int yThickness = style.getYThickness(); | |
| 952 | + | |
| 953 | + ENGINE.startPainting(g, x, y, w, h, id, state); | |
| 954 | + ENGINE.paintShadow(g, context, id, gtkState, | |
| 955 | + ShadowType.IN, "entry", x, y, w, h); | |
| 956 | + ENGINE.paintFlatBox(g, context, id, | |
| 957 | + gtkState, ShadowType.NONE, "entry_bg", | |
| 958 | + x + xThickness, | |
| 959 | + y + yThickness, | |
| 960 | + w - (2 * xThickness), | |
| 961 | + h - (2 * yThickness), | |
| 962 | + ColorType.TEXT_BACKGROUND); | |
| 963 | + | |
| 964 | + if (focusSize > 0) { | |
| 965 | + x -= focusSize; | |
| 966 | + y -= focusSize; | |
| 967 | + w += 2 * focusSize; | |
| 968 | + h += 2 * focusSize; | |
| 969 | + ENGINE.paintFocus(g, context, id, gtkState, | |
| 970 | + "entry", x, y, w, h); | |
| 971 | + } | |
| 972 | + ENGINE.finishPainting(); | |
| 973 | + } | |
| 974 | + } | |
| 975 | + | |
| 976 | + private void paintTreeCellEditorBackground(SynthContext context, Graphics g, | |
| 977 | + int x, int y, int w, int h) { | |
| 978 | + Region id = context.getRegion(); | |
| 979 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 980 | + id, context.getComponentState()); | |
| 981 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 982 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState)) { | |
| 983 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState); | |
| 984 | + ENGINE.paintFlatBox(g, context, id, gtkState, ShadowType.NONE, | |
| 985 | + "entry_bg", x, y, w, h, ColorType.TEXT_BACKGROUND); | |
| 986 | + ENGINE.finishPainting(); | |
| 987 | + } | |
| 988 | + } | |
| 989 | + } | |
| 990 | + | |
| 991 | + | |
| 992 | + // | |
| 993 | + // ROOT_PANE | |
| 994 | + // | |
| 995 | + public void paintRootPaneBackground(SynthContext context, Graphics g, | |
| 996 | + int x, int y, int w, int h) { | |
| 997 | + // Does not call into ENGINE for better performance | |
| 998 | + fillArea(context, g, x, y, w, h, GTKColorType.BACKGROUND); | |
| 999 | + } | |
| 1000 | + | |
| 1001 | + // | |
| 1002 | + // TOGGLE_BUTTON | |
| 1003 | + // | |
| 1004 | + public void paintToggleButtonBackground(SynthContext context, | |
| 1005 | + Graphics g, | |
| 1006 | + int x, int y, int w, int h) { | |
| 1007 | + Region id = context.getRegion(); | |
| 1008 | + JToggleButton toggleButton = (JToggleButton)context.getComponent(); | |
| 1009 | + boolean paintBG = toggleButton.isContentAreaFilled() && | |
| 1010 | + toggleButton.isBorderPainted(); | |
| 1011 | + boolean paintFocus = toggleButton.isFocusPainted(); | |
| 1012 | + boolean toolButton = (toggleButton.getParent() instanceof JToolBar); | |
| 1013 | + paintButtonBackgroundImpl(context, g, id, "button", | |
| 1014 | + x, y, w, h, | |
| 1015 | + paintBG, paintFocus, false, toolButton); | |
| 1016 | + } | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + // | |
| 1020 | + // SCROLL_BAR | |
| 1021 | + // | |
| 1022 | + public void paintScrollBarBackground(SynthContext context, | |
| 1023 | + Graphics g, | |
| 1024 | + int x, int y, int w,int h) { | |
| 1025 | + Region id = context.getRegion(); | |
| 1026 | + boolean focused = | |
| 1027 | + (context.getComponentState() & SynthConstants.FOCUSED) != 0; | |
| 1028 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1029 | + if (ENGINE.paintCachedImage(g, x, y, w, h, id, focused)) { | |
| 1030 | + return; | |
| 1031 | + } | |
| 1032 | + ENGINE.startPainting(g, x, y, w, h, id, focused); | |
| 1033 | + | |
| 1034 | + // Note: the scrollbar insets already include the "trough-border", | |
| 1035 | + // which is needed to position the scrollbar buttons properly. | |
| 1036 | + // But when we render, we need to take the trough border out | |
| 1037 | + // of the equation so that we paint the entire area covered by | |
| 1038 | + // the trough border and the scrollbar content itself. | |
| 1039 | + Insets insets = context.getComponent().getInsets(); | |
| 1040 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1041 | + int troughBorder = | |
| 1042 | + style.getClassSpecificIntValue(context, "trough-border", 1); | |
| 1043 | + insets.left -= troughBorder; | |
| 1044 | + insets.right -= troughBorder; | |
| 1045 | + insets.top -= troughBorder; | |
| 1046 | + insets.bottom -= troughBorder; | |
| 1047 | + | |
| 1048 | + ENGINE.paintBox(g, context, id, SynthConstants.PRESSED, | |
| 1049 | + ShadowType.IN, "trough", | |
| 1050 | + x + insets.left, | |
| 1051 | + y + insets.top, | |
| 1052 | + w - insets.left - insets.right, | |
| 1053 | + h - insets.top - insets.bottom); | |
| 1054 | + | |
| 1055 | + if (focused) { | |
| 1056 | + ENGINE.paintFocus(g, context, id, | |
| 1057 | + SynthConstants.ENABLED, "trough", x, y, w, h); | |
| 1058 | + } | |
| 1059 | + ENGINE.finishPainting(); | |
| 1060 | + } | |
| 1061 | + } | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + // | |
| 1065 | + // SCROLL_BAR_THUMB | |
| 1066 | + // | |
| 1067 | + public void paintScrollBarThumbBackground(SynthContext context, | |
| 1068 | + Graphics g, int x, int y, int w, int h, int dir) { | |
| 1069 | + Region id = context.getRegion(); | |
| 1070 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 1071 | + id, context.getComponentState()); | |
| 1072 | + | |
| 1073 | + // The clearlooks engine paints scrollbar thumbs differently | |
| 1074 | + // depending on the current scroll value (specifically, it will avoid | |
| 1075 | + // rendering a certain line when the thumb is at the starting or | |
| 1076 | + // ending position). Therefore, we normalize the current value to | |
| 1077 | + // the range [0,100] here and then pass it down to setRangeValue() | |
| 1078 | + // so that the native widget is configured appropriately. Note that | |
| 1079 | + // there are really only four values that matter (min, middle, max, | |
| 1080 | + // or fill) so we restrict to one of those four values to avoid | |
| 1081 | + // blowing out the image cache. | |
| 1082 | + JScrollBar sb = (JScrollBar)context.getComponent(); | |
| 1083 | + boolean rtl = | |
| 1084 | + sb.getOrientation() == JScrollBar.HORIZONTAL && | |
| 1085 | + !sb.getComponentOrientation().isLeftToRight(); | |
| 1086 | + double min = 0; | |
| 1087 | + double max = 100; | |
| 1088 | + double visible = 20; | |
| 1089 | + double value; | |
| 1090 | + if (sb.getMaximum() - sb.getMinimum() == sb.getVisibleAmount()) { | |
| 1091 | + // In this case, the thumb fills the entire track, so it is | |
| 1092 | + // touching both ends at the same time | |
| 1093 | + value = 0; | |
| 1094 | + visible = 100; | |
| 1095 | + } else if (sb.getValue() == sb.getMinimum()) { | |
| 1096 | + // At minimum | |
| 1097 | + value = rtl ? 100 : 0; | |
| 1098 | + } else if (sb.getValue() >= sb.getMaximum() - sb.getVisibleAmount()) { | |
| 1099 | + // At maximum | |
| 1100 | + value = rtl ? 0 : 100; | |
| 1101 | + } else { | |
| 1102 | + // Somewhere in between | |
| 1103 | + value = 50; | |
| 1104 | + } | |
| 1105 | + | |
| 1106 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1107 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, | |
| 1108 | + dir, value, visible, rtl)) | |
| 1109 | + { | |
| 1110 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState, | |
| 1111 | + dir, value, visible, rtl); | |
| 1112 | + Orientation orientation = (dir == JScrollBar.HORIZONTAL ? | |
| 1113 | + Orientation.HORIZONTAL : Orientation.VERTICAL); | |
| 1114 | + ENGINE.setRangeValue(context, id, value, min, max, visible); | |
| 1115 | + ENGINE.paintSlider(g, context, id, gtkState, | |
| 1116 | + ShadowType.OUT, "slider", x, y, w, h, orientation); | |
| 1117 | + ENGINE.finishPainting(); | |
| 1118 | + } | |
| 1119 | + } | |
| 1120 | + } | |
| 1121 | + | |
| 1122 | + // | |
| 1123 | + // TOOL_TIP | |
| 1124 | + // | |
| 1125 | + public void paintToolTipBackground(SynthContext context, Graphics g, | |
| 1126 | + int x, int y, int w,int h) { | |
| 1127 | + Region id = context.getRegion(); | |
| 1128 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1129 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 1130 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 1131 | + ENGINE.paintFlatBox(g, context, id, SynthConstants.ENABLED, | |
| 1132 | + ShadowType.OUT, "tooltip", x, y, w, h, | |
| 1133 | + ColorType.BACKGROUND); | |
| 1134 | + ENGINE.finishPainting(); | |
| 1135 | + } | |
| 1136 | + } | |
| 1137 | + } | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + // | |
| 1141 | + // TREE_CELL | |
| 1142 | + // | |
| 1143 | + public void paintTreeCellBackground(SynthContext context, Graphics g, | |
| 1144 | + int x, int y, int w, int h) { | |
| 1145 | + Region id = context.getRegion(); | |
| 1146 | + int state = context.getComponentState(); | |
| 1147 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 1148 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1149 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state)) { | |
| 1150 | + ENGINE.startPainting(g, x, y, w, h, id, state); | |
| 1151 | + // the string arg should alternate based on row being painted, | |
| 1152 | + // but we currently don't pass that in. | |
| 1153 | + ENGINE.paintFlatBox(g, context, id, gtkState, ShadowType.NONE, | |
| 1154 | + "cell_odd", x, y, w, h, ColorType.TEXT_BACKGROUND); | |
| 1155 | + ENGINE.finishPainting(); | |
| 1156 | + } | |
| 1157 | + } | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + public void paintTreeCellFocus(SynthContext context, Graphics g, | |
| 1161 | + int x, int y, int w, int h) { | |
| 1162 | + Region id = Region.TREE_CELL; | |
| 1163 | + int state = context.getComponentState(); | |
| 1164 | + paintFocus(context, g, id, state, "treeview", x, y, w, h); | |
| 1165 | + } | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + // | |
| 1169 | + // TREE | |
| 1170 | + // | |
| 1171 | + public void paintTreeBackground(SynthContext context, Graphics g, | |
| 1172 | + int x, int y, int w, int h) { | |
| 1173 | + // As far as I can tell, these don't call into the ENGINE. | |
| 1174 | + fillArea(context, g, x, y, w, h, GTKColorType.TEXT_BACKGROUND); | |
| 1175 | + } | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + // | |
| 1179 | + // VIEWPORT | |
| 1180 | + // | |
| 1181 | + public void paintViewportBackground(SynthContext context, Graphics g, | |
| 1182 | + int x, int y, int w, int h) { | |
| 1183 | + // As far as I can tell, these don't call into the ENGINE. | |
| 1184 | + // Also note that you don't want this to call into the ENGINE | |
| 1185 | + // as if it where to paint a background JViewport wouldn't scroll | |
| 1186 | + // correctly. | |
| 1187 | + fillArea(context, g, x, y, w, h, GTKColorType.TEXT_BACKGROUND); | |
| 1188 | + } | |
| 1189 | + | |
| 1190 | + void paintFocus(SynthContext context, Graphics g, Region id, | |
| 1191 | + int state, String detail, int x, int y, int w, int h) { | |
| 1192 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 1193 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1194 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, "focus")) { | |
| 1195 | + ENGINE.startPainting(g, x, y, w, h, id, gtkState, "focus"); | |
| 1196 | + ENGINE.paintFocus(g, context, id, gtkState, detail, x, y, w, h); | |
| 1197 | + ENGINE.finishPainting(); | |
| 1198 | + } | |
| 1199 | + } | |
| 1200 | + } | |
| 1201 | + | |
| 1202 | + void paintMetacityElement(SynthContext context, Graphics g, | |
| 1203 | + int gtkState, String detail, int x, int y, int w, int h, | |
| 1204 | + ShadowType shadow, ArrowType direction) { | |
| 1205 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1206 | + if (! ENGINE.paintCachedImage( | |
| 1207 | + g, x, y, w, h, gtkState, detail, shadow, direction)) { | |
| 1208 | + ENGINE.startPainting( | |
| 1209 | + g, x, y, w, h, gtkState, detail, shadow, direction); | |
| 1210 | + if (detail == "metacity-arrow") { | |
| 1211 | + ENGINE.paintArrow(g, context, Region.INTERNAL_FRAME_TITLE_PANE, | |
| 1212 | + gtkState, shadow, direction, "", x, y, w, h); | |
| 1213 | + | |
| 1214 | + } else if (detail == "metacity-box") { | |
| 1215 | + ENGINE.paintBox(g, context, Region.INTERNAL_FRAME_TITLE_PANE, | |
| 1216 | + gtkState, shadow, "", x, y, w, h); | |
| 1217 | + | |
| 1218 | + } else if (detail == "metacity-vline") { | |
| 1219 | + ENGINE.paintVline(g, context, Region.INTERNAL_FRAME_TITLE_PANE, | |
| 1220 | + gtkState, "", x, y, w, h); | |
| 1221 | + } | |
| 1222 | + ENGINE.finishPainting(); | |
| 1223 | + } | |
| 1224 | + } | |
| 1225 | + } | |
| 1226 | + | |
| 1227 | + void paintIcon(SynthContext context, Graphics g, | |
| 1228 | + Method paintMethod, int x, int y, int w, int h) { | |
| 1229 | + int state = context.getComponentState(); | |
| 1230 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1231 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, state, paintMethod)) { | |
| 1232 | + ENGINE.startPainting(g, x, y, w, h, state, paintMethod); | |
| 1233 | + try { | |
| 1234 | + paintMethod.invoke(this, context, g, state, x, y, w, h); | |
| 1235 | + } catch (IllegalAccessException iae) { | |
| 1236 | + assert false; | |
| 1237 | + } catch (InvocationTargetException ite) { | |
| 1238 | + assert false; | |
| 1239 | + } | |
| 1240 | + ENGINE.finishPainting(); | |
| 1241 | + } | |
| 1242 | + } | |
| 1243 | + } | |
| 1244 | + | |
| 1245 | + void paintIcon(SynthContext context, Graphics g, | |
| 1246 | + Method paintMethod, int x, int y, int w, int h, Object direction) { | |
| 1247 | + int state = context.getComponentState(); | |
| 1248 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1249 | + if (! ENGINE.paintCachedImage(g, | |
| 1250 | + x, y, w, h, state, paintMethod, direction)) { | |
| 1251 | + ENGINE.startPainting(g, | |
| 1252 | + x, y, w, h, state, paintMethod, direction); | |
| 1253 | + try { | |
| 1254 | + paintMethod.invoke(this, context, | |
| 1255 | + g, state, x, y, w, h, direction); | |
| 1256 | + } catch (IllegalAccessException iae) { | |
| 1257 | + assert false; | |
| 1258 | + } catch (InvocationTargetException ite) { | |
| 1259 | + assert false; | |
| 1260 | + } | |
| 1261 | + ENGINE.finishPainting(); | |
| 1262 | + } | |
| 1263 | + } | |
| 1264 | + } | |
| 1265 | + | |
| 1266 | + // All icon painting methods are called from under GTK_LOCK | |
| 1267 | + | |
| 1268 | + public void paintTreeExpandedIcon(SynthContext context, | |
| 1269 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1270 | + ENGINE.paintExpander(g, context, Region.TREE, | |
| 1271 | + GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), | |
| 1272 | + ExpanderStyle.EXPANDED, "treeview", x, y, w, h); | |
| 1273 | + } | |
| 1274 | + | |
| 1275 | + public void paintTreeCollapsedIcon(SynthContext context, | |
| 1276 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1277 | + ENGINE.paintExpander(g, context, Region.TREE, | |
| 1278 | + GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), | |
| 1279 | + ExpanderStyle.COLLAPSED, "treeview", x, y, w, h); | |
| 1280 | + } | |
| 1281 | + | |
| 1282 | + public void paintCheckBoxIcon(SynthContext context, | |
| 1283 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1284 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1285 | + int size = style.getClassSpecificIntValue(context, | |
| 1286 | + "indicator-size", GTKIconFactory.DEFAULT_ICON_SIZE); | |
| 1287 | + int offset = style.getClassSpecificIntValue(context, | |
| 1288 | + "indicator-spacing", GTKIconFactory.DEFAULT_ICON_SPACING); | |
| 1289 | + | |
| 1290 | + ENGINE.paintCheck(g, context, Region.CHECK_BOX, "checkbutton", | |
| 1291 | + x+offset, y+offset, size, size); | |
| 1292 | + } | |
| 1293 | + | |
| 1294 | + public void paintRadioButtonIcon(SynthContext context, | |
| 1295 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1296 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1297 | + int size = style.getClassSpecificIntValue(context, | |
| 1298 | + "indicator-size", GTKIconFactory.DEFAULT_ICON_SIZE); | |
| 1299 | + int offset = style.getClassSpecificIntValue(context, | |
| 1300 | + "indicator-spacing", GTKIconFactory.DEFAULT_ICON_SPACING); | |
| 1301 | + | |
| 1302 | + ENGINE.paintOption(g, context, Region.RADIO_BUTTON, "radiobutton", | |
| 1303 | + x+offset, y+offset, size, size); | |
| 1304 | + } | |
| 1305 | + | |
| 1306 | + public void paintMenuArrowIcon(SynthContext context, Graphics g, | |
| 1307 | + int state, int x, int y, int w, int h, ArrowType dir) { | |
| 1308 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 1309 | + context.getRegion(), state); | |
| 1310 | + ShadowType shadow = ShadowType.OUT; | |
| 1311 | + if (gtkState == SynthConstants.MOUSE_OVER) { | |
| 1312 | + shadow = ShadowType.IN; | |
| 1313 | + } | |
| 1314 | + ENGINE.paintArrow(g, context, Region.MENU_ITEM, gtkState, shadow, | |
| 1315 | + dir, "menuitem", x + 3, y + 3, 7, 7); | |
| 1316 | + } | |
| 1317 | + | |
| 1318 | + public void paintCheckBoxMenuItemCheckIcon(SynthContext context, | |
| 1319 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1320 | + | |
| 1321 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1322 | + int size = style.getClassSpecificIntValue(context,"indicator-size", | |
| 1323 | + GTKIconFactory.DEFAULT_TOGGLE_MENU_ITEM_SIZE); | |
| 1324 | + | |
| 1325 | + ENGINE.paintCheck(g, context, Region.CHECK_BOX_MENU_ITEM, "check", | |
| 1326 | + x + GTKIconFactory.CHECK_ICON_EXTRA_INSET, | |
| 1327 | + y + GTKIconFactory.CHECK_ICON_EXTRA_INSET, | |
| 1328 | + size, size); | |
| 1329 | + } | |
| 1330 | + | |
| 1331 | + public void paintRadioButtonMenuItemCheckIcon(SynthContext context, | |
| 1332 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1333 | + | |
| 1334 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1335 | + int size = style.getClassSpecificIntValue(context,"indicator-size", | |
| 1336 | + GTKIconFactory.DEFAULT_TOGGLE_MENU_ITEM_SIZE); | |
| 1337 | + | |
| 1338 | + ENGINE.paintOption(g, context, Region.RADIO_BUTTON_MENU_ITEM, "option", | |
| 1339 | + x + GTKIconFactory.CHECK_ICON_EXTRA_INSET, | |
| 1340 | + y + GTKIconFactory.CHECK_ICON_EXTRA_INSET, | |
| 1341 | + size, size); | |
| 1342 | + } | |
| 1343 | + | |
| 1344 | + public void paintToolBarHandleIcon(SynthContext context, Graphics g, | |
| 1345 | + int state, int x, int y, int w, int h, Orientation orientation) { | |
| 1346 | + int gtkState = GTKLookAndFeel.synthStateToGTKState( | |
| 1347 | + context.getRegion(), state); | |
| 1348 | + | |
| 1349 | + // The orientation parameter passed down by Synth refers to the | |
| 1350 | + // orientation of the toolbar, but the one we pass to GTK refers | |
| 1351 | + // to the orientation of the handle. Therefore, we need to swap | |
| 1352 | + // the value here: horizontal toolbars have vertical handles, and | |
| 1353 | + // vice versa. | |
| 1354 | + orientation = (orientation == Orientation.HORIZONTAL) ? | |
| 1355 | + Orientation.VERTICAL : Orientation.HORIZONTAL; | |
| 1356 | + | |
| 1357 | + ENGINE.paintHandle(g, context, Region.TOOL_BAR, gtkState, | |
| 1358 | + ShadowType.OUT, "handlebox", x, y, w, h, orientation); | |
| 1359 | + } | |
| 1360 | + | |
| 1361 | + public void paintAscendingSortIcon(SynthContext context, | |
| 1362 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1363 | + ENGINE.paintArrow(g, context, Region.TABLE, SynthConstants.ENABLED, | |
| 1364 | + ShadowType.IN, ArrowType.UP, "arrow", x, y, w, h); | |
| 1365 | + } | |
| 1366 | + | |
| 1367 | + public void paintDescendingSortIcon(SynthContext context, | |
| 1368 | + Graphics g, int state, int x, int y, int w, int h) { | |
| 1369 | + ENGINE.paintArrow(g, context, Region.TABLE, SynthConstants.ENABLED, | |
| 1370 | + ShadowType.IN, ArrowType.DOWN, "arrow", x, y, w, h); | |
| 1371 | + } | |
| 1372 | + | |
| 1373 | + /* | |
| 1374 | + * Fill an area with color determined from this context's Style using the | |
| 1375 | + * specified GTKColorType | |
| 1376 | + */ | |
| 1377 | + private void fillArea(SynthContext context, Graphics g, | |
| 1378 | + int x, int y, int w, int h, ColorType colorType) { | |
| 1379 | + if (context.getComponent().isOpaque()) { | |
| 1380 | + Region id = context.getRegion(); | |
| 1381 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, | |
| 1382 | + context.getComponentState()); | |
| 1383 | + GTKStyle style = (GTKStyle)context.getStyle(); | |
| 1384 | + | |
| 1385 | + g.setColor(style.getGTKColor(context, gtkState, colorType)); | |
| 1386 | + g.fillRect(x, y, w, h); | |
| 1387 | + } | |
| 1388 | + } | |
| 1389 | + | |
| 1390 | + // Refer to GTKLookAndFeel for details on this. | |
| 1391 | + static class ListTableFocusBorder extends AbstractBorder implements | |
| 1392 | + UIResource { | |
| 1393 | + | |
| 1394 | + private boolean selectedCell; | |
| 1395 | + private boolean focusedCell; | |
| 1396 | + | |
| 1397 | + public static ListTableFocusBorder getSelectedCellBorder() { | |
| 1398 | + return new ListTableFocusBorder(true, true); | |
| 1399 | + } | |
| 1400 | + | |
| 1401 | + public static ListTableFocusBorder getUnselectedCellBorder() { | |
| 1402 | + return new ListTableFocusBorder(false, true); | |
| 1403 | + } | |
| 1404 | + | |
| 1405 | + public static ListTableFocusBorder getNoFocusCellBorder() { | |
| 1406 | + return new ListTableFocusBorder(false, false); | |
| 1407 | + } | |
| 1408 | + | |
| 1409 | + public ListTableFocusBorder(boolean selectedCell, boolean focusedCell) { | |
| 1410 | + this.selectedCell = selectedCell; | |
| 1411 | + this.focusedCell = focusedCell; | |
| 1412 | + } | |
| 1413 | + | |
| 1414 | + private SynthContext getContext(Component c) { | |
| 1415 | + SynthContext context = null; | |
| 1416 | + | |
| 1417 | + ComponentUI ui = null; | |
| 1418 | + if (c instanceof JLabel) { | |
| 1419 | + ui = ((JLabel)c).getUI(); | |
| 1420 | + } | |
| 1421 | + | |
| 1422 | + if (ui instanceof SynthUI) { | |
| 1423 | + context = ((SynthUI)ui).getContext((JComponent)c); | |
| 1424 | + } | |
| 1425 | + | |
| 1426 | + return context; | |
| 1427 | + } | |
| 1428 | + | |
| 1429 | + public void paintBorder(Component c, Graphics g, int x, int y, | |
| 1430 | + int w, int h) { | |
| 1431 | + if (focusedCell) { | |
| 1432 | + SynthContext context = getContext(c); | |
| 1433 | + int state = (selectedCell? SynthConstants.SELECTED: | |
| 1434 | + SynthConstants.FOCUSED | SynthConstants.ENABLED); | |
| 1435 | + | |
| 1436 | + if (context != null) { | |
| 1437 | + GTKPainter.INSTANCE.paintFocus(context, g, | |
| 1438 | + Region.TABLE, state, "", x, y, w, h); | |
| 1439 | + } | |
| 1440 | + } | |
| 1441 | + } | |
| 1442 | + | |
| 1443 | + public Insets getBorderInsets(Component c, Insets i) { | |
| 1444 | + SynthContext context = getContext(c); | |
| 1445 | + | |
| 1446 | + if (context != null) { | |
| 1447 | + i = context.getStyle().getInsets(context, i); | |
| 1448 | + } | |
| 1449 | + | |
| 1450 | + return i; | |
| 1451 | + } | |
| 1452 | + | |
| 1453 | + public boolean isBorderOpaque() { | |
| 1454 | + return true; | |
| 1455 | + } | |
| 1456 | + } | |
| 1457 | + | |
| 1458 | + // TitledBorder implementation for GTK L&F | |
| 1459 | + static class TitledBorder extends AbstractBorder implements UIResource { | |
| 1460 | + | |
| 1461 | + public void paintBorder(Component c, Graphics g, int x, int y, | |
| 1462 | + int w, int h) { | |
| 1463 | + SynthContext context = getContext((JComponent)c); | |
| 1464 | + Region id = context.getRegion(); | |
| 1465 | + int state = context.getComponentState(); | |
| 1466 | + int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 1467 | + | |
| 1468 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 1469 | + if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { | |
| 1470 | + ENGINE.startPainting(g, x, y, w, h, id); | |
| 1471 | + ENGINE.paintShadow(g, context, id, gtkState, ShadowType.ETCHED_IN, | |
| 1472 | + "frame", x, y, w, h); | |
| 1473 | + ENGINE.finishPainting(); | |
| 1474 | + } | |
| 1475 | + } | |
| 1476 | + } | |
| 1477 | + | |
| 1478 | + public Insets getBorderInsets(Component c, Insets i) { | |
| 1479 | + SynthContext context = getContext((JComponent)c); | |
| 1480 | + return context.getStyle().getInsets(context, i); | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + public boolean isBorderOpaque() { | |
| 1484 | + return true; | |
| 1485 | + } | |
| 1486 | + | |
| 1487 | + private SynthStyle getStyle(JComponent c) { | |
| 1488 | + return SynthLookAndFeel.getStyle(c, GTKEngine.CustomRegion.TITLED_BORDER); | |
| 1489 | + } | |
| 1490 | + | |
| 1491 | + private SynthContext getContext(JComponent c) { | |
| 1492 | + int state = SynthConstants.DEFAULT; | |
| 1493 | + return new SynthContext(c, GTKEngine.CustomRegion.TITLED_BORDER, | |
| 1494 | + getStyle(c), state); | |
| 1495 | + } | |
| 1496 | + } | |
| 1497 | +} | |
| @@ -0,0 +1,42 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import javax.swing.plaf.synth.Region; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * A typesafe enumeration of the distinct rendering portions specific | |
| 31 | + * to GTK. | |
| 32 | + * | |
| 33 | + * @author Scott Violet | |
| 34 | + */ | |
| 35 | +class GTKRegion extends Region { | |
| 36 | + public static final Region HANDLE_BOX = new GTKRegion("HandleBox", null, | |
| 37 | + true); | |
| 38 | + | |
| 39 | + protected GTKRegion(String name, String ui, boolean subregion) { | |
| 40 | + super(name, ui, subregion); | |
| 41 | + } | |
| 42 | +} | |
| @@ -0,0 +1,1141 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.lang.reflect.*; | |
| 30 | +import java.security.*; | |
| 31 | +import java.util.*; | |
| 32 | +import javax.swing.*; | |
| 33 | +import javax.swing.plaf.*; | |
| 34 | +import javax.swing.plaf.synth.*; | |
| 35 | + | |
| 36 | +import sun.awt.AppContext; | |
| 37 | +import sun.awt.UNIXToolkit; | |
| 38 | +import sun.swing.SwingUtilities2; | |
| 39 | +import sun.swing.plaf.synth.SynthIcon; | |
| 40 | + | |
| 41 | +import com.sun.java.swing.plaf.gtk.GTKEngine.WidgetType; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * | |
| 45 | + * @author Scott Violet | |
| 46 | + */ | |
| 47 | +class GTKStyle extends SynthStyle implements GTKConstants { | |
| 48 | + | |
| 49 | + private static native int nativeGetXThickness(int widgetType); | |
| 50 | + private static native int nativeGetYThickness(int widgetType); | |
| 51 | + private static native int nativeGetColorForState(int widgetType, | |
| 52 | + int state, int typeID); | |
| 53 | + private static native Object nativeGetClassValue(int widgetType, | |
| 54 | + String key); | |
| 55 | + private static native String nativeGetPangoFontName(int widgetType); | |
| 56 | + | |
| 57 | + private static final String ICON_PROPERTY_PREFIX = "gtk.icon."; | |
| 58 | + | |
| 59 | + static final Color BLACK_COLOR = new ColorUIResource(Color.BLACK); | |
| 60 | + static final Color WHITE_COLOR = new ColorUIResource(Color.WHITE); | |
| 61 | + | |
| 62 | + static final Font DEFAULT_FONT = new FontUIResource("sansserif", | |
| 63 | + Font.PLAIN, 10 ); | |
| 64 | + static final Insets BUTTON_DEFAULT_BORDER_INSETS = new Insets(1, 1, 1, 1); | |
| 65 | + | |
| 66 | + private static final GTKGraphicsUtils GTK_GRAPHICS = new GTKGraphicsUtils(); | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Maps from a key that is passed to Style.get to the equivalent class | |
| 70 | + * specific key. | |
| 71 | + */ | |
| 72 | + private static final Map<String,String> CLASS_SPECIFIC_MAP; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Backing style properties that are used if the style does not | |
| 76 | + * defined the property. | |
| 77 | + */ | |
| 78 | + private static final Map<String,GTKStockIcon> ICONS_MAP; | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * The font used for this particular style, as determined at | |
| 82 | + * construction time. | |
| 83 | + */ | |
| 84 | + private final Font font; | |
| 85 | + | |
| 86 | + /** Widget type used when looking up class specific values. */ | |
| 87 | + private final int widgetType; | |
| 88 | + | |
| 89 | + /** The x/y thickness values for this particular style. */ | |
| 90 | + private final int xThickness, yThickness; | |
| 91 | + | |
| 92 | + GTKStyle(Font userFont, WidgetType widgetType) { | |
| 93 | + this.widgetType = widgetType.ordinal(); | |
| 94 | + | |
| 95 | + String pangoFontName; | |
| 96 | + synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 97 | + xThickness = nativeGetXThickness(this.widgetType); | |
| 98 | + yThickness = nativeGetYThickness(this.widgetType); | |
| 99 | + pangoFontName = nativeGetPangoFontName(this.widgetType); | |
| 100 | + } | |
| 101 | + | |
| 102 | + Font pangoFont = null; | |
| 103 | + if (pangoFontName != null) { | |
| 104 | + pangoFont = PangoFonts.lookupFont(pangoFontName); | |
| 105 | + } | |
| 106 | + if (pangoFont != null) { | |
| 107 | + this.font = pangoFont; | |
| 108 | + } else if (userFont != null) { | |
| 109 | + this.font = userFont; | |
| 110 | + } else { | |
| 111 | + this.font = DEFAULT_FONT; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + @Override | |
| 116 | + public void installDefaults(SynthContext context) { | |
| 117 | + super.installDefaults(context); | |
| 118 | + if (!context.getRegion().isSubregion()) { | |
| 119 | + context.getComponent().putClientProperty( | |
| 120 | + SwingUtilities2.AA_TEXT_PROPERTY_KEY, | |
| 121 | + GTKLookAndFeel.aaTextInfo); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + @Override | |
| 126 | + public SynthGraphicsUtils getGraphicsUtils(SynthContext context) { | |
| 127 | + return GTK_GRAPHICS; | |
| 128 | + } | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * Returns a <code>SynthPainter</code> that will route the appropriate | |
| 132 | + * calls to a <code>GTKEngine</code>. | |
| 133 | + * | |
| 134 | + * @param state SynthContext indentifying requestor | |
| 135 | + * @return SynthPainter | |
| 136 | + */ | |
| 137 | + @Override | |
| 138 | + public SynthPainter getPainter(SynthContext state) { | |
| 139 | + return GTKPainter.INSTANCE; | |
| 140 | + } | |
| 141 | + | |
| 142 | + protected Color getColorForState(SynthContext context, ColorType type) { | |
| 143 | + if (type == ColorType.FOCUS || type == GTKColorType.BLACK) { | |
| 144 | + return BLACK_COLOR; | |
| 145 | + } | |
| 146 | + else if (type == GTKColorType.WHITE) { | |
| 147 | + return WHITE_COLOR; | |
| 148 | + } | |
| 149 | + | |
| 150 | + Region id = context.getRegion(); | |
| 151 | + int state = context.getComponentState(); | |
| 152 | + state = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 153 | + | |
| 154 | + if (type == ColorType.TEXT_FOREGROUND && | |
| 155 | + (id == Region.BUTTON || | |
| 156 | + id == Region.CHECK_BOX || | |
| 157 | + id == Region.CHECK_BOX_MENU_ITEM || | |
| 158 | + id == Region.MENU || | |
| 159 | + id == Region.MENU_ITEM || | |
| 160 | + id == Region.RADIO_BUTTON || | |
| 161 | + id == Region.RADIO_BUTTON_MENU_ITEM || | |
| 162 | + id == Region.TABBED_PANE_TAB || | |
| 163 | + id == Region.TOGGLE_BUTTON || | |
| 164 | + id == Region.TOOL_TIP || | |
| 165 | + id == Region.MENU_ITEM_ACCELERATOR || | |
| 166 | + id == Region.TABBED_PANE_TAB)) { | |
| 167 | + type = ColorType.FOREGROUND; | |
| 168 | + } else if (id == Region.TABLE || | |
| 169 | + id == Region.LIST || | |
| 170 | + id == Region.TREE || | |
| 171 | + id == Region.TREE_CELL) { | |
| 172 | + if (type == ColorType.FOREGROUND) { | |
| 173 | + type = ColorType.TEXT_FOREGROUND; | |
| 174 | + if (state == SynthConstants.PRESSED) { | |
| 175 | + state = SynthConstants.SELECTED; | |
| 176 | + } | |
| 177 | + } else if (type == ColorType.BACKGROUND) { | |
| 178 | + type = ColorType.TEXT_BACKGROUND; | |
| 179 | + } | |
| 180 | + } | |
| 181 | + | |
| 182 | + return getStyleSpecificColor(context, state, type); | |
| 183 | + } | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * Returns color specific to the current style. This method is | |
| 187 | + * invoked when other variants don't fit. | |
| 188 | + */ | |
| 189 | + private Color getStyleSpecificColor(SynthContext context, int state, | |
| 190 | + ColorType type) | |
| 191 | + { | |
| 192 | + state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal(); | |
| 193 | + synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 194 | + int rgb = nativeGetColorForState(widgetType, state, | |
| 195 | + type.getID()); | |
| 196 | + return new ColorUIResource(rgb); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + Color getGTKColor(int state, ColorType type) { | |
| 201 | + return getGTKColor(null, state, type); | |
| 202 | + } | |
| 203 | + | |
| 204 | + /** | |
| 205 | + * Returns the color for the specified state. | |
| 206 | + * | |
| 207 | + * @param context SynthContext identifying requester | |
| 208 | + * @param state to get the color for | |
| 209 | + * @param type of the color | |
| 210 | + * @return Color to render with | |
| 211 | + */ | |
| 212 | + Color getGTKColor(SynthContext context, int state, ColorType type) { | |
| 213 | + if (context != null) { | |
| 214 | + JComponent c = context.getComponent(); | |
| 215 | + Region id = context.getRegion(); | |
| 216 | + | |
| 217 | + state = GTKLookAndFeel.synthStateToGTKState(id, state); | |
| 218 | + if (!id.isSubregion() && | |
| 219 | + (state & SynthConstants.ENABLED) != 0) { | |
| 220 | + if (type == ColorType.BACKGROUND || | |
| 221 | + type == ColorType.TEXT_BACKGROUND) { | |
| 222 | + Color bg = c.getBackground(); | |
| 223 | + if (!(bg instanceof UIResource)) { | |
| 224 | + return bg; | |
| 225 | + } | |
| 226 | + } | |
| 227 | + else if (type == ColorType.FOREGROUND || | |
| 228 | + type == ColorType.TEXT_FOREGROUND) { | |
| 229 | + Color fg = c.getForeground(); | |
| 230 | + if (!(fg instanceof UIResource)) { | |
| 231 | + return fg; | |
| 232 | + } | |
| 233 | + } | |
| 234 | + } | |
| 235 | + } | |
| 236 | + | |
| 237 | + return getStyleSpecificColor(context, state, type); | |
| 238 | + } | |
| 239 | + | |
| 240 | + @Override | |
| 241 | + public Color getColor(SynthContext context, ColorType type) { | |
| 242 | + JComponent c = context.getComponent(); | |
| 243 | + Region id = context.getRegion(); | |
| 244 | + int state = context.getComponentState(); | |
| 245 | + | |
| 246 | + if (c.getName() == "Table.cellRenderer") { | |
| 247 | + if (type == ColorType.BACKGROUND) { | |
| 248 | + return c.getBackground(); | |
| 249 | + } | |
| 250 | + if (type == ColorType.FOREGROUND) { | |
| 251 | + return c.getForeground(); | |
| 252 | + } | |
| 253 | + } | |
| 254 | + | |
| 255 | + if (id == Region.LABEL && type == ColorType.TEXT_FOREGROUND) { | |
| 256 | + type = ColorType.FOREGROUND; | |
| 257 | + } | |
| 258 | + | |
| 259 | + // For the enabled state, prefer the widget's colors | |
| 260 | + if (!id.isSubregion() && (state & SynthConstants.ENABLED) != 0) { | |
| 261 | + if (type == ColorType.BACKGROUND) { | |
| 262 | + return c.getBackground(); | |
| 263 | + } | |
| 264 | + else if (type == ColorType.FOREGROUND) { | |
| 265 | + return c.getForeground(); | |
| 266 | + } | |
| 267 | + else if (type == ColorType.TEXT_FOREGROUND) { | |
| 268 | + // If getForeground returns a non-UIResource it means the | |
| 269 | + // developer has explicitly set the foreground, use it over | |
| 270 | + // that of TEXT_FOREGROUND as that is typically the expected | |
| 271 | + // behavior. | |
| 272 | + Color color = c.getForeground(); | |
| 273 | + if (color != null && !(color instanceof UIResource)) { | |
| 274 | + return color; | |
| 275 | + } | |
| 276 | + } | |
| 277 | + } | |
| 278 | + return getColorForState(context, type); | |
| 279 | + } | |
| 280 | + | |
| 281 | + protected Font getFontForState(SynthContext context) { | |
| 282 | + return font; | |
| 283 | + } | |
| 284 | + | |
| 285 | + /** | |
| 286 | + * Returns the X thickness to use for this GTKStyle. | |
| 287 | + * | |
| 288 | + * @return x thickness. | |
| 289 | + */ | |
| 290 | + int getXThickness() { | |
| 291 | + return xThickness; | |
| 292 | + } | |
| 293 | + | |
| 294 | + /** | |
| 295 | + * Returns the Y thickness to use for this GTKStyle. | |
| 296 | + * | |
| 297 | + * @return y thickness. | |
| 298 | + */ | |
| 299 | + int getYThickness() { | |
| 300 | + return yThickness; | |
| 301 | + } | |
| 302 | + | |
| 303 | + /** | |
| 304 | + * Returns the Insets. If <code>insets</code> is non-null the resulting | |
| 305 | + * insets will be placed in it, otherwise a new Insets object will be | |
| 306 | + * created and returned. | |
| 307 | + * | |
| 308 | + * @param context SynthContext indentifying requestor | |
| 309 | + * @param insets Where to place Insets | |
| 310 | + * @return Insets. | |
| 311 | + */ | |
| 312 | + @Override | |
| 313 | + public Insets getInsets(SynthContext state, Insets insets) { | |
| 314 | + Region id = state.getRegion(); | |
| 315 | + JComponent component = state.getComponent(); | |
| 316 | + String name = (id.isSubregion()) ? null : component.getName(); | |
| 317 | + | |
| 318 | + if (insets == null) { | |
| 319 | + insets = new Insets(0, 0, 0, 0); | |
| 320 | + } else { | |
| 321 | + insets.top = insets.bottom = insets.left = insets.right = 0; | |
| 322 | + } | |
| 323 | + | |
| 324 | + if (id == Region.ARROW_BUTTON || id == Region.BUTTON || | |
| 325 | + id == Region.TOGGLE_BUTTON) { | |
| 326 | + if ("Spinner.previousButton" == name || | |
| 327 | + "Spinner.nextButton" == name) { | |
| 328 | + return getSimpleInsets(state, insets, 1); | |
| 329 | + } else { | |
| 330 | + return getButtonInsets(state, insets); | |
| 331 | + } | |
| 332 | + } | |
| 333 | + else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) { | |
| 334 | + return getRadioInsets(state, insets); | |
| 335 | + } | |
| 336 | + else if (id == Region.MENU_BAR) { | |
| 337 | + return getMenuBarInsets(state, insets); | |
| 338 | + } | |
| 339 | + else if (id == Region.MENU || | |
| 340 | + id == Region.MENU_ITEM || | |
| 341 | + id == Region.CHECK_BOX_MENU_ITEM || | |
| 342 | + id == Region.RADIO_BUTTON_MENU_ITEM) { | |
| 343 | + return getMenuItemInsets(state, insets); | |
| 344 | + } | |
| 345 | + else if (id == Region.FORMATTED_TEXT_FIELD) { | |
| 346 | + return getTextFieldInsets(state, insets); | |
| 347 | + } | |
| 348 | + else if (id == Region.INTERNAL_FRAME) { | |
| 349 | + insets = Metacity.INSTANCE.getBorderInsets(state, insets); | |
| 350 | + } | |
| 351 | + else if (id == Region.LABEL) { | |
| 352 | + if ("TableHeader.renderer" == name) { | |
| 353 | + return getButtonInsets(state, insets); | |
| 354 | + } | |
| 355 | + else if (component instanceof ListCellRenderer) { | |
| 356 | + return getTextFieldInsets(state, insets); | |
| 357 | + } | |
| 358 | + else if ("Tree.cellRenderer" == name) { | |
| 359 | + return getSimpleInsets(state, insets, 1); | |
| 360 | + } | |
| 361 | + } | |
| 362 | + else if (id == Region.OPTION_PANE) { | |
| 363 | + return getSimpleInsets(state, insets, 6); | |
| 364 | + } | |
| 365 | + else if (id == Region.POPUP_MENU) { | |
| 366 | + return getSimpleInsets(state, insets, 2); | |
| 367 | + } | |
| 368 | + else if (id == Region.PROGRESS_BAR || id == Region.SLIDER || | |
| 369 | + id == Region.TABBED_PANE || id == Region.TABBED_PANE_CONTENT || | |
| 370 | + id == Region.TOOL_BAR || | |
| 371 | + id == Region.TOOL_BAR_DRAG_WINDOW || | |
| 372 | + id == Region.TOOL_TIP) { | |
| 373 | + return getThicknessInsets(state, insets); | |
| 374 | + } | |
| 375 | + else if (id == Region.SCROLL_BAR) { | |
| 376 | + return getScrollBarInsets(state, insets); | |
| 377 | + } | |
| 378 | + else if (id == Region.SLIDER_TRACK) { | |
| 379 | + return getSliderTrackInsets(state, insets); | |
| 380 | + } | |
| 381 | + else if (id == Region.TABBED_PANE_TAB) { | |
| 382 | + return getTabbedPaneTabInsets(state, insets); | |
| 383 | + } | |
| 384 | + else if (id == Region.TEXT_FIELD || id == Region.PASSWORD_FIELD) { | |
| 385 | + if (name == "Tree.cellEditor") { | |
| 386 | + return getSimpleInsets(state, insets, 1); | |
| 387 | + } | |
| 388 | + return getTextFieldInsets(state, insets); | |
| 389 | + } else if (id == Region.SEPARATOR || | |
| 390 | + id == Region.POPUP_MENU_SEPARATOR || | |
| 391 | + id == Region.TOOL_BAR_SEPARATOR) { | |
| 392 | + return getSeparatorInsets(state, insets); | |
| 393 | + } else if (id == GTKEngine.CustomRegion.TITLED_BORDER) { | |
| 394 | + return getThicknessInsets(state, insets); | |
| 395 | + } | |
| 396 | + return insets; | |
| 397 | + } | |
| 398 | + | |
| 399 | + private Insets getButtonInsets(SynthContext context, Insets insets) { | |
| 400 | + // The following calculations are derived from gtkbutton.c | |
| 401 | + // (GTK+ version 2.8.20), gtk_button_size_allocate() method. | |
| 402 | + int CHILD_SPACING = 1; | |
| 403 | + int focusSize = getClassSpecificIntValue(context, "focus-line-width",1); | |
| 404 | + int focusPad = getClassSpecificIntValue(context, "focus-padding", 1); | |
| 405 | + int xThickness = getXThickness(); | |
| 406 | + int yThickness = getYThickness(); | |
| 407 | + int w = focusSize + focusPad + xThickness + CHILD_SPACING; | |
| 408 | + int h = focusSize + focusPad + yThickness + CHILD_SPACING; | |
| 409 | + insets.left = insets.right = w; | |
| 410 | + insets.top = insets.bottom = h; | |
| 411 | + | |
| 412 | + Component component = context.getComponent(); | |
| 413 | + if ((component instanceof JButton) && | |
| 414 | + !(component.getParent() instanceof JToolBar) && | |
| 415 | + ((JButton)component).isDefaultCapable()) | |
| 416 | + { | |
| 417 | + // Include the default border insets, but only for JButtons | |
| 418 | + // that are default capable. Note that | |
| 419 | + // JButton.getDefaultCapable() returns true by default, but | |
| 420 | + // GtkToolButtons are never default capable, so we skip this | |
| 421 | + // step if the button is contained in a toolbar. | |
| 422 | + Insets defaultInsets = getClassSpecificInsetsValue(context, | |
| 423 | + "default-border", BUTTON_DEFAULT_BORDER_INSETS); | |
| 424 | + insets.left += defaultInsets.left; | |
| 425 | + insets.right += defaultInsets.right; | |
| 426 | + insets.top += defaultInsets.top; | |
| 427 | + insets.bottom += defaultInsets.bottom; | |
| 428 | + } | |
| 429 | + | |
| 430 | + return insets; | |
| 431 | + } | |
| 432 | + | |
| 433 | + /* | |
| 434 | + * This is used for both RADIO_BUTTON and CHECK_BOX. | |
| 435 | + */ | |
| 436 | + private Insets getRadioInsets(SynthContext context, Insets insets) { | |
| 437 | + // The following calculations are derived from gtkcheckbutton.c | |
| 438 | + // (GTK+ version 2.8.20), gtk_check_button_size_allocate() method. | |
| 439 | + int focusSize = | |
| 440 | + getClassSpecificIntValue(context, "focus-line-width", 1); | |
| 441 | + int focusPad = | |
| 442 | + getClassSpecificIntValue(context, "focus-padding", 1); | |
| 443 | + int totalFocus = focusSize + focusPad; | |
| 444 | + | |
| 445 | + // Note: GTKIconFactory.DelegateIcon will have already included the | |
| 446 | + // "indicator-spacing" value in the size of the indicator icon, | |
| 447 | + // which explains why we use zero as the left inset (or right inset | |
| 448 | + // in the RTL case); see 6489585 for more details. | |
| 449 | + insets.top = totalFocus; | |
| 450 | + insets.bottom = totalFocus; | |
| 451 | + if (context.getComponent().getComponentOrientation().isLeftToRight()) { | |
| 452 | + insets.left = 0; | |
| 453 | + insets.right = totalFocus; | |
| 454 | + } else { | |
| 455 | + insets.left = totalFocus; | |
| 456 | + insets.right = 0; | |
| 457 | + } | |
| 458 | + | |
| 459 | + return insets; | |
| 460 | + } | |
| 461 | + | |
| 462 | + private Insets getMenuBarInsets(SynthContext context, Insets insets) { | |
| 463 | + // The following calculations are derived from gtkmenubar.c | |
| 464 | + // (GTK+ version 2.8.20), gtk_menu_bar_size_allocate() method. | |
| 465 | + int internalPadding = getClassSpecificIntValue(context, | |
| 466 | + "internal-padding", 1); | |
| 467 | + int xThickness = getXThickness(); | |
| 468 | + int yThickness = getYThickness(); | |
| 469 | + insets.left = insets.right = xThickness + internalPadding; | |
| 470 | + insets.top = insets.bottom = yThickness + internalPadding; | |
| 471 | + return insets; | |
| 472 | + } | |
| 473 | + | |
| 474 | + private Insets getMenuItemInsets(SynthContext context, Insets insets) { | |
| 475 | + // The following calculations are derived from gtkmenuitem.c | |
| 476 | + // (GTK+ version 2.8.20), gtk_menu_item_size_allocate() method. | |
| 477 | + int horizPadding = getClassSpecificIntValue(context, | |
| 478 | + "horizontal-padding", 3); | |
| 479 | + int xThickness = getXThickness(); | |
| 480 | + int yThickness = getYThickness(); | |
| 481 | + insets.left = insets.right = xThickness + horizPadding; | |
| 482 | + insets.top = insets.bottom = yThickness; | |
| 483 | + return insets; | |
| 484 | + } | |
| 485 | + | |
| 486 | + private Insets getThicknessInsets(SynthContext context, Insets insets) { | |
| 487 | + insets.left = insets.right = getXThickness(); | |
| 488 | + insets.top = insets.bottom = getYThickness(); | |
| 489 | + return insets; | |
| 490 | + } | |
| 491 | + | |
| 492 | + private Insets getSeparatorInsets(SynthContext context, Insets insets) { | |
| 493 | + int horizPadding = 0; | |
| 494 | + if (context.getRegion() == Region.POPUP_MENU_SEPARATOR) { | |
| 495 | + horizPadding = | |
| 496 | + getClassSpecificIntValue(context, "horizontal-padding", 3); | |
| 497 | + } | |
| 498 | + insets.right = insets.left = getXThickness() + horizPadding; | |
| 499 | + insets.top = insets.bottom = getYThickness(); | |
| 500 | + return insets; | |
| 501 | + } | |
| 502 | + | |
| 503 | + private Insets getSliderTrackInsets(SynthContext context, Insets insets) { | |
| 504 | + int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1); | |
| 505 | + int focusPad = getClassSpecificIntValue(context, "focus-padding", 1); | |
| 506 | + insets.top = insets.bottom = | |
| 507 | + insets.left = insets.right = focusSize + focusPad; | |
| 508 | + return insets; | |
| 509 | + } | |
| 510 | + | |
| 511 | + private Insets getSimpleInsets(SynthContext context, Insets insets, int n) { | |
| 512 | + insets.top = insets.bottom = insets.right = insets.left = n; | |
| 513 | + return insets; | |
| 514 | + } | |
| 515 | + | |
| 516 | + private Insets getTabbedPaneTabInsets(SynthContext context, Insets insets) { | |
| 517 | + int xThickness = getXThickness(); | |
| 518 | + int yThickness = getYThickness(); | |
| 519 | + int focusSize = getClassSpecificIntValue(context, "focus-line-width",1); | |
| 520 | + int pad = 2; | |
| 521 | + | |
| 522 | + insets.left = insets.right = focusSize + pad + xThickness; | |
| 523 | + insets.top = insets.bottom = focusSize + pad + yThickness; | |
| 524 | + return insets; | |
| 525 | + } | |
| 526 | + | |
| 527 | + // NOTE: this is called for ComboBox, and FormattedTextField also | |
| 528 | + private Insets getTextFieldInsets(SynthContext context, Insets insets) { | |
| 529 | + insets = getClassSpecificInsetsValue(context, "inner-border", | |
| 530 | + getSimpleInsets(context, insets, 2)); | |
| 531 | + | |
| 532 | + int xThickness = getXThickness(); | |
| 533 | + int yThickness = getYThickness(); | |
| 534 | + boolean interiorFocus = | |
| 535 | + getClassSpecificBoolValue(context, "interior-focus", true); | |
| 536 | + int focusSize = 0; | |
| 537 | + | |
| 538 | + if (!interiorFocus) { | |
| 539 | + focusSize = getClassSpecificIntValue(context, "focus-line-width",1); | |
| 540 | + } | |
| 541 | + | |
| 542 | + insets.left += focusSize + xThickness; | |
| 543 | + insets.right += focusSize + xThickness; | |
| 544 | + insets.top += focusSize + yThickness; | |
| 545 | + insets.bottom += focusSize + yThickness; | |
| 546 | + return insets; | |
| 547 | + } | |
| 548 | + | |
| 549 | + private Insets getScrollBarInsets(SynthContext context, Insets insets) { | |
| 550 | + int troughBorder = | |
| 551 | + getClassSpecificIntValue(context, "trough-border", 1); | |
| 552 | + insets.left = insets.right = insets.top = insets.bottom = troughBorder; | |
| 553 | + | |
| 554 | + JComponent c = context.getComponent(); | |
| 555 | + if (c.getParent() instanceof JScrollPane) { | |
| 556 | + // This scrollbar is part of a scrollpane; use only the | |
| 557 | + // "scrollbar-spacing" style property to determine the padding | |
| 558 | + // between the scrollbar and its parent scrollpane. | |
| 559 | + int spacing = | |
| 560 | + getClassSpecificIntValue(WidgetType.SCROLL_PANE, | |
| 561 | + "scrollbar-spacing", 3); | |
| 562 | + if (((JScrollBar)c).getOrientation() == JScrollBar.HORIZONTAL) { | |
| 563 | + insets.top += spacing; | |
| 564 | + } else { | |
| 565 | + if (c.getComponentOrientation().isLeftToRight()) { | |
| 566 | + insets.left += spacing; | |
| 567 | + } else { | |
| 568 | + insets.right += spacing; | |
| 569 | + } | |
| 570 | + } | |
| 571 | + } else { | |
| 572 | + // This is a standalone scrollbar; leave enough room for the | |
| 573 | + // focus line in addition to the trough border. | |
| 574 | + if (c.isFocusable()) { | |
| 575 | + int focusSize = | |
| 576 | + getClassSpecificIntValue(context, "focus-line-width", 1); | |
| 577 | + int focusPad = | |
| 578 | + getClassSpecificIntValue(context, "focus-padding", 1); | |
| 579 | + int totalFocus = focusSize + focusPad; | |
| 580 | + insets.left += totalFocus; | |
| 581 | + insets.right += totalFocus; | |
| 582 | + insets.top += totalFocus; | |
| 583 | + insets.bottom += totalFocus; | |
| 584 | + } | |
| 585 | + } | |
| 586 | + return insets; | |
| 587 | + } | |
| 588 | + | |
| 589 | + /** | |
| 590 | + * Returns the value for a class specific property for a particular | |
| 591 | + * WidgetType. This method is useful in those cases where we need to | |
| 592 | + * fetch a value for a Region that is not associated with the component | |
| 593 | + * currently in use (e.g. we need to figure out the insets for a | |
| 594 | + * SCROLL_BAR, but certain values can only be extracted from a | |
| 595 | + * SCROLL_PANE region). | |
| 596 | + * | |
| 597 | + * @param wt WidgetType for which to fetch the value | |
| 598 | + * @param key Key identifying class specific value | |
| 599 | + * @return Value, or null if one has not been defined | |
| 600 | + */ | |
| 601 | + private static Object getClassSpecificValue(WidgetType wt, String key) { | |
| 602 | + synchronized (UNIXToolkit.GTK_LOCK) { | |
| 603 | + return nativeGetClassValue(wt.ordinal(), key); | |
| 604 | + } | |
| 605 | + } | |
| 606 | + | |
| 607 | + /** | |
| 608 | + * Convenience method to get a class specific integer value for | |
| 609 | + * a particular WidgetType. | |
| 610 | + * | |
| 611 | + * @param wt WidgetType for which to fetch the value | |
| 612 | + * @param key Key identifying class specific value | |
| 613 | + * @param defaultValue Returned if there is no value for the specified | |
| 614 | + * type | |
| 615 | + * @return Value, or defaultValue if <code>key</code> is not defined | |
| 616 | + */ | |
| 617 | + private static int getClassSpecificIntValue(WidgetType wt, String key, | |
| 618 | + int defaultValue) | |
| 619 | + { | |
| 620 | + Object value = getClassSpecificValue(wt, key); | |
| 621 | + if (value instanceof Number) { | |
| 622 | + return ((Number)value).intValue(); | |
| 623 | + } | |
| 624 | + return defaultValue; | |
| 625 | + } | |
| 626 | + | |
| 627 | + /** | |
| 628 | + * Returns the value for a class specific property. A class specific value | |
| 629 | + * is a value that will be picked up based on class hierarchy. | |
| 630 | + * | |
| 631 | + * @param key Key identifying class specific value | |
| 632 | + * @return Value, or null if one has not been defined. | |
| 633 | + */ | |
| 634 | + Object getClassSpecificValue(String key) { | |
| 635 | + synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 636 | + return nativeGetClassValue(widgetType, key); | |
| 637 | + } | |
| 638 | + } | |
| 639 | + | |
| 640 | + /** | |
| 641 | + * Convenience method to get a class specific integer value. | |
| 642 | + * | |
| 643 | + * @param context SynthContext indentifying requestor | |
| 644 | + * @param key Key identifying class specific value | |
| 645 | + * @param defaultValue Returned if there is no value for the specified | |
| 646 | + * type | |
| 647 | + * @return Value, or defaultValue if <code>key</code> is not defined | |
| 648 | + */ | |
| 649 | + int getClassSpecificIntValue(SynthContext context, String key, | |
| 650 | + int defaultValue) | |
| 651 | + { | |
| 652 | + Object value = getClassSpecificValue(key); | |
| 653 | + | |
| 654 | + if (value instanceof Number) { | |
| 655 | + return ((Number)value).intValue(); | |
| 656 | + } | |
| 657 | + return defaultValue; | |
| 658 | + } | |
| 659 | + | |
| 660 | + /** | |
| 661 | + * Convenience method to get a class specific Insets value. | |
| 662 | + * | |
| 663 | + * @param context SynthContext indentifying requestor | |
| 664 | + * @param key Key identifying class specific value | |
| 665 | + * @param defaultValue Returned if there is no value for the specified | |
| 666 | + * type | |
| 667 | + * @return Value, or defaultValue if <code>key</code> is not defined | |
| 668 | + */ | |
| 669 | + Insets getClassSpecificInsetsValue(SynthContext context, String key, | |
| 670 | + Insets defaultValue) | |
| 671 | + { | |
| 672 | + Object value = getClassSpecificValue(key); | |
| 673 | + | |
| 674 | + if (value instanceof Insets) { | |
| 675 | + return (Insets)value; | |
| 676 | + } | |
| 677 | + return defaultValue; | |
| 678 | + } | |
| 679 | + | |
| 680 | + /** | |
| 681 | + * Convenience method to get a class specific Boolean value. | |
| 682 | + * | |
| 683 | + * @param context SynthContext indentifying requestor | |
| 684 | + * @param key Key identifying class specific value | |
| 685 | + * @param defaultValue Returned if there is no value for the specified | |
| 686 | + * type | |
| 687 | + * @return Value, or defaultValue if <code>key</code> is not defined | |
| 688 | + */ | |
| 689 | + boolean getClassSpecificBoolValue(SynthContext context, String key, | |
| 690 | + boolean defaultValue) | |
| 691 | + { | |
| 692 | + Object value = getClassSpecificValue(key); | |
| 693 | + | |
| 694 | + if (value instanceof Boolean) { | |
| 695 | + return ((Boolean)value).booleanValue(); | |
| 696 | + } | |
| 697 | + return defaultValue; | |
| 698 | + } | |
| 699 | + | |
| 700 | + /** | |
| 701 | + * Returns the value to initialize the opacity property of the Component | |
| 702 | + * to. A Style should NOT assume the opacity will remain this value, the | |
| 703 | + * developer may reset it or override it. | |
| 704 | + * | |
| 705 | + * @param context SynthContext indentifying requestor | |
| 706 | + * @return opaque Whether or not the JComponent is opaque. | |
| 707 | + */ | |
| 708 | + @Override | |
| 709 | + public boolean isOpaque(SynthContext context) { | |
| 710 | + Region region = context.getRegion(); | |
| 711 | + if (region == Region.COMBO_BOX || | |
| 712 | + region == Region.DESKTOP_PANE || | |
| 713 | + region == Region.DESKTOP_ICON || | |
| 714 | + region == Region.EDITOR_PANE || | |
| 715 | + region == Region.FORMATTED_TEXT_FIELD || | |
| 716 | + region == Region.INTERNAL_FRAME || | |
| 717 | + region == Region.LIST || | |
| 718 | + region == Region.MENU_BAR || | |
| 719 | + region == Region.PANEL || | |
| 720 | + region == Region.PASSWORD_FIELD || | |
| 721 | + region == Region.POPUP_MENU || | |
| 722 | + region == Region.PROGRESS_BAR || | |
| 723 | + region == Region.ROOT_PANE || | |
| 724 | + region == Region.SCROLL_PANE || | |
| 725 | + region == Region.SPINNER || | |
| 726 | + region == Region.SPLIT_PANE_DIVIDER || | |
| 727 | + region == Region.TABLE || | |
| 728 | + region == Region.TEXT_AREA || | |
| 729 | + region == Region.TEXT_FIELD || | |
| 730 | + region == Region.TEXT_PANE || | |
| 731 | + region == Region.TOOL_BAR_DRAG_WINDOW || | |
| 732 | + region == Region.TOOL_TIP || | |
| 733 | + region == Region.TREE || | |
| 734 | + region == Region.VIEWPORT) { | |
| 735 | + return true; | |
| 736 | + } | |
| 737 | + Component c = context.getComponent(); | |
| 738 | + String name = c.getName(); | |
| 739 | + if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") { | |
| 740 | + return true; | |
| 741 | + } | |
| 742 | + return false; | |
| 743 | + } | |
| 744 | + | |
| 745 | + @Override | |
| 746 | + public Object get(SynthContext context, Object key) { | |
| 747 | + // See if this is a class specific value. | |
| 748 | + String classKey = CLASS_SPECIFIC_MAP.get(key); | |
| 749 | + if (classKey != null) { | |
| 750 | + Object value = getClassSpecificValue(classKey); | |
| 751 | + if (value != null) { | |
| 752 | + return value; | |
| 753 | + } | |
| 754 | + } | |
| 755 | + | |
| 756 | + // Is it a specific value ? | |
| 757 | + if (key == "ScrollPane.viewportBorderInsets") { | |
| 758 | + return getThicknessInsets(context, new Insets(0, 0, 0, 0)); | |
| 759 | + } | |
| 760 | + else if (key == "Slider.tickColor") { | |
| 761 | + return getColorForState(context, ColorType.FOREGROUND); | |
| 762 | + } | |
| 763 | + else if (key == "ScrollBar.minimumThumbSize") { | |
| 764 | + int len = | |
| 765 | + getClassSpecificIntValue(context, "min-slider-length", 21); | |
| 766 | + JScrollBar sb = (JScrollBar)context.getComponent(); | |
| 767 | + if (sb.getOrientation() == JScrollBar.HORIZONTAL) { | |
| 768 | + return new DimensionUIResource(len, 0); | |
| 769 | + } else { | |
| 770 | + return new DimensionUIResource(0, len); | |
| 771 | + } | |
| 772 | + } | |
| 773 | + else if (key == "Separator.thickness") { | |
| 774 | + JSeparator sep = (JSeparator)context.getComponent(); | |
| 775 | + if (sep.getOrientation() == JSeparator.HORIZONTAL) { | |
| 776 | + return getYThickness(); | |
| 777 | + } else { | |
| 778 | + return getXThickness(); | |
| 779 | + } | |
| 780 | + } | |
| 781 | + else if (key == "ToolBar.separatorSize") { | |
| 782 | + int size = getClassSpecificIntValue(WidgetType.TOOL_BAR, | |
| 783 | + "space-size", 12); | |
| 784 | + return new DimensionUIResource(size, size); | |
| 785 | + } | |
| 786 | + else if (key == "ScrollBar.buttonSize") { | |
| 787 | + JScrollBar sb = (JScrollBar)context.getComponent().getParent(); | |
| 788 | + boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL); | |
| 789 | + WidgetType wt = horiz ? | |
| 790 | + WidgetType.HSCROLL_BAR : WidgetType.VSCROLL_BAR; | |
| 791 | + int sliderWidth = getClassSpecificIntValue(wt, "slider-width", 14); | |
| 792 | + int stepperSize = getClassSpecificIntValue(wt, "stepper-size", 14); | |
| 793 | + return horiz ? | |
| 794 | + new DimensionUIResource(stepperSize, sliderWidth) : | |
| 795 | + new DimensionUIResource(sliderWidth, stepperSize); | |
| 796 | + } | |
| 797 | + else if (key == "ArrowButton.size") { | |
| 798 | + String name = context.getComponent().getName(); | |
| 799 | + if (name != null && name.startsWith("Spinner")) { | |
| 800 | + // Believe it or not, the size of a spinner arrow button is | |
| 801 | + // dependent upon the size of the spinner's font. These | |
| 802 | + // calculations come from gtkspinbutton.c (version 2.8.20), | |
| 803 | + // spin_button_get_arrow_size() method. | |
| 804 | + String pangoFontName; | |
| 805 | + synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { | |
| 806 | + pangoFontName = | |
| 807 | + nativeGetPangoFontName(WidgetType.SPINNER.ordinal()); | |
| 808 | + } | |
| 809 | + int arrowSize = (pangoFontName != null) ? | |
| 810 | + PangoFonts.getFontSize(pangoFontName) : 10; | |
| 811 | + return (arrowSize + (getXThickness() * 2)); | |
| 812 | + } | |
| 813 | + // For all other kinds of arrow buttons (e.g. combobox arrow | |
| 814 | + // buttons), we will simply fall back on the value of | |
| 815 | + // ArrowButton.size as defined in the UIDefaults for | |
| 816 | + // GTKLookAndFeel when we call UIManager.get() below... | |
| 817 | + } | |
| 818 | + else if ("CheckBox.iconTextGap".equals(key) || | |
| 819 | + "RadioButton.iconTextGap".equals(key)) | |
| 820 | + { | |
| 821 | + // The iconTextGap value needs to include "indicator-spacing" | |
| 822 | + // and it also needs to leave enough space for the focus line, | |
| 823 | + // which falls between the indicator icon and the text. | |
| 824 | + // See getRadioInsets() and 6489585 for more details. | |
| 825 | + int indicatorSpacing = | |
| 826 | + getClassSpecificIntValue(context, "indicator-spacing", 2); | |
| 827 | + int focusSize = | |
| 828 | + getClassSpecificIntValue(context, "focus-line-width", 1); | |
| 829 | + int focusPad = | |
| 830 | + getClassSpecificIntValue(context, "focus-padding", 1); | |
| 831 | + return indicatorSpacing + focusSize + focusPad; | |
| 832 | + } | |
| 833 | + | |
| 834 | + // Is it a stock icon ? | |
| 835 | + GTKStockIcon stockIcon = null; | |
| 836 | + synchronized (ICONS_MAP) { | |
| 837 | + stockIcon = ICONS_MAP.get(key); | |
| 838 | + } | |
| 839 | + | |
| 840 | + if (stockIcon != null) { | |
| 841 | + return stockIcon; | |
| 842 | + } | |
| 843 | + | |
| 844 | + // Is it another kind of value ? | |
| 845 | + if (key != "engine") { | |
| 846 | + // For backward compatability we'll fallback to the UIManager. | |
| 847 | + // We don't go to the UIManager for engine as the engine is GTK | |
| 848 | + // specific. | |
| 849 | + Object value = UIManager.get(key); | |
| 850 | + if (key == "Table.rowHeight") { | |
| 851 | + int focusLineWidth = getClassSpecificIntValue(context, | |
| 852 | + "focus-line-width", 0); | |
| 853 | + if (value == null && focusLineWidth > 0) { | |
| 854 | + value = Integer.valueOf(16 + 2 * focusLineWidth); | |
| 855 | + } | |
| 856 | + } | |
| 857 | + return value; | |
| 858 | + } | |
| 859 | + | |
| 860 | + // Don't call super, we don't want to pick up defaults from | |
| 861 | + // SynthStyle. | |
| 862 | + return null; | |
| 863 | + } | |
| 864 | + | |
| 865 | + private Icon getStockIcon(SynthContext context, String key, int type) { | |
| 866 | + TextDirection direction = TextDirection.LTR; | |
| 867 | + | |
| 868 | + if (context != null) { | |
| 869 | + ComponentOrientation co = context.getComponent(). | |
| 870 | + getComponentOrientation(); | |
| 871 | + | |
| 872 | + if (co != null && !co.isLeftToRight()) { | |
| 873 | + direction = TextDirection.RTL; | |
| 874 | + } | |
| 875 | + } | |
| 876 | + | |
| 877 | + // First try loading a theme-specific icon using the native | |
| 878 | + // GTK libraries (native GTK handles the resizing for us). | |
| 879 | + Icon icon = getStyleSpecificIcon(key, direction, type); | |
| 880 | + if (icon != null) { | |
| 881 | + return icon; | |
| 882 | + } | |
| 883 | + | |
| 884 | + // In a failure case where native GTK (unexpectedly) returns a | |
| 885 | + // null icon, we can try loading a default icon as a fallback. | |
| 886 | + String propName = ICON_PROPERTY_PREFIX + key + '.' + type + '.' + | |
| 887 | + (direction == TextDirection.RTL ? "rtl" : "ltr"); | |
| 888 | + Image img = (Image) | |
| 889 | + Toolkit.getDefaultToolkit().getDesktopProperty(propName); | |
| 890 | + if (img != null) { | |
| 891 | + return new ImageIcon(img); | |
| 892 | + } | |
| 893 | + | |
| 894 | + // In an extreme failure situation, just return null (callers are | |
| 895 | + // already prepared to handle a null icon, so the worst that can | |
| 896 | + // happen is that an icon won't be included in the button/dialog). | |
| 897 | + return null; | |
| 898 | + } | |
| 899 | + | |
| 900 | + private Icon getStyleSpecificIcon(String key, | |
| 901 | + TextDirection direction, int type) | |
| 902 | + { | |
| 903 | + UNIXToolkit tk = (UNIXToolkit)Toolkit.getDefaultToolkit(); | |
| 904 | + Image img = | |
| 905 | + tk.getStockIcon(widgetType, key, type, direction.ordinal(), null); | |
| 906 | + return (img != null) ? new ImageIcon(img) : null; | |
| 907 | + } | |
| 908 | + | |
| 909 | + static class GTKStockIconInfo { | |
| 910 | + private static Map<String,Integer> ICON_TYPE_MAP; | |
| 911 | + private static final Object ICON_SIZE_KEY = new StringBuffer("IconSize"); | |
| 912 | + | |
| 913 | + private static Dimension[] getIconSizesMap() { | |
| 914 | + AppContext appContext = AppContext.getAppContext(); | |
| 915 | + Dimension[] iconSizes = (Dimension[])appContext.get(ICON_SIZE_KEY); | |
| 916 | + | |
| 917 | + if (iconSizes == null) { | |
| 918 | + iconSizes = new Dimension[7]; | |
| 919 | + iconSizes[0] = null; // GTK_ICON_SIZE_INVALID | |
| 920 | + iconSizes[1] = new Dimension(16, 16); // GTK_ICON_SIZE_MENU | |
| 921 | + iconSizes[2] = new Dimension(18, 18); // GTK_ICON_SIZE_SMALL_TOOLBAR | |
| 922 | + iconSizes[3] = new Dimension(24, 24); // GTK_ICON_SIZE_LARGE_TOOLBAR | |
| 923 | + iconSizes[4] = new Dimension(20, 20); // GTK_ICON_SIZE_BUTTON | |
| 924 | + iconSizes[5] = new Dimension(32, 32); // GTK_ICON_SIZE_DND | |
| 925 | + iconSizes[6] = new Dimension(48, 48); // GTK_ICON_SIZE_DIALOG | |
| 926 | + appContext.put(ICON_SIZE_KEY, iconSizes); | |
| 927 | + } | |
| 928 | + return iconSizes; | |
| 929 | + } | |
| 930 | + | |
| 931 | + /** | |
| 932 | + * Return the size of a particular icon type (logical size) | |
| 933 | + * | |
| 934 | + * @param type icon type (GtkIconSize value) | |
| 935 | + * @return a Dimension object, or null if lsize is invalid | |
| 936 | + */ | |
| 937 | + public static Dimension getIconSize(int type) { | |
| 938 | + Dimension[] iconSizes = getIconSizesMap(); | |
| 939 | + return type >= 0 && type < iconSizes.length ? | |
| 940 | + iconSizes[type] : null; | |
| 941 | + } | |
| 942 | + | |
| 943 | + /** | |
| 944 | + * Change icon size in a type to size mapping. This is called by code | |
| 945 | + * that parses the gtk-icon-sizes setting | |
| 946 | + * | |
| 947 | + * @param type icon type (GtkIconSize value) | |
| 948 | + * @param w the new icon width | |
| 949 | + * @param h the new icon height | |
| 950 | + */ | |
| 951 | + public static void setIconSize(int type, int w, int h) { | |
| 952 | + Dimension[] iconSizes = getIconSizesMap(); | |
| 953 | + if (type >= 0 && type < iconSizes.length) { | |
| 954 | + iconSizes[type] = new Dimension(w, h); | |
| 955 | + } | |
| 956 | + } | |
| 957 | + | |
| 958 | + /** | |
| 959 | + * Return icon type (GtkIconSize value) given a symbolic name which can | |
| 960 | + * occur in a theme file. | |
| 961 | + * | |
| 962 | + * @param size symbolic name, e.g. gtk-button | |
| 963 | + * @return icon type. Valid types are 1 to 6 | |
| 964 | + */ | |
| 965 | + public static int getIconType(String size) { | |
| 966 | + if (size == null) { | |
| 967 | + return UNDEFINED; | |
| 968 | + } | |
| 969 | + if (ICON_TYPE_MAP == null) { | |
| 970 | + initIconTypeMap(); | |
| 971 | + } | |
| 972 | + Integer n = ICON_TYPE_MAP.get(size); | |
| 973 | + return n != null ? n.intValue() : UNDEFINED; | |
| 974 | + } | |
| 975 | + | |
| 976 | + private static void initIconTypeMap() { | |
| 977 | + ICON_TYPE_MAP = new HashMap<String,Integer>(); | |
| 978 | + ICON_TYPE_MAP.put("gtk-menu", Integer.valueOf(1)); | |
| 979 | + ICON_TYPE_MAP.put("gtk-small-toolbar", Integer.valueOf(2)); | |
| 980 | + ICON_TYPE_MAP.put("gtk-large-toolbar", Integer.valueOf(3)); | |
| 981 | + ICON_TYPE_MAP.put("gtk-button", Integer.valueOf(4)); | |
| 982 | + ICON_TYPE_MAP.put("gtk-dnd", Integer.valueOf(5)); | |
| 983 | + ICON_TYPE_MAP.put("gtk-dialog", Integer.valueOf(6)); | |
| 984 | + } | |
| 985 | + | |
| 986 | + } | |
| 987 | + | |
| 988 | + /** | |
| 989 | + * An Icon that is fetched using getStockIcon. | |
| 990 | + */ | |
| 991 | + private static class GTKStockIcon extends SynthIcon { | |
| 992 | + private String key; | |
| 993 | + private int size; | |
| 994 | + private boolean loadedLTR; | |
| 995 | + private boolean loadedRTL; | |
| 996 | + private Icon ltrIcon; | |
| 997 | + private Icon rtlIcon; | |
| 998 | + private SynthStyle style; | |
| 999 | + | |
| 1000 | + GTKStockIcon(String key, int size) { | |
| 1001 | + this.key = key; | |
| 1002 | + this.size = size; | |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + public void paintIcon(SynthContext context, Graphics g, int x, | |
| 1006 | + int y, int w, int h) { | |
| 1007 | + Icon icon = getIcon(context); | |
| 1008 | + | |
| 1009 | + if (icon != null) { | |
| 1010 | + if (context == null) { | |
| 1011 | + icon.paintIcon(null, g, x, y); | |
| 1012 | + } | |
| 1013 | + else { | |
| 1014 | + icon.paintIcon(context.getComponent(), g, x, y); | |
| 1015 | + } | |
| 1016 | + } | |
| 1017 | + } | |
| 1018 | + | |
| 1019 | + public int getIconWidth(SynthContext context) { | |
| 1020 | + Icon icon = getIcon(context); | |
| 1021 | + | |
| 1022 | + if (icon != null) { | |
| 1023 | + return icon.getIconWidth(); | |
| 1024 | + } | |
| 1025 | + return 0; | |
| 1026 | + } | |
| 1027 | + | |
| 1028 | + public int getIconHeight(SynthContext context) { | |
| 1029 | + Icon icon = getIcon(context); | |
| 1030 | + | |
| 1031 | + if (icon != null) { | |
| 1032 | + return icon.getIconHeight(); | |
| 1033 | + } | |
| 1034 | + return 0; | |
| 1035 | + } | |
| 1036 | + | |
| 1037 | + private Icon getIcon(SynthContext context) { | |
| 1038 | + if (context != null) { | |
| 1039 | + ComponentOrientation co = context.getComponent(). | |
| 1040 | + getComponentOrientation(); | |
| 1041 | + SynthStyle style = context.getStyle(); | |
| 1042 | + | |
| 1043 | + if (style != this.style) { | |
| 1044 | + this.style = style; | |
| 1045 | + loadedLTR = loadedRTL = false; | |
| 1046 | + } | |
| 1047 | + if (co == null || co.isLeftToRight()) { | |
| 1048 | + if (!loadedLTR) { | |
| 1049 | + loadedLTR = true; | |
| 1050 | + ltrIcon = ((GTKStyle)context.getStyle()). | |
| 1051 | + getStockIcon(context, key, size); | |
| 1052 | + } | |
| 1053 | + return ltrIcon; | |
| 1054 | + } | |
| 1055 | + else if (!loadedRTL) { | |
| 1056 | + loadedRTL = true; | |
| 1057 | + rtlIcon = ((GTKStyle)context.getStyle()). | |
| 1058 | + getStockIcon(context, key,size); | |
| 1059 | + } | |
| 1060 | + return rtlIcon; | |
| 1061 | + } | |
| 1062 | + return ltrIcon; | |
| 1063 | + } | |
| 1064 | + } | |
| 1065 | + | |
| 1066 | + /** | |
| 1067 | + * GTKLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>. | |
| 1068 | + * The code is duplicate so that it can get at the package private | |
| 1069 | + * classes in gtk. | |
| 1070 | + */ | |
| 1071 | + static class GTKLazyValue implements UIDefaults.LazyValue { | |
| 1072 | + /** | |
| 1073 | + * Name of the class to create. | |
| 1074 | + */ | |
| 1075 | + private String className; | |
| 1076 | + private String methodName; | |
| 1077 | + | |
| 1078 | + GTKLazyValue(String name) { | |
| 1079 | + this(name, null); | |
| 1080 | + } | |
| 1081 | + | |
| 1082 | + GTKLazyValue(String name, String methodName) { | |
| 1083 | + this.className = name; | |
| 1084 | + this.methodName = methodName; | |
| 1085 | + } | |
| 1086 | + | |
| 1087 | + public Object createValue(UIDefaults table) { | |
| 1088 | + try { | |
| 1089 | + Class c = Class.forName(className, true,Thread.currentThread(). | |
| 1090 | + getContextClassLoader()); | |
| 1091 | + | |
| 1092 | + if (methodName == null) { | |
| 1093 | + return c.newInstance(); | |
| 1094 | + } | |
| 1095 | + Method m = c.getMethod(methodName, (Class[])null); | |
| 1096 | + | |
| 1097 | + return m.invoke(c, (Object[])null); | |
| 1098 | + } catch (ClassNotFoundException cnfe) { | |
| 1099 | + } catch (IllegalAccessException iae) { | |
| 1100 | + } catch (InvocationTargetException ite) { | |
| 1101 | + } catch (NoSuchMethodException nsme) { | |
| 1102 | + } catch (InstantiationException ie) { | |
| 1103 | + } | |
| 1104 | + return null; | |
| 1105 | + } | |
| 1106 | + } | |
| 1107 | + | |
| 1108 | + static { | |
| 1109 | + CLASS_SPECIFIC_MAP = new HashMap<String,String>(); | |
| 1110 | + CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width"); | |
| 1111 | + CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border"); | |
| 1112 | + CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size"); | |
| 1113 | + CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size"); | |
| 1114 | + CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width"); | |
| 1115 | + CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width"); | |
| 1116 | + CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color"); | |
| 1117 | + CLASS_SPECIFIC_MAP.put("TextArea.caretAspectRatio", "cursor-aspect-ratio"); | |
| 1118 | + CLASS_SPECIFIC_MAP.put("TextField.caretForeground", "cursor-color"); | |
| 1119 | + CLASS_SPECIFIC_MAP.put("TextField.caretAspectRatio", "cursor-aspect-ratio"); | |
| 1120 | + CLASS_SPECIFIC_MAP.put("PasswordField.caretForeground", "cursor-color"); | |
| 1121 | + CLASS_SPECIFIC_MAP.put("PasswordField.caretAspectRatio", "cursor-aspect-ratio"); | |
| 1122 | + CLASS_SPECIFIC_MAP.put("FormattedTextField.caretForeground", "cursor-color"); | |
| 1123 | + CLASS_SPECIFIC_MAP.put("FormattedTextField.caretAspectRatio", "cursor-aspect-"); | |
| 1124 | + CLASS_SPECIFIC_MAP.put("TextPane.caretForeground", "cursor-color"); | |
| 1125 | + CLASS_SPECIFIC_MAP.put("TextPane.caretAspectRatio", "cursor-aspect-ratio"); | |
| 1126 | + CLASS_SPECIFIC_MAP.put("EditorPane.caretForeground", "cursor-color"); | |
| 1127 | + CLASS_SPECIFIC_MAP.put("EditorPane.caretAspectRatio", "cursor-aspect-ratio"); | |
| 1128 | + | |
| 1129 | + ICONS_MAP = new HashMap<String, GTKStockIcon>(); | |
| 1130 | + ICONS_MAP.put("FileChooser.cancelIcon", new GTKStockIcon("gtk-cancel", 4)); | |
| 1131 | + ICONS_MAP.put("FileChooser.okIcon", new GTKStockIcon("gtk-ok", 4)); | |
| 1132 | + ICONS_MAP.put("OptionPane.errorIcon", new GTKStockIcon("gtk-dialog-error", 6)); | |
| 1133 | + ICONS_MAP.put("OptionPane.informationIcon", new GTKStockIcon("gtk-dialog-info", 6)); | |
| 1134 | + ICONS_MAP.put("OptionPane.warningIcon", new GTKStockIcon("gtk-dialog-warning", 6)); | |
| 1135 | + ICONS_MAP.put("OptionPane.questionIcon", new GTKStockIcon("gtk-dialog-question", 6)); | |
| 1136 | + ICONS_MAP.put("OptionPane.yesIcon", new GTKStockIcon("gtk-yes", 4)); | |
| 1137 | + ICONS_MAP.put("OptionPane.noIcon", new GTKStockIcon("gtk-no", 4)); | |
| 1138 | + ICONS_MAP.put("OptionPane.cancelIcon", new GTKStockIcon("gtk-cancel", 4)); | |
| 1139 | + ICONS_MAP.put("OptionPane.okIcon", new GTKStockIcon("gtk-ok", 4)); | |
| 1140 | + } | |
| 1141 | +} | |
| @@ -0,0 +1,182 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.Font; | |
| 29 | +import java.util.*; | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.plaf.synth.*; | |
| 32 | +import com.sun.java.swing.plaf.gtk.GTKEngine.WidgetType; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * | |
| 36 | + * @author Scott Violet | |
| 37 | + */ | |
| 38 | +class GTKStyleFactory extends SynthStyleFactory { | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Saves all styles that have been accessed. In most common cases, | |
| 42 | + * the hash key is simply the WidgetType, but in more complex cases | |
| 43 | + * it will be a ComplexKey object that contains arguments to help | |
| 44 | + * differentiate similar styles. | |
| 45 | + */ | |
| 46 | + private final Map<Object, GTKStyle> stylesCache; | |
| 47 | + | |
| 48 | + private Font defaultFont; | |
| 49 | + | |
| 50 | + GTKStyleFactory() { | |
| 51 | + stylesCache = new HashMap<Object, GTKStyle>(); | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Returns the <code>GTKStyle</code> to use based on the | |
| 56 | + * <code>Region</code> id | |
| 57 | + * | |
| 58 | + * @param c this parameter isn't used, may be null. | |
| 59 | + * @param id of the region to get the style. | |
| 60 | + */ | |
| 61 | + public synchronized SynthStyle getStyle(JComponent c, Region id) { | |
| 62 | + WidgetType wt = GTKEngine.getWidgetType(c, id); | |
| 63 | + | |
| 64 | + Object key = null; | |
| 65 | + if (id == Region.SCROLL_BAR) { | |
| 66 | + // The style/insets of a scrollbar can depend on a number of | |
| 67 | + // factors (see GTKStyle.getScrollBarInsets()) so use a | |
| 68 | + // complex key here. | |
| 69 | + if (c != null) { | |
| 70 | + JScrollBar sb = (JScrollBar)c; | |
| 71 | + boolean sp = (sb.getParent() instanceof JScrollPane); | |
| 72 | + boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL); | |
| 73 | + boolean ltr = sb.getComponentOrientation().isLeftToRight(); | |
| 74 | + boolean focusable = sb.isFocusable(); | |
| 75 | + key = new ComplexKey(wt, sp, horiz, ltr, focusable); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) { | |
| 79 | + // The style/insets of a checkbox or radiobutton can depend | |
| 80 | + // on the component orientation, so use a complex key here. | |
| 81 | + if (c != null) { | |
| 82 | + boolean ltr = c.getComponentOrientation().isLeftToRight(); | |
| 83 | + key = new ComplexKey(wt, ltr); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + else if (id == Region.BUTTON) { | |
| 87 | + // The style/insets of a button can depend on whether it is | |
| 88 | + // default capable or in a toolbar, so use a complex key here. | |
| 89 | + if (c != null) { | |
| 90 | + JButton btn = (JButton)c; | |
| 91 | + boolean toolButton = (btn.getParent() instanceof JToolBar); | |
| 92 | + boolean defaultCapable = btn.isDefaultCapable(); | |
| 93 | + key = new ComplexKey(wt, toolButton, defaultCapable); | |
| 94 | + } | |
| 95 | + } | |
| 96 | + if (key == null) { | |
| 97 | + // Otherwise, just use the WidgetType as the key. | |
| 98 | + key = wt; | |
| 99 | + } | |
| 100 | + | |
| 101 | + GTKStyle result = stylesCache.get(key); | |
| 102 | + if (result == null) { | |
| 103 | + result = new GTKStyle(defaultFont, wt); | |
| 104 | + stylesCache.put(key, result); | |
| 105 | + } | |
| 106 | + | |
| 107 | + return result; | |
| 108 | + } | |
| 109 | + | |
| 110 | + void initStyles(Font defaultFont) { | |
| 111 | + this.defaultFont = defaultFont; | |
| 112 | + stylesCache.clear(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * Represents a hash key used for fetching GTKStyle objects from the | |
| 117 | + * cache. In most cases only the WidgetType is used for lookup, but | |
| 118 | + * in some complex cases, other Object arguments can be specified | |
| 119 | + * via a ComplexKey to differentiate the various styles. | |
| 120 | + */ | |
| 121 | + private static class ComplexKey { | |
| 122 | + private final WidgetType wt; | |
| 123 | + private final Object[] args; | |
| 124 | + | |
| 125 | + ComplexKey(WidgetType wt, Object... args) { | |
| 126 | + this.wt = wt; | |
| 127 | + this.args = args; | |
| 128 | + } | |
| 129 | + | |
| 130 | + @Override | |
| 131 | + public int hashCode() { | |
| 132 | + int hash = wt.hashCode(); | |
| 133 | + if (args != null) { | |
| 134 | + for (Object arg : args) { | |
| 135 | + hash = hash*29 + (arg == null ? 0 : arg.hashCode()); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + return hash; | |
| 139 | + } | |
| 140 | + | |
| 141 | + @Override | |
| 142 | + public boolean equals(Object o) { | |
| 143 | + if (!(o instanceof ComplexKey)) { | |
| 144 | + return false; | |
| 145 | + } | |
| 146 | + ComplexKey that = (ComplexKey)o; | |
| 147 | + if (this.wt == that.wt) { | |
| 148 | + if (this.args == null && that.args == null) { | |
| 149 | + return true; | |
| 150 | + } | |
| 151 | + if (this.args != null && that.args != null && | |
| 152 | + this.args.length == that.args.length) | |
| 153 | + { | |
| 154 | + for (int i = 0; i < this.args.length; i++) { | |
| 155 | + Object a1 = this.args[i]; | |
| 156 | + Object a2 = that.args[i]; | |
| 157 | + if (!(a1==null ? a2==null : a1.equals(a2))) { | |
| 158 | + return false; | |
| 159 | + } | |
| 160 | + } | |
| 161 | + return true; | |
| 162 | + } | |
| 163 | + } | |
| 164 | + return false; | |
| 165 | + } | |
| 166 | + | |
| 167 | + @Override | |
| 168 | + public String toString() { | |
| 169 | + String str = "ComplexKey[wt=" + wt; | |
| 170 | + if (args != null) { | |
| 171 | + str += ",args=["; | |
| 172 | + for (int i = 0; i < args.length; i++) { | |
| 173 | + str += args[i]; | |
| 174 | + if (i < args.length-1) str += ","; | |
| 175 | + } | |
| 176 | + str += "]"; | |
| 177 | + } | |
| 178 | + str += "]"; | |
| 179 | + return str; | |
| 180 | + } | |
| 181 | + } | |
| 182 | +} | |
| @@ -0,0 +1,2155 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.gtk; | |
| 26 | + | |
| 27 | +import sun.swing.SwingUtilities2; | |
| 28 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType; | |
| 29 | +import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType; | |
| 30 | + | |
| 31 | +import javax.swing.plaf.ColorUIResource; | |
| 32 | +import javax.swing.plaf.synth.*; | |
| 33 | + | |
| 34 | +import java.awt.*; | |
| 35 | +import java.awt.geom.*; | |
| 36 | +import java.awt.image.*; | |
| 37 | +import java.io.*; | |
| 38 | +import java.net.*; | |
| 39 | +import java.security.*; | |
| 40 | +import java.util.*; | |
| 41 | + | |
| 42 | +import javax.swing.*; | |
| 43 | +import javax.swing.border.*; | |
| 44 | + | |
| 45 | +import javax.xml.parsers.*; | |
| 46 | +import org.xml.sax.SAXException; | |
| 47 | +import org.w3c.dom.*; | |
| 48 | + | |
| 49 | +/** | |
| 50 | + */ | |
| 51 | +class Metacity implements SynthConstants { | |
| 52 | + // Tutorial: | |
| 53 | + // http://developer.gnome.org/doc/tutorials/metacity/metacity-themes.html | |
| 54 | + | |
| 55 | + // Themes: | |
| 56 | + // http://art.gnome.org/theme_list.php?category=metacity | |
| 57 | + | |
| 58 | + static Metacity INSTANCE; | |
| 59 | + | |
| 60 | + private static final String[] themeNames = { | |
| 61 | + getUserTheme(), | |
| 62 | + "blueprint", | |
| 63 | + "Bluecurve", | |
| 64 | + "Crux", | |
| 65 | + "SwingFallbackTheme" | |
| 66 | + }; | |
| 67 | + | |
| 68 | + static { | |
| 69 | + for (String themeName : themeNames) { | |
| 70 | + if (themeName != null) { | |
| 71 | + try { | |
| 72 | + INSTANCE = new Metacity(themeName); | |
| 73 | + } catch (FileNotFoundException ex) { | |
| 74 | + } catch (IOException ex) { | |
| 75 | + logError(themeName, ex); | |
| 76 | + } catch (ParserConfigurationException ex) { | |
| 77 | + logError(themeName, ex); | |
| 78 | + } catch (SAXException ex) { | |
| 79 | + logError(themeName, ex); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + if (INSTANCE != null) { | |
| 83 | + break; | |
| 84 | + } | |
| 85 | + } | |
| 86 | + if (INSTANCE == null) { | |
| 87 | + throw new Error("Could not find any installed metacity theme, and fallback failed"); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + private static boolean errorLogged = false; | |
| 92 | + private static DocumentBuilder documentBuilder; | |
| 93 | + private static Document xmlDoc; | |
| 94 | + private static String userHome; | |
| 95 | + | |
| 96 | + private Node frame_style_set; | |
| 97 | + private Map<String, Object> frameGeometry; | |
| 98 | + private Map<String, Map<String, Object>> frameGeometries; | |
| 99 | + | |
| 100 | + private LayoutManager titlePaneLayout = new TitlePaneLayout(); | |
| 101 | + | |
| 102 | + private ColorizeImageFilter imageFilter = new ColorizeImageFilter(); | |
| 103 | + private URL themeDir = null; | |
| 104 | + private SynthContext context; | |
| 105 | + private String themeName; | |
| 106 | + | |
| 107 | + private ArithmeticExpressionEvaluator aee = new ArithmeticExpressionEvaluator(); | |
| 108 | + private Map<String, Integer> variables; | |
| 109 | + | |
| 110 | + // Reusable clip shape object | |
| 111 | + private RoundRectClipShape roundedClipShape; | |
| 112 | + | |
| 113 | + protected Metacity(String themeName) throws IOException, ParserConfigurationException, SAXException { | |
| 114 | + this.themeName = themeName; | |
| 115 | + themeDir = getThemeDir(themeName); | |
| 116 | + if (themeDir != null) { | |
| 117 | + URL themeURL = new URL(themeDir, "metacity-theme-1.xml"); | |
| 118 | + xmlDoc = getXMLDoc(themeURL); | |
| 119 | + if (xmlDoc == null) { | |
| 120 | + throw new IOException(themeURL.toString()); | |
| 121 | + } | |
| 122 | + } else { | |
| 123 | + throw new FileNotFoundException(themeName); | |
| 124 | + } | |
| 125 | + | |
| 126 | + // Initialize constants | |
| 127 | + variables = new HashMap<String, Integer>(); | |
| 128 | + NodeList nodes = xmlDoc.getElementsByTagName("constant"); | |
| 129 | + int n = nodes.getLength(); | |
| 130 | + for (int i = 0; i < n; i++) { | |
| 131 | + Node node = nodes.item(i); | |
| 132 | + String name = getStringAttr(node, "name"); | |
| 133 | + if (name != null) { | |
| 134 | + String value = getStringAttr(node, "value"); | |
| 135 | + if (value != null) { | |
| 136 | + try { | |
| 137 | + variables.put(name, Integer.parseInt(value)); | |
| 138 | + } catch (NumberFormatException ex) { | |
| 139 | + logError(themeName, ex); | |
| 140 | + // Ignore bad value | |
| 141 | + } | |
| 142 | + } | |
| 143 | + } | |
| 144 | + } | |
| 145 | + | |
| 146 | + // Cache frame geometries | |
| 147 | + frameGeometries = new HashMap<String, Map<String, Object>>(); | |
| 148 | + nodes = xmlDoc.getElementsByTagName("frame_geometry"); | |
| 149 | + n = nodes.getLength(); | |
| 150 | + for (int i = 0; i < n; i++) { | |
| 151 | + Node node = nodes.item(i); | |
| 152 | + String name = getStringAttr(node, "name"); | |
| 153 | + if (name != null) { | |
| 154 | + HashMap<String, Object> gm = new HashMap<String, Object>(); | |
| 155 | + frameGeometries.put(name, gm); | |
| 156 | + | |
| 157 | + String parentGM = getStringAttr(node, "parent"); | |
| 158 | + if (parentGM != null) { | |
| 159 | + gm.putAll(frameGeometries.get(parentGM)); | |
| 160 | + } | |
| 161 | + | |
| 162 | + gm.put("has_title", | |
| 163 | + Boolean.valueOf(getBooleanAttr(node, "has_title", true))); | |
| 164 | + gm.put("rounded_top_left", | |
| 165 | + Boolean.valueOf(getBooleanAttr(node, "rounded_top_left", false))); | |
| 166 | + gm.put("rounded_top_right", | |
| 167 | + Boolean.valueOf(getBooleanAttr(node, "rounded_top_right", false))); | |
| 168 | + gm.put("rounded_bottom_left", | |
| 169 | + Boolean.valueOf(getBooleanAttr(node, "rounded_bottom_left", false))); | |
| 170 | + gm.put("rounded_bottom_right", | |
| 171 | + Boolean.valueOf(getBooleanAttr(node, "rounded_bottom_right", false))); | |
| 172 | + | |
| 173 | + NodeList childNodes = node.getChildNodes(); | |
| 174 | + int nc = childNodes.getLength(); | |
| 175 | + for (int j = 0; j < nc; j++) { | |
| 176 | + Node child = childNodes.item(j); | |
| 177 | + if (child.getNodeType() == Node.ELEMENT_NODE) { | |
| 178 | + name = child.getNodeName(); | |
| 179 | + Object value = null; | |
| 180 | + if ("distance".equals(name)) { | |
| 181 | + value = Integer.valueOf(getIntAttr(child, "value", 0)); | |
| 182 | + } else if ("border".equals(name)) { | |
| 183 | + value = new Insets(getIntAttr(child, "top", 0), | |
| 184 | + getIntAttr(child, "left", 0), | |
| 185 | + getIntAttr(child, "bottom", 0), | |
| 186 | + getIntAttr(child, "right", 0)); | |
| 187 | + } else if ("aspect_ratio".equals(name)) { | |
| 188 | + value = new Float(getFloatAttr(child, "value", 1.0F)); | |
| 189 | + } else { | |
| 190 | + logError(themeName, "Unknown Metacity frame geometry value type: "+name); | |
| 191 | + } | |
| 192 | + String childName = getStringAttr(child, "name"); | |
| 193 | + if (childName != null && value != null) { | |
| 194 | + gm.put(childName, value); | |
| 195 | + } | |
| 196 | + } | |
| 197 | + } | |
| 198 | + } | |
| 199 | + } | |
| 200 | + frameGeometry = frameGeometries.get("normal"); | |
| 201 | + } | |
| 202 | + | |
| 203 | + | |
| 204 | + public static LayoutManager getTitlePaneLayout() { | |
| 205 | + return INSTANCE.titlePaneLayout; | |
| 206 | + } | |
| 207 | + | |
| 208 | + private Shape getRoundedClipShape(int x, int y, int w, int h, | |
| 209 | + int arcw, int arch, int corners) { | |
| 210 | + if (roundedClipShape == null) { | |
| 211 | + roundedClipShape = new RoundRectClipShape(); | |
| 212 | + } | |
| 213 | + roundedClipShape.setRoundedRect(x, y, w, h, arcw, arch, corners); | |
| 214 | + | |
| 215 | + return roundedClipShape; | |
| 216 | + } | |
| 217 | + | |
| 218 | + void paintButtonBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { | |
| 219 | + updateFrameGeometry(context); | |
| 220 | + | |
| 221 | + this.context = context; | |
| 222 | + JButton button = (JButton)context.getComponent(); | |
| 223 | + String buttonName = button.getName(); | |
| 224 | + int buttonState = context.getComponentState(); | |
| 225 | + | |
| 226 | + JComponent titlePane = (JComponent)button.getParent(); | |
| 227 | + Container titlePaneParent = titlePane.getParent(); | |
| 228 | + | |
| 229 | + JInternalFrame jif; | |
| 230 | + if (titlePaneParent instanceof JInternalFrame) { | |
| 231 | + jif = (JInternalFrame)titlePaneParent; | |
| 232 | + } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) { | |
| 233 | + jif = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame(); | |
| 234 | + } else { | |
| 235 | + return; | |
| 236 | + } | |
| 237 | + | |
| 238 | + boolean active = jif.isSelected(); | |
| 239 | + button.setOpaque(false); | |
| 240 | + | |
| 241 | + String state = "normal"; | |
| 242 | + if ((buttonState & PRESSED) != 0) { | |
| 243 | + state = "pressed"; | |
| 244 | + } else if ((buttonState & MOUSE_OVER) != 0) { | |
| 245 | + state = "prelight"; | |
| 246 | + } | |
| 247 | + | |
| 248 | + String function = null; | |
| 249 | + String location = null; | |
| 250 | + boolean left_corner = false; | |
| 251 | + boolean right_corner = false; | |
| 252 | + | |
| 253 | + | |
| 254 | + if (buttonName == "InternalFrameTitlePane.menuButton") { | |
| 255 | + function = "menu"; | |
| 256 | + location = "left_left"; | |
| 257 | + left_corner = true; | |
| 258 | + } else if (buttonName == "InternalFrameTitlePane.iconifyButton") { | |
| 259 | + function = "minimize"; | |
| 260 | + int nButtons = ((jif.isIconifiable() ? 1 : 0) + | |
| 261 | + (jif.isMaximizable() ? 1 : 0) + | |
| 262 | + (jif.isClosable() ? 1 : 0)); | |
| 263 | + right_corner = (nButtons == 1); | |
| 264 | + switch (nButtons) { | |
| 265 | + case 1: location = "right_right"; break; | |
| 266 | + case 2: location = "right_middle"; break; | |
| 267 | + case 3: location = "right_left"; break; | |
| 268 | + } | |
| 269 | + } else if (buttonName == "InternalFrameTitlePane.maximizeButton") { | |
| 270 | + function = "maximize"; | |
| 271 | + right_corner = !jif.isClosable(); | |
| 272 | + location = jif.isClosable() ? "right_middle" : "right_right"; | |
| 273 | + } else if (buttonName == "InternalFrameTitlePane.closeButton") { | |
| 274 | + function = "close"; | |
| 275 | + right_corner = true; | |
| 276 | + location = "right_right"; | |
| 277 | + } | |
| 278 | + | |
| 279 | + Node frame = getNode(frame_style_set, "frame", new String[] { | |
| 280 | + "focus", (active ? "yes" : "no"), | |
| 281 | + "state", (jif.isMaximum() ? "maximized" : "normal") | |
| 282 | + }); | |
| 283 | + | |
| 284 | + if (function != null && frame != null) { | |
| 285 | + Node frame_style = getNode("frame_style", new String[] { | |
| 286 | + "name", getStringAttr(frame, "style") | |
| 287 | + }); | |
| 288 | + if (frame_style != null) { | |
| 289 | + Shape oldClip = g.getClip(); | |
| 290 | + if ((right_corner && getBoolean("rounded_top_right", false)) || | |
| 291 | + (left_corner && getBoolean("rounded_top_left", false))) { | |
| 292 | + | |
| 293 | + Point buttonLoc = button.getLocation(); | |
| 294 | + if (right_corner) { | |
| 295 | + g.setClip(getRoundedClipShape(0, 0, w, h, | |
| 296 | + 12, 12, RoundRectClipShape.TOP_RIGHT)); | |
| 297 | + } else { | |
| 298 | + g.setClip(getRoundedClipShape(0, 0, w, h, | |
| 299 | + 11, 11, RoundRectClipShape.TOP_LEFT)); | |
| 300 | + } | |
| 301 | + | |
| 302 | + Rectangle clipBounds = oldClip.getBounds(); | |
| 303 | + g.clipRect(clipBounds.x, clipBounds.y, | |
| 304 | + clipBounds.width, clipBounds.height); | |
| 305 | + } | |
| 306 | + drawButton(frame_style, location+"_background", state, g, w, h, jif); | |
| 307 | + drawButton(frame_style, function, state, g, w, h, jif); | |
| 308 | + g.setClip(oldClip); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + } | |
| 312 | + | |
| 313 | + protected void drawButton(Node frame_style, String function, String state, | |
| 314 | + Graphics g, int w, int h, JInternalFrame jif) { | |
| 315 | + Node buttonNode = getNode(frame_style, "button", | |
| 316 | + new String[] { "function", function, "state", state }); | |
| 317 | + if (buttonNode == null && !state.equals("normal")) { | |
| 318 | + buttonNode = getNode(frame_style, "button", | |
| 319 | + new String[] { "function", function, "state", "normal" }); | |
| 320 | + } | |
| 321 | + if (buttonNode != null) { | |
| 322 | + Node draw_ops; | |
| 323 | + String draw_ops_name = getStringAttr(buttonNode, "draw_ops"); | |
| 324 | + if (draw_ops_name != null) { | |
| 325 | + draw_ops = getNode("draw_ops", new String[] { "name", draw_ops_name }); | |
| 326 | + } else { | |
| 327 | + draw_ops = getNode(buttonNode, "draw_ops", null); | |
| 328 | + } | |
| 329 | + variables.put("width", w); | |
| 330 | + variables.put("height", h); | |
| 331 | + draw(draw_ops, g, jif); | |
| 332 | + } | |
| 333 | + } | |
| 334 | + | |
| 335 | + void paintFrameBorder(SynthContext context, Graphics g, int x0, int y0, int width, int height) { | |
| 336 | + updateFrameGeometry(context); | |
| 337 | + | |
| 338 | + this.context = context; | |
| 339 | + JComponent comp = context.getComponent(); | |
| 340 | + JComponent titlePane = findChild(comp, "InternalFrame.northPane"); | |
| 341 | + | |
| 342 | + if (titlePane == null) { | |
| 343 | + return; | |
| 344 | + } | |
| 345 | + | |
| 346 | + JInternalFrame jif = null; | |
| 347 | + if (comp instanceof JInternalFrame) { | |
| 348 | + jif = (JInternalFrame)comp; | |
| 349 | + } else if (comp instanceof JInternalFrame.JDesktopIcon) { | |
| 350 | + jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame(); | |
| 351 | + } else { | |
| 352 | + assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon"; | |
| 353 | + return; | |
| 354 | + } | |
| 355 | + | |
| 356 | + boolean active = jif.isSelected(); | |
| 357 | + Font oldFont = g.getFont(); | |
| 358 | + g.setFont(titlePane.getFont()); | |
| 359 | + g.translate(x0, y0); | |
| 360 | + | |
| 361 | + Rectangle titleRect = calculateTitleArea(jif); | |
| 362 | + JComponent menuButton = findChild(titlePane, "InternalFrameTitlePane.menuButton"); | |
| 363 | + | |
| 364 | + Icon frameIcon = jif.getFrameIcon(); | |
| 365 | + variables.put("mini_icon_width", | |
| 366 | + (frameIcon != null) ? frameIcon.getIconWidth() : 0); | |
| 367 | + variables.put("mini_icon_height", | |
| 368 | + (frameIcon != null) ? frameIcon.getIconHeight() : 0); | |
| 369 | + variables.put("title_width", calculateTitleTextWidth(g, jif)); | |
| 370 | + FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g); | |
| 371 | + variables.put("title_height", fm.getAscent() + fm.getDescent()); | |
| 372 | + | |
| 373 | + // These don't seem to apply here, but the Galaxy theme uses them. Not sure why. | |
| 374 | + variables.put("icon_width", 32); | |
| 375 | + variables.put("icon_height", 32); | |
| 376 | + | |
| 377 | + if (frame_style_set != null) { | |
| 378 | + Node frame = getNode(frame_style_set, "frame", new String[] { | |
| 379 | + "focus", (active ? "yes" : "no"), | |
| 380 | + "state", (jif.isMaximum() ? "maximized" : "normal") | |
| 381 | + }); | |
| 382 | + | |
| 383 | + if (frame != null) { | |
| 384 | + Node frame_style = getNode("frame_style", new String[] { | |
| 385 | + "name", getStringAttr(frame, "style") | |
| 386 | + }); | |
| 387 | + if (frame_style != null) { | |
| 388 | + Shape oldClip = g.getClip(); | |
| 389 | + boolean roundTopLeft = getBoolean("rounded_top_left", false); | |
| 390 | + boolean roundTopRight = getBoolean("rounded_top_right", false); | |
| 391 | + boolean roundBottomLeft = getBoolean("rounded_bottom_left", false); | |
| 392 | + boolean roundBottomRight = getBoolean("rounded_bottom_right", false); | |
| 393 | + | |
| 394 | + if (roundTopLeft || roundTopRight || roundBottomLeft || roundBottomRight) { | |
| 395 | + jif.setOpaque(false); | |
| 396 | + | |
| 397 | + g.setClip(getRoundedClipShape(0, 0, width, height, 12, 12, | |
| 398 | + (roundTopLeft ? RoundRectClipShape.TOP_LEFT : 0) | | |
| 399 | + (roundTopRight ? RoundRectClipShape.TOP_RIGHT : 0) | | |
| 400 | + (roundBottomLeft ? RoundRectClipShape.BOTTOM_LEFT : 0) | | |
| 401 | + (roundBottomRight ? RoundRectClipShape.BOTTOM_RIGHT : 0))); | |
| 402 | + } | |
| 403 | + | |
| 404 | + Rectangle clipBounds = oldClip.getBounds(); | |
| 405 | + g.clipRect(clipBounds.x, clipBounds.y, | |
| 406 | + clipBounds.width, clipBounds.height); | |
| 407 | + | |
| 408 | + int titleHeight = titlePane.getHeight(); | |
| 409 | + | |
| 410 | + boolean minimized = jif.isIcon(); | |
| 411 | + Insets insets = getBorderInsets(context, null); | |
| 412 | + | |
| 413 | + int leftTitlebarEdge = getInt("left_titlebar_edge"); | |
| 414 | + int rightTitlebarEdge = getInt("right_titlebar_edge"); | |
| 415 | + int topTitlebarEdge = getInt("top_titlebar_edge"); | |
| 416 | + int bottomTitlebarEdge = getInt("bottom_titlebar_edge"); | |
| 417 | + | |
| 418 | + if (!minimized) { | |
| 419 | + drawPiece(frame_style, g, "entire_background", | |
| 420 | + 0, 0, width, height, jif); | |
| 421 | + } | |
| 422 | + drawPiece(frame_style, g, "titlebar", | |
| 423 | + 0, 0, width, titleHeight, jif); | |
| 424 | + drawPiece(frame_style, g, "titlebar_middle", | |
| 425 | + leftTitlebarEdge, topTitlebarEdge, | |
| 426 | + width - leftTitlebarEdge - rightTitlebarEdge, | |
| 427 | + titleHeight - topTitlebarEdge - bottomTitlebarEdge, | |
| 428 | + jif); | |
| 429 | + drawPiece(frame_style, g, "left_titlebar_edge", | |
| 430 | + 0, 0, leftTitlebarEdge, titleHeight, jif); | |
| 431 | + drawPiece(frame_style, g, "right_titlebar_edge", | |
| 432 | + width - rightTitlebarEdge, 0, | |
| 433 | + rightTitlebarEdge, titleHeight, jif); | |
| 434 | + drawPiece(frame_style, g, "top_titlebar_edge", | |
| 435 | + 0, 0, width, topTitlebarEdge, jif); | |
| 436 | + drawPiece(frame_style, g, "bottom_titlebar_edge", | |
| 437 | + 0, titleHeight - bottomTitlebarEdge, | |
| 438 | + width, bottomTitlebarEdge, jif); | |
| 439 | + drawPiece(frame_style, g, "title", | |
| 440 | + titleRect.x, titleRect.y, titleRect.width, titleRect.height, jif); | |
| 441 | + if (!minimized) { | |
| 442 | + drawPiece(frame_style, g, "left_edge", | |
| 443 | + 0, titleHeight, insets.left, height-titleHeight, jif); | |
| 444 | + drawPiece(frame_style, g, "right_edge", | |
| 445 | + width-insets.right, titleHeight, insets.right, height-titleHeight, jif); | |
| 446 | + drawPiece(frame_style, g, "bottom_edge", | |
| 447 | + 0, height - insets.bottom, width, insets.bottom, jif); | |
| 448 | + drawPiece(frame_style, g, "overlay", | |
| 449 | + 0, 0, width, height, jif); | |
| 450 | + } | |
| 451 | + g.setClip(oldClip); | |
| 452 | + } | |
| 453 | + } | |
| 454 | + } | |
| 455 | + g.translate(-x0, -y0); | |
| 456 | + g.setFont(oldFont); | |
| 457 | + } | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + private static class Privileged implements PrivilegedAction<Object> { | |
| 462 | + private static int GET_THEME_DIR = 0; | |
| 463 | + private static int GET_USER_THEME = 1; | |
| 464 | + private static int GET_IMAGE = 2; | |
| 465 | + private int type; | |
| 466 | + private Object arg; | |
| 467 | + | |
| 468 | + public Object doPrivileged(int type, Object arg) { | |
| 469 | + this.type = type; | |
| 470 | + this.arg = arg; | |
| 471 | + return AccessController.doPrivileged(this); | |
| 472 | + } | |
| 473 | + | |
| 474 | + public Object run() { | |
| 475 | + if (type == GET_THEME_DIR) { | |
| 476 | + String sep = File.separator; | |
| 477 | + String[] dirs = new String[] { | |
| 478 | + userHome + sep + ".themes", | |
| 479 | + System.getProperty("swing.metacitythemedir"), | |
| 480 | + "/usr/share/themes", | |
| 481 | + "/usr/gnome/share/themes", // Debian/Redhat/Solaris | |
| 482 | + "/opt/gnome2/share/themes" // SuSE | |
| 483 | + }; | |
| 484 | + | |
| 485 | + URL themeDir = null; | |
| 486 | + for (int i = 0; i < dirs.length; i++) { | |
| 487 | + // System property may not be set so skip null directories. | |
| 488 | + if (dirs[i] == null) { | |
| 489 | + continue; | |
| 490 | + } | |
| 491 | + File dir = | |
| 492 | + new File(dirs[i] + sep + arg + sep + "metacity-1"); | |
| 493 | + if (new File(dir, "metacity-theme-1.xml").canRead()) { | |
| 494 | + try { | |
| 495 | + themeDir = dir.toURI().toURL(); | |
| 496 | + } catch (MalformedURLException ex) { | |
| 497 | + themeDir = null; | |
| 498 | + } | |
| 499 | + break; | |
| 500 | + } | |
| 501 | + } | |
| 502 | + if (themeDir == null) { | |
| 503 | + String filename = "resources/metacity/" + arg + | |
| 504 | + "/metacity-1/metacity-theme-1.xml"; | |
| 505 | + URL url = getClass().getResource(filename); | |
| 506 | + if (url != null) { | |
| 507 | + String str = url.toString(); | |
| 508 | + try { | |
| 509 | + themeDir = new URL(str.substring(0, str.lastIndexOf('/'))+"/"); | |
| 510 | + } catch (MalformedURLException ex) { | |
| 511 | + themeDir = null; | |
| 512 | + } | |
| 513 | + } | |
| 514 | + } | |
| 515 | + return themeDir; | |
| 516 | + } else if (type == GET_USER_THEME) { | |
| 517 | + try { | |
| 518 | + // Set userHome here because we need the privilege | |
| 519 | + userHome = System.getProperty("user.home"); | |
| 520 | + | |
| 521 | + String theme = System.getProperty("swing.metacitythemename"); | |
| 522 | + if (theme != null) { | |
| 523 | + return theme; | |
| 524 | + } | |
| 525 | + // Note: this is a small file (< 1024 bytes) so it's not worth | |
| 526 | + // starting an XML parser or even to use a buffered reader. | |
| 527 | + URL url = new URL(new File(userHome).toURI().toURL(), | |
| 528 | + ".gconf/apps/metacity/general/%25gconf.xml"); | |
| 529 | + // Pending: verify character encoding spec for gconf | |
| 530 | + Reader reader = new InputStreamReader(url.openStream(), "ISO-8859-1"); | |
| 531 | + char[] buf = new char[1024]; | |
| 532 | + StringBuffer strBuf = new StringBuffer(); | |
| 533 | + int n; | |
| 534 | + while ((n = reader.read(buf)) >= 0) { | |
| 535 | + strBuf.append(buf, 0, n); | |
| 536 | + } | |
| 537 | + reader.close(); | |
| 538 | + String str = strBuf.toString(); | |
| 539 | + if (str != null) { | |
| 540 | + String strLowerCase = str.toLowerCase(); | |
| 541 | + int i = strLowerCase.indexOf("<entry name=\"theme\""); | |
| 542 | + if (i >= 0) { | |
| 543 | + i = strLowerCase.indexOf("<stringvalue>", i); | |
| 544 | + if (i > 0) { | |
| 545 | + i += "<stringvalue>".length(); | |
| 546 | + int i2 = str.indexOf("<", i); | |
| 547 | + return str.substring(i, i2); | |
| 548 | + } | |
| 549 | + } | |
| 550 | + } | |
| 551 | + } catch (MalformedURLException ex) { | |
| 552 | + // OK to just ignore. We'll use a fallback theme. | |
| 553 | + } catch (IOException ex) { | |
| 554 | + // OK to just ignore. We'll use a fallback theme. | |
| 555 | + } | |
| 556 | + return null; | |
| 557 | + } else if (type == GET_IMAGE) { | |
| 558 | + return new ImageIcon((URL)arg).getImage(); | |
| 559 | + } else { | |
| 560 | + return null; | |
| 561 | + } | |
| 562 | + } | |
| 563 | + } | |
| 564 | + | |
| 565 | + private static URL getThemeDir(String themeName) { | |
| 566 | + return (URL)new Privileged().doPrivileged(Privileged.GET_THEME_DIR, themeName); | |
| 567 | + } | |
| 568 | + | |
| 569 | + private static String getUserTheme() { | |
| 570 | + return (String)new Privileged().doPrivileged(Privileged.GET_USER_THEME, null); | |
| 571 | + } | |
| 572 | + | |
| 573 | + protected void tileImage(Graphics g, Image image, int x0, int y0, int w, int h, float[] alphas) { | |
| 574 | + Graphics2D g2 = (Graphics2D)g; | |
| 575 | + Composite oldComp = g2.getComposite(); | |
| 576 | + | |
| 577 | + int sw = image.getWidth(null); | |
| 578 | + int sh = image.getHeight(null); | |
| 579 | + int y = y0; | |
| 580 | + while (y < y0 + h) { | |
| 581 | + sh = Math.min(sh, y0 + h - y); | |
| 582 | + int x = x0; | |
| 583 | + while (x < x0 + w) { | |
| 584 | + float f = (alphas.length - 1.0F) * x / (x0 + w); | |
| 585 | + int i = (int)f; | |
| 586 | + f -= (int)f; | |
| 587 | + float alpha = (1-f) * alphas[i]; | |
| 588 | + if (i+1 < alphas.length) { | |
| 589 | + alpha += f * alphas[i+1]; | |
| 590 | + } | |
| 591 | + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); | |
| 592 | + int swm = Math.min(sw, x0 + w - x); | |
| 593 | + g.drawImage(image, x, y, x+swm, y+sh, 0, 0, swm, sh, null); | |
| 594 | + x += swm; | |
| 595 | + } | |
| 596 | + y += sh; | |
| 597 | + } | |
| 598 | + g2.setComposite(oldComp); | |
| 599 | + } | |
| 600 | + | |
| 601 | + private HashMap<String, Image> images = new HashMap<String, Image>(); | |
| 602 | + | |
| 603 | + protected Image getImage(String key, Color c) { | |
| 604 | + Image image = images.get(key+"-"+c.getRGB()); | |
| 605 | + if (image == null) { | |
| 606 | + image = imageFilter.colorize(getImage(key), c); | |
| 607 | + if (image != null) { | |
| 608 | + images.put(key+"-"+c.getRGB(), image); | |
| 609 | + } | |
| 610 | + } | |
| 611 | + return image; | |
| 612 | + } | |
| 613 | + | |
| 614 | + protected Image getImage(String key) { | |
| 615 | + Image image = images.get(key); | |
| 616 | + if (image == null) { | |
| 617 | + if (themeDir != null) { | |
| 618 | + try { | |
| 619 | + URL url = new URL(themeDir, key); | |
| 620 | + image = (Image)new Privileged().doPrivileged(Privileged.GET_IMAGE, url); | |
| 621 | + } catch (MalformedURLException ex) { | |
| 622 | + //log("Bad image url: "+ themeDir + "/" + key); | |
| 623 | + } | |
| 624 | + } | |
| 625 | + if (image != null) { | |
| 626 | + images.put(key, image); | |
| 627 | + } | |
| 628 | + } | |
| 629 | + return image; | |
| 630 | + } | |
| 631 | + | |
| 632 | + private class ColorizeImageFilter extends RGBImageFilter { | |
| 633 | + double cr, cg, cb; | |
| 634 | + | |
| 635 | + public ColorizeImageFilter() { | |
| 636 | + canFilterIndexColorModel = true; | |
| 637 | + } | |
| 638 | + | |
| 639 | + public void setColor(Color color) { | |
| 640 | + cr = color.getRed() / 255.0; | |
| 641 | + cg = color.getGreen() / 255.0; | |
| 642 | + cb = color.getBlue() / 255.0; | |
| 643 | + } | |
| 644 | + | |
| 645 | + public Image colorize(Image fromImage, Color c) { | |
| 646 | + setColor(c); | |
| 647 | + ImageProducer producer = new FilteredImageSource(fromImage.getSource(), this); | |
| 648 | + return new ImageIcon(context.getComponent().createImage(producer)).getImage(); | |
| 649 | + } | |
| 650 | + | |
| 651 | + public int filterRGB(int x, int y, int rgb) { | |
| 652 | + // Assume all rgb values are shades of gray | |
| 653 | + double grayLevel = 2 * (rgb & 0xff) / 255.0; | |
| 654 | + double r, g, b; | |
| 655 | + | |
| 656 | + if (grayLevel <= 1.0) { | |
| 657 | + r = cr * grayLevel; | |
| 658 | + g = cg * grayLevel; | |
| 659 | + b = cb * grayLevel; | |
| 660 | + } else { | |
| 661 | + grayLevel -= 1.0; | |
| 662 | + r = cr + (1.0 - cr) * grayLevel; | |
| 663 | + g = cg + (1.0 - cg) * grayLevel; | |
| 664 | + b = cb + (1.0 - cb) * grayLevel; | |
| 665 | + } | |
| 666 | + | |
| 667 | + return ((rgb & 0xff000000) + | |
| 668 | + (((int)(r * 255)) << 16) + | |
| 669 | + (((int)(g * 255)) << 8) + | |
| 670 | + (int)(b * 255)); | |
| 671 | + } | |
| 672 | + } | |
| 673 | + | |
| 674 | + protected static JComponent findChild(JComponent parent, String name) { | |
| 675 | + int n = parent.getComponentCount(); | |
| 676 | + for (int i = 0; i < n; i++) { | |
| 677 | + JComponent c = (JComponent)parent.getComponent(i); | |
| 678 | + if (name.equals(c.getName())) { | |
| 679 | + return c; | |
| 680 | + } | |
| 681 | + } | |
| 682 | + return null; | |
| 683 | + } | |
| 684 | + | |
| 685 | + | |
| 686 | + protected class TitlePaneLayout implements LayoutManager { | |
| 687 | + public void addLayoutComponent(String name, Component c) {} | |
| 688 | + public void removeLayoutComponent(Component c) {} | |
| 689 | + public Dimension preferredLayoutSize(Container c) { | |
| 690 | + return minimumLayoutSize(c); | |
| 691 | + } | |
| 692 | + | |
| 693 | + public Dimension minimumLayoutSize(Container c) { | |
| 694 | + JComponent titlePane = (JComponent)c; | |
| 695 | + Container titlePaneParent = titlePane.getParent(); | |
| 696 | + JInternalFrame frame; | |
| 697 | + if (titlePaneParent instanceof JInternalFrame) { | |
| 698 | + frame = (JInternalFrame)titlePaneParent; | |
| 699 | + } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) { | |
| 700 | + frame = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame(); | |
| 701 | + } else { | |
| 702 | + return null; | |
| 703 | + } | |
| 704 | + | |
| 705 | + Dimension buttonDim = calculateButtonSize(titlePane); | |
| 706 | + Insets title_border = (Insets)getFrameGeometry().get("title_border"); | |
| 707 | + Insets button_border = (Insets)getFrameGeometry().get("button_border"); | |
| 708 | + | |
| 709 | + // Calculate width. | |
| 710 | + int width = getInt("left_titlebar_edge") + buttonDim.width + getInt("right_titlebar_edge"); | |
| 711 | + if (title_border != null) { | |
| 712 | + width += title_border.left + title_border.right; | |
| 713 | + } | |
| 714 | + if (frame.isClosable()) { | |
| 715 | + width += buttonDim.width; | |
| 716 | + } | |
| 717 | + if (frame.isMaximizable()) { | |
| 718 | + width += buttonDim.width; | |
| 719 | + } | |
| 720 | + if (frame.isIconifiable()) { | |
| 721 | + width += buttonDim.width; | |
| 722 | + } | |
| 723 | + FontMetrics fm = frame.getFontMetrics(titlePane.getFont()); | |
| 724 | + String frameTitle = frame.getTitle(); | |
| 725 | + int title_w = frameTitle != null ? SwingUtilities2.stringWidth( | |
| 726 | + frame, fm, frameTitle) : 0; | |
| 727 | + int title_length = frameTitle != null ? frameTitle.length() : 0; | |
| 728 | + | |
| 729 | + // Leave room for three characters in the title. | |
| 730 | + if (title_length > 3) { | |
| 731 | + int subtitle_w = SwingUtilities2.stringWidth( | |
| 732 | + frame, fm, frameTitle.substring(0, 3) + "..."); | |
| 733 | + width += (title_w < subtitle_w) ? title_w : subtitle_w; | |
| 734 | + } else { | |
| 735 | + width += title_w; | |
| 736 | + } | |
| 737 | + | |
| 738 | + // Calculate height. | |
| 739 | + int titleHeight = fm.getHeight() + getInt("title_vertical_pad"); | |
| 740 | + if (title_border != null) { | |
| 741 | + titleHeight += title_border.top + title_border.bottom; | |
| 742 | + } | |
| 743 | + int buttonHeight = buttonDim.height; | |
| 744 | + if (button_border != null) { | |
| 745 | + buttonHeight += button_border.top + button_border.bottom; | |
| 746 | + } | |
| 747 | + int height = Math.max(buttonHeight, titleHeight); | |
| 748 | + | |
| 749 | + return new Dimension(width, height); | |
| 750 | + } | |
| 751 | + | |
| 752 | + public void layoutContainer(Container c) { | |
| 753 | + JComponent titlePane = (JComponent)c; | |
| 754 | + Container titlePaneParent = titlePane.getParent(); | |
| 755 | + JInternalFrame frame; | |
| 756 | + if (titlePaneParent instanceof JInternalFrame) { | |
| 757 | + frame = (JInternalFrame)titlePaneParent; | |
| 758 | + } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) { | |
| 759 | + frame = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame(); | |
| 760 | + } else { | |
| 761 | + return; | |
| 762 | + } | |
| 763 | + Map gm = getFrameGeometry(); | |
| 764 | + | |
| 765 | + int w = titlePane.getWidth(); | |
| 766 | + int h = titlePane.getHeight(); | |
| 767 | + | |
| 768 | + JComponent menuButton = findChild(titlePane, "InternalFrameTitlePane.menuButton"); | |
| 769 | + JComponent minimizeButton = findChild(titlePane, "InternalFrameTitlePane.iconifyButton"); | |
| 770 | + JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton"); | |
| 771 | + JComponent closeButton = findChild(titlePane, "InternalFrameTitlePane.closeButton"); | |
| 772 | + | |
| 773 | + Insets button_border = (Insets)gm.get("button_border"); | |
| 774 | + Dimension buttonDim = calculateButtonSize(titlePane); | |
| 775 | + | |
| 776 | + int y = (button_border != null) ? button_border.top : 0; | |
| 777 | + if (titlePaneParent.getComponentOrientation().isLeftToRight()) { | |
| 778 | + int x = getInt("left_titlebar_edge"); | |
| 779 | + | |
| 780 | + menuButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 781 | + | |
| 782 | + x = w - buttonDim.width - getInt("right_titlebar_edge"); | |
| 783 | + if (button_border != null) { | |
| 784 | + x -= button_border.right; | |
| 785 | + } | |
| 786 | + | |
| 787 | + if (frame.isClosable()) { | |
| 788 | + closeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 789 | + x -= buttonDim.width; | |
| 790 | + } | |
| 791 | + | |
| 792 | + if (frame.isMaximizable()) { | |
| 793 | + maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 794 | + x -= buttonDim.width; | |
| 795 | + } | |
| 796 | + | |
| 797 | + if (frame.isIconifiable()) { | |
| 798 | + minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 799 | + } | |
| 800 | + } else { | |
| 801 | + int x = w - buttonDim.width - getInt("right_titlebar_edge"); | |
| 802 | + | |
| 803 | + menuButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 804 | + | |
| 805 | + x = getInt("left_titlebar_edge"); | |
| 806 | + if (button_border != null) { | |
| 807 | + x += button_border.left; | |
| 808 | + } | |
| 809 | + | |
| 810 | + if (frame.isClosable()) { | |
| 811 | + closeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 812 | + x += buttonDim.width; | |
| 813 | + } | |
| 814 | + | |
| 815 | + if (frame.isMaximizable()) { | |
| 816 | + maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 817 | + x += buttonDim.width; | |
| 818 | + } | |
| 819 | + | |
| 820 | + if (frame.isIconifiable()) { | |
| 821 | + minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height); | |
| 822 | + } | |
| 823 | + } | |
| 824 | + } | |
| 825 | + } // end TitlePaneLayout | |
| 826 | + | |
| 827 | + protected Map getFrameGeometry() { | |
| 828 | + return frameGeometry; | |
| 829 | + } | |
| 830 | + | |
| 831 | + protected void setFrameGeometry(JComponent titlePane, Map gm) { | |
| 832 | + this.frameGeometry = gm; | |
| 833 | + if (getInt("top_height") == 0 && titlePane != null) { | |
| 834 | + gm.put("top_height", Integer.valueOf(titlePane.getHeight())); | |
| 835 | + } | |
| 836 | + } | |
| 837 | + | |
| 838 | + protected int getInt(String key) { | |
| 839 | + Integer i = (Integer)frameGeometry.get(key); | |
| 840 | + if (i == null) { | |
| 841 | + i = variables.get(key); | |
| 842 | + } | |
| 843 | + return (i != null) ? i.intValue() : 0; | |
| 844 | + } | |
| 845 | + | |
| 846 | + protected boolean getBoolean(String key, boolean fallback) { | |
| 847 | + Boolean b = (Boolean)frameGeometry.get(key); | |
| 848 | + return (b != null) ? b.booleanValue() : fallback; | |
| 849 | + } | |
| 850 | + | |
| 851 | + | |
| 852 | + protected void drawArc(Node node, Graphics g) { | |
| 853 | + NamedNodeMap attrs = node.getAttributes(); | |
| 854 | + Color color = parseColor(getStringAttr(attrs, "color")); | |
| 855 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 856 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 857 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 858 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 859 | + int start_angle = aee.evaluate(getStringAttr(attrs, "start_angle")); | |
| 860 | + int extent_angle = aee.evaluate(getStringAttr(attrs, "extent_angle")); | |
| 861 | + boolean filled = getBooleanAttr(node, "filled", false); | |
| 862 | + if (getInt("width") == -1) { | |
| 863 | + x -= w; | |
| 864 | + } | |
| 865 | + if (getInt("height") == -1) { | |
| 866 | + y -= h; | |
| 867 | + } | |
| 868 | + g.setColor(color); | |
| 869 | + if (filled) { | |
| 870 | + g.fillArc(x, y, w, h, start_angle, extent_angle); | |
| 871 | + } else { | |
| 872 | + g.drawArc(x, y, w, h, start_angle, extent_angle); | |
| 873 | + } | |
| 874 | + } | |
| 875 | + | |
| 876 | + protected void drawLine(Node node, Graphics g) { | |
| 877 | + NamedNodeMap attrs = node.getAttributes(); | |
| 878 | + Color color = parseColor(getStringAttr(attrs, "color")); | |
| 879 | + int x1 = aee.evaluate(getStringAttr(attrs, "x1")); | |
| 880 | + int y1 = aee.evaluate(getStringAttr(attrs, "y1")); | |
| 881 | + int x2 = aee.evaluate(getStringAttr(attrs, "x2")); | |
| 882 | + int y2 = aee.evaluate(getStringAttr(attrs, "y2")); | |
| 883 | + int lineWidth = aee.evaluate(getStringAttr(attrs, "width"), 1); | |
| 884 | + g.setColor(color); | |
| 885 | + if (lineWidth != 1) { | |
| 886 | + Graphics2D g2d = (Graphics2D)g; | |
| 887 | + Stroke stroke = g2d.getStroke(); | |
| 888 | + g2d.setStroke(new BasicStroke((float)lineWidth)); | |
| 889 | + g2d.drawLine(x1, y1, x2, y2); | |
| 890 | + g2d.setStroke(stroke); | |
| 891 | + } else { | |
| 892 | + g.drawLine(x1, y1, x2, y2); | |
| 893 | + } | |
| 894 | + } | |
| 895 | + | |
| 896 | + protected void drawRectangle(Node node, Graphics g) { | |
| 897 | + NamedNodeMap attrs = node.getAttributes(); | |
| 898 | + Color color = parseColor(getStringAttr(attrs, "color")); | |
| 899 | + boolean filled = getBooleanAttr(node, "filled", false); | |
| 900 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 901 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 902 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 903 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 904 | + g.setColor(color); | |
| 905 | + if (getInt("width") == -1) { | |
| 906 | + x -= w; | |
| 907 | + } | |
| 908 | + if (getInt("height") == -1) { | |
| 909 | + y -= h; | |
| 910 | + } | |
| 911 | + if (filled) { | |
| 912 | + g.fillRect(x, y, w, h); | |
| 913 | + } else { | |
| 914 | + g.drawRect(x, y, w, h); | |
| 915 | + } | |
| 916 | + } | |
| 917 | + | |
| 918 | + protected void drawTile(Node node, Graphics g, JInternalFrame jif) { | |
| 919 | + NamedNodeMap attrs = node.getAttributes(); | |
| 920 | + int x0 = aee.evaluate(getStringAttr(attrs, "x")); | |
| 921 | + int y0 = aee.evaluate(getStringAttr(attrs, "y")); | |
| 922 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 923 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 924 | + int tw = aee.evaluate(getStringAttr(attrs, "tile_width")); | |
| 925 | + int th = aee.evaluate(getStringAttr(attrs, "tile_height")); | |
| 926 | + int width = getInt("width"); | |
| 927 | + int height = getInt("height"); | |
| 928 | + if (width == -1) { | |
| 929 | + x0 -= w; | |
| 930 | + } | |
| 931 | + if (height == -1) { | |
| 932 | + y0 -= h; | |
| 933 | + } | |
| 934 | + Shape oldClip = g.getClip(); | |
| 935 | + if (g instanceof Graphics2D) { | |
| 936 | + ((Graphics2D)g).clip(new Rectangle(x0, y0, w, h)); | |
| 937 | + } | |
| 938 | + variables.put("width", tw); | |
| 939 | + variables.put("height", th); | |
| 940 | + | |
| 941 | + Node draw_ops = getNode("draw_ops", new String[] { "name", getStringAttr(node, "name") }); | |
| 942 | + | |
| 943 | + int y = y0; | |
| 944 | + while (y < y0 + h) { | |
| 945 | + int x = x0; | |
| 946 | + while (x < x0 + w) { | |
| 947 | + g.translate(x, y); | |
| 948 | + draw(draw_ops, g, jif); | |
| 949 | + g.translate(-x, -y); | |
| 950 | + x += tw; | |
| 951 | + } | |
| 952 | + y += th; | |
| 953 | + } | |
| 954 | + | |
| 955 | + variables.put("width", width); | |
| 956 | + variables.put("height", height); | |
| 957 | + g.setClip(oldClip); | |
| 958 | + } | |
| 959 | + | |
| 960 | + protected void drawTint(Node node, Graphics g) { | |
| 961 | + NamedNodeMap attrs = node.getAttributes(); | |
| 962 | + Color color = parseColor(getStringAttr(attrs, "color")); | |
| 963 | + float alpha = Float.parseFloat(getStringAttr(attrs, "alpha")); | |
| 964 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 965 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 966 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 967 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 968 | + if (getInt("width") == -1) { | |
| 969 | + x -= w; | |
| 970 | + } | |
| 971 | + if (getInt("height") == -1) { | |
| 972 | + y -= h; | |
| 973 | + } | |
| 974 | + if (g instanceof Graphics2D) { | |
| 975 | + Graphics2D g2 = (Graphics2D)g; | |
| 976 | + Composite oldComp = g2.getComposite(); | |
| 977 | + AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha); | |
| 978 | + g2.setComposite(ac); | |
| 979 | + g2.setColor(color); | |
| 980 | + g2.fillRect(x, y, w, h); | |
| 981 | + g2.setComposite(oldComp); | |
| 982 | + } | |
| 983 | + } | |
| 984 | + | |
| 985 | + protected void drawTitle(Node node, Graphics g, JInternalFrame jif) { | |
| 986 | + NamedNodeMap attrs = node.getAttributes(); | |
| 987 | + String colorStr = getStringAttr(attrs, "color"); | |
| 988 | + int i = colorStr.indexOf("gtk:fg["); | |
| 989 | + if (i > 0) { | |
| 990 | + colorStr = colorStr.substring(0, i) + "gtk:text[" + colorStr.substring(i+7); | |
| 991 | + } | |
| 992 | + Color color = parseColor(colorStr); | |
| 993 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 994 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 995 | + | |
| 996 | + String title = jif.getTitle(); | |
| 997 | + if (title != null) { | |
| 998 | + FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g); | |
| 999 | + title = SwingUtilities2.clipStringIfNecessary(jif, fm, title, | |
| 1000 | + calculateTitleArea(jif).width); | |
| 1001 | + g.setColor(color); | |
| 1002 | + SwingUtilities2.drawString(jif, g, title, x, y + fm.getAscent()); | |
| 1003 | + } | |
| 1004 | + } | |
| 1005 | + | |
| 1006 | + protected Dimension calculateButtonSize(JComponent titlePane) { | |
| 1007 | + int buttonHeight = getInt("button_height"); | |
| 1008 | + if (buttonHeight == 0) { | |
| 1009 | + buttonHeight = titlePane.getHeight(); | |
| 1010 | + if (buttonHeight == 0) { | |
| 1011 | + buttonHeight = 13; | |
| 1012 | + } else { | |
| 1013 | + Insets button_border = (Insets)frameGeometry.get("button_border"); | |
| 1014 | + if (button_border != null) { | |
| 1015 | + buttonHeight -= (button_border.top + button_border.bottom); | |
| 1016 | + } | |
| 1017 | + } | |
| 1018 | + } | |
| 1019 | + int buttonWidth = getInt("button_width"); | |
| 1020 | + if (buttonWidth == 0) { | |
| 1021 | + buttonWidth = buttonHeight; | |
| 1022 | + Float aspect_ratio = (Float)frameGeometry.get("aspect_ratio"); | |
| 1023 | + if (aspect_ratio != null) { | |
| 1024 | + buttonWidth = (int)(buttonHeight / aspect_ratio.floatValue()); | |
| 1025 | + } | |
| 1026 | + } | |
| 1027 | + return new Dimension(buttonWidth, buttonHeight); | |
| 1028 | + } | |
| 1029 | + | |
| 1030 | + protected Rectangle calculateTitleArea(JInternalFrame jif) { | |
| 1031 | + JComponent titlePane = findChild(jif, "InternalFrame.northPane"); | |
| 1032 | + Dimension buttonDim = calculateButtonSize(titlePane); | |
| 1033 | + Insets title_border = (Insets)frameGeometry.get("title_border"); | |
| 1034 | + Insets button_border = (Insets)getFrameGeometry().get("button_border"); | |
| 1035 | + | |
| 1036 | + Rectangle r = new Rectangle(); | |
| 1037 | + r.x = getInt("left_titlebar_edge"); | |
| 1038 | + r.y = 0; | |
| 1039 | + r.height = titlePane.getHeight(); | |
| 1040 | + if (title_border != null) { | |
| 1041 | + r.x += title_border.left; | |
| 1042 | + r.y += title_border.top; | |
| 1043 | + r.height -= (title_border.top + title_border.bottom); | |
| 1044 | + } | |
| 1045 | + | |
| 1046 | + if (titlePane.getParent().getComponentOrientation().isLeftToRight()) { | |
| 1047 | + r.x += buttonDim.width; | |
| 1048 | + if (button_border != null) { | |
| 1049 | + r.x += button_border.left; | |
| 1050 | + } | |
| 1051 | + r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge"); | |
| 1052 | + if (jif.isClosable()) { | |
| 1053 | + r.width -= buttonDim.width; | |
| 1054 | + } | |
| 1055 | + if (jif.isMaximizable()) { | |
| 1056 | + r.width -= buttonDim.width; | |
| 1057 | + } | |
| 1058 | + if (jif.isIconifiable()) { | |
| 1059 | + r.width -= buttonDim.width; | |
| 1060 | + } | |
| 1061 | + } else { | |
| 1062 | + if (jif.isClosable()) { | |
| 1063 | + r.x += buttonDim.width; | |
| 1064 | + } | |
| 1065 | + if (jif.isMaximizable()) { | |
| 1066 | + r.x += buttonDim.width; | |
| 1067 | + } | |
| 1068 | + if (jif.isIconifiable()) { | |
| 1069 | + r.x += buttonDim.width; | |
| 1070 | + } | |
| 1071 | + r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge") | |
| 1072 | + - buttonDim.width; | |
| 1073 | + if (button_border != null) { | |
| 1074 | + r.x -= button_border.right; | |
| 1075 | + } | |
| 1076 | + } | |
| 1077 | + if (title_border != null) { | |
| 1078 | + r.width -= title_border.right; | |
| 1079 | + } | |
| 1080 | + return r; | |
| 1081 | + } | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + protected int calculateTitleTextWidth(Graphics g, JInternalFrame jif) { | |
| 1085 | + String title = jif.getTitle(); | |
| 1086 | + if (title != null) { | |
| 1087 | + Rectangle r = calculateTitleArea(jif); | |
| 1088 | + return Math.min(SwingUtilities2.stringWidth(jif, | |
| 1089 | + SwingUtilities2.getFontMetrics(jif, g), title), r.width); | |
| 1090 | + } | |
| 1091 | + return 0; | |
| 1092 | + } | |
| 1093 | + | |
| 1094 | + protected void setClip(Node node, Graphics g) { | |
| 1095 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1096 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1097 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1098 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1099 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1100 | + if (getInt("width") == -1) { | |
| 1101 | + x -= w; | |
| 1102 | + } | |
| 1103 | + if (getInt("height") == -1) { | |
| 1104 | + y -= h; | |
| 1105 | + } | |
| 1106 | + if (g instanceof Graphics2D) { | |
| 1107 | + ((Graphics2D)g).clip(new Rectangle(x, y, w, h)); | |
| 1108 | + } | |
| 1109 | + } | |
| 1110 | + | |
| 1111 | + protected void drawGTKArrow(Node node, Graphics g) { | |
| 1112 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1113 | + String arrow = getStringAttr(attrs, "arrow"); | |
| 1114 | + String shadow = getStringAttr(attrs, "shadow"); | |
| 1115 | + String stateStr = getStringAttr(attrs, "state").toUpperCase(); | |
| 1116 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1117 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1118 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1119 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1120 | + | |
| 1121 | + int state = -1; | |
| 1122 | + if ("NORMAL".equals(stateStr)) { | |
| 1123 | + state = ENABLED; | |
| 1124 | + } else if ("SELECTED".equals(stateStr)) { | |
| 1125 | + state = SELECTED; | |
| 1126 | + } else if ("INSENSITIVE".equals(stateStr)) { | |
| 1127 | + state = DISABLED; | |
| 1128 | + } else if ("PRELIGHT".equals(stateStr)) { | |
| 1129 | + state = MOUSE_OVER; | |
| 1130 | + } | |
| 1131 | + | |
| 1132 | + ShadowType shadowType = null; | |
| 1133 | + if ("in".equals(shadow)) { | |
| 1134 | + shadowType = ShadowType.IN; | |
| 1135 | + } else if ("out".equals(shadow)) { | |
| 1136 | + shadowType = ShadowType.OUT; | |
| 1137 | + } else if ("etched_in".equals(shadow)) { | |
| 1138 | + shadowType = ShadowType.ETCHED_IN; | |
| 1139 | + } else if ("etched_out".equals(shadow)) { | |
| 1140 | + shadowType = ShadowType.ETCHED_OUT; | |
| 1141 | + } else if ("none".equals(shadow)) { | |
| 1142 | + shadowType = ShadowType.NONE; | |
| 1143 | + } | |
| 1144 | + | |
| 1145 | + ArrowType direction = null; | |
| 1146 | + if ("up".equals(arrow)) { | |
| 1147 | + direction = ArrowType.UP; | |
| 1148 | + } else if ("down".equals(arrow)) { | |
| 1149 | + direction = ArrowType.DOWN; | |
| 1150 | + } else if ("left".equals(arrow)) { | |
| 1151 | + direction = ArrowType.LEFT; | |
| 1152 | + } else if ("right".equals(arrow)) { | |
| 1153 | + direction = ArrowType.RIGHT; | |
| 1154 | + } | |
| 1155 | + | |
| 1156 | + GTKPainter.INSTANCE.paintMetacityElement(context, g, state, | |
| 1157 | + "metacity-arrow", x, y, w, h, shadowType, direction); | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + protected void drawGTKBox(Node node, Graphics g) { | |
| 1161 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1162 | + String shadow = getStringAttr(attrs, "shadow"); | |
| 1163 | + String stateStr = getStringAttr(attrs, "state").toUpperCase(); | |
| 1164 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1165 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1166 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1167 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1168 | + | |
| 1169 | + int state = -1; | |
| 1170 | + if ("NORMAL".equals(stateStr)) { | |
| 1171 | + state = ENABLED; | |
| 1172 | + } else if ("SELECTED".equals(stateStr)) { | |
| 1173 | + state = SELECTED; | |
| 1174 | + } else if ("INSENSITIVE".equals(stateStr)) { | |
| 1175 | + state = DISABLED; | |
| 1176 | + } else if ("PRELIGHT".equals(stateStr)) { | |
| 1177 | + state = MOUSE_OVER; | |
| 1178 | + } | |
| 1179 | + | |
| 1180 | + ShadowType shadowType = null; | |
| 1181 | + if ("in".equals(shadow)) { | |
| 1182 | + shadowType = ShadowType.IN; | |
| 1183 | + } else if ("out".equals(shadow)) { | |
| 1184 | + shadowType = ShadowType.OUT; | |
| 1185 | + } else if ("etched_in".equals(shadow)) { | |
| 1186 | + shadowType = ShadowType.ETCHED_IN; | |
| 1187 | + } else if ("etched_out".equals(shadow)) { | |
| 1188 | + shadowType = ShadowType.ETCHED_OUT; | |
| 1189 | + } else if ("none".equals(shadow)) { | |
| 1190 | + shadowType = ShadowType.NONE; | |
| 1191 | + } | |
| 1192 | + GTKPainter.INSTANCE.paintMetacityElement(context, g, state, | |
| 1193 | + "metacity-box", x, y, w, h, shadowType, null); | |
| 1194 | + } | |
| 1195 | + | |
| 1196 | + protected void drawGTKVLine(Node node, Graphics g) { | |
| 1197 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1198 | + String stateStr = getStringAttr(attrs, "state").toUpperCase(); | |
| 1199 | + | |
| 1200 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1201 | + int y1 = aee.evaluate(getStringAttr(attrs, "y1")); | |
| 1202 | + int y2 = aee.evaluate(getStringAttr(attrs, "y2")); | |
| 1203 | + | |
| 1204 | + int state = -1; | |
| 1205 | + if ("NORMAL".equals(stateStr)) { | |
| 1206 | + state = ENABLED; | |
| 1207 | + } else if ("SELECTED".equals(stateStr)) { | |
| 1208 | + state = SELECTED; | |
| 1209 | + } else if ("INSENSITIVE".equals(stateStr)) { | |
| 1210 | + state = DISABLED; | |
| 1211 | + } else if ("PRELIGHT".equals(stateStr)) { | |
| 1212 | + state = MOUSE_OVER; | |
| 1213 | + } | |
| 1214 | + | |
| 1215 | + GTKPainter.INSTANCE.paintMetacityElement(context, g, state, | |
| 1216 | + "metacity-vline", x, y1, 1, y2 - y1, null, null); | |
| 1217 | + } | |
| 1218 | + | |
| 1219 | + protected void drawGradient(Node node, Graphics g) { | |
| 1220 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1221 | + String type = getStringAttr(attrs, "type"); | |
| 1222 | + float alpha = getFloatAttr(node, "alpha", -1F); | |
| 1223 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1224 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1225 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1226 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1227 | + if (getInt("width") == -1) { | |
| 1228 | + x -= w; | |
| 1229 | + } | |
| 1230 | + if (getInt("height") == -1) { | |
| 1231 | + y -= h; | |
| 1232 | + } | |
| 1233 | + | |
| 1234 | + // Get colors from child nodes | |
| 1235 | + Node[] colorNodes = getNodesByName(node, "color"); | |
| 1236 | + Color[] colors = new Color[colorNodes.length]; | |
| 1237 | + for (int i = 0; i < colorNodes.length; i++) { | |
| 1238 | + colors[i] = parseColor(getStringAttr(colorNodes[i], "value")); | |
| 1239 | + } | |
| 1240 | + | |
| 1241 | + boolean horizontal = ("diagonal".equals(type) || "horizontal".equals(type)); | |
| 1242 | + boolean vertical = ("diagonal".equals(type) || "vertical".equals(type)); | |
| 1243 | + | |
| 1244 | + if (g instanceof Graphics2D) { | |
| 1245 | + Graphics2D g2 = (Graphics2D)g; | |
| 1246 | + Composite oldComp = g2.getComposite(); | |
| 1247 | + if (alpha >= 0F) { | |
| 1248 | + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); | |
| 1249 | + } | |
| 1250 | + int n = colors.length - 1; | |
| 1251 | + for (int i = 0; i < n; i++) { | |
| 1252 | + g2.setPaint(new GradientPaint(x + (horizontal ? (i*w/n) : 0), | |
| 1253 | + y + (vertical ? (i*h/n) : 0), | |
| 1254 | + colors[i], | |
| 1255 | + x + (horizontal ? ((i+1)*w/n) : 0), | |
| 1256 | + y + (vertical ? ((i+1)*h/n) : 0), | |
| 1257 | + colors[i+1])); | |
| 1258 | + g2.fillRect(x + (horizontal ? (i*w/n) : 0), | |
| 1259 | + y + (vertical ? (i*h/n) : 0), | |
| 1260 | + (horizontal ? (w/n) : w), | |
| 1261 | + (vertical ? (h/n) : h)); | |
| 1262 | + } | |
| 1263 | + g2.setComposite(oldComp); | |
| 1264 | + } | |
| 1265 | + } | |
| 1266 | + | |
| 1267 | + protected void drawImage(Node node, Graphics g) { | |
| 1268 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1269 | + String filename = getStringAttr(attrs, "filename"); | |
| 1270 | + String colorizeStr = getStringAttr(attrs, "colorize"); | |
| 1271 | + Color colorize = (colorizeStr != null) ? parseColor(colorizeStr) : null; | |
| 1272 | + String alpha = getStringAttr(attrs, "alpha"); | |
| 1273 | + Image object = (colorize != null) ? getImage(filename, colorize) : getImage(filename); | |
| 1274 | + variables.put("object_width", object.getWidth(null)); | |
| 1275 | + variables.put("object_height", object.getHeight(null)); | |
| 1276 | + String fill_type = getStringAttr(attrs, "fill_type"); | |
| 1277 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1278 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1279 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1280 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1281 | + if (getInt("width") == -1) { | |
| 1282 | + x -= w; | |
| 1283 | + } | |
| 1284 | + if (getInt("height") == -1) { | |
| 1285 | + y -= h; | |
| 1286 | + } | |
| 1287 | + | |
| 1288 | + if (alpha != null) { | |
| 1289 | + if ("tile".equals(fill_type)) { | |
| 1290 | + StringTokenizer tokenizer = new StringTokenizer(alpha, ":"); | |
| 1291 | + float[] alphas = new float[tokenizer.countTokens()]; | |
| 1292 | + for (int i = 0; i < alphas.length; i++) { | |
| 1293 | + alphas[i] = Float.parseFloat(tokenizer.nextToken()); | |
| 1294 | + } | |
| 1295 | + tileImage(g, object, x, y, w, h, alphas); | |
| 1296 | + } else { | |
| 1297 | + float a = Float.parseFloat(alpha); | |
| 1298 | + if (g instanceof Graphics2D) { | |
| 1299 | + Graphics2D g2 = (Graphics2D)g; | |
| 1300 | + Composite oldComp = g2.getComposite(); | |
| 1301 | + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a)); | |
| 1302 | + g2.drawImage(object, x, y, w, h, null); | |
| 1303 | + g2.setComposite(oldComp); | |
| 1304 | + } | |
| 1305 | + } | |
| 1306 | + } else { | |
| 1307 | + g.drawImage(object, x, y, w, h, null); | |
| 1308 | + } | |
| 1309 | + } | |
| 1310 | + | |
| 1311 | + protected void drawIcon(Node node, Graphics g, JInternalFrame jif) { | |
| 1312 | + Icon icon = jif.getFrameIcon(); | |
| 1313 | + if (icon == null) { | |
| 1314 | + return; | |
| 1315 | + } | |
| 1316 | + | |
| 1317 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1318 | + String alpha = getStringAttr(attrs, "alpha"); | |
| 1319 | + int x = aee.evaluate(getStringAttr(attrs, "x")); | |
| 1320 | + int y = aee.evaluate(getStringAttr(attrs, "y")); | |
| 1321 | + int w = aee.evaluate(getStringAttr(attrs, "width")); | |
| 1322 | + int h = aee.evaluate(getStringAttr(attrs, "height")); | |
| 1323 | + if (getInt("width") == -1) { | |
| 1324 | + x -= w; | |
| 1325 | + } | |
| 1326 | + if (getInt("height") == -1) { | |
| 1327 | + y -= h; | |
| 1328 | + } | |
| 1329 | + | |
| 1330 | + if (alpha != null) { | |
| 1331 | + float a = Float.parseFloat(alpha); | |
| 1332 | + if (g instanceof Graphics2D) { | |
| 1333 | + Graphics2D g2 = (Graphics2D)g; | |
| 1334 | + Composite oldComp = g2.getComposite(); | |
| 1335 | + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a)); | |
| 1336 | + icon.paintIcon(jif, g, x, y); | |
| 1337 | + g2.setComposite(oldComp); | |
| 1338 | + } | |
| 1339 | + } else { | |
| 1340 | + icon.paintIcon(jif, g, x, y); | |
| 1341 | + } | |
| 1342 | + } | |
| 1343 | + | |
| 1344 | + protected void drawInclude(Node node, Graphics g, JInternalFrame jif) { | |
| 1345 | + int oldWidth = getInt("width"); | |
| 1346 | + int oldHeight = getInt("height"); | |
| 1347 | + | |
| 1348 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1349 | + int x = aee.evaluate(getStringAttr(attrs, "x"), 0); | |
| 1350 | + int y = aee.evaluate(getStringAttr(attrs, "y"), 0); | |
| 1351 | + int w = aee.evaluate(getStringAttr(attrs, "width"), -1); | |
| 1352 | + int h = aee.evaluate(getStringAttr(attrs, "height"), -1); | |
| 1353 | + | |
| 1354 | + if (w != -1) { | |
| 1355 | + variables.put("width", w); | |
| 1356 | + } | |
| 1357 | + if (h != -1) { | |
| 1358 | + variables.put("height", h); | |
| 1359 | + } | |
| 1360 | + | |
| 1361 | + Node draw_ops = getNode("draw_ops", new String[] { | |
| 1362 | + "name", getStringAttr(node, "name") | |
| 1363 | + }); | |
| 1364 | + g.translate(x, y); | |
| 1365 | + draw(draw_ops, g, jif); | |
| 1366 | + g.translate(-x, -y); | |
| 1367 | + | |
| 1368 | + if (w != -1) { | |
| 1369 | + variables.put("width", oldWidth); | |
| 1370 | + } | |
| 1371 | + if (h != -1) { | |
| 1372 | + variables.put("height", oldHeight); | |
| 1373 | + } | |
| 1374 | + } | |
| 1375 | + | |
| 1376 | + protected void draw(Node draw_ops, Graphics g, JInternalFrame jif) { | |
| 1377 | + if (draw_ops != null) { | |
| 1378 | + NodeList nodes = draw_ops.getChildNodes(); | |
| 1379 | + if (nodes != null) { | |
| 1380 | + Shape oldClip = g.getClip(); | |
| 1381 | + for (int i = 0; i < nodes.getLength(); i++) { | |
| 1382 | + Node child = nodes.item(i); | |
| 1383 | + if (child.getNodeType() == Node.ELEMENT_NODE) { | |
| 1384 | + try { | |
| 1385 | + String name = child.getNodeName(); | |
| 1386 | + if ("include".equals(name)) { | |
| 1387 | + drawInclude(child, g, jif); | |
| 1388 | + } else if ("arc".equals(name)) { | |
| 1389 | + drawArc(child, g); | |
| 1390 | + } else if ("clip".equals(name)) { | |
| 1391 | + setClip(child, g); | |
| 1392 | + } else if ("gradient".equals(name)) { | |
| 1393 | + drawGradient(child, g); | |
| 1394 | + } else if ("gtk_arrow".equals(name)) { | |
| 1395 | + drawGTKArrow(child, g); | |
| 1396 | + } else if ("gtk_box".equals(name)) { | |
| 1397 | + drawGTKBox(child, g); | |
| 1398 | + } else if ("gtk_vline".equals(name)) { | |
| 1399 | + drawGTKVLine(child, g); | |
| 1400 | + } else if ("image".equals(name)) { | |
| 1401 | + drawImage(child, g); | |
| 1402 | + } else if ("icon".equals(name)) { | |
| 1403 | + drawIcon(child, g, jif); | |
| 1404 | + } else if ("line".equals(name)) { | |
| 1405 | + drawLine(child, g); | |
| 1406 | + } else if ("rectangle".equals(name)) { | |
| 1407 | + drawRectangle(child, g); | |
| 1408 | + } else if ("tint".equals(name)) { | |
| 1409 | + drawTint(child, g); | |
| 1410 | + } else if ("tile".equals(name)) { | |
| 1411 | + drawTile(child, g, jif); | |
| 1412 | + } else if ("title".equals(name)) { | |
| 1413 | + drawTitle(child, g, jif); | |
| 1414 | + } else { | |
| 1415 | + System.err.println("Unknown Metacity drawing op: "+child); | |
| 1416 | + } | |
| 1417 | + } catch (NumberFormatException ex) { | |
| 1418 | + logError(themeName, ex); | |
| 1419 | + } | |
| 1420 | + } | |
| 1421 | + } | |
| 1422 | + g.setClip(oldClip); | |
| 1423 | + } | |
| 1424 | + } | |
| 1425 | + } | |
| 1426 | + | |
| 1427 | + protected void drawPiece(Node frame_style, Graphics g, String position, int x, int y, | |
| 1428 | + int width, int height, JInternalFrame jif) { | |
| 1429 | + Node piece = getNode(frame_style, "piece", new String[] { "position", position }); | |
| 1430 | + if (piece != null) { | |
| 1431 | + Node draw_ops; | |
| 1432 | + String draw_ops_name = getStringAttr(piece, "draw_ops"); | |
| 1433 | + if (draw_ops_name != null) { | |
| 1434 | + draw_ops = getNode("draw_ops", new String[] { "name", draw_ops_name }); | |
| 1435 | + } else { | |
| 1436 | + draw_ops = getNode(piece, "draw_ops", null); | |
| 1437 | + } | |
| 1438 | + variables.put("width", width); | |
| 1439 | + variables.put("height", height); | |
| 1440 | + g.translate(x, y); | |
| 1441 | + draw(draw_ops, g, jif); | |
| 1442 | + g.translate(-x, -y); | |
| 1443 | + } | |
| 1444 | + } | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + Insets getBorderInsets(SynthContext context, Insets insets) { | |
| 1448 | + updateFrameGeometry(context); | |
| 1449 | + | |
| 1450 | + if (insets == null) { | |
| 1451 | + insets = new Insets(0, 0, 0, 0); | |
| 1452 | + } | |
| 1453 | + insets.top = ((Insets)frameGeometry.get("title_border")).top; | |
| 1454 | + insets.bottom = getInt("bottom_height"); | |
| 1455 | + insets.left = getInt("left_width"); | |
| 1456 | + insets.right = getInt("right_width"); | |
| 1457 | + return insets; | |
| 1458 | + } | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + private void updateFrameGeometry(SynthContext context) { | |
| 1462 | + this.context = context; | |
| 1463 | + JComponent comp = context.getComponent(); | |
| 1464 | + JComponent titlePane = findChild(comp, "InternalFrame.northPane"); | |
| 1465 | + | |
| 1466 | + JInternalFrame jif = null; | |
| 1467 | + if (comp instanceof JInternalFrame) { | |
| 1468 | + jif = (JInternalFrame)comp; | |
| 1469 | + } else if (comp instanceof JInternalFrame.JDesktopIcon) { | |
| 1470 | + jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame(); | |
| 1471 | + } else { | |
| 1472 | + assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon"; | |
| 1473 | + return; | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + if (frame_style_set == null) { | |
| 1477 | + Node window = getNode("window", new String[]{"type", "normal"}); | |
| 1478 | + | |
| 1479 | + if (window != null) { | |
| 1480 | + frame_style_set = getNode("frame_style_set", | |
| 1481 | + new String[] {"name", getStringAttr(window, "style_set")}); | |
| 1482 | + } | |
| 1483 | + | |
| 1484 | + if (frame_style_set == null) { | |
| 1485 | + frame_style_set = getNode("frame_style_set", new String[] {"name", "normal"}); | |
| 1486 | + } | |
| 1487 | + } | |
| 1488 | + | |
| 1489 | + if (frame_style_set != null) { | |
| 1490 | + Node frame = getNode(frame_style_set, "frame", new String[] { | |
| 1491 | + "focus", (jif.isSelected() ? "yes" : "no"), | |
| 1492 | + "state", (jif.isMaximum() ? "maximized" : "normal") | |
| 1493 | + }); | |
| 1494 | + | |
| 1495 | + if (frame != null) { | |
| 1496 | + Node frame_style = getNode("frame_style", new String[] { | |
| 1497 | + "name", getStringAttr(frame, "style") | |
| 1498 | + }); | |
| 1499 | + if (frame_style != null) { | |
| 1500 | + Map gm = frameGeometries.get(getStringAttr(frame_style, "geometry")); | |
| 1501 | + | |
| 1502 | + setFrameGeometry(titlePane, gm); | |
| 1503 | + } | |
| 1504 | + } | |
| 1505 | + } | |
| 1506 | + } | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + protected static void logError(String themeName, Exception ex) { | |
| 1510 | + logError(themeName, ex.toString()); | |
| 1511 | + } | |
| 1512 | + | |
| 1513 | + protected static void logError(String themeName, String msg) { | |
| 1514 | + if (!errorLogged) { | |
| 1515 | + System.err.println("Exception in Metacity for theme \""+themeName+"\": "+msg); | |
| 1516 | + errorLogged = true; | |
| 1517 | + } | |
| 1518 | + } | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + // XML Parsing | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + protected static Document getXMLDoc(final URL xmlFile) | |
| 1525 | + throws IOException, | |
| 1526 | + ParserConfigurationException, | |
| 1527 | + SAXException { | |
| 1528 | + if (documentBuilder == null) { | |
| 1529 | + documentBuilder = | |
| 1530 | + DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |
| 1531 | + } | |
| 1532 | + InputStream inputStream = | |
| 1533 | + AccessController.doPrivileged(new PrivilegedAction<InputStream>() { | |
| 1534 | + public InputStream run() { | |
| 1535 | + try { | |
| 1536 | + return new BufferedInputStream(xmlFile.openStream()); | |
| 1537 | + } catch (IOException ex) { | |
| 1538 | + return null; | |
| 1539 | + } | |
| 1540 | + } | |
| 1541 | + }); | |
| 1542 | + | |
| 1543 | + Document doc = null; | |
| 1544 | + if (inputStream != null) { | |
| 1545 | + doc = documentBuilder.parse(inputStream); | |
| 1546 | + } | |
| 1547 | + return doc; | |
| 1548 | + } | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + protected Node[] getNodesByName(Node parent, String name) { | |
| 1552 | + NodeList nodes = parent.getChildNodes(); // ElementNode | |
| 1553 | + int n = nodes.getLength(); | |
| 1554 | + ArrayList<Node> list = new ArrayList<Node>(); | |
| 1555 | + for (int i=0; i < n; i++) { | |
| 1556 | + Node node = nodes.item(i); | |
| 1557 | + if (name.equals(node.getNodeName())) { | |
| 1558 | + list.add(node); | |
| 1559 | + } | |
| 1560 | + } | |
| 1561 | + return list.toArray(new Node[list.size()]); | |
| 1562 | + } | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + protected Node getNode(String tagName, String[] attrs) { | |
| 1567 | + NodeList nodes = xmlDoc.getElementsByTagName(tagName); | |
| 1568 | + return (nodes != null) ? getNode(nodes, tagName, attrs) : null; | |
| 1569 | + } | |
| 1570 | + | |
| 1571 | + protected Node getNode(Node parent, String name, String[] attrs) { | |
| 1572 | + Node node = null; | |
| 1573 | + NodeList nodes = parent.getChildNodes(); | |
| 1574 | + if (nodes != null) { | |
| 1575 | + node = getNode(nodes, name, attrs); | |
| 1576 | + } | |
| 1577 | + if (node == null) { | |
| 1578 | + String inheritFrom = getStringAttr(parent, "parent"); | |
| 1579 | + if (inheritFrom != null) { | |
| 1580 | + Node inheritFromNode = getNode(parent.getParentNode(), | |
| 1581 | + parent.getNodeName(), | |
| 1582 | + new String[] { "name", inheritFrom }); | |
| 1583 | + if (inheritFromNode != null) { | |
| 1584 | + node = getNode(inheritFromNode, name, attrs); | |
| 1585 | + } | |
| 1586 | + } | |
| 1587 | + } | |
| 1588 | + return node; | |
| 1589 | + } | |
| 1590 | + | |
| 1591 | + protected Node getNode(NodeList nodes, String name, String[] attrs) { | |
| 1592 | + int n = nodes.getLength(); | |
| 1593 | + for (int i=0; i < n; i++) { | |
| 1594 | + Node node = nodes.item(i); | |
| 1595 | + if (name.equals(node.getNodeName())) { | |
| 1596 | + if (attrs != null) { | |
| 1597 | + NamedNodeMap nodeAttrs = node.getAttributes(); | |
| 1598 | + if (nodeAttrs != null) { | |
| 1599 | + boolean matches = true; | |
| 1600 | + int nAttrs = attrs.length / 2; | |
| 1601 | + for (int a = 0; a < nAttrs; a++) { | |
| 1602 | + String aName = attrs[a * 2]; | |
| 1603 | + String aValue = attrs[a * 2 + 1]; | |
| 1604 | + Node attr = nodeAttrs.getNamedItem(aName); | |
| 1605 | + if (attr == null || | |
| 1606 | + aValue != null && !aValue.equals(attr.getNodeValue())) { | |
| 1607 | + matches = false; | |
| 1608 | + break; | |
| 1609 | + } | |
| 1610 | + } | |
| 1611 | + if (matches) { | |
| 1612 | + return node; | |
| 1613 | + } | |
| 1614 | + } | |
| 1615 | + } else { | |
| 1616 | + return node; | |
| 1617 | + } | |
| 1618 | + } | |
| 1619 | + } | |
| 1620 | + return null; | |
| 1621 | + } | |
| 1622 | + | |
| 1623 | + protected String getStringAttr(Node node, String name) { | |
| 1624 | + String value = null; | |
| 1625 | + NamedNodeMap attrs = node.getAttributes(); | |
| 1626 | + if (attrs != null) { | |
| 1627 | + value = getStringAttr(attrs, name); | |
| 1628 | + if (value == null) { | |
| 1629 | + String inheritFrom = getStringAttr(attrs, "parent"); | |
| 1630 | + if (inheritFrom != null) { | |
| 1631 | + Node inheritFromNode = getNode(node.getParentNode(), | |
| 1632 | + node.getNodeName(), | |
| 1633 | + new String[] { "name", inheritFrom }); | |
| 1634 | + if (inheritFromNode != null) { | |
| 1635 | + value = getStringAttr(inheritFromNode, name); | |
| 1636 | + } | |
| 1637 | + } | |
| 1638 | + } | |
| 1639 | + } | |
| 1640 | + return value; | |
| 1641 | + } | |
| 1642 | + | |
| 1643 | + protected String getStringAttr(NamedNodeMap attrs, String name) { | |
| 1644 | + Node item = attrs.getNamedItem(name); | |
| 1645 | + return (item != null) ? item.getNodeValue() : null; | |
| 1646 | + } | |
| 1647 | + | |
| 1648 | + protected boolean getBooleanAttr(Node node, String name, boolean fallback) { | |
| 1649 | + String str = getStringAttr(node, name); | |
| 1650 | + if (str != null) { | |
| 1651 | + return Boolean.valueOf(str).booleanValue(); | |
| 1652 | + } | |
| 1653 | + return fallback; | |
| 1654 | + } | |
| 1655 | + | |
| 1656 | + protected int getIntAttr(Node node, String name, int fallback) { | |
| 1657 | + String str = getStringAttr(node, name); | |
| 1658 | + int value = fallback; | |
| 1659 | + if (str != null) { | |
| 1660 | + try { | |
| 1661 | + value = Integer.parseInt(str); | |
| 1662 | + } catch (NumberFormatException ex) { | |
| 1663 | + logError(themeName, ex); | |
| 1664 | + } | |
| 1665 | + } | |
| 1666 | + return value; | |
| 1667 | + } | |
| 1668 | + | |
| 1669 | + protected float getFloatAttr(Node node, String name, float fallback) { | |
| 1670 | + String str = getStringAttr(node, name); | |
| 1671 | + float value = fallback; | |
| 1672 | + if (str != null) { | |
| 1673 | + try { | |
| 1674 | + value = Float.parseFloat(str); | |
| 1675 | + } catch (NumberFormatException ex) { | |
| 1676 | + logError(themeName, ex); | |
| 1677 | + } | |
| 1678 | + } | |
| 1679 | + return value; | |
| 1680 | + } | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + protected Color parseColor(String str) { | |
| 1685 | + StringTokenizer tokenizer = new StringTokenizer(str, "/"); | |
| 1686 | + int n = tokenizer.countTokens(); | |
| 1687 | + if (n > 1) { | |
| 1688 | + String function = tokenizer.nextToken(); | |
| 1689 | + if ("shade".equals(function)) { | |
| 1690 | + assert (n == 3); | |
| 1691 | + Color c = parseColor2(tokenizer.nextToken()); | |
| 1692 | + float alpha = Float.parseFloat(tokenizer.nextToken()); | |
| 1693 | + return GTKColorType.adjustColor(c, 1.0F, alpha, alpha); | |
| 1694 | + } else if ("blend".equals(function)) { | |
| 1695 | + assert (n == 4); | |
| 1696 | + Color bg = parseColor2(tokenizer.nextToken()); | |
| 1697 | + Color fg = parseColor2(tokenizer.nextToken()); | |
| 1698 | + float alpha = Float.parseFloat(tokenizer.nextToken()); | |
| 1699 | + if (alpha > 1.0f) { | |
| 1700 | + alpha = 1.0f / alpha; | |
| 1701 | + } | |
| 1702 | + | |
| 1703 | + return new Color((int)(bg.getRed() + ((fg.getRed() - bg.getRed()) * alpha)), | |
| 1704 | + (int)(bg.getRed() + ((fg.getRed() - bg.getRed()) * alpha)), | |
| 1705 | + (int)(bg.getRed() + ((fg.getRed() - bg.getRed()) * alpha))); | |
| 1706 | + } else { | |
| 1707 | + System.err.println("Unknown Metacity color function="+str); | |
| 1708 | + return null; | |
| 1709 | + } | |
| 1710 | + } else { | |
| 1711 | + return parseColor2(str); | |
| 1712 | + } | |
| 1713 | + } | |
| 1714 | + | |
| 1715 | + protected Color parseColor2(String str) { | |
| 1716 | + Color c = null; | |
| 1717 | + if (str.startsWith("gtk:")) { | |
| 1718 | + int i1 = str.indexOf('['); | |
| 1719 | + if (i1 > 3) { | |
| 1720 | + String typeStr = str.substring(4, i1).toLowerCase(); | |
| 1721 | + int i2 = str.indexOf(']'); | |
| 1722 | + if (i2 > i1+1) { | |
| 1723 | + String stateStr = str.substring(i1+1, i2).toUpperCase(); | |
| 1724 | + int state = -1; | |
| 1725 | + if ("ACTIVE".equals(stateStr)) { | |
| 1726 | + state = PRESSED; | |
| 1727 | + } else if ("INSENSITIVE".equals(stateStr)) { | |
| 1728 | + state = DISABLED; | |
| 1729 | + } else if ("NORMAL".equals(stateStr)) { | |
| 1730 | + state = ENABLED; | |
| 1731 | + } else if ("PRELIGHT".equals(stateStr)) { | |
| 1732 | + state = MOUSE_OVER; | |
| 1733 | + } else if ("SELECTED".equals(stateStr)) { | |
| 1734 | + state = SELECTED; | |
| 1735 | + } | |
| 1736 | + ColorType type = null; | |
| 1737 | + if ("fg".equals(typeStr)) { | |
| 1738 | + type = GTKColorType.FOREGROUND; | |
| 1739 | + } else if ("bg".equals(typeStr)) { | |
| 1740 | + type = GTKColorType.BACKGROUND; | |
| 1741 | + } else if ("base".equals(typeStr)) { | |
| 1742 | + type = GTKColorType.TEXT_BACKGROUND; | |
| 1743 | + } else if ("text".equals(typeStr)) { | |
| 1744 | + type = GTKColorType.TEXT_FOREGROUND; | |
| 1745 | + } else if ("dark".equals(typeStr)) { | |
| 1746 | + type = GTKColorType.DARK; | |
| 1747 | + } else if ("light".equals(typeStr)) { | |
| 1748 | + type = GTKColorType.LIGHT; | |
| 1749 | + } | |
| 1750 | + if (state >= 0 && type != null) { | |
| 1751 | + c = ((GTKStyle)context.getStyle()).getGTKColor(context, state, type); | |
| 1752 | + } | |
| 1753 | + } | |
| 1754 | + } | |
| 1755 | + } | |
| 1756 | + if (c == null) { | |
| 1757 | + c = parseColorString(str); | |
| 1758 | + } | |
| 1759 | + return c; | |
| 1760 | + } | |
| 1761 | + | |
| 1762 | + private static Color parseColorString(String str) { | |
| 1763 | + if (str.charAt(0) == '#') { | |
| 1764 | + str = str.substring(1); | |
| 1765 | + | |
| 1766 | + int i = str.length(); | |
| 1767 | + | |
| 1768 | + if (i < 3 || i > 12 || (i % 3) != 0) { | |
| 1769 | + return null; | |
| 1770 | + } | |
| 1771 | + | |
| 1772 | + i /= 3; | |
| 1773 | + | |
| 1774 | + int r; | |
| 1775 | + int g; | |
| 1776 | + int b; | |
| 1777 | + | |
| 1778 | + try { | |
| 1779 | + r = Integer.parseInt(str.substring(0, i), 16); | |
| 1780 | + g = Integer.parseInt(str.substring(i, i * 2), 16); | |
| 1781 | + b = Integer.parseInt(str.substring(i * 2, i * 3), 16); | |
| 1782 | + } catch (NumberFormatException nfe) { | |
| 1783 | + return null; | |
| 1784 | + } | |
| 1785 | + | |
| 1786 | + if (i == 4) { | |
| 1787 | + return new ColorUIResource(r / 65535.0f, g / 65535.0f, b / 65535.0f); | |
| 1788 | + } else if (i == 1) { | |
| 1789 | + return new ColorUIResource(r / 15.0f, g / 15.0f, b / 15.0f); | |
| 1790 | + } else if (i == 2) { | |
| 1791 | + return new ColorUIResource(r, g, b); | |
| 1792 | + } else { | |
| 1793 | + return new ColorUIResource(r / 4095.0f, g / 4095.0f, b / 4095.0f); | |
| 1794 | + } | |
| 1795 | + } else { | |
| 1796 | + return XColors.lookupColor(str); | |
| 1797 | + } | |
| 1798 | + } | |
| 1799 | + | |
| 1800 | + class ArithmeticExpressionEvaluator { | |
| 1801 | + private PeekableStringTokenizer tokenizer; | |
| 1802 | + | |
| 1803 | + int evaluate(String expr) { | |
| 1804 | + tokenizer = new PeekableStringTokenizer(expr, " \t+-*/%()", true); | |
| 1805 | + return Math.round(expression()); | |
| 1806 | + } | |
| 1807 | + | |
| 1808 | + int evaluate(String expr, int fallback) { | |
| 1809 | + return (expr != null) ? evaluate(expr) : fallback; | |
| 1810 | + } | |
| 1811 | + | |
| 1812 | + public float expression() { | |
| 1813 | + float value = getTermValue(); | |
| 1814 | + boolean done = false; | |
| 1815 | + while (!done && tokenizer.hasMoreTokens()) { | |
| 1816 | + String next = tokenizer.peek(); | |
| 1817 | + if ("+".equals(next) || | |
| 1818 | + "-".equals(next) || | |
| 1819 | + "`max`".equals(next) || | |
| 1820 | + "`min`".equals(next)) { | |
| 1821 | + tokenizer.nextToken(); | |
| 1822 | + float value2 = getTermValue(); | |
| 1823 | + if ("+".equals(next)) { | |
| 1824 | + value += value2; | |
| 1825 | + } else if ("-".equals(next)) { | |
| 1826 | + value -= value2; | |
| 1827 | + } else if ("`max`".equals(next)) { | |
| 1828 | + value = Math.max(value, value2); | |
| 1829 | + } else if ("`min`".equals(next)) { | |
| 1830 | + value = Math.min(value, value2); | |
| 1831 | + } | |
| 1832 | + } else { | |
| 1833 | + done = true; | |
| 1834 | + } | |
| 1835 | + } | |
| 1836 | + return value; | |
| 1837 | + } | |
| 1838 | + | |
| 1839 | + public float getTermValue() { | |
| 1840 | + float value = getFactorValue(); | |
| 1841 | + boolean done = false; | |
| 1842 | + while (!done && tokenizer.hasMoreTokens()) { | |
| 1843 | + String next = tokenizer.peek(); | |
| 1844 | + if ("*".equals(next) || "/".equals(next) || "%".equals(next)) { | |
| 1845 | + tokenizer.nextToken(); | |
| 1846 | + float value2 = getFactorValue(); | |
| 1847 | + if ("*".equals(next)) { | |
| 1848 | + value *= value2; | |
| 1849 | + } else if ("/".equals(next)) { | |
| 1850 | + value /= value2; | |
| 1851 | + } else { | |
| 1852 | + value %= value2; | |
| 1853 | + } | |
| 1854 | + } else { | |
| 1855 | + done = true; | |
| 1856 | + } | |
| 1857 | + } | |
| 1858 | + return value; | |
| 1859 | + } | |
| 1860 | + | |
| 1861 | + public float getFactorValue() { | |
| 1862 | + float value; | |
| 1863 | + if ("(".equals(tokenizer.peek())) { | |
| 1864 | + tokenizer.nextToken(); | |
| 1865 | + value = expression(); | |
| 1866 | + tokenizer.nextToken(); // skip right paren | |
| 1867 | + } else { | |
| 1868 | + String token = tokenizer.nextToken(); | |
| 1869 | + if (Character.isDigit(token.charAt(0))) { | |
| 1870 | + value = Float.parseFloat(token); | |
| 1871 | + } else { | |
| 1872 | + Integer i = variables.get(token); | |
| 1873 | + if (i == null) { | |
| 1874 | + i = (Integer)getFrameGeometry().get(token); | |
| 1875 | + } | |
| 1876 | + if (i == null) { | |
| 1877 | + logError(themeName, "Variable \"" + token + "\" not defined"); | |
| 1878 | + return 0; | |
| 1879 | + } | |
| 1880 | + value = (i != null) ? i.intValue() : 0F; | |
| 1881 | + } | |
| 1882 | + } | |
| 1883 | + return value; | |
| 1884 | + } | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + } | |
| 1888 | + | |
| 1889 | + static class PeekableStringTokenizer extends StringTokenizer { | |
| 1890 | + String token = null; | |
| 1891 | + | |
| 1892 | + public PeekableStringTokenizer(String str, String delim, | |
| 1893 | + boolean returnDelims) { | |
| 1894 | + super(str, delim, returnDelims); | |
| 1895 | + peek(); | |
| 1896 | + } | |
| 1897 | + | |
| 1898 | + public String peek() { | |
| 1899 | + if (token == null) { | |
| 1900 | + token = nextToken(); | |
| 1901 | + } | |
| 1902 | + return token; | |
| 1903 | + } | |
| 1904 | + | |
| 1905 | + public boolean hasMoreTokens() { | |
| 1906 | + return (token != null || super.hasMoreTokens()); | |
| 1907 | + } | |
| 1908 | + | |
| 1909 | + public String nextToken() { | |
| 1910 | + if (token != null) { | |
| 1911 | + String t = token; | |
| 1912 | + token = null; | |
| 1913 | + if (hasMoreTokens()) { | |
| 1914 | + peek(); | |
| 1915 | + } | |
| 1916 | + return t; | |
| 1917 | + } else { | |
| 1918 | + String token = super.nextToken(); | |
| 1919 | + while ((token.equals(" ") || token.equals("\t")) | |
| 1920 | + && hasMoreTokens()) { | |
| 1921 | + token = super.nextToken(); | |
| 1922 | + } | |
| 1923 | + return token; | |
| 1924 | + } | |
| 1925 | + } | |
| 1926 | + } | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + static class RoundRectClipShape extends RectangularShape { | |
| 1930 | + static final int TOP_LEFT = 1; | |
| 1931 | + static final int TOP_RIGHT = 2; | |
| 1932 | + static final int BOTTOM_LEFT = 4; | |
| 1933 | + static final int BOTTOM_RIGHT = 8; | |
| 1934 | + | |
| 1935 | + int x; | |
| 1936 | + int y; | |
| 1937 | + int width; | |
| 1938 | + int height; | |
| 1939 | + int arcwidth; | |
| 1940 | + int archeight; | |
| 1941 | + int corners; | |
| 1942 | + | |
| 1943 | + public RoundRectClipShape() { | |
| 1944 | + } | |
| 1945 | + | |
| 1946 | + public RoundRectClipShape(int x, int y, int w, int h, | |
| 1947 | + int arcw, int arch, int corners) { | |
| 1948 | + setRoundedRect(x, y, w, h, arcw, arch, corners); | |
| 1949 | + } | |
| 1950 | + | |
| 1951 | + public void setRoundedRect(int x, int y, int w, int h, | |
| 1952 | + int arcw, int arch, int corners) { | |
| 1953 | + this.corners = corners; | |
| 1954 | + this.x = x; | |
| 1955 | + this.y = y; | |
| 1956 | + this.width = w; | |
| 1957 | + this.height = h; | |
| 1958 | + this.arcwidth = arcw; | |
| 1959 | + this.archeight = arch; | |
| 1960 | + } | |
| 1961 | + | |
| 1962 | + public double getX() { | |
| 1963 | + return (double)x; | |
| 1964 | + } | |
| 1965 | + | |
| 1966 | + public double getY() { | |
| 1967 | + return (double)y; | |
| 1968 | + } | |
| 1969 | + | |
| 1970 | + public double getWidth() { | |
| 1971 | + return (double)width; | |
| 1972 | + } | |
| 1973 | + | |
| 1974 | + public double getHeight() { | |
| 1975 | + return (double)height; | |
| 1976 | + } | |
| 1977 | + | |
| 1978 | + public double getArcWidth() { | |
| 1979 | + return (double)arcwidth; | |
| 1980 | + } | |
| 1981 | + | |
| 1982 | + public double getArcHeight() { | |
| 1983 | + return (double)archeight; | |
| 1984 | + } | |
| 1985 | + | |
| 1986 | + public boolean isEmpty() { | |
| 1987 | + return false; // Not called | |
| 1988 | + } | |
| 1989 | + | |
| 1990 | + public Rectangle2D getBounds2D() { | |
| 1991 | + return null; // Not called | |
| 1992 | + } | |
| 1993 | + | |
| 1994 | + public int getCornerFlags() { | |
| 1995 | + return corners; | |
| 1996 | + } | |
| 1997 | + | |
| 1998 | + public void setFrame(double x, double y, double w, double h) { | |
| 1999 | + // Not called | |
| 2000 | + } | |
| 2001 | + | |
| 2002 | + public boolean contains(double x, double y) { | |
| 2003 | + return false; // Not called | |
| 2004 | + } | |
| 2005 | + | |
| 2006 | + private int classify(double coord, double left, double right, double arcsize) { | |
| 2007 | + return 0; // Not called | |
| 2008 | + } | |
| 2009 | + | |
| 2010 | + public boolean intersects(double x, double y, double w, double h) { | |
| 2011 | + return false; // Not called | |
| 2012 | + } | |
| 2013 | + | |
| 2014 | + public boolean contains(double x, double y, double w, double h) { | |
| 2015 | + return false; // Not called | |
| 2016 | + } | |
| 2017 | + | |
| 2018 | + public PathIterator getPathIterator(AffineTransform at) { | |
| 2019 | + return new RoundishRectIterator(this, at); | |
| 2020 | + } | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + static class RoundishRectIterator implements PathIterator { | |
| 2024 | + double x, y, w, h, aw, ah; | |
| 2025 | + AffineTransform affine; | |
| 2026 | + int index; | |
| 2027 | + | |
| 2028 | + double ctrlpts[][]; | |
| 2029 | + int types[]; | |
| 2030 | + | |
| 2031 | + private static final double angle = Math.PI / 4.0; | |
| 2032 | + private static final double a = 1.0 - Math.cos(angle); | |
| 2033 | + private static final double b = Math.tan(angle); | |
| 2034 | + private static final double c = Math.sqrt(1.0 + b * b) - 1 + a; | |
| 2035 | + private static final double cv = 4.0 / 3.0 * a * b / c; | |
| 2036 | + private static final double acv = (1.0 - cv) / 2.0; | |
| 2037 | + | |
| 2038 | + // For each array: | |
| 2039 | + // 4 values for each point {v0, v1, v2, v3}: | |
| 2040 | + // point = (x + v0 * w + v1 * arcWidth, | |
| 2041 | + // y + v2 * h + v3 * arcHeight); | |
| 2042 | + private static final double CtrlPtTemplate[][] = { | |
| 2043 | + { 0.0, 0.0, 1.0, 0.0 }, /* BOTTOM LEFT corner */ | |
| 2044 | + { 0.0, 0.0, 1.0, -0.5 }, /* BOTTOM LEFT arc start */ | |
| 2045 | + { 0.0, 0.0, 1.0, -acv, /* BOTTOM LEFT arc curve */ | |
| 2046 | + 0.0, acv, 1.0, 0.0, | |
| 2047 | + 0.0, 0.5, 1.0, 0.0 }, | |
| 2048 | + { 1.0, 0.0, 1.0, 0.0 }, /* BOTTOM RIGHT corner */ | |
| 2049 | + { 1.0, -0.5, 1.0, 0.0 }, /* BOTTOM RIGHT arc start */ | |
| 2050 | + { 1.0, -acv, 1.0, 0.0, /* BOTTOM RIGHT arc curve */ | |
| 2051 | + 1.0, 0.0, 1.0, -acv, | |
| 2052 | + 1.0, 0.0, 1.0, -0.5 }, | |
| 2053 | + { 1.0, 0.0, 0.0, 0.0 }, /* TOP RIGHT corner */ | |
| 2054 | + { 1.0, 0.0, 0.0, 0.5 }, /* TOP RIGHT arc start */ | |
| 2055 | + { 1.0, 0.0, 0.0, acv, /* TOP RIGHT arc curve */ | |
| 2056 | + 1.0, -acv, 0.0, 0.0, | |
| 2057 | + 1.0, -0.5, 0.0, 0.0 }, | |
| 2058 | + { 0.0, 0.0, 0.0, 0.0 }, /* TOP LEFT corner */ | |
| 2059 | + { 0.0, 0.5, 0.0, 0.0 }, /* TOP LEFT arc start */ | |
| 2060 | + { 0.0, acv, 0.0, 0.0, /* TOP LEFT arc curve */ | |
| 2061 | + 0.0, 0.0, 0.0, acv, | |
| 2062 | + 0.0, 0.0, 0.0, 0.5 }, | |
| 2063 | + {}, /* Closing path element */ | |
| 2064 | + }; | |
| 2065 | + private static final int CornerFlags[] = { | |
| 2066 | + RoundRectClipShape.BOTTOM_LEFT, | |
| 2067 | + RoundRectClipShape.BOTTOM_RIGHT, | |
| 2068 | + RoundRectClipShape.TOP_RIGHT, | |
| 2069 | + RoundRectClipShape.TOP_LEFT, | |
| 2070 | + }; | |
| 2071 | + | |
| 2072 | + RoundishRectIterator(RoundRectClipShape rr, AffineTransform at) { | |
| 2073 | + this.x = rr.getX(); | |
| 2074 | + this.y = rr.getY(); | |
| 2075 | + this.w = rr.getWidth(); | |
| 2076 | + this.h = rr.getHeight(); | |
| 2077 | + this.aw = Math.min(w, Math.abs(rr.getArcWidth())); | |
| 2078 | + this.ah = Math.min(h, Math.abs(rr.getArcHeight())); | |
| 2079 | + this.affine = at; | |
| 2080 | + if (w < 0 || h < 0) { | |
| 2081 | + // Don't draw anything... | |
| 2082 | + ctrlpts = new double[0][]; | |
| 2083 | + types = new int[0]; | |
| 2084 | + } else { | |
| 2085 | + int corners = rr.getCornerFlags(); | |
| 2086 | + int numedges = 5; // 4xCORNER_POINT, CLOSE | |
| 2087 | + for (int i = 1; i < 0x10; i <<= 1) { | |
| 2088 | + // Add one for each corner that has a curve | |
| 2089 | + if ((corners & i) != 0) numedges++; | |
| 2090 | + } | |
| 2091 | + ctrlpts = new double[numedges][]; | |
| 2092 | + types = new int[numedges]; | |
| 2093 | + int j = 0; | |
| 2094 | + for (int i = 0; i < 4; i++) { | |
| 2095 | + types[j] = SEG_LINETO; | |
| 2096 | + if ((corners & CornerFlags[i]) == 0) { | |
| 2097 | + ctrlpts[j++] = CtrlPtTemplate[i*3+0]; | |
| 2098 | + } else { | |
| 2099 | + ctrlpts[j++] = CtrlPtTemplate[i*3+1]; | |
| 2100 | + types[j] = SEG_CUBICTO; | |
| 2101 | + ctrlpts[j++] = CtrlPtTemplate[i*3+2]; | |
| 2102 | + } | |
| 2103 | + } | |
| 2104 | + types[j] = SEG_CLOSE; | |
| 2105 | + ctrlpts[j++] = CtrlPtTemplate[12]; | |
| 2106 | + types[0] = SEG_MOVETO; | |
| 2107 | + } | |
| 2108 | + } | |
| 2109 | + | |
| 2110 | + public int getWindingRule() { | |
| 2111 | + return WIND_NON_ZERO; | |
| 2112 | + } | |
| 2113 | + | |
| 2114 | + public boolean isDone() { | |
| 2115 | + return index >= ctrlpts.length; | |
| 2116 | + } | |
| 2117 | + | |
| 2118 | + public void next() { | |
| 2119 | + index++; | |
| 2120 | + } | |
| 2121 | + | |
| 2122 | + public int currentSegment(float[] coords) { | |
| 2123 | + if (isDone()) { | |
| 2124 | + throw new NoSuchElementException("roundrect iterator out of bounds"); | |
| 2125 | + } | |
| 2126 | + double ctrls[] = ctrlpts[index]; | |
| 2127 | + int nc = 0; | |
| 2128 | + for (int i = 0; i < ctrls.length; i += 4) { | |
| 2129 | + coords[nc++] = (float) (x + ctrls[i + 0] * w + ctrls[i + 1] * aw); | |
| 2130 | + coords[nc++] = (float) (y + ctrls[i + 2] * h + ctrls[i + 3] * ah); | |
| 2131 | + } | |
| 2132 | + if (affine != null) { | |
| 2133 | + affine.transform(coords, 0, coords, 0, nc / 2); | |
| 2134 | + } | |
| 2135 | + return types[index]; | |
| 2136 | + } | |
| 2137 | + | |
| 2138 | + public int currentSegment(double[] coords) { | |
| 2139 | + if (isDone()) { | |
| 2140 | + throw new NoSuchElementException("roundrect iterator out of bounds"); | |
| 2141 | + } | |
| 2142 | + double ctrls[] = ctrlpts[index]; | |
| 2143 | + int nc = 0; | |
| 2144 | + for (int i = 0; i < ctrls.length; i += 4) { | |
| 2145 | + coords[nc++] = x + ctrls[i + 0] * w + ctrls[i + 1] * aw; | |
| 2146 | + coords[nc++] = y + ctrls[i + 2] * h + ctrls[i + 3] * ah; | |
| 2147 | + } | |
| 2148 | + if (affine != null) { | |
| 2149 | + affine.transform(coords, 0, coords, 0, nc / 2); | |
| 2150 | + } | |
| 2151 | + return types[index]; | |
| 2152 | + } | |
| 2153 | + } | |
| 2154 | + } | |
| 2155 | +} | |
| @@ -0,0 +1,233 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.awt.geom.AffineTransform; | |
| 30 | +import javax.swing.plaf.FontUIResource; | |
| 31 | +import java.util.StringTokenizer; | |
| 32 | + | |
| 33 | +import sun.font.FontConfigManager; | |
| 34 | +import sun.font.FontUtilities; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * @author Shannon Hickey | |
| 38 | + * @author Leif Samuelsson | |
| 39 | + */ | |
| 40 | +class PangoFonts { | |
| 41 | + | |
| 42 | + public static final String CHARS_DIGITS = "0123456789"; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Calculate a default scale factor for fonts in this L&F to match | |
| 46 | + * the reported resolution of the screen. | |
| 47 | + * Java 2D specified a default user-space scale of 72dpi. | |
| 48 | + * This is unlikely to correspond to that of the real screen. | |
| 49 | + * The Xserver reports a value which may be used to adjust for this. | |
| 50 | + * and Java 2D exposes it via a normalizing transform. | |
| 51 | + * However many Xservers report a hard-coded 90dpi whilst others report a | |
| 52 | + * calculated value based on possibly incorrect data. | |
| 53 | + * That is something that must be solved at the X11 level | |
| 54 | + * Note that in an X11 multi-screen environment, the default screen | |
| 55 | + * is the one used by the JRE so it is safe to use it here. | |
| 56 | + */ | |
| 57 | + private static double fontScale; | |
| 58 | + | |
| 59 | + static { | |
| 60 | + fontScale = 1.0d; | |
| 61 | + GraphicsEnvironment ge = | |
| 62 | + GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
| 63 | + | |
| 64 | + if (!ge.isHeadless()) { | |
| 65 | + GraphicsConfiguration gc = | |
| 66 | + ge.getDefaultScreenDevice().getDefaultConfiguration(); | |
| 67 | + AffineTransform at = gc.getNormalizingTransform(); | |
| 68 | + fontScale = at.getScaleY(); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Parses a String containing a pango font description and returns | |
| 75 | + * a Font object. | |
| 76 | + * | |
| 77 | + * @param pangoName a String describing a pango font | |
| 78 | + * e.g. "Sans Italic 10" | |
| 79 | + * @return a Font object as a FontUIResource | |
| 80 | + * or null if no suitable font could be created. | |
| 81 | + */ | |
| 82 | + static Font lookupFont(String pangoName) { | |
| 83 | + String family = ""; | |
| 84 | + int style = Font.PLAIN; | |
| 85 | + int size = 10; | |
| 86 | + | |
| 87 | + StringTokenizer tok = new StringTokenizer(pangoName); | |
| 88 | + | |
| 89 | + while (tok.hasMoreTokens()) { | |
| 90 | + String word = tok.nextToken(); | |
| 91 | + | |
| 92 | + if (word.equalsIgnoreCase("italic")) { | |
| 93 | + style |= Font.ITALIC; | |
| 94 | + } else if (word.equalsIgnoreCase("bold")) { | |
| 95 | + style |= Font.BOLD; | |
| 96 | + } else if (CHARS_DIGITS.indexOf(word.charAt(0)) != -1) { | |
| 97 | + try { | |
| 98 | + size = Integer.parseInt(word); | |
| 99 | + } catch (NumberFormatException ex) { | |
| 100 | + } | |
| 101 | + } else { | |
| 102 | + if (family.length() > 0) { | |
| 103 | + family += " "; | |
| 104 | + } | |
| 105 | + | |
| 106 | + family += word; | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 110 | + /* | |
| 111 | + * Java 2D font point sizes are in a user-space scale of 72dpi. | |
| 112 | + * GTK allows a user to configure a "dpi" property used to scale | |
| 113 | + * the fonts used to match a user's preference. | |
| 114 | + * To match the font size of GTK apps we need to obtain this DPI and | |
| 115 | + * adjust as follows: | |
| 116 | + * Some versions of GTK use XSETTINGS if available to dynamically | |
| 117 | + * monitor user-initiated changes in the DPI to be used by GTK | |
| 118 | + * apps. This value is also made available as the Xft.dpi X resource. | |
| 119 | + * This is presumably a function of the font preferences API and/or | |
| 120 | + * the manner in which it requests the toolkit to update the default | |
| 121 | + * for the desktop. This dual approach is probably necessary since | |
| 122 | + * other versions of GTK - or perhaps some apps - determine the size | |
| 123 | + * to use only at start-up from that X resource. | |
| 124 | + * If that resource is not set then GTK scales for the DPI resolution | |
| 125 | + * reported by the Xserver using the formula | |
| 126 | + * DisplayHeight(dpy, screen) / DisplayHeightMM(dpy, screen) * 25.4 | |
| 127 | + * (25.4mm == 1 inch). | |
| 128 | + * JDK tracks the Xft.dpi XSETTINGS property directly so it can | |
| 129 | + * dynamically change font size by tracking just that value. | |
| 130 | + * If that resource is not available use the same fall back formula | |
| 131 | + * as GTK (see calculation for fontScale). | |
| 132 | + * | |
| 133 | + * GTK's default setting for Xft.dpi is 96 dpi (and it seems -1 | |
| 134 | + * apparently also can mean that "default"). However this default | |
| 135 | + * isn't used if there's no property set. The real default in the | |
| 136 | + * absence of a resource is the Xserver reported dpi. | |
| 137 | + * Finally this DPI is used to calculate the nearest Java 2D font | |
| 138 | + * 72 dpi font size. | |
| 139 | + * There are cases in which JDK behaviour may not exactly mimic | |
| 140 | + * GTK native app behaviour : | |
| 141 | + * 1) When a GTK app is not able to dynamically track the changes | |
| 142 | + * (does not use XSETTINGS), JDK will resize but other apps will | |
| 143 | + * not. This is OK as JDK is exhibiting preferred behaviour and | |
| 144 | + * this is probably how all later GTK apps will behave | |
| 145 | + * 2) When a GTK app does not use XSETTINGS and for some reason | |
| 146 | + * the XRDB property is not present. JDK will pick up XSETTINGS | |
| 147 | + * and the GTK app will use the Xserver default. Since its | |
| 148 | + * impossible for JDK to know that some other GTK app is not | |
| 149 | + * using XSETTINGS its impossible to account for this and in any | |
| 150 | + * case for it to be a problem the values would have to be different. | |
| 151 | + * It also seems unlikely to arise except when a user explicitly | |
| 152 | + * deletes the X resource database entry. | |
| 153 | + * There also some other issues to be aware of for the future: | |
| 154 | + * GTK specifies the Xft.dpi value as server-wide which when used | |
| 155 | + * on systems with 2 distinct X screens with different physical DPI | |
| 156 | + * the font sizes will inevitably appear different. It would have | |
| 157 | + * been a more user-friendly design to further adjust that one | |
| 158 | + * setting depending on the screen resolution to achieve perceived | |
| 159 | + * equivalent sizes. If such a change were ever to be made in GTK | |
| 160 | + * we would need to update for that. | |
| 161 | + */ | |
| 162 | + double dsize = size; | |
| 163 | + int dpi = 96; | |
| 164 | + Object value = | |
| 165 | + Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI"); | |
| 166 | + if (value instanceof Integer) { | |
| 167 | + dpi = ((Integer)value).intValue() / 1024; | |
| 168 | + if (dpi == -1) { | |
| 169 | + dpi = 96; | |
| 170 | + } | |
| 171 | + if (dpi < 50) { /* 50 dpi is the minimum value gnome allows */ | |
| 172 | + dpi = 50; | |
| 173 | + } | |
| 174 | + /* The Java rasteriser assumes pts are in a user space of | |
| 175 | + * 72 dpi, so we need to adjust for that. | |
| 176 | + */ | |
| 177 | + dsize = ((double)(dpi * size)/ 72.0); | |
| 178 | + } else { | |
| 179 | + /* If there's no property, GTK scales for the resolution | |
| 180 | + * reported by the Xserver using the formula listed above. | |
| 181 | + * fontScale already accounts for the 72 dpi Java 2D space. | |
| 182 | + */ | |
| 183 | + dsize = size * fontScale; | |
| 184 | + } | |
| 185 | + | |
| 186 | + /* Round size to nearest integer pt size */ | |
| 187 | + size = (int)(dsize + 0.5); | |
| 188 | + if (size < 1) { | |
| 189 | + size = 1; | |
| 190 | + } | |
| 191 | + | |
| 192 | + String fcFamilyLC = family.toLowerCase(); | |
| 193 | + if (FontUtilities.mapFcName(fcFamilyLC) != null) { | |
| 194 | + /* family is a Fc/Pango logical font which we need to expand. */ | |
| 195 | + Font font = FontUtilities.getFontConfigFUIR(fcFamilyLC, style, size); | |
| 196 | + font = font.deriveFont(style, (float)dsize); | |
| 197 | + return new FontUIResource(font); | |
| 198 | + } else { | |
| 199 | + /* It's a physical font which we will create with a fallback */ | |
| 200 | + Font font = new Font(family, style, size); | |
| 201 | + /* a roundabout way to set the font size in floating points */ | |
| 202 | + font = font.deriveFont(style, (float)dsize); | |
| 203 | + FontUIResource fuir = new FontUIResource(font); | |
| 204 | + return FontUtilities.getCompositeFontUIResource(fuir); | |
| 205 | + } | |
| 206 | + } | |
| 207 | + | |
| 208 | + /** | |
| 209 | + * Parses a String containing a pango font description and returns | |
| 210 | + * the (unscaled) font size as an integer. | |
| 211 | + * | |
| 212 | + * @param pangoName a String describing a pango font | |
| 213 | + * @return the size of the font described by pangoName (e.g. if | |
| 214 | + * pangoName is "Sans Italic 10", then this method returns 10) | |
| 215 | + */ | |
| 216 | + static int getFontSize(String pangoName) { | |
| 217 | + int size = 10; | |
| 218 | + | |
| 219 | + StringTokenizer tok = new StringTokenizer(pangoName); | |
| 220 | + while (tok.hasMoreTokens()) { | |
| 221 | + String word = tok.nextToken(); | |
| 222 | + | |
| 223 | + if (CHARS_DIGITS.indexOf(word.charAt(0)) != -1) { | |
| 224 | + try { | |
| 225 | + size = Integer.parseInt(word); | |
| 226 | + } catch (NumberFormatException ex) { | |
| 227 | + } | |
| 228 | + } | |
| 229 | + } | |
| 230 | + | |
| 231 | + return size; | |
| 232 | + } | |
| 233 | +} | |
| @@ -0,0 +1,831 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.gtk; | |
| 27 | + | |
| 28 | +import java.awt.Color; | |
| 29 | +import java.util.Arrays; | |
| 30 | +import javax.swing.plaf.ColorUIResource; | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * @author Shannon Hickey | |
| 34 | + */ | |
| 35 | +class XColors { | |
| 36 | + | |
| 37 | + private static class XColor implements Comparable { | |
| 38 | + String name; | |
| 39 | + | |
| 40 | + int red; | |
| 41 | + int green; | |
| 42 | + int blue; | |
| 43 | + | |
| 44 | + XColor(String name, int red, int green, int blue) { | |
| 45 | + this.name = name; | |
| 46 | + this.red = red; | |
| 47 | + this.green = green; | |
| 48 | + this.blue = blue; | |
| 49 | + } | |
| 50 | + | |
| 51 | + Color toColor() { | |
| 52 | + return new ColorUIResource(red, green, blue); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public int compareTo(Object o) { | |
| 56 | + XColor other = (XColor)o; | |
| 57 | + | |
| 58 | + return name.compareTo(other.name); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + private static XColor key = new XColor("", -1, -1, -1); | |
| 63 | + | |
| 64 | + static Color lookupColor(String name) { | |
| 65 | + key.name = name.toLowerCase(); | |
| 66 | + | |
| 67 | + int pos = Arrays.binarySearch(colors, key); | |
| 68 | + | |
| 69 | + if (pos < 0) { | |
| 70 | + return null; | |
| 71 | + } | |
| 72 | + | |
| 73 | + return colors[pos].toColor(); | |
| 74 | + } | |
| 75 | + | |
| 76 | + private static final XColor[] colors = { | |
| 77 | + new XColor("alice blue", 240, 248, 255), | |
| 78 | + new XColor("aliceblue", 240, 248, 255), | |
| 79 | + new XColor("antique white", 250, 235, 215), | |
| 80 | + new XColor("antiquewhite", 250, 235, 215), | |
| 81 | + new XColor("antiquewhite1", 255, 239, 219), | |
| 82 | + new XColor("antiquewhite2", 238, 223, 204), | |
| 83 | + new XColor("antiquewhite3", 205, 192, 176), | |
| 84 | + new XColor("antiquewhite4", 139, 131, 120), | |
| 85 | + new XColor("aquamarine", 127, 255, 212), | |
| 86 | + new XColor("aquamarine1", 127, 255, 212), | |
| 87 | + new XColor("aquamarine2", 118, 238, 198), | |
| 88 | + new XColor("aquamarine3", 102, 205, 170), | |
| 89 | + new XColor("aquamarine4", 69, 139, 116), | |
| 90 | + new XColor("azure", 240, 255, 255), | |
| 91 | + new XColor("azure1", 240, 255, 255), | |
| 92 | + new XColor("azure2", 224, 238, 238), | |
| 93 | + new XColor("azure3", 193, 205, 205), | |
| 94 | + new XColor("azure4", 131, 139, 139), | |
| 95 | + new XColor("beige", 245, 245, 220), | |
| 96 | + new XColor("bisque", 255, 228, 196), | |
| 97 | + new XColor("bisque1", 255, 228, 196), | |
| 98 | + new XColor("bisque2", 238, 213, 183), | |
| 99 | + new XColor("bisque3", 205, 183, 158), | |
| 100 | + new XColor("bisque4", 139, 125, 107), | |
| 101 | + new XColor("black", 0, 0, 0), | |
| 102 | + new XColor("blanched almond", 255, 235, 205), | |
| 103 | + new XColor("blanchedalmond", 255, 235, 205), | |
| 104 | + new XColor("blue", 0, 0, 255), | |
| 105 | + new XColor("blue violet", 138, 43, 226), | |
| 106 | + new XColor("blue1", 0, 0, 255), | |
| 107 | + new XColor("blue2", 0, 0, 238), | |
| 108 | + new XColor("blue3", 0, 0, 205), | |
| 109 | + new XColor("blue4", 0, 0, 139), | |
| 110 | + new XColor("blueviolet", 138, 43, 226), | |
| 111 | + new XColor("brown", 165, 42, 42), | |
| 112 | + new XColor("brown1", 255, 64, 64), | |
| 113 | + new XColor("brown2", 238, 59, 59), | |
| 114 | + new XColor("brown3", 205, 51, 51), | |
| 115 | + new XColor("brown4", 139, 35, 35), | |
| 116 | + new XColor("burlywood", 222, 184, 135), | |
| 117 | + new XColor("burlywood1", 255, 211, 155), | |
| 118 | + new XColor("burlywood2", 238, 197, 145), | |
| 119 | + new XColor("burlywood3", 205, 170, 125), | |
| 120 | + new XColor("burlywood4", 139, 115, 85), | |
| 121 | + new XColor("cadet blue", 95, 158, 160), | |
| 122 | + new XColor("cadetblue", 95, 158, 160), | |
| 123 | + new XColor("cadetblue1", 152, 245, 255), | |
| 124 | + new XColor("cadetblue2", 142, 229, 238), | |
| 125 | + new XColor("cadetblue3", 122, 197, 205), | |
| 126 | + new XColor("cadetblue4", 83, 134, 139), | |
| 127 | + new XColor("chartreuse", 127, 255, 0), | |
| 128 | + new XColor("chartreuse1", 127, 255, 0), | |
| 129 | + new XColor("chartreuse2", 118, 238, 0), | |
| 130 | + new XColor("chartreuse3", 102, 205, 0), | |
| 131 | + new XColor("chartreuse4", 69, 139, 0), | |
| 132 | + new XColor("chocolate", 210, 105, 30), | |
| 133 | + new XColor("chocolate1", 255, 127, 36), | |
| 134 | + new XColor("chocolate2", 238, 118, 33), | |
| 135 | + new XColor("chocolate3", 205, 102, 29), | |
| 136 | + new XColor("chocolate4", 139, 69, 19), | |
| 137 | + new XColor("coral", 255, 127, 80), | |
| 138 | + new XColor("coral1", 255, 114, 86), | |
| 139 | + new XColor("coral2", 238, 106, 80), | |
| 140 | + new XColor("coral3", 205, 91, 69), | |
| 141 | + new XColor("coral4", 139, 62, 47), | |
| 142 | + new XColor("cornflower blue", 100, 149, 237), | |
| 143 | + new XColor("cornflowerblue", 100, 149, 237), | |
| 144 | + new XColor("cornsilk", 255, 248, 220), | |
| 145 | + new XColor("cornsilk1", 255, 248, 220), | |
| 146 | + new XColor("cornsilk2", 238, 232, 205), | |
| 147 | + new XColor("cornsilk3", 205, 200, 177), | |
| 148 | + new XColor("cornsilk4", 139, 136, 120), | |
| 149 | + new XColor("cyan", 0, 255, 255), | |
| 150 | + new XColor("cyan1", 0, 255, 255), | |
| 151 | + new XColor("cyan2", 0, 238, 238), | |
| 152 | + new XColor("cyan3", 0, 205, 205), | |
| 153 | + new XColor("cyan4", 0, 139, 139), | |
| 154 | + new XColor("dark blue", 0, 0, 139), | |
| 155 | + new XColor("dark cyan", 0, 139, 139), | |
| 156 | + new XColor("dark goldenrod", 184, 134, 11), | |
| 157 | + new XColor("dark gray", 169, 169, 169), | |
| 158 | + new XColor("dark green", 0, 100, 0), | |
| 159 | + new XColor("dark grey", 169, 169, 169), | |
| 160 | + new XColor("dark khaki", 189, 183, 107), | |
| 161 | + new XColor("dark magenta", 139, 0, 139), | |
| 162 | + new XColor("dark olive green", 85, 107, 47), | |
| 163 | + new XColor("dark orange", 255, 140, 0), | |
| 164 | + new XColor("dark orchid", 153, 50, 204), | |
| 165 | + new XColor("dark red", 139, 0, 0), | |
| 166 | + new XColor("dark salmon", 233, 150, 122), | |
| 167 | + new XColor("dark sea green", 143, 188, 143), | |
| 168 | + new XColor("dark slate blue", 72, 61, 139), | |
| 169 | + new XColor("dark slate gray", 47, 79, 79), | |
| 170 | + new XColor("dark slate grey", 47, 79, 79), | |
| 171 | + new XColor("dark turquoise", 0, 206, 209), | |
| 172 | + new XColor("dark violet", 148, 0, 211), | |
| 173 | + new XColor("darkblue", 0, 0, 139), | |
| 174 | + new XColor("darkcyan", 0, 139, 139), | |
| 175 | + new XColor("darkgoldenrod", 184, 134, 11), | |
| 176 | + new XColor("darkgoldenrod1", 255, 185, 15), | |
| 177 | + new XColor("darkgoldenrod2", 238, 173, 14), | |
| 178 | + new XColor("darkgoldenrod3", 205, 149, 12), | |
| 179 | + new XColor("darkgoldenrod4", 139, 101, 8), | |
| 180 | + new XColor("darkgray", 169, 169, 169), | |
| 181 | + new XColor("darkgreen", 0, 100, 0), | |
| 182 | + new XColor("darkgrey", 169, 169, 169), | |
| 183 | + new XColor("darkkhaki", 189, 183, 107), | |
| 184 | + new XColor("darkmagenta", 139, 0, 139), | |
| 185 | + new XColor("darkolivegreen", 85, 107, 47), | |
| 186 | + new XColor("darkolivegreen1", 202, 255, 112), | |
| 187 | + new XColor("darkolivegreen2", 188, 238, 104), | |
| 188 | + new XColor("darkolivegreen3", 162, 205, 90), | |
| 189 | + new XColor("darkolivegreen4", 110, 139, 61), | |
| 190 | + new XColor("darkorange", 255, 140, 0), | |
| 191 | + new XColor("darkorange1", 255, 127, 0), | |
| 192 | + new XColor("darkorange2", 238, 118, 0), | |
| 193 | + new XColor("darkorange3", 205, 102, 0), | |
| 194 | + new XColor("darkorange4", 139, 69, 0), | |
| 195 | + new XColor("darkorchid", 153, 50, 204), | |
| 196 | + new XColor("darkorchid1", 191, 62, 255), | |
| 197 | + new XColor("darkorchid2", 178, 58, 238), | |
| 198 | + new XColor("darkorchid3", 154, 50, 205), | |
| 199 | + new XColor("darkorchid4", 104, 34, 139), | |
| 200 | + new XColor("darkred", 139, 0, 0), | |
| 201 | + new XColor("darksalmon", 233, 150, 122), | |
| 202 | + new XColor("darkseagreen", 143, 188, 143), | |
| 203 | + new XColor("darkseagreen1", 193, 255, 193), | |
| 204 | + new XColor("darkseagreen2", 180, 238, 180), | |
| 205 | + new XColor("darkseagreen3", 155, 205, 155), | |
| 206 | + new XColor("darkseagreen4", 105, 139, 105), | |
| 207 | + new XColor("darkslateblue", 72, 61, 139), | |
| 208 | + new XColor("darkslategray", 47, 79, 79), | |
| 209 | + new XColor("darkslategray1", 151, 255, 255), | |
| 210 | + new XColor("darkslategray2", 141, 238, 238), | |
| 211 | + new XColor("darkslategray3", 121, 205, 205), | |
| 212 | + new XColor("darkslategray4", 82, 139, 139), | |
| 213 | + new XColor("darkslategrey", 47, 79, 79), | |
| 214 | + new XColor("darkturquoise", 0, 206, 209), | |
| 215 | + new XColor("darkviolet", 148, 0, 211), | |
| 216 | + new XColor("deep pink", 255, 20, 147), | |
| 217 | + new XColor("deep sky blue", 0, 191, 255), | |
| 218 | + new XColor("deeppink", 255, 20, 147), | |
| 219 | + new XColor("deeppink1", 255, 20, 147), | |
| 220 | + new XColor("deeppink2", 238, 18, 137), | |
| 221 | + new XColor("deeppink3", 205, 16, 118), | |
| 222 | + new XColor("deeppink4", 139, 10, 80), | |
| 223 | + new XColor("deepskyblue", 0, 191, 255), | |
| 224 | + new XColor("deepskyblue1", 0, 191, 255), | |
| 225 | + new XColor("deepskyblue2", 0, 178, 238), | |
| 226 | + new XColor("deepskyblue3", 0, 154, 205), | |
| 227 | + new XColor("deepskyblue4", 0, 104, 139), | |
| 228 | + new XColor("dim gray", 105, 105, 105), | |
| 229 | + new XColor("dim grey", 105, 105, 105), | |
| 230 | + new XColor("dimgray", 105, 105, 105), | |
| 231 | + new XColor("dimgrey", 105, 105, 105), | |
| 232 | + new XColor("dodger blue", 30, 144, 255), | |
| 233 | + new XColor("dodgerblue", 30, 144, 255), | |
| 234 | + new XColor("dodgerblue1", 30, 144, 255), | |
| 235 | + new XColor("dodgerblue2", 28, 134, 238), | |
| 236 | + new XColor("dodgerblue3", 24, 116, 205), | |
| 237 | + new XColor("dodgerblue4", 16, 78, 139), | |
| 238 | + new XColor("firebrick", 178, 34, 34), | |
| 239 | + new XColor("firebrick1", 255, 48, 48), | |
| 240 | + new XColor("firebrick2", 238, 44, 44), | |
| 241 | + new XColor("firebrick3", 205, 38, 38), | |
| 242 | + new XColor("firebrick4", 139, 26, 26), | |
| 243 | + new XColor("floral white", 255, 250, 240), | |
| 244 | + new XColor("floralwhite", 255, 250, 240), | |
| 245 | + new XColor("forest green", 34, 139, 34), | |
| 246 | + new XColor("forestgreen", 34, 139, 34), | |
| 247 | + new XColor("gainsboro", 220, 220, 220), | |
| 248 | + new XColor("ghost white", 248, 248, 255), | |
| 249 | + new XColor("ghostwhite", 248, 248, 255), | |
| 250 | + new XColor("gold", 255, 215, 0), | |
| 251 | + new XColor("gold1", 255, 215, 0), | |
| 252 | + new XColor("gold2", 238, 201, 0), | |
| 253 | + new XColor("gold3", 205, 173, 0), | |
| 254 | + new XColor("gold4", 139, 117, 0), | |
| 255 | + new XColor("goldenrod", 218, 165, 32), | |
| 256 | + new XColor("goldenrod1", 255, 193, 37), | |
| 257 | + new XColor("goldenrod2", 238, 180, 34), | |
| 258 | + new XColor("goldenrod3", 205, 155, 29), | |
| 259 | + new XColor("goldenrod4", 139, 105, 20), | |
| 260 | + new XColor("gray", 190, 190, 190), | |
| 261 | + new XColor("gray0", 0, 0, 0), | |
| 262 | + new XColor("gray1", 3, 3, 3), | |
| 263 | + new XColor("gray10", 26, 26, 26), | |
| 264 | + new XColor("gray100", 255, 255, 255), | |
| 265 | + new XColor("gray11", 28, 28, 28), | |
| 266 | + new XColor("gray12", 31, 31, 31), | |
| 267 | + new XColor("gray13", 33, 33, 33), | |
| 268 | + new XColor("gray14", 36, 36, 36), | |
| 269 | + new XColor("gray15", 38, 38, 38), | |
| 270 | + new XColor("gray16", 41, 41, 41), | |
| 271 | + new XColor("gray17", 43, 43, 43), | |
| 272 | + new XColor("gray18", 46, 46, 46), | |
| 273 | + new XColor("gray19", 48, 48, 48), | |
| 274 | + new XColor("gray2", 5, 5, 5), | |
| 275 | + new XColor("gray20", 51, 51, 51), | |
| 276 | + new XColor("gray21", 54, 54, 54), | |
| 277 | + new XColor("gray22", 56, 56, 56), | |
| 278 | + new XColor("gray23", 59, 59, 59), | |
| 279 | + new XColor("gray24", 61, 61, 61), | |
| 280 | + new XColor("gray25", 64, 64, 64), | |
| 281 | + new XColor("gray26", 66, 66, 66), | |
| 282 | + new XColor("gray27", 69, 69, 69), | |
| 283 | + new XColor("gray28", 71, 71, 71), | |
| 284 | + new XColor("gray29", 74, 74, 74), | |
| 285 | + new XColor("gray3", 8, 8, 8), | |
| 286 | + new XColor("gray30", 77, 77, 77), | |
| 287 | + new XColor("gray31", 79, 79, 79), | |
| 288 | + new XColor("gray32", 82, 82, 82), | |
| 289 | + new XColor("gray33", 84, 84, 84), | |
| 290 | + new XColor("gray34", 87, 87, 87), | |
| 291 | + new XColor("gray35", 89, 89, 89), | |
| 292 | + new XColor("gray36", 92, 92, 92), | |
| 293 | + new XColor("gray37", 94, 94, 94), | |
| 294 | + new XColor("gray38", 97, 97, 97), | |
| 295 | + new XColor("gray39", 99, 99, 99), | |
| 296 | + new XColor("gray4", 10, 10, 10), | |
| 297 | + new XColor("gray40", 102, 102, 102), | |
| 298 | + new XColor("gray41", 105, 105, 105), | |
| 299 | + new XColor("gray42", 107, 107, 107), | |
| 300 | + new XColor("gray43", 110, 110, 110), | |
| 301 | + new XColor("gray44", 112, 112, 112), | |
| 302 | + new XColor("gray45", 115, 115, 115), | |
| 303 | + new XColor("gray46", 117, 117, 117), | |
| 304 | + new XColor("gray47", 120, 120, 120), | |
| 305 | + new XColor("gray48", 122, 122, 122), | |
| 306 | + new XColor("gray49", 125, 125, 125), | |
| 307 | + new XColor("gray5", 13, 13, 13), | |
| 308 | + new XColor("gray50", 127, 127, 127), | |
| 309 | + new XColor("gray51", 130, 130, 130), | |
| 310 | + new XColor("gray52", 133, 133, 133), | |
| 311 | + new XColor("gray53", 135, 135, 135), | |
| 312 | + new XColor("gray54", 138, 138, 138), | |
| 313 | + new XColor("gray55", 140, 140, 140), | |
| 314 | + new XColor("gray56", 143, 143, 143), | |
| 315 | + new XColor("gray57", 145, 145, 145), | |
| 316 | + new XColor("gray58", 148, 148, 148), | |
| 317 | + new XColor("gray59", 150, 150, 150), | |
| 318 | + new XColor("gray6", 15, 15, 15), | |
| 319 | + new XColor("gray60", 153, 153, 153), | |
| 320 | + new XColor("gray61", 156, 156, 156), | |
| 321 | + new XColor("gray62", 158, 158, 158), | |
| 322 | + new XColor("gray63", 161, 161, 161), | |
| 323 | + new XColor("gray64", 163, 163, 163), | |
| 324 | + new XColor("gray65", 166, 166, 166), | |
| 325 | + new XColor("gray66", 168, 168, 168), | |
| 326 | + new XColor("gray67", 171, 171, 171), | |
| 327 | + new XColor("gray68", 173, 173, 173), | |
| 328 | + new XColor("gray69", 176, 176, 176), | |
| 329 | + new XColor("gray7", 18, 18, 18), | |
| 330 | + new XColor("gray70", 179, 179, 179), | |
| 331 | + new XColor("gray71", 181, 181, 181), | |
| 332 | + new XColor("gray72", 184, 184, 184), | |
| 333 | + new XColor("gray73", 186, 186, 186), | |
| 334 | + new XColor("gray74", 189, 189, 189), | |
| 335 | + new XColor("gray75", 191, 191, 191), | |
| 336 | + new XColor("gray76", 194, 194, 194), | |
| 337 | + new XColor("gray77", 196, 196, 196), | |
| 338 | + new XColor("gray78", 199, 199, 199), | |
| 339 | + new XColor("gray79", 201, 201, 201), | |
| 340 | + new XColor("gray8", 20, 20, 20), | |
| 341 | + new XColor("gray80", 204, 204, 204), | |
| 342 | + new XColor("gray81", 207, 207, 207), | |
| 343 | + new XColor("gray82", 209, 209, 209), | |
| 344 | + new XColor("gray83", 212, 212, 212), | |
| 345 | + new XColor("gray84", 214, 214, 214), | |
| 346 | + new XColor("gray85", 217, 217, 217), | |
| 347 | + new XColor("gray86", 219, 219, 219), | |
| 348 | + new XColor("gray87", 222, 222, 222), | |
| 349 | + new XColor("gray88", 224, 224, 224), | |
| 350 | + new XColor("gray89", 227, 227, 227), | |
| 351 | + new XColor("gray9", 23, 23, 23), | |
| 352 | + new XColor("gray90", 229, 229, 229), | |
| 353 | + new XColor("gray91", 232, 232, 232), | |
| 354 | + new XColor("gray92", 235, 235, 235), | |
| 355 | + new XColor("gray93", 237, 237, 237), | |
| 356 | + new XColor("gray94", 240, 240, 240), | |
| 357 | + new XColor("gray95", 242, 242, 242), | |
| 358 | + new XColor("gray96", 245, 245, 245), | |
| 359 | + new XColor("gray97", 247, 247, 247), | |
| 360 | + new XColor("gray98", 250, 250, 250), | |
| 361 | + new XColor("gray99", 252, 252, 252), | |
| 362 | + new XColor("green", 0, 255, 0), | |
| 363 | + new XColor("green yellow", 173, 255, 47), | |
| 364 | + new XColor("green1", 0, 255, 0), | |
| 365 | + new XColor("green2", 0, 238, 0), | |
| 366 | + new XColor("green3", 0, 205, 0), | |
| 367 | + new XColor("green4", 0, 139, 0), | |
| 368 | + new XColor("greenyellow", 173, 255, 47), | |
| 369 | + new XColor("grey", 190, 190, 190), | |
| 370 | + new XColor("grey0", 0, 0, 0), | |
| 371 | + new XColor("grey1", 3, 3, 3), | |
| 372 | + new XColor("grey10", 26, 26, 26), | |
| 373 | + new XColor("grey100", 255, 255, 255), | |
| 374 | + new XColor("grey11", 28, 28, 28), | |
| 375 | + new XColor("grey12", 31, 31, 31), | |
| 376 | + new XColor("grey13", 33, 33, 33), | |
| 377 | + new XColor("grey14", 36, 36, 36), | |
| 378 | + new XColor("grey15", 38, 38, 38), | |
| 379 | + new XColor("grey16", 41, 41, 41), | |
| 380 | + new XColor("grey17", 43, 43, 43), | |
| 381 | + new XColor("grey18", 46, 46, 46), | |
| 382 | + new XColor("grey19", 48, 48, 48), | |
| 383 | + new XColor("grey2", 5, 5, 5), | |
| 384 | + new XColor("grey20", 51, 51, 51), | |
| 385 | + new XColor("grey21", 54, 54, 54), | |
| 386 | + new XColor("grey22", 56, 56, 56), | |
| 387 | + new XColor("grey23", 59, 59, 59), | |
| 388 | + new XColor("grey24", 61, 61, 61), | |
| 389 | + new XColor("grey25", 64, 64, 64), | |
| 390 | + new XColor("grey26", 66, 66, 66), | |
| 391 | + new XColor("grey27", 69, 69, 69), | |
| 392 | + new XColor("grey28", 71, 71, 71), | |
| 393 | + new XColor("grey29", 74, 74, 74), | |
| 394 | + new XColor("grey3", 8, 8, 8), | |
| 395 | + new XColor("grey30", 77, 77, 77), | |
| 396 | + new XColor("grey31", 79, 79, 79), | |
| 397 | + new XColor("grey32", 82, 82, 82), | |
| 398 | + new XColor("grey33", 84, 84, 84), | |
| 399 | + new XColor("grey34", 87, 87, 87), | |
| 400 | + new XColor("grey35", 89, 89, 89), | |
| 401 | + new XColor("grey36", 92, 92, 92), | |
| 402 | + new XColor("grey37", 94, 94, 94), | |
| 403 | + new XColor("grey38", 97, 97, 97), | |
| 404 | + new XColor("grey39", 99, 99, 99), | |
| 405 | + new XColor("grey4", 10, 10, 10), | |
| 406 | + new XColor("grey40", 102, 102, 102), | |
| 407 | + new XColor("grey41", 105, 105, 105), | |
| 408 | + new XColor("grey42", 107, 107, 107), | |
| 409 | + new XColor("grey43", 110, 110, 110), | |
| 410 | + new XColor("grey44", 112, 112, 112), | |
| 411 | + new XColor("grey45", 115, 115, 115), | |
| 412 | + new XColor("grey46", 117, 117, 117), | |
| 413 | + new XColor("grey47", 120, 120, 120), | |
| 414 | + new XColor("grey48", 122, 122, 122), | |
| 415 | + new XColor("grey49", 125, 125, 125), | |
| 416 | + new XColor("grey5", 13, 13, 13), | |
| 417 | + new XColor("grey50", 127, 127, 127), | |
| 418 | + new XColor("grey51", 130, 130, 130), | |
| 419 | + new XColor("grey52", 133, 133, 133), | |
| 420 | + new XColor("grey53", 135, 135, 135), | |
| 421 | + new XColor("grey54", 138, 138, 138), | |
| 422 | + new XColor("grey55", 140, 140, 140), | |
| 423 | + new XColor("grey56", 143, 143, 143), | |
| 424 | + new XColor("grey57", 145, 145, 145), | |
| 425 | + new XColor("grey58", 148, 148, 148), | |
| 426 | + new XColor("grey59", 150, 150, 150), | |
| 427 | + new XColor("grey6", 15, 15, 15), | |
| 428 | + new XColor("grey60", 153, 153, 153), | |
| 429 | + new XColor("grey61", 156, 156, 156), | |
| 430 | + new XColor("grey62", 158, 158, 158), | |
| 431 | + new XColor("grey63", 161, 161, 161), | |
| 432 | + new XColor("grey64", 163, 163, 163), | |
| 433 | + new XColor("grey65", 166, 166, 166), | |
| 434 | + new XColor("grey66", 168, 168, 168), | |
| 435 | + new XColor("grey67", 171, 171, 171), | |
| 436 | + new XColor("grey68", 173, 173, 173), | |
| 437 | + new XColor("grey69", 176, 176, 176), | |
| 438 | + new XColor("grey7", 18, 18, 18), | |
| 439 | + new XColor("grey70", 179, 179, 179), | |
| 440 | + new XColor("grey71", 181, 181, 181), | |
| 441 | + new XColor("grey72", 184, 184, 184), | |
| 442 | + new XColor("grey73", 186, 186, 186), | |
| 443 | + new XColor("grey74", 189, 189, 189), | |
| 444 | + new XColor("grey75", 191, 191, 191), | |
| 445 | + new XColor("grey76", 194, 194, 194), | |
| 446 | + new XColor("grey77", 196, 196, 196), | |
| 447 | + new XColor("grey78", 199, 199, 199), | |
| 448 | + new XColor("grey79", 201, 201, 201), | |
| 449 | + new XColor("grey8", 20, 20, 20), | |
| 450 | + new XColor("grey80", 204, 204, 204), | |
| 451 | + new XColor("grey81", 207, 207, 207), | |
| 452 | + new XColor("grey82", 209, 209, 209), | |
| 453 | + new XColor("grey83", 212, 212, 212), | |
| 454 | + new XColor("grey84", 214, 214, 214), | |
| 455 | + new XColor("grey85", 217, 217, 217), | |
| 456 | + new XColor("grey86", 219, 219, 219), | |
| 457 | + new XColor("grey87", 222, 222, 222), | |
| 458 | + new XColor("grey88", 224, 224, 224), | |
| 459 | + new XColor("grey89", 227, 227, 227), | |
| 460 | + new XColor("grey9", 23, 23, 23), | |
| 461 | + new XColor("grey90", 229, 229, 229), | |
| 462 | + new XColor("grey91", 232, 232, 232), | |
| 463 | + new XColor("grey92", 235, 235, 235), | |
| 464 | + new XColor("grey93", 237, 237, 237), | |
| 465 | + new XColor("grey94", 240, 240, 240), | |
| 466 | + new XColor("grey95", 242, 242, 242), | |
| 467 | + new XColor("grey96", 245, 245, 245), | |
| 468 | + new XColor("grey97", 247, 247, 247), | |
| 469 | + new XColor("grey98", 250, 250, 250), | |
| 470 | + new XColor("grey99", 252, 252, 252), | |
| 471 | + new XColor("honeydew", 240, 255, 240), | |
| 472 | + new XColor("honeydew1", 240, 255, 240), | |
| 473 | + new XColor("honeydew2", 224, 238, 224), | |
| 474 | + new XColor("honeydew3", 193, 205, 193), | |
| 475 | + new XColor("honeydew4", 131, 139, 131), | |
| 476 | + new XColor("hot pink", 255, 105, 180), | |
| 477 | + new XColor("hotpink", 255, 105, 180), | |
| 478 | + new XColor("hotpink1", 255, 110, 180), | |
| 479 | + new XColor("hotpink2", 238, 106, 167), | |
| 480 | + new XColor("hotpink3", 205, 96, 144), | |
| 481 | + new XColor("hotpink4", 139, 58, 98), | |
| 482 | + new XColor("indian red", 205, 92, 92), | |
| 483 | + new XColor("indianred", 205, 92, 92), | |
| 484 | + new XColor("indianred1", 255, 106, 106), | |
| 485 | + new XColor("indianred2", 238, 99, 99), | |
| 486 | + new XColor("indianred3", 205, 85, 85), | |
| 487 | + new XColor("indianred4", 139, 58, 58), | |
| 488 | + new XColor("ivory", 255, 255, 240), | |
| 489 | + new XColor("ivory1", 255, 255, 240), | |
| 490 | + new XColor("ivory2", 238, 238, 224), | |
| 491 | + new XColor("ivory3", 205, 205, 193), | |
| 492 | + new XColor("ivory4", 139, 139, 131), | |
| 493 | + new XColor("khaki", 240, 230, 140), | |
| 494 | + new XColor("khaki1", 255, 246, 143), | |
| 495 | + new XColor("khaki2", 238, 230, 133), | |
| 496 | + new XColor("khaki3", 205, 198, 115), | |
| 497 | + new XColor("khaki4", 139, 134, 78), | |
| 498 | + new XColor("lavender", 230, 230, 250), | |
| 499 | + new XColor("lavender blush", 255, 240, 245), | |
| 500 | + new XColor("lavenderblush", 255, 240, 245), | |
| 501 | + new XColor("lavenderblush1", 255, 240, 245), | |
| 502 | + new XColor("lavenderblush2", 238, 224, 229), | |
| 503 | + new XColor("lavenderblush3", 205, 193, 197), | |
| 504 | + new XColor("lavenderblush4", 139, 131, 134), | |
| 505 | + new XColor("lawn green", 124, 252, 0), | |
| 506 | + new XColor("lawngreen", 124, 252, 0), | |
| 507 | + new XColor("lemon chiffon", 255, 250, 205), | |
| 508 | + new XColor("lemonchiffon", 255, 250, 205), | |
| 509 | + new XColor("lemonchiffon1", 255, 250, 205), | |
| 510 | + new XColor("lemonchiffon2", 238, 233, 191), | |
| 511 | + new XColor("lemonchiffon3", 205, 201, 165), | |
| 512 | + new XColor("lemonchiffon4", 139, 137, 112), | |
| 513 | + new XColor("light blue", 173, 216, 230), | |
| 514 | + new XColor("light coral", 240, 128, 128), | |
| 515 | + new XColor("light cyan", 224, 255, 255), | |
| 516 | + new XColor("light goldenrod", 238, 221, 130), | |
| 517 | + new XColor("light goldenrod yellow", 250, 250, 210), | |
| 518 | + new XColor("light gray", 211, 211, 211), | |
| 519 | + new XColor("light green", 144, 238, 144), | |
| 520 | + new XColor("light grey", 211, 211, 211), | |
| 521 | + new XColor("light pink", 255, 182, 193), | |
| 522 | + new XColor("light salmon", 255, 160, 122), | |
| 523 | + new XColor("light sea green", 32, 178, 170), | |
| 524 | + new XColor("light sky blue", 135, 206, 250), | |
| 525 | + new XColor("light slate blue", 132, 112, 255), | |
| 526 | + new XColor("light slate gray", 119, 136, 153), | |
| 527 | + new XColor("light slate grey", 119, 136, 153), | |
| 528 | + new XColor("light steel blue", 176, 196, 222), | |
| 529 | + new XColor("light yellow", 255, 255, 224), | |
| 530 | + new XColor("lightblue", 173, 216, 230), | |
| 531 | + new XColor("lightblue1", 191, 239, 255), | |
| 532 | + new XColor("lightblue2", 178, 223, 238), | |
| 533 | + new XColor("lightblue3", 154, 192, 205), | |
| 534 | + new XColor("lightblue4", 104, 131, 139), | |
| 535 | + new XColor("lightcoral", 240, 128, 128), | |
| 536 | + new XColor("lightcyan", 224, 255, 255), | |
| 537 | + new XColor("lightcyan1", 224, 255, 255), | |
| 538 | + new XColor("lightcyan2", 209, 238, 238), | |
| 539 | + new XColor("lightcyan3", 180, 205, 205), | |
| 540 | + new XColor("lightcyan4", 122, 139, 139), | |
| 541 | + new XColor("lightgoldenrod", 238, 221, 130), | |
| 542 | + new XColor("lightgoldenrod1", 255, 236, 139), | |
| 543 | + new XColor("lightgoldenrod2", 238, 220, 130), | |
| 544 | + new XColor("lightgoldenrod3", 205, 190, 112), | |
| 545 | + new XColor("lightgoldenrod4", 139, 129, 76), | |
| 546 | + new XColor("lightgoldenrodyellow", 250, 250, 210), | |
| 547 | + new XColor("lightgray", 211, 211, 211), | |
| 548 | + new XColor("lightgreen", 144, 238, 144), | |
| 549 | + new XColor("lightgrey", 211, 211, 211), | |
| 550 | + new XColor("lightpink", 255, 182, 193), | |
| 551 | + new XColor("lightpink1", 255, 174, 185), | |
| 552 | + new XColor("lightpink2", 238, 162, 173), | |
| 553 | + new XColor("lightpink3", 205, 140, 149), | |
| 554 | + new XColor("lightpink4", 139, 95, 101), | |
| 555 | + new XColor("lightsalmon", 255, 160, 122), | |
| 556 | + new XColor("lightsalmon1", 255, 160, 122), | |
| 557 | + new XColor("lightsalmon2", 238, 149, 114), | |
| 558 | + new XColor("lightsalmon3", 205, 129, 98), | |
| 559 | + new XColor("lightsalmon4", 139, 87, 66), | |
| 560 | + new XColor("lightseagreen", 32, 178, 170), | |
| 561 | + new XColor("lightskyblue", 135, 206, 250), | |
| 562 | + new XColor("lightskyblue1", 176, 226, 255), | |
| 563 | + new XColor("lightskyblue2", 164, 211, 238), | |
| 564 | + new XColor("lightskyblue3", 141, 182, 205), | |
| 565 | + new XColor("lightskyblue4", 96, 123, 139), | |
| 566 | + new XColor("lightslateblue", 132, 112, 255), | |
| 567 | + new XColor("lightslategray", 119, 136, 153), | |
| 568 | + new XColor("lightslategrey", 119, 136, 153), | |
| 569 | + new XColor("lightsteelblue", 176, 196, 222), | |
| 570 | + new XColor("lightsteelblue1", 202, 225, 255), | |
| 571 | + new XColor("lightsteelblue2", 188, 210, 238), | |
| 572 | + new XColor("lightsteelblue3", 162, 181, 205), | |
| 573 | + new XColor("lightsteelblue4", 110, 123, 139), | |
| 574 | + new XColor("lightyellow", 255, 255, 224), | |
| 575 | + new XColor("lightyellow1", 255, 255, 224), | |
| 576 | + new XColor("lightyellow2", 238, 238, 209), | |
| 577 | + new XColor("lightyellow3", 205, 205, 180), | |
| 578 | + new XColor("lightyellow4", 139, 139, 122), | |
| 579 | + new XColor("lime green", 50, 205, 50), | |
| 580 | + new XColor("limegreen", 50, 205, 50), | |
| 581 | + new XColor("linen", 250, 240, 230), | |
| 582 | + new XColor("magenta", 255, 0, 255), | |
| 583 | + new XColor("magenta1", 255, 0, 255), | |
| 584 | + new XColor("magenta2", 238, 0, 238), | |
| 585 | + new XColor("magenta3", 205, 0, 205), | |
| 586 | + new XColor("magenta4", 139, 0, 139), | |
| 587 | + new XColor("maroon", 176, 48, 96), | |
| 588 | + new XColor("maroon1", 255, 52, 179), | |
| 589 | + new XColor("maroon2", 238, 48, 167), | |
| 590 | + new XColor("maroon3", 205, 41, 144), | |
| 591 | + new XColor("maroon4", 139, 28, 98), | |
| 592 | + new XColor("medium aquamarine", 102, 205, 170), | |
| 593 | + new XColor("medium blue", 0, 0, 205), | |
| 594 | + new XColor("medium orchid", 186, 85, 211), | |
| 595 | + new XColor("medium purple", 147, 112, 219), | |
| 596 | + new XColor("medium sea green", 60, 179, 113), | |
| 597 | + new XColor("medium slate blue", 123, 104, 238), | |
| 598 | + new XColor("medium spring green", 0, 250, 154), | |
| 599 | + new XColor("medium turquoise", 72, 209, 204), | |
| 600 | + new XColor("medium violet red", 199, 21, 133), | |
| 601 | + new XColor("mediumaquamarine", 102, 205, 170), | |
| 602 | + new XColor("mediumblue", 0, 0, 205), | |
| 603 | + new XColor("mediumorchid", 186, 85, 211), | |
| 604 | + new XColor("mediumorchid1", 224, 102, 255), | |
| 605 | + new XColor("mediumorchid2", 209, 95, 238), | |
| 606 | + new XColor("mediumorchid3", 180, 82, 205), | |
| 607 | + new XColor("mediumorchid4", 122, 55, 139), | |
| 608 | + new XColor("mediumpurple", 147, 112, 219), | |
| 609 | + new XColor("mediumpurple1", 171, 130, 255), | |
| 610 | + new XColor("mediumpurple2", 159, 121, 238), | |
| 611 | + new XColor("mediumpurple3", 137, 104, 205), | |
| 612 | + new XColor("mediumpurple4", 93, 71, 139), | |
| 613 | + new XColor("mediumseagreen", 60, 179, 113), | |
| 614 | + new XColor("mediumslateblue", 123, 104, 238), | |
| 615 | + new XColor("mediumspringgreen", 0, 250, 154), | |
| 616 | + new XColor("mediumturquoise", 72, 209, 204), | |
| 617 | + new XColor("mediumvioletred", 199, 21, 133), | |
| 618 | + new XColor("midnight blue", 25, 25, 112), | |
| 619 | + new XColor("midnightblue", 25, 25, 112), | |
| 620 | + new XColor("mint cream", 245, 255, 250), | |
| 621 | + new XColor("mintcream", 245, 255, 250), | |
| 622 | + new XColor("misty rose", 255, 228, 225), | |
| 623 | + new XColor("mistyrose", 255, 228, 225), | |
| 624 | + new XColor("mistyrose1", 255, 228, 225), | |
| 625 | + new XColor("mistyrose2", 238, 213, 210), | |
| 626 | + new XColor("mistyrose3", 205, 183, 181), | |
| 627 | + new XColor("mistyrose4", 139, 125, 123), | |
| 628 | + new XColor("moccasin", 255, 228, 181), | |
| 629 | + new XColor("navajo white", 255, 222, 173), | |
| 630 | + new XColor("navajowhite", 255, 222, 173), | |
| 631 | + new XColor("navajowhite1", 255, 222, 173), | |
| 632 | + new XColor("navajowhite2", 238, 207, 161), | |
| 633 | + new XColor("navajowhite3", 205, 179, 139), | |
| 634 | + new XColor("navajowhite4", 139, 121, 94), | |
| 635 | + new XColor("navy", 0, 0, 128), | |
| 636 | + new XColor("navy blue", 0, 0, 128), | |
| 637 | + new XColor("navyblue", 0, 0, 128), | |
| 638 | + new XColor("old lace", 253, 245, 230), | |
| 639 | + new XColor("oldlace", 253, 245, 230), | |
| 640 | + new XColor("olive drab", 107, 142, 35), | |
| 641 | + new XColor("olivedrab", 107, 142, 35), | |
| 642 | + new XColor("olivedrab1", 192, 255, 62), | |
| 643 | + new XColor("olivedrab2", 179, 238, 58), | |
| 644 | + new XColor("olivedrab3", 154, 205, 50), | |
| 645 | + new XColor("olivedrab4", 105, 139, 34), | |
| 646 | + new XColor("orange", 255, 165, 0), | |
| 647 | + new XColor("orange red", 255, 69, 0), | |
| 648 | + new XColor("orange1", 255, 165, 0), | |
| 649 | + new XColor("orange2", 238, 154, 0), | |
| 650 | + new XColor("orange3", 205, 133, 0), | |
| 651 | + new XColor("orange4", 139, 90, 0), | |
| 652 | + new XColor("orangered", 255, 69, 0), | |
| 653 | + new XColor("orangered1", 255, 69, 0), | |
| 654 | + new XColor("orangered2", 238, 64, 0), | |
| 655 | + new XColor("orangered3", 205, 55, 0), | |
| 656 | + new XColor("orangered4", 139, 37, 0), | |
| 657 | + new XColor("orchid", 218, 112, 214), | |
| 658 | + new XColor("orchid1", 255, 131, 250), | |
| 659 | + new XColor("orchid2", 238, 122, 233), | |
| 660 | + new XColor("orchid3", 205, 105, 201), | |
| 661 | + new XColor("orchid4", 139, 71, 137), | |
| 662 | + new XColor("pale goldenrod", 238, 232, 170), | |
| 663 | + new XColor("pale green", 152, 251, 152), | |
| 664 | + new XColor("pale turquoise", 175, 238, 238), | |
| 665 | + new XColor("pale violet red", 219, 112, 147), | |
| 666 | + new XColor("palegoldenrod", 238, 232, 170), | |
| 667 | + new XColor("palegreen", 152, 251, 152), | |
| 668 | + new XColor("palegreen1", 154, 255, 154), | |
| 669 | + new XColor("palegreen2", 144, 238, 144), | |
| 670 | + new XColor("palegreen3", 124, 205, 124), | |
| 671 | + new XColor("palegreen4", 84, 139, 84), | |
| 672 | + new XColor("paleturquoise", 175, 238, 238), | |
| 673 | + new XColor("paleturquoise1", 187, 255, 255), | |
| 674 | + new XColor("paleturquoise2", 174, 238, 238), | |
| 675 | + new XColor("paleturquoise3", 150, 205, 205), | |
| 676 | + new XColor("paleturquoise4", 102, 139, 139), | |
| 677 | + new XColor("palevioletred", 219, 112, 147), | |
| 678 | + new XColor("palevioletred1", 255, 130, 171), | |
| 679 | + new XColor("palevioletred2", 238, 121, 159), | |
| 680 | + new XColor("palevioletred3", 205, 104, 137), | |
| 681 | + new XColor("palevioletred4", 139, 71, 93), | |
| 682 | + new XColor("papaya whip", 255, 239, 213), | |
| 683 | + new XColor("papayawhip", 255, 239, 213), | |
| 684 | + new XColor("peach puff", 255, 218, 185), | |
| 685 | + new XColor("peachpuff", 255, 218, 185), | |
| 686 | + new XColor("peachpuff1", 255, 218, 185), | |
| 687 | + new XColor("peachpuff2", 238, 203, 173), | |
| 688 | + new XColor("peachpuff3", 205, 175, 149), | |
| 689 | + new XColor("peachpuff4", 139, 119, 101), | |
| 690 | + new XColor("peru", 205, 133, 63), | |
| 691 | + new XColor("pink", 255, 192, 203), | |
| 692 | + new XColor("pink1", 255, 181, 197), | |
| 693 | + new XColor("pink2", 238, 169, 184), | |
| 694 | + new XColor("pink3", 205, 145, 158), | |
| 695 | + new XColor("pink4", 139, 99, 108), | |
| 696 | + new XColor("plum", 221, 160, 221), | |
| 697 | + new XColor("plum1", 255, 187, 255), | |
| 698 | + new XColor("plum2", 238, 174, 238), | |
| 699 | + new XColor("plum3", 205, 150, 205), | |
| 700 | + new XColor("plum4", 139, 102, 139), | |
| 701 | + new XColor("powder blue", 176, 224, 230), | |
| 702 | + new XColor("powderblue", 176, 224, 230), | |
| 703 | + new XColor("purple", 160, 32, 240), | |
| 704 | + new XColor("purple1", 155, 48, 255), | |
| 705 | + new XColor("purple2", 145, 44, 238), | |
| 706 | + new XColor("purple3", 125, 38, 205), | |
| 707 | + new XColor("purple4", 85, 26, 139), | |
| 708 | + new XColor("red", 255, 0, 0), | |
| 709 | + new XColor("red1", 255, 0, 0), | |
| 710 | + new XColor("red2", 238, 0, 0), | |
| 711 | + new XColor("red3", 205, 0, 0), | |
| 712 | + new XColor("red4", 139, 0, 0), | |
| 713 | + new XColor("rosy brown", 188, 143, 143), | |
| 714 | + new XColor("rosybrown", 188, 143, 143), | |
| 715 | + new XColor("rosybrown1", 255, 193, 193), | |
| 716 | + new XColor("rosybrown2", 238, 180, 180), | |
| 717 | + new XColor("rosybrown3", 205, 155, 155), | |
| 718 | + new XColor("rosybrown4", 139, 105, 105), | |
| 719 | + new XColor("royal blue", 65, 105, 225), | |
| 720 | + new XColor("royalblue", 65, 105, 225), | |
| 721 | + new XColor("royalblue1", 72, 118, 255), | |
| 722 | + new XColor("royalblue2", 67, 110, 238), | |
| 723 | + new XColor("royalblue3", 58, 95, 205), | |
| 724 | + new XColor("royalblue4", 39, 64, 139), | |
| 725 | + new XColor("saddle brown", 139, 69, 19), | |
| 726 | + new XColor("saddlebrown", 139, 69, 19), | |
| 727 | + new XColor("salmon", 250, 128, 114), | |
| 728 | + new XColor("salmon1", 255, 140, 105), | |
| 729 | + new XColor("salmon2", 238, 130, 98), | |
| 730 | + new XColor("salmon3", 205, 112, 84), | |
| 731 | + new XColor("salmon4", 139, 76, 57), | |
| 732 | + new XColor("sandy brown", 244, 164, 96), | |
| 733 | + new XColor("sandybrown", 244, 164, 96), | |
| 734 | + new XColor("sea green", 46, 139, 87), | |
| 735 | + new XColor("seagreen", 46, 139, 87), | |
| 736 | + new XColor("seagreen1", 84, 255, 159), | |
| 737 | + new XColor("seagreen2", 78, 238, 148), | |
| 738 | + new XColor("seagreen3", 67, 205, 128), | |
| 739 | + new XColor("seagreen4", 46, 139, 87), | |
| 740 | + new XColor("seashell", 255, 245, 238), | |
| 741 | + new XColor("seashell1", 255, 245, 238), | |
| 742 | + new XColor("seashell2", 238, 229, 222), | |
| 743 | + new XColor("seashell3", 205, 197, 191), | |
| 744 | + new XColor("seashell4", 139, 134, 130), | |
| 745 | + new XColor("sienna", 160, 82, 45), | |
| 746 | + new XColor("sienna1", 255, 130, 71), | |
| 747 | + new XColor("sienna2", 238, 121, 66), | |
| 748 | + new XColor("sienna3", 205, 104, 57), | |
| 749 | + new XColor("sienna4", 139, 71, 38), | |
| 750 | + new XColor("sky blue", 135, 206, 235), | |
| 751 | + new XColor("skyblue", 135, 206, 235), | |
| 752 | + new XColor("skyblue1", 135, 206, 255), | |
| 753 | + new XColor("skyblue2", 126, 192, 238), | |
| 754 | + new XColor("skyblue3", 108, 166, 205), | |
| 755 | + new XColor("skyblue4", 74, 112, 139), | |
| 756 | + new XColor("slate blue", 106, 90, 205), | |
| 757 | + new XColor("slate gray", 112, 128, 144), | |
| 758 | + new XColor("slate grey", 112, 128, 144), | |
| 759 | + new XColor("slateblue", 106, 90, 205), | |
| 760 | + new XColor("slateblue1", 131, 111, 255), | |
| 761 | + new XColor("slateblue2", 122, 103, 238), | |
| 762 | + new XColor("slateblue3", 105, 89, 205), | |
| 763 | + new XColor("slateblue4", 71, 60, 139), | |
| 764 | + new XColor("slategray", 112, 128, 144), | |
| 765 | + new XColor("slategray1", 198, 226, 255), | |
| 766 | + new XColor("slategray2", 185, 211, 238), | |
| 767 | + new XColor("slategray3", 159, 182, 205), | |
| 768 | + new XColor("slategray4", 108, 123, 139), | |
| 769 | + new XColor("slategrey", 112, 128, 144), | |
| 770 | + new XColor("snow", 255, 250, 250), | |
| 771 | + new XColor("snow1", 255, 250, 250), | |
| 772 | + new XColor("snow2", 238, 233, 233), | |
| 773 | + new XColor("snow3", 205, 201, 201), | |
| 774 | + new XColor("snow4", 139, 137, 137), | |
| 775 | + new XColor("spring green", 0, 255, 127), | |
| 776 | + new XColor("springgreen", 0, 255, 127), | |
| 777 | + new XColor("springgreen1", 0, 255, 127), | |
| 778 | + new XColor("springgreen2", 0, 238, 118), | |
| 779 | + new XColor("springgreen3", 0, 205, 102), | |
| 780 | + new XColor("springgreen4", 0, 139, 69), | |
| 781 | + new XColor("steel blue", 70, 130, 180), | |
| 782 | + new XColor("steelblue", 70, 130, 180), | |
| 783 | + new XColor("steelblue1", 99, 184, 255), | |
| 784 | + new XColor("steelblue2", 92, 172, 238), | |
| 785 | + new XColor("steelblue3", 79, 148, 205), | |
| 786 | + new XColor("steelblue4", 54, 100, 139), | |
| 787 | + new XColor("tan", 210, 180, 140), | |
| 788 | + new XColor("tan1", 255, 165, 79), | |
| 789 | + new XColor("tan2", 238, 154, 73), | |
| 790 | + new XColor("tan3", 205, 133, 63), | |
| 791 | + new XColor("tan4", 139, 90, 43), | |
| 792 | + new XColor("thistle", 216, 191, 216), | |
| 793 | + new XColor("thistle1", 255, 225, 255), | |
| 794 | + new XColor("thistle2", 238, 210, 238), | |
| 795 | + new XColor("thistle3", 205, 181, 205), | |
| 796 | + new XColor("thistle4", 139, 123, 139), | |
| 797 | + new XColor("tomato", 255, 99, 71), | |
| 798 | + new XColor("tomato1", 255, 99, 71), | |
| 799 | + new XColor("tomato2", 238, 92, 66), | |
| 800 | + new XColor("tomato3", 205, 79, 57), | |
| 801 | + new XColor("tomato4", 139, 54, 38), | |
| 802 | + new XColor("turquoise", 64, 224, 208), | |
| 803 | + new XColor("turquoise1", 0, 245, 255), | |
| 804 | + new XColor("turquoise2", 0, 229, 238), | |
| 805 | + new XColor("turquoise3", 0, 197, 205), | |
| 806 | + new XColor("turquoise4", 0, 134, 139), | |
| 807 | + new XColor("violet", 238, 130, 238), | |
| 808 | + new XColor("violet red", 208, 32, 144), | |
| 809 | + new XColor("violetred", 208, 32, 144), | |
| 810 | + new XColor("violetred1", 255, 62, 150), | |
| 811 | + new XColor("violetred2", 238, 58, 140), | |
| 812 | + new XColor("violetred3", 205, 50, 120), | |
| 813 | + new XColor("violetred4", 139, 34, 82), | |
| 814 | + new XColor("wheat", 245, 222, 179), | |
| 815 | + new XColor("wheat1", 255, 231, 186), | |
| 816 | + new XColor("wheat2", 238, 216, 174), | |
| 817 | + new XColor("wheat3", 205, 186, 150), | |
| 818 | + new XColor("wheat4", 139, 126, 102), | |
| 819 | + new XColor("white", 255, 255, 255), | |
| 820 | + new XColor("white smoke", 245, 245, 245), | |
| 821 | + new XColor("whitesmoke", 245, 245, 245), | |
| 822 | + new XColor("yellow", 255, 255, 0), | |
| 823 | + new XColor("yellow green", 154, 205, 50), | |
| 824 | + new XColor("yellow1", 255, 255, 0), | |
| 825 | + new XColor("yellow2", 238, 238, 0), | |
| 826 | + new XColor("yellow3", 205, 205, 0), | |
| 827 | + new XColor("yellow4", 139, 139, 0), | |
| 828 | + new XColor("yellowgreen", 154, 205, 5) | |
| 829 | + }; | |
| 830 | + | |
| 831 | +} | |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,2 @@ | ||
| 1 | +<../../../../../../../../../mkconfig | |
| 2 | + | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +<../../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + icons\ | |
| 5 | + resources\ | |
| 6 | + | |
| 7 | +TARG=\ | |
| 8 | + GTKColorChooserPanel.dis\ | |
| 9 | + GTKColorType.dis\ | |
| 10 | + GTKConstants.dis\ | |
| 11 | + GTKEngine.dis\ | |
| 12 | + GTKFileChooserUI.dis\ | |
| 13 | + GTKGraphicsUtils.dis\ | |
| 14 | + GTKIconFactory.dis\ | |
| 15 | + GTKLookAndFeel.dis\ | |
| 16 | + GTKPainter.dis\ | |
| 17 | + GTKRegion.dis\ | |
| 18 | + GTKStyle.dis\ | |
| 19 | + GTKStyleFactory.dis\ | |
| 20 | + Metacity.dis\ | |
| 21 | + PangoFonts.dis\ | |
| 22 | + XColors.dis\ | |
| 23 | + | |
| 24 | +DISBIN=$ROOT/java/dis/java/java/com/sun/java/swing/plaf/gtk | |
| 25 | + | |
| 26 | +<$ROOT/mkfiles/mkjava | |
| 27 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,83 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK Color Chooser | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Hue: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=72 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Red: | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=Saturation: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Green: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Value: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Blue: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Color Name: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=All Files | |
| 49 | +FileChooser.newFolderButtonText=New Folder | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Folder name: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Error | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Error creating directory "{0}": No such file or directory | |
| 54 | +FileChooser.deleteFileButtonText=Delete File | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=Rename File | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Cancel | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Save | |
| 65 | +FileChooser.openDialogTitleText=Open | |
| 66 | +FileChooser.pathLabelText=Selection: | |
| 67 | +FileChooser.filterLabelText=Filter: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=Folders | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=Files | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Abort file chooser dialog. | |
| 75 | +FileChooser.saveButtonToolTipText=Save selected file. | |
| 76 | +FileChooser.openButtonToolTipText=Open selected file. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Rename file "{0}" to | |
| 79 | +FileChooser.renameFileErrorTitle=Error | |
| 80 | +FileChooser.renameFileErrorText=Error renaming file "{0}" to "{1}" | |
| 81 | + | |
| 82 | +OptionPane.okButtonMnemonic=79 | |
| 83 | +OptionPane.cancelButtonMnemonic=67 | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK-Farbauswahl | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Farbton: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=70 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Rot: | |
| 27 | +GTKColorChooserPanel.redMnemonic=82 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=S\u00E4ttigung: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Gr\u00FCn: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Wert: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=87 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Blau: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Farbname: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Alle Dateien | |
| 49 | +FileChooser.newFolderButtonText=Neuer Ordner | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Ordnername: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Fehler | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Fehler beim Erstellen von Verzeichnis "{0}": Datei oder Verzeichnis nicht vorhanden | |
| 54 | +FileChooser.deleteFileButtonText=Datei l\u00F6schen | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=Datei umbenennen | |
| 57 | +FileChooser.renameFileButtonMnemonic=85 | |
| 58 | +FileChooser.cancelButtonText=Abbrechen | |
| 59 | +FileChooser.cancelButtonMnemonic=65 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Speichern | |
| 65 | +FileChooser.openDialogTitleText=\u00D6ffnen | |
| 66 | +FileChooser.pathLabelText=Auswahl: | |
| 67 | +FileChooser.filterLabelText=Filter: | |
| 68 | +FileChooser.pathLabelMnemonic=87 | |
| 69 | +FileChooser.foldersLabelText=Ordner | |
| 70 | +FileChooser.foldersLabelMnemonic=79 | |
| 71 | +FileChooser.filesLabelText=Dateien | |
| 72 | +FileChooser.filesLabelMnemonic=68 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Dialogfeld f\u00FCr Dateiauswahl schlie\u00DFen. | |
| 75 | +FileChooser.saveButtonToolTipText=Ausgew\u00E4hlte Datei speichern. | |
| 76 | +FileChooser.openButtonToolTipText=Ausgew\u00E4hlte Datei \u00F6ffnen. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Datei "{0}" umbenennen in | |
| 79 | +FileChooser.renameFileErrorTitle=Fehler | |
| 80 | +FileChooser.renameFileErrorText=Fehler beim Umbenennen der Datei "{0}" in "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=OK | |
| 84 | +OptionPane.okButtonMnemonic=79 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Abbrechen | |
| 87 | +OptionPane.cancelButtonMnemonic=65 | |
| 88 | + | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=Selector de Color para GTK | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Mat: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=77 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Rojo: | |
| 27 | +GTKColorChooserPanel.redMnemonic=74 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=Saturaci\u00F3n: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Verde: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=69 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Valor: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Azul: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=65 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Nombre del Color: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Todos los Archivos | |
| 49 | +FileChooser.newFolderButtonText=Nueva Carpeta | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Nombre de la Carpeta: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Error | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Error al crear el directorio "{0}": no existe dicho archivo o directorio | |
| 54 | +FileChooser.deleteFileButtonText=Suprimir Archivo | |
| 55 | +FileChooser.deleteFileButtonMnemonic=80 | |
| 56 | +FileChooser.renameFileButtonText=Cambiar Nombre de Archivo | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Cancelar | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=Aceptar | |
| 61 | +FileChooser.saveButtonMnemonic=65 | |
| 62 | +FileChooser.openButtonText=Aceptar | |
| 63 | +FileChooser.openButtonMnemonic=65 | |
| 64 | +FileChooser.saveDialogTitleText=Guardar | |
| 65 | +FileChooser.openDialogTitleText=Abrir | |
| 66 | +FileChooser.pathLabelText=Selecci\u00F3n: | |
| 67 | +FileChooser.filterLabelText=Filtro: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=Carpetas | |
| 70 | +FileChooser.foldersLabelMnemonic=84 | |
| 71 | +FileChooser.filesLabelText=Archivos | |
| 72 | +FileChooser.filesLabelMnemonic=65 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Abortar cuadro de di\u00E1logo del selector de archivos. | |
| 75 | +FileChooser.saveButtonToolTipText=Guardar el archivo seleccionado. | |
| 76 | +FileChooser.openButtonToolTipText=Abrir el archivo seleccionado. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Cambiar el nombre del archivo "{0}" por | |
| 79 | +FileChooser.renameFileErrorTitle=Error | |
| 80 | +FileChooser.renameFileErrorText=Error al cambiar el nombre del archivo "{0}" a "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=Aceptar | |
| 84 | +OptionPane.okButtonMnemonic=65 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Cancelar | |
| 87 | +OptionPane.cancelButtonMnemonic=67 | |
| 88 | + | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=S\u00E9lecteur de couleurs GTK | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Teinte : | |
| 24 | +GTKColorChooserPanel.hueMnemonic=84 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Rouge\u00A0: | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=Saturation : | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Vert : | |
| 33 | +GTKColorChooserPanel.greenMnemonic=69 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Valeur : | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Bleu : | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Nom de couleur : | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Tous les fichiers | |
| 49 | +FileChooser.newFolderButtonText=Nouveau dossier | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Nom du dossier : | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Erreur | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Erreur lors de la cr\u00E9ation du r\u00E9pertoire "{0}" : ce fichier ou r\u00E9pertoire n''existe pas | |
| 54 | +FileChooser.deleteFileButtonText=Supprimer le fichier | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=Renommer le fichier | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Annuler | |
| 59 | +FileChooser.cancelButtonMnemonic=65 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Enregistrer | |
| 65 | +FileChooser.openDialogTitleText=Ouvrir | |
| 66 | +FileChooser.pathLabelText=S\u00E9lection : | |
| 67 | +FileChooser.filterLabelText=Filtre : | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=Dossiers | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=Fichiers | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Ferme la bo\u00EEte de dialogue du s\u00E9lecteur de fichiers. | |
| 75 | +FileChooser.saveButtonToolTipText=Enregistre le fichier s\u00E9lectionn\u00E9. | |
| 76 | +FileChooser.openButtonToolTipText=Ouvre le fichier s\u00E9lectionn\u00E9. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Renomme le fichier "{0}" en | |
| 79 | +FileChooser.renameFileErrorTitle=Erreur | |
| 80 | +FileChooser.renameFileErrorText=Erreur lors du changement de nom du fichier "{0}" en "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=OK | |
| 84 | +OptionPane.okButtonMnemonic=79 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Annuler | |
| 87 | +OptionPane.cancelButtonMnemonic=65 | |
| 88 | + | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=Selezione colore GTK | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Ton.: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=84 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Rosso: | |
| 27 | +GTKColorChooserPanel.redMnemonic=79 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=Saturazione: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Verde: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=69 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Valore: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Blu: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Nome colore: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Tutti i file | |
| 49 | +FileChooser.newFolderButtonText=Nuova cartella | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Nome della cartella: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Errore | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Errore durante la creazione della directory "{0}": file o directory inesistente | |
| 54 | +FileChooser.deleteFileButtonText=Elimina file | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=Rinomina file | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Annulla | |
| 59 | +FileChooser.cancelButtonMnemonic=65 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Salva | |
| 65 | +FileChooser.openDialogTitleText=Apri | |
| 66 | +FileChooser.pathLabelText=Selezione: | |
| 67 | +FileChooser.filterLabelText=Filtro: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=Cartelle | |
| 70 | +FileChooser.foldersLabelMnemonic=84 | |
| 71 | +FileChooser.filesLabelText=File | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Chiude la finestra di dialogo di selezione file. | |
| 75 | +FileChooser.saveButtonToolTipText=Salva il file selezionato. | |
| 76 | +FileChooser.openButtonToolTipText=Apre il file selezionato. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Rinomina file "{0}" in | |
| 79 | +FileChooser.renameFileErrorTitle=Errore | |
| 80 | +FileChooser.renameFileErrorText=Errore durante la ridenominazione del file "{0}" in "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=OK | |
| 84 | +OptionPane.okButtonMnemonic=79 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Annulla | |
| 87 | +OptionPane.cancelButtonMnemonic=65 | |
| 88 | + | |
| @@ -0,0 +1,84 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK\u30AB\u30E9\u30FC\u30FB\u30C1\u30E5\u30FC\u30B6(G) | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=\u8272\u76F8(H): | |
| 24 | +GTKColorChooserPanel.hueMnemonic=72 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=\u8D64(E): | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=\u5F69\u5EA6(S): | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=\u7DD1(G): | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=\u5024(V): | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=\u9752(B): | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=\u8272\u540D(N): | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB | |
| 49 | +FileChooser.newFolderButtonText=\u65B0\u898F\u30D5\u30A9\u30EB\u30C0(N) | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=\u30D5\u30A9\u30EB\u30C0\u540D: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=\u30A8\u30E9\u30FC | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA"{0}"\u306E\u4F5C\u6210\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: \u3053\u306E\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\u5B58\u5728\u3057\u307E\u305B\u3093 | |
| 54 | +FileChooser.deleteFileButtonText=\u30D5\u30A1\u30A4\u30EB\u306E\u524A\u9664(L) | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u5909\u66F4(R) | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=\u53D6\u6D88 | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=\u4FDD\u5B58 | |
| 65 | +FileChooser.openDialogTitleText=\u958B\u304F | |
| 66 | +FileChooser.pathLabelText=\u9078\u629E(S): | |
| 67 | +FileChooser.filterLabelText=\u30D5\u30A3\u30EB\u30BF: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=\u30D5\u30A9\u30EB\u30C0(D) | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=\u30D5\u30A1\u30A4\u30EB(F) | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=\u30D5\u30A1\u30A4\u30EB\u30FB\u30C1\u30E5\u30FC\u30B6\u30FB\u30C0\u30A4\u30A2\u30ED\u30B0\u3092\u7D42\u4E86\u3057\u307E\u3059\u3002 | |
| 75 | +FileChooser.saveButtonToolTipText=\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u4FDD\u5B58\u3057\u307E\u3059\u3002 | |
| 76 | +FileChooser.openButtonToolTipText=\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304D\u307E\u3059\u3002 | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=\u30D5\u30A1\u30A4\u30EB"{0}"\u3092\u6B21\u306E\u540D\u524D\u306B\u5909\u66F4: | |
| 79 | +FileChooser.renameFileErrorTitle=\u30A8\u30E9\u30FC | |
| 80 | +FileChooser.renameFileErrorText=\u30D5\u30A1\u30A4\u30EB"{0}"\u306E"{1}"\u3078\u306E\u5909\u66F4\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F | |
| 81 | + | |
| 82 | +#OptionPane.okButtonMnemonic=79 | |
| 83 | +#OptionPane.cancelButtonMnemonic=67 | |
| 84 | + | |
| @@ -0,0 +1,84 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK \uC0C9\uC0C1 \uC120\uD0DD\uAE30(G) | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=\uC0C9\uC870(H): | |
| 24 | +GTKColorChooserPanel.hueMnemonic=72 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=\uBE68\uAC04\uC0C9(E): | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=\uCC44\uB3C4(S): | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=\uB179\uC0C9(G): | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=\uAC12(V): | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=\uD30C\uB780\uC0C9(B): | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=\uC0C9\uC0C1 \uC774\uB984(N): | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=\uBAA8\uB4E0 \uD30C\uC77C | |
| 49 | +FileChooser.newFolderButtonText=\uC0C8 \uD3F4\uB354(N) | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=\uD3F4\uB354 \uC774\uB984: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=\uC624\uB958 | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText="{0}" \uB514\uB809\uD1A0\uB9AC\uB97C \uC0DD\uC131\uD558\uB294 \uC911 \uC624\uB958 \uBC1C\uC0DD: \uD574\uB2F9 \uD30C\uC77C \uB610\uB294 \uB514\uB809\uD1A0\uB9AC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. | |
| 54 | +FileChooser.deleteFileButtonText=\uD30C\uC77C \uC0AD\uC81C(L) | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=\uD30C\uC77C \uC774\uB984 \uBC14\uAFB8\uAE30(R) | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=\uCDE8\uC18C | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=\uD655\uC778 | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=\uD655\uC778 | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=\uC800\uC7A5 | |
| 65 | +FileChooser.openDialogTitleText=\uC5F4\uAE30 | |
| 66 | +FileChooser.pathLabelText=\uC120\uD0DD \uC0AC\uD56D(S): | |
| 67 | +FileChooser.filterLabelText=\uD544\uD130: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=\uD3F4\uB354(D) | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=\uD30C\uC77C(F) | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=\uD30C\uC77C \uC120\uD0DD\uAE30 \uB300\uD654\uC0C1\uC790\uB97C \uC911\uB2E8\uD569\uB2C8\uB2E4. | |
| 75 | +FileChooser.saveButtonToolTipText=\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC800\uC7A5\uD569\uB2C8\uB2E4. | |
| 76 | +FileChooser.openButtonToolTipText=\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC5FD\uB2C8\uB2E4. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText="{0}" \uD30C\uC77C\uC758 \uC774\uB984 \uBC14\uAFB8\uAE30 | |
| 79 | +FileChooser.renameFileErrorTitle=\uC624\uB958 | |
| 80 | +FileChooser.renameFileErrorText="{0}" \uD30C\uC77C\uC758 \uC774\uB984\uC744 "{1}"(\uC73C)\uB85C \uBC14\uAFB8\uB294 \uC911 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4. | |
| 81 | + | |
| 82 | +#OptionPane.okButtonMnemonic=79 | |
| 83 | +#OptionPane.cancelButtonMnemonic=67 | |
| 84 | + | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=Seletor de Cores do GTK | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Matiz: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=77 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=Vermelho: | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=Satura\u00E7\u00E3o: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Verde: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=68 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=Valor: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Azul: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=65 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=Nome da Cor: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Todos os Arquivos | |
| 49 | +FileChooser.newFolderButtonText=Nova Pasta | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Nome da pasta: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Erro | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Erro ao criar o diret\u00F3rio "{0}": N\u00E3o h\u00E1 arquivo ou diret\u00F3rio | |
| 54 | +FileChooser.deleteFileButtonText=Deletar Arquivo | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=Renomear Arquivo | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Cancelar | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Salvar | |
| 65 | +FileChooser.openDialogTitleText=Abrir | |
| 66 | +FileChooser.pathLabelText=Sele\u00E7\u00E3o: | |
| 67 | +FileChooser.filterLabelText=Filtro: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=Pastas | |
| 70 | +FileChooser.foldersLabelMnemonic=80 | |
| 71 | +FileChooser.filesLabelText=Arquivos | |
| 72 | +FileChooser.filesLabelMnemonic=65 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Abortar caixa de di\u00E1logo do seletor de arquivos. | |
| 75 | +FileChooser.saveButtonToolTipText=Salvar arquivo selecionado. | |
| 76 | +FileChooser.openButtonToolTipText=Abrir arquivo selecionado. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Renomear arquivo "{0}" por | |
| 79 | +FileChooser.renameFileErrorTitle=Erro | |
| 80 | +FileChooser.renameFileErrorText=Erro ao renomear o arquivo "{0}" por "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=OK | |
| 84 | +OptionPane.okButtonMnemonic=79 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Cancelar | |
| 87 | +OptionPane.cancelButtonMnemonic=67 | |
| 88 | + | |
| @@ -0,0 +1,88 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK-f\u00E4rgv\u00E4ljaren | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=Nyans: | |
| 24 | +GTKColorChooserPanel.hueMnemonic=78 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=R\u00F6d: | |
| 27 | +GTKColorChooserPanel.redMnemonic=82 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=M\u00E4ttnad: | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=77 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=Gr\u00F6n: | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=V\u00E4rde: | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=Bl\u00E5: | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=F\u00E4rgnamn: | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=70 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=Alla filer | |
| 49 | +FileChooser.newFolderButtonText=Ny mapp | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=Mapp: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=Fel | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=Ett fel intr\u00E4ffade vid f\u00F6rs\u00F6k att skapa katalogen "{0}": Filen eller katalogen finns inte | |
| 54 | +FileChooser.deleteFileButtonText=Ta bort fil | |
| 55 | +FileChooser.deleteFileButtonMnemonic=66 | |
| 56 | +FileChooser.renameFileButtonText=\u00C4ndra namn p\u00E5 filen | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=Avbryt | |
| 59 | +FileChooser.cancelButtonMnemonic=65 | |
| 60 | +FileChooser.saveButtonText=OK | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=OK | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=Spara | |
| 65 | +FileChooser.openDialogTitleText=\u00D6ppna | |
| 66 | +FileChooser.pathLabelText=Urval: | |
| 67 | +FileChooser.filterLabelText=Filter: | |
| 68 | +FileChooser.pathLabelMnemonic=85 | |
| 69 | +FileChooser.foldersLabelText=Mappar | |
| 70 | +FileChooser.foldersLabelMnemonic=80 | |
| 71 | +FileChooser.filesLabelText=Filer | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=Avbryt dialogrutan Filv\u00E4ljare. | |
| 75 | +FileChooser.saveButtonToolTipText=Spara vald fil. | |
| 76 | +FileChooser.openButtonToolTipText=\u00D6ppna vald fil. | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=Namn\u00E4ndra fil "{0}" till | |
| 79 | +FileChooser.renameFileErrorTitle=Fel | |
| 80 | +FileChooser.renameFileErrorText=Fel vid namn\u00E4ndring av fil "{0}" till "{1}" | |
| 81 | + | |
| 82 | +# dummy resource added for translation automation | |
| 83 | +OptionPane.okButtonText=OK | |
| 84 | +OptionPane.okButtonMnemonic=79 | |
| 85 | +# dummy resource added for translation automation | |
| 86 | +OptionPane.cancelButtonText=Avbryt | |
| 87 | +OptionPane.cancelButtonMnemonic=65 | |
| 88 | + | |
| @@ -0,0 +1,84 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK \u989C\u8272\u9009\u62E9\u5668(G) | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=\u8272\u8C03(H): | |
| 24 | +GTKColorChooserPanel.hueMnemonic=72 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=\u7EA2\u8272(E): | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=\u9971\u548C\u5EA6(S): | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=\u7EFF\u8272(G): | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=\u503C(V): | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=\u84DD\u8272(B): | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=\u989C\u8272\u540D(N): | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=\u6240\u6709\u6587\u4EF6 | |
| 49 | +FileChooser.newFolderButtonText=\u65B0\u6587\u4EF6\u5939(N) | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=\u6587\u4EF6\u5939\u540D: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=\u9519\u8BEF | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=\u521B\u5EFA\u76EE\u5F55 "{0}" \u65F6\u51FA\u9519: \u6CA1\u6709\u6B64\u7C7B\u6587\u4EF6\u6216\u76EE\u5F55 | |
| 54 | +FileChooser.deleteFileButtonText=\u5220\u9664\u6587\u4EF6(L) | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=\u91CD\u547D\u540D\u6587\u4EF6(R) | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=\u53D6\u6D88 | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=\u786E\u5B9A | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=\u786E\u5B9A | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=\u4FDD\u5B58 | |
| 65 | +FileChooser.openDialogTitleText=\u6253\u5F00 | |
| 66 | +FileChooser.pathLabelText=\u9009\u5B9A\u5185\u5BB9(S): | |
| 67 | +FileChooser.filterLabelText=\u7B5B\u9009\u5668: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=\u6587\u4EF6\u5939(D) | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=\u6587\u4EF6(F) | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=\u4E2D\u6B62\u6587\u4EF6\u9009\u62E9\u5668\u5BF9\u8BDD\u6846\u3002 | |
| 75 | +FileChooser.saveButtonToolTipText=\u4FDD\u5B58\u6240\u9009\u6587\u4EF6\u3002 | |
| 76 | +FileChooser.openButtonToolTipText=\u6253\u5F00\u6240\u9009\u6587\u4EF6\u3002 | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=\u5C06\u6587\u4EF6 "{0}" \u91CD\u547D\u540D\u4E3A | |
| 79 | +FileChooser.renameFileErrorTitle=\u9519\u8BEF | |
| 80 | +FileChooser.renameFileErrorText=\u5C06\u6587\u4EF6 "{0}" \u91CD\u547D\u540D\u4E3A "{1}" \u65F6\u51FA\u9519 | |
| 81 | + | |
| 82 | +#OptionPane.okButtonMnemonic=79 | |
| 83 | +#OptionPane.cancelButtonMnemonic=67 | |
| 84 | + | |
| @@ -0,0 +1,84 @@ | ||
| 1 | +# Refer to the note in basic.properties for a description as to what | |
| 2 | +# the mnemonics correspond to and how to calculate them. | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | +# GTK specific properties | |
| 7 | + | |
| 8 | +# GTK color chooser properties: | |
| 9 | +GTKColorChooserPanel.nameText=GTK \u8272\u5F69\u9078\u64C7\u5668(G) | |
| 10 | +# mnemonic as a VK_ constant | |
| 11 | +GTKColorChooserPanel.mnemonic=71 | |
| 12 | +# Can also define GTKColorChooserPanel.dispalyedMnemonicIndex if you | |
| 13 | +# want an index other than would normally be underlined by | |
| 14 | +# GTKColorChooserPanel.mnemonic to be underlined. This is only useful | |
| 15 | +# if GTKColorChooserPanel.nameText defines the mnemonic character more | |
| 16 | +# than once and you want a character other than the first underlined. | |
| 17 | + | |
| 18 | +# Text and mnemonics for the spinner. You can also defined a different | |
| 19 | +# index for the mnemonic via xxxMnemonicIndex, for example | |
| 20 | +# GTKColorChooserPanel.hueMnemonicIndex=1 would indicate the second | |
| 21 | +# character of GTKColorChooserPanel.hueText should be underlined to | |
| 22 | +# represent the mnemonic. | |
| 23 | +GTKColorChooserPanel.hueText=\u8272\u8ABF(H)\uFF1A | |
| 24 | +GTKColorChooserPanel.hueMnemonic=72 | |
| 25 | + | |
| 26 | +GTKColorChooserPanel.redText=\u7D05(E): | |
| 27 | +GTKColorChooserPanel.redMnemonic=69 | |
| 28 | + | |
| 29 | +GTKColorChooserPanel.saturationText=\u5F69\u5EA6(S): | |
| 30 | +GTKColorChooserPanel.saturationMnemonic=83 | |
| 31 | + | |
| 32 | +GTKColorChooserPanel.greenText=\u7DA0(G): | |
| 33 | +GTKColorChooserPanel.greenMnemonic=71 | |
| 34 | + | |
| 35 | +GTKColorChooserPanel.valueText=\u503C(V): | |
| 36 | +GTKColorChooserPanel.valueMnemonic=86 | |
| 37 | + | |
| 38 | +GTKColorChooserPanel.blueText=\u85CD(B): | |
| 39 | +GTKColorChooserPanel.blueMnemonic=66 | |
| 40 | + | |
| 41 | +GTKColorChooserPanel.colorNameText=\u984F\u8272\u540D\u7A31(N): | |
| 42 | +GTKColorChooserPanel.colorNameMnemonic=78 | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | +############ FILE CHOOSER STRINGS ############# | |
| 47 | + | |
| 48 | +FileChooser.acceptAllFileFilterText=\u6240\u6709\u6A94\u6848 | |
| 49 | +FileChooser.newFolderButtonText=\u65B0\u5EFA\u8CC7\u6599\u593E(N) | |
| 50 | +FileChooser.newFolderButtonMnemonic=78 | |
| 51 | +FileChooser.newFolderDialogText=\u8CC7\u6599\u593E\u540D\u7A31: | |
| 52 | +FileChooser.newFolderNoDirectoryErrorTitleText=\u932F\u8AA4 | |
| 53 | +FileChooser.newFolderNoDirectoryErrorText=\u5EFA\u7ACB\u76EE\u9304 "{0}" \u6642\u767C\u751F\u932F\u8AA4: \u6C92\u6709\u6B64\u6A94\u6848\u6216\u76EE\u9304 | |
| 54 | +FileChooser.deleteFileButtonText=\u522A\u9664\u6A94\u6848(L) | |
| 55 | +FileChooser.deleteFileButtonMnemonic=76 | |
| 56 | +FileChooser.renameFileButtonText=\u91CD\u65B0\u547D\u540D\u6A94\u6848(R) | |
| 57 | +FileChooser.renameFileButtonMnemonic=82 | |
| 58 | +FileChooser.cancelButtonText=\u53D6\u6D88 | |
| 59 | +FileChooser.cancelButtonMnemonic=67 | |
| 60 | +FileChooser.saveButtonText=\u78BA\u5B9A | |
| 61 | +FileChooser.saveButtonMnemonic=79 | |
| 62 | +FileChooser.openButtonText=\u78BA\u5B9A | |
| 63 | +FileChooser.openButtonMnemonic=79 | |
| 64 | +FileChooser.saveDialogTitleText=\u5132\u5B58 | |
| 65 | +FileChooser.openDialogTitleText=\u958B\u555F | |
| 66 | +FileChooser.pathLabelText=\u9078\u53D6(S): | |
| 67 | +FileChooser.filterLabelText=\u7BE9\u9078: | |
| 68 | +FileChooser.pathLabelMnemonic=83 | |
| 69 | +FileChooser.foldersLabelText=\u8CC7\u6599\u593E(D) | |
| 70 | +FileChooser.foldersLabelMnemonic=68 | |
| 71 | +FileChooser.filesLabelText=\u6A94\u6848(F) | |
| 72 | +FileChooser.filesLabelMnemonic=70 | |
| 73 | + | |
| 74 | +FileChooser.cancelButtonToolTipText=\u4E2D\u6B62\u6A94\u6848\u9078\u64C7\u5668\u5C0D\u8A71\u65B9\u584A\u3002 | |
| 75 | +FileChooser.saveButtonToolTipText=\u5132\u5B58\u9078\u53D6\u7684\u6A94\u6848\u3002 | |
| 76 | +FileChooser.openButtonToolTipText=\u958B\u555F\u9078\u53D6\u7684\u6A94\u6848\u3002 | |
| 77 | + | |
| 78 | +FileChooser.renameFileDialogText=\u5C07\u6A94\u6848 "{0}" \u91CD\u65B0\u547D\u540D\u70BA | |
| 79 | +FileChooser.renameFileErrorTitle=\u932F\u8AA4 | |
| 80 | +FileChooser.renameFileErrorText=\u5C07\u6A94\u6848 "{0}" \u91CD\u65B0\u547D\u540D\u70BA "{1}" \u6642\u51FA\u73FE\u932F\u8AA4 | |
| 81 | + | |
| 82 | +#OptionPane.okButtonMnemonic=79 | |
| 83 | +#OptionPane.cancelButtonMnemonic=67 | |
| 84 | + | |
| @@ -0,0 +1,178 @@ | ||
| 1 | +<?xml version="1.0"?> | |
| 2 | + | |
| 3 | +<!-- | |
| 4 | + Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. | |
| 5 | + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 6 | + | |
| 7 | + This code is free software; you can redistribute it and/or modify it | |
| 8 | + under the terms of the GNU General Public License version 2 only, as | |
| 9 | + published by the Free Software Foundation. Oracle designates this | |
| 10 | + particular file as subject to the "Classpath" exception as provided | |
| 11 | + by Oracle in the LICENSE file that accompanied this code. | |
| 12 | + | |
| 13 | + This code is distributed in the hope that it will be useful, but WITHOUT | |
| 14 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 | + version 2 for more details (a copy is included in the LICENSE file that | |
| 17 | + accompanied this code). | |
| 18 | + | |
| 19 | + You should have received a copy of the GNU General Public License version | |
| 20 | + 2 along with this work; if not, write to the Free Software Foundation, | |
| 21 | + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 22 | + | |
| 23 | + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 24 | + or visit www.oracle.com if you need additional information or have any | |
| 25 | + questions. | |
| 26 | +--> | |
| 27 | + | |
| 28 | +<metacity_theme> | |
| 29 | + <info> | |
| 30 | + <name>SwingFallbackTheme</name> | |
| 31 | + <author>Leif Samuelsson</author> | |
| 32 | + <copyright>Â Sun Microsystems, Inc, 2003</copyright> | |
| 33 | + <description> | |
| 34 | + A fallback theme for Swing's GTK Look and Feel, in case no other metacity | |
| 35 | + theme can be found. Note: This theme is not intended to work with the | |
| 36 | + Metacity window manager, nor to be used for any purpose other than stated | |
| 37 | + here. | |
| 38 | + </description> | |
| 39 | + </info> | |
| 40 | + | |
| 41 | + <frame_geometry name="normal"> | |
| 42 | + <distance name="left_width" value="5"/> | |
| 43 | + <distance name="right_width" value="6"/> | |
| 44 | + <distance name="bottom_height" value="6"/> | |
| 45 | + <distance name="left_titlebar_edge" value="5"/> | |
| 46 | + <distance name="right_titlebar_edge" value="6"/> | |
| 47 | + <aspect_ratio name="button" value="1.0"/> | |
| 48 | + <distance name="title_vertical_pad" value="0"/> | |
| 49 | + <border name="title_border" left="0" right="0" top="3" bottom="3"/> | |
| 50 | + <border name="button_border" left="0" right="0" top="3" bottom="3"/> | |
| 51 | + </frame_geometry> | |
| 52 | + | |
| 53 | + <draw_ops name="button"> | |
| 54 | + <rectangle color="black" x="0" y="0" width="width-2" height="height-2"/> | |
| 55 | + </draw_ops> | |
| 56 | + | |
| 57 | + <draw_ops name="button_pressed"> | |
| 58 | + <rectangle color="black" x="1" y="1" width="width-2" height="height-2"/> | |
| 59 | + </draw_ops> | |
| 60 | + | |
| 61 | + <frame_style name="normal" geometry="normal"> | |
| 62 | + | |
| 63 | + <piece position="entire_background"> | |
| 64 | + <draw_ops> | |
| 65 | + <rectangle color="black" x="0" y="0" width="width-1" height="height-1"/> | |
| 66 | + <rectangle color="black" x="left_width-1" y="1" width="width-left_width-right_width+1" height="height-bottom_height-1"/> | |
| 67 | + </draw_ops> | |
| 68 | + </piece> | |
| 69 | + | |
| 70 | + <piece position="title"> | |
| 71 | + <draw_ops> | |
| 72 | + <title color="black" x="2" y="0"/> | |
| 73 | + </draw_ops> | |
| 74 | + </piece> | |
| 75 | + | |
| 76 | + <piece position="titlebar"> | |
| 77 | + <draw_ops> | |
| 78 | + <gradient type="diagonal" x="1" y="1" width="width-2" height="height-2"> | |
| 79 | + <color value="shade/gtk:bg[NORMAL]/1.0"/> | |
| 80 | + <color value="shade/gtk:bg[NORMAL]/0.9"/> | |
| 81 | + </gradient> | |
| 82 | + <line color="black" x1="left_width" y1="height-1" x2="width-right_width" y2="height-1"/> | |
| 83 | + </draw_ops> | |
| 84 | + </piece> | |
| 85 | + | |
| 86 | + <button function="close" state="normal"> | |
| 87 | + <draw_ops> | |
| 88 | + <include name="button"/> | |
| 89 | + <line color="black" x1="3" y1="3" x2="width-5" y2="height-5"/> | |
| 90 | + <line color="black" x1="width-5" y1="3" x2="3" y2="height-5"/> | |
| 91 | + </draw_ops> | |
| 92 | + </button> | |
| 93 | + | |
| 94 | + <button function="close" state="pressed"> | |
| 95 | + <draw_ops> | |
| 96 | + <include name="button_pressed"/> | |
| 97 | + <line color="black" x1="4" y1="4" x2="width-4" y2="height-4"/> | |
| 98 | + <line color="black" x1="width-4" y1="4" x2="4" y2="height-4"/> | |
| 99 | + </draw_ops> | |
| 100 | + </button> | |
| 101 | + | |
| 102 | + <button function="minimize" state="normal"> | |
| 103 | + <draw_ops> | |
| 104 | + <include name="button"/> | |
| 105 | + <line color="black" x1="4" y1="height-4" x2="width-5" y2="height-4"/> | |
| 106 | + </draw_ops> | |
| 107 | + </button> | |
| 108 | + | |
| 109 | + <button function="minimize" state="pressed"> | |
| 110 | + <draw_ops> | |
| 111 | + <include name="button_pressed"/> | |
| 112 | + <line color="black" x1="5" y1="height-3" x2="width-4" y2="height-3"/> | |
| 113 | + </draw_ops> | |
| 114 | + </button> | |
| 115 | + | |
| 116 | + <button function="maximize" state="normal"> | |
| 117 | + <draw_ops> | |
| 118 | + <include name="button"/> | |
| 119 | + <rectangle color="black" x="3" y="3" width="width-3-5" height="height-3-5"/> | |
| 120 | + </draw_ops> | |
| 121 | + </button> | |
| 122 | + | |
| 123 | + <button function="maximize" state="pressed"> | |
| 124 | + <draw_ops> | |
| 125 | + <include name="button_pressed"/> | |
| 126 | + <rectangle color="black" x="4" y="4" width="width-3-5" height="height-3-5"/> | |
| 127 | + </draw_ops> | |
| 128 | + </button> | |
| 129 | + | |
| 130 | + <button function="menu" state="normal"> | |
| 131 | + <draw_ops> | |
| 132 | + <include name="button"/> | |
| 133 | + </draw_ops> | |
| 134 | + </button> | |
| 135 | + | |
| 136 | + <button function="menu" state="pressed"> | |
| 137 | + <draw_ops> | |
| 138 | + <include name="button_pressed"/> | |
| 139 | + </draw_ops> | |
| 140 | + </button> | |
| 141 | + </frame_style> | |
| 142 | + | |
| 143 | + | |
| 144 | + <frame_style name="focused" geometry="normal" parent="normal"> | |
| 145 | + | |
| 146 | + <piece position="entire_background"> | |
| 147 | + <draw_ops> | |
| 148 | + <rectangle color="black" x="0" y="0" width="width-1" height="height-1"/> | |
| 149 | + <rectangle color="black" x="left_width-1" y="1" width="width-left_width-right_width+1" height="height-bottom_height-1"/> | |
| 150 | + </draw_ops> | |
| 151 | + </piece> | |
| 152 | + | |
| 153 | + <piece position="title"> | |
| 154 | + <draw_ops> | |
| 155 | + <title color="black" x="2" y="((height - title_height) / 2) `max` 0"/> | |
| 156 | + </draw_ops> | |
| 157 | + </piece> | |
| 158 | + | |
| 159 | + <piece position="titlebar"> | |
| 160 | + <draw_ops> | |
| 161 | + <gradient type="diagonal" x="1" y="1" width="width-2" height="height-2"> | |
| 162 | + <color value="#f0f0f0"/> | |
| 163 | + <color value="shade/gtk:bg[NORMAL]/1.0"/> | |
| 164 | + </gradient> | |
| 165 | + <line color="black" x1="left_width" y1="height-1" x2="width-right_width" y2="height-1"/> | |
| 166 | + </draw_ops> | |
| 167 | + </piece> | |
| 168 | + | |
| 169 | + </frame_style> | |
| 170 | + | |
| 171 | + <frame_style_set name="normal"> | |
| 172 | + <frame focus="yes" state="normal" resize="both" style="focused"/> | |
| 173 | + <frame focus="yes" state="maximized" style="focused"/> | |
| 174 | + <frame focus="no" state="normal" resize="both" style="normal"/> | |
| 175 | + <frame focus="no" state="maximized" style="normal"/> | |
| 176 | + </frame_style_set> | |
| 177 | + | |
| 178 | +</metacity_theme> | |
| @@ -0,0 +1,2 @@ | ||
| 1 | +<../../../../../../../../../../../../mkconfig | |
| 2 | + | |
| @@ -0,0 +1,6 @@ | ||
| 1 | +<../../../../../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + metacity-1\ | |
| 5 | + | |
| 6 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,6 @@ | ||
| 1 | +<../../../../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + SwingFallbackTheme\ | |
| 5 | + | |
| 6 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,6 @@ | ||
| 1 | +<../../../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + metacity\ | |
| 5 | + | |
| 6 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,9 @@ | ||
| 1 | +<../../../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + gtk\ | |
| 5 | + motif\ | |
| 6 | + nimbus\ | |
| 7 | + windows\ | |
| 8 | + | |
| 9 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,734 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import sun.swing.SwingUtilities2; | |
| 29 | +import javax.swing.*; | |
| 30 | +import javax.swing.border.*; | |
| 31 | +import javax.swing.plaf.*; | |
| 32 | + | |
| 33 | +import java.awt.Color; | |
| 34 | +import java.awt.Component; | |
| 35 | +import java.awt.Dimension; | |
| 36 | +import java.awt.Font; | |
| 37 | +import java.awt.FontMetrics; | |
| 38 | +import java.awt.Graphics; | |
| 39 | +import java.awt.Insets; | |
| 40 | +import java.awt.Point; | |
| 41 | +import java.awt.Rectangle; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * Factory object that can vend Icons appropriate for the basic L & F. | |
| 45 | + * <p> | |
| 46 | + * <strong>Warning:</strong> | |
| 47 | + * Serialized objects of this class will not be compatible with | |
| 48 | + * future Swing releases. The current serialization support is appropriate | |
| 49 | + * for short term storage or RMI between applications running the same | |
| 50 | + * version of Swing. A future release of Swing will provide support for | |
| 51 | + * long term persistence. | |
| 52 | + * | |
| 53 | + * @author Amy Fowler | |
| 54 | + */ | |
| 55 | +public class MotifBorders { | |
| 56 | + | |
| 57 | + public static class BevelBorder extends AbstractBorder implements UIResource { | |
| 58 | + private Color darkShadow = UIManager.getColor("controlShadow"); | |
| 59 | + private Color lightShadow = UIManager.getColor("controlLtHighlight"); | |
| 60 | + private boolean isRaised; | |
| 61 | + | |
| 62 | + public BevelBorder(boolean isRaised, Color darkShadow, Color lightShadow) { | |
| 63 | + this.isRaised = isRaised; | |
| 64 | + this.darkShadow = darkShadow; | |
| 65 | + this.lightShadow = lightShadow; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { | |
| 69 | + g.setColor((isRaised) ? lightShadow : darkShadow); | |
| 70 | + g.drawLine(x, y, x+w-1, y); // top | |
| 71 | + g.drawLine(x, y+h-1, x, y+1); // left | |
| 72 | + | |
| 73 | + g.setColor((isRaised) ? darkShadow : lightShadow); | |
| 74 | + g.drawLine(x+1, y+h-1, x+w-1, y+h-1); // bottom | |
| 75 | + g.drawLine(x+w-1, y+h-1, x+w-1, y+1); // right | |
| 76 | + } | |
| 77 | + | |
| 78 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 79 | + insets.set(1, 1, 1, 1); | |
| 80 | + return insets; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public boolean isOpaque(Component c) { | |
| 84 | + return true; | |
| 85 | + } | |
| 86 | + | |
| 87 | + } | |
| 88 | + | |
| 89 | + | |
| 90 | + public static class FocusBorder extends AbstractBorder implements UIResource { | |
| 91 | + private Color focus; | |
| 92 | + private Color control; | |
| 93 | + | |
| 94 | + public FocusBorder(Color control, Color focus) { | |
| 95 | + this.control = control; | |
| 96 | + this.focus = focus; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { | |
| 100 | + if (c.hasFocus()) { | |
| 101 | + g.setColor(focus); | |
| 102 | + g.drawRect(x, y, w-1, h-1); | |
| 103 | + } else { | |
| 104 | + g.setColor(control); | |
| 105 | + g.drawRect(x, y, w-1, h-1); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + | |
| 109 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 110 | + insets.set(1, 1, 1, 1); | |
| 111 | + return insets; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + | |
| 116 | + public static class ButtonBorder extends AbstractBorder implements UIResource { | |
| 117 | + protected Color focus = UIManager.getColor("activeCaptionBorder"); | |
| 118 | + protected Color shadow = UIManager.getColor("Button.shadow"); | |
| 119 | + protected Color highlight = UIManager.getColor("Button.light"); | |
| 120 | + protected Color darkShadow; | |
| 121 | + | |
| 122 | + public ButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) { | |
| 123 | + this.shadow = shadow; | |
| 124 | + this.highlight = highlight; | |
| 125 | + this.darkShadow = darkShadow; | |
| 126 | + this.focus = focus; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { | |
| 130 | + boolean isPressed = false; | |
| 131 | + boolean hasFocus = false; | |
| 132 | + boolean canBeDefault = false; | |
| 133 | + boolean isDefault = false; | |
| 134 | + | |
| 135 | + if (c instanceof AbstractButton) { | |
| 136 | + AbstractButton b = (AbstractButton)c; | |
| 137 | + ButtonModel model = b.getModel(); | |
| 138 | + | |
| 139 | + isPressed = (model.isArmed() && model.isPressed()); | |
| 140 | + hasFocus = (model.isArmed() && isPressed) || | |
| 141 | + (b.isFocusPainted() && b.hasFocus()); | |
| 142 | + if (b instanceof JButton) { | |
| 143 | + canBeDefault = ((JButton)b).isDefaultCapable(); | |
| 144 | + isDefault = ((JButton)b).isDefaultButton(); | |
| 145 | + } | |
| 146 | + } | |
| 147 | + int bx1 = x+1; | |
| 148 | + int by1 = y+1; | |
| 149 | + int bx2 = x+w-2; | |
| 150 | + int by2 = y+h-2; | |
| 151 | + | |
| 152 | + if (canBeDefault) { | |
| 153 | + if (isDefault) { | |
| 154 | + g.setColor(shadow); | |
| 155 | + g.drawLine(x+3, y+3, x+3, y+h-4); | |
| 156 | + g.drawLine(x+3, y+3, x+w-4, y+3); | |
| 157 | + | |
| 158 | + g.setColor(highlight); | |
| 159 | + g.drawLine(x+4, y+h-4, x+w-4, y+h-4); | |
| 160 | + g.drawLine(x+w-4, y+3, x+w-4, y+h-4); | |
| 161 | + } | |
| 162 | + bx1 +=6; | |
| 163 | + by1 += 6; | |
| 164 | + bx2 -= 6; | |
| 165 | + by2 -= 6; | |
| 166 | + } | |
| 167 | + | |
| 168 | + if (hasFocus) { | |
| 169 | + g.setColor(focus); | |
| 170 | + if (isDefault) { | |
| 171 | + g.drawRect(x, y, w-1, h-1); | |
| 172 | + } else { | |
| 173 | + g.drawRect(bx1-1, by1-1, bx2-bx1+2, by2-by1+2); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + g.setColor(isPressed? shadow : highlight); | |
| 178 | + g.drawLine(bx1, by1, bx2, by1); | |
| 179 | + g.drawLine(bx1, by1, bx1, by2); | |
| 180 | + | |
| 181 | + g.setColor(isPressed? highlight : shadow); | |
| 182 | + g.drawLine(bx2, by1+1, bx2, by2); | |
| 183 | + g.drawLine(bx1+1, by2, bx2, by2); | |
| 184 | + } | |
| 185 | + | |
| 186 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 187 | + int thickness = (c instanceof JButton && ((JButton)c).isDefaultCapable())? 8 : 2; | |
| 188 | + insets.set(thickness, thickness, thickness, thickness); | |
| 189 | + return insets; | |
| 190 | + } | |
| 191 | + | |
| 192 | + } | |
| 193 | + | |
| 194 | + public static class ToggleButtonBorder extends ButtonBorder { | |
| 195 | + | |
| 196 | + public ToggleButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) { | |
| 197 | + super(shadow, highlight, darkShadow, focus); | |
| 198 | + } | |
| 199 | + | |
| 200 | + public void paintBorder(Component c, Graphics g, int x, int y, | |
| 201 | + int width, int height) { | |
| 202 | + if (c instanceof AbstractButton) { | |
| 203 | + AbstractButton b = (AbstractButton)c; | |
| 204 | + ButtonModel model = b.getModel(); | |
| 205 | + | |
| 206 | + if (model.isArmed() && model.isPressed() || model.isSelected()) { | |
| 207 | + drawBezel(g, x, y, width, height, | |
| 208 | + (model.isPressed() || model.isSelected()), | |
| 209 | + b.isFocusPainted() && b.hasFocus(), shadow, highlight, darkShadow, focus); | |
| 210 | + } else { | |
| 211 | + drawBezel(g, x, y, width, height, | |
| 212 | + false, b.isFocusPainted() && b.hasFocus(), | |
| 213 | + shadow, highlight, darkShadow, focus); | |
| 214 | + } | |
| 215 | + } else { | |
| 216 | + drawBezel(g, x, y, width, height, false, false, | |
| 217 | + shadow, highlight, darkShadow, focus); | |
| 218 | + } | |
| 219 | + } | |
| 220 | + | |
| 221 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 222 | + insets.set(2, 2, 3, 3); | |
| 223 | + return insets; | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + public static class MenuBarBorder extends ButtonBorder { | |
| 228 | + | |
| 229 | + public MenuBarBorder(Color shadow, Color highlight, Color darkShadow, Color focus) { | |
| 230 | + super(shadow, highlight, darkShadow, focus); | |
| 231 | + } | |
| 232 | + | |
| 233 | + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { | |
| 234 | + if (!(c instanceof JMenuBar)) { | |
| 235 | + return; | |
| 236 | + } | |
| 237 | + JMenuBar menuBar = (JMenuBar)c; | |
| 238 | + if (menuBar.isBorderPainted() == true) { | |
| 239 | + // this draws the MenuBar border | |
| 240 | + Dimension size = menuBar.getSize(); | |
| 241 | + drawBezel(g,x,y,size.width,size.height,false,false, | |
| 242 | + shadow, highlight, darkShadow, focus); | |
| 243 | + } | |
| 244 | + } | |
| 245 | + | |
| 246 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 247 | + insets.set(6, 6, 6, 6); | |
| 248 | + return insets; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + | |
| 252 | + public static class FrameBorder extends AbstractBorder implements UIResource { | |
| 253 | + | |
| 254 | + JComponent jcomp; | |
| 255 | + Color frameHighlight; | |
| 256 | + Color frameColor; | |
| 257 | + Color frameShadow; | |
| 258 | + | |
| 259 | + // The width of the border | |
| 260 | + public final static int BORDER_SIZE = 5; | |
| 261 | + | |
| 262 | + /** Constructs an FrameBorder for the JComponent <b>comp</b>. | |
| 263 | + */ | |
| 264 | + public FrameBorder(JComponent comp) { | |
| 265 | + jcomp = comp; | |
| 266 | + } | |
| 267 | + | |
| 268 | + /** Sets the FrameBorder's JComponent. | |
| 269 | + */ | |
| 270 | + public void setComponent(JComponent comp) { | |
| 271 | + jcomp = comp; | |
| 272 | + } | |
| 273 | + | |
| 274 | + /** Returns the FrameBorder's JComponent. | |
| 275 | + * @see #setComponent | |
| 276 | + */ | |
| 277 | + public JComponent component() { | |
| 278 | + return jcomp; | |
| 279 | + } | |
| 280 | + | |
| 281 | + protected Color getFrameHighlight() { | |
| 282 | + return frameHighlight; | |
| 283 | + } | |
| 284 | + | |
| 285 | + protected Color getFrameColor() { | |
| 286 | + return frameColor; | |
| 287 | + } | |
| 288 | + | |
| 289 | + protected Color getFrameShadow() { | |
| 290 | + return frameShadow; | |
| 291 | + } | |
| 292 | + | |
| 293 | + public Insets getBorderInsets(Component c, Insets newInsets) { | |
| 294 | + newInsets.set(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE); | |
| 295 | + return newInsets; | |
| 296 | + } | |
| 297 | + | |
| 298 | + /** Draws the FrameBorder's top border. | |
| 299 | + */ | |
| 300 | + protected boolean drawTopBorder(Component c, Graphics g, | |
| 301 | + int x, int y, int width, int height) { | |
| 302 | + Rectangle titleBarRect = new Rectangle(x, y, width, BORDER_SIZE); | |
| 303 | + if (!g.getClipBounds().intersects(titleBarRect)) { | |
| 304 | + return false; | |
| 305 | + } | |
| 306 | + | |
| 307 | + int maxX = width - 1; | |
| 308 | + int maxY = BORDER_SIZE - 1; | |
| 309 | + | |
| 310 | + // Draw frame | |
| 311 | + g.setColor(frameColor); | |
| 312 | + g.drawLine(x, y + 2, maxX - 2, y + 2); | |
| 313 | + g.drawLine(x, y + 3, maxX - 2, y + 3); | |
| 314 | + g.drawLine(x, y + 4, maxX - 2, y + 4); | |
| 315 | + | |
| 316 | + // Draw highlights | |
| 317 | + g.setColor(frameHighlight); | |
| 318 | + g.drawLine(x, y, maxX, y); | |
| 319 | + g.drawLine(x, y + 1, maxX, y + 1); | |
| 320 | + g.drawLine(x, y + 2, x, y + 4); | |
| 321 | + g.drawLine(x + 1, y + 2, x + 1, y + 4); | |
| 322 | + | |
| 323 | + // Draw shadows | |
| 324 | + g.setColor(frameShadow); | |
| 325 | + g.drawLine(x + 4, y + 4, maxX - 4, y + 4); | |
| 326 | + g.drawLine(maxX, y + 1, maxX, maxY); | |
| 327 | + g.drawLine(maxX - 1, y + 2, maxX - 1, maxY); | |
| 328 | + | |
| 329 | + return true; | |
| 330 | + } | |
| 331 | + | |
| 332 | + /** Draws the FrameBorder's left border. | |
| 333 | + */ | |
| 334 | + protected boolean drawLeftBorder(Component c, Graphics g, int x, int y, | |
| 335 | + int width, int height) { | |
| 336 | + Rectangle borderRect = | |
| 337 | + new Rectangle(0, 0, getBorderInsets(c).left, height); | |
| 338 | + if (!g.getClipBounds().intersects(borderRect)) { | |
| 339 | + return false; | |
| 340 | + } | |
| 341 | + | |
| 342 | + int startY = BORDER_SIZE; | |
| 343 | + | |
| 344 | + g.setColor(frameHighlight); | |
| 345 | + g.drawLine(x, startY, x, height - 1); | |
| 346 | + g.drawLine(x + 1, startY, x + 1, height - 2); | |
| 347 | + | |
| 348 | + g.setColor(frameColor); | |
| 349 | + g.fillRect(x + 2, startY, x + 2, height - 3); | |
| 350 | + | |
| 351 | + g.setColor(frameShadow); | |
| 352 | + g.drawLine(x + 4, startY, x + 4, height - 5); | |
| 353 | + | |
| 354 | + return true; | |
| 355 | + } | |
| 356 | + | |
| 357 | + /** Draws the FrameBorder's right border. | |
| 358 | + */ | |
| 359 | + protected boolean drawRightBorder(Component c, Graphics g, int x, int y, | |
| 360 | + int width, int height) { | |
| 361 | + Rectangle borderRect = new Rectangle( | |
| 362 | + width - getBorderInsets(c).right, 0, | |
| 363 | + getBorderInsets(c).right, height); | |
| 364 | + if (!g.getClipBounds().intersects(borderRect)) { | |
| 365 | + return false; | |
| 366 | + } | |
| 367 | + | |
| 368 | + int startX = width - getBorderInsets(c).right; | |
| 369 | + int startY = BORDER_SIZE; | |
| 370 | + | |
| 371 | + g.setColor(frameColor); | |
| 372 | + g.fillRect(startX + 1, startY, 2, height - 1); | |
| 373 | + | |
| 374 | + g.setColor(frameShadow); | |
| 375 | + g.fillRect(startX + 3, startY, 2, height - 1); | |
| 376 | + | |
| 377 | + g.setColor(frameHighlight); | |
| 378 | + g.drawLine(startX, startY, startX, height - 1); | |
| 379 | + | |
| 380 | + return true; | |
| 381 | + } | |
| 382 | + | |
| 383 | + /** Draws the FrameBorder's bottom border. | |
| 384 | + */ | |
| 385 | + protected boolean drawBottomBorder(Component c, Graphics g, int x, int y, | |
| 386 | + int width, int height) { | |
| 387 | + Rectangle borderRect; | |
| 388 | + int marginHeight, startY; | |
| 389 | + | |
| 390 | + borderRect = new Rectangle(0, height - getBorderInsets(c).bottom, | |
| 391 | + width, getBorderInsets(c).bottom); | |
| 392 | + if (!g.getClipBounds().intersects(borderRect)) { | |
| 393 | + return false; | |
| 394 | + } | |
| 395 | + | |
| 396 | + startY = height - getBorderInsets(c).bottom; | |
| 397 | + | |
| 398 | + g.setColor(frameShadow); | |
| 399 | + g.drawLine(x + 1, height - 1, width - 1, height - 1); | |
| 400 | + g.drawLine(x + 2, height - 2, width - 2, height - 2); | |
| 401 | + | |
| 402 | + g.setColor(frameColor); | |
| 403 | + g.fillRect(x + 2, startY + 1, width - 4, 2); | |
| 404 | + | |
| 405 | + g.setColor(frameHighlight); | |
| 406 | + g.drawLine(x + 5, startY, width - 5, startY); | |
| 407 | + | |
| 408 | + return true; | |
| 409 | + } | |
| 410 | + | |
| 411 | + // Returns true if the associated component has focus. | |
| 412 | + protected boolean isActiveFrame() { | |
| 413 | + return jcomp.hasFocus(); | |
| 414 | + } | |
| 415 | + | |
| 416 | + /** Draws the FrameBorder in the given Rect. Calls | |
| 417 | + * <b>drawTitleBar</b>, <b>drawLeftBorder</b>, <b>drawRightBorder</b> and | |
| 418 | + * <b>drawBottomBorder</b>. | |
| 419 | + */ | |
| 420 | + public void paintBorder(Component c, Graphics g, | |
| 421 | + int x, int y, int width, int height) { | |
| 422 | + if (isActiveFrame()) { | |
| 423 | + frameColor = UIManager.getColor("activeCaptionBorder"); | |
| 424 | + } else { | |
| 425 | + frameColor = UIManager.getColor("inactiveCaptionBorder"); | |
| 426 | + } | |
| 427 | + frameHighlight = frameColor.brighter(); | |
| 428 | + frameShadow = frameColor.darker().darker(); | |
| 429 | + | |
| 430 | + drawTopBorder(c, g, x, y, width, height); | |
| 431 | + drawLeftBorder(c, g, x, y, width, height); | |
| 432 | + drawRightBorder(c, g, x, y, width, height); | |
| 433 | + drawBottomBorder(c, g, x, y, width, height); | |
| 434 | + } | |
| 435 | + } | |
| 436 | + | |
| 437 | + public static class InternalFrameBorder extends FrameBorder { | |
| 438 | + | |
| 439 | + JInternalFrame frame; | |
| 440 | + | |
| 441 | + // The size of the bounding box for Motif frame corners. | |
| 442 | + public final static int CORNER_SIZE = 24; | |
| 443 | + | |
| 444 | + /** Constructs an InternalFrameBorder for the InternalFrame | |
| 445 | + * <b>aFrame</b>. | |
| 446 | + */ | |
| 447 | + public InternalFrameBorder(JInternalFrame aFrame) { | |
| 448 | + super(aFrame); | |
| 449 | + frame = aFrame; | |
| 450 | + } | |
| 451 | + | |
| 452 | + /** Sets the InternalFrameBorder's InternalFrame. | |
| 453 | + */ | |
| 454 | + public void setFrame(JInternalFrame aFrame) { | |
| 455 | + frame = aFrame; | |
| 456 | + } | |
| 457 | + | |
| 458 | + /** Returns the InternalFrameBorder's InternalFrame. | |
| 459 | + * @see #setFrame | |
| 460 | + */ | |
| 461 | + public JInternalFrame frame() { | |
| 462 | + return frame; | |
| 463 | + } | |
| 464 | + | |
| 465 | + /** Returns the width of the InternalFrameBorder's resize controls, | |
| 466 | + * appearing along the InternalFrameBorder's bottom border. Clicking | |
| 467 | + * and dragging within these controls lets the user change both the | |
| 468 | + * InternalFrame's width and height, while dragging between the controls | |
| 469 | + * constrains resizing to just the vertical dimension. Override this | |
| 470 | + * method if you implement your own bottom border painting and use a | |
| 471 | + * resize control with a different size. | |
| 472 | + */ | |
| 473 | + public int resizePartWidth() { | |
| 474 | + if (!frame.isResizable()) { | |
| 475 | + return 0; | |
| 476 | + } | |
| 477 | + return FrameBorder.BORDER_SIZE; | |
| 478 | + } | |
| 479 | + | |
| 480 | + /** Draws the InternalFrameBorder's top border. | |
| 481 | + */ | |
| 482 | + protected boolean drawTopBorder(Component c, Graphics g, | |
| 483 | + int x, int y, int width, int height) { | |
| 484 | + if (super.drawTopBorder(c, g, x, y, width, height) && | |
| 485 | + frame.isResizable()) { | |
| 486 | + g.setColor(getFrameShadow()); | |
| 487 | + g.drawLine(CORNER_SIZE - 1, y + 1, CORNER_SIZE - 1, y + 4); | |
| 488 | + g.drawLine(width - CORNER_SIZE - 1, y + 1, | |
| 489 | + width - CORNER_SIZE - 1, y + 4); | |
| 490 | + | |
| 491 | + g.setColor(getFrameHighlight()); | |
| 492 | + g.drawLine(CORNER_SIZE, y, CORNER_SIZE, y + 4); | |
| 493 | + g.drawLine(width - CORNER_SIZE, y, width - CORNER_SIZE, y + 4); | |
| 494 | + return true; | |
| 495 | + } | |
| 496 | + return false; | |
| 497 | + } | |
| 498 | + | |
| 499 | + /** Draws the InternalFrameBorder's left border. | |
| 500 | + */ | |
| 501 | + protected boolean drawLeftBorder(Component c, Graphics g, int x, int y, | |
| 502 | + int width, int height) { | |
| 503 | + if (super.drawLeftBorder(c, g, x, y, width, height) && | |
| 504 | + frame.isResizable()) { | |
| 505 | + g.setColor(getFrameHighlight()); | |
| 506 | + int topY = y + CORNER_SIZE; | |
| 507 | + g.drawLine(x, topY, x + 4, topY); | |
| 508 | + int bottomY = height - CORNER_SIZE; | |
| 509 | + g.drawLine(x + 1, bottomY, x + 5, bottomY); | |
| 510 | + g.setColor(getFrameShadow()); | |
| 511 | + g.drawLine(x + 1, topY - 1, x + 5, topY - 1); | |
| 512 | + g.drawLine(x + 1, bottomY - 1, x + 5, bottomY - 1); | |
| 513 | + return true; | |
| 514 | + } | |
| 515 | + return false; | |
| 516 | + } | |
| 517 | + | |
| 518 | + /** Draws the InternalFrameBorder's right border. | |
| 519 | + */ | |
| 520 | + protected boolean drawRightBorder(Component c, Graphics g, int x, int y, | |
| 521 | + int width, int height) { | |
| 522 | + if (super.drawRightBorder(c, g, x, y, width, height) && | |
| 523 | + frame.isResizable()) { | |
| 524 | + int startX = width - getBorderInsets(c).right; | |
| 525 | + g.setColor(getFrameHighlight()); | |
| 526 | + int topY = y + CORNER_SIZE; | |
| 527 | + g.drawLine(startX, topY, width - 2, topY); | |
| 528 | + int bottomY = height - CORNER_SIZE; | |
| 529 | + g.drawLine(startX + 1, bottomY, startX + 3, bottomY); | |
| 530 | + g.setColor(getFrameShadow()); | |
| 531 | + g.drawLine(startX + 1, topY - 1, width - 2, topY - 1); | |
| 532 | + g.drawLine(startX + 1, bottomY - 1, startX + 3, bottomY - 1); | |
| 533 | + return true; | |
| 534 | + } | |
| 535 | + return false; | |
| 536 | + } | |
| 537 | + | |
| 538 | + /** Draws the InternalFrameBorder's bottom border. | |
| 539 | + */ | |
| 540 | + protected boolean drawBottomBorder(Component c, Graphics g, int x, int y, | |
| 541 | + int width, int height) { | |
| 542 | + if (super.drawBottomBorder(c, g, x, y, width, height) && | |
| 543 | + frame.isResizable()) { | |
| 544 | + int startY = height - getBorderInsets(c).bottom; | |
| 545 | + | |
| 546 | + g.setColor(getFrameShadow()); | |
| 547 | + g.drawLine(CORNER_SIZE - 1, startY + 1, | |
| 548 | + CORNER_SIZE - 1, height - 1); | |
| 549 | + g.drawLine(width - CORNER_SIZE, startY + 1, | |
| 550 | + width - CORNER_SIZE, height - 1); | |
| 551 | + | |
| 552 | + g.setColor(getFrameHighlight()); | |
| 553 | + g.drawLine(CORNER_SIZE, startY, CORNER_SIZE, height - 2); | |
| 554 | + g.drawLine(width - CORNER_SIZE + 1, startY, | |
| 555 | + width - CORNER_SIZE + 1, height - 2); | |
| 556 | + return true; | |
| 557 | + } | |
| 558 | + return false; | |
| 559 | + } | |
| 560 | + | |
| 561 | + // Returns true if the associated internal frame has focus. | |
| 562 | + protected boolean isActiveFrame() { | |
| 563 | + return frame.isSelected(); | |
| 564 | + } | |
| 565 | + } | |
| 566 | + | |
| 567 | + public static void drawBezel(Graphics g, int x, int y, int w, int h, | |
| 568 | + boolean isPressed, boolean hasFocus, | |
| 569 | + Color shadow, Color highlight, | |
| 570 | + Color darkShadow, Color focus) { | |
| 571 | + | |
| 572 | + Color oldColor = g.getColor(); | |
| 573 | + g.translate(x, y); | |
| 574 | + | |
| 575 | + if (isPressed) { | |
| 576 | + if (hasFocus){ | |
| 577 | + g.setColor(focus); | |
| 578 | + g.drawRect(0, 0, w-1, h-1); | |
| 579 | + } | |
| 580 | + g.setColor(shadow); // inner border | |
| 581 | + g.drawRect(1, 1, w-3, h-3); | |
| 582 | + | |
| 583 | + g.setColor(highlight); // inner 3D border | |
| 584 | + g.drawLine(2, h-3, w-3, h-3); | |
| 585 | + g.drawLine(w-3, 2, w-3, h-4); | |
| 586 | + | |
| 587 | + } else { | |
| 588 | + if (hasFocus) { | |
| 589 | + g.setColor(focus); | |
| 590 | + g.drawRect(0, 0, w-1, h-1); | |
| 591 | + | |
| 592 | + g.setColor(highlight); // inner 3D border | |
| 593 | + g.drawLine(1, 1, 1, h-3); | |
| 594 | + g.drawLine(2, 1, w-4, 1); | |
| 595 | + | |
| 596 | + g.setColor(shadow); | |
| 597 | + g.drawLine(2, h-3, w-3, h-3); | |
| 598 | + g.drawLine(w-3, 1, w-3, h-4); | |
| 599 | + | |
| 600 | + g.setColor(darkShadow); // black drop shadow __| | |
| 601 | + g.drawLine(1, h-2, w-2, h-2); | |
| 602 | + g.drawLine(w-2, h-2, w-2, 1); | |
| 603 | + } else { | |
| 604 | + g.setColor(highlight); // inner 3D border | |
| 605 | + g.drawLine(1,1,1,h-3); | |
| 606 | + g.drawLine(2,1,w-4,1); | |
| 607 | + g.setColor(shadow); | |
| 608 | + g.drawLine(2,h-3,w-3,h-3); | |
| 609 | + g.drawLine(w-3,1,w-3,h-4); | |
| 610 | + | |
| 611 | + g.setColor(darkShadow); // black drop shadow __| | |
| 612 | + g.drawLine(1,h-2,w-2,h-2); | |
| 613 | + g.drawLine(w-2,h-2,w-2,0); | |
| 614 | + | |
| 615 | + } | |
| 616 | + g.translate(-x, -y); | |
| 617 | + } | |
| 618 | + g.setColor(oldColor); | |
| 619 | + } | |
| 620 | + | |
| 621 | + public static class MotifPopupMenuBorder extends AbstractBorder implements UIResource { | |
| 622 | + protected Font font; | |
| 623 | + protected Color background; | |
| 624 | + protected Color foreground; | |
| 625 | + protected Color shadowColor; | |
| 626 | + protected Color highlightColor; | |
| 627 | + | |
| 628 | + // Space between the border and text | |
| 629 | + static protected final int TEXT_SPACING = 2; | |
| 630 | + | |
| 631 | + // Space for the separator under the title | |
| 632 | + static protected final int GROOVE_HEIGHT = 2; | |
| 633 | + | |
| 634 | + /** | |
| 635 | + * Creates a MotifPopupMenuBorder instance | |
| 636 | + * | |
| 637 | + */ | |
| 638 | + public MotifPopupMenuBorder( | |
| 639 | + Font titleFont, | |
| 640 | + Color bgColor, | |
| 641 | + Color fgColor, | |
| 642 | + Color shadow, | |
| 643 | + Color highlight) { | |
| 644 | + this.font = titleFont; | |
| 645 | + this.background = bgColor; | |
| 646 | + this.foreground = fgColor; | |
| 647 | + this.shadowColor = shadow; | |
| 648 | + this.highlightColor = highlight; | |
| 649 | + } | |
| 650 | + | |
| 651 | + /** | |
| 652 | + * Paints the border for the specified component with the | |
| 653 | + * specified position and size. | |
| 654 | + * @param c the component for which this border is being painted | |
| 655 | + * @param g the paint graphics | |
| 656 | + * @param x the x position of the painted border | |
| 657 | + * @param y the y position of the painted border | |
| 658 | + * @param width the width of the painted border | |
| 659 | + * @param height the height of the painted border | |
| 660 | + */ | |
| 661 | + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { | |
| 662 | + if (!(c instanceof JPopupMenu)) { | |
| 663 | + return; | |
| 664 | + } | |
| 665 | + | |
| 666 | + Font origFont = g.getFont(); | |
| 667 | + Color origColor = g.getColor(); | |
| 668 | + JPopupMenu popup = (JPopupMenu)c; | |
| 669 | + | |
| 670 | + String title = popup.getLabel(); | |
| 671 | + if (title == null) { | |
| 672 | + return; | |
| 673 | + } | |
| 674 | + | |
| 675 | + g.setFont(font); | |
| 676 | + | |
| 677 | + FontMetrics fm = SwingUtilities2.getFontMetrics(popup, g, font); | |
| 678 | + int fontHeight = fm.getHeight(); | |
| 679 | + int descent = fm.getDescent(); | |
| 680 | + int ascent = fm.getAscent(); | |
| 681 | + Point textLoc = new Point(); | |
| 682 | + int stringWidth = SwingUtilities2.stringWidth(popup, fm, | |
| 683 | + title); | |
| 684 | + | |
| 685 | + textLoc.y = y + ascent + TEXT_SPACING; | |
| 686 | + textLoc.x = x + ((width - stringWidth) / 2); | |
| 687 | + | |
| 688 | + g.setColor(background); | |
| 689 | + g.fillRect(textLoc.x - TEXT_SPACING, textLoc.y - (fontHeight-descent), | |
| 690 | + stringWidth + (2 * TEXT_SPACING), fontHeight - descent); | |
| 691 | + g.setColor(foreground); | |
| 692 | + SwingUtilities2.drawString(popup, g, title, textLoc.x, textLoc.y); | |
| 693 | + | |
| 694 | + MotifGraphicsUtils.drawGroove(g, x, textLoc.y + TEXT_SPACING, | |
| 695 | + width, GROOVE_HEIGHT, | |
| 696 | + shadowColor, highlightColor); | |
| 697 | + | |
| 698 | + g.setFont(origFont); | |
| 699 | + g.setColor(origColor); | |
| 700 | + } | |
| 701 | + | |
| 702 | + /** | |
| 703 | + * Reinitialize the insets parameter with this Border's current Insets. | |
| 704 | + * @param c the component for which this border insets value applies | |
| 705 | + * @param insets the object to be reinitialized | |
| 706 | + */ | |
| 707 | + public Insets getBorderInsets(Component c, Insets insets) { | |
| 708 | + if (!(c instanceof JPopupMenu)) { | |
| 709 | + return insets; | |
| 710 | + } | |
| 711 | + FontMetrics fm; | |
| 712 | + int descent = 0; | |
| 713 | + int ascent = 16; | |
| 714 | + | |
| 715 | + String title = ((JPopupMenu)c).getLabel(); | |
| 716 | + if (title == null) { | |
| 717 | + insets.left = insets.top = insets.right = insets.bottom = 0; | |
| 718 | + return insets; | |
| 719 | + } | |
| 720 | + | |
| 721 | + fm = c.getFontMetrics(font); | |
| 722 | + | |
| 723 | + if(fm != null) { | |
| 724 | + descent = fm.getDescent(); | |
| 725 | + ascent = fm.getAscent(); | |
| 726 | + } | |
| 727 | + | |
| 728 | + insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT; | |
| 729 | + return insets; | |
| 730 | + } | |
| 731 | + | |
| 732 | + } | |
| 733 | + | |
| 734 | +} | |
| @@ -0,0 +1,49 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | + | |
| 27 | +package com.sun.java.swing.plaf.motif; | |
| 28 | + | |
| 29 | +import java.awt.*; | |
| 30 | +import java.awt.event.*; | |
| 31 | +import javax.swing.*; | |
| 32 | +import javax.swing.plaf.basic.*; | |
| 33 | +import javax.swing.event.*; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Button Listener | |
| 37 | + * <p> | |
| 38 | + * | |
| 39 | + * @author Rich Schiavi | |
| 40 | + */ | |
| 41 | +public class MotifButtonListener extends BasicButtonListener { | |
| 42 | + public MotifButtonListener(AbstractButton b ) { | |
| 43 | + super(b); | |
| 44 | + } | |
| 45 | + | |
| 46 | + protected void checkOpacity(AbstractButton b) { | |
| 47 | + b.setOpaque( false ); | |
| 48 | + } | |
| 49 | +} | |
| @@ -0,0 +1,150 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import sun.awt.AppContext; | |
| 29 | + | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.border.*; | |
| 32 | +import javax.swing.plaf.basic.*; | |
| 33 | +import java.awt.*; | |
| 34 | +import java.awt.event.*; | |
| 35 | +import javax.swing.plaf.*; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * MotifButton implementation | |
| 39 | + * <p> | |
| 40 | + * <strong>Warning:</strong> | |
| 41 | + * Serialized objects of this class will not be compatible with | |
| 42 | + * future Swing releases. The current serialization support is appropriate | |
| 43 | + * for short term storage or RMI between applications running the same | |
| 44 | + * version of Swing. A future release of Swing will provide support for | |
| 45 | + * long term persistence. | |
| 46 | + * | |
| 47 | + * @author Rich Schiavi | |
| 48 | + */ | |
| 49 | +public class MotifButtonUI extends BasicButtonUI { | |
| 50 | + | |
| 51 | + protected Color selectColor; | |
| 52 | + | |
| 53 | + private boolean defaults_initialized = false; | |
| 54 | + | |
| 55 | + private static final Object MOTIF_BUTTON_UI_KEY = new Object(); | |
| 56 | + | |
| 57 | + // ******************************** | |
| 58 | + // Create PLAF | |
| 59 | + // ******************************** | |
| 60 | + public static ComponentUI createUI(JComponent c) { | |
| 61 | + AppContext appContext = AppContext.getAppContext(); | |
| 62 | + MotifButtonUI motifButtonUI = | |
| 63 | + (MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY); | |
| 64 | + if (motifButtonUI == null) { | |
| 65 | + motifButtonUI = new MotifButtonUI(); | |
| 66 | + appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI); | |
| 67 | + } | |
| 68 | + return motifButtonUI; | |
| 69 | + } | |
| 70 | + | |
| 71 | + // ******************************** | |
| 72 | + // Create Listeners | |
| 73 | + // ******************************** | |
| 74 | + protected BasicButtonListener createButtonListener(AbstractButton b){ | |
| 75 | + return new MotifButtonListener(b); | |
| 76 | + } | |
| 77 | + | |
| 78 | + // ******************************** | |
| 79 | + // Install Defaults | |
| 80 | + // ******************************** | |
| 81 | + public void installDefaults(AbstractButton b) { | |
| 82 | + super.installDefaults(b); | |
| 83 | + if(!defaults_initialized) { | |
| 84 | + selectColor = UIManager.getColor(getPropertyPrefix() + "select"); | |
| 85 | + defaults_initialized = true; | |
| 86 | + } | |
| 87 | + LookAndFeel.installProperty(b, "opaque", Boolean.FALSE); | |
| 88 | + } | |
| 89 | + | |
| 90 | + protected void uninstallDefaults(AbstractButton b) { | |
| 91 | + super.uninstallDefaults(b); | |
| 92 | + defaults_initialized = false; | |
| 93 | + } | |
| 94 | + | |
| 95 | + // ******************************** | |
| 96 | + // Default Accessors | |
| 97 | + // ******************************** | |
| 98 | + | |
| 99 | + protected Color getSelectColor() { | |
| 100 | + return selectColor; | |
| 101 | + } | |
| 102 | + | |
| 103 | + // ******************************** | |
| 104 | + // Paint Methods | |
| 105 | + // ******************************** | |
| 106 | + public void paint(Graphics g, JComponent c) { | |
| 107 | + fillContentArea( g, (AbstractButton)c , c.getBackground() ); | |
| 108 | + super.paint(g,c); | |
| 109 | + } | |
| 110 | + | |
| 111 | + // Overridden to ensure we don't paint icon over button borders. | |
| 112 | + protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { | |
| 113 | + Shape oldClip = g.getClip(); | |
| 114 | + Rectangle newClip = | |
| 115 | + AbstractBorder.getInteriorRectangle(c, c.getBorder(), 0, 0, | |
| 116 | + c.getWidth(), c.getHeight()); | |
| 117 | + | |
| 118 | + Rectangle r = oldClip.getBounds(); | |
| 119 | + newClip = | |
| 120 | + SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height, | |
| 121 | + newClip); | |
| 122 | + g.setClip(newClip); | |
| 123 | + super.paintIcon(g, c, iconRect); | |
| 124 | + g.setClip(oldClip); | |
| 125 | + } | |
| 126 | + | |
| 127 | + protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){ | |
| 128 | + // focus painting is handled by the border | |
| 129 | + } | |
| 130 | + | |
| 131 | + protected void paintButtonPressed(Graphics g, AbstractButton b) { | |
| 132 | + | |
| 133 | + fillContentArea( g, b , selectColor ); | |
| 134 | + | |
| 135 | + } | |
| 136 | + | |
| 137 | + protected void fillContentArea( Graphics g, AbstractButton b, Color fillColor) { | |
| 138 | + | |
| 139 | + if (b.isContentAreaFilled()) { | |
| 140 | + Insets margin = b.getMargin(); | |
| 141 | + Insets insets = b.getInsets(); | |
| 142 | + Dimension size = b.getSize(); | |
| 143 | + g.setColor(fillColor); | |
| 144 | + g.fillRect(insets.left - margin.left, | |
| 145 | + insets.top - margin.top, | |
| 146 | + size.width - (insets.left-margin.left) - (insets.right - margin.right), | |
| 147 | + size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom)); | |
| 148 | + } | |
| 149 | + } | |
| 150 | +} | |
| @@ -0,0 +1,107 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import javax.swing.*; | |
| 29 | +import javax.swing.event.*; | |
| 30 | +import javax.swing.plaf.*; | |
| 31 | +import javax.swing.plaf.basic.BasicButtonListener; | |
| 32 | +import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; | |
| 33 | + | |
| 34 | +import java.awt.*; | |
| 35 | +import java.awt.event.*; | |
| 36 | + | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * MotifCheckboxMenuItem implementation | |
| 40 | + * <p> | |
| 41 | + * | |
| 42 | + * @author Georges Saab | |
| 43 | + * @author Rich Schiavi | |
| 44 | + */ | |
| 45 | +public class MotifCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI | |
| 46 | +{ | |
| 47 | + protected ChangeListener changeListener; | |
| 48 | + | |
| 49 | + public static ComponentUI createUI(JComponent b) { | |
| 50 | + return new MotifCheckBoxMenuItemUI(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + protected void installListeners() { | |
| 54 | + super.installListeners(); | |
| 55 | + changeListener = createChangeListener(menuItem); | |
| 56 | + menuItem.addChangeListener(changeListener); | |
| 57 | + } | |
| 58 | + | |
| 59 | + protected void uninstallListeners() { | |
| 60 | + super.uninstallListeners(); | |
| 61 | + menuItem.removeChangeListener(changeListener); | |
| 62 | + } | |
| 63 | + | |
| 64 | + protected ChangeListener createChangeListener(JComponent c) { | |
| 65 | + return new ChangeHandler(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + protected class ChangeHandler implements ChangeListener { | |
| 69 | + public void stateChanged(ChangeEvent e) { | |
| 70 | + JMenuItem c = (JMenuItem)e.getSource(); | |
| 71 | + LookAndFeel.installProperty(c, "borderPainted", c.isArmed()); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + protected MouseInputListener createMouseInputListener(JComponent c) { | |
| 76 | + return new MouseInputHandler(); | |
| 77 | + } | |
| 78 | + | |
| 79 | + | |
| 80 | + protected class MouseInputHandler implements MouseInputListener { | |
| 81 | + public void mouseClicked(MouseEvent e) {} | |
| 82 | + public void mousePressed(MouseEvent e) { | |
| 83 | + MenuSelectionManager manager = MenuSelectionManager.defaultManager(); | |
| 84 | + manager.setSelectedPath(getPath()); | |
| 85 | + } | |
| 86 | + public void mouseReleased(MouseEvent e) { | |
| 87 | + MenuSelectionManager manager = | |
| 88 | + MenuSelectionManager.defaultManager(); | |
| 89 | + JMenuItem menuItem = (JMenuItem)e.getComponent(); | |
| 90 | + Point p = e.getPoint(); | |
| 91 | + if(p.x >= 0 && p.x < menuItem.getWidth() && | |
| 92 | + p.y >= 0 && p.y < menuItem.getHeight()) { | |
| 93 | + manager.clearSelectedPath(); | |
| 94 | + menuItem.doClick(0); | |
| 95 | + } else { | |
| 96 | + manager.processMouseEvent(e); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + public void mouseEntered(MouseEvent e) {} | |
| 100 | + public void mouseExited(MouseEvent e) {} | |
| 101 | + public void mouseDragged(MouseEvent e) { | |
| 102 | + MenuSelectionManager.defaultManager().processMouseEvent(e); | |
| 103 | + } | |
| 104 | + public void mouseMoved(MouseEvent e) { } | |
| 105 | + } | |
| 106 | + | |
| 107 | +} | |
| @@ -0,0 +1,90 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import sun.awt.AppContext; | |
| 29 | + | |
| 30 | +import javax.swing.*; | |
| 31 | + | |
| 32 | +import javax.swing.plaf.*; | |
| 33 | + | |
| 34 | +import java.awt.*; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * MotifCheckBox implementation | |
| 38 | + * <p> | |
| 39 | + * <strong>Warning:</strong> | |
| 40 | + * Serialized objects of this class will not be compatible with | |
| 41 | + * future Swing releases. The current serialization support is appropriate | |
| 42 | + * for short term storage or RMI between applications running the same | |
| 43 | + * version of Swing. A future release of Swing will provide support for | |
| 44 | + * long term persistence. | |
| 45 | + * | |
| 46 | + * @author Rich Schiavi | |
| 47 | + */ | |
| 48 | +public class MotifCheckBoxUI extends MotifRadioButtonUI { | |
| 49 | + | |
| 50 | + private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object(); | |
| 51 | + | |
| 52 | + private final static String propertyPrefix = "CheckBox" + "."; | |
| 53 | + | |
| 54 | + private boolean defaults_initialized = false; | |
| 55 | + | |
| 56 | + | |
| 57 | + // ******************************** | |
| 58 | + // Create PLAF | |
| 59 | + // ******************************** | |
| 60 | + public static ComponentUI createUI(JComponent c) { | |
| 61 | + AppContext appContext = AppContext.getAppContext(); | |
| 62 | + MotifCheckBoxUI motifCheckBoxUI = | |
| 63 | + (MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY); | |
| 64 | + if (motifCheckBoxUI == null) { | |
| 65 | + motifCheckBoxUI = new MotifCheckBoxUI(); | |
| 66 | + appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI); | |
| 67 | + } | |
| 68 | + return motifCheckBoxUI; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public String getPropertyPrefix() { | |
| 72 | + return propertyPrefix; | |
| 73 | + } | |
| 74 | + | |
| 75 | + // ******************************** | |
| 76 | + // Defaults | |
| 77 | + // ******************************** | |
| 78 | + public void installDefaults(AbstractButton b) { | |
| 79 | + super.installDefaults(b); | |
| 80 | + if(!defaults_initialized) { | |
| 81 | + icon = UIManager.getIcon(getPropertyPrefix() + "icon"); | |
| 82 | + defaults_initialized = true; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + protected void uninstallDefaults(AbstractButton b) { | |
| 87 | + super.uninstallDefaults(b); | |
| 88 | + defaults_initialized = false; | |
| 89 | + } | |
| 90 | +} | |
| @@ -0,0 +1,361 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.motif; | |
| 26 | + | |
| 27 | +import java.awt.*; | |
| 28 | +import javax.swing.*; | |
| 29 | +import javax.swing.plaf.*; | |
| 30 | +import javax.swing.border.*; | |
| 31 | +import javax.swing.plaf.basic.*; | |
| 32 | +import java.io.Serializable; | |
| 33 | +import java.awt.event.*; | |
| 34 | +import java.beans.*; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * ComboBox motif look and feel | |
| 38 | + * <p> * <strong>Warning:</strong> | |
| 39 | + * Serialized objects of this class will not be compatible with | |
| 40 | + * future Swing releases. The current serialization support is appropriate | |
| 41 | + * for short term storage or RMI between applications running the same | |
| 42 | + * version of Swing. A future release of Swing will provide support for | |
| 43 | + * long term persistence. | |
| 44 | + * | |
| 45 | + * @author Arnaud Weber | |
| 46 | + */ | |
| 47 | +public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable { | |
| 48 | + Icon arrowIcon; | |
| 49 | + static final int HORIZ_MARGIN = 3; | |
| 50 | + | |
| 51 | + public static ComponentUI createUI(JComponent c) { | |
| 52 | + return new MotifComboBoxUI(); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void installUI(JComponent c) { | |
| 56 | + super.installUI(c); | |
| 57 | + arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"), | |
| 58 | + UIManager.getColor("controlShadow"), | |
| 59 | + UIManager.getColor("control")); | |
| 60 | + | |
| 61 | + Runnable initCode = new Runnable() { | |
| 62 | + public void run(){ | |
| 63 | + if ( motifGetEditor() != null ) { | |
| 64 | + motifGetEditor().setBackground( UIManager.getColor( "text" ) ); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + }; | |
| 68 | + | |
| 69 | + SwingUtilities.invokeLater( initCode ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + public Dimension getMinimumSize( JComponent c ) { | |
| 73 | + if ( !isMinimumSizeDirty ) { | |
| 74 | + return new Dimension( cachedMinimumSize ); | |
| 75 | + } | |
| 76 | + Dimension size; | |
| 77 | + Insets insets = getInsets(); | |
| 78 | + size = getDisplaySize(); | |
| 79 | + size.height += insets.top + insets.bottom; | |
| 80 | + int buttonSize = iconAreaWidth(); | |
| 81 | + size.width += insets.left + insets.right + buttonSize; | |
| 82 | + | |
| 83 | + cachedMinimumSize.setSize( size.width, size.height ); | |
| 84 | + isMinimumSizeDirty = false; | |
| 85 | + | |
| 86 | + return size; | |
| 87 | + } | |
| 88 | + | |
| 89 | + protected ComboPopup createPopup() { | |
| 90 | + return new MotifComboPopup( comboBox ); | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Overriden to empty the MouseMotionListener. | |
| 95 | + */ | |
| 96 | + protected class MotifComboPopup extends BasicComboPopup { | |
| 97 | + | |
| 98 | + public MotifComboPopup( JComboBox comboBox ) { | |
| 99 | + super( comboBox ); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Motif combo popup should not track the mouse in the list. | |
| 104 | + */ | |
| 105 | + public MouseMotionListener createListMouseMotionListener() { | |
| 106 | + return new MouseMotionAdapter() {}; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public KeyListener createKeyListener() { | |
| 110 | + return super.createKeyListener(); | |
| 111 | + } | |
| 112 | + | |
| 113 | + protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler { | |
| 114 | + protected InvocationKeyHandler() { | |
| 115 | + MotifComboPopup.this.super(); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 120 | + protected void installComponents() { | |
| 121 | + if ( comboBox.isEditable() ) { | |
| 122 | + addEditor(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + comboBox.add( currentValuePane ); | |
| 126 | + } | |
| 127 | + | |
| 128 | + protected void uninstallComponents() { | |
| 129 | + removeEditor(); | |
| 130 | + comboBox.removeAll(); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void paint(Graphics g, JComponent c) { | |
| 134 | + boolean hasFocus = comboBox.hasFocus(); | |
| 135 | + Rectangle r; | |
| 136 | + | |
| 137 | + if (comboBox.isEnabled()) { | |
| 138 | + g.setColor(comboBox.getBackground()); | |
| 139 | + } else { | |
| 140 | + g.setColor(UIManager.getColor("ComboBox.disabledBackground")); | |
| 141 | + } | |
| 142 | + g.fillRect(0,0,c.getWidth(),c.getHeight()); | |
| 143 | + | |
| 144 | + if ( !comboBox.isEditable() ) { | |
| 145 | + r = rectangleForCurrentValue(); | |
| 146 | + paintCurrentValue(g,r,hasFocus); | |
| 147 | + } | |
| 148 | + r = rectangleForArrowIcon(); | |
| 149 | + arrowIcon.paintIcon(c,g,r.x,r.y); | |
| 150 | + if ( !comboBox.isEditable() ) { | |
| 151 | + Border border = comboBox.getBorder(); | |
| 152 | + Insets in; | |
| 153 | + if ( border != null ) { | |
| 154 | + in = border.getBorderInsets(comboBox); | |
| 155 | + } | |
| 156 | + else { | |
| 157 | + in = new Insets( 0, 0, 0, 0 ); | |
| 158 | + } | |
| 159 | + // Draw the separation | |
| 160 | + if(MotifGraphicsUtils.isLeftToRight(comboBox)) { | |
| 161 | + r.x -= (HORIZ_MARGIN + 2); | |
| 162 | + } | |
| 163 | + else { | |
| 164 | + r.x += r.width + HORIZ_MARGIN + 1; | |
| 165 | + } | |
| 166 | + r.y = in.top; | |
| 167 | + r.width = 1; | |
| 168 | + r.height = comboBox.getBounds().height - in.bottom - in.top; | |
| 169 | + g.setColor(UIManager.getColor("controlShadow")); | |
| 170 | + g.fillRect(r.x,r.y,r.width,r.height); | |
| 171 | + r.x++; | |
| 172 | + g.setColor(UIManager.getColor("controlHighlight")); | |
| 173 | + g.fillRect(r.x,r.y,r.width,r.height); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) { | |
| 178 | + ListCellRenderer renderer = comboBox.getRenderer(); | |
| 179 | + Component c; | |
| 180 | + Dimension d; | |
| 181 | + c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false); | |
| 182 | + c.setFont(comboBox.getFont()); | |
| 183 | + if ( comboBox.isEnabled() ) { | |
| 184 | + c.setForeground(comboBox.getForeground()); | |
| 185 | + c.setBackground(comboBox.getBackground()); | |
| 186 | + } | |
| 187 | + else { | |
| 188 | + c.setForeground(UIManager.getColor("ComboBox.disabledForeground")); | |
| 189 | + c.setBackground(UIManager.getColor("ComboBox.disabledBackground")); | |
| 190 | + } | |
| 191 | + d = c.getPreferredSize(); | |
| 192 | + currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y, | |
| 193 | + bounds.width,d.height); | |
| 194 | + } | |
| 195 | + | |
| 196 | + protected Rectangle rectangleForArrowIcon() { | |
| 197 | + Rectangle b = comboBox.getBounds(); | |
| 198 | + Border border = comboBox.getBorder(); | |
| 199 | + Insets in; | |
| 200 | + if ( border != null ) { | |
| 201 | + in = border.getBorderInsets(comboBox); | |
| 202 | + } | |
| 203 | + else { | |
| 204 | + in = new Insets( 0, 0, 0, 0 ); | |
| 205 | + } | |
| 206 | + b.x = in.left; | |
| 207 | + b.y = in.top; | |
| 208 | + b.width -= (in.left + in.right); | |
| 209 | + b.height -= (in.top + in.bottom); | |
| 210 | + | |
| 211 | + if(MotifGraphicsUtils.isLeftToRight(comboBox)) { | |
| 212 | + b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth(); | |
| 213 | + } | |
| 214 | + else { | |
| 215 | + b.x += HORIZ_MARGIN; | |
| 216 | + } | |
| 217 | + b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2; | |
| 218 | + b.width = arrowIcon.getIconWidth(); | |
| 219 | + b.height = arrowIcon.getIconHeight(); | |
| 220 | + return b; | |
| 221 | + } | |
| 222 | + | |
| 223 | + protected Rectangle rectangleForCurrentValue() { | |
| 224 | + int width = comboBox.getWidth(); | |
| 225 | + int height = comboBox.getHeight(); | |
| 226 | + Insets insets = getInsets(); | |
| 227 | + if(MotifGraphicsUtils.isLeftToRight(comboBox)) { | |
| 228 | + return new Rectangle(insets.left, insets.top, | |
| 229 | + (width - (insets.left + insets.right)) - | |
| 230 | + iconAreaWidth(), | |
| 231 | + height - (insets.top + insets.bottom)); | |
| 232 | + } | |
| 233 | + else { | |
| 234 | + return new Rectangle(insets.left + iconAreaWidth(), insets.top, | |
| 235 | + (width - (insets.left + insets.right)) - | |
| 236 | + iconAreaWidth(), | |
| 237 | + height - (insets.top + insets.bottom)); | |
| 238 | + } | |
| 239 | + } | |
| 240 | + | |
| 241 | + public int iconAreaWidth() { | |
| 242 | + if ( comboBox.isEditable() ) | |
| 243 | + return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN); | |
| 244 | + else | |
| 245 | + return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2; | |
| 246 | + } | |
| 247 | + | |
| 248 | + public void configureEditor() { | |
| 249 | + super.configureEditor(); | |
| 250 | + editor.setBackground( UIManager.getColor( "text" ) ); | |
| 251 | + } | |
| 252 | + | |
| 253 | + protected LayoutManager createLayoutManager() { | |
| 254 | + return new ComboBoxLayoutManager(); | |
| 255 | + } | |
| 256 | + | |
| 257 | + private Component motifGetEditor() { | |
| 258 | + return editor; | |
| 259 | + } | |
| 260 | + | |
| 261 | + /** | |
| 262 | + * This inner class is marked "public" due to a compiler bug. | |
| 263 | + * This class should be treated as a "protected" inner class. | |
| 264 | + * Instantiate it only within subclasses of <FooUI>. | |
| 265 | + */ | |
| 266 | + public class ComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager { | |
| 267 | + public ComboBoxLayoutManager() { | |
| 268 | + MotifComboBoxUI.this.super(); | |
| 269 | + } | |
| 270 | + public void layoutContainer(Container parent) { | |
| 271 | + if ( motifGetEditor() != null ) { | |
| 272 | + Rectangle cvb = rectangleForCurrentValue(); | |
| 273 | + cvb.x += 1; | |
| 274 | + cvb.y += 1; | |
| 275 | + cvb.width -= 1; | |
| 276 | + cvb.height -= 2; | |
| 277 | + motifGetEditor().setBounds(cvb); | |
| 278 | + } | |
| 279 | + } | |
| 280 | + } | |
| 281 | + | |
| 282 | + static class MotifComboBoxArrowIcon implements Icon, Serializable { | |
| 283 | + private Color lightShadow; | |
| 284 | + private Color darkShadow; | |
| 285 | + private Color fill; | |
| 286 | + | |
| 287 | + public MotifComboBoxArrowIcon(Color lightShadow, Color darkShadow, Color fill) { | |
| 288 | + this.lightShadow = lightShadow; | |
| 289 | + this.darkShadow = darkShadow; | |
| 290 | + this.fill = fill; | |
| 291 | + } | |
| 292 | + | |
| 293 | + | |
| 294 | + public void paintIcon(Component c, Graphics g, int xo, int yo) { | |
| 295 | + int w = getIconWidth(); | |
| 296 | + int h = getIconHeight(); | |
| 297 | + | |
| 298 | + g.setColor(lightShadow); | |
| 299 | + g.drawLine(xo, yo, xo+w-1, yo); | |
| 300 | + g.drawLine(xo, yo+1, xo+w-3, yo+1); | |
| 301 | + g.setColor(darkShadow); | |
| 302 | + g.drawLine(xo+w-2, yo+1, xo+w-1, yo+1); | |
| 303 | + | |
| 304 | + for ( int x = xo+1, y = yo+2, dx = w-6; y+1 < yo+h; y += 2 ) { | |
| 305 | + g.setColor(lightShadow); | |
| 306 | + g.drawLine(x, y, x+1, y); | |
| 307 | + g.drawLine(x, y+1, x+1, y+1); | |
| 308 | + if ( dx > 0 ) { | |
| 309 | + g.setColor(fill); | |
| 310 | + g.drawLine(x+2, y, x+1+dx, y); | |
| 311 | + g.drawLine(x+2, y+1, x+1+dx, y+1); | |
| 312 | + } | |
| 313 | + g.setColor(darkShadow); | |
| 314 | + g.drawLine(x+dx+2, y, x+dx+3, y); | |
| 315 | + g.drawLine(x+dx+2, y+1, x+dx+3, y+1); | |
| 316 | + x += 1; | |
| 317 | + dx -= 2; | |
| 318 | + } | |
| 319 | + | |
| 320 | + g.setColor(darkShadow); | |
| 321 | + g.drawLine(xo+(w/2), yo+h-1, xo+(w/2), yo+h-1); | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + public int getIconWidth() { | |
| 326 | + return 11; | |
| 327 | + } | |
| 328 | + | |
| 329 | + public int getIconHeight() { | |
| 330 | + return 11; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 334 | + /** | |
| 335 | + *{@inheritDoc} | |
| 336 | + * | |
| 337 | + * @since 1.6 | |
| 338 | + */ | |
| 339 | + protected PropertyChangeListener createPropertyChangeListener() { | |
| 340 | + return new MotifPropertyChangeListener(); | |
| 341 | + } | |
| 342 | + | |
| 343 | + /** | |
| 344 | + * This class should be made "protected" in future releases. | |
| 345 | + */ | |
| 346 | + private class MotifPropertyChangeListener | |
| 347 | + extends BasicComboBoxUI.PropertyChangeHandler { | |
| 348 | + public void propertyChange(PropertyChangeEvent e) { | |
| 349 | + super.propertyChange(e); | |
| 350 | + String propertyName = e.getPropertyName(); | |
| 351 | + if (propertyName == "enabled") { | |
| 352 | + if (comboBox.isEnabled()) { | |
| 353 | + Component editor = motifGetEditor(); | |
| 354 | + if (editor != null) { | |
| 355 | + editor.setBackground(UIManager.getColor("text")); | |
| 356 | + } | |
| 357 | + } | |
| 358 | + } | |
| 359 | + } | |
| 360 | + } | |
| 361 | +} | |
| @@ -0,0 +1,365 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import sun.swing.SwingUtilities2; | |
| 29 | +import java.awt.*; | |
| 30 | +import java.awt.event.*; | |
| 31 | +import javax.swing.*; | |
| 32 | +import javax.swing.border.*; | |
| 33 | +import javax.swing.plaf.*; | |
| 34 | +import javax.swing.plaf.basic.*; | |
| 35 | +import java.beans.*; | |
| 36 | +import java.util.EventListener; | |
| 37 | +import java.io.Serializable; | |
| 38 | + | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Motif rendition of the component. | |
| 42 | + * | |
| 43 | + * @author Thomas Ball | |
| 44 | + * @author Rich Schiavi | |
| 45 | + */ | |
| 46 | +public class MotifDesktopIconUI extends BasicDesktopIconUI | |
| 47 | +{ | |
| 48 | + protected DesktopIconActionListener desktopIconActionListener; | |
| 49 | + protected DesktopIconMouseListener desktopIconMouseListener; | |
| 50 | + | |
| 51 | + protected Icon defaultIcon; | |
| 52 | + protected IconButton iconButton; | |
| 53 | + protected IconLabel iconLabel; | |
| 54 | + | |
| 55 | + // This is only used for its system menu, but we need a reference to it so | |
| 56 | + // we can remove its listeners. | |
| 57 | + private MotifInternalFrameTitlePane sysMenuTitlePane; | |
| 58 | + | |
| 59 | + JPopupMenu systemMenu; | |
| 60 | + EventListener mml; | |
| 61 | + | |
| 62 | + final static int LABEL_HEIGHT = 18; | |
| 63 | + final static int LABEL_DIVIDER = 4; // padding between icon and label | |
| 64 | + | |
| 65 | + final static Font defaultTitleFont = | |
| 66 | + new Font(Font.SANS_SERIF, Font.PLAIN, 12); | |
| 67 | + | |
| 68 | + public static ComponentUI createUI(JComponent c) { | |
| 69 | + return new MotifDesktopIconUI(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + public MotifDesktopIconUI() { | |
| 73 | + } | |
| 74 | + | |
| 75 | + protected void installDefaults(){ | |
| 76 | + super.installDefaults(); | |
| 77 | + setDefaultIcon(UIManager.getIcon("DesktopIcon.icon")); | |
| 78 | + iconButton = createIconButton(defaultIcon); | |
| 79 | + // An underhanded way of creating a system popup menu. | |
| 80 | + sysMenuTitlePane = new MotifInternalFrameTitlePane(frame); | |
| 81 | + systemMenu = sysMenuTitlePane.getSystemMenu(); | |
| 82 | + | |
| 83 | + MotifBorders.FrameBorder border = new MotifBorders.FrameBorder(desktopIcon); | |
| 84 | + desktopIcon.setLayout(new BorderLayout()); | |
| 85 | + iconButton.setBorder(border); | |
| 86 | + desktopIcon.add(iconButton, BorderLayout.CENTER); | |
| 87 | + iconLabel = createIconLabel(frame); | |
| 88 | + iconLabel.setBorder(border); | |
| 89 | + desktopIcon.add(iconLabel, BorderLayout.SOUTH); | |
| 90 | + desktopIcon.setSize(desktopIcon.getPreferredSize()); | |
| 91 | + desktopIcon.validate(); | |
| 92 | + JLayeredPane.putLayer(desktopIcon, JLayeredPane.getLayer(frame)); | |
| 93 | + } | |
| 94 | + | |
| 95 | + protected void installComponents(){ | |
| 96 | + } | |
| 97 | + | |
| 98 | + protected void uninstallComponents(){ | |
| 99 | + } | |
| 100 | + | |
| 101 | + protected void installListeners(){ | |
| 102 | + super.installListeners(); | |
| 103 | + desktopIconActionListener = createDesktopIconActionListener(); | |
| 104 | + desktopIconMouseListener = createDesktopIconMouseListener(); | |
| 105 | + iconButton.addActionListener(desktopIconActionListener); | |
| 106 | + iconButton.addMouseListener(desktopIconMouseListener); | |
| 107 | + iconLabel.addMouseListener(desktopIconMouseListener); | |
| 108 | + } | |
| 109 | + | |
| 110 | + JInternalFrame.JDesktopIcon getDesktopIcon(){ | |
| 111 | + return desktopIcon; | |
| 112 | + } | |
| 113 | + | |
| 114 | + void setDesktopIcon(JInternalFrame.JDesktopIcon d){ | |
| 115 | + desktopIcon = d; | |
| 116 | + } | |
| 117 | + | |
| 118 | + JInternalFrame getFrame(){ | |
| 119 | + return frame; | |
| 120 | + } | |
| 121 | + | |
| 122 | + void setFrame(JInternalFrame f){ | |
| 123 | + frame = f ; | |
| 124 | + } | |
| 125 | + | |
| 126 | + protected void showSystemMenu(){ | |
| 127 | + systemMenu.show(iconButton, 0, getDesktopIcon().getHeight()); | |
| 128 | + } | |
| 129 | + | |
| 130 | + protected void hideSystemMenu(){ | |
| 131 | + systemMenu.setVisible(false); | |
| 132 | + } | |
| 133 | + | |
| 134 | + protected IconLabel createIconLabel(JInternalFrame frame){ | |
| 135 | + return new IconLabel(frame); | |
| 136 | + } | |
| 137 | + | |
| 138 | + protected IconButton createIconButton(Icon i){ | |
| 139 | + return new IconButton(i); | |
| 140 | + } | |
| 141 | + | |
| 142 | + protected DesktopIconActionListener createDesktopIconActionListener(){ | |
| 143 | + return new DesktopIconActionListener(); | |
| 144 | + } | |
| 145 | + | |
| 146 | + protected DesktopIconMouseListener createDesktopIconMouseListener(){ | |
| 147 | + return new DesktopIconMouseListener(); | |
| 148 | + } | |
| 149 | + | |
| 150 | + protected void uninstallDefaults(){ | |
| 151 | + super.uninstallDefaults(); | |
| 152 | + desktopIcon.setLayout(null); | |
| 153 | + desktopIcon.remove(iconButton); | |
| 154 | + desktopIcon.remove(iconLabel); | |
| 155 | + } | |
| 156 | + | |
| 157 | + protected void uninstallListeners(){ | |
| 158 | + super.uninstallListeners(); | |
| 159 | + iconButton.removeActionListener(desktopIconActionListener); | |
| 160 | + iconButton.removeMouseListener(desktopIconMouseListener); | |
| 161 | + sysMenuTitlePane.uninstallListeners(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public Dimension getMinimumSize(JComponent c) { | |
| 165 | + JInternalFrame iframe = desktopIcon.getInternalFrame(); | |
| 166 | + | |
| 167 | + int w = defaultIcon.getIconWidth(); | |
| 168 | + int h = defaultIcon.getIconHeight() + LABEL_HEIGHT + LABEL_DIVIDER; | |
| 169 | + | |
| 170 | + Border border = iframe.getBorder(); | |
| 171 | + if(border != null) { | |
| 172 | + w += border.getBorderInsets(iframe).left + | |
| 173 | + border.getBorderInsets(iframe).right; | |
| 174 | + h += border.getBorderInsets(iframe).bottom + | |
| 175 | + border.getBorderInsets(iframe).top; | |
| 176 | + } | |
| 177 | + | |
| 178 | + return new Dimension(w, h); | |
| 179 | + } | |
| 180 | + | |
| 181 | + public Dimension getPreferredSize(JComponent c) { | |
| 182 | + return getMinimumSize(c); | |
| 183 | + } | |
| 184 | + | |
| 185 | + public Dimension getMaximumSize(JComponent c){ | |
| 186 | + return getMinimumSize(c); | |
| 187 | + } | |
| 188 | + | |
| 189 | + /** | |
| 190 | + * Returns the default desktop icon. | |
| 191 | + */ | |
| 192 | + public Icon getDefaultIcon() { | |
| 193 | + return defaultIcon; | |
| 194 | + } | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * Sets the icon used as the default desktop icon. | |
| 198 | + */ | |
| 199 | + public void setDefaultIcon(Icon newIcon) { | |
| 200 | + defaultIcon = newIcon; | |
| 201 | + } | |
| 202 | + | |
| 203 | + protected class IconLabel extends JPanel { | |
| 204 | + JInternalFrame frame; | |
| 205 | + | |
| 206 | + IconLabel(JInternalFrame f) { | |
| 207 | + super(); | |
| 208 | + this.frame = f; | |
| 209 | + setFont(defaultTitleFont); | |
| 210 | + | |
| 211 | + // Forward mouse events to titlebar for moves. | |
| 212 | + addMouseMotionListener(new MouseMotionListener() { | |
| 213 | + public void mouseDragged(MouseEvent e) { | |
| 214 | + forwardEventToParent(e); | |
| 215 | + } | |
| 216 | + public void mouseMoved(MouseEvent e) { | |
| 217 | + forwardEventToParent(e); | |
| 218 | + } | |
| 219 | + }); | |
| 220 | + addMouseListener(new MouseListener() { | |
| 221 | + public void mouseClicked(MouseEvent e) { | |
| 222 | + forwardEventToParent(e); | |
| 223 | + } | |
| 224 | + public void mousePressed(MouseEvent e) { | |
| 225 | + forwardEventToParent(e); | |
| 226 | + } | |
| 227 | + public void mouseReleased(MouseEvent e) { | |
| 228 | + forwardEventToParent(e); | |
| 229 | + } | |
| 230 | + public void mouseEntered(MouseEvent e) { | |
| 231 | + forwardEventToParent(e); | |
| 232 | + } | |
| 233 | + public void mouseExited(MouseEvent e) { | |
| 234 | + forwardEventToParent(e); | |
| 235 | + } | |
| 236 | + }); | |
| 237 | + } | |
| 238 | + | |
| 239 | + void forwardEventToParent(MouseEvent e) { | |
| 240 | + getParent().dispatchEvent(new MouseEvent( | |
| 241 | + getParent(), e.getID(), e.getWhen(), e.getModifiers(), | |
| 242 | + e.getX(), e.getY(), e.getXOnScreen(), | |
| 243 | + e.getYOnScreen(), e.getClickCount(), | |
| 244 | + e.isPopupTrigger(), MouseEvent.NOBUTTON)); | |
| 245 | + } | |
| 246 | + | |
| 247 | + public boolean isFocusTraversable() { | |
| 248 | + return false; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public Dimension getMinimumSize() { | |
| 252 | + return new Dimension(defaultIcon.getIconWidth() + 1, | |
| 253 | + LABEL_HEIGHT + LABEL_DIVIDER); | |
| 254 | + } | |
| 255 | + | |
| 256 | + public Dimension getPreferredSize() { | |
| 257 | + String title = frame.getTitle(); | |
| 258 | + FontMetrics fm = frame.getFontMetrics(defaultTitleFont); | |
| 259 | + int w = 4; | |
| 260 | + if (title != null) { | |
| 261 | + w += SwingUtilities2.stringWidth(frame, fm, title); | |
| 262 | + } | |
| 263 | + return new Dimension(w, LABEL_HEIGHT + LABEL_DIVIDER); | |
| 264 | + } | |
| 265 | + | |
| 266 | + public void paint(Graphics g) { | |
| 267 | + super.paint(g); | |
| 268 | + | |
| 269 | + // touch-up frame | |
| 270 | + int maxX = getWidth() - 1; | |
| 271 | + Color shadow = | |
| 272 | + UIManager.getColor("inactiveCaptionBorder").darker().darker(); | |
| 273 | + g.setColor(shadow); | |
| 274 | + g.setClip(0, 0, getWidth(), getHeight()); | |
| 275 | + g.drawLine(maxX - 1, 1, maxX - 1, 1); | |
| 276 | + g.drawLine(maxX, 0, maxX, 0); | |
| 277 | + | |
| 278 | + // fill background | |
| 279 | + g.setColor(UIManager.getColor("inactiveCaption")); | |
| 280 | + g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1); | |
| 281 | + | |
| 282 | + // draw text -- clipping to truncate text like CDE/Motif | |
| 283 | + g.setClip(2, 1, maxX - 4, LABEL_HEIGHT); | |
| 284 | + int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g). | |
| 285 | + getDescent(); | |
| 286 | + g.setColor(UIManager.getColor("inactiveCaptionText")); | |
| 287 | + String title = frame.getTitle(); | |
| 288 | + if (title != null) { | |
| 289 | + SwingUtilities2.drawString(frame, g, title, 4, y); | |
| 290 | + } | |
| 291 | + } | |
| 292 | + } | |
| 293 | + | |
| 294 | + protected class IconButton extends JButton { | |
| 295 | + Icon icon; | |
| 296 | + | |
| 297 | + IconButton(Icon icon) { | |
| 298 | + super(icon); | |
| 299 | + this.icon = icon; | |
| 300 | + // Forward mouse events to titlebar for moves. | |
| 301 | + addMouseMotionListener(new MouseMotionListener() { | |
| 302 | + public void mouseDragged(MouseEvent e) { | |
| 303 | + forwardEventToParent(e); | |
| 304 | + } | |
| 305 | + public void mouseMoved(MouseEvent e) { | |
| 306 | + forwardEventToParent(e); | |
| 307 | + } | |
| 308 | + }); | |
| 309 | + addMouseListener(new MouseListener() { | |
| 310 | + public void mouseClicked(MouseEvent e) { | |
| 311 | + forwardEventToParent(e); | |
| 312 | + } | |
| 313 | + public void mousePressed(MouseEvent e) { | |
| 314 | + forwardEventToParent(e); | |
| 315 | + } | |
| 316 | + public void mouseReleased(MouseEvent e) { | |
| 317 | + if (!systemMenu.isShowing()) { | |
| 318 | + forwardEventToParent(e); | |
| 319 | + } | |
| 320 | + } | |
| 321 | + public void mouseEntered(MouseEvent e) { | |
| 322 | + forwardEventToParent(e); | |
| 323 | + } | |
| 324 | + public void mouseExited(MouseEvent e) { | |
| 325 | + forwardEventToParent(e); | |
| 326 | + } | |
| 327 | + }); | |
| 328 | + } | |
| 329 | + | |
| 330 | + void forwardEventToParent(MouseEvent e) { | |
| 331 | + getParent().dispatchEvent(new MouseEvent( | |
| 332 | + getParent(), e.getID(), e.getWhen(), e.getModifiers(), | |
| 333 | + e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), | |
| 334 | + e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON )); | |
| 335 | + } | |
| 336 | + | |
| 337 | + public boolean isFocusTraversable() { | |
| 338 | + return false; | |
| 339 | + } | |
| 340 | + } | |
| 341 | + | |
| 342 | + | |
| 343 | + protected class DesktopIconActionListener implements ActionListener { | |
| 344 | + public void actionPerformed(ActionEvent e){ | |
| 345 | + systemMenu.show(iconButton, 0, getDesktopIcon().getHeight()); | |
| 346 | + } | |
| 347 | + } | |
| 348 | + | |
| 349 | + protected class DesktopIconMouseListener extends MouseAdapter { | |
| 350 | + // if we drag or move we should deengage the popup | |
| 351 | + public void mousePressed(MouseEvent e){ | |
| 352 | + if (e.getClickCount() > 1) { | |
| 353 | + try { | |
| 354 | + getFrame().setIcon(false); | |
| 355 | + } catch (PropertyVetoException e2){ } | |
| 356 | + systemMenu.setVisible(false); | |
| 357 | + /* the mouse release will not get reported correctly, | |
| 358 | + because the icon will no longer be in the hierarchy; | |
| 359 | + maybe that should be fixed, but until it is, we need | |
| 360 | + to do the required cleanup here. */ | |
| 361 | + getFrame().getDesktopPane().getDesktopManager().endDraggingFrame((JComponent)e.getSource()); | |
| 362 | + } | |
| 363 | + } | |
| 364 | + } | |
| 365 | +} | |
| @@ -0,0 +1,267 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import javax.swing.*; | |
| 29 | +import java.awt.Rectangle; | |
| 30 | +import java.awt.Dimension; | |
| 31 | +import java.awt.Insets; | |
| 32 | +import java.awt.Color; | |
| 33 | +import java.awt.Graphics; | |
| 34 | +import java.awt.Component; | |
| 35 | +import java.awt.Point; | |
| 36 | +import javax.swing.plaf.*; | |
| 37 | +import java.io.Serializable; | |
| 38 | + | |
| 39 | +/** | |
| 40 | + * <p> | |
| 41 | + * <strong>Warning:</strong> | |
| 42 | + * Serialized objects of this class will not be compatible with | |
| 43 | + * future Swing releases. The current serialization support is appropriate | |
| 44 | + * for short term storage or RMI between applications running the same | |
| 45 | + * version of Swing. A future release of Swing will provide support for | |
| 46 | + * long term persistence. | |
| 47 | + * | |
| 48 | + * @author David Kloba | |
| 49 | + */ | |
| 50 | +public class MotifDesktopPaneUI extends javax.swing.plaf.basic.BasicDesktopPaneUI | |
| 51 | +{ | |
| 52 | + | |
| 53 | +/// DesktopPaneUI methods | |
| 54 | + public static ComponentUI createUI(JComponent d) { | |
| 55 | + return new MotifDesktopPaneUI(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public MotifDesktopPaneUI() { | |
| 59 | + } | |
| 60 | + | |
| 61 | + protected void installDesktopManager() { | |
| 62 | + desktopManager = desktop.getDesktopManager(); | |
| 63 | + if(desktopManager == null) { | |
| 64 | + desktopManager = new MotifDesktopManager(); | |
| 65 | + desktop.setDesktopManager(desktopManager); | |
| 66 | + ((MotifDesktopManager)desktopManager).adjustIcons(desktop); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + public Insets getInsets(JComponent c) {return new Insets(0,0,0,0);} | |
| 71 | + | |
| 72 | +//////////////////////////////////////////////////////////////////////////////////// | |
| 73 | +/// DragPane class | |
| 74 | +//////////////////////////////////////////////////////////////////////////////////// | |
| 75 | + private class DragPane extends JComponent { | |
| 76 | + public void paint(Graphics g) { | |
| 77 | + g.setColor(Color.darkGray); | |
| 78 | + g.drawRect(0, 0, getWidth()-1, getHeight()-1); | |
| 79 | + } | |
| 80 | + }; | |
| 81 | + | |
| 82 | +//////////////////////////////////////////////////////////////////////////////////// | |
| 83 | +/// MotifDesktopManager class | |
| 84 | +//////////////////////////////////////////////////////////////////////////////////// | |
| 85 | + private class MotifDesktopManager extends DefaultDesktopManager implements Serializable, UIResource { | |
| 86 | + JComponent dragPane; | |
| 87 | + boolean usingDragPane = false; | |
| 88 | + private transient JLayeredPane layeredPaneForDragPane; | |
| 89 | + int iconWidth, iconHeight; | |
| 90 | + | |
| 91 | + // PENDING(klobad) this should be optimized | |
| 92 | + public void setBoundsForFrame(JComponent f, int newX, int newY, | |
| 93 | + int newWidth, int newHeight) { | |
| 94 | + if(!usingDragPane) { | |
| 95 | + boolean didResize; | |
| 96 | + didResize = (f.getWidth() != newWidth || f.getHeight() != newHeight); | |
| 97 | + Rectangle r = f.getBounds(); | |
| 98 | + f.setBounds(newX, newY, newWidth, newHeight); | |
| 99 | + SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r); | |
| 100 | + f.getParent().repaint(r.x, r.y, r.width, r.height); | |
| 101 | + if(didResize) { | |
| 102 | + f.validate(); | |
| 103 | + } | |
| 104 | + } else { | |
| 105 | + Rectangle r = dragPane.getBounds(); | |
| 106 | + dragPane.setBounds(newX, newY, newWidth, newHeight); | |
| 107 | + SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r); | |
| 108 | + dragPane.getParent().repaint(r.x, r.y, r.width, r.height); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + public void beginDraggingFrame(JComponent f) { | |
| 113 | + usingDragPane = false; | |
| 114 | + if(f.getParent() instanceof JLayeredPane) { | |
| 115 | + if(dragPane == null) | |
| 116 | + dragPane = new DragPane(); | |
| 117 | + layeredPaneForDragPane = (JLayeredPane)f.getParent(); | |
| 118 | + layeredPaneForDragPane.setLayer(dragPane, Integer.MAX_VALUE); | |
| 119 | + dragPane.setBounds(f.getX(), f.getY(), f.getWidth(), f.getHeight()); | |
| 120 | + layeredPaneForDragPane.add(dragPane); | |
| 121 | + usingDragPane = true; | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void dragFrame(JComponent f, int newX, int newY) { | |
| 126 | + setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight()); | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void endDraggingFrame(JComponent f) { | |
| 130 | + if(usingDragPane) { | |
| 131 | + layeredPaneForDragPane.remove(dragPane); | |
| 132 | + usingDragPane = false; | |
| 133 | + if (f instanceof JInternalFrame) { | |
| 134 | + setBoundsForFrame(f, dragPane.getX(), dragPane.getY(), | |
| 135 | + dragPane.getWidth(), dragPane.getHeight()); | |
| 136 | + } else if (f instanceof JInternalFrame.JDesktopIcon) { | |
| 137 | + adjustBoundsForIcon((JInternalFrame.JDesktopIcon)f, | |
| 138 | + dragPane.getX(), dragPane.getY()); | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void beginResizingFrame(JComponent f, int direction) { | |
| 144 | + usingDragPane = false; | |
| 145 | + if(f.getParent() instanceof JLayeredPane) { | |
| 146 | + if(dragPane == null) | |
| 147 | + dragPane = new DragPane(); | |
| 148 | + JLayeredPane p = (JLayeredPane)f.getParent(); | |
| 149 | + p.setLayer(dragPane, Integer.MAX_VALUE); | |
| 150 | + dragPane.setBounds(f.getX(), f.getY(), | |
| 151 | + f.getWidth(), f.getHeight()); | |
| 152 | + p.add(dragPane); | |
| 153 | + usingDragPane = true; | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void resizeFrame(JComponent f, int newX, int newY, | |
| 158 | + int newWidth, int newHeight) { | |
| 159 | + setBoundsForFrame(f, newX, newY, newWidth, newHeight); | |
| 160 | + } | |
| 161 | + | |
| 162 | + public void endResizingFrame(JComponent f) { | |
| 163 | + if(usingDragPane) { | |
| 164 | + JLayeredPane p = (JLayeredPane)f.getParent(); | |
| 165 | + p.remove(dragPane); | |
| 166 | + usingDragPane = false; | |
| 167 | + setBoundsForFrame(f, dragPane.getX(), dragPane.getY(), | |
| 168 | + dragPane.getWidth(), dragPane.getHeight()); | |
| 169 | + } | |
| 170 | + } | |
| 171 | + | |
| 172 | + public void iconifyFrame(JInternalFrame f) { | |
| 173 | + JInternalFrame.JDesktopIcon icon = f.getDesktopIcon(); | |
| 174 | + Point p = icon.getLocation(); | |
| 175 | + adjustBoundsForIcon(icon, p.x, p.y); | |
| 176 | + super.iconifyFrame(f); | |
| 177 | + } | |
| 178 | + | |
| 179 | + /** | |
| 180 | + * Change positions of icons in the desktop pane so that | |
| 181 | + * they do not overlap | |
| 182 | + */ | |
| 183 | + protected void adjustIcons(JDesktopPane desktop) { | |
| 184 | + // We need to know Motif icon size | |
| 185 | + JInternalFrame.JDesktopIcon icon = new JInternalFrame.JDesktopIcon( | |
| 186 | + new JInternalFrame()); | |
| 187 | + Dimension iconSize = icon.getPreferredSize(); | |
| 188 | + iconWidth = iconSize.width; | |
| 189 | + iconHeight = iconSize.height; | |
| 190 | + | |
| 191 | + JInternalFrame[] frames = desktop.getAllFrames(); | |
| 192 | + for (int i=0; i<frames.length; i++) { | |
| 193 | + icon = frames[i].getDesktopIcon(); | |
| 194 | + Point ip = icon.getLocation(); | |
| 195 | + adjustBoundsForIcon(icon, ip.x, ip.y); | |
| 196 | + } | |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * Change positions of icon so that it doesn't overlap | |
| 201 | + * other icons. | |
| 202 | + */ | |
| 203 | + protected void adjustBoundsForIcon(JInternalFrame.JDesktopIcon icon, | |
| 204 | + int x, int y) { | |
| 205 | + JDesktopPane c = icon.getDesktopPane(); | |
| 206 | + | |
| 207 | + int maxy = c.getHeight(); | |
| 208 | + int w = iconWidth; | |
| 209 | + int h = iconHeight; | |
| 210 | + c.repaint(x, y, w, h); | |
| 211 | + x = x < 0 ? 0 : x; | |
| 212 | + y = y < 0 ? 0 : y; | |
| 213 | + | |
| 214 | + /* Fix for disappearing icons. If the y value is maxy then this | |
| 215 | + * algorithm would place the icon in a non-displayed cell. Never | |
| 216 | + * to be ssen again.*/ | |
| 217 | + y = y >= maxy ? (maxy - 1) : y; | |
| 218 | + | |
| 219 | + /* Compute the offset for the cell we are trying to go in. */ | |
| 220 | + int lx = (x / w) * w; | |
| 221 | + int ygap = maxy % h; | |
| 222 | + int ly = ((y-ygap) / h) * h + ygap; | |
| 223 | + | |
| 224 | + /* How far are we into the cell we dropped the icon in. */ | |
| 225 | + int dx = x - lx; | |
| 226 | + int dy = y - ly; | |
| 227 | + | |
| 228 | + /* Set coordinates for the icon. */ | |
| 229 | + x = dx < w/2 ? lx: lx + w; | |
| 230 | + y = dy < h/2 ? ly: ((ly + h) < maxy ? ly + h: ly); | |
| 231 | + | |
| 232 | + while (getIconAt(c, icon, x, y) != null) { | |
| 233 | + x += w; | |
| 234 | + } | |
| 235 | + | |
| 236 | + /* Cancel the move if the x value was moved off screen. */ | |
| 237 | + if (x > c.getWidth()) { | |
| 238 | + return; | |
| 239 | + } | |
| 240 | + if (icon.getParent() != null) { | |
| 241 | + setBoundsForFrame(icon, x, y, w, h); | |
| 242 | + } else { | |
| 243 | + icon.setLocation(x, y); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + protected JInternalFrame.JDesktopIcon getIconAt(JDesktopPane desktop, | |
| 248 | + JInternalFrame.JDesktopIcon icon, int x, int y) { | |
| 249 | + | |
| 250 | + JInternalFrame.JDesktopIcon currentIcon = null; | |
| 251 | + Component[] components = desktop.getComponents(); | |
| 252 | + | |
| 253 | + for (int i=0; i<components.length; i++) { | |
| 254 | + Component comp = components[i]; | |
| 255 | + if (comp instanceof JInternalFrame.JDesktopIcon && | |
| 256 | + comp != icon) { | |
| 257 | + | |
| 258 | + Point p = comp.getLocation(); | |
| 259 | + if (p.x == x && p.y == y) { | |
| 260 | + return (JInternalFrame.JDesktopIcon)comp; | |
| 261 | + } | |
| 262 | + } | |
| 263 | + } | |
| 264 | + return null; | |
| 265 | + } | |
| 266 | + }; /// END of MotifDesktopManager | |
| 267 | +} | |
| @@ -0,0 +1,68 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.motif; | |
| 26 | + | |
| 27 | +import javax.swing.*; | |
| 28 | +import javax.swing.text.*; | |
| 29 | +import javax.swing.plaf.*; | |
| 30 | +import javax.swing.plaf.basic.BasicEditorPaneUI; | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * Provides the look and feel for an pluggable content-type text editor. | |
| 34 | + * <p> | |
| 35 | + * <strong>Warning:</strong> | |
| 36 | + * Serialized objects of this class will not be compatible with | |
| 37 | + * future Swing releases. The current serialization support is appropriate | |
| 38 | + * for short term storage or RMI between applications running the same | |
| 39 | + * version of Swing. A future release of Swing will provide support for | |
| 40 | + * long term persistence. | |
| 41 | + * | |
| 42 | + * @author Timothy Prinzing | |
| 43 | + */ | |
| 44 | +public class MotifEditorPaneUI extends BasicEditorPaneUI { | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Creates a UI for the JTextPane. | |
| 48 | + * | |
| 49 | + * @param c the JTextPane component | |
| 50 | + * @return the UI | |
| 51 | + */ | |
| 52 | + public static ComponentUI createUI(JComponent c) { | |
| 53 | + return new MotifEditorPaneUI(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Creates the object to use for a caret. By default an | |
| 58 | + * instance of MotifTextUI.MotifCaret is created. This method | |
| 59 | + * can be redefined to provide something else that implements | |
| 60 | + * the Caret interface. | |
| 61 | + * | |
| 62 | + * @return the caret object | |
| 63 | + */ | |
| 64 | + protected Caret createCaret() { | |
| 65 | + return MotifTextUI.createCaret(); | |
| 66 | + } | |
| 67 | + | |
| 68 | +} | |
| @@ -0,0 +1,846 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import javax.swing.*; | |
| 29 | +import javax.swing.filechooser.*; | |
| 30 | +import javax.swing.event.*; | |
| 31 | +import javax.swing.plaf.*; | |
| 32 | +import javax.swing.plaf.basic.*; | |
| 33 | +import java.awt.*; | |
| 34 | +import java.awt.event.MouseAdapter; | |
| 35 | +import java.awt.event.MouseEvent; | |
| 36 | +import java.beans.*; | |
| 37 | +import java.io.File; | |
| 38 | +import java.io.IOException; | |
| 39 | +import java.util.*; | |
| 40 | +import sun.awt.shell.ShellFolder; | |
| 41 | +import sun.swing.SwingUtilities2; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * Motif FileChooserUI. | |
| 45 | + * | |
| 46 | + * @author Jeff Dinkins | |
| 47 | + */ | |
| 48 | +public class MotifFileChooserUI extends BasicFileChooserUI { | |
| 49 | + | |
| 50 | + private FilterComboBoxModel filterComboBoxModel; | |
| 51 | + | |
| 52 | + protected JList directoryList = null; | |
| 53 | + protected JList fileList = null; | |
| 54 | + | |
| 55 | + protected JTextField pathField = null; | |
| 56 | + protected JComboBox filterComboBox = null; | |
| 57 | + protected JTextField filenameTextField = null; | |
| 58 | + | |
| 59 | + private static final Dimension hstrut10 = new Dimension(10, 1); | |
| 60 | + private static final Dimension vstrut10 = new Dimension(1, 10); | |
| 61 | + | |
| 62 | + private static final Insets insets = new Insets(10, 10, 10, 10); | |
| 63 | + | |
| 64 | + private static Dimension prefListSize = new Dimension(75, 150); | |
| 65 | + | |
| 66 | + private static Dimension WITH_ACCELERATOR_PREF_SIZE = new Dimension(650, 450); | |
| 67 | + private static Dimension PREF_SIZE = new Dimension(350, 450); | |
| 68 | + private static Dimension MIN_SIZE = new Dimension(200, 300); | |
| 69 | + | |
| 70 | + private static Dimension PREF_ACC_SIZE = new Dimension(10, 10); | |
| 71 | + private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1); | |
| 72 | + | |
| 73 | + private static Dimension MAX_SIZE = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); | |
| 74 | + | |
| 75 | + private static final Insets buttonMargin = new Insets(3, 3, 3, 3); | |
| 76 | + | |
| 77 | + private JPanel bottomPanel; | |
| 78 | + | |
| 79 | + protected JButton approveButton; | |
| 80 | + | |
| 81 | + private String enterFolderNameLabelText = null; | |
| 82 | + private int enterFolderNameLabelMnemonic = 0; | |
| 83 | + private String enterFileNameLabelText = null; | |
| 84 | + private int enterFileNameLabelMnemonic = 0; | |
| 85 | + | |
| 86 | + private String filesLabelText = null; | |
| 87 | + private int filesLabelMnemonic = 0; | |
| 88 | + | |
| 89 | + private String foldersLabelText = null; | |
| 90 | + private int foldersLabelMnemonic = 0; | |
| 91 | + | |
| 92 | + private String pathLabelText = null; | |
| 93 | + private int pathLabelMnemonic = 0; | |
| 94 | + | |
| 95 | + private String filterLabelText = null; | |
| 96 | + private int filterLabelMnemonic = 0; | |
| 97 | + | |
| 98 | + private JLabel fileNameLabel; | |
| 99 | + | |
| 100 | + private void populateFileNameLabel() { | |
| 101 | + if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) { | |
| 102 | + fileNameLabel.setText(enterFolderNameLabelText); | |
| 103 | + fileNameLabel.setDisplayedMnemonic(enterFolderNameLabelMnemonic); | |
| 104 | + } else { | |
| 105 | + fileNameLabel.setText(enterFileNameLabelText); | |
| 106 | + fileNameLabel.setDisplayedMnemonic(enterFileNameLabelMnemonic); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 110 | + private String fileNameString(File file) { | |
| 111 | + if (file == null) { | |
| 112 | + return null; | |
| 113 | + } else { | |
| 114 | + JFileChooser fc = getFileChooser(); | |
| 115 | + if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) { | |
| 116 | + return file.getPath(); | |
| 117 | + } else { | |
| 118 | + return file.getName(); | |
| 119 | + } | |
| 120 | + } | |
| 121 | + } | |
| 122 | + | |
| 123 | + private String fileNameString(File[] files) { | |
| 124 | + StringBuffer buf = new StringBuffer(); | |
| 125 | + for (int i = 0; files != null && i < files.length; i++) { | |
| 126 | + if (i > 0) { | |
| 127 | + buf.append(" "); | |
| 128 | + } | |
| 129 | + if (files.length > 1) { | |
| 130 | + buf.append("\""); | |
| 131 | + } | |
| 132 | + buf.append(fileNameString(files[i])); | |
| 133 | + if (files.length > 1) { | |
| 134 | + buf.append("\""); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + return buf.toString(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + public MotifFileChooserUI(JFileChooser filechooser) { | |
| 141 | + super(filechooser); | |
| 142 | + } | |
| 143 | + | |
| 144 | + public String getFileName() { | |
| 145 | + if(filenameTextField != null) { | |
| 146 | + return filenameTextField.getText(); | |
| 147 | + } else { | |
| 148 | + return null; | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + public void setFileName(String filename) { | |
| 153 | + if(filenameTextField != null) { | |
| 154 | + filenameTextField.setText(filename); | |
| 155 | + } | |
| 156 | + } | |
| 157 | + | |
| 158 | + public String getDirectoryName() { | |
| 159 | + return pathField.getText(); | |
| 160 | + } | |
| 161 | + | |
| 162 | + public void setDirectoryName(String dirname) { | |
| 163 | + pathField.setText(dirname); | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void ensureFileIsVisible(JFileChooser fc, File f) { | |
| 167 | + // PENDING(jeff) | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void rescanCurrentDirectory(JFileChooser fc) { | |
| 171 | + getModel().validateFileCache(); | |
| 172 | + } | |
| 173 | + | |
| 174 | + public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) { | |
| 175 | + return new PropertyChangeListener() { | |
| 176 | + public void propertyChange(PropertyChangeEvent e) { | |
| 177 | + String prop = e.getPropertyName(); | |
| 178 | + if(prop.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { | |
| 179 | + File f = (File) e.getNewValue(); | |
| 180 | + if(f != null) { | |
| 181 | + setFileName(getFileChooser().getName(f)); | |
| 182 | + } | |
| 183 | + } else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) { | |
| 184 | + File[] files = (File[]) e.getNewValue(); | |
| 185 | + JFileChooser fc = getFileChooser(); | |
| 186 | + if (files != null && files.length > 0 && (files.length > 1 || fc.isDirectorySelectionEnabled() | |
| 187 | + || !files[0].isDirectory())) { | |
| 188 | + setFileName(fileNameString(files)); | |
| 189 | + } | |
| 190 | + } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) { | |
| 191 | + fileList.clearSelection(); | |
| 192 | + } else if(prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { | |
| 193 | + directoryList.clearSelection(); | |
| 194 | + ListSelectionModel sm = directoryList.getSelectionModel(); | |
| 195 | + if (sm instanceof DefaultListSelectionModel) { | |
| 196 | + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); | |
| 197 | + sm.setAnchorSelectionIndex(0); | |
| 198 | + } | |
| 199 | + fileList.clearSelection(); | |
| 200 | + sm = fileList.getSelectionModel(); | |
| 201 | + if (sm instanceof DefaultListSelectionModel) { | |
| 202 | + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); | |
| 203 | + sm.setAnchorSelectionIndex(0); | |
| 204 | + } | |
| 205 | + File currentDirectory = getFileChooser().getCurrentDirectory(); | |
| 206 | + if(currentDirectory != null) { | |
| 207 | + try { | |
| 208 | + setDirectoryName(ShellFolder.getNormalizedFile((File)e.getNewValue()).getPath()); | |
| 209 | + } catch (IOException ioe) { | |
| 210 | + setDirectoryName(((File)e.getNewValue()).getAbsolutePath()); | |
| 211 | + } | |
| 212 | + if ((getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) && !getFileChooser().isMultiSelectionEnabled()) { | |
| 213 | + setFileName(getDirectoryName()); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + } else if(prop.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) { | |
| 217 | + if (fileNameLabel != null) { | |
| 218 | + populateFileNameLabel(); | |
| 219 | + } | |
| 220 | + directoryList.clearSelection(); | |
| 221 | + } else if (prop.equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) { | |
| 222 | + if(getFileChooser().isMultiSelectionEnabled()) { | |
| 223 | + fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
| 224 | + } else { | |
| 225 | + fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
| 226 | + fileList.clearSelection(); | |
| 227 | + getFileChooser().setSelectedFiles(null); | |
| 228 | + } | |
| 229 | + } else if (prop.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) { | |
| 230 | + if(getAccessoryPanel() != null) { | |
| 231 | + if(e.getOldValue() != null) { | |
| 232 | + getAccessoryPanel().remove((JComponent) e.getOldValue()); | |
| 233 | + } | |
| 234 | + JComponent accessory = (JComponent) e.getNewValue(); | |
| 235 | + if(accessory != null) { | |
| 236 | + getAccessoryPanel().add(accessory, BorderLayout.CENTER); | |
| 237 | + getAccessoryPanel().setPreferredSize(PREF_ACC_SIZE); | |
| 238 | + getAccessoryPanel().setMaximumSize(MAX_SIZE); | |
| 239 | + } else { | |
| 240 | + getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE); | |
| 241 | + getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + } else if (prop.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) || | |
| 245 | + prop.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY) || | |
| 246 | + prop.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) { | |
| 247 | + approveButton.setText(getApproveButtonText(getFileChooser())); | |
| 248 | + approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser())); | |
| 249 | + } else if (prop.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) { | |
| 250 | + doControlButtonsChanged(e); | |
| 251 | + } else if (prop.equals("componentOrientation")) { | |
| 252 | + ComponentOrientation o = (ComponentOrientation)e.getNewValue(); | |
| 253 | + JFileChooser cc = (JFileChooser)e.getSource(); | |
| 254 | + if (o != (ComponentOrientation)e.getOldValue()) { | |
| 255 | + cc.applyComponentOrientation(o); | |
| 256 | + } | |
| 257 | + } | |
| 258 | + } | |
| 259 | + }; | |
| 260 | + } | |
| 261 | + | |
| 262 | + // | |
| 263 | + // ComponentUI Interface Implementation methods | |
| 264 | + // | |
| 265 | + public static ComponentUI createUI(JComponent c) { | |
| 266 | + return new MotifFileChooserUI((JFileChooser)c); | |
| 267 | + } | |
| 268 | + | |
| 269 | + public void installUI(JComponent c) { | |
| 270 | + super.installUI(c); | |
| 271 | + } | |
| 272 | + | |
| 273 | + public void uninstallUI(JComponent c) { | |
| 274 | + c.removePropertyChangeListener(filterComboBoxModel); | |
| 275 | + approveButton.removeActionListener(getApproveSelectionAction()); | |
| 276 | + filenameTextField.removeActionListener(getApproveSelectionAction()); | |
| 277 | + super.uninstallUI(c); | |
| 278 | + } | |
| 279 | + | |
| 280 | + public void installComponents(JFileChooser fc) { | |
| 281 | + fc.setLayout(new BorderLayout(10, 10)); | |
| 282 | + fc.setAlignmentX(JComponent.CENTER_ALIGNMENT); | |
| 283 | + | |
| 284 | + JPanel interior = new JPanel() { | |
| 285 | + public Insets getInsets() { | |
| 286 | + return insets; | |
| 287 | + } | |
| 288 | + }; | |
| 289 | + interior.setInheritsPopupMenu(true); | |
| 290 | + align(interior); | |
| 291 | + interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS)); | |
| 292 | + | |
| 293 | + fc.add(interior, BorderLayout.CENTER); | |
| 294 | + | |
| 295 | + // PENDING(jeff) - I18N | |
| 296 | + JLabel l = new JLabel(pathLabelText); | |
| 297 | + l.setDisplayedMnemonic(pathLabelMnemonic); | |
| 298 | + align(l); | |
| 299 | + interior.add(l); | |
| 300 | + | |
| 301 | + File currentDirectory = fc.getCurrentDirectory(); | |
| 302 | + String curDirName = null; | |
| 303 | + if(currentDirectory != null) { | |
| 304 | + curDirName = currentDirectory.getPath(); | |
| 305 | + } | |
| 306 | + pathField = new JTextField(curDirName) { | |
| 307 | + public Dimension getMaximumSize() { | |
| 308 | + Dimension d = super.getMaximumSize(); | |
| 309 | + d.height = getPreferredSize().height; | |
| 310 | + return d; | |
| 311 | + } | |
| 312 | + }; | |
| 313 | + pathField.setInheritsPopupMenu(true); | |
| 314 | + l.setLabelFor(pathField); | |
| 315 | + align(pathField); | |
| 316 | + | |
| 317 | + // Change to folder on return | |
| 318 | + pathField.addActionListener(getUpdateAction()); | |
| 319 | + interior.add(pathField); | |
| 320 | + | |
| 321 | + interior.add(Box.createRigidArea(vstrut10)); | |
| 322 | + | |
| 323 | + | |
| 324 | + // CENTER: left, right accessory | |
| 325 | + JPanel centerPanel = new JPanel(); | |
| 326 | + centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS)); | |
| 327 | + align(centerPanel); | |
| 328 | + | |
| 329 | + // left panel - Filter & folderList | |
| 330 | + JPanel leftPanel = new JPanel(); | |
| 331 | + leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); | |
| 332 | + align(leftPanel); | |
| 333 | + | |
| 334 | + // add the filter PENDING(jeff) - I18N | |
| 335 | + l = new JLabel(filterLabelText); | |
| 336 | + l.setDisplayedMnemonic(filterLabelMnemonic); | |
| 337 | + align(l); | |
| 338 | + leftPanel.add(l); | |
| 339 | + | |
| 340 | + filterComboBox = new JComboBox() { | |
| 341 | + public Dimension getMaximumSize() { | |
| 342 | + Dimension d = super.getMaximumSize(); | |
| 343 | + d.height = getPreferredSize().height; | |
| 344 | + return d; | |
| 345 | + } | |
| 346 | + }; | |
| 347 | + filterComboBox.setInheritsPopupMenu(true); | |
| 348 | + l.setLabelFor(filterComboBox); | |
| 349 | + filterComboBoxModel = createFilterComboBoxModel(); | |
| 350 | + filterComboBox.setModel(filterComboBoxModel); | |
| 351 | + filterComboBox.setRenderer(createFilterComboBoxRenderer()); | |
| 352 | + fc.addPropertyChangeListener(filterComboBoxModel); | |
| 353 | + align(filterComboBox); | |
| 354 | + leftPanel.add(filterComboBox); | |
| 355 | + | |
| 356 | + // leftPanel.add(Box.createRigidArea(vstrut10)); | |
| 357 | + | |
| 358 | + // Add the Folder List PENDING(jeff) - I18N | |
| 359 | + l = new JLabel(foldersLabelText); | |
| 360 | + l.setDisplayedMnemonic(foldersLabelMnemonic); | |
| 361 | + align(l); | |
| 362 | + leftPanel.add(l); | |
| 363 | + JScrollPane sp = createDirectoryList(); | |
| 364 | + sp.getVerticalScrollBar().setFocusable(false); | |
| 365 | + sp.getHorizontalScrollBar().setFocusable(false); | |
| 366 | + sp.setInheritsPopupMenu(true); | |
| 367 | + l.setLabelFor(sp.getViewport().getView()); | |
| 368 | + leftPanel.add(sp); | |
| 369 | + leftPanel.setInheritsPopupMenu(true); | |
| 370 | + | |
| 371 | + | |
| 372 | + // create files list | |
| 373 | + JPanel rightPanel = new JPanel(); | |
| 374 | + align(rightPanel); | |
| 375 | + rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS)); | |
| 376 | + rightPanel.setInheritsPopupMenu(true); | |
| 377 | + | |
| 378 | + l = new JLabel(filesLabelText); | |
| 379 | + l.setDisplayedMnemonic(filesLabelMnemonic); | |
| 380 | + align(l); | |
| 381 | + rightPanel.add(l); | |
| 382 | + sp = createFilesList(); | |
| 383 | + l.setLabelFor(sp.getViewport().getView()); | |
| 384 | + rightPanel.add(sp); | |
| 385 | + sp.setInheritsPopupMenu(true); | |
| 386 | + | |
| 387 | + centerPanel.add(leftPanel); | |
| 388 | + centerPanel.add(Box.createRigidArea(hstrut10)); | |
| 389 | + centerPanel.add(rightPanel); | |
| 390 | + centerPanel.setInheritsPopupMenu(true); | |
| 391 | + | |
| 392 | + JComponent accessoryPanel = getAccessoryPanel(); | |
| 393 | + JComponent accessory = fc.getAccessory(); | |
| 394 | + if(accessoryPanel != null) { | |
| 395 | + if(accessory == null) { | |
| 396 | + accessoryPanel.setPreferredSize(ZERO_ACC_SIZE); | |
| 397 | + accessoryPanel.setMaximumSize(ZERO_ACC_SIZE); | |
| 398 | + } else { | |
| 399 | + getAccessoryPanel().add(accessory, BorderLayout.CENTER); | |
| 400 | + accessoryPanel.setPreferredSize(PREF_ACC_SIZE); | |
| 401 | + accessoryPanel.setMaximumSize(MAX_SIZE); | |
| 402 | + } | |
| 403 | + align(accessoryPanel); | |
| 404 | + centerPanel.add(accessoryPanel); | |
| 405 | + accessoryPanel.setInheritsPopupMenu(true); | |
| 406 | + } | |
| 407 | + interior.add(centerPanel); | |
| 408 | + interior.add(Box.createRigidArea(vstrut10)); | |
| 409 | + | |
| 410 | + // add the filename field PENDING(jeff) - I18N | |
| 411 | + fileNameLabel = new JLabel(); | |
| 412 | + populateFileNameLabel(); | |
| 413 | + align(fileNameLabel); | |
| 414 | + interior.add(fileNameLabel); | |
| 415 | + | |
| 416 | + filenameTextField = new JTextField() { | |
| 417 | + public Dimension getMaximumSize() { | |
| 418 | + Dimension d = super.getMaximumSize(); | |
| 419 | + d.height = getPreferredSize().height; | |
| 420 | + return d; | |
| 421 | + } | |
| 422 | + }; | |
| 423 | + filenameTextField.setInheritsPopupMenu(true); | |
| 424 | + fileNameLabel.setLabelFor(filenameTextField); | |
| 425 | + filenameTextField.addActionListener(getApproveSelectionAction()); | |
| 426 | + align(filenameTextField); | |
| 427 | + filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT); | |
| 428 | + interior.add(filenameTextField); | |
| 429 | + | |
| 430 | + bottomPanel = getBottomPanel(); | |
| 431 | + bottomPanel.add(new JSeparator(), BorderLayout.NORTH); | |
| 432 | + | |
| 433 | + // Add buttons | |
| 434 | + JPanel buttonPanel = new JPanel(); | |
| 435 | + align(buttonPanel); | |
| 436 | + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); | |
| 437 | + buttonPanel.add(Box.createGlue()); | |
| 438 | + | |
| 439 | + approveButton = new JButton(getApproveButtonText(fc)) { | |
| 440 | + public Dimension getMaximumSize() { | |
| 441 | + return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); | |
| 442 | + } | |
| 443 | + }; | |
| 444 | + approveButton.setMnemonic(getApproveButtonMnemonic(fc)); | |
| 445 | + approveButton.setToolTipText(getApproveButtonToolTipText(fc)); | |
| 446 | + approveButton.setInheritsPopupMenu(true); | |
| 447 | + align(approveButton); | |
| 448 | + approveButton.setMargin(buttonMargin); | |
| 449 | + approveButton.addActionListener(getApproveSelectionAction()); | |
| 450 | + buttonPanel.add(approveButton); | |
| 451 | + buttonPanel.add(Box.createGlue()); | |
| 452 | + | |
| 453 | + JButton updateButton = new JButton(updateButtonText) { | |
| 454 | + public Dimension getMaximumSize() { | |
| 455 | + return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); | |
| 456 | + } | |
| 457 | + }; | |
| 458 | + updateButton.setMnemonic(updateButtonMnemonic); | |
| 459 | + updateButton.setToolTipText(updateButtonToolTipText); | |
| 460 | + updateButton.setInheritsPopupMenu(true); | |
| 461 | + align(updateButton); | |
| 462 | + updateButton.setMargin(buttonMargin); | |
| 463 | + updateButton.addActionListener(getUpdateAction()); | |
| 464 | + buttonPanel.add(updateButton); | |
| 465 | + buttonPanel.add(Box.createGlue()); | |
| 466 | + | |
| 467 | + JButton cancelButton = new JButton(cancelButtonText) { | |
| 468 | + public Dimension getMaximumSize() { | |
| 469 | + return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); | |
| 470 | + } | |
| 471 | + }; | |
| 472 | + cancelButton.setMnemonic(cancelButtonMnemonic); | |
| 473 | + cancelButton.setToolTipText(cancelButtonToolTipText); | |
| 474 | + cancelButton.setInheritsPopupMenu(true); | |
| 475 | + align(cancelButton); | |
| 476 | + cancelButton.setMargin(buttonMargin); | |
| 477 | + cancelButton.addActionListener(getCancelSelectionAction()); | |
| 478 | + buttonPanel.add(cancelButton); | |
| 479 | + buttonPanel.add(Box.createGlue()); | |
| 480 | + | |
| 481 | + JButton helpButton = new JButton(helpButtonText) { | |
| 482 | + public Dimension getMaximumSize() { | |
| 483 | + return new Dimension(MAX_SIZE.width, this.getPreferredSize().height); | |
| 484 | + } | |
| 485 | + }; | |
| 486 | + helpButton.setMnemonic(helpButtonMnemonic); | |
| 487 | + helpButton.setToolTipText(helpButtonToolTipText); | |
| 488 | + align(helpButton); | |
| 489 | + helpButton.setMargin(buttonMargin); | |
| 490 | + helpButton.setEnabled(false); | |
| 491 | + helpButton.setInheritsPopupMenu(true); | |
| 492 | + buttonPanel.add(helpButton); | |
| 493 | + buttonPanel.add(Box.createGlue()); | |
| 494 | + buttonPanel.setInheritsPopupMenu(true); | |
| 495 | + | |
| 496 | + bottomPanel.add(buttonPanel, BorderLayout.SOUTH); | |
| 497 | + bottomPanel.setInheritsPopupMenu(true); | |
| 498 | + if (fc.getControlButtonsAreShown()) { | |
| 499 | + fc.add(bottomPanel, BorderLayout.SOUTH); | |
| 500 | + } | |
| 501 | + } | |
| 502 | + | |
| 503 | + protected JPanel getBottomPanel() { | |
| 504 | + if (bottomPanel == null) { | |
| 505 | + bottomPanel = new JPanel(new BorderLayout(0, 4)); | |
| 506 | + } | |
| 507 | + return bottomPanel; | |
| 508 | + } | |
| 509 | + | |
| 510 | + private void doControlButtonsChanged(PropertyChangeEvent e) { | |
| 511 | + if (getFileChooser().getControlButtonsAreShown()) { | |
| 512 | + getFileChooser().add(bottomPanel,BorderLayout.SOUTH); | |
| 513 | + } else { | |
| 514 | + getFileChooser().remove(getBottomPanel()); | |
| 515 | + } | |
| 516 | + } | |
| 517 | + | |
| 518 | + public void uninstallComponents(JFileChooser fc) { | |
| 519 | + fc.removeAll(); | |
| 520 | + bottomPanel = null; | |
| 521 | + if (filterComboBoxModel != null) { | |
| 522 | + fc.removePropertyChangeListener(filterComboBoxModel); | |
| 523 | + } | |
| 524 | + } | |
| 525 | + | |
| 526 | + protected void installStrings(JFileChooser fc) { | |
| 527 | + super.installStrings(fc); | |
| 528 | + | |
| 529 | + Locale l = fc.getLocale(); | |
| 530 | + | |
| 531 | + enterFolderNameLabelText = UIManager.getString("FileChooser.enterFolderNameLabelText",l); | |
| 532 | + enterFolderNameLabelMnemonic = UIManager.getInt("FileChooser.enterFolderNameLabelMnemonic"); | |
| 533 | + enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText",l); | |
| 534 | + enterFileNameLabelMnemonic = UIManager.getInt("FileChooser.enterFileNameLabelMnemonic"); | |
| 535 | + | |
| 536 | + filesLabelText = UIManager.getString("FileChooser.filesLabelText",l); | |
| 537 | + filesLabelMnemonic = UIManager.getInt("FileChooser.filesLabelMnemonic"); | |
| 538 | + | |
| 539 | + foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l); | |
| 540 | + foldersLabelMnemonic = UIManager.getInt("FileChooser.foldersLabelMnemonic"); | |
| 541 | + | |
| 542 | + pathLabelText = UIManager.getString("FileChooser.pathLabelText",l); | |
| 543 | + pathLabelMnemonic = UIManager.getInt("FileChooser.pathLabelMnemonic"); | |
| 544 | + | |
| 545 | + filterLabelText = UIManager.getString("FileChooser.filterLabelText",l); | |
| 546 | + filterLabelMnemonic = UIManager.getInt("FileChooser.filterLabelMnemonic"); | |
| 547 | + } | |
| 548 | + | |
| 549 | + protected void installIcons(JFileChooser fc) { | |
| 550 | + // Since motif doesn't have button icons, leave this empty | |
| 551 | + // which overrides the supertype icon loading | |
| 552 | + } | |
| 553 | + | |
| 554 | + protected void uninstallIcons(JFileChooser fc) { | |
| 555 | + // Since motif doesn't have button icons, leave this empty | |
| 556 | + // which overrides the supertype icon loading | |
| 557 | + } | |
| 558 | + | |
| 559 | + protected JScrollPane createFilesList() { | |
| 560 | + fileList = new JList(); | |
| 561 | + | |
| 562 | + if(getFileChooser().isMultiSelectionEnabled()) { | |
| 563 | + fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
| 564 | + } else { | |
| 565 | + fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | |
| 566 | + } | |
| 567 | + | |
| 568 | + fileList.setModel(new MotifFileListModel()); | |
| 569 | + fileList.getSelectionModel().removeSelectionInterval(0, 0); | |
| 570 | + fileList.setCellRenderer(new FileCellRenderer()); | |
| 571 | + fileList.addListSelectionListener(createListSelectionListener(getFileChooser())); | |
| 572 | + fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList)); | |
| 573 | + fileList.addMouseListener(new MouseAdapter() { | |
| 574 | + public void mouseClicked(MouseEvent e) { | |
| 575 | + JFileChooser chooser = getFileChooser(); | |
| 576 | + if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) { | |
| 577 | + int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint()); | |
| 578 | + if (index >= 0) { | |
| 579 | + File file = (File) fileList.getModel().getElementAt(index); | |
| 580 | + setFileName(chooser.getName(file)); | |
| 581 | + } | |
| 582 | + } | |
| 583 | + } | |
| 584 | + }); | |
| 585 | + align(fileList); | |
| 586 | + JScrollPane scrollpane = new JScrollPane(fileList); | |
| 587 | + scrollpane.setPreferredSize(prefListSize); | |
| 588 | + scrollpane.setMaximumSize(MAX_SIZE); | |
| 589 | + align(scrollpane); | |
| 590 | + fileList.setInheritsPopupMenu(true); | |
| 591 | + scrollpane.setInheritsPopupMenu(true); | |
| 592 | + return scrollpane; | |
| 593 | + } | |
| 594 | + | |
| 595 | + protected JScrollPane createDirectoryList() { | |
| 596 | + directoryList = new JList(); | |
| 597 | + align(directoryList); | |
| 598 | + | |
| 599 | + directoryList.setCellRenderer(new DirectoryCellRenderer()); | |
| 600 | + directoryList.setModel(new MotifDirectoryListModel()); | |
| 601 | + directoryList.getSelectionModel().removeSelectionInterval(0, 0); | |
| 602 | + directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList)); | |
| 603 | + directoryList.addListSelectionListener(createListSelectionListener(getFileChooser())); | |
| 604 | + directoryList.setInheritsPopupMenu(true); | |
| 605 | + | |
| 606 | + JScrollPane scrollpane = new JScrollPane(directoryList); | |
| 607 | + scrollpane.setMaximumSize(MAX_SIZE); | |
| 608 | + scrollpane.setPreferredSize(prefListSize); | |
| 609 | + scrollpane.setInheritsPopupMenu(true); | |
| 610 | + align(scrollpane); | |
| 611 | + return scrollpane; | |
| 612 | + } | |
| 613 | + | |
| 614 | + public Dimension getPreferredSize(JComponent c) { | |
| 615 | + Dimension prefSize = | |
| 616 | + (getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE; | |
| 617 | + Dimension d = c.getLayout().preferredLayoutSize(c); | |
| 618 | + if (d != null) { | |
| 619 | + return new Dimension(d.width < prefSize.width ? prefSize.width : d.width, | |
| 620 | + d.height < prefSize.height ? prefSize.height : d.height); | |
| 621 | + } else { | |
| 622 | + return prefSize; | |
| 623 | + } | |
| 624 | + } | |
| 625 | + | |
| 626 | + public Dimension getMinimumSize(JComponent x) { | |
| 627 | + return MIN_SIZE; | |
| 628 | + } | |
| 629 | + | |
| 630 | + public Dimension getMaximumSize(JComponent x) { | |
| 631 | + return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); | |
| 632 | + } | |
| 633 | + | |
| 634 | + protected void align(JComponent c) { | |
| 635 | + c.setAlignmentX(JComponent.LEFT_ALIGNMENT); | |
| 636 | + c.setAlignmentY(JComponent.TOP_ALIGNMENT); | |
| 637 | + } | |
| 638 | + | |
| 639 | + protected class FileCellRenderer extends DefaultListCellRenderer { | |
| 640 | + public Component getListCellRendererComponent(JList list, Object value, int index, | |
| 641 | + boolean isSelected, boolean cellHasFocus) { | |
| 642 | + | |
| 643 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 644 | + setText(getFileChooser().getName((File) value)); | |
| 645 | + setInheritsPopupMenu(true); | |
| 646 | + return this; | |
| 647 | + } | |
| 648 | + } | |
| 649 | + | |
| 650 | + protected class DirectoryCellRenderer extends DefaultListCellRenderer { | |
| 651 | + public Component getListCellRendererComponent(JList list, Object value, int index, | |
| 652 | + boolean isSelected, boolean cellHasFocus) { | |
| 653 | + | |
| 654 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 655 | + setText(getFileChooser().getName((File) value)); | |
| 656 | + setInheritsPopupMenu(true); | |
| 657 | + return this; | |
| 658 | + } | |
| 659 | + } | |
| 660 | + | |
| 661 | + protected class MotifDirectoryListModel extends AbstractListModel implements ListDataListener { | |
| 662 | + public MotifDirectoryListModel() { | |
| 663 | + getModel().addListDataListener(this); | |
| 664 | + } | |
| 665 | + | |
| 666 | + public int getSize() { | |
| 667 | + return getModel().getDirectories().size(); | |
| 668 | + } | |
| 669 | + | |
| 670 | + public Object getElementAt(int index) { | |
| 671 | + return getModel().getDirectories().elementAt(index); | |
| 672 | + } | |
| 673 | + | |
| 674 | + public void intervalAdded(ListDataEvent e) { | |
| 675 | + fireIntervalAdded(this, e.getIndex0(), e.getIndex1()); | |
| 676 | + } | |
| 677 | + | |
| 678 | + public void intervalRemoved(ListDataEvent e) { | |
| 679 | + fireIntervalRemoved(this, e.getIndex0(), e.getIndex1()); | |
| 680 | + } | |
| 681 | + | |
| 682 | + // PENDING(jeff) - this is inefficient - should sent out | |
| 683 | + // incremental adjustment values instead of saying that the | |
| 684 | + // whole list has changed. | |
| 685 | + public void fireContentsChanged() { | |
| 686 | + fireContentsChanged(this, 0, getModel().getDirectories().size()-1); | |
| 687 | + } | |
| 688 | + | |
| 689 | + // PENDING(jeff) - fire the correct interval changed - currently sending | |
| 690 | + // out that everything has changed | |
| 691 | + public void contentsChanged(ListDataEvent e) { | |
| 692 | + fireContentsChanged(); | |
| 693 | + } | |
| 694 | + | |
| 695 | + } | |
| 696 | + | |
| 697 | + protected class MotifFileListModel extends AbstractListModel implements ListDataListener { | |
| 698 | + public MotifFileListModel() { | |
| 699 | + getModel().addListDataListener(this); | |
| 700 | + } | |
| 701 | + | |
| 702 | + public int getSize() { | |
| 703 | + return getModel().getFiles().size(); | |
| 704 | + } | |
| 705 | + | |
| 706 | + public boolean contains(Object o) { | |
| 707 | + return getModel().getFiles().contains(o); | |
| 708 | + } | |
| 709 | + | |
| 710 | + public int indexOf(Object o) { | |
| 711 | + return getModel().getFiles().indexOf(o); | |
| 712 | + } | |
| 713 | + | |
| 714 | + public Object getElementAt(int index) { | |
| 715 | + return getModel().getFiles().elementAt(index); | |
| 716 | + } | |
| 717 | + | |
| 718 | + public void intervalAdded(ListDataEvent e) { | |
| 719 | + fireIntervalAdded(this, e.getIndex0(), e.getIndex1()); | |
| 720 | + } | |
| 721 | + | |
| 722 | + public void intervalRemoved(ListDataEvent e) { | |
| 723 | + fireIntervalRemoved(this, e.getIndex0(), e.getIndex1()); | |
| 724 | + } | |
| 725 | + | |
| 726 | + // PENDING(jeff) - this is inefficient - should sent out | |
| 727 | + // incremental adjustment values instead of saying that the | |
| 728 | + // whole list has changed. | |
| 729 | + public void fireContentsChanged() { | |
| 730 | + fireContentsChanged(this, 0, getModel().getFiles().size()-1); | |
| 731 | + } | |
| 732 | + | |
| 733 | + // PENDING(jeff) - fire the interval changed | |
| 734 | + public void contentsChanged(ListDataEvent e) { | |
| 735 | + fireContentsChanged(); | |
| 736 | + } | |
| 737 | + | |
| 738 | + } | |
| 739 | + | |
| 740 | + // | |
| 741 | + // DataModel for Types Comboxbox | |
| 742 | + // | |
| 743 | + protected FilterComboBoxModel createFilterComboBoxModel() { | |
| 744 | + return new FilterComboBoxModel(); | |
| 745 | + } | |
| 746 | + | |
| 747 | + // | |
| 748 | + // Renderer for Types ComboBox | |
| 749 | + // | |
| 750 | + protected FilterComboBoxRenderer createFilterComboBoxRenderer() { | |
| 751 | + return new FilterComboBoxRenderer(); | |
| 752 | + } | |
| 753 | + | |
| 754 | + | |
| 755 | + /** | |
| 756 | + * Render different type sizes and styles. | |
| 757 | + */ | |
| 758 | + public class FilterComboBoxRenderer extends DefaultListCellRenderer { | |
| 759 | + public Component getListCellRendererComponent(JList list, | |
| 760 | + Object value, int index, boolean isSelected, | |
| 761 | + boolean cellHasFocus) { | |
| 762 | + | |
| 763 | + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | |
| 764 | + | |
| 765 | + if (value != null && value instanceof FileFilter) { | |
| 766 | + setText(((FileFilter)value).getDescription()); | |
| 767 | + } | |
| 768 | + | |
| 769 | + return this; | |
| 770 | + } | |
| 771 | + } | |
| 772 | + | |
| 773 | + /** | |
| 774 | + * Data model for a type-face selection combo-box. | |
| 775 | + */ | |
| 776 | + protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener { | |
| 777 | + protected FileFilter[] filters; | |
| 778 | + protected FilterComboBoxModel() { | |
| 779 | + super(); | |
| 780 | + filters = getFileChooser().getChoosableFileFilters(); | |
| 781 | + } | |
| 782 | + | |
| 783 | + public void propertyChange(PropertyChangeEvent e) { | |
| 784 | + String prop = e.getPropertyName(); | |
| 785 | + if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) { | |
| 786 | + filters = (FileFilter[]) e.getNewValue(); | |
| 787 | + fireContentsChanged(this, -1, -1); | |
| 788 | + } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) { | |
| 789 | + fireContentsChanged(this, -1, -1); | |
| 790 | + } | |
| 791 | + } | |
| 792 | + | |
| 793 | + public void setSelectedItem(Object filter) { | |
| 794 | + if(filter != null) { | |
| 795 | + getFileChooser().setFileFilter((FileFilter) filter); | |
| 796 | + fireContentsChanged(this, -1, -1); | |
| 797 | + } | |
| 798 | + } | |
| 799 | + | |
| 800 | + public Object getSelectedItem() { | |
| 801 | + // Ensure that the current filter is in the list. | |
| 802 | + // NOTE: we shouldnt' have to do this, since JFileChooser adds | |
| 803 | + // the filter to the choosable filters list when the filter | |
| 804 | + // is set. Lets be paranoid just in case someone overrides | |
| 805 | + // setFileFilter in JFileChooser. | |
| 806 | + FileFilter currentFilter = getFileChooser().getFileFilter(); | |
| 807 | + boolean found = false; | |
| 808 | + if(currentFilter != null) { | |
| 809 | + for (FileFilter filter : filters) { | |
| 810 | + if (filter == currentFilter) { | |
| 811 | + found = true; | |
| 812 | + } | |
| 813 | + } | |
| 814 | + if (!found) { | |
| 815 | + getFileChooser().addChoosableFileFilter(currentFilter); | |
| 816 | + } | |
| 817 | + } | |
| 818 | + return getFileChooser().getFileFilter(); | |
| 819 | + } | |
| 820 | + | |
| 821 | + public int getSize() { | |
| 822 | + if(filters != null) { | |
| 823 | + return filters.length; | |
| 824 | + } else { | |
| 825 | + return 0; | |
| 826 | + } | |
| 827 | + } | |
| 828 | + | |
| 829 | + public Object getElementAt(int index) { | |
| 830 | + if(index > getSize() - 1) { | |
| 831 | + // This shouldn't happen. Try to recover gracefully. | |
| 832 | + return getFileChooser().getFileFilter(); | |
| 833 | + } | |
| 834 | + if(filters != null) { | |
| 835 | + return filters[index]; | |
| 836 | + } else { | |
| 837 | + return null; | |
| 838 | + } | |
| 839 | + } | |
| 840 | + } | |
| 841 | + | |
| 842 | + protected JButton getApproveButton(JFileChooser fc) { | |
| 843 | + return approveButton; | |
| 844 | + } | |
| 845 | + | |
| 846 | +} | |
| @@ -0,0 +1,476 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package com.sun.java.swing.plaf.motif; | |
| 26 | + | |
| 27 | +import sun.swing.SwingUtilities2; | |
| 28 | + | |
| 29 | +import javax.swing.*; | |
| 30 | +import java.awt.Color; | |
| 31 | +import java.awt.Dimension; | |
| 32 | +import java.awt.Graphics; | |
| 33 | +import java.awt.Font; | |
| 34 | +import java.awt.FontMetrics; | |
| 35 | +import java.awt.Rectangle; | |
| 36 | +import java.awt.Component; | |
| 37 | +import java.awt.Insets; | |
| 38 | +import java.awt.event.KeyEvent; | |
| 39 | +import java.awt.Container; | |
| 40 | + | |
| 41 | +import javax.swing.plaf.basic.*; | |
| 42 | +import javax.swing.text.View; | |
| 43 | + | |
| 44 | +/* | |
| 45 | + * @author Jeff Dinkins | |
| 46 | + * @author Dave Kloba | |
| 47 | + */ | |
| 48 | + | |
| 49 | +public class MotifGraphicsUtils implements SwingConstants | |
| 50 | +{ | |
| 51 | + /* Client Property keys for text and accelerator text widths */ | |
| 52 | + private static final String MAX_ACC_WIDTH = "maxAccWidth"; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Draws the point (<b>x</b>, <b>y</b>) in the current color. | |
| 56 | + */ | |
| 57 | + static void drawPoint(Graphics g, int x, int y) { | |
| 58 | + g.drawLine(x, y, x, y); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /* | |
| 62 | + * Convenience method for drawing a grooved line | |
| 63 | + * | |
| 64 | + */ | |
| 65 | + public static void drawGroove(Graphics g, int x, int y, int w, int h, | |
| 66 | + Color shadow, Color highlight) | |
| 67 | + { | |
| 68 | + Color oldColor = g.getColor(); // Make no net change to g | |
| 69 | + g.translate(x, y); | |
| 70 | + | |
| 71 | + g.setColor(shadow); | |
| 72 | + g.drawRect(0, 0, w-2, h-2); | |
| 73 | + | |
| 74 | + g.setColor(highlight); | |
| 75 | + g.drawLine(1, h-3, 1, 1); | |
| 76 | + g.drawLine(1, 1, w-3, 1); | |
| 77 | + | |
| 78 | + g.drawLine(0, h-1, w-1, h-1); | |
| 79 | + g.drawLine(w-1, h-1, w-1, 0); | |
| 80 | + | |
| 81 | + g.translate(-x, -y); | |
| 82 | + g.setColor(oldColor); | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** Draws <b>aString</b> in the rectangle defined by | |
| 86 | + * (<b>x</b>, <b>y</b>, <b>width</b>, <b>height</b>). | |
| 87 | + * <b>justification</b> specifies the text's justification, one of | |
| 88 | + * LEFT, CENTER, or RIGHT. | |
| 89 | + * <b>drawStringInRect()</b> does not clip to the rectangle, but instead | |
| 90 | + * uses this rectangle and the desired justification to compute the point | |
| 91 | + * at which to begin drawing the text. | |
| 92 | + * @see #drawString | |
| 93 | + */ | |
| 94 | + public static void drawStringInRect(Graphics g, String aString, int x, int y, | |
| 95 | + int width, int height, int justification) { | |
| 96 | + drawStringInRect(null, g, aString, x, y, width, height, justification); | |
| 97 | + } | |
| 98 | + | |
| 99 | + static void drawStringInRect(JComponent c, Graphics g, String aString, | |
| 100 | + int x, int y, int width, int height, | |
| 101 | + int justification) { | |
| 102 | + FontMetrics fontMetrics; | |
| 103 | + int drawWidth, startX, startY, delta; | |
| 104 | + | |
| 105 | + if (g.getFont() == null) { | |
| 106 | +// throw new InconsistencyException("No font set"); | |
| 107 | + return; | |
| 108 | + } | |
| 109 | + fontMetrics = SwingUtilities2.getFontMetrics(c, g); | |
| 110 | + if (fontMetrics == null) { | |
| 111 | +// throw new InconsistencyException("No metrics for Font " + font()); | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + | |
| 115 | + if (justification == CENTER) { | |
| 116 | + drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString); | |
| 117 | + if (drawWidth > width) { | |
| 118 | + drawWidth = width; | |
| 119 | + } | |
| 120 | + startX = x + (width - drawWidth) / 2; | |
| 121 | + } else if (justification == RIGHT) { | |
| 122 | + drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString); | |
| 123 | + if (drawWidth > width) { | |
| 124 | + drawWidth = width; | |
| 125 | + } | |
| 126 | + startX = x + width - drawWidth; | |
| 127 | + } else { | |
| 128 | + startX = x; | |
| 129 | + } | |
| 130 | + | |
| 131 | + delta = (height - fontMetrics.getAscent() - fontMetrics.getDescent()) / 2; | |
| 132 | + if (delta < 0) { | |
| 133 | + delta = 0; | |
| 134 | + } | |
| 135 | + | |
| 136 | + startY = y + height - delta - fontMetrics.getDescent(); | |
| 137 | + | |
| 138 | + SwingUtilities2.drawString(c, g, aString, startX, startY); | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * This method is not being used to paint menu item since | |
| 143 | + * 6.0 This code left for compatibility only. Do not use or | |
| 144 | + * override it, this will not cause any visible effect. | |
| 145 | + */ | |
| 146 | + public static void paintMenuItem(Graphics g, JComponent c, | |
| 147 | + Icon checkIcon, Icon arrowIcon, | |
| 148 | + Color background, Color foreground, | |
| 149 | + int defaultTextIconGap) | |
| 150 | + { | |
| 151 | + | |
| 152 | + JMenuItem b = (JMenuItem) c; | |
| 153 | + ButtonModel model = b.getModel(); | |
| 154 | + | |
| 155 | + Dimension size = b.getSize(); | |
| 156 | + Insets i = c.getInsets(); | |
| 157 | + | |
| 158 | + Rectangle viewRect = new Rectangle(size); | |
| 159 | + | |
| 160 | + viewRect.x += i.left; | |
| 161 | + viewRect.y += i.top; | |
| 162 | + viewRect.width -= (i.right + viewRect.x); | |
| 163 | + viewRect.height -= (i.bottom + viewRect.y); | |
| 164 | + | |
| 165 | + Rectangle iconRect = new Rectangle(); | |
| 166 | + Rectangle textRect = new Rectangle(); | |
| 167 | + Rectangle acceleratorRect = new Rectangle(); | |
| 168 | + Rectangle checkRect = new Rectangle(); | |
| 169 | + Rectangle arrowRect = new Rectangle(); | |
| 170 | + | |
| 171 | + Font holdf = g.getFont(); | |
| 172 | + Font f = c.getFont(); | |
| 173 | + g.setFont(f); | |
| 174 | + FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); | |
| 175 | + FontMetrics fmAccel = SwingUtilities2.getFontMetrics( | |
| 176 | + c, g, UIManager.getFont("MenuItem.acceleratorFont")); | |
| 177 | + | |
| 178 | + if (c.isOpaque()) { | |
| 179 | + if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) { | |
| 180 | + g.setColor(background); | |
| 181 | + } else { | |
| 182 | + g.setColor(c.getBackground()); | |
| 183 | + } | |
| 184 | + g.fillRect(0,0, size.width, size.height); | |
| 185 | + } | |
| 186 | + | |
| 187 | + // get Accelerator text | |
| 188 | + KeyStroke accelerator = b.getAccelerator(); | |
| 189 | + String acceleratorText = ""; | |
| 190 | + if (accelerator != null) { | |
| 191 | + int modifiers = accelerator.getModifiers(); | |
| 192 | + if (modifiers > 0) { | |
| 193 | + acceleratorText = KeyEvent.getKeyModifiersText(modifiers); | |
| 194 | + acceleratorText += "+"; | |
| 195 | + } | |
| 196 | + acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode()); | |
| 197 | + } | |
| 198 | + | |
| 199 | + // layout the text and icon | |
| 200 | + String text = layoutMenuItem(c, fm, b.getText(), fmAccel, | |
| 201 | + acceleratorText, b.getIcon(), | |
| 202 | + checkIcon, arrowIcon, | |
| 203 | + b.getVerticalAlignment(), | |
| 204 | + b.getHorizontalAlignment(), | |
| 205 | + b.getVerticalTextPosition(), | |
| 206 | + b.getHorizontalTextPosition(), | |
| 207 | + viewRect, iconRect, | |
| 208 | + textRect, acceleratorRect, | |
| 209 | + checkRect, arrowRect, | |
| 210 | + b.getText() == null | |
| 211 | + ? 0 : defaultTextIconGap, | |
| 212 | + defaultTextIconGap | |
| 213 | + ); | |
| 214 | + | |
| 215 | + // Paint the Check | |
| 216 | + Color holdc = g.getColor(); | |
| 217 | + if (checkIcon != null) { | |
| 218 | + if(model.isArmed() || (c instanceof JMenu && model.isSelected())) | |
| 219 | + g.setColor(foreground); | |
| 220 | + checkIcon.paintIcon(c, g, checkRect.x, checkRect.y); | |
| 221 | + g.setColor(holdc); | |
| 222 | + } | |
| 223 | + | |
| 224 | + // Paint the Icon | |
| 225 | + if(b.getIcon() != null) { | |
| 226 | + Icon icon; | |
| 227 | + if(!model.isEnabled()) { | |
| 228 | + icon = b.getDisabledIcon(); | |
| 229 | + } else if(model.isPressed() && model.isArmed()) { | |
| 230 | + icon = b.getPressedIcon(); | |
| 231 | + if(icon == null) { | |
| 232 | + // Use default icon | |
| 233 | + icon = b.getIcon(); | |
| 234 | + } | |
| 235 | + } else { | |
| 236 | + icon = b.getIcon(); | |
| 237 | + } | |
| 238 | + | |
| 239 | + if (icon!=null) { | |
| 240 | + icon.paintIcon(c, g, iconRect.x, iconRect.y); | |
| 241 | + } | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Draw the Text | |
| 245 | + if(text != null && !text.equals("")) { | |
| 246 | + // Once BasicHTML becomes public, use BasicHTML.propertyKey | |
| 247 | + // instead of the hardcoded string below! | |
| 248 | + View v = (View) c.getClientProperty("html"); | |
| 249 | + if (v != null) { | |
| 250 | + v.paint(g, textRect); | |
| 251 | + } else { | |
| 252 | + int mnemIndex = b.getDisplayedMnemonicIndex(); | |
| 253 | + | |
| 254 | + if(!model.isEnabled()) { | |
| 255 | + // *** paint the text disabled | |
| 256 | + g.setColor(b.getBackground().brighter()); | |
| 257 | + SwingUtilities2.drawStringUnderlineCharAt(b, g,text, | |
| 258 | + mnemIndex, | |
| 259 | + textRect.x, textRect.y + fmAccel.getAscent()); | |
| 260 | + g.setColor(b.getBackground().darker()); | |
| 261 | + SwingUtilities2.drawStringUnderlineCharAt(b, g,text, | |
| 262 | + mnemIndex, | |
| 263 | + textRect.x - 1, textRect.y + fmAccel.getAscent() - 1); | |
| 264 | + | |
| 265 | + } else { | |
| 266 | + // *** paint the text normally | |
| 267 | + if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) { | |
| 268 | + g.setColor(foreground); | |
| 269 | + } else { | |
| 270 | + g.setColor(b.getForeground()); | |
| 271 | + } | |
| 272 | + SwingUtilities2.drawStringUnderlineCharAt(b, g,text, | |
| 273 | + mnemIndex, | |
| 274 | + textRect.x, | |
| 275 | + textRect.y + fm.getAscent()); | |
| 276 | + } | |
| 277 | + } | |
| 278 | + } | |
| 279 | + | |
| 280 | + // Draw the Accelerator Text | |
| 281 | + if(acceleratorText != null && !acceleratorText.equals("")) { | |
| 282 | + | |
| 283 | + //Get the maxAccWidth from the parent to calculate the offset. | |
| 284 | + int accOffset = 0; | |
| 285 | + Container parent = b.getParent(); | |
| 286 | + if (parent != null && parent instanceof JComponent) { | |
| 287 | + JComponent p = (JComponent) parent; | |
| 288 | + Integer maxValueInt = (Integer) p.getClientProperty(MotifGraphicsUtils.MAX_ACC_WIDTH); | |
| 289 | + int maxValue = maxValueInt != null ? | |
| 290 | + maxValueInt.intValue() : acceleratorRect.width; | |
| 291 | + | |
| 292 | + //Calculate the offset, with which the accelerator texts will be drawn with. | |
| 293 | + accOffset = maxValue - acceleratorRect.width; | |
| 294 | + } | |
| 295 | + | |
| 296 | + g.setFont( UIManager.getFont("MenuItem.acceleratorFont") ); | |
| 297 | + if(!model.isEnabled()) { | |
| 298 | + // *** paint the acceleratorText disabled | |
| 299 | + g.setColor(b.getBackground().brighter()); | |
| 300 | + SwingUtilities2.drawString(c, g,acceleratorText, | |
| 301 | + acceleratorRect.x - accOffset, acceleratorRect.y + fm.getAscent()); | |
| 302 | + g.setColor(b.getBackground().darker()); | |
| 303 | + SwingUtilities2.drawString(c, g,acceleratorText, | |
| 304 | + acceleratorRect.x - accOffset - 1, acceleratorRect.y + fm.getAscent() - 1); | |
| 305 | + } else { | |
| 306 | + // *** paint the acceleratorText normally | |
| 307 | + if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) | |
| 308 | + { | |
| 309 | + g.setColor(foreground); | |
| 310 | + } else { | |
| 311 | + g.setColor(b.getForeground()); | |
| 312 | + } | |
| 313 | + SwingUtilities2.drawString(c, g,acceleratorText, | |
| 314 | + acceleratorRect.x - accOffset, | |
| 315 | + acceleratorRect.y + fmAccel.getAscent()); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + // Paint the Arrow | |
| 320 | + if (arrowIcon != null) { | |
| 321 | + if(model.isArmed() || (c instanceof JMenu && model.isSelected())) | |
| 322 | + g.setColor(foreground); | |
| 323 | + if( !(b.getParent() instanceof JMenuBar) ) | |
| 324 | + arrowIcon.paintIcon(c, g, arrowRect.x, arrowRect.y); | |
| 325 | + } | |
| 326 | + | |
| 327 | + g.setColor(holdc); | |
| 328 | + g.setFont(holdf); | |
| 329 | + } | |
| 330 | + | |
| 331 | + | |
| 332 | + /** | |
| 333 | + * Compute and return the location of the icons origin, the | |
| 334 | + * location of origin of the text baseline, and a possibly clipped | |
| 335 | + * version of the compound labels string. Locations are computed | |
| 336 | + * relative to the viewR rectangle. | |
| 337 | + */ | |
| 338 | + | |
| 339 | + private static String layoutMenuItem( | |
| 340 | + JComponent c, | |
| 341 | + FontMetrics fm, | |
| 342 | + String text, | |
| 343 | + FontMetrics fmAccel, | |
| 344 | + String acceleratorText, | |
| 345 | + Icon icon, | |
| 346 | + Icon checkIcon, | |
| 347 | + Icon arrowIcon, | |
| 348 | + int verticalAlignment, | |
| 349 | + int horizontalAlignment, | |
| 350 | + int verticalTextPosition, | |
| 351 | + int horizontalTextPosition, | |
| 352 | + Rectangle viewR, | |
| 353 | + Rectangle iconR, | |
| 354 | + Rectangle textR, | |
| 355 | + Rectangle acceleratorR, | |
| 356 | + Rectangle checkIconR, | |
| 357 | + Rectangle arrowIconR, | |
| 358 | + int textIconGap, | |
| 359 | + int menuItemGap | |
| 360 | + ) | |
| 361 | + { | |
| 362 | + | |
| 363 | + SwingUtilities.layoutCompoundLabel(c, | |
| 364 | + fm, | |
| 365 | + text, | |
| 366 | + icon, | |
| 367 | + verticalAlignment, | |
| 368 | + horizontalAlignment, | |
| 369 | + verticalTextPosition, | |
| 370 | + horizontalTextPosition, | |
| 371 | + viewR, | |
| 372 | + iconR, | |
| 373 | + textR, | |
| 374 | + textIconGap); | |
| 375 | + | |
| 376 | + /* Initialize the acceelratorText bounds rectangle textR. If a null | |
| 377 | + * or and empty String was specified we substitute "" here | |
| 378 | + * and use 0,0,0,0 for acceleratorTextR. | |
| 379 | + */ | |
| 380 | + if( (acceleratorText == null) || acceleratorText.equals("") ) { | |
| 381 | + acceleratorR.width = acceleratorR.height = 0; | |
| 382 | + acceleratorText = ""; | |
| 383 | + } | |
| 384 | + else { | |
| 385 | + acceleratorR.width | |
| 386 | + = SwingUtilities2.stringWidth(c, fmAccel, acceleratorText); | |
| 387 | + acceleratorR.height = fmAccel.getHeight(); | |
| 388 | + } | |
| 389 | + | |
| 390 | + /* Initialize the checkIcon bounds rectangle checkIconR. | |
| 391 | + */ | |
| 392 | + | |
| 393 | + if (checkIcon != null) { | |
| 394 | + checkIconR.width = checkIcon.getIconWidth(); | |
| 395 | + checkIconR.height = checkIcon.getIconHeight(); | |
| 396 | + } | |
| 397 | + else { | |
| 398 | + checkIconR.width = checkIconR.height = 0; | |
| 399 | + } | |
| 400 | + | |
| 401 | + /* Initialize the arrowIcon bounds rectangle arrowIconR. | |
| 402 | + */ | |
| 403 | + | |
| 404 | + if (arrowIcon != null) { | |
| 405 | + arrowIconR.width = arrowIcon.getIconWidth(); | |
| 406 | + arrowIconR.height = arrowIcon.getIconHeight(); | |
| 407 | + } | |
| 408 | + else { | |
| 409 | + arrowIconR.width = arrowIconR.height = 0; | |
| 410 | + } | |
| 411 | + | |
| 412 | + | |
| 413 | + Rectangle labelR = iconR.union(textR); | |
| 414 | + if( MotifGraphicsUtils.isLeftToRight(c) ) { | |
| 415 | + textR.x += checkIconR.width + menuItemGap; | |
| 416 | + iconR.x += checkIconR.width + menuItemGap; | |
| 417 | + | |
| 418 | + // Position the Accelerator text rect | |
| 419 | + acceleratorR.x = viewR.x + viewR.width - arrowIconR.width | |
| 420 | + - menuItemGap - acceleratorR.width; | |
| 421 | + | |
| 422 | + // Position the Check and Arrow Icons | |
| 423 | + checkIconR.x = viewR.x; | |
| 424 | + arrowIconR.x = viewR.x + viewR.width - menuItemGap | |
| 425 | + - arrowIconR.width; | |
| 426 | + } else { | |
| 427 | + textR.x -= (checkIconR.width + menuItemGap); | |
| 428 | + iconR.x -= (checkIconR.width + menuItemGap); | |
| 429 | + | |
| 430 | + // Position the Accelerator text rect | |
| 431 | + acceleratorR.x = viewR.x + arrowIconR.width + menuItemGap; | |
| 432 | + | |
| 433 | + // Position the Check and Arrow Icons | |
| 434 | + checkIconR.x = viewR.x + viewR.width - checkIconR.width; | |
| 435 | + arrowIconR.x = viewR.x + menuItemGap; | |
| 436 | + } | |
| 437 | + | |
| 438 | + // Align the accelertor text and the check and arrow icons vertically | |
| 439 | + // with the center of the label rect. | |
| 440 | + acceleratorR.y = labelR.y + (labelR.height/2) - (acceleratorR.height/2); | |
| 441 | + arrowIconR.y = labelR.y + (labelR.height/2) - (arrowIconR.height/2); | |
| 442 | + checkIconR.y = labelR.y + (labelR.height/2) - (checkIconR.height/2); | |
| 443 | + | |
| 444 | + /* | |
| 445 | + System.out.println("Layout: v=" +viewR+" c="+checkIconR+" i="+ | |
| 446 | + iconR+" t="+textR+" acc="+acceleratorR+" a="+arrowIconR); | |
| 447 | + */ | |
| 448 | + return text; | |
| 449 | + } | |
| 450 | + | |
| 451 | + private static void drawMenuBezel(Graphics g, Color background, | |
| 452 | + int x, int y, | |
| 453 | + int width, int height) | |
| 454 | + { | |
| 455 | + // shadowed button region | |
| 456 | + g.setColor(background); | |
| 457 | + g.fillRect(x,y,width,height); | |
| 458 | + | |
| 459 | + g.setColor(background.brighter().brighter()); | |
| 460 | + g.drawLine(x+1, y+height-1, x+width-1, y+height-1); | |
| 461 | + g.drawLine(x+width-1, y+height-2, x+width-1, y+1); | |
| 462 | + | |
| 463 | + g.setColor(background.darker().darker()); | |
| 464 | + g.drawLine(x, y, x+width-2, y); | |
| 465 | + g.drawLine(x, y+1, x, y+height-2); | |
| 466 | + | |
| 467 | + } | |
| 468 | + | |
| 469 | + /* | |
| 470 | + * Convenience function for determining ComponentOrientation. Helps us | |
| 471 | + * avoid having Munge directives throughout the code. | |
| 472 | + */ | |
| 473 | + static boolean isLeftToRight( Component c ) { | |
| 474 | + return c.getComponentOrientation().isLeftToRight(); | |
| 475 | + } | |
| 476 | +} | |
| @@ -0,0 +1,460 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import javax.swing.*; | |
| 29 | + | |
| 30 | +import javax.swing.plaf.UIResource; | |
| 31 | + | |
| 32 | +import java.awt.Color; | |
| 33 | +import java.awt.Component; | |
| 34 | +import java.awt.Dimension; | |
| 35 | +import java.awt.Graphics; | |
| 36 | +import java.awt.Polygon; | |
| 37 | + | |
| 38 | +import java.io.Serializable; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Icon factory for the CDE/Motif Look and Feel | |
| 42 | + * <p> | |
| 43 | + * <strong>Warning:</strong> | |
| 44 | + * Serialized objects of this class will not be compatible with | |
| 45 | + * future Swing releases. The current serialization support is appropriate | |
| 46 | + * for short term storage or RMI between applications running the same | |
| 47 | + * version of Swing. A future release of Swing will provide support for | |
| 48 | + * long term persistence. | |
| 49 | + * | |
| 50 | + * 1.20 04/27/99 | |
| 51 | + * @author Georges Saab | |
| 52 | + */ | |
| 53 | +public class MotifIconFactory implements Serializable | |
| 54 | +{ | |
| 55 | + private static Icon checkBoxIcon; | |
| 56 | + private static Icon radioButtonIcon; | |
| 57 | + private static Icon menuItemCheckIcon; | |
| 58 | + private static Icon menuItemArrowIcon; | |
| 59 | + private static Icon menuArrowIcon; | |
| 60 | + | |
| 61 | + public static Icon getMenuItemCheckIcon() { | |
| 62 | + return null; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public static Icon getMenuItemArrowIcon() { | |
| 66 | + if (menuItemArrowIcon == null) { | |
| 67 | + menuItemArrowIcon = new MenuItemArrowIcon(); | |
| 68 | + } | |
| 69 | + return menuItemArrowIcon; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public static Icon getMenuArrowIcon() { | |
| 73 | + if (menuArrowIcon == null) { | |
| 74 | + menuArrowIcon = new MenuArrowIcon(); | |
| 75 | + } | |
| 76 | + return menuArrowIcon; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public static Icon getCheckBoxIcon() { | |
| 80 | + if (checkBoxIcon == null) { | |
| 81 | + checkBoxIcon = new CheckBoxIcon(); | |
| 82 | + } | |
| 83 | + return checkBoxIcon; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public static Icon getRadioButtonIcon() { | |
| 87 | + if (radioButtonIcon == null) { | |
| 88 | + radioButtonIcon = new RadioButtonIcon(); | |
| 89 | + } | |
| 90 | + return radioButtonIcon; | |
| 91 | + } | |
| 92 | + | |
| 93 | + private static class CheckBoxIcon implements Icon, UIResource, Serializable { | |
| 94 | + final static int csize = 13; | |
| 95 | + | |
| 96 | + private Color control = UIManager.getColor("control"); | |
| 97 | + private Color foreground = UIManager.getColor("CheckBox.foreground"); | |
| 98 | + private Color shadow = UIManager.getColor("controlShadow"); | |
| 99 | + private Color highlight = UIManager.getColor("controlHighlight"); | |
| 100 | + private Color lightShadow = UIManager.getColor("controlLightShadow"); | |
| 101 | + | |
| 102 | + public void paintIcon(Component c, Graphics g, int x, int y) { | |
| 103 | + AbstractButton b = (AbstractButton) c; | |
| 104 | + ButtonModel model = b.getModel(); | |
| 105 | + | |
| 106 | + boolean flat = false; | |
| 107 | + | |
| 108 | + if(b instanceof JCheckBox) { | |
| 109 | + flat = ((JCheckBox)b).isBorderPaintedFlat(); | |
| 110 | + } | |
| 111 | + | |
| 112 | + boolean isPressed = model.isPressed(); | |
| 113 | + boolean isArmed = model.isArmed(); | |
| 114 | + boolean isEnabled = model.isEnabled(); | |
| 115 | + boolean isSelected = model.isSelected(); | |
| 116 | + | |
| 117 | + // There are 4 "looks" to the Motif CheckBox: | |
| 118 | + // drawCheckBezelOut - default unchecked state | |
| 119 | + // drawBezel - when we uncheck in toggled state | |
| 120 | + // drawCheckBezel - when we check in toggle state | |
| 121 | + // drawCheckBezelIn - selected, mouseReleased | |
| 122 | + boolean checkToggleIn = ((isPressed && | |
| 123 | + !isArmed && | |
| 124 | + isSelected) || | |
| 125 | + (isPressed && | |
| 126 | + isArmed && | |
| 127 | + !isSelected)); | |
| 128 | + boolean uncheckToggleOut = ((isPressed && | |
| 129 | + !isArmed && | |
| 130 | + !isSelected) || | |
| 131 | + (isPressed && | |
| 132 | + isArmed && | |
| 133 | + isSelected)); | |
| 134 | + | |
| 135 | + boolean checkIn = (!isPressed && | |
| 136 | + isArmed && | |
| 137 | + isSelected || | |
| 138 | + (!isPressed && | |
| 139 | + !isArmed && | |
| 140 | + isSelected)); | |
| 141 | + | |
| 142 | + | |
| 143 | + if(flat) { | |
| 144 | + g.setColor(shadow); | |
| 145 | + g.drawRect(x+2,y,csize-1,csize-1); | |
| 146 | + if(uncheckToggleOut || checkToggleIn) { | |
| 147 | + g.setColor(control); | |
| 148 | + g.fillRect(x+3,y+1,csize-2,csize-2); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + if (checkToggleIn) { | |
| 153 | + // toggled from unchecked to checked | |
| 154 | + drawCheckBezel(g,x,y,csize,true,false,false,flat); | |
| 155 | + } else if (uncheckToggleOut) { | |
| 156 | + // MotifBorderFactory.drawBezel(g,x,y,csize,csize,false,false); | |
| 157 | + drawCheckBezel(g,x,y,csize,true,true,false,flat); | |
| 158 | + } else if (checkIn) { | |
| 159 | + // show checked, unpressed state | |
| 160 | + drawCheckBezel(g,x,y,csize,false,false,true,flat); | |
| 161 | + } else if(!flat) { | |
| 162 | + // show unchecked state | |
| 163 | + drawCheckBezelOut(g,x,y,csize); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + public int getIconWidth() { | |
| 168 | + return csize; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public int getIconHeight() { | |
| 172 | + return csize; | |
| 173 | + } | |
| 174 | + | |
| 175 | + public void drawCheckBezelOut(Graphics g, int x, int y, int csize){ | |
| 176 | + Color controlShadow = UIManager.getColor("controlShadow"); | |
| 177 | + | |
| 178 | + int w = csize; | |
| 179 | + int h = csize; | |
| 180 | + Color oldColor = g.getColor(); | |
| 181 | + | |
| 182 | + g.translate(x,y); | |
| 183 | + g.setColor(highlight); // inner 3D border | |
| 184 | + g.drawLine(0, 0, 0, h-1); | |
| 185 | + g.drawLine(1, 0, w-1, 0); | |
| 186 | + | |
| 187 | + g.setColor(shadow); // black drop shadow __| | |
| 188 | + g.drawLine(1, h-1, w-1, h-1); | |
| 189 | + g.drawLine(w-1, h-1, w-1, 1); | |
| 190 | + g.translate(-x,-y); | |
| 191 | + g.setColor(oldColor); | |
| 192 | + } | |
| 193 | + | |
| 194 | + public void drawCheckBezel(Graphics g, int x, int y, int csize, | |
| 195 | + boolean shade, boolean out, boolean check, boolean flat) | |
| 196 | + { | |
| 197 | + | |
| 198 | + | |
| 199 | + Color oldColor = g.getColor(); | |
| 200 | + g.translate(x, y); | |
| 201 | + | |
| 202 | + | |
| 203 | + //bottom | |
| 204 | + if(!flat) { | |
| 205 | + if (out) { | |
| 206 | + g.setColor(control); | |
| 207 | + g.fillRect(1,1,csize-2,csize-2); | |
| 208 | + g.setColor(shadow); | |
| 209 | + } else { | |
| 210 | + g.setColor(lightShadow); | |
| 211 | + g.fillRect(0,0,csize,csize); | |
| 212 | + g.setColor(highlight); | |
| 213 | + } | |
| 214 | + | |
| 215 | + g.drawLine(1,csize-1,csize-2,csize-1); | |
| 216 | + if (shade) { | |
| 217 | + g.drawLine(2,csize-2,csize-3,csize-2); | |
| 218 | + g.drawLine(csize-2,2,csize-2 ,csize-1); | |
| 219 | + if (out) { | |
| 220 | + g.setColor(highlight); | |
| 221 | + } else { | |
| 222 | + g.setColor(shadow); | |
| 223 | + } | |
| 224 | + g.drawLine(1,2,1,csize-2); | |
| 225 | + g.drawLine(1,1,csize-3,1); | |
| 226 | + if (out) { | |
| 227 | + g.setColor(shadow); | |
| 228 | + } else { | |
| 229 | + g.setColor(highlight); | |
| 230 | + } | |
| 231 | + } | |
| 232 | + //right | |
| 233 | + g.drawLine(csize-1,1,csize-1,csize-1); | |
| 234 | + | |
| 235 | + //left | |
| 236 | + if (out) { | |
| 237 | + g.setColor(highlight); | |
| 238 | + } else { | |
| 239 | + g.setColor(shadow); | |
| 240 | + } | |
| 241 | + g.drawLine(0,1,0,csize-1); | |
| 242 | + | |
| 243 | + //top | |
| 244 | + g.drawLine(0,0,csize-1,0); | |
| 245 | + } | |
| 246 | + | |
| 247 | + if (check) { | |
| 248 | + // draw check | |
| 249 | + g.setColor(foreground); | |
| 250 | + g.drawLine(csize-2,1,csize-2,2); | |
| 251 | + g.drawLine(csize-3,2,csize-3,3); | |
| 252 | + g.drawLine(csize-4,3,csize-4,4); | |
| 253 | + g.drawLine(csize-5,4,csize-5,6); | |
| 254 | + g.drawLine(csize-6,5,csize-6,8); | |
| 255 | + g.drawLine(csize-7,6,csize-7,10); | |
| 256 | + g.drawLine(csize-8,7,csize-8,10); | |
| 257 | + g.drawLine(csize-9,6,csize-9,9); | |
| 258 | + g.drawLine(csize-10,5,csize-10,8); | |
| 259 | + g.drawLine(csize-11,5,csize-11,7); | |
| 260 | + g.drawLine(csize-12,6,csize-12,6); | |
| 261 | + } | |
| 262 | + g.translate(-x, -y); | |
| 263 | + g.setColor(oldColor); | |
| 264 | + } | |
| 265 | + } // end class CheckBoxIcon | |
| 266 | + | |
| 267 | + private static class RadioButtonIcon implements Icon, UIResource, Serializable { | |
| 268 | + private Color dot = UIManager.getColor("activeCaptionBorder"); | |
| 269 | + private Color highlight = UIManager.getColor("controlHighlight"); | |
| 270 | + private Color shadow = UIManager.getColor("controlShadow"); | |
| 271 | + | |
| 272 | + public void paintIcon(Component c, Graphics g, int x, int y) { | |
| 273 | + // fill interior | |
| 274 | + AbstractButton b = (AbstractButton) c; | |
| 275 | + ButtonModel model = b.getModel(); | |
| 276 | + | |
| 277 | + int w = getIconWidth(); | |
| 278 | + int h = getIconHeight(); | |
| 279 | + | |
| 280 | + boolean isPressed = model.isPressed(); | |
| 281 | + boolean isArmed = model.isArmed(); | |
| 282 | + boolean isEnabled = model.isEnabled(); | |
| 283 | + boolean isSelected = model.isSelected(); | |
| 284 | + | |
| 285 | + boolean checkIn = ((isPressed && | |
| 286 | + !isArmed && | |
| 287 | + isSelected) || | |
| 288 | + (isPressed && | |
| 289 | + isArmed && | |
| 290 | + !isSelected) | |
| 291 | + || | |
| 292 | + (!isPressed && | |
| 293 | + isArmed && | |
| 294 | + isSelected || | |
| 295 | + (!isPressed && | |
| 296 | + !isArmed && | |
| 297 | + isSelected))); | |
| 298 | + | |
| 299 | + if (checkIn){ | |
| 300 | + g.setColor(shadow); | |
| 301 | + g.drawLine(x+5,y+0,x+8,y+0); | |
| 302 | + g.drawLine(x+3,y+1,x+4,y+1); | |
| 303 | + g.drawLine(x+9,y+1,x+9,y+1); | |
| 304 | + g.drawLine(x+2,y+2,x+2,y+2); | |
| 305 | + g.drawLine(x+1,y+3,x+1,y+3); | |
| 306 | + g.drawLine(x,y+4,x,y+9); | |
| 307 | + g.drawLine(x+1,y+10,x+1,y+10); | |
| 308 | + g.drawLine(x+2,y+11,x+2,y+11); | |
| 309 | + g.setColor(highlight); | |
| 310 | + g.drawLine(x+3,y+12,x+4,y+12); | |
| 311 | + g.drawLine(x+5,y+13,x+8,y+13); | |
| 312 | + g.drawLine(x+9,y+12,x+10,y+12); | |
| 313 | + g.drawLine(x+11,y+11,x+11,y+11); | |
| 314 | + g.drawLine(x+12,y+10,x+12,y+10); | |
| 315 | + g.drawLine(x+13,y+9,x+13,y+4); | |
| 316 | + g.drawLine(x+12,y+3,x+12,y+3); | |
| 317 | + g.drawLine(x+11,y+2,x+11,y+2); | |
| 318 | + g.drawLine(x+10,y+1,x+10,y+1); | |
| 319 | + g.setColor(dot); | |
| 320 | + g.fillRect(x+4,y+5,6,4); | |
| 321 | + g.drawLine(x+5,y+4,x+8,y+4); | |
| 322 | + g.drawLine(x+5,y+9,x+8,y+9); | |
| 323 | + } | |
| 324 | + else { | |
| 325 | + g.setColor(highlight); | |
| 326 | + g.drawLine(x+5,y+0,x+8,y+0); | |
| 327 | + g.drawLine(x+3,y+1,x+4,y+1); | |
| 328 | + g.drawLine(x+9,y+1,x+9,y+1); | |
| 329 | + g.drawLine(x+2,y+2,x+2,y+2); | |
| 330 | + g.drawLine(x+1,y+3,x+1,y+3); | |
| 331 | + g.drawLine(x,y+4,x,y+9); | |
| 332 | + g.drawLine(x+1,y+10,x+1,y+10); | |
| 333 | + g.drawLine(x+2,y+11,x+2,y+11); | |
| 334 | + | |
| 335 | + g.setColor(shadow); | |
| 336 | + g.drawLine(x+3,y+12,x+4,y+12); | |
| 337 | + g.drawLine(x+5,y+13,x+8,y+13); | |
| 338 | + g.drawLine(x+9,y+12,x+10,y+12); | |
| 339 | + g.drawLine(x+11,y+11,x+11,y+11); | |
| 340 | + g.drawLine(x+12,y+10,x+12,y+10); | |
| 341 | + g.drawLine(x+13,y+9,x+13,y+4); | |
| 342 | + g.drawLine(x+12,y+3,x+12,y+3); | |
| 343 | + g.drawLine(x+11,y+2,x+11,y+2); | |
| 344 | + g.drawLine(x+10,y+1,x+10,y+1); | |
| 345 | + | |
| 346 | + } | |
| 347 | + } | |
| 348 | + | |
| 349 | + public int getIconWidth() { | |
| 350 | + return 14; | |
| 351 | + } | |
| 352 | + | |
| 353 | + public int getIconHeight() { | |
| 354 | + return 14; | |
| 355 | + } | |
| 356 | + } // end class RadioButtonIcon | |
| 357 | + | |
| 358 | + private static class MenuItemCheckIcon implements Icon, UIResource, Serializable | |
| 359 | + { | |
| 360 | + public void paintIcon(Component c,Graphics g, int x, int y) | |
| 361 | + { | |
| 362 | + } | |
| 363 | + public int getIconWidth() { return 0; } | |
| 364 | + public int getIconHeight() { return 0; } | |
| 365 | + } // end class MenuItemCheckIcon | |
| 366 | + | |
| 367 | + | |
| 368 | + private static class MenuItemArrowIcon implements Icon, UIResource, Serializable | |
| 369 | + { | |
| 370 | + public void paintIcon(Component c,Graphics g, int x, int y) | |
| 371 | + { | |
| 372 | + } | |
| 373 | + public int getIconWidth() { return 0; } | |
| 374 | + public int getIconHeight() { return 0; } | |
| 375 | + } // end class MenuItemArrowIcon | |
| 376 | + | |
| 377 | + private static class MenuArrowIcon implements Icon, UIResource, Serializable | |
| 378 | + { | |
| 379 | + private Color focus = UIManager.getColor("windowBorder"); | |
| 380 | + private Color shadow = UIManager.getColor("controlShadow"); | |
| 381 | + private Color highlight = UIManager.getColor("controlHighlight"); | |
| 382 | + | |
| 383 | + public void paintIcon(Component c, Graphics g, int x, int y) { | |
| 384 | + AbstractButton b = (AbstractButton) c; | |
| 385 | + ButtonModel model = b.getModel(); | |
| 386 | + | |
| 387 | + // These variables are kind of pointless as the following code | |
| 388 | + // assumes the icon will be 10 x 10 regardless of their value. | |
| 389 | + int w = getIconWidth(); | |
| 390 | + int h = getIconHeight(); | |
| 391 | + | |
| 392 | + Color oldColor = g.getColor(); | |
| 393 | + | |
| 394 | + if (model.isSelected()){ | |
| 395 | + if( MotifGraphicsUtils.isLeftToRight(c) ){ | |
| 396 | + g.setColor(shadow); | |
| 397 | + g.fillRect(x+1,y+1,2,h); | |
| 398 | + g.drawLine(x+4,y+2,x+4,y+2); | |
| 399 | + g.drawLine(x+6,y+3,x+6,y+3); | |
| 400 | + g.drawLine(x+8,y+4,x+8,y+5); | |
| 401 | + g.setColor(focus); | |
| 402 | + g.fillRect(x+2,y+2,2,h-2); | |
| 403 | + g.fillRect(x+4,y+3,2,h-4); | |
| 404 | + g.fillRect(x+6,y+4,2,h-6); | |
| 405 | + g.setColor(highlight); | |
| 406 | + g.drawLine(x+2,y+h,x+2,y+h); | |
| 407 | + g.drawLine(x+4,y+h-1,x+4,y+h-1); | |
| 408 | + g.drawLine(x+6,y+h-2,x+6,y+h-2); | |
| 409 | + g.drawLine(x+8,y+h-4,x+8,y+h-3); | |
| 410 | + } else { | |
| 411 | + g.setColor(highlight); | |
| 412 | + g.fillRect(x+7,y+1,2,10); | |
| 413 | + g.drawLine(x+5,y+9,x+5,y+9); | |
| 414 | + g.drawLine(x+3,y+8,x+3,y+8); | |
| 415 | + g.drawLine(x+1,y+6,x+1,y+7); | |
| 416 | + g.setColor(focus); | |
| 417 | + g.fillRect(x+6,y+2,2,8); | |
| 418 | + g.fillRect(x+4,y+3,2,6); | |
| 419 | + g.fillRect(x+2,y+4,2,4); | |
| 420 | + g.setColor(shadow); | |
| 421 | + g.drawLine(x+1,y+4,x+1,y+5); | |
| 422 | + g.drawLine(x+3,y+3,x+3,y+3); | |
| 423 | + g.drawLine(x+5,y+2,x+5,y+2); | |
| 424 | + g.drawLine(x+7,y+1,x+7,y+1); | |
| 425 | + } | |
| 426 | + } else { | |
| 427 | + if( MotifGraphicsUtils.isLeftToRight(c) ){ | |
| 428 | + g.setColor(highlight); | |
| 429 | + g.drawLine(x+1,y+1,x+1,y+h); | |
| 430 | + g.drawLine(x+2,y+1,x+2,y+h-2); | |
| 431 | + g.fillRect(x+3,y+2,2,2); | |
| 432 | + g.fillRect(x+5,y+3,2,2); | |
| 433 | + g.fillRect(x+7,y+4,2,2); | |
| 434 | + g.setColor(shadow); | |
| 435 | + g.drawLine(x+2,y+h-1,x+2,y+h); | |
| 436 | + g.fillRect(x+3,y+h-2,2,2); | |
| 437 | + g.fillRect(x+5,y+h-3,2,2); | |
| 438 | + g.fillRect(x+7,y+h-4,2,2); | |
| 439 | + g.setColor(oldColor); | |
| 440 | + } else { | |
| 441 | + g.setColor(highlight); | |
| 442 | + g.fillRect(x+1,y+4,2,2); | |
| 443 | + g.fillRect(x+3,y+3,2,2); | |
| 444 | + g.fillRect(x+5,y+2,2,2); | |
| 445 | + g.drawLine(x+7,y+1,x+7,y+2); | |
| 446 | + g.setColor(shadow); | |
| 447 | + g.fillRect(x+1,y+h-4,2,2); | |
| 448 | + g.fillRect(x+3,y+h-3,2,2); | |
| 449 | + g.fillRect(x+5,y+h-2,2,2); | |
| 450 | + g.drawLine(x+7,y+3,x+7,y+h); | |
| 451 | + g.drawLine(x+8,y+1,x+8,y+h); | |
| 452 | + g.setColor(oldColor); | |
| 453 | + } | |
| 454 | + } | |
| 455 | + | |
| 456 | + } | |
| 457 | + public int getIconWidth() { return 10; } | |
| 458 | + public int getIconHeight() { return 10; } | |
| 459 | + } // End class MenuArrowIcon | |
| 460 | +} | |
| @@ -0,0 +1,374 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.awt.event.*; | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.border.*; | |
| 32 | +import javax.swing.event.InternalFrameEvent; | |
| 33 | +import javax.swing.plaf.basic.*; | |
| 34 | +import java.util.EventListener; | |
| 35 | +import java.beans.PropertyChangeListener; | |
| 36 | +import java.beans.PropertyChangeEvent; | |
| 37 | +import java.beans.VetoableChangeListener; | |
| 38 | +import java.beans.PropertyVetoException; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Class that manages a Motif title bar | |
| 42 | + * | |
| 43 | + * @since 1.3 | |
| 44 | + */ | |
| 45 | +public class MotifInternalFrameTitlePane | |
| 46 | + extends BasicInternalFrameTitlePane implements LayoutManager, ActionListener, PropertyChangeListener | |
| 47 | +{ | |
| 48 | + SystemButton systemButton; | |
| 49 | + MinimizeButton minimizeButton; | |
| 50 | + MaximizeButton maximizeButton; | |
| 51 | + JPopupMenu systemMenu; | |
| 52 | + Title title; | |
| 53 | + Color color; | |
| 54 | + Color highlight; | |
| 55 | + Color shadow; | |
| 56 | + | |
| 57 | + // The width and height of a title pane button | |
| 58 | + public final static int BUTTON_SIZE = 19; // 17 + 1 pixel border | |
| 59 | + | |
| 60 | + | |
| 61 | + public MotifInternalFrameTitlePane(JInternalFrame frame) { | |
| 62 | + super(frame); | |
| 63 | + } | |
| 64 | + | |
| 65 | + protected void installDefaults() { | |
| 66 | + setFont(UIManager.getFont("InternalFrame.titleFont")); | |
| 67 | + setPreferredSize(new Dimension(100, BUTTON_SIZE)); | |
| 68 | + } | |
| 69 | + | |
| 70 | + protected void uninstallListeners() { | |
| 71 | + // Get around protected method in superclass | |
| 72 | + super.uninstallListeners(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + protected PropertyChangeListener createPropertyChangeListener() { | |
| 76 | + return this; | |
| 77 | + } | |
| 78 | + | |
| 79 | + protected LayoutManager createLayout() { | |
| 80 | + return this; | |
| 81 | + } | |
| 82 | + | |
| 83 | + JPopupMenu getSystemMenu() { | |
| 84 | + return systemMenu; | |
| 85 | + } | |
| 86 | + | |
| 87 | + protected void assembleSystemMenu() { | |
| 88 | + systemMenu = new JPopupMenu(); | |
| 89 | + JMenuItem mi = systemMenu.add(new JMenuItem(restoreAction)); | |
| 90 | + mi.setMnemonic('R'); | |
| 91 | + mi = systemMenu.add(new JMenuItem(moveAction)); | |
| 92 | + mi.setMnemonic('M'); | |
| 93 | + mi = systemMenu.add(new JMenuItem(sizeAction)); | |
| 94 | + mi.setMnemonic('S'); | |
| 95 | + mi = systemMenu.add(new JMenuItem(iconifyAction)); | |
| 96 | + mi.setMnemonic('n'); | |
| 97 | + mi = systemMenu.add(new JMenuItem(maximizeAction)); | |
| 98 | + mi.setMnemonic('x'); | |
| 99 | + systemMenu.add(new JSeparator()); | |
| 100 | + mi = systemMenu.add(new JMenuItem(closeAction)); | |
| 101 | + mi.setMnemonic('C'); | |
| 102 | + | |
| 103 | + systemButton = new SystemButton(); | |
| 104 | + systemButton.addActionListener(new ActionListener() { | |
| 105 | + public void actionPerformed(ActionEvent e) { | |
| 106 | + systemMenu.show(systemButton, 0, BUTTON_SIZE); | |
| 107 | + } | |
| 108 | + }); | |
| 109 | + | |
| 110 | + systemButton.addMouseListener(new MouseAdapter() { | |
| 111 | + public void mousePressed(MouseEvent evt) { | |
| 112 | + try { | |
| 113 | + frame.setSelected(true); | |
| 114 | + } catch (PropertyVetoException pve) { | |
| 115 | + } | |
| 116 | + if ((evt.getClickCount() == 2)) { | |
| 117 | + closeAction.actionPerformed(new | |
| 118 | + ActionEvent(evt.getSource(), | |
| 119 | + ActionEvent.ACTION_PERFORMED, | |
| 120 | + null, evt.getWhen(), 0)); | |
| 121 | + systemMenu.setVisible(false); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + | |
| 127 | + | |
| 128 | + protected void createButtons() { | |
| 129 | + minimizeButton = new MinimizeButton(); | |
| 130 | + minimizeButton.addActionListener(iconifyAction); | |
| 131 | + | |
| 132 | + maximizeButton = new MaximizeButton(); | |
| 133 | + maximizeButton.addActionListener(maximizeAction); | |
| 134 | + } | |
| 135 | + | |
| 136 | + | |
| 137 | + protected void addSubComponents() { | |
| 138 | + title = new Title(frame.getTitle()); | |
| 139 | + title.setFont(getFont()); | |
| 140 | + | |
| 141 | + add(systemButton); | |
| 142 | + add(title); | |
| 143 | + add(minimizeButton); | |
| 144 | + add(maximizeButton); | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void paintComponent(Graphics g) { | |
| 148 | + } | |
| 149 | + | |
| 150 | + void setColors(Color c, Color h, Color s) { | |
| 151 | + color = c; | |
| 152 | + highlight = h; | |
| 153 | + shadow = s; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public void actionPerformed(ActionEvent e) { | |
| 157 | + } | |
| 158 | + | |
| 159 | + public void propertyChange(PropertyChangeEvent evt) { | |
| 160 | + String prop = evt.getPropertyName(); | |
| 161 | + JInternalFrame f = (JInternalFrame)evt.getSource(); | |
| 162 | + boolean value = false; | |
| 163 | + if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) { | |
| 164 | + repaint(); | |
| 165 | + } else if (prop.equals("maximizable")) { | |
| 166 | + if ((Boolean)evt.getNewValue() == Boolean.TRUE) | |
| 167 | + add(maximizeButton); | |
| 168 | + else | |
| 169 | + remove(maximizeButton); | |
| 170 | + revalidate(); | |
| 171 | + repaint(); | |
| 172 | + } else if (prop.equals("iconable")) { | |
| 173 | + if ((Boolean)evt.getNewValue() == Boolean.TRUE) | |
| 174 | + add(minimizeButton); | |
| 175 | + else | |
| 176 | + remove(minimizeButton); | |
| 177 | + revalidate(); | |
| 178 | + repaint(); | |
| 179 | + } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) { | |
| 180 | + repaint(); | |
| 181 | + } | |
| 182 | + enableActions(); | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void addLayoutComponent(String name, Component c) {} | |
| 186 | + public void removeLayoutComponent(Component c) {} | |
| 187 | + public Dimension preferredLayoutSize(Container c) { | |
| 188 | + return minimumLayoutSize(c); | |
| 189 | + } | |
| 190 | + | |
| 191 | + public Dimension minimumLayoutSize(Container c) { | |
| 192 | + return new Dimension(100, BUTTON_SIZE); | |
| 193 | + } | |
| 194 | + | |
| 195 | + public void layoutContainer(Container c) { | |
| 196 | + int w = getWidth(); | |
| 197 | + systemButton.setBounds(0, 0, BUTTON_SIZE, BUTTON_SIZE); | |
| 198 | + int x = w - BUTTON_SIZE; | |
| 199 | + | |
| 200 | + if(frame.isMaximizable()) { | |
| 201 | + maximizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE); | |
| 202 | + x -= BUTTON_SIZE; | |
| 203 | + } else if(maximizeButton.getParent() != null) { | |
| 204 | + maximizeButton.getParent().remove(maximizeButton); | |
| 205 | + } | |
| 206 | + | |
| 207 | + if(frame.isIconifiable()) { | |
| 208 | + minimizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE); | |
| 209 | + x -= BUTTON_SIZE; | |
| 210 | + } else if(minimizeButton.getParent() != null) { | |
| 211 | + minimizeButton.getParent().remove(minimizeButton); | |
| 212 | + } | |
| 213 | + | |
| 214 | + title.setBounds(BUTTON_SIZE, 0, x, BUTTON_SIZE); | |
| 215 | + } | |
| 216 | + | |
| 217 | + protected void showSystemMenu(){ | |
| 218 | + systemMenu.show(systemButton, 0, BUTTON_SIZE); | |
| 219 | + } | |
| 220 | + | |
| 221 | + protected void hideSystemMenu(){ | |
| 222 | + systemMenu.setVisible(false); | |
| 223 | + } | |
| 224 | + | |
| 225 | + static Dimension buttonDimension = new Dimension(BUTTON_SIZE, BUTTON_SIZE); | |
| 226 | + | |
| 227 | + private abstract class FrameButton extends JButton { | |
| 228 | + | |
| 229 | + FrameButton() { | |
| 230 | + super(); | |
| 231 | + setFocusPainted(false); | |
| 232 | + setBorderPainted(false); | |
| 233 | + } | |
| 234 | + | |
| 235 | + public boolean isFocusTraversable() { | |
| 236 | + return false; | |
| 237 | + } | |
| 238 | + | |
| 239 | + public void requestFocus() { | |
| 240 | + // ignore request. | |
| 241 | + } | |
| 242 | + | |
| 243 | + public Dimension getMinimumSize() { | |
| 244 | + return buttonDimension; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public Dimension getPreferredSize() { | |
| 248 | + return buttonDimension; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public void paintComponent(Graphics g) { | |
| 252 | + Dimension d = getSize(); | |
| 253 | + int maxX = d.width - 1; | |
| 254 | + int maxY = d.height - 1; | |
| 255 | + | |
| 256 | + // draw background | |
| 257 | + g.setColor(color); | |
| 258 | + g.fillRect(1, 1, d.width, d.height); | |
| 259 | + | |
| 260 | + // draw border | |
| 261 | + boolean pressed = getModel().isPressed(); | |
| 262 | + g.setColor(pressed ? shadow : highlight); | |
| 263 | + g.drawLine(0, 0, maxX, 0); | |
| 264 | + g.drawLine(0, 0, 0, maxY); | |
| 265 | + g.setColor(pressed ? highlight : shadow); | |
| 266 | + g.drawLine(1, maxY, maxX, maxY); | |
| 267 | + g.drawLine(maxX, 1, maxX, maxY); | |
| 268 | + } | |
| 269 | + } | |
| 270 | + | |
| 271 | + private class MinimizeButton extends FrameButton { | |
| 272 | + public void paintComponent(Graphics g) { | |
| 273 | + super.paintComponent(g); | |
| 274 | + g.setColor(highlight); | |
| 275 | + g.drawLine(7, 8, 7, 11); | |
| 276 | + g.drawLine(7, 8, 10, 8); | |
| 277 | + g.setColor(shadow); | |
| 278 | + g.drawLine(8, 11, 10, 11); | |
| 279 | + g.drawLine(11, 9, 11, 11); | |
| 280 | + } | |
| 281 | + } | |
| 282 | + | |
| 283 | + private class MaximizeButton extends FrameButton { | |
| 284 | + public void paintComponent(Graphics g) { | |
| 285 | + super.paintComponent(g); | |
| 286 | + int max = BUTTON_SIZE - 5; | |
| 287 | + boolean isMaxed = frame.isMaximum(); | |
| 288 | + g.setColor(isMaxed ? shadow : highlight); | |
| 289 | + g.drawLine(4, 4, 4, max); | |
| 290 | + g.drawLine(4, 4, max, 4); | |
| 291 | + g.setColor(isMaxed ? highlight : shadow); | |
| 292 | + g.drawLine(5, max, max, max); | |
| 293 | + g.drawLine(max, 5, max, max); | |
| 294 | + } | |
| 295 | + } | |
| 296 | + | |
| 297 | + private class SystemButton extends FrameButton { | |
| 298 | + public boolean isFocusTraversable() { return false; } | |
| 299 | + public void requestFocus() {} | |
| 300 | + | |
| 301 | + public void paintComponent(Graphics g) { | |
| 302 | + super.paintComponent(g); | |
| 303 | + g.setColor(highlight); | |
| 304 | + g.drawLine(4, 8, 4, 11); | |
| 305 | + g.drawLine(4, 8, BUTTON_SIZE - 5, 8); | |
| 306 | + g.setColor(shadow); | |
| 307 | + g.drawLine(5, 11, BUTTON_SIZE - 5, 11); | |
| 308 | + g.drawLine(BUTTON_SIZE - 5, 9, BUTTON_SIZE - 5, 11); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + | |
| 312 | + private class Title extends FrameButton { | |
| 313 | + Title(String title) { | |
| 314 | + super(); | |
| 315 | + setText(title); | |
| 316 | + setHorizontalAlignment(SwingConstants.CENTER); | |
| 317 | + setBorder(BorderFactory.createBevelBorder( | |
| 318 | + BevelBorder.RAISED, | |
| 319 | + UIManager.getColor("activeCaptionBorder"), | |
| 320 | + UIManager.getColor("inactiveCaptionBorder"))); | |
| 321 | + | |
| 322 | + // Forward mouse events to titlebar for moves. | |
| 323 | + addMouseMotionListener(new MouseMotionListener() { | |
| 324 | + public void mouseDragged(MouseEvent e) { | |
| 325 | + forwardEventToParent(e); | |
| 326 | + } | |
| 327 | + public void mouseMoved(MouseEvent e) { | |
| 328 | + forwardEventToParent(e); | |
| 329 | + } | |
| 330 | + }); | |
| 331 | + addMouseListener(new MouseListener() { | |
| 332 | + public void mouseClicked(MouseEvent e) { | |
| 333 | + forwardEventToParent(e); | |
| 334 | + } | |
| 335 | + public void mousePressed(MouseEvent e) { | |
| 336 | + forwardEventToParent(e); | |
| 337 | + } | |
| 338 | + public void mouseReleased(MouseEvent e) { | |
| 339 | + forwardEventToParent(e); | |
| 340 | + } | |
| 341 | + public void mouseEntered(MouseEvent e) { | |
| 342 | + forwardEventToParent(e); | |
| 343 | + } | |
| 344 | + public void mouseExited(MouseEvent e) { | |
| 345 | + forwardEventToParent(e); | |
| 346 | + } | |
| 347 | + }); | |
| 348 | + } | |
| 349 | + | |
| 350 | + void forwardEventToParent(MouseEvent e) { | |
| 351 | + getParent().dispatchEvent(new MouseEvent( | |
| 352 | + getParent(), e.getID(), e.getWhen(), e.getModifiers(), | |
| 353 | + e.getX(), e.getY(), e.getXOnScreen(), | |
| 354 | + e.getYOnScreen(), e.getClickCount(), | |
| 355 | + e.isPopupTrigger(), MouseEvent.NOBUTTON)); | |
| 356 | + } | |
| 357 | + | |
| 358 | + public void paintComponent(Graphics g) { | |
| 359 | + super.paintComponent(g); | |
| 360 | + if (frame.isSelected()) { | |
| 361 | + g.setColor(UIManager.getColor("activeCaptionText")); | |
| 362 | + } else { | |
| 363 | + g.setColor(UIManager.getColor("inactiveCaptionText")); | |
| 364 | + } | |
| 365 | + Dimension d = getSize(); | |
| 366 | + String frameTitle = frame.getTitle(); | |
| 367 | + if (frameTitle != null) { | |
| 368 | + MotifGraphicsUtils.drawStringInRect(frame, g, frameTitle, | |
| 369 | + 0, 0, d.width, d.height, | |
| 370 | + SwingConstants.CENTER); | |
| 371 | + } | |
| 372 | + } | |
| 373 | + } | |
| 374 | +} | |
| @@ -0,0 +1,223 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import java.awt.*; | |
| 29 | +import java.awt.event.*; | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.event.*; | |
| 32 | + | |
| 33 | +import java.util.EventListener; | |
| 34 | + | |
| 35 | +import javax.swing.plaf.basic.*; | |
| 36 | +import javax.swing.border.*; | |
| 37 | +import javax.swing.plaf.*; | |
| 38 | + | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * A Motif L&F implementation of InternalFrame. | |
| 42 | + * <p> | |
| 43 | + * <strong>Warning:</strong> | |
| 44 | + * Serialized objects of this class will not be compatible with | |
| 45 | + * future Swing releases. The current serialization support is appropriate | |
| 46 | + * for short term storage or RMI between applications running the same | |
| 47 | + * version of Swing. A future release of Swing will provide support for | |
| 48 | + * long term persistence. | |
| 49 | + * | |
| 50 | + * @author Tom Ball | |
| 51 | + */ | |
| 52 | +public class MotifInternalFrameUI extends BasicInternalFrameUI { | |
| 53 | + | |
| 54 | + Color color; | |
| 55 | + Color highlight; | |
| 56 | + Color shadow; | |
| 57 | + MotifInternalFrameTitlePane titlePane; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * As of Java 2 platform v1.3 this previously undocumented field is no | |
| 61 | + * longer used. | |
| 62 | + * Key bindings are now defined by the LookAndFeel, please refer to | |
| 63 | + * the key bindings specification for further details. | |
| 64 | + * | |
| 65 | + * @deprecated As of Java 2 platform v1.3. | |
| 66 | + */ | |
| 67 | + @Deprecated | |
| 68 | + protected KeyStroke closeMenuKey; | |
| 69 | + | |
| 70 | + | |
| 71 | +///////////////////////////////////////////////////////////////////////////// | |
| 72 | +// ComponentUI Interface Implementation methods | |
| 73 | +///////////////////////////////////////////////////////////////////////////// | |
| 74 | + public static ComponentUI createUI(JComponent w) { | |
| 75 | + return new MotifInternalFrameUI((JInternalFrame)w); | |
| 76 | + } | |
| 77 | + | |
| 78 | + public MotifInternalFrameUI(JInternalFrame w) { | |
| 79 | + super(w); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void installUI(JComponent c) { | |
| 83 | + super.installUI(c); | |
| 84 | + setColors((JInternalFrame)c); | |
| 85 | + } | |
| 86 | + | |
| 87 | + protected void installDefaults() { | |
| 88 | + Border frameBorder = frame.getBorder(); | |
| 89 | + frame.setLayout(internalFrameLayout = createLayoutManager()); | |
| 90 | + if (frameBorder == null || frameBorder instanceof UIResource) { | |
| 91 | + frame.setBorder(new MotifBorders.InternalFrameBorder(frame)); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 95 | + | |
| 96 | + protected void installKeyboardActions(){ | |
| 97 | + super.installKeyboardActions(); | |
| 98 | + // We replace the | |
| 99 | + // we use JPopup in our TitlePane so need escape support | |
| 100 | + closeMenuKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); | |
| 101 | + } | |
| 102 | + | |
| 103 | + | |
| 104 | + protected void uninstallDefaults() { | |
| 105 | + LookAndFeel.uninstallBorder(frame); | |
| 106 | + frame.setLayout(null); | |
| 107 | + internalFrameLayout = null; | |
| 108 | + } | |
| 109 | + | |
| 110 | + private JInternalFrame getFrame(){ | |
| 111 | + return frame; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public JComponent createNorthPane(JInternalFrame w) { | |
| 115 | + titlePane = new MotifInternalFrameTitlePane(w); | |
| 116 | + return titlePane; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public Dimension getMaximumSize(JComponent x) { | |
| 120 | + return Toolkit.getDefaultToolkit().getScreenSize(); | |
| 121 | + } | |
| 122 | + | |
| 123 | + protected void uninstallKeyboardActions(){ | |
| 124 | + super.uninstallKeyboardActions(); | |
| 125 | + if (isKeyBindingRegistered()){ | |
| 126 | + JInternalFrame.JDesktopIcon di = frame.getDesktopIcon(); | |
| 127 | + SwingUtilities.replaceUIActionMap(di, null); | |
| 128 | + SwingUtilities.replaceUIInputMap(di, JComponent.WHEN_IN_FOCUSED_WINDOW, | |
| 129 | + null); | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + protected void setupMenuOpenKey(){ | |
| 134 | + super.setupMenuOpenKey(); | |
| 135 | + ActionMap map = SwingUtilities.getUIActionMap(frame); | |
| 136 | + if (map != null) { | |
| 137 | + // BasicInternalFrameUI creates an action with the same name, we override | |
| 138 | + // it as MotifInternalFrameTitlePane has a titlePane ivar that shadows the | |
| 139 | + // titlePane ivar in BasicInternalFrameUI, making supers action throw | |
| 140 | + // an NPE for us. | |
| 141 | + map.put("showSystemMenu", new AbstractAction(){ | |
| 142 | + public void actionPerformed(ActionEvent e){ | |
| 143 | + titlePane.showSystemMenu(); | |
| 144 | + } | |
| 145 | + public boolean isEnabled(){ | |
| 146 | + return isKeyBindingActive(); | |
| 147 | + } | |
| 148 | + }); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + protected void setupMenuCloseKey(){ | |
| 153 | + ActionMap map = SwingUtilities.getUIActionMap(frame); | |
| 154 | + if (map != null) { | |
| 155 | + map.put("hideSystemMenu", new AbstractAction(){ | |
| 156 | + public void actionPerformed(ActionEvent e){ | |
| 157 | + titlePane.hideSystemMenu(); | |
| 158 | + } | |
| 159 | + public boolean isEnabled(){ | |
| 160 | + return isKeyBindingActive(); | |
| 161 | + } | |
| 162 | + }); | |
| 163 | + } | |
| 164 | + | |
| 165 | + // Set up the bindings for the DesktopIcon, it is odd that | |
| 166 | + // we install them, and not the desktop icon. | |
| 167 | + JInternalFrame.JDesktopIcon di = frame.getDesktopIcon(); | |
| 168 | + InputMap diInputMap = SwingUtilities.getUIInputMap | |
| 169 | + (di, JComponent.WHEN_IN_FOCUSED_WINDOW); | |
| 170 | + if (diInputMap == null) { | |
| 171 | + Object[] bindings = (Object[])UIManager.get | |
| 172 | + ("DesktopIcon.windowBindings"); | |
| 173 | + if (bindings != null) { | |
| 174 | + diInputMap = LookAndFeel.makeComponentInputMap(di, bindings); | |
| 175 | + | |
| 176 | + SwingUtilities.replaceUIInputMap(di, JComponent. | |
| 177 | + WHEN_IN_FOCUSED_WINDOW, | |
| 178 | + diInputMap); | |
| 179 | + } | |
| 180 | + } | |
| 181 | + ActionMap diActionMap = SwingUtilities.getUIActionMap(di); | |
| 182 | + if (diActionMap == null) { | |
| 183 | + diActionMap = new ActionMapUIResource(); | |
| 184 | + diActionMap.put("hideSystemMenu", new AbstractAction(){ | |
| 185 | + public void actionPerformed(ActionEvent e){ | |
| 186 | + JInternalFrame.JDesktopIcon icon = getFrame(). | |
| 187 | + getDesktopIcon(); | |
| 188 | + MotifDesktopIconUI micon = (MotifDesktopIconUI)icon. | |
| 189 | + getUI(); | |
| 190 | + micon.hideSystemMenu(); | |
| 191 | + } | |
| 192 | + public boolean isEnabled(){ | |
| 193 | + return isKeyBindingActive(); | |
| 194 | + } | |
| 195 | + }); | |
| 196 | + SwingUtilities.replaceUIActionMap(di, diActionMap); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + /** This method is called when the frame becomes selected. | |
| 201 | + */ | |
| 202 | + protected void activateFrame(JInternalFrame f) { | |
| 203 | + super.activateFrame(f); | |
| 204 | + setColors(f); | |
| 205 | + } | |
| 206 | + /** This method is called when the frame is no longer selected. | |
| 207 | + */ | |
| 208 | + protected void deactivateFrame(JInternalFrame f) { | |
| 209 | + setColors(f); | |
| 210 | + super.deactivateFrame(f); | |
| 211 | + } | |
| 212 | + | |
| 213 | + void setColors(JInternalFrame frame) { | |
| 214 | + if (frame.isSelected()) { | |
| 215 | + color = UIManager.getColor("InternalFrame.activeTitleBackground"); | |
| 216 | + } else { | |
| 217 | + color = UIManager.getColor("InternalFrame.inactiveTitleBackground"); | |
| 218 | + } | |
| 219 | + highlight = color.brighter(); | |
| 220 | + shadow = color.darker().darker(); | |
| 221 | + titlePane.setColors(color, highlight, shadow); | |
| 222 | + } | |
| 223 | +} | |
| @@ -0,0 +1,61 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import sun.awt.AppContext; | |
| 29 | + | |
| 30 | +import javax.swing.*; | |
| 31 | +import javax.swing.plaf.basic.BasicLabelUI; | |
| 32 | +import javax.swing.plaf.ComponentUI; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * A Motif L&F implementation of LabelUI. | |
| 36 | + * This merely sets up new default values in MotifLookAndFeel. | |
| 37 | + * <p> | |
| 38 | + * <strong>Warning:</strong> | |
| 39 | + * Serialized objects of this class will not be compatible with | |
| 40 | + * future Swing releases. The current serialization support is appropriate | |
| 41 | + * for short term storage or RMI between applications running the same | |
| 42 | + * version of Swing. A future release of Swing will provide support for | |
| 43 | + * long term persistence. | |
| 44 | + * | |
| 45 | + * @author Amy Fowler | |
| 46 | + */ | |
| 47 | +public class MotifLabelUI extends BasicLabelUI | |
| 48 | +{ | |
| 49 | + private static final Object MOTIF_LABEL_UI_KEY = new Object(); | |
| 50 | + | |
| 51 | + public static ComponentUI createUI(JComponent c) { | |
| 52 | + AppContext appContext = AppContext.getAppContext(); | |
| 53 | + MotifLabelUI motifLabelUI = | |
| 54 | + (MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY); | |
| 55 | + if (motifLabelUI == null) { | |
| 56 | + motifLabelUI = new MotifLabelUI(); | |
| 57 | + appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI); | |
| 58 | + } | |
| 59 | + return motifLabelUI; | |
| 60 | + } | |
| 61 | +} | |
| @@ -0,0 +1,1283 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import java.awt.Color; | |
| 29 | +import java.awt.Font; | |
| 30 | +import java.awt.Insets; | |
| 31 | +import java.awt.event.KeyEvent; | |
| 32 | +import java.awt.event.InputEvent; | |
| 33 | +import java.util.*; | |
| 34 | + | |
| 35 | +import javax.swing.*; | |
| 36 | +import javax.swing.plaf.*; | |
| 37 | +import javax.swing.border.*; | |
| 38 | +import javax.swing.text.JTextComponent; | |
| 39 | +import javax.swing.text.DefaultEditorKit; | |
| 40 | + | |
| 41 | +import javax.swing.plaf.basic.BasicLookAndFeel; | |
| 42 | +import javax.swing.plaf.basic.BasicBorders; | |
| 43 | +import javax.swing.plaf.basic.BasicComboBoxRenderer; | |
| 44 | +import javax.swing.plaf.basic.BasicComboBoxEditor; | |
| 45 | + | |
| 46 | +import sun.swing.SwingUtilities2; | |
| 47 | +import sun.awt.OSInfo; | |
| 48 | + | |
| 49 | +/** | |
| 50 | + * Implements the Motif Look and Feel. | |
| 51 | + * UI classes not implemented specifically for Motif will | |
| 52 | + * default to those implemented in Basic. | |
| 53 | + * <p> | |
| 54 | + * <strong>Warning:</strong> | |
| 55 | + * Serialized objects of this class will not be compatible with | |
| 56 | + * future Swing releases. The current serialization support is appropriate | |
| 57 | + * for short term storage or RMI between applications running the same | |
| 58 | + * version of Swing. A future release of Swing will provide support for | |
| 59 | + * long term persistence. | |
| 60 | + * | |
| 61 | + * @author unattributed | |
| 62 | + */ | |
| 63 | +public class MotifLookAndFeel extends BasicLookAndFeel | |
| 64 | +{ | |
| 65 | + public String getName() { | |
| 66 | + return "CDE/Motif"; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public String getID() { | |
| 70 | + return "Motif"; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public String getDescription() { | |
| 74 | + return "The CDE/Motif Look and Feel"; | |
| 75 | + } | |
| 76 | + | |
| 77 | + | |
| 78 | + public boolean isNativeLookAndFeel() { | |
| 79 | + return OSInfo.getOSType() == OSInfo.OSType.SOLARIS; | |
| 80 | + } | |
| 81 | + | |
| 82 | + | |
| 83 | + public boolean isSupportedLookAndFeel() { | |
| 84 | + return true; | |
| 85 | + } | |
| 86 | + | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Load the SystemColors into the defaults table. The keys | |
| 90 | + * for SystemColor defaults are the same as the names of | |
| 91 | + * the public fields in SystemColor. If the table is being | |
| 92 | + * created on a native Motif platform we use the SystemColor | |
| 93 | + * values, otherwise we create color objects whose values match | |
| 94 | + * the default CDE/Motif colors. | |
| 95 | + */ | |
| 96 | + protected void initSystemColorDefaults(UIDefaults table) | |
| 97 | + { | |
| 98 | + String[] defaultSystemColors = { | |
| 99 | + "desktop", "#005C5C", /* Color of the desktop background */ | |
| 100 | + "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */ | |
| 101 | + "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */ | |
| 102 | + "activeCaptionBorder", "#B24D7A", /* Border color for caption (title bar) window borders. */ | |
| 103 | + "inactiveCaption", "#AEB2C3", /* Color for captions (title bars) when not active. */ | |
| 104 | + "inactiveCaptionText", "#000000", /* Text color for text in inactive captions (title bars). */ | |
| 105 | + "inactiveCaptionBorder", "#AEB2C3", /* Border color for inactive caption (title bar) window borders. */ | |
| 106 | + "window", "#AEB2C3", /* Default color for the interior of windows */ | |
| 107 | + "windowBorder", "#AEB2C3", /* ??? */ | |
| 108 | + "windowText", "#000000", /* ??? */ | |
| 109 | + "menu", "#AEB2C3", /* ??? */ | |
| 110 | + "menuText", "#000000", /* ??? */ | |
| 111 | + "text", "#FFF7E9", /* Text background color */ | |
| 112 | + "textText", "#000000", /* Text foreground color */ | |
| 113 | + "textHighlight", "#000000", /* Text background color when selected */ | |
| 114 | + "textHighlightText", "#FFF7E9", /* Text color when selected */ | |
| 115 | + "textInactiveText", "#808080", /* Text color when disabled */ | |
| 116 | + "control", "#AEB2C3", /* Default color for controls (buttons, sliders, etc) */ | |
| 117 | + "controlText", "#000000", /* Default color for text in controls */ | |
| 118 | + "controlHighlight", "#DCDEE5", /* Highlight color for controls */ | |
| 119 | + "controlLtHighlight", "#DCDEE5", /* Light highlight color for controls */ | |
| 120 | + "controlShadow", "#63656F", /* Shadow color for controls */ | |
| 121 | + "controlLightShadow", "#9397A5", /* Shadow color for controls */ | |
| 122 | + "controlDkShadow", "#000000", /* Dark shadow color for controls */ | |
| 123 | + "scrollbar", "#AEB2C3", /* Scrollbar ??? color. PENDING(jeff) foreground? background? ?*/ | |
| 124 | + "info", "#FFF7E9", /* ??? */ | |
| 125 | + "infoText", "#000000" /* ??? */ | |
| 126 | + }; | |
| 127 | + | |
| 128 | + loadSystemColors(table, defaultSystemColors, false); | |
| 129 | + } | |
| 130 | + | |
| 131 | + | |
| 132 | + protected void initClassDefaults(UIDefaults table) | |
| 133 | + { | |
| 134 | + super.initClassDefaults(table); | |
| 135 | + String motifPackageName = "com.sun.java.swing.plaf.motif."; | |
| 136 | + | |
| 137 | + Object[] uiDefaults = { | |
| 138 | + "ButtonUI", motifPackageName + "MotifButtonUI", | |
| 139 | + "CheckBoxUI", motifPackageName + "MotifCheckBoxUI", | |
| 140 | + "DirectoryPaneUI", motifPackageName + "MotifDirectoryPaneUI", | |
| 141 | + "FileChooserUI", motifPackageName + "MotifFileChooserUI", | |
| 142 | + "LabelUI", motifPackageName + "MotifLabelUI", | |
| 143 | + "MenuBarUI", motifPackageName + "MotifMenuBarUI", | |
| 144 | + "MenuUI", motifPackageName + "MotifMenuUI", | |
| 145 | + "MenuItemUI", motifPackageName + "MotifMenuItemUI", | |
| 146 | + "CheckBoxMenuItemUI", motifPackageName + "MotifCheckBoxMenuItemUI", | |
| 147 | + "RadioButtonMenuItemUI", motifPackageName + "MotifRadioButtonMenuItemUI", | |
| 148 | + "RadioButtonUI", motifPackageName + "MotifRadioButtonUI", | |
| 149 | + "ToggleButtonUI", motifPackageName + "MotifToggleButtonUI", | |
| 150 | + "PopupMenuUI", motifPackageName + "MotifPopupMenuUI", | |
| 151 | + "ProgressBarUI", motifPackageName + "MotifProgressBarUI", | |
| 152 | + "ScrollBarUI", motifPackageName + "MotifScrollBarUI", | |
| 153 | + "ScrollPaneUI", motifPackageName + "MotifScrollPaneUI", | |
| 154 | + "SliderUI", motifPackageName + "MotifSliderUI", | |
| 155 | + "SplitPaneUI", motifPackageName + "MotifSplitPaneUI", | |
| 156 | + "TabbedPaneUI", motifPackageName + "MotifTabbedPaneUI", | |
| 157 | + "TextAreaUI", motifPackageName + "MotifTextAreaUI", | |
| 158 | + "TextFieldUI", motifPackageName + "MotifTextFieldUI", | |
| 159 | + "PasswordFieldUI", motifPackageName + "MotifPasswordFieldUI", | |
| 160 | + "TextPaneUI", motifPackageName + "MotifTextPaneUI", | |
| 161 | + "EditorPaneUI", motifPackageName + "MotifEditorPaneUI", | |
| 162 | + "TreeUI", motifPackageName + "MotifTreeUI", | |
| 163 | + "InternalFrameUI", motifPackageName + "MotifInternalFrameUI", | |
| 164 | + "DesktopPaneUI", motifPackageName + "MotifDesktopPaneUI", | |
| 165 | + "SeparatorUI", motifPackageName + "MotifSeparatorUI", | |
| 166 | + "PopupMenuSeparatorUI", motifPackageName + "MotifPopupMenuSeparatorUI", | |
| 167 | + "OptionPaneUI", motifPackageName + "MotifOptionPaneUI", | |
| 168 | + "ComboBoxUI", motifPackageName + "MotifComboBoxUI", | |
| 169 | + "DesktopIconUI", motifPackageName + "MotifDesktopIconUI" | |
| 170 | + }; | |
| 171 | + | |
| 172 | + table.putDefaults(uiDefaults); | |
| 173 | + } | |
| 174 | + | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Initialize the defaults table with the name of the ResourceBundle | |
| 178 | + * used for getting localized defaults. | |
| 179 | + */ | |
| 180 | + private void initResourceBundle(UIDefaults table) { | |
| 181 | + table.addResourceBundle( "com.sun.java.swing.plaf.motif.resources.motif" ); | |
| 182 | + } | |
| 183 | + | |
| 184 | + | |
| 185 | + protected void initComponentDefaults(UIDefaults table) | |
| 186 | + { | |
| 187 | + super.initComponentDefaults(table); | |
| 188 | + | |
| 189 | + initResourceBundle(table); | |
| 190 | + | |
| 191 | + FontUIResource dialogPlain12 = new FontUIResource(Font.DIALOG, | |
| 192 | + Font.PLAIN, 12); | |
| 193 | + FontUIResource serifPlain12 = new FontUIResource(Font.SERIF, | |
| 194 | + Font.PLAIN, 12); | |
| 195 | + FontUIResource sansSerifPlain12 = new FontUIResource(Font.SANS_SERIF, | |
| 196 | + Font.PLAIN, 12); | |
| 197 | + FontUIResource monospacedPlain12 = new FontUIResource(Font.MONOSPACED, | |
| 198 | + Font.PLAIN, 12); | |
| 199 | + ColorUIResource red = new ColorUIResource(Color.red); | |
| 200 | + ColorUIResource black = new ColorUIResource(Color.black); | |
| 201 | + ColorUIResource white = new ColorUIResource(Color.white); | |
| 202 | + ColorUIResource lightGray = new ColorUIResource(Color.lightGray); | |
| 203 | + ColorUIResource controlDarker = new ColorUIResource(147, 151, 165); // slate blue | |
| 204 | + ColorUIResource scrollBarTrack = controlDarker; | |
| 205 | + ColorUIResource menuItemPressedBackground = new ColorUIResource(165,165,165); | |
| 206 | + ColorUIResource menuItemPressedForeground = new ColorUIResource(0,0,0); | |
| 207 | + | |
| 208 | + | |
| 209 | + Border loweredBevelBorder = new MotifBorders.BevelBorder(false, | |
| 210 | + table.getColor("controlShadow"), | |
| 211 | + table.getColor("controlLtHighlight")); | |
| 212 | + | |
| 213 | + Border raisedBevelBorder = new MotifBorders.BevelBorder(true, table.getColor("controlShadow"), | |
| 214 | + table.getColor("controlLtHighlight")); | |
| 215 | + | |
| 216 | + Border marginBorder = new BasicBorders.MarginBorder(); | |
| 217 | + | |
| 218 | + Border focusBorder = new MotifBorders.FocusBorder( | |
| 219 | + table.getColor("control"), | |
| 220 | + table.getColor("activeCaptionBorder")); | |
| 221 | + | |
| 222 | + | |
| 223 | + Border focusBevelBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 224 | + focusBorder, | |
| 225 | + loweredBevelBorder); | |
| 226 | + | |
| 227 | + Border comboBoxBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 228 | + focusBorder, | |
| 229 | + raisedBevelBorder); | |
| 230 | + | |
| 231 | + | |
| 232 | + Border buttonBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 233 | + new MotifBorders.ButtonBorder( | |
| 234 | + table.getColor("Button.shadow"), | |
| 235 | + table.getColor("Button.highlight"), | |
| 236 | + table.getColor("Button.darkShadow"), | |
| 237 | + table.getColor("activeCaptionBorder")), | |
| 238 | + marginBorder); | |
| 239 | + | |
| 240 | + Border toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 241 | + new MotifBorders.ToggleButtonBorder( | |
| 242 | + table.getColor("ToggleButton.shadow"), | |
| 243 | + table.getColor("ToggleButton.highlight"), | |
| 244 | + table.getColor("ToggleButton.darkShadow"), | |
| 245 | + table.getColor("activeCaptionBorder")), marginBorder); | |
| 246 | + | |
| 247 | + Border textFieldBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 248 | + focusBevelBorder, | |
| 249 | + marginBorder); | |
| 250 | + | |
| 251 | + Border popupMenuBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 252 | + raisedBevelBorder, | |
| 253 | + new MotifBorders.MotifPopupMenuBorder( | |
| 254 | + table.getFont("PopupMenu.font"), | |
| 255 | + table.getColor("PopupMenu.background"), | |
| 256 | + table.getColor("PopupMenu.foreground"), | |
| 257 | + table.getColor("controlShadow"), | |
| 258 | + table.getColor("controlLtHighlight") | |
| 259 | + )); | |
| 260 | + | |
| 261 | + Object menuItemCheckIcon = new UIDefaults.LazyValue() { | |
| 262 | + public Object createValue(UIDefaults table) { | |
| 263 | + return MotifIconFactory.getMenuItemCheckIcon(); | |
| 264 | + } | |
| 265 | + }; | |
| 266 | + | |
| 267 | + Object menuItemArrowIcon = new UIDefaults.LazyValue() { | |
| 268 | + public Object createValue(UIDefaults table) { | |
| 269 | + return MotifIconFactory.getMenuItemArrowIcon(); | |
| 270 | + } | |
| 271 | + }; | |
| 272 | + | |
| 273 | + Object menuArrowIcon = new UIDefaults.LazyValue() { | |
| 274 | + public Object createValue(UIDefaults table) { | |
| 275 | + return MotifIconFactory.getMenuArrowIcon(); | |
| 276 | + } | |
| 277 | + }; | |
| 278 | + | |
| 279 | + Object checkBoxIcon = new UIDefaults.LazyValue() { | |
| 280 | + public Object createValue(UIDefaults table) { | |
| 281 | + return MotifIconFactory.getCheckBoxIcon(); | |
| 282 | + } | |
| 283 | + }; | |
| 284 | + | |
| 285 | + Object radioButtonIcon = new UIDefaults.LazyValue() { | |
| 286 | + public Object createValue(UIDefaults table) { | |
| 287 | + return MotifIconFactory.getRadioButtonIcon(); | |
| 288 | + } | |
| 289 | + }; | |
| 290 | + | |
| 291 | + Object unselectedTabBackground = new UIDefaults.LazyValue() { | |
| 292 | + public Object createValue(UIDefaults table) { | |
| 293 | + Color c = table.getColor("control"); | |
| 294 | + return new ColorUIResource(Math.max((int)(c.getRed()*.85),0), | |
| 295 | + Math.max((int)(c.getGreen()*.85),0), | |
| 296 | + Math.max((int)(c.getBlue()*.85),0)); | |
| 297 | + } | |
| 298 | + }; | |
| 299 | + | |
| 300 | + Object unselectedTabForeground = new UIDefaults.LazyValue() { | |
| 301 | + public Object createValue(UIDefaults table) { | |
| 302 | + Color c = table.getColor("controlText"); | |
| 303 | + return new ColorUIResource(Math.max((int)(c.getRed()*.85),0), | |
| 304 | + Math.max((int)(c.getGreen()*.85),0), | |
| 305 | + Math.max((int)(c.getBlue()*.85),0)); | |
| 306 | + } | |
| 307 | + }; | |
| 308 | + | |
| 309 | + Object unselectedTabShadow = new UIDefaults.LazyValue() { | |
| 310 | + public Object createValue(UIDefaults table) { | |
| 311 | + Color c = table.getColor("control"); | |
| 312 | + Color base = new Color(Math.max((int)(c.getRed()*.85),0), | |
| 313 | + Math.max((int)(c.getGreen()*.85),0), | |
| 314 | + Math.max((int)(c.getBlue()*.85),0)); | |
| 315 | + return new ColorUIResource(base.darker()); | |
| 316 | + } | |
| 317 | + }; | |
| 318 | + | |
| 319 | + Object unselectedTabHighlight = new UIDefaults.LazyValue() { | |
| 320 | + public Object createValue(UIDefaults table) { | |
| 321 | + Color c = table.getColor("control"); | |
| 322 | + Color base = new Color(Math.max((int)(c.getRed()*.85),0), | |
| 323 | + Math.max((int)(c.getGreen()*.85),0), | |
| 324 | + Math.max((int)(c.getBlue()*.85),0)); | |
| 325 | + return new ColorUIResource(base.brighter()); | |
| 326 | + } | |
| 327 | + }; | |
| 328 | + | |
| 329 | + // *** Text | |
| 330 | + | |
| 331 | + Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 332 | + "COPY", DefaultEditorKit.copyAction, | |
| 333 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 334 | + "CUT", DefaultEditorKit.cutAction, | |
| 335 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 336 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 337 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 338 | + "control F", DefaultEditorKit.forwardAction, | |
| 339 | + "control B", DefaultEditorKit.backwardAction, | |
| 340 | + "control D", DefaultEditorKit.deleteNextCharAction, | |
| 341 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 342 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 343 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 344 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 345 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 346 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 347 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 348 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 349 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 350 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 351 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 352 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 353 | + "control LEFT", DefaultEditorKit.previousWordAction, | |
| 354 | + "control RIGHT", DefaultEditorKit.nextWordAction, | |
| 355 | + "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 356 | + "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 357 | + "control SLASH", DefaultEditorKit.selectAllAction, | |
| 358 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 359 | + "END", DefaultEditorKit.endLineAction, | |
| 360 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 361 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 362 | + "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 363 | + "ENTER", JTextField.notifyAction, | |
| 364 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 365 | + }); | |
| 366 | + | |
| 367 | + Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 368 | + "COPY", DefaultEditorKit.copyAction, | |
| 369 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 370 | + "CUT", DefaultEditorKit.cutAction, | |
| 371 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 372 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 373 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 374 | + "control F", DefaultEditorKit.forwardAction, | |
| 375 | + "control B", DefaultEditorKit.backwardAction, | |
| 376 | + "control D", DefaultEditorKit.deleteNextCharAction, | |
| 377 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 378 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 379 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 380 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 381 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 382 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 383 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 384 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 385 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 386 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 387 | + "control LEFT", DefaultEditorKit.beginLineAction, | |
| 388 | + "control RIGHT", DefaultEditorKit.endLineAction, | |
| 389 | + "control shift LEFT", DefaultEditorKit.selectionBeginLineAction, | |
| 390 | + "control shift RIGHT", DefaultEditorKit.selectionEndLineAction, | |
| 391 | + "control SLASH", DefaultEditorKit.selectAllAction, | |
| 392 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 393 | + "END", DefaultEditorKit.endLineAction, | |
| 394 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 395 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 396 | + "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 397 | + "ENTER", JTextField.notifyAction, | |
| 398 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 399 | + }); | |
| 400 | + | |
| 401 | + Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { | |
| 402 | + "COPY", DefaultEditorKit.copyAction, | |
| 403 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 404 | + "CUT", DefaultEditorKit.cutAction, | |
| 405 | + "control INSERT", DefaultEditorKit.copyAction, | |
| 406 | + "shift INSERT", DefaultEditorKit.pasteAction, | |
| 407 | + "shift DELETE", DefaultEditorKit.cutAction, | |
| 408 | + "control F", DefaultEditorKit.forwardAction, | |
| 409 | + "control B", DefaultEditorKit.backwardAction, | |
| 410 | + "control D", DefaultEditorKit.deleteNextCharAction, | |
| 411 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 412 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 413 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 414 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 415 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 416 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 417 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 418 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 419 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 420 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 421 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 422 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 423 | + "control LEFT", DefaultEditorKit.previousWordAction, | |
| 424 | + "control RIGHT", DefaultEditorKit.nextWordAction, | |
| 425 | + "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 426 | + "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 427 | + "control SLASH", DefaultEditorKit.selectAllAction, | |
| 428 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 429 | + "END", DefaultEditorKit.endLineAction, | |
| 430 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 431 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 432 | + | |
| 433 | + "control N", DefaultEditorKit.downAction, | |
| 434 | + "control P", DefaultEditorKit.upAction, | |
| 435 | + "UP", DefaultEditorKit.upAction, | |
| 436 | + "DOWN", DefaultEditorKit.downAction, | |
| 437 | + "PAGE_UP", DefaultEditorKit.pageUpAction, | |
| 438 | + "PAGE_DOWN", DefaultEditorKit.pageDownAction, | |
| 439 | + "shift PAGE_UP", "selection-page-up", | |
| 440 | + "shift PAGE_DOWN", "selection-page-down", | |
| 441 | + "ctrl shift PAGE_UP", "selection-page-left", | |
| 442 | + "ctrl shift PAGE_DOWN", "selection-page-right", | |
| 443 | + "shift UP", DefaultEditorKit.selectionUpAction, | |
| 444 | + "shift DOWN", DefaultEditorKit.selectionDownAction, | |
| 445 | + "ENTER", DefaultEditorKit.insertBreakAction, | |
| 446 | + "TAB", DefaultEditorKit.insertTabAction, | |
| 447 | + "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, | |
| 448 | + "control HOME", DefaultEditorKit.beginAction, | |
| 449 | + "control END", DefaultEditorKit.endAction, | |
| 450 | + "control shift HOME", DefaultEditorKit.selectionBeginAction, | |
| 451 | + "control shift END", DefaultEditorKit.selectionEndAction, | |
| 452 | + "control T", "next-link-action", | |
| 453 | + "control shift T", "previous-link-action", | |
| 454 | + "control SPACE", "activate-link-action", | |
| 455 | + "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ | |
| 456 | + }); | |
| 457 | + | |
| 458 | + // *** Tree | |
| 459 | + | |
| 460 | + Object treeOpenIcon = SwingUtilities2.makeIcon(getClass(), | |
| 461 | + MotifLookAndFeel.class, | |
| 462 | + "icons/TreeOpen.gif"); | |
| 463 | + | |
| 464 | + Object treeClosedIcon = SwingUtilities2.makeIcon(getClass(), | |
| 465 | + MotifLookAndFeel.class, | |
| 466 | + "icons/TreeClosed.gif"); | |
| 467 | + | |
| 468 | + Object treeLeafIcon = new UIDefaults.LazyValue() { | |
| 469 | + public Object createValue(UIDefaults table) { | |
| 470 | + return MotifTreeCellRenderer.loadLeafIcon(); | |
| 471 | + } | |
| 472 | + }; | |
| 473 | + | |
| 474 | + Object treeExpandedIcon = new UIDefaults.LazyValue() { | |
| 475 | + public Object createValue(UIDefaults table) { | |
| 476 | + return MotifTreeUI.MotifExpandedIcon.createExpandedIcon(); | |
| 477 | + } | |
| 478 | + }; | |
| 479 | + | |
| 480 | + Object treeCollapsedIcon = new UIDefaults.LazyValue() { | |
| 481 | + public Object createValue(UIDefaults table) { | |
| 482 | + return MotifTreeUI.MotifCollapsedIcon.createCollapsedIcon(); | |
| 483 | + } | |
| 484 | + }; | |
| 485 | + | |
| 486 | + Border menuBarBorder = new MotifBorders.MenuBarBorder( | |
| 487 | + table.getColor("MenuBar.shadow"), | |
| 488 | + table.getColor("MenuBar.highlight"), | |
| 489 | + table.getColor("MenuBar.darkShadow"), | |
| 490 | + table.getColor("activeCaptionBorder")); | |
| 491 | + | |
| 492 | + | |
| 493 | + Border menuMarginBorder = new BorderUIResource.CompoundBorderUIResource( | |
| 494 | + loweredBevelBorder, | |
| 495 | + marginBorder); | |
| 496 | + | |
| 497 | + | |
| 498 | + Border focusCellHighlightBorder = new BorderUIResource.LineBorderUIResource( | |
| 499 | + table.getColor("activeCaptionBorder")); | |
| 500 | + | |
| 501 | + Object sliderFocusInsets = new InsetsUIResource( 0, 0, 0, 0 ); | |
| 502 | + | |
| 503 | + // ** for tabbedpane | |
| 504 | + | |
| 505 | + Object tabbedPaneTabInsets = new InsetsUIResource(3, 4, 3, 4); | |
| 506 | + | |
| 507 | + Object tabbedPaneTabPadInsets = new InsetsUIResource(3, 0, 1, 0); | |
| 508 | + | |
| 509 | + Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 8); | |
| 510 | + | |
| 511 | + Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 2, 2); | |
| 512 | + | |
| 513 | + | |
| 514 | + // ** for optionpane | |
| 515 | + | |
| 516 | + Object optionPaneBorder = new BorderUIResource.EmptyBorderUIResource(10,0,0,0); | |
| 517 | + | |
| 518 | + Object optionPaneButtonAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,10,10); | |
| 519 | + | |
| 520 | + Object optionPaneMessageAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,12,10); | |
| 521 | + | |
| 522 | + | |
| 523 | + Object[] defaults = { | |
| 524 | + | |
| 525 | + "Desktop.background", table.get("desktop"), | |
| 526 | + "Desktop.ancestorInputMap", | |
| 527 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 528 | + "ctrl F5", "restore", | |
| 529 | + "ctrl F4", "close", | |
| 530 | + "ctrl F7", "move", | |
| 531 | + "ctrl F8", "resize", | |
| 532 | + "RIGHT", "right", | |
| 533 | + "KP_RIGHT", "right", | |
| 534 | + "shift RIGHT", "shrinkRight", | |
| 535 | + "shift KP_RIGHT", "shrinkRight", | |
| 536 | + "LEFT", "left", | |
| 537 | + "KP_LEFT", "left", | |
| 538 | + "shift LEFT", "shrinkLeft", | |
| 539 | + "shift KP_LEFT", "shrinkLeft", | |
| 540 | + "UP", "up", | |
| 541 | + "KP_UP", "up", | |
| 542 | + "shift UP", "shrinkUp", | |
| 543 | + "shift KP_UP", "shrinkUp", | |
| 544 | + "DOWN", "down", | |
| 545 | + "KP_DOWN", "down", | |
| 546 | + "shift DOWN", "shrinkDown", | |
| 547 | + "shift KP_DOWN", "shrinkDown", | |
| 548 | + "ESCAPE", "escape", | |
| 549 | + "ctrl F9", "minimize", | |
| 550 | + "ctrl F10", "maximize", | |
| 551 | + "ctrl F6", "selectNextFrame", | |
| 552 | + "ctrl TAB", "selectNextFrame", | |
| 553 | + "ctrl alt F6", "selectNextFrame", | |
| 554 | + "shift ctrl alt F6", "selectPreviousFrame", | |
| 555 | + "ctrl F12", "navigateNext", | |
| 556 | + "shift ctrl F12", "navigatePrevious" | |
| 557 | + }), | |
| 558 | + | |
| 559 | + "Panel.background", table.get("control"), | |
| 560 | + "Panel.foreground", table.get("textText"), | |
| 561 | + "Panel.font", dialogPlain12, | |
| 562 | + | |
| 563 | + "ProgressBar.font", dialogPlain12, | |
| 564 | + "ProgressBar.foreground", controlDarker, | |
| 565 | + "ProgressBar.background", table.get("control"), | |
| 566 | + "ProgressBar.selectionForeground", table.get("control"), | |
| 567 | + "ProgressBar.selectionBackground", table.get("controlText"), | |
| 568 | + "ProgressBar.border", loweredBevelBorder, | |
| 569 | + "ProgressBar.cellLength", new Integer(6), | |
| 570 | + "ProgressBar.cellSpacing", Integer.valueOf(0), | |
| 571 | + | |
| 572 | + // Buttons | |
| 573 | + "Button.margin", new InsetsUIResource(2, 4, 2, 4), | |
| 574 | + "Button.border", buttonBorder, | |
| 575 | + "Button.background", table.get("control"), | |
| 576 | + "Button.foreground", table.get("controlText"), | |
| 577 | + "Button.select", table.get("controlLightShadow"), | |
| 578 | + "Button.font", dialogPlain12, | |
| 579 | + "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 580 | + "SPACE", "pressed", | |
| 581 | + "released SPACE", "released" | |
| 582 | + }), | |
| 583 | + | |
| 584 | + "CheckBox.textIconGap", new Integer(8), | |
| 585 | + "CheckBox.margin", new InsetsUIResource(4, 2, 4, 2), | |
| 586 | + "CheckBox.icon", checkBoxIcon, | |
| 587 | + "CheckBox.focus", table.get("activeCaptionBorder"), | |
| 588 | + "CheckBox.focusInputMap", | |
| 589 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 590 | + "SPACE", "pressed", | |
| 591 | + "released SPACE", "released" | |
| 592 | + }), | |
| 593 | + | |
| 594 | + "RadioButton.margin", new InsetsUIResource(4, 2, 4, 2), | |
| 595 | + "RadioButton.textIconGap", new Integer(8), | |
| 596 | + "RadioButton.background", table.get("control"), | |
| 597 | + "RadioButton.foreground", table.get("controlText"), | |
| 598 | + "RadioButton.icon", radioButtonIcon, | |
| 599 | + "RadioButton.focus", table.get("activeCaptionBorder"), | |
| 600 | + "RadioButton.icon", radioButtonIcon, | |
| 601 | + "RadioButton.focusInputMap", | |
| 602 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 603 | + "SPACE", "pressed", | |
| 604 | + "released SPACE", "released" | |
| 605 | + }), | |
| 606 | + | |
| 607 | + "ToggleButton.border", toggleButtonBorder, | |
| 608 | + "ToggleButton.background", table.get("control"), | |
| 609 | + "ToggleButton.foreground", table.get("controlText"), | |
| 610 | + "ToggleButton.focus", table.get("controlText"), | |
| 611 | + "ToggleButton.select", table.get("controlLightShadow"), | |
| 612 | + "ToggleButton.focusInputMap", | |
| 613 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 614 | + "SPACE", "pressed", | |
| 615 | + "released SPACE", "released" | |
| 616 | + }), | |
| 617 | + | |
| 618 | + // Menus | |
| 619 | + "Menu.border", menuMarginBorder, | |
| 620 | + "Menu.font", dialogPlain12, | |
| 621 | + "Menu.acceleratorFont", dialogPlain12, | |
| 622 | + "Menu.acceleratorSelectionForeground", menuItemPressedForeground, | |
| 623 | + "Menu.foreground", table.get("menuText"), | |
| 624 | + "Menu.background", table.get("menu"), | |
| 625 | + "Menu.selectionForeground", menuItemPressedForeground, | |
| 626 | + "Menu.selectionBackground", menuItemPressedBackground, | |
| 627 | + "Menu.checkIcon", menuItemCheckIcon, | |
| 628 | + "Menu.arrowIcon", menuArrowIcon, | |
| 629 | + "Menu.menuPopupOffsetX", new Integer(0), | |
| 630 | + "Menu.menuPopupOffsetY", new Integer(0), | |
| 631 | + "Menu.submenuPopupOffsetX", new Integer(-2), | |
| 632 | + "Menu.submenuPopupOffsetY", new Integer(3), | |
| 633 | + "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK, | |
| 634 | + KeyEvent.META_MASK}, | |
| 635 | + "Menu.cancelMode", "hideMenuTree", | |
| 636 | + | |
| 637 | + "MenuBar.border", menuBarBorder, | |
| 638 | + "MenuBar.background", table.get("menu"), | |
| 639 | + "MenuBar.foreground", table.get("menuText"), | |
| 640 | + "MenuBar.font", dialogPlain12, | |
| 641 | + "MenuBar.windowBindings", new Object[] { | |
| 642 | + "F10", "takeFocus" }, | |
| 643 | + | |
| 644 | + "MenuItem.border", menuMarginBorder, | |
| 645 | + "MenuItem.font", dialogPlain12, | |
| 646 | + "MenuItem.acceleratorFont", dialogPlain12, | |
| 647 | + "MenuItem.acceleratorSelectionForeground", menuItemPressedForeground, | |
| 648 | + "MenuItem.foreground", table.get("menuText"), | |
| 649 | + "MenuItem.background", table.get("menu"), | |
| 650 | + "MenuItem.selectionForeground", menuItemPressedForeground, | |
| 651 | + "MenuItem.selectionBackground", menuItemPressedBackground, | |
| 652 | + "MenuItem.checkIcon", menuItemCheckIcon, | |
| 653 | + "MenuItem.arrowIcon", menuItemArrowIcon, | |
| 654 | + | |
| 655 | + "RadioButtonMenuItem.border", menuMarginBorder, | |
| 656 | + "RadioButtonMenuItem.font", dialogPlain12, | |
| 657 | + "RadioButtonMenuItem.acceleratorFont", dialogPlain12, | |
| 658 | + "RadioButtonMenuItem.acceleratorSelectionForeground", menuItemPressedForeground, | |
| 659 | + "RadioButtonMenuItem.foreground", table.get("menuText"), | |
| 660 | + "RadioButtonMenuItem.background", table.get("menu"), | |
| 661 | + "RadioButtonMenuItem.selectionForeground", menuItemPressedForeground, | |
| 662 | + "RadioButtonMenuItem.selectionBackground", menuItemPressedBackground, | |
| 663 | + "RadioButtonMenuItem.checkIcon", radioButtonIcon, | |
| 664 | + "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon, | |
| 665 | + | |
| 666 | + "CheckBoxMenuItem.border", menuMarginBorder, | |
| 667 | + "CheckBoxMenuItem.font", dialogPlain12, | |
| 668 | + "CheckBoxMenuItem.acceleratorFont", dialogPlain12, | |
| 669 | + "CheckBoxMenuItem.acceleratorSelectionForeground", menuItemPressedForeground, | |
| 670 | + "CheckBoxMenuItem.foreground", table.get("menuText"), | |
| 671 | + "CheckBoxMenuItem.background", table.get("menu"), | |
| 672 | + "CheckBoxMenuItem.selectionForeground", menuItemPressedForeground, | |
| 673 | + "CheckBoxMenuItem.selectionBackground", menuItemPressedBackground, | |
| 674 | + "CheckBoxMenuItem.checkIcon", checkBoxIcon, | |
| 675 | + "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon, | |
| 676 | + | |
| 677 | + "PopupMenu.background", table.get("menu"), | |
| 678 | + "PopupMenu.border", popupMenuBorder, | |
| 679 | + "PopupMenu.foreground", table.get("menuText"), | |
| 680 | + "PopupMenu.font", dialogPlain12, | |
| 681 | + "PopupMenu.consumeEventOnClose", Boolean.TRUE, | |
| 682 | + | |
| 683 | + "Label.font", dialogPlain12, | |
| 684 | + "Label.background", table.get("control"), | |
| 685 | + "Label.foreground", table.get("controlText"), | |
| 686 | + | |
| 687 | + "Separator.shadow", table.get("controlShadow"), // DEPRECATED - DO NOT USE! | |
| 688 | + "Separator.highlight", table.get("controlLtHighlight"), // DEPRECATED - DO NOT USE! | |
| 689 | + | |
| 690 | + "Separator.background", table.get("controlLtHighlight"), | |
| 691 | + "Separator.foreground", table.get("controlShadow"), | |
| 692 | + | |
| 693 | + "List.focusCellHighlightBorder", focusCellHighlightBorder, | |
| 694 | + "List.focusInputMap", | |
| 695 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 696 | + "COPY", "copy", | |
| 697 | + "PASTE", "paste", | |
| 698 | + "CUT", "cut", | |
| 699 | + "control INSERT", "copy", | |
| 700 | + "shift INSERT", "paste", | |
| 701 | + "shift DELETE", "cut", | |
| 702 | + "UP", "selectPreviousRow", | |
| 703 | + "KP_UP", "selectPreviousRow", | |
| 704 | + "shift UP", "selectPreviousRowExtendSelection", | |
| 705 | + "shift KP_UP", "selectPreviousRowExtendSelection", | |
| 706 | + "ctrl shift UP", "selectPreviousRowExtendSelection", | |
| 707 | + "ctrl shift KP_UP", "selectPreviousRowExtendSelection", | |
| 708 | + "ctrl UP", "selectPreviousRowChangeLead", | |
| 709 | + "ctrl KP_UP", "selectPreviousRowChangeLead", | |
| 710 | + "DOWN", "selectNextRow", | |
| 711 | + "KP_DOWN", "selectNextRow", | |
| 712 | + "shift DOWN", "selectNextRowExtendSelection", | |
| 713 | + "shift KP_DOWN", "selectNextRowExtendSelection", | |
| 714 | + "ctrl shift DOWN", "selectNextRowExtendSelection", | |
| 715 | + "ctrl shift KP_DOWN", "selectNextRowExtendSelection", | |
| 716 | + "ctrl DOWN", "selectNextRowChangeLead", | |
| 717 | + "ctrl KP_DOWN", "selectNextRowChangeLead", | |
| 718 | + "LEFT", "selectPreviousColumn", | |
| 719 | + "KP_LEFT", "selectPreviousColumn", | |
| 720 | + "shift LEFT", "selectPreviousColumnExtendSelection", | |
| 721 | + "shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 722 | + "ctrl shift LEFT", "selectPreviousColumnExtendSelection", | |
| 723 | + "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 724 | + "ctrl LEFT", "selectPreviousColumnChangeLead", | |
| 725 | + "ctrl KP_LEFT", "selectPreviousColumnChangeLead", | |
| 726 | + "RIGHT", "selectNextColumn", | |
| 727 | + "KP_RIGHT", "selectNextColumn", | |
| 728 | + "shift RIGHT", "selectNextColumnExtendSelection", | |
| 729 | + "shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 730 | + "ctrl shift RIGHT", "selectNextColumnExtendSelection", | |
| 731 | + "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 732 | + "ctrl RIGHT", "selectNextColumnChangeLead", | |
| 733 | + "ctrl KP_RIGHT", "selectNextColumnChangeLead", | |
| 734 | + "HOME", "selectFirstRow", | |
| 735 | + "shift HOME", "selectFirstRowExtendSelection", | |
| 736 | + "ctrl shift HOME", "selectFirstRowExtendSelection", | |
| 737 | + "ctrl HOME", "selectFirstRowChangeLead", | |
| 738 | + "END", "selectLastRow", | |
| 739 | + "shift END", "selectLastRowExtendSelection", | |
| 740 | + "ctrl shift END", "selectLastRowExtendSelection", | |
| 741 | + "ctrl END", "selectLastRowChangeLead", | |
| 742 | + "PAGE_UP", "scrollUp", | |
| 743 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 744 | + "ctrl shift PAGE_UP", "scrollUpExtendSelection", | |
| 745 | + "ctrl PAGE_UP", "scrollUpChangeLead", | |
| 746 | + "PAGE_DOWN", "scrollDown", | |
| 747 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 748 | + "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 749 | + "ctrl PAGE_DOWN", "scrollDownChangeLead", | |
| 750 | + "ctrl A", "selectAll", | |
| 751 | + "ctrl SLASH", "selectAll", | |
| 752 | + "ctrl BACK_SLASH", "clearSelection", | |
| 753 | + "SPACE", "addToSelection", | |
| 754 | + "ctrl SPACE", "toggleAndAnchor", | |
| 755 | + "shift SPACE", "extendTo", | |
| 756 | + "ctrl shift SPACE", "moveSelectionTo" | |
| 757 | + }), | |
| 758 | + | |
| 759 | + "DesktopIcon.icon", SwingUtilities2.makeIcon(getClass(), | |
| 760 | + MotifLookAndFeel.class, | |
| 761 | + "icons/DesktopIcon.gif"), | |
| 762 | + "DesktopIcon.border", null, | |
| 763 | + // These are a little odd, MotifInternalFrameUI isntalls em! | |
| 764 | + "DesktopIcon.windowBindings", new Object[] | |
| 765 | + { "ESCAPE", "hideSystemMenu" }, | |
| 766 | + | |
| 767 | + "InternalFrame.activeTitleBackground", table.get("activeCaptionBorder"), | |
| 768 | + "InternalFrame.inactiveTitleBackground", table.get("inactiveCaptionBorder"), | |
| 769 | + "InternalFrame.windowBindings", new Object[] { | |
| 770 | + "shift ESCAPE", "showSystemMenu", | |
| 771 | + "ctrl SPACE", "showSystemMenu", | |
| 772 | + "ESCAPE", "hideSystemMenu" | |
| 773 | + }, | |
| 774 | + | |
| 775 | + "ScrollBar.background", scrollBarTrack, | |
| 776 | + "ScrollBar.foreground", table.get("control"), | |
| 777 | + "ScrollBar.track", scrollBarTrack, | |
| 778 | + "ScrollBar.trackHighlight", table.get("controlDkShadow"), | |
| 779 | + "ScrollBar.thumb", table.get("control"), | |
| 780 | + "ScrollBar.thumbHighlight", table.get("controlHighlight"), | |
| 781 | + "ScrollBar.thumbDarkShadow", table.get("controlDkShadow"), | |
| 782 | + "ScrollBar.thumbShadow", table.get("controlShadow"), | |
| 783 | + "ScrollBar.border", loweredBevelBorder, | |
| 784 | + "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE, | |
| 785 | + "ScrollBar.ancestorInputMap", | |
| 786 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 787 | + "RIGHT", "positiveUnitIncrement", | |
| 788 | + "KP_RIGHT", "positiveUnitIncrement", | |
| 789 | + "DOWN", "positiveUnitIncrement", | |
| 790 | + "KP_DOWN", "positiveUnitIncrement", | |
| 791 | + "PAGE_DOWN", "positiveBlockIncrement", | |
| 792 | + "ctrl PAGE_DOWN", "positiveBlockIncrement", | |
| 793 | + "LEFT", "negativeUnitIncrement", | |
| 794 | + "KP_LEFT", "negativeUnitIncrement", | |
| 795 | + "UP", "negativeUnitIncrement", | |
| 796 | + "KP_UP", "negativeUnitIncrement", | |
| 797 | + "PAGE_UP", "negativeBlockIncrement", | |
| 798 | + "ctrl PAGE_UP", "negativeBlockIncrement", | |
| 799 | + "HOME", "minScroll", | |
| 800 | + "END", "maxScroll" | |
| 801 | + }), | |
| 802 | + | |
| 803 | + "ScrollPane.font", dialogPlain12, | |
| 804 | + "ScrollPane.background", table.get("control"), | |
| 805 | + "ScrollPane.foreground", table.get("controlText"), | |
| 806 | + "ScrollPane.border", null, | |
| 807 | + "ScrollPane.viewportBorder", loweredBevelBorder, | |
| 808 | + "ScrollPane.ancestorInputMap", | |
| 809 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 810 | + "RIGHT", "unitScrollRight", | |
| 811 | + "KP_RIGHT", "unitScrollRight", | |
| 812 | + "DOWN", "unitScrollDown", | |
| 813 | + "KP_DOWN", "unitScrollDown", | |
| 814 | + "LEFT", "unitScrollLeft", | |
| 815 | + "KP_LEFT", "unitScrollLeft", | |
| 816 | + "UP", "unitScrollUp", | |
| 817 | + "KP_UP", "unitScrollUp", | |
| 818 | + "PAGE_UP", "scrollUp", | |
| 819 | + "PAGE_DOWN", "scrollDown", | |
| 820 | + "ctrl PAGE_UP", "scrollLeft", | |
| 821 | + "ctrl PAGE_DOWN", "scrollRight", | |
| 822 | + "ctrl HOME", "scrollHome", | |
| 823 | + "ctrl END", "scrollEnd" | |
| 824 | + }), | |
| 825 | + | |
| 826 | + "Slider.font", dialogPlain12, | |
| 827 | + "Slider.border", focusBevelBorder, | |
| 828 | + "Slider.foreground", table.get("control"), | |
| 829 | + "Slider.background", controlDarker, | |
| 830 | + "Slider.highlight", table.get("controlHighlight"), | |
| 831 | + "Slider.shadow", table.get("controlShadow"), | |
| 832 | + "Slider.focus", table.get("controlDkShadow"), | |
| 833 | + "Slider.focusInsets", sliderFocusInsets, | |
| 834 | + "Slider.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 835 | + "RIGHT", "positiveUnitIncrement", | |
| 836 | + "KP_RIGHT", "positiveUnitIncrement", | |
| 837 | + "DOWN", "negativeUnitIncrement", | |
| 838 | + "KP_DOWN", "negativeUnitIncrement", | |
| 839 | + "ctrl PAGE_DOWN", "negativeBlockIncrement", | |
| 840 | + "LEFT", "negativeUnitIncrement", | |
| 841 | + "KP_LEFT", "negativeUnitIncrement", | |
| 842 | + "UP", "positiveUnitIncrement", | |
| 843 | + "KP_UP", "positiveUnitIncrement", | |
| 844 | + "ctrl PAGE_UP", "positiveBlockIncrement", | |
| 845 | + "HOME", "minScroll", | |
| 846 | + "END", "maxScroll" | |
| 847 | + }), | |
| 848 | + | |
| 849 | + // Spinner | |
| 850 | + "Spinner.ancestorInputMap", | |
| 851 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 852 | + "UP", "increment", | |
| 853 | + "KP_UP", "increment", | |
| 854 | + "DOWN", "decrement", | |
| 855 | + "KP_DOWN", "decrement", | |
| 856 | + }), | |
| 857 | + "Spinner.border", textFieldBorder, | |
| 858 | + | |
| 859 | + "SplitPane.background", table.get("control"), | |
| 860 | + "SplitPane.highlight", table.get("controlHighlight"), | |
| 861 | + "SplitPane.shadow", table.get("controlShadow"), | |
| 862 | + "SplitPane.dividerSize", Integer.valueOf(20), | |
| 863 | + "SplitPane.activeThumb", table.get("activeCaptionBorder"), | |
| 864 | + "SplitPane.ancestorInputMap", | |
| 865 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 866 | + "UP", "negativeIncrement", | |
| 867 | + "DOWN", "positiveIncrement", | |
| 868 | + "LEFT", "negativeIncrement", | |
| 869 | + "RIGHT", "positiveIncrement", | |
| 870 | + "KP_UP", "negativeIncrement", | |
| 871 | + "KP_DOWN", "positiveIncrement", | |
| 872 | + "KP_LEFT", "negativeIncrement", | |
| 873 | + "KP_RIGHT", "positiveIncrement", | |
| 874 | + "HOME", "selectMin", | |
| 875 | + "END", "selectMax", | |
| 876 | + "F8", "startResize", | |
| 877 | + "F6", "toggleFocus", | |
| 878 | + "ctrl TAB", "focusOutForward", | |
| 879 | + "ctrl shift TAB", "focusOutBackward" | |
| 880 | + }), | |
| 881 | + | |
| 882 | + "TabbedPane.font", dialogPlain12, | |
| 883 | + "TabbedPane.background", table.get("control"), | |
| 884 | + "TabbedPane.foreground", table.get("controlText"), | |
| 885 | + "TabbedPane.light", table.get("controlHighlight"), | |
| 886 | + "TabbedPane.highlight", table.get("controlLtHighlight"), | |
| 887 | + "TabbedPane.shadow", table.get("controlShadow"), | |
| 888 | + "TabbedPane.darkShadow", table.get("controlShadow"), | |
| 889 | + "TabbedPane.unselectedTabBackground", unselectedTabBackground, | |
| 890 | + "TabbedPane.unselectedTabForeground", unselectedTabForeground, | |
| 891 | + "TabbedPane.unselectedTabHighlight", unselectedTabHighlight, | |
| 892 | + "TabbedPane.unselectedTabShadow", unselectedTabShadow, | |
| 893 | + "TabbedPane.focus", table.get("activeCaptionBorder"), | |
| 894 | + "TabbedPane.tabInsets", tabbedPaneTabInsets, | |
| 895 | + "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets, | |
| 896 | + "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets, | |
| 897 | + "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets, | |
| 898 | + "TabbedPane.focusInputMap", | |
| 899 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 900 | + "RIGHT", "navigateRight", | |
| 901 | + "KP_RIGHT", "navigateRight", | |
| 902 | + "LEFT", "navigateLeft", | |
| 903 | + "KP_LEFT", "navigateLeft", | |
| 904 | + "UP", "navigateUp", | |
| 905 | + "KP_UP", "navigateUp", | |
| 906 | + "DOWN", "navigateDown", | |
| 907 | + "KP_DOWN", "navigateDown", | |
| 908 | + "ctrl DOWN", "requestFocusForVisibleComponent", | |
| 909 | + "ctrl KP_DOWN", "requestFocusForVisibleComponent", | |
| 910 | + }), | |
| 911 | + "TabbedPane.ancestorInputMap", | |
| 912 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 913 | + "ctrl PAGE_DOWN", "navigatePageDown", | |
| 914 | + "ctrl PAGE_UP", "navigatePageUp", | |
| 915 | + "ctrl UP", "requestFocus", | |
| 916 | + "ctrl KP_UP", "requestFocus", | |
| 917 | + }), | |
| 918 | + | |
| 919 | + | |
| 920 | + "Tree.background", controlDarker, // default: dark slate blue | |
| 921 | + "Tree.hash", table.get("controlDkShadow"), // default: black | |
| 922 | + "Tree.iconShadow", table.get("controlShadow"), | |
| 923 | + "Tree.iconHighlight", table.get("controlHighlight"), | |
| 924 | + "Tree.iconBackground", table.get("control"), | |
| 925 | + "Tree.iconForeground", table.get("controlShadow"), // default: black | |
| 926 | + "Tree.textBackground", controlDarker, // default: dark slate blue | |
| 927 | + "Tree.textForeground", table.get("textText"), // default: black | |
| 928 | + "Tree.selectionBackground", table.get("text"), // default: white | |
| 929 | + "Tree.selectionForeground", table.get("textText"), // default: black | |
| 930 | + "Tree.selectionBorderColor", table.get("activeCaptionBorder"), // default: maroon | |
| 931 | + "Tree.openIcon", treeOpenIcon, | |
| 932 | + "Tree.closedIcon", treeClosedIcon, | |
| 933 | + "Tree.leafIcon", treeLeafIcon, | |
| 934 | + "Tree.expandedIcon", treeExpandedIcon, | |
| 935 | + "Tree.collapsedIcon", treeCollapsedIcon, | |
| 936 | + "Tree.editorBorder", focusBorder, | |
| 937 | + "Tree.editorBorderSelectionColor", table.get("activeCaptionBorder"), | |
| 938 | + "Tree.rowHeight", new Integer(18), | |
| 939 | + "Tree.drawsFocusBorderAroundIcon", Boolean.TRUE, | |
| 940 | + "Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 941 | + "COPY", "copy", | |
| 942 | + "PASTE", "paste", | |
| 943 | + "CUT", "cut", | |
| 944 | + "control INSERT", "copy", | |
| 945 | + "shift INSERT", "paste", | |
| 946 | + "shift DELETE", "cut", | |
| 947 | + "UP", "selectPrevious", | |
| 948 | + "KP_UP", "selectPrevious", | |
| 949 | + "shift UP", "selectPreviousExtendSelection", | |
| 950 | + "shift KP_UP", "selectPreviousExtendSelection", | |
| 951 | + "ctrl shift UP", "selectPreviousExtendSelection", | |
| 952 | + "ctrl shift KP_UP", "selectPreviousExtendSelection", | |
| 953 | + "ctrl UP", "selectPreviousChangeLead", | |
| 954 | + "ctrl KP_UP", "selectPreviousChangeLead", | |
| 955 | + "DOWN", "selectNext", | |
| 956 | + "KP_DOWN", "selectNext", | |
| 957 | + "shift DOWN", "selectNextExtendSelection", | |
| 958 | + "shift KP_DOWN", "selectNextExtendSelection", | |
| 959 | + "ctrl shift DOWN", "selectNextExtendSelection", | |
| 960 | + "ctrl shift KP_DOWN", "selectNextExtendSelection", | |
| 961 | + "ctrl DOWN", "selectNextChangeLead", | |
| 962 | + "ctrl KP_DOWN", "selectNextChangeLead", | |
| 963 | + "RIGHT", "selectChild", | |
| 964 | + "KP_RIGHT", "selectChild", | |
| 965 | + "LEFT", "selectParent", | |
| 966 | + "KP_LEFT", "selectParent", | |
| 967 | + "PAGE_UP", "scrollUpChangeSelection", | |
| 968 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 969 | + "ctrl shift PAGE_UP", "scrollUpExtendSelection", | |
| 970 | + "ctrl PAGE_UP", "scrollUpChangeLead", | |
| 971 | + "PAGE_DOWN", "scrollDownChangeSelection", | |
| 972 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 973 | + "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 974 | + "ctrl PAGE_DOWN", "scrollDownChangeLead", | |
| 975 | + "HOME", "selectFirst", | |
| 976 | + "shift HOME", "selectFirstExtendSelection", | |
| 977 | + "ctrl shift HOME", "selectFirstExtendSelection", | |
| 978 | + "ctrl HOME", "selectFirstChangeLead", | |
| 979 | + "END", "selectLast", | |
| 980 | + "shift END", "selectLastExtendSelection", | |
| 981 | + "ctrl shift END", "selectLastExtendSelection", | |
| 982 | + "ctrl END", "selectLastChangeLead", | |
| 983 | + "F2", "startEditing", | |
| 984 | + "ctrl A", "selectAll", | |
| 985 | + "ctrl SLASH", "selectAll", | |
| 986 | + "ctrl BACK_SLASH", "clearSelection", | |
| 987 | + "ctrl LEFT", "scrollLeft", | |
| 988 | + "ctrl KP_LEFT", "scrollLeft", | |
| 989 | + "ctrl RIGHT", "scrollRight", | |
| 990 | + "ctrl KP_RIGHT", "scrollRight", | |
| 991 | + "SPACE", "addToSelection", | |
| 992 | + "ctrl SPACE", "toggleAndAnchor", | |
| 993 | + "shift SPACE", "extendTo", | |
| 994 | + "ctrl shift SPACE", "moveSelectionTo" | |
| 995 | + }), | |
| 996 | + "Tree.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 997 | + "ESCAPE", "cancel" }), | |
| 998 | + | |
| 999 | + "Table.focusCellHighlightBorder", focusCellHighlightBorder, | |
| 1000 | + "Table.scrollPaneBorder", null, | |
| 1001 | + "Table.dropLineShortColor", table.get("activeCaptionBorder"), | |
| 1002 | + | |
| 1003 | + // "Table.background", white, // cell background color | |
| 1004 | + "Table.ancestorInputMap", | |
| 1005 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1006 | + "COPY", "copy", | |
| 1007 | + "PASTE", "paste", | |
| 1008 | + "CUT", "cut", | |
| 1009 | + "control INSERT", "copy", | |
| 1010 | + "shift INSERT", "paste", | |
| 1011 | + "shift DELETE", "cut", | |
| 1012 | + "RIGHT", "selectNextColumn", | |
| 1013 | + "KP_RIGHT", "selectNextColumn", | |
| 1014 | + "shift RIGHT", "selectNextColumnExtendSelection", | |
| 1015 | + "shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 1016 | + "ctrl shift RIGHT", "selectNextColumnExtendSelection", | |
| 1017 | + "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", | |
| 1018 | + "ctrl RIGHT", "selectNextColumnChangeLead", | |
| 1019 | + "ctrl KP_RIGHT", "selectNextColumnChangeLead", | |
| 1020 | + "LEFT", "selectPreviousColumn", | |
| 1021 | + "KP_LEFT", "selectPreviousColumn", | |
| 1022 | + "shift LEFT", "selectPreviousColumnExtendSelection", | |
| 1023 | + "shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 1024 | + "ctrl shift LEFT", "selectPreviousColumnExtendSelection", | |
| 1025 | + "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", | |
| 1026 | + "ctrl LEFT", "selectPreviousColumnChangeLead", | |
| 1027 | + "ctrl KP_LEFT", "selectPreviousColumnChangeLead", | |
| 1028 | + "DOWN", "selectNextRow", | |
| 1029 | + "KP_DOWN", "selectNextRow", | |
| 1030 | + "shift DOWN", "selectNextRowExtendSelection", | |
| 1031 | + "shift KP_DOWN", "selectNextRowExtendSelection", | |
| 1032 | + "ctrl shift DOWN", "selectNextRowExtendSelection", | |
| 1033 | + "ctrl shift KP_DOWN", "selectNextRowExtendSelection", | |
| 1034 | + "ctrl DOWN", "selectNextRowChangeLead", | |
| 1035 | + "ctrl KP_DOWN", "selectNextRowChangeLead", | |
| 1036 | + "UP", "selectPreviousRow", | |
| 1037 | + "KP_UP", "selectPreviousRow", | |
| 1038 | + "shift UP", "selectPreviousRowExtendSelection", | |
| 1039 | + "shift KP_UP", "selectPreviousRowExtendSelection", | |
| 1040 | + "ctrl shift UP", "selectPreviousRowExtendSelection", | |
| 1041 | + "ctrl shift KP_UP", "selectPreviousRowExtendSelection", | |
| 1042 | + "ctrl UP", "selectPreviousRowChangeLead", | |
| 1043 | + "ctrl KP_UP", "selectPreviousRowChangeLead", | |
| 1044 | + "HOME", "selectFirstColumn", | |
| 1045 | + "shift HOME", "selectFirstColumnExtendSelection", | |
| 1046 | + "ctrl shift HOME", "selectFirstRowExtendSelection", | |
| 1047 | + "ctrl HOME", "selectFirstRow", | |
| 1048 | + "END", "selectLastColumn", | |
| 1049 | + "shift END", "selectLastColumnExtendSelection", | |
| 1050 | + "ctrl shift END", "selectLastRowExtendSelection", | |
| 1051 | + "ctrl END", "selectLastRow", | |
| 1052 | + "PAGE_UP", "scrollUpChangeSelection", | |
| 1053 | + "shift PAGE_UP", "scrollUpExtendSelection", | |
| 1054 | + "ctrl shift PAGE_UP", "scrollLeftExtendSelection", | |
| 1055 | + "ctrl PAGE_UP", "scrollLeftChangeSelection", | |
| 1056 | + "PAGE_DOWN", "scrollDownChangeSelection", | |
| 1057 | + "shift PAGE_DOWN", "scrollDownExtendSelection", | |
| 1058 | + "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", | |
| 1059 | + "ctrl PAGE_DOWN", "scrollRightChangeSelection", | |
| 1060 | + "TAB", "selectNextColumnCell", | |
| 1061 | + "shift TAB", "selectPreviousColumnCell", | |
| 1062 | + "ENTER", "selectNextRowCell", | |
| 1063 | + "shift ENTER", "selectPreviousRowCell", | |
| 1064 | + "ctrl A", "selectAll", | |
| 1065 | + "ctrl SLASH", "selectAll", | |
| 1066 | + "ctrl BACK_SLASH", "clearSelection", | |
| 1067 | + "ESCAPE", "cancel", | |
| 1068 | + "F2", "startEditing", | |
| 1069 | + "SPACE", "addToSelection", | |
| 1070 | + "ctrl SPACE", "toggleAndAnchor", | |
| 1071 | + "shift SPACE", "extendTo", | |
| 1072 | + "ctrl shift SPACE", "moveSelectionTo", | |
| 1073 | + "F8", "focusHeader" | |
| 1074 | + }), | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + "FormattedTextField.focusInputMap", | |
| 1078 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1079 | + "ctrl C", DefaultEditorKit.copyAction, | |
| 1080 | + "ctrl V", DefaultEditorKit.pasteAction, | |
| 1081 | + "ctrl X", DefaultEditorKit.cutAction, | |
| 1082 | + "COPY", DefaultEditorKit.copyAction, | |
| 1083 | + "PASTE", DefaultEditorKit.pasteAction, | |
| 1084 | + "CUT", DefaultEditorKit.cutAction, | |
| 1085 | + "shift LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 1086 | + "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, | |
| 1087 | + "shift RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 1088 | + "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, | |
| 1089 | + "ctrl LEFT", DefaultEditorKit.previousWordAction, | |
| 1090 | + "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, | |
| 1091 | + "ctrl RIGHT", DefaultEditorKit.nextWordAction, | |
| 1092 | + "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, | |
| 1093 | + "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 1094 | + "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, | |
| 1095 | + "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 1096 | + "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, | |
| 1097 | + "ctrl A", DefaultEditorKit.selectAllAction, | |
| 1098 | + "HOME", DefaultEditorKit.beginLineAction, | |
| 1099 | + "END", DefaultEditorKit.endLineAction, | |
| 1100 | + "shift HOME", DefaultEditorKit.selectionBeginLineAction, | |
| 1101 | + "shift END", DefaultEditorKit.selectionEndLineAction, | |
| 1102 | + "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 1103 | + "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, | |
| 1104 | + "ctrl H", DefaultEditorKit.deletePrevCharAction, | |
| 1105 | + "DELETE", DefaultEditorKit.deleteNextCharAction, | |
| 1106 | + "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, | |
| 1107 | + "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, | |
| 1108 | + "RIGHT", DefaultEditorKit.forwardAction, | |
| 1109 | + "LEFT", DefaultEditorKit.backwardAction, | |
| 1110 | + "KP_RIGHT", DefaultEditorKit.forwardAction, | |
| 1111 | + "KP_LEFT", DefaultEditorKit.backwardAction, | |
| 1112 | + "ENTER", JTextField.notifyAction, | |
| 1113 | + "ctrl BACK_SLASH", "unselect", | |
| 1114 | + "control shift O", "toggle-componentOrientation", | |
| 1115 | + "ESCAPE", "reset-field-edit", | |
| 1116 | + "UP", "increment", | |
| 1117 | + "KP_UP", "increment", | |
| 1118 | + "DOWN", "decrement", | |
| 1119 | + "KP_DOWN", "decrement", | |
| 1120 | + }), | |
| 1121 | + | |
| 1122 | + // ToolBar. | |
| 1123 | + "ToolBar.ancestorInputMap", | |
| 1124 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1125 | + "UP", "navigateUp", | |
| 1126 | + "KP_UP", "navigateUp", | |
| 1127 | + "DOWN", "navigateDown", | |
| 1128 | + "KP_DOWN", "navigateDown", | |
| 1129 | + "LEFT", "navigateLeft", | |
| 1130 | + "KP_LEFT", "navigateLeft", | |
| 1131 | + "RIGHT", "navigateRight", | |
| 1132 | + "KP_RIGHT", "navigateRight" | |
| 1133 | + }), | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + "ComboBox.control", table.get("control"), | |
| 1138 | + "ComboBox.controlForeground", black, | |
| 1139 | + "ComboBox.background", table.get("window"), | |
| 1140 | + "ComboBox.foreground", black, | |
| 1141 | + "ComboBox.border", comboBoxBorder, | |
| 1142 | + "ComboBox.selectionBackground", black, | |
| 1143 | + "ComboBox.selectionForeground", table.get("text"), | |
| 1144 | + "ComboBox.disabledBackground", table.get("control"), | |
| 1145 | + "ComboBox.disabledForeground", table.get("textInactiveText"), | |
| 1146 | + "ComboBox.font", dialogPlain12, | |
| 1147 | + "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { | |
| 1148 | + "ESCAPE", "hidePopup", | |
| 1149 | + "PAGE_UP", "pageUpPassThrough", | |
| 1150 | + "PAGE_DOWN", "pageDownPassThrough", | |
| 1151 | + "HOME", "homePassThrough", | |
| 1152 | + "END", "endPassThrough", | |
| 1153 | + "DOWN", "selectNext", | |
| 1154 | + "KP_DOWN", "selectNext", | |
| 1155 | + "UP", "selectPrevious", | |
| 1156 | + "KP_UP", "selectPrevious", | |
| 1157 | + "SPACE", "spacePopup", | |
| 1158 | + "ENTER", "enterPressed" | |
| 1159 | + | |
| 1160 | + }), | |
| 1161 | + | |
| 1162 | + "TextField.caretForeground", black, | |
| 1163 | + "TextField.caretBlinkRate", Integer.valueOf(500), | |
| 1164 | + "TextField.inactiveForeground", table.get("textInactiveText"), | |
| 1165 | + "TextField.selectionBackground", table.get("textHighlight"), | |
| 1166 | + "TextField.selectionForeground", table.get("textHighlightText"), | |
| 1167 | + "TextField.background", table.get("window"), | |
| 1168 | + "TextField.foreground", table.get("textText"), | |
| 1169 | + "TextField.font", sansSerifPlain12, | |
| 1170 | + "TextField.border", textFieldBorder, | |
| 1171 | + "TextField.focusInputMap", fieldInputMap, | |
| 1172 | + | |
| 1173 | + "PasswordField.caretForeground", black, | |
| 1174 | + "PasswordField.caretBlinkRate", Integer.valueOf(500), | |
| 1175 | + "PasswordField.inactiveForeground", table.get("textInactiveText"), | |
| 1176 | + "PasswordField.selectionBackground", table.get("textHighlight"), | |
| 1177 | + "PasswordField.selectionForeground", table.get("textHighlightText"), | |
| 1178 | + "PasswordField.background", table.get("window"), | |
| 1179 | + "PasswordField.foreground", table.get("textText"), | |
| 1180 | + "PasswordField.font", monospacedPlain12, | |
| 1181 | + "PasswordField.border", textFieldBorder, | |
| 1182 | + "PasswordField.focusInputMap", passwordInputMap, | |
| 1183 | + | |
| 1184 | + "TextArea.caretForeground", black, | |
| 1185 | + "TextArea.caretBlinkRate", Integer.valueOf(500), | |
| 1186 | + "TextArea.inactiveForeground", table.get("textInactiveText"), | |
| 1187 | + "TextArea.selectionBackground", table.get("textHighlight"), | |
| 1188 | + "TextArea.selectionForeground", table.get("textHighlightText"), | |
| 1189 | + "TextArea.background", table.get("window"), | |
| 1190 | + "TextArea.foreground", table.get("textText"), | |
| 1191 | + "TextArea.font", monospacedPlain12, | |
| 1192 | + "TextArea.border", marginBorder, | |
| 1193 | + "TextArea.focusInputMap", multilineInputMap, | |
| 1194 | + | |
| 1195 | + "TextPane.caretForeground", black, | |
| 1196 | + "TextPane.caretBlinkRate", Integer.valueOf(500), | |
| 1197 | + "TextPane.inactiveForeground", table.get("textInactiveText"), | |
| 1198 | + "TextPane.selectionBackground", lightGray, | |
| 1199 | + "TextPane.selectionForeground", table.get("textHighlightText"), | |
| 1200 | + "TextPane.background", white, | |
| 1201 | + "TextPane.foreground", table.get("textText"), | |
| 1202 | + "TextPane.font", serifPlain12, | |
| 1203 | + "TextPane.border", marginBorder, | |
| 1204 | + "TextPane.focusInputMap", multilineInputMap, | |
| 1205 | + | |
| 1206 | + "EditorPane.caretForeground", red, | |
| 1207 | + "EditorPane.caretBlinkRate", Integer.valueOf(500), | |
| 1208 | + "EditorPane.inactiveForeground", table.get("textInactiveText"), | |
| 1209 | + "EditorPane.selectionBackground", lightGray, | |
| 1210 | + "EditorPane.selectionForeground", table.get("textHighlightText"), | |
| 1211 | + "EditorPane.background", white, | |
| 1212 | + "EditorPane.foreground", table.get("textText"), | |
| 1213 | + "EditorPane.font", serifPlain12, | |
| 1214 | + "EditorPane.border", marginBorder, | |
| 1215 | + "EditorPane.focusInputMap", multilineInputMap, | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + "FileChooser.pathLabelMnemonic", new Integer(KeyEvent.VK_P), // 'p' | |
| 1219 | + "FileChooser.filterLabelMnemonic", new Integer (KeyEvent.VK_R), // 'r' | |
| 1220 | + "FileChooser.foldersLabelMnemonic", new Integer (KeyEvent.VK_L), // 'l' | |
| 1221 | + "FileChooser.filesLabelMnemonic", new Integer (KeyEvent.VK_I), // 'i' | |
| 1222 | + "FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n' | |
| 1223 | + "FileChooser.ancestorInputMap", | |
| 1224 | + new UIDefaults.LazyInputMap(new Object[] { | |
| 1225 | + "ESCAPE", "cancelSelection" | |
| 1226 | + }), | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + "ToolTip.border", raisedBevelBorder, | |
| 1230 | + "ToolTip.background", table.get("info"), | |
| 1231 | + "ToolTip.foreground", table.get("infoText"), | |
| 1232 | + | |
| 1233 | + // These window InputMap bindings are used when the Menu is | |
| 1234 | + // selected. | |
| 1235 | + "PopupMenu.selectedWindowInputMapBindings", new Object[] { | |
| 1236 | + "ESCAPE", "cancel", | |
| 1237 | + "TAB", "cancel", | |
| 1238 | + "shift TAB", "cancel", | |
| 1239 | + "DOWN", "selectNext", | |
| 1240 | + "KP_DOWN", "selectNext", | |
| 1241 | + "UP", "selectPrevious", | |
| 1242 | + "KP_UP", "selectPrevious", | |
| 1243 | + "LEFT", "selectParent", | |
| 1244 | + "KP_LEFT", "selectParent", | |
| 1245 | + "RIGHT", "selectChild", | |
| 1246 | + "KP_RIGHT", "selectChild", | |
| 1247 | + "ENTER", "return", | |
| 1248 | + "SPACE", "return" | |
| 1249 | + }, | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + "OptionPane.border", optionPaneBorder, | |
| 1253 | + "OptionPane.messageAreaBorder", optionPaneMessageAreaBorder, | |
| 1254 | + "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder, | |
| 1255 | + "OptionPane.errorIcon", SwingUtilities2.makeIcon(getClass(), | |
| 1256 | + MotifLookAndFeel.class, | |
| 1257 | + "icons/Error.gif"), | |
| 1258 | + "OptionPane.informationIcon", SwingUtilities2.makeIcon(getClass(), | |
| 1259 | + MotifLookAndFeel.class, | |
| 1260 | + "icons/Inform.gif"), | |
| 1261 | + "OptionPane.warningIcon", SwingUtilities2.makeIcon(getClass(), | |
| 1262 | + MotifLookAndFeel.class, | |
| 1263 | + "icons/Warn.gif"), | |
| 1264 | + "OptionPane.questionIcon", SwingUtilities2.makeIcon(getClass(), | |
| 1265 | + MotifLookAndFeel.class, | |
| 1266 | + "icons/Question.gif"), | |
| 1267 | + "OptionPane.windowBindings", new Object[] { | |
| 1268 | + "ESCAPE", "close" }, | |
| 1269 | + | |
| 1270 | + // These bindings are only enabled when there is a default | |
| 1271 | + // button set on the rootpane. | |
| 1272 | + "RootPane.defaultButtonWindowKeyBindings", new Object[] { | |
| 1273 | + "ENTER", "press", | |
| 1274 | + "released ENTER", "release", | |
| 1275 | + "ctrl ENTER", "press", | |
| 1276 | + "ctrl released ENTER", "release" | |
| 1277 | + }, | |
| 1278 | + }; | |
| 1279 | + | |
| 1280 | + table.putDefaults(defaults); | |
| 1281 | + } | |
| 1282 | + | |
| 1283 | +} | |
| @@ -0,0 +1,69 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package com.sun.java.swing.plaf.motif; | |
| 27 | + | |
| 28 | +import java.awt.Component; | |
| 29 | +import java.awt.Container; | |
| 30 | +import java.awt.Dimension; | |
| 31 | +import java.awt.Graphics; | |
| 32 | +import java.awt.Color; | |
| 33 | +import java.awt.Insets; | |
| 34 | +import java.awt.Point; | |
| 35 | +import java.awt.Rectangle; | |
| 36 | +import java.awt.event.*; | |
| 37 | +import java.io.Serializable; | |
| 38 | + | |
| 39 | +import javax.swing.*; | |
| 40 | +import javax.swing.event.*; | |
29 more lines aren’t shown here.
This diff is large: its 110 lines aren’t shown here.
This diff is large: its 49 lines aren’t shown here.
This diff is large: its 44 lines aren’t shown here.
This diff is large: its 152 lines aren’t shown here.
This diff is large: its 115 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 67 lines aren’t shown here.
This diff is large: its 115 lines aren’t shown here.
This diff is large: its 59 lines aren’t shown here.
This diff is large: its 114 lines aren’t shown here.
This diff is large: its 105 lines aren’t shown here.
This diff is large: its 212 lines aren’t shown here.
This diff is large: its 109 lines aren’t shown here.
This diff is large: its 144 lines aren’t shown here.
This diff is large: its 60 lines aren’t shown here.
This diff is large: its 160 lines aren’t shown here.
This diff is large: its 296 lines aren’t shown here.
This diff is large: its 67 lines aren’t shown here.
This diff is large: its 307 lines aren’t shown here.
This diff is large: its 71 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 176 lines aren’t shown here.
This diff is large: its 126 lines aren’t shown here.
This diff is large: its 114 lines aren’t shown here.
This diff is large: its 167 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 56 lines aren’t shown here.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 41 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 34 lines aren’t shown here.
This diff is large: its 10 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 429 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 286 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 566 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 337 lines aren’t shown here.
This diff is large: its 55 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 321 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 105 lines aren’t shown here.
This diff is large: its 96 lines aren’t shown here.
Binary file not shown.
This diff is large: its 45 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 566 lines aren’t shown here.
This diff is large: its 99 lines aren’t shown here.
This diff is large: its 104 lines aren’t shown here.
This diff is large: its 72 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 1310 lines aren’t shown here.
Binary file not shown.
This diff is large: its 212 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 904 lines aren’t shown here.
This diff is large: its 560 lines aren’t shown here.
This diff is large: its 135 lines aren’t shown here.
This diff is large: its 113 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 2621 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 187 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 178 lines aren’t shown here.
Binary file not shown.
This diff is large: its 47 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 296 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 70 lines aren’t shown here.
This diff is large: its 95 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 225 lines aren’t shown here.
This diff is large: its 96 lines aren’t shown here.
This diff is large: its 401 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 104 lines aren’t shown here.
This diff is large: its 131 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
This diff is large: its 185 lines aren’t shown here.
This diff is large: its 480 lines aren’t shown here.
This diff is large: its 45 lines aren’t shown here.
This diff is large: its 36 lines aren’t shown here.
This diff is large: its 235 lines aren’t shown here.
This diff is large: its 104 lines aren’t shown here.
This diff is large: its 73 lines aren’t shown here.
This diff is large: its 68 lines aren’t shown here.
This diff is large: its 228 lines aren’t shown here.
This diff is large: its 246 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 176 lines aren’t shown here.
This diff is large: its 68 lines aren’t shown here.
This diff is large: its 237 lines aren’t shown here.
This diff is large: its 182 lines aren’t shown here.
This diff is large: its 125 lines aren’t shown here.
This diff is large: its 100 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 235 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 752 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 65 lines aren’t shown here.
This diff is large: its 3 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 48 lines aren’t shown here.
This diff is large: its 7 lines aren’t shown here.
Binary file not shown.
This diff is large: its 299 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 1623 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 2683 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 495 lines aren’t shown here.
Binary file not shown.
This diff is large: its 258 lines aren’t shown here.
Binary file not shown.
This diff is large: its 400 lines aren’t shown here.
Binary file not shown.
This diff is large: its 908 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 1490 lines aren’t shown here.
Binary file not shown.
This diff is large: its 44 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 1219 lines aren’t shown here.
Binary file not shown.
This diff is large: its 437 lines aren’t shown here.
This diff is large: its 726 lines aren’t shown here.
This diff is large: its 132 lines aren’t shown here.
Binary file not shown.
This diff is large: its 175 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 547 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 819 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 665 lines aren’t shown here.
Binary file not shown.
This diff is large: its 323 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 1323 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 2205 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 1620 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 643 lines aren’t shown here.
Binary file not shown.
This diff is large: its 501 lines aren’t shown here.
Binary file not shown.
This diff is large: its 339 lines aren’t shown here.
Binary file not shown.
This diff is large: its 98 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 282 lines aren’t shown here.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This diff is large: its 345 lines aren’t shown here.
This diff is large: its 47 lines aren’t shown here.
This diff is large: its 35 lines aren’t shown here.
This diff is large: its 105 lines aren’t shown here.
This diff is large: its 7 lines aren’t shown here.