Ticket #2209: TextView.diff
File TextView.diff, 3.9 KB (added by , 16 years ago) |
---|
-
src/kits/interface/TextView.cpp
3576 3576 } while ((tabChars + numTabs) < numBytes); 3577 3577 } 3578 3578 3579 if (inputRegion.CountRects() > 0) { 3579 int32 returnedBytes; 3580 const char* stringToDraw; 3581 3582 if (inputRegion.CountRects() > 0 3583 && (offset <= fInline->Offset() && fInline->Offset() < offset + tabChars 3584 || fInline->Offset() <= offset && offset < fInline->Offset() + fInline->Length())) { 3580 3585 BRegion textRegion; 3581 3586 GetTextRegion(offset, offset + length, &textRegion); 3582 3583 3587 textRegion.IntersectWith(&inputRegion); 3584 view->PushState();3585 3588 3589 rgb_color viewColor = view->ViewColor(); 3590 3586 3591 // Highlight in blue the inputted text 3587 3592 view->SetHighColor(kBlueInputColor); 3588 3593 view->FillRect(textRegion.Frame()); … … 3594 3599 + fInline->SelectionOffset(), fInline->Offset() 3595 3600 + fInline->SelectionOffset() 3596 3601 + fInline->SelectionLength(), &selectedRegion); 3597 3598 3602 textRegion.IntersectWith(&selectedRegion); 3599 3603 3600 3604 view->SetHighColor(kRedInputColor); 3601 3605 view->FillRect(textRegion.Frame()); 3602 3606 } 3607 3608 int32 drawnBytes = 0; 3609 view->SetHighColor(*color); 3603 3610 3604 view->PopState(); 3611 // before inputted text 3612 _DrawLineInlucdeInputted(view, offset, min_c(fInline->Offset(), offset + tabChars), 3613 viewColor, &drawnBytes); 3614 3615 // blue inputted text 3616 _DrawLineInlucdeInputted(view, offset, 3617 min_c(fInline->Offset() + fInline->SelectionOffset(), offset + tabChars), 3618 kBlueInputColor, &drawnBytes); 3619 3620 // red inputted text 3621 int32 afterSelectionOffset = fInline->Offset() + fInline->SelectionOffset() 3622 + fInline->SelectionLength(); 3623 _DrawLineInlucdeInputted(view, offset, min_c(afterSelectionOffset, offset + tabChars), 3624 kRedInputColor, &drawnBytes); 3625 3626 // blue inputted text 3627 int32 afterInputted = fInline->Offset() + fInline->Length(); 3628 _DrawLineInlucdeInputted(view, offset, min_c(afterInputted, offset + tabChars), 3629 kBlueInputColor, &drawnBytes); 3630 3631 // after inputted text 3632 _DrawLineInlucdeInputted(view, offset, offset + tabChars, viewColor, &drawnBytes); 3633 view->SetLowColor(viewColor); 3634 view->SetViewColor(viewColor); 3635 } else { 3636 returnedBytes = tabChars; 3637 stringToDraw = fText->GetString(offset, &returnedBytes); 3638 view->DrawString(stringToDraw, returnedBytes); 3605 3639 } 3606 3640 3607 int32 returnedBytes = tabChars;3608 const char *stringToDraw = fText->GetString(offset,3609 &returnedBytes);3610 3611 view->DrawString(stringToDraw, returnedBytes);3612 3641 if (foundTab) { 3613 3642 float penPos = PenLocation().x - fTextRect.left; 3614 3643 float tabWidth = _ActualTabWidth(penPos); … … 3630 3659 3631 3660 3632 3661 void 3662 BTextView::_DrawLineInlucdeInputted(BView* view, int32 offset, int32 end, const rgb_color& bgColor, 3663 int32* drawnBytes) 3664 { 3665 if (offset + *drawnBytes >= end) 3666 return; 3667 SetLowColor(bgColor); 3668 SetViewColor(bgColor); 3669 3670 int32 returnedBytes = end - (offset + *drawnBytes); 3671 const char* stringToDraw = fText->GetString(offset + *drawnBytes, &returnedBytes); 3672 view->DrawString(stringToDraw, returnedBytes); 3673 *drawnBytes += returnedBytes; 3674 } 3675 3676 3677 void 3633 3678 BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset, 3634 3679 bool erase) 3635 3680 { -
headers/os/interface/TextView.h
254 254 void _DrawLine(BView* view, const int32 &startLine, 255 255 const int32& startOffset, const bool& erase, BRect& eraseRect, 256 256 BRegion& inputRegion); 257 void _DrawLineInlucdeInputted(BView* view, int32 offset, int32 end, const rgb_color& bgColor, 258 int32* drawnBytes); 257 259 258 260 void _DrawLines(int32 startLine, int32 endLine, int32 startOffset = -1, 259 261 bool erase = false);