Skip to content

Commit

Permalink
PIVOT-340 :: Complete getBaseline() implementation for ScrollPaneSkin…
Browse files Browse the repository at this point in the history
… and TerraCalendarSkin

git-svn-id: https://svn.apache.org/repos/asf/incubator/pivot/trunk@880892 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Todd Volkert committed Nov 16, 2009
1 parent 163afbe commit 0b5391b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
44 changes: 37 additions & 7 deletions wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java
Expand Up @@ -309,17 +309,47 @@ public Dimensions getPreferredSize() {

@Override
public int getBaseline(int width, int height) {
int baseline = -1;

ScrollPane scrollPane = (ScrollPane)getComponent();

Component view = scrollPane.getView();
Component rowHeader = scrollPane.getRowHeader();
Component columnHeader = scrollPane.getColumnHeader();

// TODO Look for baseline in column header, then row header, then view
int baseline = -1;

// Delegate baseline calculation to the view component
if (view != null) {
// TODO Offset baseline by the expected view y-coordinate given width and height
baseline = view.getBaseline(width, height);
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;
Expand Down
Expand Up @@ -536,6 +536,11 @@ public Dimensions getPreferredSize() {
return calendarTablePane.getPreferredSize();
}

@Override
public int getBaseline(int width, int height) {
return calendarTablePane.getBaseline(width, height);
}

@Override
public void layout() {
calendarTablePane.setSize(getWidth(), getHeight());
Expand Down

0 comments on commit 0b5391b

Please sign in to comment.