< prev index next >

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

Print this page




 198     /************************************************
 199      *
 200      * Utility functions
 201      *
 202      ************************************************/
 203 
 204     //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
 205     //near the periphery of the screen, XToolkit
 206 
 207     /**
 208      * Calculates placement of popup menu window
 209      * given origin in global coordinates and
 210      * size of menu window. Returns suggested
 211      * rectangle for menu window in global coordinates
 212      * @param origin the origin point specified in show()
 213      * function converted to global coordinates
 214      * @param windowSize the desired size of menu's window
 215      */
 216     protected Rectangle getWindowBounds(Point origin, Dimension windowSize) {
 217         Rectangle globalBounds = new Rectangle(origin.x, origin.y, 0, 0);
 218         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 219         Rectangle res;
 220         res = fitWindowRight(globalBounds, windowSize, screenSize);
 221         if (res != null) {
 222             return res;
 223         }
 224         res = fitWindowLeft(globalBounds, windowSize, screenSize);
 225         if (res != null) {
 226             return res;
 227         }
 228         res = fitWindowBelow(globalBounds, windowSize, screenSize);
 229         if (res != null) {
 230             return res;
 231         }
 232         res = fitWindowAbove(globalBounds, windowSize, screenSize);
 233         if (res != null) {
 234             return res;
 235         }
 236         return fitWindowToScreen(windowSize, screenSize);
 237    }
 238 




 198     /************************************************
 199      *
 200      * Utility functions
 201      *
 202      ************************************************/
 203 
 204     //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
 205     //near the periphery of the screen, XToolkit
 206 
 207     /**
 208      * Calculates placement of popup menu window
 209      * given origin in global coordinates and
 210      * size of menu window. Returns suggested
 211      * rectangle for menu window in global coordinates
 212      * @param origin the origin point specified in show()
 213      * function converted to global coordinates
 214      * @param windowSize the desired size of menu's window
 215      */
 216     protected Rectangle getWindowBounds(Point origin, Dimension windowSize) {
 217         Rectangle globalBounds = new Rectangle(origin.x, origin.y, 0, 0);
 218         Dimension screenSize = graphicsConfig.getBounds().getSize();        
 219         Rectangle res;
 220         res = fitWindowRight(globalBounds, windowSize, screenSize);
 221         if (res != null) {
 222             return res;
 223         }
 224         res = fitWindowLeft(globalBounds, windowSize, screenSize);
 225         if (res != null) {
 226             return res;
 227         }
 228         res = fitWindowBelow(globalBounds, windowSize, screenSize);
 229         if (res != null) {
 230             return res;
 231         }
 232         res = fitWindowAbove(globalBounds, windowSize, screenSize);
 233         if (res != null) {
 234             return res;
 235         }
 236         return fitWindowToScreen(windowSize, screenSize);
 237    }
 238 


< prev index next >