headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / servers / app / font_spacing / main.cpp
blobcab6195592224f028aa0467c0bf91744f3389e83
1 /*
2 * Copyright 2014 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
7 #include <algorithm>
8 #include <stdio.h>
9 #include <string.h>
11 #include <Application.h>
12 #include <Bitmap.h>
13 #include <GradientLinear.h>
14 #include <Message.h>
15 #include <Picture.h>
16 #include <LayoutBuilder.h>
17 #include <List.h>
18 #include <PopUpMenu.h>
19 #include <Resources.h>
20 #include <Roster.h>
21 #include <ScrollView.h>
22 #include <String.h>
23 #include <StringView.h>
24 #include <View.h>
25 #include <Window.h>
28 static const char* kAppSignature = "application/x.vnd-Haiku.FontSpacing";
31 class TestView : public BView {
32 public:
33 TestView();
34 virtual ~TestView();
36 virtual void Draw(BRect updateRect);
40 TestView::TestView()
42 BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
47 TestView::~TestView()
52 void
53 TestView::Draw(BRect updateRect)
55 float scale = Bounds().Width() / 400.0f;
57 if (scale < 0.25f)
58 scale = 0.25f;
59 else if (scale > 3.0f)
60 scale = 3.0f;
62 SetScale(scale);
64 const char* string = "Testing the various BFont spacing modes.";
66 BFont font;
67 SetFont(&font);
68 DrawString(string, BPoint(30.0f, 25.0f));
70 font.SetSpacing(B_STRING_SPACING);
71 SetFont(&font);
72 DrawString(string, BPoint(30.0f, 45.0f));
74 font.SetSpacing(B_CHAR_SPACING);
75 SetFont(&font);
76 DrawString(string, BPoint(30.0f, 65.0f));
80 // #pragma mark -
83 int
84 main(int argc, char** argv)
86 BApplication app(kAppSignature);
88 BWindow* window = new BWindow(BRect(50, 50, 450, 450), "Font spacing test",
89 B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_QUIT_ON_WINDOW_CLOSE
90 | B_AUTO_UPDATE_SIZE_LIMITS);
92 BLayoutBuilder::Group<>(window)
93 .Add(new TestView())
96 window->Show();
98 app.Run();
99 return 0;