Search in sources :

Example 6 with ScrollPane

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

the class ScrollPaneSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    ScrollPane scrollPane = (ScrollPane) component;
    scrollPane.getViewportListeners().add(this);
    scrollPane.getScrollPaneListeners().add(this);
    scrollPane.add(horizontalScrollBar);
    scrollPane.add(verticalScrollBar);
    scrollPane.add(topLeftCorner);
    scrollPane.add(bottomLeftCorner);
    scrollPane.add(bottomRightCorner);
    scrollPane.add(topRightCorner);
    horizontalScrollBar.getScrollBarValueListeners().add(this);
    verticalScrollBar.getScrollBarValueListeners().add(this);
}
Also used : ScrollPane(org.apache.pivot.wtk.ScrollPane)

Example 7 with ScrollPane

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

the class ScrollPaneSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    ScrollPane scrollPane = (ScrollPane) getComponent();
    int preferredWidth = 0;
    int preferredHeight = 0;
    Component view = scrollPane.getView();
    if (view != null) {
        Dimensions preferredViewSize = view.getPreferredSize();
        preferredWidth += preferredViewSize.width;
        preferredHeight += preferredViewSize.height;
        Component rowHeader = scrollPane.getRowHeader();
        if (rowHeader != null) {
            preferredWidth += rowHeader.getPreferredWidth(-1);
        }
        Component columnHeader = scrollPane.getColumnHeader();
        if (columnHeader != null) {
            preferredHeight += columnHeader.getPreferredHeight(-1);
        }
        if (scrollPane.getHorizontalScrollBarPolicy() == ScrollBarPolicy.ALWAYS) {
            preferredHeight += horizontalScrollBar.getPreferredHeight(-1);
        }
        if (scrollPane.getVerticalScrollBarPolicy() == ScrollBarPolicy.ALWAYS) {
            preferredWidth += verticalScrollBar.getPreferredWidth(-1);
        }
    }
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : ScrollPane(org.apache.pivot.wtk.ScrollPane) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) Paint(java.awt.Paint)

Example 8 with ScrollPane

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

the class ScrollPaneSkin method getViewportBounds.

// Viewport.Skin methods
@Override
public Bounds getViewportBounds() {
    int x = 0;
    int y = 0;
    int width = getWidth();
    int height = getHeight();
    ScrollPane scrollPane = (ScrollPane) getComponent();
    Component rowHeader = scrollPane.getRowHeader();
    if (rowHeader != null) {
        int rowHeaderWidth = rowHeader.getWidth();
        x += rowHeaderWidth;
        width -= rowHeaderWidth;
    }
    Component columnHeader = scrollPane.getColumnHeader();
    if (columnHeader != null) {
        int columnHeaderHeight = columnHeader.getHeight();
        y += columnHeaderHeight;
        height -= columnHeaderHeight;
    }
    if (horizontalScrollBar.isVisible()) {
        height -= horizontalScrollBar.getHeight();
    }
    if (verticalScrollBar.isVisible()) {
        width -= verticalScrollBar.getWidth();
    }
    return new Bounds(x, y, width, height);
}
Also used : ScrollPane(org.apache.pivot.wtk.ScrollPane) Bounds(org.apache.pivot.wtk.Bounds) Component(org.apache.pivot.wtk.Component) Paint(java.awt.Paint)

Example 9 with ScrollPane

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

the class ScrollPaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    ScrollPane scrollPane = (ScrollPane) getComponent();
    Component view = scrollPane.getView();
    Component rowHeader = scrollPane.getRowHeader();
    Component columnHeader = scrollPane.getColumnHeader();
    int baseline = -1;
    int clientWidth = width;
    int clientHeight = height;
    int rowHeaderWidth = 0;
    if (rowHeader != null) {
        rowHeaderWidth = rowHeader.getPreferredWidth(-1);
        clientWidth -= rowHeaderWidth;
    }
    int columnHeaderHeight = 0;
    if (columnHeader != null) {
        columnHeaderHeight = columnHeader.getPreferredHeight(-1);
        clientHeight -= columnHeaderHeight;
        baseline = columnHeader.getBaseline(clientWidth, columnHeaderHeight);
    }
    if (baseline == -1 && rowHeader != null) {
        baseline = rowHeader.getBaseline(rowHeaderWidth, clientHeight);
        if (baseline != -1) {
            baseline += columnHeaderHeight;
        }
    }
    if (baseline == -1 && view != null) {
        baseline = view.getBaseline(clientWidth, clientHeight);
        if (baseline != -1) {
            baseline += columnHeaderHeight;
        }
    }
    return baseline;
}
Also used : ScrollPane(org.apache.pivot.wtk.ScrollPane) Component(org.apache.pivot.wtk.Component) Paint(java.awt.Paint)

