< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XMenuWindow.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2014, 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


 261                 nextOffset += itemHeight;
 262                 item.map(bounds, textOrigin);
 263             } else {
 264                 //Text metrics could not be determined because of errors
 265                 //Map item with empty rectangle
 266                 Rectangle bounds = new Rectangle(WINDOW_SPACING_LEFT, nextOffset, 0, 0);
 267                 Point textOrigin = new Point(WINDOW_SPACING_LEFT + WINDOW_ITEM_MARGIN_LEFT + maxLeftIndent, nextOffset);
 268                 item.map(bounds, textOrigin);
 269             }
 270         }
 271         int height = nextOffset + WINDOW_SPACING_BOTTOM;
 272         MappingData mappingData = new MappingData(itemVector, captionRect, new Dimension(width, height), maxLeftIndent, shortcutOrigin, rightMarkOrigin);
 273         return mappingData;
 274     }
 275 
 276     /**
 277      * @see XBaseMenuWindow#getSubmenuBounds
 278      */
 279     protected Rectangle getSubmenuBounds(Rectangle itemBounds, Dimension windowSize) {
 280         Rectangle globalBounds = toGlobal(itemBounds);
 281         Dimension screenSize = graphicsConfig.getBounds().getSize();
 282         Rectangle res;
 283         res = fitWindowRight(globalBounds, windowSize, screenSize);
 284         if (res != null) {
 285             return res;
 286         }
 287         res = fitWindowBelow(globalBounds, windowSize, screenSize);
 288         if (res != null) {
 289             return res;
 290         }
 291         res = fitWindowAbove(globalBounds, windowSize, screenSize);
 292         if (res != null) {
 293             return res;
 294         }
 295         res = fitWindowLeft(globalBounds, windowSize, screenSize);
 296         if (res != null) {
 297             return res;
 298         }
 299         return fitWindowToScreen(windowSize, screenSize);
 300    }
 301 
 302     /**
 303      * It's likely that size of items was changed
 304      * invoke resizing of window on eventHandlerThread
 305      */
 306     protected void updateSize() {
 307         resetMapping();
 308         if (isShowing()) {
 309             XToolkit.executeOnEventHandlerThread(target, new Runnable() {
 310                     public void run() {
 311                         Dimension dim = getDesiredSize();
 312                         reshape(x, y, dim.width, dim.height);
 313                     }
 314                 });
 315         }
 316     }
 317 
 318     /************************************************
 319      *


   1 /*
   2  * Copyright (c) 2002, 2017, 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


 261                 nextOffset += itemHeight;
 262                 item.map(bounds, textOrigin);
 263             } else {
 264                 //Text metrics could not be determined because of errors
 265                 //Map item with empty rectangle
 266                 Rectangle bounds = new Rectangle(WINDOW_SPACING_LEFT, nextOffset, 0, 0);
 267                 Point textOrigin = new Point(WINDOW_SPACING_LEFT + WINDOW_ITEM_MARGIN_LEFT + maxLeftIndent, nextOffset);
 268                 item.map(bounds, textOrigin);
 269             }
 270         }
 271         int height = nextOffset + WINDOW_SPACING_BOTTOM;
 272         MappingData mappingData = new MappingData(itemVector, captionRect, new Dimension(width, height), maxLeftIndent, shortcutOrigin, rightMarkOrigin);
 273         return mappingData;
 274     }
 275 
 276     /**
 277      * @see XBaseMenuWindow#getSubmenuBounds
 278      */
 279     protected Rectangle getSubmenuBounds(Rectangle itemBounds, Dimension windowSize) {
 280         Rectangle globalBounds = toGlobal(itemBounds);
 281         Rectangle screenBounds = getCurrentGraphicsConfiguration().getBounds();
 282         Rectangle res;
 283         res = fitWindowRight(globalBounds, windowSize, screenBounds);
 284         if (res != null) {
 285             return res;
 286         }
 287         res = fitWindowBelow(globalBounds, windowSize, screenBounds);
 288         if (res != null) {
 289             return res;
 290         }
 291         res = fitWindowAbove(globalBounds, windowSize, screenBounds);
 292         if (res != null) {
 293             return res;
 294         }
 295         res = fitWindowLeft(globalBounds, windowSize, screenBounds);
 296         if (res != null) {
 297             return res;
 298         }
 299         return fitWindowToScreen(windowSize, screenBounds);
 300    }
 301 
 302     /**
 303      * It's likely that size of items was changed
 304      * invoke resizing of window on eventHandlerThread
 305      */
 306     protected void updateSize() {
 307         resetMapping();
 308         if (isShowing()) {
 309             XToolkit.executeOnEventHandlerThread(target, new Runnable() {
 310                     public void run() {
 311                         Dimension dim = getDesiredSize();
 312                         reshape(x, y, dim.width, dim.height);
 313                     }
 314                 });
 315         }
 316     }
 317 
 318     /************************************************
 319      *


< prev index next >