1 #include "PrintTestWindow.hpp" 2 3 #include "PrintTestView.hpp" 4 5 #include <Application.h> 6 #include <MenuItem.h> 7 #include <MenuBar.h> 8 #include <View.h> 9 10 PrintTestWindow::PrintTestWindow() 11 : Inherited(BRect(100,100,500,300), "OpenBeOS Printing", B_DOCUMENT_WINDOW, 0) 12 { 13 BuildGUI(); 14 } 15 16 bool PrintTestWindow::QuitRequested() 17 { 18 bool isOk = Inherited::QuitRequested(); 19 if (isOk) { 20 be_app->PostMessage(B_QUIT_REQUESTED); 21 } 22 23 return isOk; 24 } 25 26 27 void PrintTestWindow::BuildGUI() 28 { 29 BView* backdrop = new BView(Bounds(), "backdrop", B_FOLLOW_ALL, B_WILL_DRAW); 30 backdrop->SetViewColor(::ui_color(B_PANEL_BACKGROUND_COLOR)); 31 AddChild(backdrop); 32 33 BMenuBar* mb = new BMenuBar(Bounds(), "menubar"); 34 BMenu* m = new BMenu("File"); 35 m->AddItem(new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, new BMessage('PStp'), 'P', B_SHIFT_KEY)); 36 m->AddItem(new BMenuItem("Print" B_UTF8_ELLIPSIS, new BMessage('Prnt'), 'P')); 37 m->AddSeparatorItem(); 38 m->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); 39 m->SetTargetForItems(be_app_messenger); 40 mb->AddItem(m); 41 42 m = new BMenu("Edit"); 43 m->AddItem(new BMenuItem("Undo", new BMessage(B_UNDO), 'Z')); 44 m->AddSeparatorItem(); 45 m->AddItem(new BMenuItem("Cut", new BMessage(B_CUT), 'X')); 46 m->AddItem(new BMenuItem("Copy", new BMessage(B_COPY), 'C')); 47 m->AddItem(new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); 48 m->AddItem(new BMenuItem("Clear", new BMessage(B_DELETE))); 49 m->AddSeparatorItem(); 50 m->AddItem(new BMenuItem("Select All", new BMessage(B_SELECT_ALL))); 51 mb->AddItem(m); 52 53 backdrop->AddChild(mb); 54 55 BRect b = Bounds(); 56 b.top = mb->Bounds().bottom +1; 57 backdrop->AddChild(new PrintTestView(b)); 58 } 59 60