use of org.apache.pivot.wtk.Component in project pivot by apache.
the class CardPaneSkin method getBaseline.
@Override
public int getBaseline(int width, int height) {
int baseline = -1;
if (sizeToSelection) {
CardPane cardPane = (CardPane) getComponent();
Component selectedCard = cardPane.getSelectedCard();
if (selectedCard != null) {
int cardWidth = Math.max(width - padding.getWidth(), 0);
int cardHeight = Math.max(height - padding.getHeight(), 0);
baseline = selectedCard.getBaseline(cardWidth, cardHeight);
if (baseline != -1) {
baseline += padding.top;
}
}
}
return baseline;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class CardPaneSkin method selectedIndexChanged.
@Override
public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) {
int selectedIndex = cardPane.getSelectedIndex();
if (selectedIndex != previousSelectedIndex) {
// This was not an indirect selection change
if (selectedIndex != -1) {
Component selectedCard = cardPane.get(selectedIndex);
selectedCard.setVisible(true);
}
if (previousSelectedIndex != -1) {
Component previousSelectedCard = cardPane.get(previousSelectedIndex);
previousSelectedCard.setVisible(false);
}
if (selectedIndex == -1 || previousSelectedIndex == -1 || sizeToSelection) {
invalidateComponent();
}
}
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class StackPaneSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
StackPane stackPane = (StackPane) getComponent();
for (Component component : stackPane) {
preferredHeight = Math.max(preferredHeight, component.getPreferredHeight(width));
}
preferredHeight += padding.getHeight();
return preferredHeight;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class StackPaneSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
StackPane stackPane = (StackPane) getComponent();
for (Component component : stackPane) {
preferredWidth = Math.max(preferredWidth, component.getPreferredWidth(height));
}
preferredWidth += padding.getWidth();
return preferredWidth;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class StackPaneSkin method layout.
@Override
public void layout() {
// Set the size of all components to match the size of the stack pane,
// minus padding
StackPane stackPane = (StackPane) getComponent();
int width = Math.max(getWidth() - padding.getWidth(), 0);
int height = Math.max(getHeight() - padding.getHeight(), 0);
for (Component component : stackPane) {
component.setLocation(padding.left, padding.top);
component.setSize(width, height);
}
}
Aggregations