History log of /haiku/src/kits/interface/TextInput.cpp
Revision Date Author Comments
# d9385a9d 20-Jul-2020 John Scipione <jscipione@gmail.com>

IK: align BTextView text rect/fix alignment

Recalculate line breaks in FrameResized() if word-wrap is on, otherwise
only move the text rect into position. StyledEdit was recalculating line
breaks before on resize (we have to in this mode) and the frame offset
updates for non-wrapping text views are inexpensive. This makes resizing
text view's work like StyledEdit everywhere.

Scroll to cursor when word-wrap setting changes if text view is editable.
If you are viewing a long document changing word-wrap can move the cursor
quite far, so scroll back to it.

Fix _ActualTabWidth() pen location for right and center-aligned text views
so that tabs widths are calculated correctly.

Reset fTextRect horizontal limits to bounds minus insets in
_RecalculateLineBreaks(), then grow fTextRect based on alignment when
wrap is off.

Fixing insets also fixes right and center-aligned BTextViews.
Left-aligned text view's grow right, right-aligned ones grow left,
and center-aligned ones grow out.

Make extra scrolling space for all aligned text views go the other way
from how it did in hrev24130 (and on left-aligned text view's too) so
that half the text is visible when you edit past the end or before the
beginnning of a text view instead of none of it.

Fixes #1651 #12608 #13796 #15189

Do not _RecalculateLineBreaks() if text view bounds are invalid.
In SetText() detect invalid text view bounds and resize the view to the
width and height of the first line. Then recalculate line breaks.
This fixes BAlert text view size issues.

Fixes #16481 (regression from hrev54496.)

Remove useless and heavy computation. There is no point in computing line
breaks for a 10px wide text view and it takes a long time because it needs
a lot of linebreaks. The view eventually gets laid out properly.

Fixes #5582 (which was not locale-related, after all.)

Only apply default insets if text rect is set to bounds. This ensures
that apps that manipulate the text rect can continue to do so without
the default insets interfering while apps that don't can benefit
from the defaults. If you want to set the text rect to bounds and
not use the default insets you must override the default by calling
SetInsets(). This prevent the default insets from being applied once
apps have changed the text rect fixing a bug in Icon-O-Matic where the
text rect insets were being applied incorrectly.

Fixes #16488 (regression from hrev54496.)

Reduce left and right insets inside text views from full label spacing
to half label spacing. Unify padding between BTextControl and BTextView.

Move fLayoutData->UpdateInsets() to private BTextView::_UpdateInsets()
because we need access to BTextView member variables when deciding
whether or not to add the default padding or not.

_UpdateInsets() changes:
* Don't update insets if BTextView::SetInsets() was called.
* Don't add default insets unless fTextRect is set to view Bounds().
* Do not set the right and bottom insets to left and top if negative,
set them to 0 like we do to left and top -- DeskCalc bug otherwise.

Fixes #15688

Other BTextView fixes:
* Replace max_c and min_c with std::max and std::min respectively.
* Remove scrolling from one instance of BTextView::SetText() as it
produced undesired results while editing a scrolled text view.
* Add default insets in _UpdateInsets()
* Fix scrolling when entering and deleting text so that some part of
the text is always visible. Make visible scroll width depend on font
size.
* Allow scrolling to a negative offset in x but not y. This allows you
to scroll the entire contents of right and centered-aligned text views
whose content does not fit in the box.
* Change _Refresh() to take an offset instead of a bool so that you can
scroll to any offset.
* Replace TextLength() with fText->Length() in a couple of places.

TextControl changes:
* Set text rect in BTextControl::DoLayout().
* Remove AlignTextRect() from TextInput.

Fix the following problems in apps:

ScreenSaver: Set text rect in PreviewView::AddPreview().
Tracker: Set "Edit name" text view insets to 2. Tweek text rect position
to be on top of label in icon, mini-icon, and list mode. Add a TODO that
the text rect is a pixel off from the name on some files.
Mail: Remove _AlignTextRect() and FrameResized() from AddressTextControl.
Use default insets on the text view, defaults are fine here.
DeskCalc: Set insets based on font size in ExpressionTextView
SetTextRect() instead of manipulating the text rect.
Remove _CheckTextRect() and related methods from InputTextView.
Icon-O-Matic: Remove _CheckTextRect() and related methods from InputTextView.
WebPositive: Remove _AlignTextRect() and FrameResized() from URLTextView
and call SetInsets().
StyledEdit: Word-wrap and FrameResized() changes ported to BTextView.

Fixes #16476 #16480 #16488 (regressions from hrev54496.)

Change-Id: Ifeca6077f8815ccd86d5a3880f99556298aaf0fe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3152
Reviewed-by: John Scipione <jscipione@gmail.com>


# 22758f16 17-Aug-2020 John Scipione <jscipione@gmail.com>

Revert "IK: align BTextView text rect/fix alignment"

This reverts commit a9b301871d06c0ebe42d22b31c685abed5107acd.

hrev54496

Change-Id: Ife3c834ad98d330f04976d9adf3b1553e7aca034
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3153
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# a9b30187 20-Jul-2020 John Scipione <jscipione@gmail.com>

IK: align BTextView text rect/fix alignment

Preserve passed in text rect in fTextRext (unless in layout)
and create an internal version fAlignedTextRect which is used
in place of fTextRect. fAlignedTextRext is aligned to fit the
text rect bounds and grows to fit. fAlignedTextRect always grows
vertically but only grows horizontally if wrap is off.

Left-aligned text view's grow right, right-aligned ones grow left,
and center center aligned ones grow out.

Set fTextRect to bounds in _DoLayout().

Reduce left and right padding inside text views from full label
spacing to half label spacing. Unify padding between BTextControl
and BTextView.

Fixing padding also fixes right and center-aligned BTextViews.

Undo extra scrolling for non-left text views from hrev24130 fixing
a scrolling left and right with mouse bug when it shouldn't.

Replace max_c and min_c with std::max and std::min respectively.

Remove scrolling from one instance of BTextView::SetText as it
produced undesired results while editing a scrolled text view.

Set text rect in BTextControl::DoLayout() and ScreenSaver
PreviewView::AddPreview().

Don't add padding if BTextView::SetInsets() is called. Set insets
to 0 in Tracker "Edit name" setting which prevents default padding
from being added. This is so that when you rename a file in Tracker
the TextView appears on top of the file name text with no padding.

80 char limit fixes.

Fixes #1651 #12608 #13796 #15189 #15688

Change-Id: I8c6106effc612f49aff374f29742471628b5df86
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3054
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 1c9c7729 12-Jan-2020 X512 <danger_mail@list.ru>

Interface Kit: make BTextControl behave like BeOS

Contents of BTextControl should be not selected if text is directly clicked.
Selection should be removed if BTextView lose focus.

Change-Id: Ifba914c2ada4fc1aac88205f69a64a4356009469
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2109
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3c42c902 18-Jul-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert changes to BTextInput's text-rect calculation.

This reverts commit 11dee0444f911abba5555d3be056fb64f1f5eea4.
This reverts commit 1641a0516d9e8228a0189a83a688532d6554d271.
This reverts commit 484f64f315680eae5dcf5ad8b74325c3debc6da9.

These changes break various edge-cases in BTextInput (e.g. typing off the end
of a long string, using the arrow keys to navigate while out-of-bounds),
and nobody has found any fixes for them in the nearly-a-year since they've
been instanted, so they are now being reverted.

Reopens #12608, #13796.


# 484f64f3 23-Nov-2017 hyche <cvghy116@gmail.com>

TextInput: Align the text when typing or removing.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Closes #13796.


# 1641a051 23-Nov-2017 hyche <cvghy116@gmail.com>

Fix aligning when text growing more than the right bound..

because the bound scrolls to the current cursor to view the text (ScrollToOffset).
Follow up #12608

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>


# 11dee044 23-Nov-2017 hyche <cvghy116@gmail.com>

TextInput: Fix text width

Thanks PulkoMandy for teaching me how to use Debugger and part of the interface kit..
Fixes #12608

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Thanks for investigating and finding the problem!


# bfbb9655 10-Sep-2017 Augustin Cavalier <waddlesplash@gmail.com>

Interface Kit: Remove more non-BControlLook code.


# 06cdb655 16-Mar-2015 Axel Dörfler <axeld@pinc-software.de>

_BTextInput_: Only invalidate parent when in a window.

* Otherwise there is nothing to it.
* Removed comment and commented out invalidation. Seems to work
just fine without it, and I cannot think of a reason why it should
be there.


# ccc3ced2 16-Mar-2015 Axel Dörfler <axeld@pinc-software.de>

_BTextInput_: style cleanup.


# 4cec648e 04-Dec-2014 Laurent Chea <contact@laurentchea.com>

Fix alignment in TextControl widgets

* Fixes #8391
preferences.

Signed-off-by: Adrien Destugues <pulkomandy@gmail.com>

* This was visible for example in the "double click text area" in Mouse


# 57c5b09e 05-Aug-2012 Ryan Leavengood <leavengood@gmail.com>

Use be_control_look != NULL everywhere in the Interface Kit.

Should not be a functional change. It is not in the Haiku Coding Guidelines but
I feel like 'if (object != NULL)' is generally preferred to 'if (object)', plus
in this case of be_control_look that is the more common style.


# 846cb932 12-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

Fix my strlcpy() adventure with a much simpler version of the code that should
also perform better for the usual case of inserting one char at a time. Using
strpbrk() on non-terminated strings was probably also not too healthy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36187 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a68045b3 12-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

strlcpy() takes buffer size and will copy buffer size - 1 chars at max and then
use the remaining byte to terminate the buffer. Thanks for the heads up!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36185 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 954af586 11-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

Bug found by mmlr, since the "inText" is not terminated, strcpy could overwrite
a random amount of memory of the allocated "buffer". If it were terminated, it
would overwrite one byte, since it will also terminate the destination buffer,
which didn't contain the necessary room. Use strlcpy() instead and provide
enough room.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 82d9f508 08-Apr-2009 Stephan Aßmus <superstippi@gmx.de>

Some BTextView fixes, most importantly the annoying up/down ping pong when
triggering auto-scrolling in BTextControls...
* _BTextInput_::MinSize() added 1 to the line height, but when aligning the
text rect, at least one pixel is added at the top and bottom, which makes
for at least two extra pixels.
* BTextView::_PerformAutoScrolling() had some code which was supposed to
prevent from out-of-bounds scrolling, but the bottom maximum coordinate
was not correctly calculated. This and the above item led to the ping-pong
effect.
* Additionally, I prevented scrolling vertically for one-line text views
completely.
* On mouse-up, reset the cursor. It may have to be the I-Beam cursor again,
for example after de-selecting.
* While mouse tracking the selection, always use the I-Beam cursor.
* Also when mouse tracking, do not use the minimum/maximum text offset when
the mouse is above/below the text rect. Do this only when it's also outside
on left/right sides. This is less irritating and works like on other
platforms. It means the first/last line can still be selected, without
having to constrain the mouse to the inside of the text view.
* When calculating the selection region, don't make the bottom one pixel too
far up. Lines which contain glyphs that extend below the base-line have
one more pixel below the glyphs that is inverted now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f86ba45 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented a new look for the Haiku interface controls. It was
overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 349c911e 16-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Implemented a lot of layout related methods and resolved a few TODOs by
doing a lot of these things the same way as BMenuField are already doing.
Perhaps a private helper class could be refactored from these two controls
to avoid duplicating a lot of this code, although there are a few subtle
differences here and there.

These changes make a BTextControl behave properly in the layout management
frame work, in case CreateLabelLayoutItem() and CreateTextViewLayoutItem()
are _not_ used to layout the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991c062f 24-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the archive version of BTextControl::_InitData() more resistant against
a broken archive - it will now create a new _BTextInput_ child, if it couldn't
find one. This fixes #2086.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25123 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ea5b1e 25-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

Further improvements to auto scrolling and text rect + container view resizing:
* Renaming things in Tracker list mode no longer magically grows the text view.
* ScrollToOffset() is not supposed to depend on the existence of any scroll
bars, in R5 text views simply scroll to where they need to. This fixes
renaming things in Tracker when hitting the window bounds (text widget stops
growing and starts to autoscroll) and also the Text tool in WonderBrush.
* _ScrollToOffset() is therefor no longer needed.
* The insets of the text rect are not so interesting as the original width.
In auto resizing mode, the original width is important when there is no
container view. In this setup, the text rect auto resizing is mainly needed
for auto scrolling, but it should never shrink below the original size.
* Further improved auto scrolling for right aligned and center aligned text
views, it works like R5 now. Also take the line height into account when
checking for the bounds bottom. Removed extra spacing for vertical
scrolling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24130 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8872c02 24-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

BTextControl:
* Placed _BTextInput_ into BPrivate namespace.
* Made _BTextInput_::AlignTextRect() smarter, it centers the line vertically,
for the case that the BTextControl has a larger label font. Improved insets
for asthetics.
* Used _BTextInput_::AlignTextRect() consistently in BTextControl, no more
custom calls to SetTextRect(). Account for minimum vertical inset of 2
pixels in GetPreferredSize().
* Consistendly select all text when gaining focus in _BTextInput_.
* Override MouseDown() in case the control did not have focus before, or else
BTextView::MouseDown() will deselct the text again and place the cursor.
(in line with BeOS behavior)
* Removed unused fBool member from _BTextInput_ and other cleanup.

BTextView:
* Reimplemented BTextView::_AutoResize() so that it works well with
BTextControl and autoscrolling when the alignment is not B_ALIGN_LEFT.
I needed two new members for this, fLeftInset and fRightInset which are
the original insets from the fTextRects. It might currently be broken
for renaming things in Tracker, I will have to check. _AutoResize() no
longer messes up the fTextRect insets.
* Fixed stray carrets sometimes being left over, mostly when auto scrolling,
but I observed them in other cases as well.
* Prevent negative scrolling offsets when autoscrolling. Fixes weird scrolling
offsets when navigating to the left.
* Reset scrolling to B_ORIGIN when SetText() is called. Fixes for example
starting to type in the middle of the control in Vision when entering new
text and autoscrolling was triggered before.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2476bcc 04-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Rene Gollent: TextViews now can scroll even if they aren't
attached to a BScrollView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a431f44b 31-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* make the text view layouting more robust, draw the frame around the
text view, ignore the divider for this (application code could layout
the textview itself, and fDivider might not be maintained)
* change Draw() and TextInput::MakeFocus() accordingly

this fixes the weird placement of text controls in Beam


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22134 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fab61b62 18-Jun-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved TextInput.h to src/kits/interface as it's only used there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c5ab65d 21-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* fPreviousText can be NULL for views that don't have focus (ie. by using SetEventMask()).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 437fc0be 14-Nov-2005 Stephan Aßmus <superstippi@gmx.de>

invalidate the parent where the blue focus indication actually belongs, completes Axels recent changes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14931 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 105644bf 12-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* the text rect of the inner text view is now the same size as its bounds;
that's simplifies resizing and moving a lot (it's now working correctly).
* the inner text view is now only navigable if the text control should have
been navigable.
* default text view inset is now (3, 3) - but this might be adapted by the
total size of the control.
* the height of the control now takes the label into account - it may differ
from the height of the text line.
* instead of computing the size again, the BTextControl constructor now
just uses its GetPreferredSize().
* the label position now depends on the position of the text view.
* the inner text view is now centered vertically inside the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ad6b4804 16-May-2005 Stephan Aßmus <superstippi@gmx.de>

