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:
@@ -2166,6 +2166,9 @@ BTextView::Highlight(int32 startOffset, int32 endOffset)
|
||||
SetDrawingMode(B_OP_INVERT);
|
||||
FillRegion(&selRegion, B_SOLID_HIGH);
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -348,10 +348,12 @@ BTextControl::AttachedToWindow()
|
||||
void
|
||||
BTextControl::MakeFocus(bool state)
|
||||
{
|
||||
fText->MakeFocus(state);
|
||||
if (state != fText->IsFocus()) {
|
||||
fText->MakeFocus(state);
|
||||
|
||||
if (state)
|
||||
fText->SelectAll();
|
||||
if (state)
|
||||
fText->SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -399,17 +401,12 @@ BTextControl::SetEnabled(bool state)
|
||||
void
|
||||
BTextControl::GetPreferredSize(float *width, float *height)
|
||||
{
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
font_height fh;
|
||||
font.GetHeight(&fh);
|
||||
|
||||
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
|
||||
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
|
||||
BTextControl::WindowActivated(bool active)
|
||||
{
|
||||
if (fText->IsFocus())
|
||||
Invalidate();
|
||||
if (fText->IsFocus()) {
|
||||
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());
|
||||
|
||||
fText = NULL;
|
||||
//fLabel = NULL;
|
||||
fModificationMessage = NULL;
|
||||
fLabelAlign = B_ALIGN_LEFT;
|
||||
fDivider = 0.0f;
|
||||
fPrevWidth = 0;
|
||||
fPrevHeight = 0;
|
||||
//fClean = true;
|
||||
fSkipSetFlags = false;
|
||||
|
||||
int32 flags = 0;
|
||||
|
||||
@@ -83,8 +83,14 @@ _BTextInput_::Archive(BMessage *data, bool deep) const
|
||||
void
|
||||
_BTextInput_::FrameResized(float width, float height)
|
||||
{
|
||||
printf("_BTextInput_::FrameResized()\n");
|
||||
BTextView::FrameResized(width, height);
|
||||
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()) {
|
||||
Draw(Bounds());
|
||||
Flush();
|
||||
// TODO: why do we have to invalidate here?
|
||||
// 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
|
||||
_BTextInput_::AlignTextRect()
|
||||
{
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user