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
+12 -14
View File
@@ -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;