Auto-Sizing Checkbox
Checkboxes (UWindowCheckbox) consist of a caption and a little fixed-sized box. Auto-sizing changes the width of the control without changing the location of the box. With this piece of code you can create checkboxes that have the box on the same side as the text alignment.
var bool bAutoSize; // adjust the size of the control to its Text's size function BeforePaint(Canvas C, float X, float Y) { local float TW, TH; if ( bAutoSize ) { if ( Text == "" ) { TW = 0; TH = 16; } else { if ( Align == TA_Left ) TextSize(C, Text $ " ", TW, TH); else if ( Align == TA_Right ) TextSize(C, " " $ Text, TW, TH); else TextSize(C, Text, TW, TH); TH = Max(TH, 16); } if ( Align == TA_Left ) WinLeft -= TW + TH - WinWidth; else if ( Align == TA_Center ) WinLeft -= (TW + TH - WinWidth) / 2; WinWidth = TW + TH; } Super.BeforePaint(C, X, Y); }
Notes:
- Align = TA_Center will look kind of strange with checkboxes.
- TA_Left means "Display text on the left", so use TA_Right to display box and text left-aligned with the auto-size feature.
Page Information
2022-11-18T15:58:34.810361Z
2002-08-27T15:48:38Z
Wormbo
*
https://wiki.beyondunreal.com/Legacy:Useful UWindow Extensions/Checkbox
Attribution-NonCommercial-ShareAlike 3.0