//---------------------------------------------------------------------- public KeyBox( Screen _screen, Keys _key ) : base(_screen) { mKey = _key; mFont = _screen.Style.MediumFont; mPadding = new Box( 15 ); UpdateContentSize(); }
//---------------------------------------------------------------------- public EditBox( Screen _screen, string _strText = "", Func<char,bool> _textEnteredHandler = null ) : base(_screen) { mstrText = _strText; mFont = _screen.Style.MediumFont; mPadding = new Box( 15 ); TextEnteredHandler = _textEnteredHandler; Frame = Screen.Style.EditBoxFrame; FrameCornerSize = Screen.Style.EditBoxCornerSize; UpdateContentSize(); }
//---------------------------------------------------------------------- public Label( Screen _screen, string _strText, Anchor _anchor, Color _color ) : base(_screen) { mstrText = _strText; mstrDisplayedText = mstrText; mFont = _screen.Style.MediumFont; mPadding = new Box( 10 ); mAnchor = _anchor; Color = _color; OutlineRadius = Screen.Style.BlurRadius; OutlineColor = _color * 0.5f; UpdateContentSize(); }
int ComputeCaretOffsetAtX( int _iX, string _strText, UIFont _font ) { // FIXME: This does many calls to Font.MeasureString // We should do a binary search instead! int iIndex = 0; float fPreviousX = 0f; while( iIndex < _strText.Length ) { iIndex++; float fX = _font.MeasureString( _strText.Substring( 0, iIndex ) ).X; if( fX > _iX ) { bool bAfter = ( fX - _iX ) < ( ( fX - fPreviousX ) / 2f ); return bAfter ? iIndex : ( iIndex - 1 ); } fPreviousX = fX; } return _strText.Length; }
//---------------------------------------------------------------------- public TextArea( Screen _screen ) : base( _screen ) { Font = Screen.Style.MediumFont; Text = ""; mbWrapTextNeeded = true; Caret = new TextCaret( this ); RemoteCaretsById = new Dictionary<UInt16,RemoteTextCaret>(); Padding = new Box(20); Scrollbar = new Scrollbar( _screen ); Scrollbar.Parent = this; PanelTex = Screen.Style.ListFrame; }