Work in Progress. The server keeps the client window up to date on layer movement/resizing. This fixes quite a few problems and brings support for FrameMoved and Resized hooks. But implementing it this way has its own set of problem, most importantly: When a BView calles Window()->CurrentMessage() in its FrameMoved/Resized hooks, it will see something very different from what it would see in R5. This needs to be fixed, but I have not had a good idea how to do this other than faking the current message in BWindow, which I didn't look into.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d8d6cad 15-May-2005 Stephan Aßmus <superstippi@gmx.de>

Work in progress to improve BTextView and BTextControl. I don't know what _BTextInput_::AlignTextRect() was thought to do. Some of the fixes are Haiku specific and we need to make sure that we don't need them later on (flushing drawing commands).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12685 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 99a5b57a 18-Oct-2004 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Style and license fixes, added Marc Flerackers to the authors list.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9392 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf43596 19-Jun-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Added missing includes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3580 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cb2dbe2 16-Jun-2003 Marc Flerackers <mflerackers@nowhere.fake>

Fixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 06cdb6558fe3a25e4e4034839f1b845f9bb41e24 16-Mar-2015 Axel Dörfler <axeld@pinc-software.de>

_BTextInput_: Only invalidate parent when in a window.

* Otherwise there is nothing to it.
* Removed comment and commented out invalidation. Seems to work
just fine without it, and I cannot think of a reason why it should
be there.


