Implemented AutoResize(), probably not completely correct. Removed duplicated code
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16483 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1006,47 +1006,13 @@ BTextView::Perform(perform_code d, void *arg)
|
|||||||
void
|
void
|
||||||
BTextView::SetText(const char *inText, const text_run_array *inRuns)
|
BTextView::SetText(const char *inText, const text_run_array *inRuns)
|
||||||
{
|
{
|
||||||
CALLED();
|
SetText(inText, inText ? strlen(inText) : 0, inRuns);
|
||||||
|
|
||||||
CancelInputMethod();
|
|
||||||
|
|
||||||
// hide the caret/unhilite the selection
|
|
||||||
if (fActive) {
|
|
||||||
if (fSelStart != fSelEnd)
|
|
||||||
Highlight(fSelStart, fSelEnd);
|
|
||||||
else {
|
|
||||||
if (fCaretVisible)
|
|
||||||
InvertCaret();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove data from buffer
|
|
||||||
if (fText->Length() > 0)
|
|
||||||
DeleteText(0, fText->Length()); // TODO: was fText->Length() - 1
|
|
||||||
|
|
||||||
int32 len = inText ? strlen(inText) : 0;
|
|
||||||
|
|
||||||
if (inText != NULL && len > 0)
|
|
||||||
InsertText(inText, len, 0, inRuns);
|
|
||||||
|
|
||||||
fClickOffset = fSelStart = fSelEnd = 0;
|
|
||||||
|
|
||||||
// recalc line breaks and draw the text
|
|
||||||
Refresh(0, len, true, true);
|
|
||||||
|
|
||||||
// draw the caret
|
|
||||||
if (fActive) {
|
|
||||||
if (!fCaretVisible)
|
|
||||||
InvertCaret();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::SetText(const char *inText, int32 inLength, const text_run_array *inRuns)
|
BTextView::SetText(const char *inText, int32 inLength, const text_run_array *inRuns)
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
|
|
||||||
CancelInputMethod();
|
CancelInputMethod();
|
||||||
|
|
||||||
// hide the caret/unhilite the selection
|
// hide the caret/unhilite the selection
|
||||||
@@ -2769,7 +2735,7 @@ BTextView::DeleteText(int32 fromOffset, int32 toOffset)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
// sanity checking
|
// sanity checking
|
||||||
if (fromOffset >= toOffset || fromOffset < 0 || toOffset < 0)
|
if (fromOffset >= toOffset || fromOffset < 0 || toOffset > fText->Length())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set nullStyle to style at beginning of range
|
// set nullStyle to style at beginning of range
|
||||||
@@ -4121,8 +4087,16 @@ BTextView::UpdateScrollbars()
|
|||||||
void
|
void
|
||||||
BTextView::AutoResize(bool doredraw)
|
BTextView::AutoResize(bool doredraw)
|
||||||
{
|
{
|
||||||
CALLED();
|
// TODO: What about fContainerView ? Should we resize it as well ?
|
||||||
// TODO: Implement
|
if (fResizable) {
|
||||||
|
float width = 0;
|
||||||
|
for (int32 i = 0; i < CountLines(); i++)
|
||||||
|
width = max_c(width, LineWidth(i));
|
||||||
|
|
||||||
|
ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
||||||
|
if (fContainerView)
|
||||||
|
fContainerView->ResizeTo(Bounds().Width(), Bounds().Height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user