headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / add-ons / print / pdf / bezierbounds / BBApp.cpp
blobfce2f1bf012b6d1a24d2ce6e45e918e84b03050e
1 #include "BBApp.h"
3 BMessage* NewMessage(uint32 what, uint32 data)
5 BMessage* m = new BMessage(what);
6 m->AddInt32("data", (int32)data);
7 return m;
11 AppWindow::AppWindow(BRect aRect)
12 : BWindow(aRect, APPLICATION, B_TITLED_WINDOW, 0) {
13 // add menu bar
14 BRect rect = BRect(0,0,aRect.Width(), aRect.Height());
15 menubar = new BMenuBar(rect, "menu_bar");
16 BMenu *menu;
18 menu = new BMenu("Test");
19 menu->AddItem(new BMenuItem("About ...", new BMessage(B_ABOUT_REQUESTED)));
20 menu->AddSeparatorItem();
21 menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
22 menubar->AddItem(menu);
24 menu = new BMenu("Line Cap");
25 menu->AddItem(new BMenuItem("Round", NewMessage(CAP_MSG, B_ROUND_CAP)));
26 menu->AddItem(new BMenuItem("Butt", NewMessage(CAP_MSG, B_BUTT_CAP)));
27 menu->AddItem(new BMenuItem("Square", NewMessage(CAP_MSG, B_SQUARE_CAP)));
28 menubar->AddItem(menu);
30 menu = new BMenu("Line Join");
31 menu->AddItem(new BMenuItem("Round", NewMessage(JOIN_MSG, B_ROUND_JOIN)));
32 menu->AddItem(new BMenuItem("Miter", NewMessage(JOIN_MSG, B_MITER_JOIN)));
33 menu->AddItem(new BMenuItem("Bevel", NewMessage(JOIN_MSG, B_BEVEL_JOIN)));
34 menu->AddItem(new BMenuItem("Butt", NewMessage(JOIN_MSG, B_BUTT_JOIN)));
35 menu->AddItem(new BMenuItem("Square", NewMessage(JOIN_MSG, B_SQUARE_JOIN)));
36 menubar->AddItem(menu);
38 menu = new BMenu("Path");
39 menu->AddItem(new BMenuItem("Open", new BMessage(OPEN_MSG)));
40 menu->AddItem(new BMenuItem("Close", new BMessage(CLOSE_MSG)));
41 menubar->AddItem(menu);
43 AddChild(menubar);
44 // add view
45 aRect.Set(0, menubar->Bounds().Height()+1, aRect.Width(), aRect.Height());
46 view = NULL;
47 AddChild(view = new BBView(aRect));
48 // make window visible
49 Show();
52 void AppWindow::MessageReceived(BMessage *message) {
53 int32 data;
54 message->FindInt32("data", &data);
56 switch(message->what) {
57 case MENU_APP_NEW:
58 break;
59 case B_ABOUT_REQUESTED:
60 AboutRequested();
61 break;
62 case CAP_MSG:
63 view->SetLineMode((cap_mode)data, view->LineJoinMode(), view->LineMiterLimit());
64 view->Invalidate();
65 break;
66 case JOIN_MSG:
67 view->SetLineMode(view->LineCapMode(), (join_mode)data, view->LineMiterLimit());
68 view->Invalidate();
69 break;
70 case OPEN_MSG:
71 case CLOSE_MSG:
72 view->SetClose(message->what == CLOSE_MSG);
73 view->Invalidate();
74 break;
75 default:
76 BWindow::MessageReceived(message);
81 bool AppWindow::QuitRequested() {
82 be_app->PostMessage(B_QUIT_REQUESTED);
83 return(true);
86 void AppWindow::AboutRequested() {
87 BAlert *about = new BAlert(APPLICATION,
88 APPLICATION " " VERSION "\nThis program is freeware under BSD/MIT license.\n\n"
89 "Written 2002.\n\n"
90 "By Michael Pfeiffer.\n\n"
91 "EMail: michael.pfeiffer@utanet.at.","Close");
92 about->Go();
95 App::App() : BApplication("application/x-vnd.obos.BezierBounds") {
96 BRect aRect;
97 // set up a rectangle and instantiate a new window
98 aRect.Set(100, 80, 410, 380);
99 window = NULL;
100 window = new AppWindow(aRect);
103 int main(int argc, char *argv[]) {
104 be_app = NULL;
105 App app;
106 be_app->Run();
107 return 0;