# ccc3ced21ccf62a140f49bc07d2c5309d170437e 16-Mar-2015 Axel Dörfler <axeld@pinc-software.de>

_BTextInput_: style cleanup.


# 4cec648e86c78dd4c93ab2ec0cc811dd8f63a301 04-Dec-2014 Laurent Chea <contact@laurentchea.com>

Fix alignment in TextControl widgets

* Fixes #8391
preferences.

Signed-off-by: Adrien Destugues <pulkomandy@gmail.com>

* This was visible for example in the "double click text area" in Mouse


# 57c5b09e1a3d0f36f94cbab11c96842d782b8eaf 05-Aug-2012 Ryan Leavengood <leavengood@gmail.com>

Use be_control_look != NULL everywhere in the Interface Kit.

Should not be a functional change. It is not in the Haiku Coding Guidelines but
I feel like 'if (object != NULL)' is generally preferred to 'if (object)', plus
in this case of be_control_look that is the more common style.


# 846cb93278fc9f1ed8c34b4b8fa954cb82614f46 12-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

Fix my strlcpy() adventure with a much simpler version of the code that should
also perform better for the usual case of inserting one char at a time. Using
strpbrk() on non-terminated strings was probably also not too healthy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36187 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a68045b3675b435a40b1cf1122bb1ed6638ca5ef 12-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

