Ignore:
Timestamp:
2014-08-30T01:59:31+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #10392 - rework of MenuScroller to replace static scrollCount approach by dynamic behaviour (fix regressions from #10207)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r7012 r7463  
    66import java.awt.Component;
    77import java.awt.Dimension;
     8import java.awt.GraphicsConfiguration;
    89import java.awt.GraphicsDevice;
    910import java.awt.GraphicsEnvironment;
     11import java.awt.Insets;
    1012import java.awt.Point;
    1113import java.awt.Rectangle;
     
    1416import java.util.regex.Matcher;
    1517import java.util.regex.Pattern;
     18
     19import javax.swing.JComponent;
    1620
    1721import org.openstreetmap.josm.Main;
     
    367371        }
    368372        return virtualBounds;
     373    }
     374
     375    /**
     376     * Computes the maximum dimension for a component to fit in screen displaying {@code component}.
     377     * @param component The component to get current screen info from. Must not be {@code null}
     378     * @return the maximum dimension for a component to fit in current screen
     379     * @throws IllegalArgumentException if {@code component} is null
     380     * @since 7463
     381     */
     382    public static Dimension getMaxDimensionOnScreen(JComponent component) {
     383        CheckParameterUtil.ensureParameterNotNull(component, "component");
     384        // Compute max dimension of current screen
     385        Dimension result = new Dimension();
     386        GraphicsConfiguration gc = component.getGraphicsConfiguration();
     387        if (gc == null && Main.parent != null) {
     388            gc = Main.parent.getGraphicsConfiguration();
     389        }
     390        if (gc != null) {
     391            // Max displayable dimension (max screen dimension - insets)
     392            Rectangle bounds = gc.getBounds();
     393            Insets insets = component.getToolkit().getScreenInsets(gc);
     394            result.width  = bounds.width  - insets.left - insets.right;
     395            result.height = bounds.height - insets.top - insets.bottom;
     396        }
     397        return result;
    369398    }
    370399
Note: See TracChangeset for help on using the changeset viewer.