libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / resedit / ResWindow.cpp
blob83d1c925e834671b7402e08b94aae54b7bb6064a
1 /*
2 * Copyright (c) 2005-2010, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
5 * Author:
6 * DarkWyrm <darkwyrm@gmail.com>
7 */
8 #include "ResWindow.h"
10 #include "App.h"
11 #include "ResView.h"
13 #include <Alert.h>
15 static int32 sWindowCount = 0;
17 ResWindow::ResWindow(const BRect &rect, const entry_ref *ref)
18 : BWindow(rect, "", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
20 atomic_add(&sWindowCount, 1);
22 fView = new ResView(Bounds(), "resview", B_FOLLOW_ALL, B_WILL_DRAW, ref);
23 AddChild(fView);
24 Show();
28 ResWindow::~ResWindow(void)
33 bool
34 ResWindow::QuitRequested(void)
36 if (fView->GetSaveStatus() == FILE_DIRTY) {
37 BAlert *alert = new BAlert("ResEdit", "Save changes before closing?",
38 "Cancel", "Don't save", "Save",
39 B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
40 alert->SetShortcut(0, B_ESCAPE);
41 alert->SetShortcut(1, 'd');
42 alert->SetShortcut(2, 's');
44 switch (alert->Go()) {
45 case 0:
46 return false;
47 case 2: {
48 fView->SaveAndQuit();
49 return false;
51 default:
52 break;
56 atomic_add(&sWindowCount, -1);
58 if (sWindowCount == 0)
59 be_app->PostMessage(B_QUIT_REQUESTED);
60 return true;