strlcpy() takes buffer size and will copy buffer size - 1 chars at max and then
use the remaining byte to terminate the buffer. Thanks for the heads up!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36185 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 954af58694a58f74c861e276ca8b76b0836ac4f4 11-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

Bug found by mmlr, since the "inText" is not terminated, strcpy could overwrite
a random amount of memory of the allocated "buffer". If it were terminated, it
would overwrite one byte, since it will also terminate the destination buffer,
which didn't contain the necessary room. Use strlcpy() instead and provide
enough room.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 82d9f508418d3d622861afc797967daf4f986267 08-Apr-2009 Stephan Aßmus <superstippi@gmx.de>

Some BTextView fixes, most importantly the annoying up/down ping pong when
triggering auto-scrolling in BTextControls...
* _BTextInput_::MinSize() added 1 to the line height, but when aligning the
text rect, at least one pixel is added at the top and bottom, which makes
for at least two extra pixels.
* BTextView::_PerformAutoScrolling() had some code which was supposed to
prevent from out-of-bounds scrolling, but the bottom maximum coordinate
was not correctly calculated. This and the above item led to the ping-pong
effect.
* Additionally, I prevented scrolling vertically for one-line text views
completely.
* On mouse-up, reset the cursor. It may have to be the I-Beam cursor again,
for example after de-selecting.
* While mouse tracking the selection, always use the I-Beam cursor.
* Also when mouse tracking, do not use the minimum/maximum text offset when
the mouse is above/below the text rect. Do this only when it's also outside
on left/right sides. This is less irritating and works like on other
platforms. It means the first/last line can still be selected, without
having to constrain the mouse to the inside of the text view.
* When calculating the selection region, don't make the bottom one pixel too
far up. Lines which contain glyphs that extend below the base-line have
one more pixel below the glyphs that is inverted now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30046 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f86ba45579bdc9648b232175f87edc62ab71b54 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented a new look for the Haiku interface controls. It was
overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 349c911ee9194e4f25c31267a6464f5399c71e59 16-Sep-2008 Stephan Aßmus <superstippi@gmx.de>