Example 10 with ScrollPane

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

the class TableViewRowEditor method beginEdit.

@Override
public void beginEdit(TableView tableViewArgument, int rowIndexArgument, int columnIndexArgument) {
    this.tableView = tableViewArgument;
    this.rowIndex = rowIndexArgument;
    this.columnIndex = columnIndexArgument;
    Container tableViewParent = tableViewArgument.getParent();
    tableViewScrollPane = (tableViewParent instanceof ScrollPane) ? (ScrollPane) tableViewParent : null;
    // Add/create the editor components
    TableView.ColumnSequence tableViewColumns = tableViewArgument.getColumns();
    TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();
    for (int i = 0, n = tableViewColumns.getLength(); i < n; i++) {
        // Add a new column to the table pane to match the table view column
        TablePane.Column tablePaneColumn = new TablePane.Column();
        tablePaneColumn.setWidth(tableViewArgument.getColumnBounds(i).width);
        tablePaneColumns.add(tablePaneColumn);
        // Determine which component to use as the editor for this column
        String columnName = tableViewColumns.get(i).getName();
        Component editorComponent = null;
        if (columnName != null) {
            editorComponent = cellEditors.get(columnName);
        }
        // Default to a read-only text input editor
        if (editorComponent == null) {
            TextInput editorTextInput = new TextInput();
            editorTextInput.setTextKey(columnName);
            editorTextInput.setEnabled(false);
            editorTextInput.setTextBindType(BindType.LOAD);
            editorComponent = editorTextInput;
        }
        // Add the editor component to the table pane
        editorRow.add(editorComponent);
    }
    // Get the data being edited
    List<?> tableData = tableViewArgument.getTableData();
    Object tableRow = tableData.get(rowIndexArgument);
    // Load the row data into the editor components
    tablePane.load(tableRow);
    // Get the row bounds
    Bounds rowBounds = tableViewArgument.getRowBounds(rowIndexArgument);
    rowImage.bounds = rowBounds;
    // Scroll to make the row as visible as possible
    tableViewArgument.scrollAreaToVisible(rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
    // Constrain the bounds by what is visible through viewport ancestors
    rowBounds = tableViewArgument.getVisibleArea(rowBounds);
    Point location = tableViewArgument.mapPointToAncestor(tableViewArgument.getDisplay(), rowBounds.x, rowBounds.y);
    // Set size and location and match scroll left
    setPreferredWidth(rowBounds.width);
    setLocation(location.x, location.y + (rowBounds.height - getPreferredHeight(-1)) / 2);
    if (tableViewScrollPane != null) {
        scrollPane.setScrollLeft(tableViewScrollPane.getScrollLeft());
    }
    // Open the editor
    open(tableViewArgument.getWindow());
    // Start the transition
    cardPane.setSelectedIndex(EDITOR_CARD_INDEX);
}
Also used : Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) Point(org.apache.pivot.wtk.Point) Container(org.apache.pivot.wtk.Container) ScrollPane(org.apache.pivot.wtk.ScrollPane) Component(org.apache.pivot.wtk.Component) TextInput(org.apache.pivot.wtk.TextInput) TableView(org.apache.pivot.wtk.TableView) TablePane(org.apache.pivot.wtk.TablePane)

Aggregations

ScrollPane (org.apache.pivot.wtk.ScrollPane)18 Paint (java.awt.Paint)14 Component (org.apache.pivot.wtk.Component)14 Bounds (org.apache.pivot.wtk.Bounds)4 Dimensions (org.apache.pivot.wtk.Dimensions)4 ScrollBarPolicy (org.apache.pivot.wtk.ScrollPane.ScrollBarPolicy)3 Graphics2D (java.awt.Graphics2D)2 TextInput (org.apache.pivot.wtk.TextInput)2 Color (java.awt.Color)1 ArrayList (org.apache.pivot.collections.ArrayList)1 ApplicationContext (org.apache.pivot.wtk.ApplicationContext)1 BoxPane (org.apache.pivot.wtk.BoxPane)1 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)1 Container (org.apache.pivot.wtk.Container)1 DesktopApplicationContext (org.apache.pivot.wtk.DesktopApplicationContext)1 Frame (org.apache.pivot.wtk.Frame)1 Label (org.apache.pivot.wtk.Label)1 ListView (org.apache.pivot.wtk.ListView)1 ListViewSelectionListener (org.apache.pivot.wtk.ListViewSelectionListener)1 Mouse (org.apache.pivot.wtk.Mouse)1