test app_server: Fix build & add font spacing test.

This commit is contained in:
Stephan Aßmus 2014-02-26 11:50:41 +01:00
parent b8f4968d9b
commit cb7de03cca
3 changed files with 120 additions and 0 deletions

View File

@ -81,6 +81,7 @@ local decorator_src =
DefaultDecorator.cpp
DefaultWindowBehaviour.cpp
MagneticBorder.cpp
TabDecorator.cpp
WindowBehaviour.cpp
;
@ -233,6 +234,7 @@ SubInclude HAIKU_TOP src tests servers app drawing_modes ;
SubInclude HAIKU_TOP src tests servers app event_mask ;
SubInclude HAIKU_TOP src tests servers app find_view ;
SubInclude HAIKU_TOP src tests servers app following ;
SubInclude HAIKU_TOP src tests servers app font_spacing ;
SubInclude HAIKU_TOP src tests servers app hide_and_show ;
SubInclude HAIKU_TOP src tests servers app idle_test ;
SubInclude HAIKU_TOP src tests servers app lagging_get_mouse ;

View File

@ -0,0 +1,18 @@
SubDir HAIKU_TOP src tests servers app font_spacing ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
UseHeaders [ FDirName os app ] ;
UseHeaders [ FDirName os interface ] ;
SimpleTest FontSpacing :
main.cpp
: be $(TARGET_LIBSUPC++)
:
;
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : FontSpacing
: tests!apps ;
}

View File

@ -0,0 +1,100 @@
/*
* Copyright 2014 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <Application.h>
#include <Bitmap.h>
#include <GradientLinear.h>
#include <Message.h>
#include <Picture.h>
#include <LayoutBuilder.h>
#include <List.h>
#include <PopUpMenu.h>
#include <Resources.h>
#include <Roster.h>
#include <ScrollView.h>
#include <String.h>
#include <StringView.h>
#include <View.h>
#include <Window.h>
static const char* kAppSignature = "application/x.vnd-Haiku.FontSpacing";
class TestView : public BView {
public:
TestView();
virtual ~TestView();
virtual void Draw(BRect updateRect);
};
TestView::TestView()
:
BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{
}
TestView::~TestView()
{
}
void
TestView::Draw(BRect updateRect)
{
float scale = Bounds().Width() / 400.0f;
if (scale < 0.25f)
scale = 0.25f;
else if (scale > 3.0f)
scale = 3.0f;
SetScale(scale);
const char* string = "Testing the various BFont spacing modes.";
BFont font;
SetFont(&font);
DrawString(string, BPoint(30.0f, 25.0f));
font.SetSpacing(B_STRING_SPACING);
SetFont(&font);
DrawString(string, BPoint(30.0f, 45.0f));
font.SetSpacing(B_CHAR_SPACING);
SetFont(&font);
DrawString(string, BPoint(30.0f, 65.0f));
}
// #pragma mark -
int
main(int argc, char** argv)
{
BApplication app(kAppSignature);
BWindow* window = new BWindow(BRect(50, 50, 450, 450), "Font spacing test",
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_QUIT_ON_WINDOW_CLOSE
| B_AUTO_UPDATE_SIZE_LIMITS);
BLayoutBuilder::Group<>(window)
.Add(new TestView())
;
window->Show();
app.Run();
return 0;
}