* Implemented a lot of layout related methods and resolved a few TODOs by
doing a lot of these things the same way as BMenuField are already doing.
Perhaps a private helper class could be refactored from these two controls
to avoid duplicating a lot of this code, although there are a few subtle
differences here and there.

These changes make a BTextControl behave properly in the layout management
frame work, in case CreateLabelLayoutItem() and CreateTextViewLayoutItem()
are _not_ used to layout the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27584 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991c062ff3d344abc28963281fe2a2f4d0543262 24-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the archive version of BTextControl::_InitData() more resistant against
a broken archive - it will now create a new _BTextInput_ child, if it couldn't
find one. This fixes #2086.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25123 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ea5b1e49005fa48c79898fb3ad9f8f28476b52 25-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

Further improvements to auto scrolling and text rect + container view resizing:
* Renaming things in Tracker list mode no longer magically grows the text view.
* ScrollToOffset() is not supposed to depend on the existence of any scroll
bars, in R5 text views simply scroll to where they need to. This fixes
renaming things in Tracker when hitting the window bounds (text widget stops
growing and starts to autoscroll) and also the Text tool in WonderBrush.
* _ScrollToOffset() is therefor no longer needed.
* The insets of the text rect are not so interesting as the original width.
In auto resizing mode, the original width is important when there is no
container view. In this setup, the text rect auto resizing is mainly needed
for auto scrolling, but it should never shrink below the original size.
* Further improved auto scrolling for right aligned and center aligned text
views, it works like R5 now. Also take the line height into account when
checking for the bounds bottom. Removed extra spacing for vertical
scrolling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24130 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b8872c02c1d02d892037bcdb6cbbb3dfe482b98b 24-Feb-2008 Stephan Aßmus <superstippi@gmx.de>

