114 public PopupControl() {
115 super();
116 this.bridge = new CSSBridge();
117 setAnchorLocation(AnchorLocation.CONTENT_TOP_LEFT);
118 PopupWindowHelper.getContent(this).add(bridge);
119 }
120
121 // TODO the fact that PopupWindow uses a group for auto-moving things
122 // around means that the scene resize semantics don't work if the
123 // child is a resizable. I will need to replicate those semantics
124 // here sometime, such that if the Skin provides a resizable, it is
125 // given to match the popup window's width & height.
126
127 /**
128 * The id of this {@code PopupControl}. This simple string identifier is useful for
129 * finding a specific Node within the scene graph. While the id of a Node
130 * should be unique within the scene graph, this uniqueness is not enforced.
131 * This is analogous to the "id" attribute on an HTML element
132 * (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS ID Specification</a>).
133 *
134 * @defaultValue null
135 */
136 public final StringProperty idProperty() { return bridge.idProperty(); }
137
138 /**
139 * Sets the id of this {@code PopupControl}. This simple string identifier is useful for
140 * finding a specific Node within the scene graph. While the id of a Node
141 * should be unique within the scene graph, this uniqueness is not enforced.
142 * This is analogous to the "id" attribute on an HTML element
143 * (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS ID Specification</a>).
144 *
145 * @param value the id assigned to this {@code PopupControl} using the {@code setId}
146 * method or {@code null}, if no id has been assigned.
147 * @defaultValue null
148 */
149 public final void setId(String value) { idProperty().set(value); }
150
151 /**
152 * The id of this {@code PopupControl}. This simple string identifier is useful for
153 * finding a specific Node within the scene graph. While the id of a Node
384 * computed minimum width.
385 * <p>
386 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
387 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
388 * enabling applications to easily restrict the resizability of the control.
389 */
390 private DoubleProperty minWidth;
391
392 /**
393 * Property for overriding the control's computed minimum width.
394 * This should only be set if the control's internally computed minimum width
395 * doesn't meet the application's layout needs.
396 * <p>
397 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
398 * <code>getMinWidth(forHeight)</code> will return the control's internally
399 * computed minimum width.
400 * <p>
401 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
402 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
403 * enabling applications to easily restrict the resizability of the control.
404 */
405 public final void setMinWidth(double value) { minWidthProperty().set(value); }
406
407 /**
408 * Property for overriding the control's computed minimum width.
409 * This should only be set if the control's internally computed minimum width
410 * doesn't meet the application's layout needs.
411 * <p>
412 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
413 * <code>getMinWidth(forHeight)</code> will return the control's internally
414 * computed minimum width.
415 * <p>
416 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
417 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
418 * enabling applications to easily restrict the resizability of the control.
419 */
420 public final double getMinWidth() { return minWidth == null ? USE_COMPUTED_SIZE : minWidth.get(); }
421 public final DoubleProperty minWidthProperty() {
422 if (minWidth == null) {
423 minWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
424 @Override public void invalidated() {
425 if (isShowing()) bridge.requestLayout();
426 }
427
428 @Override
429 public Object getBean() {
430 return PopupControl.this;
431 }
432
433 @Override
434 public String getName() {
435 return "minWidth";
436 }
437 };
438 }
452 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
453 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
454 * enabling applications to easily restrict the resizability of the control.
455 *
456 */
457 private DoubleProperty minHeight;
458
459 /**
460 * Property for overriding the control's computed minimum height.
461 * This should only be set if the control's internally computed minimum height
462 * doesn't meet the application's layout needs.
463 * <p>
464 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
465 * <code>getMinHeight(forWidth)</code> will return the control's internally
466 * computed minimum height.
467 * <p>
468 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
469 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
470 * enabling applications to easily restrict the resizability of the control.
471 *
472 */
473 public final void setMinHeight(double value) { minHeightProperty().set(value); }
474
475 /**
476 * Property for overriding the control's computed minimum height.
477 * This should only be set if the control's internally computed minimum height
478 * doesn't meet the application's layout needs.
479 * <p>
480 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
481 * <code>getMinHeight(forWidth)</code> will return the control's internally
482 * computed minimum height.
483 * <p>
484 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
485 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
486 * enabling applications to easily restrict the resizability of the control.
487 *
488 */
489 public final double getMinHeight() { return minHeight == null ? USE_COMPUTED_SIZE : minHeight.get(); }
490 public final DoubleProperty minHeightProperty() {
491 if (minHeight == null) {
492 minHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
493 @Override public void invalidated() {
494 if (isShowing()) bridge.requestLayout();
495 }
496
497 @Override
498 public Object getBean() {
499 return PopupControl.this;
500 }
501
502 @Override
503 public String getName() {
504 return "minHeight";
505 }
506 };
507 }
525
526 /**
527 * Property for overriding the control's computed preferred width.
528 * This should only be set if the control's internally computed preferred width
529 * doesn't meet the application's layout needs.
530 * <p>
531 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
532 * <code>getPrefWidth(forHeight)</code> will return the control's internally
533 * computed preferred width.
534 */
535 private DoubleProperty prefWidth;
536
537 /**
538 * Property for overriding the control's computed preferred width.
539 * This should only be set if the control's internally computed preferred width
540 * doesn't meet the application's layout needs.
541 * <p>
542 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
543 * <code>getPrefWidth(forHeight)</code> will return the control's internally
544 * computed preferred width.
545 */
546 public final void setPrefWidth(double value) { prefWidthProperty().set(value); }
547
548 /**
549 * Property for overriding the control's computed preferred width.
550 * This should only be set if the control's internally computed preferred width
551 * doesn't meet the application's layout needs.
552 * <p>
553 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
554 * <code>getPrefWidth(forHeight)</code> will return the control's internally
555 * computed preferred width.
556 */
557 public final double getPrefWidth() { return prefWidth == null ? USE_COMPUTED_SIZE : prefWidth.get(); }
558 public final DoubleProperty prefWidthProperty() {
559 if (prefWidth == null) {
560 prefWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
561 @Override public void invalidated() {
562 if (isShowing()) bridge.requestLayout();
563 }
564
565 @Override
566 public Object getBean() {
567 return PopupControl.this;
568 }
569
570 @Override
571 public String getName() {
572 return "prefWidth";
573 }
574 };
575 }
580 * Property for overriding the control's computed preferred height.
581 * This should only be set if the control's internally computed preferred height
582 * doesn't meet the application's layout needs.
583 * <p>
584 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
585 * <code>getPrefHeight(forWidth)</code> will return the control's internally
586 * computed preferred width.
587 *
588 */
589 private DoubleProperty prefHeight;
590
591 /**
592 * Property for overriding the control's computed preferred height.
593 * This should only be set if the control's internally computed preferred height
594 * doesn't meet the application's layout needs.
595 * <p>
596 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
597 * <code>getPrefHeight(forWidth)</code> will return the control's internally
598 * computed preferred width.
599 *
600 */
601 public final void setPrefHeight(double value) { prefHeightProperty().set(value); }
602
603 /**
604 * Property for overriding the control's computed preferred height.
605 * This should only be set if the control's internally computed preferred height
606 * doesn't meet the application's layout needs.
607 * <p>
608 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
609 * <code>getPrefHeight(forWidth)</code> will return the control's internally
610 * computed preferred width.
611 *
612 */
613 public final double getPrefHeight() { return prefHeight == null ? USE_COMPUTED_SIZE : prefHeight.get(); }
614 public final DoubleProperty prefHeightProperty() {
615 if (prefHeight == null) {
616 prefHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
617 @Override public void invalidated() {
618 if (isShowing()) bridge.requestLayout();
619 }
620
621 @Override
622 public Object getBean() {
623 return PopupControl.this;
624 }
625
626 @Override
627 public String getName() {
628 return "prefHeight";
629 }
630 };
631 }
657 * computed maximum width.
658 * <p>
659 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
660 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
661 * enabling applications to easily restrict the resizability of the control.
662 */
663 private DoubleProperty maxWidth;
664
665 /**
666 * Property for overriding the control's computed maximum width.
667 * This should only be set if the control's internally computed maximum width
668 * doesn't meet the application's layout needs.
669 * <p>
670 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
671 * <code>getMaxWidth(forHeight)</code> will return the control's internally
672 * computed maximum width.
673 * <p>
674 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
675 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
676 * enabling applications to easily restrict the resizability of the control.
677 */
678 public final void setMaxWidth(double value) { maxWidthProperty().set(value); }
679
680 /**
681 * Property for overriding the control's computed maximum width.
682 * This should only be set if the control's internally computed maximum width
683 * doesn't meet the application's layout needs.
684 * <p>
685 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
686 * <code>getMaxWidth(forHeight)</code> will return the control's internally
687 * computed maximum width.
688 * <p>
689 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
690 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
691 * enabling applications to easily restrict the resizability of the control.
692 */
693 public final double getMaxWidth() { return maxWidth == null ? USE_COMPUTED_SIZE : maxWidth.get(); }
694 public final DoubleProperty maxWidthProperty() {
695 if (maxWidth == null) {
696 maxWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
697 @Override public void invalidated() {
698 if (isShowing()) bridge.requestLayout();
699 }
700
701 @Override
702 public Object getBean() {
703 return PopupControl.this;
704 }
705
706 @Override
707 public String getName() {
708 return "maxWidth";
709 }
710 };
711 }
724 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
725 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
726 * enabling applications to easily restrict the resizability of the control.
727 *
728 */
729 private DoubleProperty maxHeight;
730
731 /**
732 * Property for overriding the control's computed maximum height.
733 * This should only be set if the control's internally computed maximum height
734 * doesn't meet the application's layout needs.
735 * <p>
736 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
737 * <code>getMaxHeight(forWidth)</code> will return the control's internally
738 * computed maximum height.
739 * <p>
740 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
741 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
742 * enabling applications to easily restrict the resizability of the control.
743 *
744 */
745 public final void setMaxHeight(double value) { maxHeightProperty().set(value); }
746
747 /**
748 * Property for overriding the control's computed maximum height.
749 * This should only be set if the control's internally computed maximum height
750 * doesn't meet the application's layout needs.
751 * <p>
752 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
753 * <code>getMaxHeight(forWidth)</code> will return the control's internally
754 * computed maximum height.
755 * <p>
756 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
757 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
758 * enabling applications to easily restrict the resizability of the control.
759 *
760 */
761 public final double getMaxHeight() { return maxHeight == null ? USE_COMPUTED_SIZE : maxHeight.get(); }
762 public final DoubleProperty maxHeightProperty() {
763 if (maxHeight == null) {
764 maxHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
765 @Override public void invalidated() {
766 if (isShowing()) bridge.requestLayout();
767 }
768
769 @Override
770 public Object getBean() {
771 return PopupControl.this;
772 }
773
774 @Override
775 public String getName() {
776 return "maxHeight";
777 }
778 };
779 }
1017
1018 /**
1019 * @return The CssMetaData associated with this class, which may include the
1020 * CssMetaData of its superclasses.
1021 * @since JavaFX 8.0
1022 */
1023 public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
1024 return STYLEABLES;
1025 }
1026
1027 /**
1028 * {@inheritDoc}
1029 * @since JavaFX 8.0
1030 */
1031 @Override
1032 public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
1033 return getClassCssMetaData();
1034 }
1035
1036 /**
1037 * @see Node#pseudoClassStateChanged(javafx.css.PseudoClass, boolean)
1038 * @since JavaFX 8.0
1039 */
1040 public final void pseudoClassStateChanged(PseudoClass pseudoClass, boolean active) {
1041 bridge.pseudoClassStateChanged(pseudoClass, active);
1042 }
1043
1044 /**
1045 * {@inheritDoc}
1046 * @return "PopupControl"
1047 * @since JavaFX 8.0
1048 */
1049 @Override
1050 public String getTypeSelector() {
1051 return "PopupControl";
1052 }
1053
1054 /**
1055 * {@inheritDoc}
1056 *
1057 * A PopupControl's styles are based on the popup "owner" which is the
1058 * {@link javafx.stage.PopupWindow#getOwnerNode() ownerNode} or,
1059 * if the ownerNode is not set, the root of the {@link javafx.stage.PopupWindow#getOwnerWindow() ownerWindow's}
1060 * scene. If the popup has not been shown, both ownerNode and ownerWindow will be null and {@code null} will be returned.
1061 *
1062 * Note that the PopupWindow's scene root is not returned because there is no way to guarantee that the
1063 * PopupWindow's scene root would properly return the ownerNode or ownerWindow.
1064 *
1065 * @return {@link javafx.stage.PopupWindow#getOwnerNode()}, {@link javafx.stage.PopupWindow#getOwnerWindow()},
1066 * or null.
1067 * @since JavaFX 8.0
1068 */
1069 @Override
1070 public Styleable getStyleableParent() {
1071
1072 final Node ownerNode = getOwnerNode();
1073 if (ownerNode != null) {
1074 return ownerNode;
1075
1076 } else {
1077
1078 final Window ownerWindow = getOwnerWindow();
1079 if (ownerWindow != null) {
1080
1081 final Scene ownerScene = ownerWindow.getScene();
1082 if (ownerScene != null) {
1083 return ownerScene.getRoot();
1084 }
1085 }
1086 }
1087
1088 return bridge.getParent();
1089
1090 }
1091
1092 /**
1093 * {@inheritDoc}
1094 * @since JavaFX 8.0
1095 */
1096 public final ObservableSet<PseudoClass> getPseudoClassStates() {
1097 return FXCollections.emptyObservableSet();
1098 }
1099
1100 /** {@inheritDoc} */
1101 @Override public Node getStyleableNode() {
1102 return bridge;
1103 }
1104
1105 /**
1106 * The link between the popup window and the scenegraph.
1107 *
1108 * @since JavaFX 2.1
1109 */
1110 protected class CSSBridge extends Pane {
1111
1112 private final PopupControl popupControl = PopupControl.this;
1113
1114 {
1115 // To initialize the class helper at the begining each constructor of this class
1116 CSSBridgeHelper.initHelper(this);
1117 }
1118
1119 /**
1120 * Requests a layout pass to be performed before the next scene is
1121 * rendered. This is batched up asynchronously to happen once per
1122 * "pulse", or frame of animation.
1123 * <p/>
1124 * If this parent is either a layout root or unmanaged, then it will be
1125 * added directly to the scene's dirty layout list, otherwise requestLayout
1126 * will be invoked on its parent.
1127 */
1128 @Override public void requestLayout() {
1129 prefWidthCache = -1;
1130 prefHeightCache = -1;
1131 minWidthCache = -1;
1132 minHeightCache = -1;
1133 maxWidthCache = -1;
1134 maxHeightCache = -1;
1135 //skinSizeComputed = false; -- RT-33073 disabled this
1136 super.requestLayout();
1137 }
1138
1139 /**
1140 * This method should be treated as final and should not be overridden by any subclasses of CSSBridge.
1141 */
1142 @Override
1143 public Styleable getStyleableParent() {
1144 return PopupControl.this.getStyleableParent();
1145 }
1146
1147 @Override
1148 public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
1149 return PopupControl.this.getCssMetaData();
1150 }
1151
1152 /*
1153 * Note: This method MUST only be called via its accessor method.
1154 */
1155 private List<String> doGetAllParentStylesheets() {
1156 Styleable styleable = getStyleableParent();
1157 if (styleable instanceof Parent) {
1158 return ParentHelper.getAllParentStylesheets((Parent)styleable);
1159 }
1160 return null;
|
114 public PopupControl() {
115 super();
116 this.bridge = new CSSBridge();
117 setAnchorLocation(AnchorLocation.CONTENT_TOP_LEFT);
118 PopupWindowHelper.getContent(this).add(bridge);
119 }
120
121 // TODO the fact that PopupWindow uses a group for auto-moving things
122 // around means that the scene resize semantics don't work if the
123 // child is a resizable. I will need to replicate those semantics
124 // here sometime, such that if the Skin provides a resizable, it is
125 // given to match the popup window's width & height.
126
127 /**
128 * The id of this {@code PopupControl}. This simple string identifier is useful for
129 * finding a specific Node within the scene graph. While the id of a Node
130 * should be unique within the scene graph, this uniqueness is not enforced.
131 * This is analogous to the "id" attribute on an HTML element
132 * (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS ID Specification</a>).
133 *
134 * @return the id property
135 * @defaultValue null
136 */
137 public final StringProperty idProperty() { return bridge.idProperty(); }
138
139 /**
140 * Sets the id of this {@code PopupControl}. This simple string identifier is useful for
141 * finding a specific Node within the scene graph. While the id of a Node
142 * should be unique within the scene graph, this uniqueness is not enforced.
143 * This is analogous to the "id" attribute on an HTML element
144 * (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS ID Specification</a>).
145 *
146 * @param value the id assigned to this {@code PopupControl} using the {@code setId}
147 * method or {@code null}, if no id has been assigned.
148 * @defaultValue null
149 */
150 public final void setId(String value) { idProperty().set(value); }
151
152 /**
153 * The id of this {@code PopupControl}. This simple string identifier is useful for
154 * finding a specific Node within the scene graph. While the id of a Node
385 * computed minimum width.
386 * <p>
387 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
388 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
389 * enabling applications to easily restrict the resizability of the control.
390 */
391 private DoubleProperty minWidth;
392
393 /**
394 * Property for overriding the control's computed minimum width.
395 * This should only be set if the control's internally computed minimum width
396 * doesn't meet the application's layout needs.
397 * <p>
398 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
399 * <code>getMinWidth(forHeight)</code> will return the control's internally
400 * computed minimum width.
401 * <p>
402 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
403 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
404 * enabling applications to easily restrict the resizability of the control.
405 * @param value the minimum width
406 */
407 public final void setMinWidth(double value) { minWidthProperty().set(value); }
408
409 /**
410 * Property for overriding the control's computed minimum width.
411 * This should only be set if the control's internally computed minimum width
412 * doesn't meet the application's layout needs.
413 * <p>
414 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
415 * <code>getMinWidth(forHeight)</code> will return the control's internally
416 * computed minimum width.
417 * <p>
418 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
419 * <code>getMinWidth(forHeight)</code> to return the control's preferred width,
420 * enabling applications to easily restrict the resizability of the control.
421 * @return the minimum width
422 */
423 public final double getMinWidth() { return minWidth == null ? USE_COMPUTED_SIZE : minWidth.get(); }
424 public final DoubleProperty minWidthProperty() {
425 if (minWidth == null) {
426 minWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
427 @Override public void invalidated() {
428 if (isShowing()) bridge.requestLayout();
429 }
430
431 @Override
432 public Object getBean() {
433 return PopupControl.this;
434 }
435
436 @Override
437 public String getName() {
438 return "minWidth";
439 }
440 };
441 }
455 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
456 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
457 * enabling applications to easily restrict the resizability of the control.
458 *
459 */
460 private DoubleProperty minHeight;
461
462 /**
463 * Property for overriding the control's computed minimum height.
464 * This should only be set if the control's internally computed minimum height
465 * doesn't meet the application's layout needs.
466 * <p>
467 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
468 * <code>getMinHeight(forWidth)</code> will return the control's internally
469 * computed minimum height.
470 * <p>
471 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
472 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
473 * enabling applications to easily restrict the resizability of the control.
474 *
475 * @param value the minimum height
476 */
477 public final void setMinHeight(double value) { minHeightProperty().set(value); }
478
479 /**
480 * Property for overriding the control's computed minimum height.
481 * This should only be set if the control's internally computed minimum height
482 * doesn't meet the application's layout needs.
483 * <p>
484 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
485 * <code>getMinHeight(forWidth)</code> will return the control's internally
486 * computed minimum height.
487 * <p>
488 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
489 * <code>getMinHeight(forWidth)</code> to return the control's preferred height,
490 * enabling applications to easily restrict the resizability of the control.
491 *
492 * @return the minimum height
493 */
494 public final double getMinHeight() { return minHeight == null ? USE_COMPUTED_SIZE : minHeight.get(); }
495 public final DoubleProperty minHeightProperty() {
496 if (minHeight == null) {
497 minHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
498 @Override public void invalidated() {
499 if (isShowing()) bridge.requestLayout();
500 }
501
502 @Override
503 public Object getBean() {
504 return PopupControl.this;
505 }
506
507 @Override
508 public String getName() {
509 return "minHeight";
510 }
511 };
512 }
530
531 /**
532 * Property for overriding the control's computed preferred width.
533 * This should only be set if the control's internally computed preferred width
534 * doesn't meet the application's layout needs.
535 * <p>
536 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
537 * <code>getPrefWidth(forHeight)</code> will return the control's internally
538 * computed preferred width.
539 */
540 private DoubleProperty prefWidth;
541
542 /**
543 * Property for overriding the control's computed preferred width.
544 * This should only be set if the control's internally computed preferred width
545 * doesn't meet the application's layout needs.
546 * <p>
547 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
548 * <code>getPrefWidth(forHeight)</code> will return the control's internally
549 * computed preferred width.
550 * @param value the preferred width
551 */
552 public final void setPrefWidth(double value) { prefWidthProperty().set(value); }
553
554 /**
555 * Property for overriding the control's computed preferred width.
556 * This should only be set if the control's internally computed preferred width
557 * doesn't meet the application's layout needs.
558 * <p>
559 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
560 * <code>getPrefWidth(forHeight)</code> will return the control's internally
561 * computed preferred width.
562 * @return the preferred width
563 */
564 public final double getPrefWidth() { return prefWidth == null ? USE_COMPUTED_SIZE : prefWidth.get(); }
565 public final DoubleProperty prefWidthProperty() {
566 if (prefWidth == null) {
567 prefWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
568 @Override public void invalidated() {
569 if (isShowing()) bridge.requestLayout();
570 }
571
572 @Override
573 public Object getBean() {
574 return PopupControl.this;
575 }
576
577 @Override
578 public String getName() {
579 return "prefWidth";
580 }
581 };
582 }
587 * Property for overriding the control's computed preferred height.
588 * This should only be set if the control's internally computed preferred height
589 * doesn't meet the application's layout needs.
590 * <p>
591 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
592 * <code>getPrefHeight(forWidth)</code> will return the control's internally
593 * computed preferred width.
594 *
595 */
596 private DoubleProperty prefHeight;
597
598 /**
599 * Property for overriding the control's computed preferred height.
600 * This should only be set if the control's internally computed preferred height
601 * doesn't meet the application's layout needs.
602 * <p>
603 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
604 * <code>getPrefHeight(forWidth)</code> will return the control's internally
605 * computed preferred width.
606 *
607 * @param value the preferred height
608 */
609 public final void setPrefHeight(double value) { prefHeightProperty().set(value); }
610
611 /**
612 * Property for overriding the control's computed preferred height.
613 * This should only be set if the control's internally computed preferred height
614 * doesn't meet the application's layout needs.
615 * <p>
616 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
617 * <code>getPrefHeight(forWidth)</code> will return the control's internally
618 * computed preferred width.
619 *
620 * @return the preferred height
621 */
622 public final double getPrefHeight() { return prefHeight == null ? USE_COMPUTED_SIZE : prefHeight.get(); }
623 public final DoubleProperty prefHeightProperty() {
624 if (prefHeight == null) {
625 prefHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
626 @Override public void invalidated() {
627 if (isShowing()) bridge.requestLayout();
628 }
629
630 @Override
631 public Object getBean() {
632 return PopupControl.this;
633 }
634
635 @Override
636 public String getName() {
637 return "prefHeight";
638 }
639 };
640 }
666 * computed maximum width.
667 * <p>
668 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
669 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
670 * enabling applications to easily restrict the resizability of the control.
671 */
672 private DoubleProperty maxWidth;
673
674 /**
675 * Property for overriding the control's computed maximum width.
676 * This should only be set if the control's internally computed maximum width
677 * doesn't meet the application's layout needs.
678 * <p>
679 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
680 * <code>getMaxWidth(forHeight)</code> will return the control's internally
681 * computed maximum width.
682 * <p>
683 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
684 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
685 * enabling applications to easily restrict the resizability of the control.
686 * @param value the maximum width
687 */
688 public final void setMaxWidth(double value) { maxWidthProperty().set(value); }
689
690 /**
691 * Property for overriding the control's computed maximum width.
692 * This should only be set if the control's internally computed maximum width
693 * doesn't meet the application's layout needs.
694 * <p>
695 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
696 * <code>getMaxWidth(forHeight)</code> will return the control's internally
697 * computed maximum width.
698 * <p>
699 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
700 * <code>getMaxWidth(forHeight)</code> to return the control's preferred width,
701 * enabling applications to easily restrict the resizability of the control.
702 * @return the maximum width
703 */
704 public final double getMaxWidth() { return maxWidth == null ? USE_COMPUTED_SIZE : maxWidth.get(); }
705 public final DoubleProperty maxWidthProperty() {
706 if (maxWidth == null) {
707 maxWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
708 @Override public void invalidated() {
709 if (isShowing()) bridge.requestLayout();
710 }
711
712 @Override
713 public Object getBean() {
714 return PopupControl.this;
715 }
716
717 @Override
718 public String getName() {
719 return "maxWidth";
720 }
721 };
722 }
735 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
736 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
737 * enabling applications to easily restrict the resizability of the control.
738 *
739 */
740 private DoubleProperty maxHeight;
741
742 /**
743 * Property for overriding the control's computed maximum height.
744 * This should only be set if the control's internally computed maximum height
745 * doesn't meet the application's layout needs.
746 * <p>
747 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
748 * <code>getMaxHeight(forWidth)</code> will return the control's internally
749 * computed maximum height.
750 * <p>
751 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
752 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
753 * enabling applications to easily restrict the resizability of the control.
754 *
755 * @param value the maximum height
756 */
757 public final void setMaxHeight(double value) { maxHeightProperty().set(value); }
758
759 /**
760 * Property for overriding the control's computed maximum height.
761 * This should only be set if the control's internally computed maximum height
762 * doesn't meet the application's layout needs.
763 * <p>
764 * Defaults to the <code>USE_COMPUTED_SIZE</code> flag, which means that
765 * <code>getMaxHeight(forWidth)</code> will return the control's internally
766 * computed maximum height.
767 * <p>
768 * Setting this value to the <code>USE_PREF_SIZE</code> flag will cause
769 * <code>getMaxHeight(forWidth)</code> to return the control's preferred height,
770 * enabling applications to easily restrict the resizability of the control.
771 *
772 * @return the maximum height
773 */
774 public final double getMaxHeight() { return maxHeight == null ? USE_COMPUTED_SIZE : maxHeight.get(); }
775 public final DoubleProperty maxHeightProperty() {
776 if (maxHeight == null) {
777 maxHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
778 @Override public void invalidated() {
779 if (isShowing()) bridge.requestLayout();
780 }
781
782 @Override
783 public Object getBean() {
784 return PopupControl.this;
785 }
786
787 @Override
788 public String getName() {
789 return "maxHeight";
790 }
791 };
792 }
1030
1031 /**
1032 * @return The CssMetaData associated with this class, which may include the
1033 * CssMetaData of its superclasses.
1034 * @since JavaFX 8.0
1035 */
1036 public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
1037 return STYLEABLES;
1038 }
1039
1040 /**
1041 * {@inheritDoc}
1042 * @since JavaFX 8.0
1043 */
1044 @Override
1045 public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
1046 return getClassCssMetaData();
1047 }
1048
1049 /**
1050 * @param pseudoClass the pseudo class
1051 * @param active the active state
1052 * @see Node#pseudoClassStateChanged(javafx.css.PseudoClass, boolean)
1053 * @since JavaFX 8.0
1054 */
1055 public final void pseudoClassStateChanged(PseudoClass pseudoClass, boolean active) {
1056 bridge.pseudoClassStateChanged(pseudoClass, active);
1057 }
1058
1059 /**
1060 * {@inheritDoc}
1061 * @return "PopupControl"
1062 * @since JavaFX 8.0
1063 */
1064 @Override
1065 public String getTypeSelector() {
1066 return "PopupControl";
1067 }
1068
1069 /**
1070 * {@inheritDoc}
1071 *
1072 * {@literal A PopupControl's styles are based on the popup "owner" which is the}
1073 * {@link javafx.stage.PopupWindow#getOwnerNode() ownerNode} or,
1074 * if the ownerNode is not set, the root of the
1075 * {@link javafx.stage.PopupWindow#getOwnerWindow() ownerWindow's}
1076 * scene. If the popup has not been shown, both ownerNode and ownerWindow will be null and {@code null} will be returned.
1077 *
1078 * {@literal Note that the PopupWindow's scene root is not returned because
1079 * there is no way to guarantee that the PopupWindow's scene root would
1080 * properly return the ownerNode or ownerWindow.}
1081 *
1082 * @return {@link javafx.stage.PopupWindow#getOwnerNode()}, {@link javafx.stage.PopupWindow#getOwnerWindow()},
1083 * or null.
1084 * @since JavaFX 8.0
1085 */
1086 @Override
1087 public Styleable getStyleableParent() {
1088
1089 final Node ownerNode = getOwnerNode();
1090 if (ownerNode != null) {
1091 return ownerNode;
1092
1093 } else {
1094
1095 final Window ownerWindow = getOwnerWindow();
1096 if (ownerWindow != null) {
1097
1098 final Scene ownerScene = ownerWindow.getScene();
1099 if (ownerScene != null) {
1100 return ownerScene.getRoot();
1101 }
1102 }
1103 }
1104
1105 return bridge.getParent();
1106
1107 }
1108
1109 /**
1110 * {@inheritDoc}
1111 * @since JavaFX 8.0
1112 */
1113 @Override
1114 public final ObservableSet<PseudoClass> getPseudoClassStates() {
1115 return FXCollections.emptyObservableSet();
1116 }
1117
1118 /** {@inheritDoc} */
1119 @Override public Node getStyleableNode() {
1120 return bridge;
1121 }
1122
1123 /**
1124 * The link between the popup window and the scenegraph.
1125 *
1126 * @since JavaFX 2.1
1127 */
1128 protected class CSSBridge extends Pane {
1129
1130 private final PopupControl popupControl = PopupControl.this;
1131
1132 {
1133 // To initialize the class helper at the begining each constructor of this class
1134 CSSBridgeHelper.initHelper(this);
1135 }
1136
1137 /**
1138 * Requests a layout pass to be performed before the next scene is
1139 * rendered. This is batched up asynchronously to happen once per
1140 * "pulse", or frame of animation.
1141 * <p>
1142 * If this parent is either a layout root or unmanaged, then it will be
1143 * added directly to the scene's dirty layout list, otherwise requestLayout
1144 * will be invoked on its parent.
1145 */
1146 @Override public void requestLayout() {
1147 prefWidthCache = -1;
1148 prefHeightCache = -1;
1149 minWidthCache = -1;
1150 minHeightCache = -1;
1151 maxWidthCache = -1;
1152 maxHeightCache = -1;
1153 //skinSizeComputed = false; -- RT-33073 disabled this
1154 super.requestLayout();
1155 }
1156
1157 /**
1158 * This method should be treated as final and should not be overridden by any subclasses of CSSBridge.
1159 * @return the styleable parent
1160 */
1161 @Override
1162 public Styleable getStyleableParent() {
1163 return PopupControl.this.getStyleableParent();
1164 }
1165
1166 @Override
1167 public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
1168 return PopupControl.this.getCssMetaData();
1169 }
1170
1171 /*
1172 * Note: This method MUST only be called via its accessor method.
1173 */
1174 private List<String> doGetAllParentStylesheets() {
1175 Styleable styleable = getStyleableParent();
1176 if (styleable instanceof Parent) {
1177 return ParentHelper.getAllParentStylesheets((Parent)styleable);
1178 }
1179 return null;
|