Ticket #14176: testtextview.cpp

File testtextview.cpp, 1.5 KB (added by irtusb, 3 years ago)

sample code. link with -lbe

Line 
1#include <Application.h>
2#include <Window.h>
3#include <TextView.h>
4#include <String.h>
5#include <LayoutBuilder.h>
6
7class AppTest : public BApplication {
8public:
9 AppTest()
10 :BApplication("application/x-vnd.badtv")
11 {
12 BString text;
13 text.Append('m', 200);
14
15 BWindow* win1 = new BWindow(BRect(100, 200, 400, 500), "No Layout, non-editable", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
16 BTextView* tv1 = new BTextView("");
17 tv1->ResizeTo(250, 250);
18 tv1->MakeEditable(false);
19 tv1->SetText(text);
20 tv1->SetInsets(20, 30, 40, 50);
21 win1->AddChild(tv1);
22 win1->Show();
23
24 BWindow* win2 = new BWindow(BRect(100, 200, 400, 500), "Layout, editable", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
25 win2->MoveBy(200, 50);
26 BTextView* tv2 = new BTextView("");
27 tv2->SetText(text);
28 tv2->SetInsets(20, 30, 40, 50);
29 BLayoutBuilder::Group<>(win2, B_VERTICAL)
30 //.SetInsets(0)
31 .Add(tv2);
32 win2->Show();
33
34
35 BWindow* win3 = new BWindow(BRect(100, 200, 400, 500), "Layout, non-editable", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
36 win3->MoveBy(400, 100);
37 BTextView* tv3 = new BTextView("");
38 tv3->SetText(text);
39 tv3->SetInsets(20, 30, 40, 50);
40 tv3->MakeEditable(false);
41 BLayoutBuilder::Group<>(win3, B_VERTICAL)
42 //.SetInsets(0)
43 .Add(tv3);
44 win3->Show();
45 }
46};
47
48
49int main(int argc, char* argv[]) {
50 AppTest* app = new AppTest();
51 app->Run();
52}