BTextControl:
* Placed _BTextInput_ into BPrivate namespace.
* Made _BTextInput_::AlignTextRect() smarter, it centers the line vertically,
for the case that the BTextControl has a larger label font. Improved insets
for asthetics.
* Used _BTextInput_::AlignTextRect() consistently in BTextControl, no more
custom calls to SetTextRect(). Account for minimum vertical inset of 2
pixels in GetPreferredSize().
* Consistendly select all text when gaining focus in _BTextInput_.
* Override MouseDown() in case the control did not have focus before, or else
BTextView::MouseDown() will deselct the text again and place the cursor.
(in line with BeOS behavior)
* Removed unused fBool member from _BTextInput_ and other cleanup.

BTextView:
* Reimplemented BTextView::_AutoResize() so that it works well with
BTextControl and autoscrolling when the alignment is not B_ALIGN_LEFT.
I needed two new members for this, fLeftInset and fRightInset which are
the original insets from the fTextRects. It might currently be broken
for renaming things in Tracker, I will have to check. _AutoResize() no
longer messes up the fTextRect insets.
* Fixed stray carrets sometimes being left over, mostly when auto scrolling,
but I observed them in other cases as well.
* Prevent negative scrolling offsets when autoscrolling. Fixes weird scrolling
offsets when navigating to the left.
* Reset scrolling to B_ORIGIN when SetText() is called. Fixes for example
starting to type in the middle of the control in Vision when entering new
text and autoscrolling was triggered before.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2476bcc9c193632711781727a96a3222ee1df05 04-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Rene Gollent: TextViews now can scroll even if they aren't
attached to a BScrollView.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a431f44be88d3d0f1748a1fe032c1159dab8d11c 31-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* make the text view layouting more robust, draw the frame around the
text view, ignore the divider for this (application code could layout
the textview itself, and fDivider might not be maintained)
* change Draw() and TextInput::MakeFocus() accordingly

this fixes the weird placement of text controls in Beam


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22134 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fab61b623760b244cdc3f2cfade7f214ad8e2f71 18-Jun-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved TextInput.h to src/kits/interface as it's only used there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c5ab65d239825faca32830acde9664b224954ae 21-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* fPreviousText can be NULL for views that don't have focus (ie. by using SetEventMask()).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 437fc0be3f704636f6e9624a19860cfce1855ee6 14-Nov-2005 Stephan Aßmus <superstippi@gmx.de>

invalidate the parent where the blue focus indication actually belongs, completes Axels recent changes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14931 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 105644bf32c7aaca865b4624e413e4b864dd0c21 12-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* the text rect of the inner text view is now the same size as its bounds;
that's simplifies resizing and moving a lot (it's now working correctly).
* the inner text view is now only navigable if the text control should have
been navigable.
* default text view inset is now (3, 3) - but this might be adapted by the
total size of the control.
* the height of the control now takes the label into account - it may differ
from the height of the text line.
* instead of computing the size again, the BTextControl constructor now
just uses its GetPreferredSize().
* the label position now depends on the position of the text view.
* the inner text view is now centered vertically inside the BTextControl.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ad6b480400e921f46a444359fc92be5251ab6ac4 16-May-2005 Stephan Aßmus <superstippi@gmx.de>

Work in Progress. The server keeps the client window up to date on layer movement/resizing. This fixes quite a few problems and brings support for FrameMoved and Resized hooks. But implementing it this way has its own set of problem, most importantly: When a BView calles Window()->CurrentMessage() in its FrameMoved/Resized hooks, it will see something very different from what it would see in R5. This needs to be fixed, but I have not had a good idea how to do this other than faking the current message in BWindow, which I didn't look into.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d8d6cad9da47bc0390985127aadc269e027880e 15-May-2005 Stephan Aßmus <superstippi@gmx.de>

Work in progress to improve BTextView and BTextControl. I don't know what _BTextInput_::AlignTextRect() was thought to do. Some of the fixes are Haiku specific and we need to make sure that we don't need them later on (flushing drawing commands).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12685 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 99a5b57a502cb6dd3d51973278eccf32426e6aef 18-Oct-2004 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Style and license fixes, added Marc Flerackers to the authors list.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9392 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf43596d6565bc1e03bdc68b053c75819d67ec9 19-Jun-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Added missing includes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3580 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cb2dbe29dbcf58bce0bd925316c77faafce43e0 16-Jun-2003 Marc Flerackers <mflerackers@nowhere.fake>

Fixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96