1 /* 2 * Copyright (c) 2005-2010, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * DarkWyrm <darkwyrm@gmail.com> 7 */ 8 #include "ResWindow.h" 9 10 #include "App.h" 11 #include "ResView.h" 12 13 #include <Alert.h> 14 15 static int32 sWindowCount = 0; 16 17 ResWindow::ResWindow(const BRect &rect, const entry_ref *ref) 18 : BWindow(rect, "", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) 19 { 20 atomic_add(&sWindowCount, 1); 21 22 fView = new ResView(Bounds(), "resview", B_FOLLOW_ALL, B_WILL_DRAW, ref); 23 AddChild(fView); 24 Show(); 25 } 26 27 28 ResWindow::~ResWindow(void) 29 { 30 } 31 32 33 bool 34 ResWindow::QuitRequested(void) 35 { 36 if (fView->GetSaveStatus() == FILE_DIRTY) { 37 BAlert *alert = new BAlert("ResEdit", "Save your changes?", "Cancel", 38 "Don't Save", "Save"); 39 alert->SetShortcut(0, B_ESCAPE); 40 41 switch (alert->Go()) { 42 case 0: 43 return false; 44 case 2: { 45 fView->SaveAndQuit(); 46 return false; 47 } 48 default: 49 break; 50 } 51 } 52 53 atomic_add(&sWindowCount, -1); 54 55 if (sWindowCount == 0) 56 be_app->PostMessage(B_QUIT_REQUESTED); 57 return true; 58 } 59 60 61