1 | #include <Application.h>
|
---|
2 | #include <Button.h>
|
---|
3 | #include <GroupLayoutBuilder.h>
|
---|
4 | #include <LayoutBuilder.h>
|
---|
5 | #include <RadioButton.h>
|
---|
6 | #include <TextControl.h>
|
---|
7 | #include <View.h>
|
---|
8 | #include <Window.h>
|
---|
9 |
|
---|
10 | #include <cstdio>
|
---|
11 | #include <cstdlib>
|
---|
12 |
|
---|
13 |
|
---|
14 | enum messages {
|
---|
15 | kButtonMessage
|
---|
16 | };
|
---|
17 |
|
---|
18 | class Window : public BWindow {
|
---|
19 | public:
|
---|
20 | Window();
|
---|
21 | virtual void MessageReceived(BMessage* message);
|
---|
22 | private:
|
---|
23 | BButton* fButton;
|
---|
24 | BTextControl* fTextControl;
|
---|
25 | };
|
---|
26 |
|
---|
27 | int main()
|
---|
28 | {
|
---|
29 | BApplication app("application/bitmaptest");
|
---|
30 |
|
---|
31 | Window* window = new Window();
|
---|
32 | window->Show();
|
---|
33 | app.Run();
|
---|
34 | return 0;
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | // Window
|
---|
39 | Window::Window()
|
---|
40 | :
|
---|
41 | BWindow(BRect(100, 100, 400, 400), "window", B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_AUTO_UPDATE_SIZE_LIMITS|B_QUIT_ON_WINDOW_CLOSE)
|
---|
42 | {
|
---|
43 | fButton = new BButton("button", new BMessage(kButtonMessage));
|
---|
44 | fTextControl = new BTextControl("textcontrol", "control", new BMessage());
|
---|
45 | BLayoutBuilder::Group<>(this, B_HORIZONTAL)
|
---|
46 | .Add(fButton)
|
---|
47 | .Add(fTextControl)
|
---|
48 | .End();
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | void
|
---|
53 | Window::MessageReceived(BMessage* message)
|
---|
54 | {
|
---|
55 | switch (message->what) {
|
---|
56 | case kButtonMessage:
|
---|
57 | {
|
---|
58 | fTextControl->SetEnabled(!fTextControl->IsEnabled());
|
---|
59 | break;
|
---|
60 | }
|
---|
61 | default:
|
---|
62 | BWindow::MessageReceived(message);
|
---|
63 | break;
|
---|
64 | }
|
---|
65 | }
|
---|