1 | // Test of Redirecting Standard Output
|
---|
2 |
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <unistd.h>
|
---|
5 | #include <Application.h>
|
---|
6 | #include <View.h>
|
---|
7 | #include <Window.h>
|
---|
8 | #include <TextView.h>
|
---|
9 | #include <TextControl.h>
|
---|
10 |
|
---|
11 |
|
---|
12 | class TestWindow : public BWindow {
|
---|
13 | public:
|
---|
14 | TestWindow(BRect frame);
|
---|
15 | virtual bool QuitRequested() {
|
---|
16 | be_app->PostMessage(B_QUIT_REQUESTED);
|
---|
17 | return true;
|
---|
18 | }
|
---|
19 | BTextView *tview;
|
---|
20 | BTextControl *tcntrl;
|
---|
21 | };
|
---|
22 |
|
---|
23 | TestWindow::TestWindow(BRect frame)
|
---|
24 | : BWindow(frame, "Text Control Test", B_TITLED_WINDOW, 0)
|
---|
25 | {
|
---|
26 | tview = new BTextView(BRect(10,40,100,60), "textview",
|
---|
27 | frame.OffsetToCopy(B_ORIGIN), B_FOLLOW_TOP| B_FOLLOW_LEFT, B_WILL_DRAW);
|
---|
28 | AddChild(tview);
|
---|
29 | tview->SetAlignment(B_ALIGN_RIGHT);
|
---|
30 | tview->SetText("Text");
|
---|
31 | tcntrl = new BTextControl(BRect(10,65,100,85), "textcontrol", NULL,
|
---|
32 | "abc", NULL);
|
---|
33 | AddChild(tcntrl);
|
---|
34 | tcntrl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | class TestApplication : public BApplication
|
---|
39 | {
|
---|
40 | public:
|
---|
41 | TestApplication() : BApplication("application/x-Test-TextView") {
|
---|
42 | (new TestWindow(BRect(50, 50, 350, 350)))->Show();
|
---|
43 | }
|
---|
44 | };
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | int main(void)
|
---|
49 | {
|
---|
50 | TestApplication myApplication;
|
---|
51 | myApplication.Run();
|
---|
52 | return(0);
|
---|
53 | }
|
---|
54 |
|
---|