1 /* 2 * Copyright 2001-2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Rafael Romo 7 * Stefano Ceccherini (burton666@libero.it) 8 * Axel Dörfler, axeld@pinc-software.de 9 */ 10 11 #include "AlertWindow.h" 12 #include "AlertView.h" 13 #include "Constants.h" 14 15 #include <Catalog.h> 16 #include <Window.h> 17 #include <Screen.h> 18 19 20 #undef B_TRANSLATION_CONTEXT 21 #define B_TRANSLATION_CONTEXT "Screen" 22 23 24 AlertWindow::AlertWindow(BMessenger target) 25 : BWindow(BRect(100.0, 100.0, 400.0, 193.0), B_TRANSLATE("Undo"), 26 B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 27 B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES), 28 fTarget(target) 29 { 30 fAlertView = new AlertView(Bounds(), "AlertView"); 31 32 ResizeTo(fAlertView->Bounds().Width(), fAlertView->Bounds().Height()); 33 AddChild(fAlertView); 34 35 // center window on screen 36 BScreen screen(this); 37 MoveTo(screen.Frame().left + (screen.Frame().Width() - Frame().Width()) / 2, 38 screen.Frame().top + (screen.Frame().Height() - Frame().Height()) / 2); 39 } 40 41 42 void 43 AlertWindow::MessageReceived(BMessage *message) 44 { 45 switch (message->what) { 46 case BUTTON_KEEP_MSG: 47 fTarget.SendMessage(MAKE_INITIAL_MSG); 48 PostMessage(B_QUIT_REQUESTED); 49 break; 50 51 case BUTTON_UNDO_MSG: 52 fTarget.SendMessage(BUTTON_UNDO_MSG); 53 PostMessage(B_QUIT_REQUESTED); 54 break; 55 56 default: 57 BWindow::MessageReceived(message); 58 break; 59 } 60 } 61