Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Changes to StyledText.setTopIndex

The specification of setTopIndex limits the top index to the number of 
lines minus the number of (fully) visible lines. This is valid unless no 
line is fully visible. In that case the spec implies that an input 
parameter of getLineCount() is valid. This is not true and would lead to 
errors under certain conditions.
The specification of StyledText setTopIndex(int) is going to change as 
follows.

"@param index new top index. Must be between 0 and getLineCount() - 
visible lines per page. An out of range index will be adjusted 
accordingly."

will change to:

"@param index new top index. Must be between 0 and getLineCount() -  fully 
visible lines per page. If no lines are fully visible the maximum value is 
getLineCount() - 1. An out of range index will be adjusted accordingly."

Note that, as indicated in the spec, the setTopIndex API does not throw an 
exception if the index is out of range. Instead, the index is adjusted to 
be within the valid range. This change will therefore not affect any callers of setTopIndex. 

The only potential effect of the change will be to callers of 
getTopIndex() for following scenario ==> Call setTopIndex with input parameter of getLineCount() while the widget 
height is less than the line height.  Then call getTopIndex and expect the 
returned top index to be getLineCount().  Note that, as soon as the widget 
height is increased, the top index is fixed by the widget to reflect the 
visual location of the scroll bar and the actual top line. The widget 
height is 0 if the widget has not been made visible yet after creation.

Knut  & Lynne


Back to the top