Adding test that shows that B_TRUNCATE_BEGINNING mode is essentially broken.
Worse yet for a small enough length it actually crashes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35379 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -117,6 +117,11 @@ SimpleTest SliderTest :
|
|||||||
: be $(TARGET_LIBSUPC++)
|
: be $(TARGET_LIBSUPC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SimpleTest TruncateString :
|
||||||
|
TruncateString.cpp
|
||||||
|
: be $(TARGET_LIBSUPC++)
|
||||||
|
;
|
||||||
|
|
||||||
SimpleTest MenuBeginningTest :
|
SimpleTest MenuBeginningTest :
|
||||||
MenuBeginningTest.cpp
|
MenuBeginningTest.cpp
|
||||||
: be $(TARGET_LIBSUPC++)
|
: be $(TARGET_LIBSUPC++)
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
class TruncateView : public BView {
|
||||||
|
public:
|
||||||
|
TruncateView(BRect frame)
|
||||||
|
: BView(frame, "TruncateView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
const float kSpacing = 20.0;
|
||||||
|
const float kTopOffset = kSpacing + 5;
|
||||||
|
const uint32 kTruncateModes[]
|
||||||
|
= { B_TRUNCATE_BEGINNING, B_TRUNCATE_MIDDLE, B_TRUNCATE_END };
|
||||||
|
const uint32 kTruncateModeCount
|
||||||
|
= sizeof(kTruncateModes) / sizeof(kTruncateModes[0]);
|
||||||
|
|
||||||
|
BString theString("ö-ä-ü");
|
||||||
|
BPoint point(10, kTopOffset);
|
||||||
|
BString truncated;
|
||||||
|
|
||||||
|
for (float length = 25; length < 50; length += 5) {
|
||||||
|
SetHighColor(255, 0, 0);
|
||||||
|
StrokeRect(BRect(point.x, point.y - kSpacing, point.x + length,
|
||||||
|
point.y + kSpacing * (kTruncateModeCount - 1)));
|
||||||
|
SetHighColor(0, 0, 0);
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < kTruncateModeCount; i++) {
|
||||||
|
truncated = theString;
|
||||||
|
TruncateString(&truncated, kTruncateModes[i], length);
|
||||||
|
DrawString(truncated.String(), point);
|
||||||
|
point.y += kSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
point.x += length + kSpacing;
|
||||||
|
point.y = kTopOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
BApplication app("application/x-vnd.Haiku-TruncateString");
|
||||||
|
|
||||||
|
BRect frame(200, 200, 600, 400);
|
||||||
|
BWindow *window = new BWindow(frame, "TruncateString", B_TITLED_WINDOW,
|
||||||
|
B_QUIT_ON_WINDOW_CLOSE);
|
||||||
|
|
||||||
|
TruncateView *view = new TruncateView(frame.OffsetToSelf(0, 0));
|
||||||
|
window->AddChild(view);
|
||||||
|
|
||||||
|
window->Show();
|
||||||
|
app.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user