1 | #include <Application.h>
|
---|
2 | #include <Menu.h>
|
---|
3 | #include <MenuField.h>
|
---|
4 | #include <MenuItem.h>
|
---|
5 | #include <View.h>
|
---|
6 | #include <Window.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | class View : public BView {
|
---|
10 | public:
|
---|
11 | View(BRect rect)
|
---|
12 | : BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
|
---|
13 | {
|
---|
14 | BMenu* menu = new BMenu("Text");
|
---|
15 | menu->AddItem(new BMenuItem("MenuItem", NULL));
|
---|
16 |
|
---|
17 | fMenuField = new BMenuField(rect, "menu_field", "Test", menu);
|
---|
18 | AddChild(fMenuField);
|
---|
19 |
|
---|
20 | fMenuField->ResizeToPreferred();
|
---|
21 | }
|
---|
22 |
|
---|
23 | private:
|
---|
24 | BMenuField* fMenuField;
|
---|
25 | };
|
---|
26 |
|
---|
27 |
|
---|
28 | class Window : public BWindow {
|
---|
29 | public:
|
---|
30 | Window()
|
---|
31 | : BWindow(BRect(100, 100, 200, 200), "Helper", B_TITLED_WINDOW_LOOK,
|
---|
32 | B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
|
---|
33 | {
|
---|
34 | AddChild(new View(Bounds()));
|
---|
35 | }
|
---|
36 | };
|
---|
37 |
|
---|
38 |
|
---|
39 | class Application : public BApplication {
|
---|
40 | public:
|
---|
41 | Application() : BApplication("application/x-vnd.BMenuFieldTest") {}
|
---|
42 |
|
---|
43 | void ReadyToRun()
|
---|
44 | {
|
---|
45 | BWindow* win = new Window();
|
---|
46 | win->Show();
|
---|
47 | }
|
---|
48 | };
|
---|
49 |
|
---|
50 |
|
---|
51 | int main()
|
---|
52 | {
|
---|
53 | Application app;
|
---|
54 | return app.Run();
|
---|
55 | }
|
---|