Seems like BeBook lies on BTextView's autoresizing mode. The textview itself isn't resized, but only the textrect is. Fixes bug 161, but maybe it needs more work
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16770 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -384,6 +384,7 @@ BTextView::AttachedToWindow()
|
|||||||
AutoResize(true);
|
AutoResize(true);
|
||||||
|
|
||||||
UpdateScrollbars();
|
UpdateScrollbars();
|
||||||
|
ScrollToSelection();
|
||||||
|
|
||||||
if (!fCursor)
|
if (!fCursor)
|
||||||
SetViewCursor(B_CURSOR_I_BEAM);
|
SetViewCursor(B_CURSOR_I_BEAM);
|
||||||
@@ -1033,10 +1034,10 @@ BTextView::SetText(const char *inText, int32 inLength, const text_run_array *inR
|
|||||||
if (inText != NULL && inLength > 0)
|
if (inText != NULL && inLength > 0)
|
||||||
InsertText(inText, inLength, 0, inRuns);
|
InsertText(inText, inLength, 0, inRuns);
|
||||||
|
|
||||||
fClickOffset = fSelStart = fSelEnd = 0;
|
|
||||||
|
|
||||||
// recalc line breaks and draw the text
|
// recalc line breaks and draw the text
|
||||||
Refresh(0, inLength, true, true);
|
Refresh(0, inLength, true, false);
|
||||||
|
fClickOffset = fSelStart = fSelEnd = 0;
|
||||||
|
ScrollToOffset(fSelStart);
|
||||||
|
|
||||||
// draw the caret
|
// draw the caret
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
@@ -1077,10 +1078,10 @@ BTextView::SetText(BFile *inFile, int32 inOffset, int32 inLength,
|
|||||||
fText->Length(), B_FONT_ALL, NULL, NULL);
|
fText->Length(), B_FONT_ALL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
fClickOffset = fSelStart = fSelEnd = 0;
|
|
||||||
|
|
||||||
// recalc line breaks and draw the text
|
// recalc line breaks and draw the text
|
||||||
Refresh(0, inLength, true, true);
|
Refresh(0, inLength, true, false);
|
||||||
|
fClickOffset = fSelStart = fSelEnd = 0;
|
||||||
|
ScrollToOffset(fSelStart);
|
||||||
|
|
||||||
// draw the caret
|
// draw the caret
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
@@ -2369,7 +2370,6 @@ BTextView::ColorSpace() const
|
|||||||
void
|
void
|
||||||
BTextView::MakeResizable(bool resize, BView *resizeView)
|
BTextView::MakeResizable(bool resize, BView *resizeView)
|
||||||
{
|
{
|
||||||
// TODO: I don't think this function is finished.
|
|
||||||
CALLED();
|
CALLED();
|
||||||
if (resize) {
|
if (resize) {
|
||||||
fResizable = true;
|
fResizable = true;
|
||||||
@@ -3139,8 +3139,7 @@ BTextView::HandleAlphaKey(const char *bytes, int32 numBytes)
|
|||||||
\param scroll If true, function will scroll the view to the end offset.
|
\param scroll If true, function will scroll the view to the end offset.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase,
|
BTextView::Refresh(int32 fromOffset, int32 toOffset, bool erase, bool scroll)
|
||||||
bool scroll)
|
|
||||||
{
|
{
|
||||||
// TODO: Cleanup
|
// TODO: Cleanup
|
||||||
float saveHeight = fTextRect.Height();
|
float saveHeight = fTextRect.Height();
|
||||||
@@ -3285,8 +3284,7 @@ BTextView::RecalculateLineBreaks(int32 *startLine, int32 *endLine)
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BTextView::FindLineBreak(int32 fromOffset, float *outAscent,
|
BTextView::FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent, float *ioWidth)
|
||||||
float *outDescent, float *ioWidth)
|
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
*outAscent = 0.0;
|
*outAscent = 0.0;
|
||||||
@@ -3889,7 +3887,6 @@ BTextView::InitiateDrag()
|
|||||||
BHandler *dragHandler = NULL;
|
BHandler *dragHandler = NULL;
|
||||||
|
|
||||||
GetDragParameters(message, &dragBitmap, &bitmapPoint, &dragHandler);
|
GetDragParameters(message, &dragBitmap, &bitmapPoint, &dragHandler);
|
||||||
|
|
||||||
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
|
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
|
||||||
|
|
||||||
if (dragBitmap != NULL)
|
if (dragBitmap != NULL)
|
||||||
@@ -4015,6 +4012,7 @@ BTextView::UpdateScrollbars()
|
|||||||
void
|
void
|
||||||
BTextView::AutoResize(bool redraw)
|
BTextView::AutoResize(bool redraw)
|
||||||
{
|
{
|
||||||
|
// TODO: Review this
|
||||||
if (fResizable) {
|
if (fResizable) {
|
||||||
float width = 0;
|
float width = 0;
|
||||||
for (int32 i = 0; i < CountLines(); i++)
|
for (int32 i = 0; i < CountLines(); i++)
|
||||||
@@ -4022,9 +4020,10 @@ BTextView::AutoResize(bool redraw)
|
|||||||
|
|
||||||
float textRectPadding = Bounds().right - fTextRect.right;
|
float textRectPadding = Bounds().right - fTextRect.right;
|
||||||
width += fTextRect.left + textRectPadding;
|
width += fTextRect.left + textRectPadding;
|
||||||
|
width = ceilf(width);
|
||||||
BView *viewToResize = fContainerView != NULL ? fContainerView : this;
|
|
||||||
viewToResize->ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
if (fContainerView != NULL)
|
||||||
|
fContainerView->ResizeTo(width, max_c(Bounds().Height(), TextHeight(0, CountLines())));
|
||||||
|
|
||||||
fTextRect.right = Bounds().right - textRectPadding;
|
fTextRect.right = Bounds().right - textRectPadding;
|
||||||
if (redraw)
|
if (redraw)
|
||||||
@@ -4212,8 +4211,7 @@ BTextView::PreviousInitialByte(int32 offset) const
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextView::GetProperty(BMessage *specifier, int32 form,
|
BTextView::GetProperty(BMessage *specifier, int32 form, const char *property, BMessage *reply)
|
||||||
const char *property, BMessage *reply)
|
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (strcmp(property, "Selection") == 0) {
|
if (strcmp(property, "Selection") == 0) {
|
||||||
@@ -4248,8 +4246,7 @@ BTextView::GetProperty(BMessage *specifier, int32 form,
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextView::SetProperty(BMessage *specifier, int32 form,
|
BTextView::SetProperty(BMessage *specifier, int32 form, const char *property, BMessage *reply)
|
||||||
const char *property, BMessage *reply)
|
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (strcmp(property, "Selection") == 0) {
|
if (strcmp(property, "Selection") == 0) {
|
||||||
@@ -4291,8 +4288,7 @@ BTextView::SetProperty(BMessage *specifier, int32 form,
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextView::CountProperties(BMessage *specifier, int32 form,
|
BTextView::CountProperties(BMessage *specifier, int32 form, const char *property, BMessage *reply)
|
||||||
const char *property, BMessage *reply)
|
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (strcmp(property, "Text") == 0) {
|
if (strcmp(property, "Text") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user