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
This commit is contained in:
Stephan Aßmus
2005-05-16 12:02:23 +00:00
parent 3c2fddee4e
commit 6d8d6cad9d
3 changed files with 33 additions and 17 deletions
@@ -2166,6 +2166,9 @@ BTextView::Highlight(int32 startOffset, int32 endOffset)
SetDrawingMode(B_OP_INVERT); SetDrawingMode(B_OP_INVERT);
FillRegion(&selRegion, B_SOLID_HIGH); FillRegion(&selRegion, B_SOLID_HIGH);
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);
// TODO: unnecessary in R5 - maybe we should
// carry out drawing commands outside Draw() immediately?
Flush();
} }
@@ -3807,6 +3810,9 @@ BTextView::DrawCaret(int32 offset)
caretRect.bottom = caretPoint.y + lineHeight; caretRect.bottom = caretPoint.y + lineHeight;
InvertRect(caretRect); InvertRect(caretRect);
// TODO: This call seems not necessary on R5. So we need to fix something
// in our app_server. We should "auto-flush" eventually.
Flush();
} }
+12 -14
View File
@@ -348,10 +348,12 @@ BTextControl::AttachedToWindow()
void void
BTextControl::MakeFocus(bool state) BTextControl::MakeFocus(bool state)
{ {
fText->MakeFocus(state); if (state != fText->IsFocus()) {
fText->MakeFocus(state);
if (state) if (state)
fText->SelectAll(); fText->SelectAll();
}
} }
@@ -399,17 +401,12 @@ BTextControl::SetEnabled(bool state)
void void
BTextControl::GetPreferredSize(float *width, float *height) BTextControl::GetPreferredSize(float *width, float *height)
{ {
BFont font;
GetFont(&font);
font_height fh;
font.GetHeight(&fh);
if (height) if (height)
*height = (float)ceil(fh.ascent + fh.descent + fh.leading) + 7.0f; *height = fText->LineHeight(0) + 8.0f;
// TODO: this one I need to find out // TODO: this one I need to find out
if (width) if (width)
*width = 4.0f + (float)ceil(font.StringWidth(Label()))*2.0f; *width = 4.0f + ceilf(StringWidth(Label())) * 2.0f;
} }
@@ -538,8 +535,11 @@ BTextControl::FrameResized(float newWidth, float newHeight)
void void
BTextControl::WindowActivated(bool active) BTextControl::WindowActivated(bool active)
{ {
if (fText->IsFocus()) if (fText->IsFocus()) {
Invalidate(); BRect rect(fText->Frame());
rect.InsetBy(-1.0, -1.0);
Invalidate(rect);
}
} }
@@ -576,13 +576,11 @@ BTextControl::InitData(const char *label, const char *initial_text,
BRect bounds(Bounds()); BRect bounds(Bounds());
fText = NULL; fText = NULL;
//fLabel = NULL;
fModificationMessage = NULL; fModificationMessage = NULL;
fLabelAlign = B_ALIGN_LEFT; fLabelAlign = B_ALIGN_LEFT;
fDivider = 0.0f; fDivider = 0.0f;
fPrevWidth = 0; fPrevWidth = 0;
fPrevHeight = 0; fPrevHeight = 0;
//fClean = true;
fSkipSetFlags = false; fSkipSetFlags = false;
int32 flags = 0; int32 flags = 0;
+15 -3
View File
@@ -83,8 +83,14 @@ _BTextInput_::Archive(BMessage *data, bool deep) const
void void
_BTextInput_::FrameResized(float width, float height) _BTextInput_::FrameResized(float width, float height)
{ {
printf("_BTextInput_::FrameResized()\n");
BTextView::FrameResized(width, height); BTextView::FrameResized(width, height);
AlignTextRect(); AlignTextRect();
// TODO: just to get something working, it wouldn't be correct for
// scrolled views
BRect textRect(Bounds());
textRect.InsetBy(2.0, 2.0);
SetTextRect(textRect);
} }
@@ -154,8 +160,14 @@ _BTextInput_::MakeFocus(bool state)
} }
if (Window()) { if (Window()) {
Draw(Bounds()); // TODO: why do we have to invalidate here?
Flush(); // I'm leaving this in, but it looks suspicious... :-)
Invalidate(Bounds());
if (BView* parent = Parent()) {
BRect frame = Frame();
frame.InsetBy(-1.0, -1.0);
parent->Invalidate(frame);
}
} }
} }
@@ -163,7 +175,7 @@ _BTextInput_::MakeFocus(bool state)
void void
_BTextInput_::AlignTextRect() _BTextInput_::AlignTextRect()
{ {
// TODO
} }