jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 116 9c43d9eb1029
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.logging.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class XMenuItemPeer implements MenuItemPeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * Data members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private static Logger log = Logger.getLogger("sun.awt.X11.XMenuItemPeer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * Primary members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Window that this item belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private XBaseMenuWindow container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Target MenuItem. Note that 'target' member
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * in XWindow is required for dispatching events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * This member is only used for accessing its fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * and firing ActionEvent & ItemEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private MenuItem target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Mapping to window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Rectange occupied by menu item in container's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * coordinates. Filled by map(...) function from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * XBaseMenuWindow.map()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private Rectangle bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Point in container's coordinate system used as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * origin by drawText.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private Point textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Size constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private final static int SEPARATOR_WIDTH = 20;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private final static int SEPARATOR_HEIGHT = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * MenuItem's fields & methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private final static Field f_enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private final static Field f_label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private final static Field f_shortcut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private final static Method m_getFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private final static Method m_isItemEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private final static Method m_getActionCommand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        f_enabled = SunToolkit.getField(MenuItem.class, "enabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        f_label = SunToolkit.getField(MenuItem.class, "label");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        f_shortcut = SunToolkit.getField(MenuItem.class, "shortcut");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        m_getActionCommand = SunToolkit.getMethod(MenuItem.class, "getActionCommandImpl", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        m_isItemEnabled = SunToolkit.getMethod(MenuItem.class, "isItemEnabled", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Text Metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Text metrics are filled in calcTextMetrics function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * and reset in resetTextMetrics function. Text metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * contain calculated dimensions of various components of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private TextMetrics textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    static class TextMetrics implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
         * Calculated text size members
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        private Dimension textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        private int shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        private int textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        TextMetrics(Dimension textDimension, int shortcutWidth, int textBaseline) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            this.textDimension = textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            this.shortcutWidth = shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            this.textBaseline = textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            } catch (CloneNotSupportedException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                throw new InternalError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        Dimension getTextDimension() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return this.textDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        int getShortcutWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return this.shortcutWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        int getTextBaseline() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            return this.textBaseline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    XMenuItemPeer(MenuItem target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        this.target = target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Implementaion of interface methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * From MenuComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        //Empty function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public void setFont(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        resetTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * From MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public void setLabel(String label) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        resetTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public void setEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        repaintIfShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @see java.awt.peer.MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public void enable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        setEnabled( true );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @see java.awt.peer.MenuItemPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void disable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        setEnabled( false );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Access to target's fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    MenuItem getTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    Font getTargetFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            return XWindow.defaultFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return (Font)m_getFont.invoke(target, new Object[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return XWindow.defaultFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    String getTargetLabel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            String label = (String)f_label.get(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return (label == null) ? "" : label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    boolean isTargetEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            return f_enabled.getBoolean(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Returns true if item and all its parents are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * This function is used to fix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    boolean isTargetItemEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            return ((Boolean)m_isItemEnabled.invoke(target, new Object[0])).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    String getTargetActionCommand() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            return (String) m_getActionCommand.invoke(target,(Object[]) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    MenuShortcut getTargetShortcut() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        if (target == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            return (MenuShortcut)f_shortcut.get(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    String getShortcutText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        //Fix for 6180413: shortcuts should not be displayed for any of the menuitems in a popup menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        if (container.getRootMenuWindow() instanceof XPopupMenuPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        MenuShortcut sc = getTargetShortcut();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        //TODO:This can potentially call user code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return (sc == null) ? null : sc.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Basic manipulations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * This function is called when filling item vectors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * in XMenuWindow & XMenuBar. We need it because peers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * are created earlier than windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @param container the window that this item belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    void setContainer(XBaseMenuWindow container) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        synchronized(XBaseMenuWindow.getMenuTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            this.container = container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * returns the window that this item belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    XBaseMenuWindow getContainer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return this.container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Overridable behaviour
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * This function should be overriden simply to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * return false in inherited classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    boolean isSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        boolean r = (getTargetLabel().equals("-"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Utility functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Returns true if container exists and is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    boolean isContainerShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        return container.isShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * Repaints item if it is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    void repaintIfShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        if (isContainerShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            container.postPaintEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * This function is invoked when the user clicks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * on menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @param when the timestamp of action event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    void action(long when) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        if (!isSeparator() && isTargetItemEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            XWindow.postEventStatic(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                                    getTargetActionCommand(), when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                                    0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * Text metrics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * Returns text metrics of menu item.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * and is guaranteed to return some value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * (possibly actual, possibly expired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    TextMetrics getTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        return textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * Returns dimensions of item's label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * Returns actual or expired  value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * or null if error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /*Dimension getTextDimension() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return (textMetrics != null) ? textMetrics.textDimension : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * Returns width of item's shortcut label,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * 0 if item has no shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * The height of shortcut can be deternimed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * from text dimensions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * This function does not use any locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * and is guaranteed to return some value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * (possibly actual, possibly expired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /*int getShortcutWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        return (textMetrics != null) ? textMetrics.shortcutWidth : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    int getTextBaseline() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        TextMetrics textMetrics = this.textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        if (textMetrics == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            textMetrics = calcTextMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            this.textMetrics = textMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        return (textMetrics != null) ? textMetrics.textBaseline : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    TextMetrics calcTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        if (container == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        if (isSeparator()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            return new TextMetrics(new Dimension(SEPARATOR_WIDTH, SEPARATOR_HEIGHT), 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        Graphics g = container.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        if (g == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            g.setFont(getTargetFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            FontMetrics fm = g.getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            String str = getTargetLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            int width = fm.stringWidth(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            int height = fm.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            Dimension textDimension = new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            int textBaseline = fm.getHeight() - fm.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            String sc = getShortcutText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            int shortcutWidth = (sc == null) ? 0 : fm.stringWidth(sc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            return new TextMetrics(textDimension, shortcutWidth, textBaseline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    void resetTextMetrics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        textMetrics = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        if (container != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            container.updateSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    /************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * Mapping utility functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     ************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Sets mapping of item to window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param bounds bounds of item in container's coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param textOrigin point for drawString in container's coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @see XBaseMenuWindow.map()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    void map(Rectangle bounds, Point textOrigin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        this.bounds = bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        this.textOrigin = textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * returns bounds of item that were previously set by map() function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        return bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * returns origin of item's text that was previously set by map() function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    Point getTextOrigin() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return textOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
}