Shiny Language Reference
Language Reference > User Interface > List Boxes
setlistboxtextrect
setlistboxtextrect(int ID, int X, int Y, int Width, int Height);
Sets a bounding rectangle for text
The SETLISTBOXTEXTRECT statement creates a bounding rectangle inside the list control within which all text is constrained. This statement is useful when using custom drawn list boxes. For example, if a custom drawn list box is made up of a PNG that has a 10 pixel rounded border, SETLISTBOXTEXTRECT can be used to ensure the list box text stays within the 10 pixel boundaries.
Note: Resizing the list box using setcontrolsize will cause it to discard any previously configured bounding rectangle. You must call SETLISTBOXTEXTRECT again with new (or repeating the previous) bounding information.
If you do not use custom-drawn list boxes and do not alter the scrollbar size, there is no need to call SETLISTBOXTEXTRECT. Brass automatically assigns a valid bounding rectangle for you.
Scrollbars will always be drawn over the list box text.
Parameters
ID
The control ID of the control you wish to change the style of
X
The top left X position from which rendering of the list box text will start. This is relative to the upper left corner of the list box.
Y
The top left Y position from which rendering of the list box text will start. This is relative to the upper left corner of the list box.
Width
The maximum width of visible text in the list box. All text will be visibly constrained to X + Width. This does not affect the text itself, only the display.
Height
The maximum height of visible text in the list box. All text will be visibly constrained to Y + Height. This does not affect the text itself, only the display. You are responsible for ensuring the specified height is compatible with the selected font (using setlistboxfont)
Return Value
None
Example Code
// Create the edit box X: 10, Y:10 and sized 200*120
int iListBoxID = createlistbox(1, 10, 10, 200, 120);
// Add 25 test items
for(int iTest = 0; iTest < 25; iTest++)
addlistboxitem(iListBoxID, "Test item " + iTest);
// Set the text to start at 1 pixel in from the left and
// one pixel down from the top, with a maximum width of
// 150 pixels and height of 100 pixels
setlistboxtextrect(iListBoxID, 1, 1, 150, 100);