xref: /haiku/src/preferences/screen/AlertWindow.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
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 <Window.h>
16 #include <Screen.h>
17 
18 
19 AlertWindow::AlertWindow(BMessenger target)
20 	: BWindow(BRect(100.0, 100.0, 400.0, 193.0), "Undo",
21 		B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
22 		B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
23 	fTarget(target)
24 {
25 	fAlertView = new AlertView(Bounds(), "AlertView");
26 
27 	ResizeTo(fAlertView->Bounds().Width(), fAlertView->Bounds().Height());
28 	AddChild(fAlertView);
29 
30 	// center window on screen
31 	BScreen screen(this);
32 	MoveTo(screen.Frame().left + (screen.Frame().Width() - Frame().Width()) / 2,
33 		screen.Frame().top + (screen.Frame().Height() - Frame().Height()) / 2);
34 }
35 
36 
37 void
38 AlertWindow::MessageReceived(BMessage *message)
39 {
40 	switch (message->what) {
41 		case BUTTON_KEEP_MSG:
42 			fTarget.SendMessage(MAKE_INITIAL_MSG);
43 			PostMessage(B_QUIT_REQUESTED);
44 			break;
45 
46 		case BUTTON_UNDO_MSG:
47 			fTarget.SendMessage(BUTTON_UNDO_MSG);
48 			PostMessage(B_QUIT_REQUESTED);
49 			break;
50 
51 		default:
52 			BWindow::MessageReceived(message);
53 			break;
54 	}
55 }
56