* The text view now has a larger horizontal offset to look better.
* Since the text view doesn't necessarily occupy the whole text area anymore, we need to clear the area around it manually. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14872 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Region.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ BTextControl::BTextControl(BRect frame, const char *name, const char *label,
|
|||||||
|
|
||||||
ResizeTo(Bounds().Width(), height);
|
ResizeTo(Bounds().Width(), height);
|
||||||
|
|
||||||
float lineHeight = fText->LineHeight(0);
|
float lineHeight = ceil(fText->LineHeight(0));
|
||||||
fText->ResizeTo(fText->Bounds().Width(), lineHeight);
|
fText->ResizeTo(fText->Bounds().Width(), lineHeight);
|
||||||
fText->MoveTo(fText->Frame().left, (height - lineHeight) / 2);
|
fText->MoveTo(fText->Frame().left, (height - lineHeight) / 2);
|
||||||
}
|
}
|
||||||
@@ -226,8 +227,30 @@ BTextControl::Draw(BRect updateRect)
|
|||||||
if (fText->IsFocus() && Window()->IsActive())
|
if (fText->IsFocus() && Window()->IsActive())
|
||||||
active = true;
|
active = true;
|
||||||
|
|
||||||
BRect rect(fText->Frame());
|
// outer bevel
|
||||||
rect.InsetBy(-1.0f, -1.0f);
|
|
||||||
|
BRect rect = Bounds();
|
||||||
|
rect.left = fDivider;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
SetHighColor(darken1);
|
||||||
|
else
|
||||||
|
SetHighColor(noTint);
|
||||||
|
|
||||||
|
StrokeLine(rect.LeftBottom(), rect.LeftTop());
|
||||||
|
StrokeLine(rect.RightTop());
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
SetHighColor(lighten2);
|
||||||
|
else
|
||||||
|
SetHighColor(lighten1);
|
||||||
|
|
||||||
|
StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
|
||||||
|
StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom());
|
||||||
|
|
||||||
|
// inner bevel
|
||||||
|
|
||||||
|
rect.InsetBy(1.0f, 1.0f);
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
SetHighColor(navigationColor);
|
SetHighColor(navigationColor);
|
||||||
@@ -246,23 +269,17 @@ BTextControl::Draw(BRect updateRect)
|
|||||||
StrokeLine(BPoint(rect.right, rect.top + 1.0f));
|
StrokeLine(BPoint(rect.right, rect.top + 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.InsetBy(-1.0f, -1.0f);
|
// area around text view
|
||||||
|
|
||||||
if (enabled)
|
SetHighColor(fText->ViewColor());
|
||||||
SetHighColor(darken1);
|
rect.InsetBy(1, 1);
|
||||||
else
|
BRegion region(rect);
|
||||||
SetHighColor(noTint);
|
BRegion updateRegion(updateRect);
|
||||||
|
// why is there no IntersectWith(BRect &) version?
|
||||||
StrokeLine(rect.LeftBottom(), rect.LeftTop());
|
region.IntersectWith(&updateRegion);
|
||||||
StrokeLine(rect.RightTop());
|
for (int32 i = region.CountRects(); i-- > 0;) {
|
||||||
|
FillRect(region.RectAt(i));
|
||||||
if (enabled)
|
}
|
||||||
SetHighColor(lighten2);
|
|
||||||
else
|
|
||||||
SetHighColor(lighten1);
|
|
||||||
|
|
||||||
StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
|
|
||||||
StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom());
|
|
||||||
|
|
||||||
if (Label()) {
|
if (Label()) {
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
@@ -571,8 +588,8 @@ BTextControl::CommitValue()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextControl::InitData(const char *label, const char *initial_text,
|
BTextControl::InitData(const char *label, const char *initialText,
|
||||||
BMessage *data)
|
BMessage *data)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
@@ -614,7 +631,7 @@ BTextControl::InitData(const char *label, const char *initial_text,
|
|||||||
bounds.right, bounds.bottom);
|
bounds.right, bounds.bottom);
|
||||||
// we are stroking the frame around the text view, which
|
// we are stroking the frame around the text view, which
|
||||||
// is 2 pixels wide
|
// is 2 pixels wide
|
||||||
frame.InsetBy(3.0, 3.0);
|
frame.InsetBy(4.0, 3.0);
|
||||||
BRect textRect(frame.OffsetToCopy(0.0f, 0.0f));
|
BRect textRect(frame.OffsetToCopy(0.0f, 0.0f));
|
||||||
|
|
||||||
fText = new _BTextInput_(frame, textRect,
|
fText = new _BTextInput_(frame, textRect,
|
||||||
@@ -622,7 +639,7 @@ BTextControl::InitData(const char *label, const char *initial_text,
|
|||||||
B_WILL_DRAW | B_FRAME_EVENTS | navigableFlags);
|
B_WILL_DRAW | B_FRAME_EVENTS | navigableFlags);
|
||||||
AddChild(fText);
|
AddChild(fText);
|
||||||
|
|
||||||
SetText(initial_text);
|
SetText(initialText);
|
||||||
fText->SetAlignment(B_ALIGN_LEFT);
|
fText->SetAlignment(B_ALIGN_LEFT);
|
||||||
fText->AlignTextRect();
|
fText->AlignTextRect();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user