Implemented MakeResizable more correctly (at least, it looks like it). Replaced LONG_MAX with the right lines number in Refresh() calls. Started work to make the widget double buffered. More cleanups.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8130 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2003, OpenBeOS
|
// Copyright (c) 2001-2004, Haiku
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// Standard Includes -----------------------------------------------------------
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
// System Includes -------------------------------------------------------------
|
||||||
#include "SupportDefs.h"
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -68,7 +68,6 @@ virtual ~_BTextGapBuffer_();
|
|||||||
|
|
||||||
char RealCharAt(int32 offset) const;
|
char RealCharAt(int32 offset) const;
|
||||||
|
|
||||||
// void InsertText(BFile *, int32, int32, int32);
|
|
||||||
bool PasswordMode() const;
|
bool PasswordMode() const;
|
||||||
void SetPasswordMode(bool);
|
void SetPasswordMode(bool);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2004, OpenBeOS
|
// Copyright (c) 2001-2004, Haiku
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1915,7 +1915,7 @@ BTextView::SetTextRect(BRect rect)
|
|||||||
fTextRect = rect;
|
fTextRect = rect;
|
||||||
|
|
||||||
if (Window() != NULL)
|
if (Window() != NULL)
|
||||||
Refresh(0, LONG_MAX, true, false);
|
Refresh(0, fLines->NumLines(), true, false);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
BRect
|
BRect
|
||||||
@@ -1949,7 +1949,7 @@ BTextView::SetTabWidth(float width)
|
|||||||
fTabWidth = width;
|
fTabWidth = width;
|
||||||
|
|
||||||
if (Window() != NULL)
|
if (Window() != NULL)
|
||||||
Refresh(0, LONG_MAX, true, false);
|
Refresh(0, fLines->NumLines(), true, false);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
float
|
float
|
||||||
@@ -2030,11 +2030,11 @@ BTextView::SetWordWrap(bool wrap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh(0, LONG_MAX, true, false);
|
Refresh(0, fLines->NumLines(), true, false);
|
||||||
|
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
// show the caret, hilite the selection
|
// show the caret, hilite the selection
|
||||||
if (fSelStart != fSelEnd)
|
if (fSelStart != fSelEnd && fSelectable)
|
||||||
Highlight(fSelStart, fSelEnd);
|
Highlight(fSelStart, fSelEnd);
|
||||||
else {
|
else {
|
||||||
if (!fCaretVisible)
|
if (!fCaretVisible)
|
||||||
@@ -2087,7 +2087,18 @@ void
|
|||||||
BTextView::SetAlignment(alignment flag)
|
BTextView::SetAlignment(alignment flag)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
// Do a reality check
|
||||||
|
if (fAlignment != flag && flag >= 0 && flag <= 2) {
|
||||||
fAlignment = flag;
|
fAlignment = flag;
|
||||||
|
|
||||||
|
// After setting new alignment, update the view/window
|
||||||
|
BWindow *window = Window();
|
||||||
|
if (window) {
|
||||||
|
Invalidate();
|
||||||
|
window->UpdateIfNeeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
alignment
|
alignment
|
||||||
@@ -2133,12 +2144,35 @@ void
|
|||||||
BTextView::MakeResizable(bool resize, BView *resizeView)
|
BTextView::MakeResizable(bool resize, BView *resizeView)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
fResizable = resize;
|
if (resize) {
|
||||||
|
fResizable = true;
|
||||||
fContainerView = resizeView;
|
fContainerView = resizeView;
|
||||||
|
|
||||||
|
// Wrapping mode and resizable mode can't live together
|
||||||
|
if (fWrap) {
|
||||||
|
fWrap = false;
|
||||||
|
|
||||||
|
if (fActive && Window() != NULL) {
|
||||||
|
if (fSelStart != fSelEnd && fSelectable)
|
||||||
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
|
||||||
|
else if (fCaretVisible) {
|
||||||
|
InvertCaret();
|
||||||
|
Refresh(0, fLines->NumLines(), true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fResizable = false;
|
||||||
|
fContainerView = NULL;
|
||||||
|
if (fOffscreen)
|
||||||
|
DeleteOffscreen();
|
||||||
|
NewOffscreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
BTextView::IsResizable () const
|
BTextView::IsResizable() const
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return fResizable;
|
return fResizable;
|
||||||
@@ -3347,14 +3381,14 @@ BTextView::NewOffscreen(float padding)
|
|||||||
CALLED();
|
CALLED();
|
||||||
if (fOffscreen != NULL)
|
if (fOffscreen != NULL)
|
||||||
DeleteOffscreen();
|
DeleteOffscreen();
|
||||||
/*
|
|
||||||
BRect bitmapRect(0, 0, fTextRect.Width() + padding, fTextRect.Height());
|
BRect bitmapRect(0, 0, fTextRect.Width() + padding, fTextRect.Height());
|
||||||
fOffscreen = new BBitmap(bitmapRect, fColorSpace, true, false);
|
fOffscreen = new BBitmap(bitmapRect, fColorSpace, true, false);
|
||||||
if (fOffscreen != NULL && fOffscreen->Lock()) {
|
if (fOffscreen != NULL && fOffscreen->Lock()) {
|
||||||
BView *bufferView = new BView(bitmapRect, "buffer view", 0, 0);
|
BView *bufferView = new BView(bitmapRect, "buffer view", 0, 0);
|
||||||
fOffscreen->AddChild(bufferView);
|
fOffscreen->AddChild(bufferView);
|
||||||
fOffscreen->Unlock();
|
fOffscreen->Unlock();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
@@ -3373,6 +3407,8 @@ BTextView::Activate()
|
|||||||
CALLED();
|
CALLED();
|
||||||
fActive = true;
|
fActive = true;
|
||||||
|
|
||||||
|
NewOffscreen();
|
||||||
|
|
||||||
if (fSelStart != fSelEnd) {
|
if (fSelStart != fSelEnd) {
|
||||||
if (fSelectable)
|
if (fSelectable)
|
||||||
Highlight(fSelStart, fSelEnd);
|
Highlight(fSelStart, fSelEnd);
|
||||||
|
|||||||
Reference in New Issue
Block a user