modules/controls/src/main/java/javafx/scene/control/DialogPane.java

Print this page




 913     }
 914 
 915     /** {@inheritDoc} */
 916     @Override protected double computeMinWidth(double height) {
 917         double headerMinWidth = hasHeader() ? getActualHeader().minWidth(height) + 10 : 0;
 918         double contentMinWidth = getActualContent().minWidth(height);
 919         double buttonBarMinWidth = buttonBar == null ? 0 : buttonBar.minWidth(height);
 920         double graphicMinWidth = getActualGraphic().minWidth(height);
 921 
 922         double expandableContentMinWidth = 0;
 923         final Node expandableContent = getExpandableContent();
 924         if (isExpanded() && expandableContent != null) {
 925             expandableContentMinWidth = expandableContent.minWidth(height);
 926         }
 927 
 928         double minWidth = snappedLeftInset() +
 929                 (hasHeader() ? 0 : graphicMinWidth) +
 930                 Math.max(Math.max(headerMinWidth, expandableContentMinWidth), Math.max(contentMinWidth, buttonBarMinWidth)) +
 931                 snappedRightInset();
 932 
 933         return snapSize(minWidth);
 934     }
 935 
 936     /** {@inheritDoc} */
 937     @Override protected double computeMinHeight(double width) {
 938         final boolean hasHeader = hasHeader();
 939 
 940         double headerMinHeight = hasHeader ? getActualHeader().minHeight(width) : 0;
 941         double buttonBarMinHeight = buttonBar == null ? 0 : buttonBar.minHeight(width);
 942 
 943         Node graphic = getActualGraphic();
 944         double graphicMinWidth = hasHeader ? 0 : graphic.minWidth(-1);
 945         double graphicMinHeight = hasHeader ? 0 : graphic.minHeight(width);
 946 
 947         // min height of a label is based on one line (wrapping is ignored)
 948         Node content = getActualContent();
 949         double contentAvailableWidth = width == Region.USE_COMPUTED_SIZE ? Region.USE_COMPUTED_SIZE :
 950                 hasHeader ? width : (width - graphicMinWidth);
 951         double contentMinHeight = content.minHeight(contentAvailableWidth);
 952 
 953         double expandableContentMinHeight = 0;
 954         final Node expandableContent = getExpandableContent();
 955         if (isExpanded() && expandableContent != null) {
 956             expandableContentMinHeight = expandableContent.minHeight(width);
 957         }
 958 
 959         double minHeight = snappedTopInset() +
 960                 headerMinHeight +
 961                 Math.max(graphicMinHeight, contentMinHeight) +
 962                 expandableContentMinHeight +
 963                 buttonBarMinHeight +
 964                 snappedBottomInset();
 965 
 966         return snapSize(minHeight);
 967     }
 968 
 969     /** {@inheritDoc} */
 970     @Override protected double computePrefWidth(double height) {
 971         double headerPrefWidth = hasHeader() ? getActualHeader().prefWidth(height) + 10 : 0;
 972         double contentPrefWidth = getActualContent().prefWidth(height);
 973         double buttonBarPrefWidth = buttonBar == null ? 0 : buttonBar.prefWidth(height);
 974         double graphicPrefWidth = getActualGraphic().prefWidth(height);
 975 
 976         double expandableContentPrefWidth = 0;
 977         final Node expandableContent = getExpandableContent();
 978         if (isExpanded() && expandableContent != null) {
 979             expandableContentPrefWidth = expandableContent.prefWidth(height);
 980         }
 981 
 982         double prefWidth = snappedLeftInset() +
 983                (hasHeader() ? 0 : graphicPrefWidth) +
 984                Math.max(Math.max(headerPrefWidth, expandableContentPrefWidth), Math.max(contentPrefWidth, buttonBarPrefWidth)) +
 985                snappedRightInset();
 986 
 987         return snapSize(prefWidth);
 988     }
 989 
 990     /** {@inheritDoc} */
 991     @Override protected double computePrefHeight(double width) {
 992         final boolean hasHeader = hasHeader();
 993 
 994         double headerPrefHeight = hasHeader ? getActualHeader().prefHeight(width) : 0;
 995         double buttonBarPrefHeight = buttonBar == null ? 0 : buttonBar.prefHeight(width);
 996 
 997         Node graphic = getActualGraphic();
 998         double graphicPrefWidth = hasHeader ? 0 : graphic.prefWidth(-1);
 999         double graphicPrefHeight = hasHeader ? 0 : graphic.prefHeight(width);
1000 
1001         Node content = getActualContent();
1002         double contentAvailableWidth = width == Region.USE_COMPUTED_SIZE ? Region.USE_COMPUTED_SIZE :
1003                 hasHeader ? width : (width - graphicPrefWidth);
1004         double contentPrefHeight = content.prefHeight(contentAvailableWidth);
1005 
1006         double expandableContentPrefHeight = 0;
1007         final Node expandableContent = getExpandableContent();
1008         if (isExpanded() && expandableContent != null) {
1009             expandableContentPrefHeight = expandableContent.prefHeight(width);
1010         }
1011 
1012         double prefHeight = snappedTopInset() +
1013                headerPrefHeight +
1014                Math.max(graphicPrefHeight, contentPrefHeight) +
1015                expandableContentPrefHeight +
1016                buttonBarPrefHeight +
1017                snappedBottomInset();
1018 
1019         return snapSize(prefHeight);
1020     }
1021 
1022 
1023 
1024     /**************************************************************************
1025      *
1026      * Private implementation
1027      * @param buttonBar
1028      *
1029      **************************************************************************/
1030 
1031     private void updateButtons(ButtonBar buttonBar) {
1032         buttonBar.getButtons().clear();
1033 
1034         // show details button if expandable content is present
1035         if (hasExpandableContent()) {
1036             if (detailsButton == null) {
1037                 detailsButton = createDetailsButton();
1038             }
1039             ButtonBar.setButtonData(detailsButton, ButtonData.HELP_2);




 913     }
 914 
 915     /** {@inheritDoc} */
 916     @Override protected double computeMinWidth(double height) {
 917         double headerMinWidth = hasHeader() ? getActualHeader().minWidth(height) + 10 : 0;
 918         double contentMinWidth = getActualContent().minWidth(height);
 919         double buttonBarMinWidth = buttonBar == null ? 0 : buttonBar.minWidth(height);
 920         double graphicMinWidth = getActualGraphic().minWidth(height);
 921 
 922         double expandableContentMinWidth = 0;
 923         final Node expandableContent = getExpandableContent();
 924         if (isExpanded() && expandableContent != null) {
 925             expandableContentMinWidth = expandableContent.minWidth(height);
 926         }
 927 
 928         double minWidth = snappedLeftInset() +
 929                 (hasHeader() ? 0 : graphicMinWidth) +
 930                 Math.max(Math.max(headerMinWidth, expandableContentMinWidth), Math.max(contentMinWidth, buttonBarMinWidth)) +
 931                 snappedRightInset();
 932 
 933         return snapSizeX(minWidth);
 934     }
 935 
 936     /** {@inheritDoc} */
 937     @Override protected double computeMinHeight(double width) {
 938         final boolean hasHeader = hasHeader();
 939 
 940         double headerMinHeight = hasHeader ? getActualHeader().minHeight(width) : 0;
 941         double buttonBarMinHeight = buttonBar == null ? 0 : buttonBar.minHeight(width);
 942 
 943         Node graphic = getActualGraphic();
 944         double graphicMinWidth = hasHeader ? 0 : graphic.minWidth(-1);
 945         double graphicMinHeight = hasHeader ? 0 : graphic.minHeight(width);
 946 
 947         // min height of a label is based on one line (wrapping is ignored)
 948         Node content = getActualContent();
 949         double contentAvailableWidth = width == Region.USE_COMPUTED_SIZE ? Region.USE_COMPUTED_SIZE :
 950                 hasHeader ? width : (width - graphicMinWidth);
 951         double contentMinHeight = content.minHeight(contentAvailableWidth);
 952 
 953         double expandableContentMinHeight = 0;
 954         final Node expandableContent = getExpandableContent();
 955         if (isExpanded() && expandableContent != null) {
 956             expandableContentMinHeight = expandableContent.minHeight(width);
 957         }
 958 
 959         double minHeight = snappedTopInset() +
 960                 headerMinHeight +
 961                 Math.max(graphicMinHeight, contentMinHeight) +
 962                 expandableContentMinHeight +
 963                 buttonBarMinHeight +
 964                 snappedBottomInset();
 965 
 966         return snapSizeY(minHeight);
 967     }
 968 
 969     /** {@inheritDoc} */
 970     @Override protected double computePrefWidth(double height) {
 971         double headerPrefWidth = hasHeader() ? getActualHeader().prefWidth(height) + 10 : 0;
 972         double contentPrefWidth = getActualContent().prefWidth(height);
 973         double buttonBarPrefWidth = buttonBar == null ? 0 : buttonBar.prefWidth(height);
 974         double graphicPrefWidth = getActualGraphic().prefWidth(height);
 975 
 976         double expandableContentPrefWidth = 0;
 977         final Node expandableContent = getExpandableContent();
 978         if (isExpanded() && expandableContent != null) {
 979             expandableContentPrefWidth = expandableContent.prefWidth(height);
 980         }
 981 
 982         double prefWidth = snappedLeftInset() +
 983                (hasHeader() ? 0 : graphicPrefWidth) +
 984                Math.max(Math.max(headerPrefWidth, expandableContentPrefWidth), Math.max(contentPrefWidth, buttonBarPrefWidth)) +
 985                snappedRightInset();
 986 
 987         return snapSizeX(prefWidth);
 988     }
 989 
 990     /** {@inheritDoc} */
 991     @Override protected double computePrefHeight(double width) {
 992         final boolean hasHeader = hasHeader();
 993 
 994         double headerPrefHeight = hasHeader ? getActualHeader().prefHeight(width) : 0;
 995         double buttonBarPrefHeight = buttonBar == null ? 0 : buttonBar.prefHeight(width);
 996 
 997         Node graphic = getActualGraphic();
 998         double graphicPrefWidth = hasHeader ? 0 : graphic.prefWidth(-1);
 999         double graphicPrefHeight = hasHeader ? 0 : graphic.prefHeight(width);
1000 
1001         Node content = getActualContent();
1002         double contentAvailableWidth = width == Region.USE_COMPUTED_SIZE ? Region.USE_COMPUTED_SIZE :
1003                 hasHeader ? width : (width - graphicPrefWidth);
1004         double contentPrefHeight = content.prefHeight(contentAvailableWidth);
1005 
1006         double expandableContentPrefHeight = 0;
1007         final Node expandableContent = getExpandableContent();
1008         if (isExpanded() && expandableContent != null) {
1009             expandableContentPrefHeight = expandableContent.prefHeight(width);
1010         }
1011 
1012         double prefHeight = snappedTopInset() +
1013                headerPrefHeight +
1014                Math.max(graphicPrefHeight, contentPrefHeight) +
1015                expandableContentPrefHeight +
1016                buttonBarPrefHeight +
1017                snappedBottomInset();
1018 
1019         return snapSizeY(prefHeight);
1020     }
1021 
1022 
1023 
1024     /**************************************************************************
1025      *
1026      * Private implementation
1027      * @param buttonBar
1028      *
1029      **************************************************************************/
1030 
1031     private void updateButtons(ButtonBar buttonBar) {
1032         buttonBar.getButtons().clear();
1033 
1034         // show details button if expandable content is present
1035         if (hasExpandableContent()) {
1036             if (detailsButton == null) {
1037                 detailsButton = createDetailsButton();
1038             }
1039             ButtonBar.setButtonData(detailsButton, ButtonData.HELP_2);