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","Don't Save","Save"); 38 switch (alert->Go()) { 39 case 0: 40 return false; 41 case 2: { 42 fView->SaveAndQuit(); 43 return false; 44 } 45 default: 46 break; 47 } 48 } 49 50 atomic_add(&sWindowCount, -1); 51 52 if (sWindowCount == 0) 53 be_app->PostMessage(B_QUIT_REQUESTED); 54 return true; 55 } 56 57 58