Search in sources :

Example 76 with Dimensions

use of org.apache.pivot.wtk.Dimensions in project pivot by apache.

the class FakeWindowSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    int preferredWidth = 0;
    int preferredHeight = 0;
    FakeWindow frame = (FakeWindow) getComponent();
    // Include title bar width plus left/right title bar borders
    Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
    preferredWidth = Math.max(preferredWidth, titleBarSize.width + 2);
    // Include title bar height plus top/bottom title bar borders
    preferredHeight += titleBarSize.height + 2;
    Component content = frame.getContent();
    if (content != null) {
        Dimensions preferredContentSize = content.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
        preferredHeight += preferredContentSize.height;
    }
    // Add padding, borders, and content bevel
    preferredWidth += padding.getWidth() + 2;
    preferredHeight += padding.getHeight() + (1) + 2;
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Aggregations

Dimensions (org.apache.pivot.wtk.Dimensions)76 Component (org.apache.pivot.wtk.Component)40 GradientPaint (java.awt.GradientPaint)21 Point (org.apache.pivot.wtk.Point)16 FontRenderContext (java.awt.font.FontRenderContext)9 Button (org.apache.pivot.wtk.Button)9 Paint (java.awt.Paint)7 Rectangle2D (java.awt.geom.Rectangle2D)6 LineMetrics (java.awt.font.LineMetrics)5 BoxPane (org.apache.pivot.wtk.BoxPane)5 FlowPane (org.apache.pivot.wtk.FlowPane)5 Label (org.apache.pivot.wtk.Label)5 ScrollPane (org.apache.pivot.wtk.ScrollPane)4 Separator (org.apache.pivot.wtk.Separator)4 Form (org.apache.pivot.wtk.Form)3 ImageView (org.apache.pivot.wtk.ImageView)3 Image (org.apache.pivot.wtk.media.Image)3 Color (java.awt.Color)2 Font (java.awt.Font)2 LineBreakMeasurer (java.awt.font.LineBreakMeasurer)2