// GridView fragments:
// stuff that's being moved out of the way in order to simplify
// 5may99

// I belong in the WorkspaceGridView:
	
	// special (non-scrollable) row ID codes
	enum row_id_t {
		TOP_FIXED_ROW=-1,
		BOTTOM_FIXED_ROW=-2
	};

// ---------------------------------------------------------------- //
// IScrollTarget impl.
// ---------------------------------------------------------------- //

// used to pass horizontal scroll events to all cells in the
// subscribed column

class scroll_column_by { public:
	uint32 column;
	float xOffset;
	scroll_column_by(uint32 _column, float _xOffset) :
		column(_column), xOffset(_xOffset) {}
	void operator()(GridRow& row) {
		if(row.cellAt(column)) {
//			row.cellAt(column)->ScrollBy(xOffset, 0.0);
			row.cellAt(column)->ScrollTo(
				row.cellAt(column)->Bounds().left + xOffset, 0.0);
		}
	}
};

void GridView::handleScrollBy(float xDelta, float yDelta) {

//	D_PRINTF("handleScrollTo(%.1f,%.1f): %ld\n", xDelta, yDelta,
//		m_scrollTargetColumn);


	if(m_scrollTargetColumn >= 0) {
		// handle horizontal portion (hand off to any cell views in
		// the designated scroll-target column)
		for_each(
			m_rows.begin(),
			m_rows.end(),
			scroll_column_by(
				m_scrollTargetColumn,
				xDelta));
	} else {
		// no target column set?  scroll entire enclosing view
		ScrollBy(xDelta, yDelta);
	}
}


// from GridView::updateScrollLimits()
		if(m_scrollTargetColumn >= 0) {
			// fetch horizontal limits for target column
			float hMin = 0.0;
			float hMax = 0.0;
			getHScrollLimits(hMin, hMax);
			ASSERT(hMin <= hMax);
	
			m_pHScrollBar->SetRange(hMin, hMax);
			if(fDataWidth > (hMax-hMin))
				m_pHScrollBar->SetProportion((hMax-hMin)/fViewWidth);
		} else {



/*
// resize the given scrollable row (or all rows, if ganged)
// constrains the given height to sane limits

void GridView::updateRowSize(uint32 rowIndex, float fHeight) {

	TEST_LOCK();

	// doesn't support top/bottom-most rows yet +++++
	// 5may99 e.moon
	ASSERT(rowIndex >= 0);
	ASSERT(rowIndex < m_rows.size());

	// constrain by step size (round 'down', magnitude-wise)
	float fDelta = fHeight - m_rows[rowIndex].m_height;
	
	if(fDelta > 0)
		fDelta -= fmod(fDelta, m_fRowResizeStep);
	else if(fDelta < 0)
		fDelta += fmod(-fDelta, m_fRowResizeStep);
	
	fHeight = m_rows[rowIndex].m_height + fDelta;
	
	// constrain to min/max size
	if(fHeight < s_fMinRowHeight)
		fHeight = s_fMinRowHeight;
	else if(fHeight > s_fMaxRowHeight)
		fHeight = s_fMaxRowHeight;

	// apply
	row_vector::iterator it, itLast;
	if(m_layoutFlags & ROWS_RESIZE_IN_TANDEM) {
		// apply to all
		it = m_rows.begin();
		itLast = m_rows.end();
	}
	else {
		// apply to single row
		it = m_rows.begin() + rowIndex;
		itLast = it + 1;
	}
	
	for(it; it != itLast; it++) {
		float fDelta = fHeight - (*it).m_height;
		(*it).m_height += fDelta;
		(*it).m_fCellHeight += fDelta;

		// resize all cells in the view
		for(GridRow::cell_vector::iterator itC = (*it).m_cells.begin();
			itC != (*it).m_cells.end(); itC++) {
			if((*itC).pCell)
				(*itC).pCell->ResizeBy(0.0, fDelta);
		}

		// move grip, if any
		if((*it).m_pRowGrip)
			(*it).m_pRowGrip->MoveBy(0.0, fDelta);

		// move following views
		// +++++ not particularly efficient: 5may99 e.moon
		offsetRowViews((it+1) - m_rows.begin(), m_rows.size(), fDelta);
	}
	
	updateContainerBounds();
	updateScrollLimits();
}
*/
