1 /* 2 ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. 3 Copyright (C) 2004 beunited.org 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 21 #include "PCWorld.h" 22 #include "PCWindow.h" 23 #include "Preferences.h" 24 #include "ProcessController.h" 25 #include "Utilities.h" 26 27 #include <Alert.h> 28 #include <Application.h> 29 #include <Catalog.h> 30 #include <Deskbar.h> 31 #include <Dragger.h> 32 #include <Roster.h> 33 #include <StringView.h> 34 35 36 PCWindow::PCWindow() 37 : 38 BWindow(BRect(100, 150, 131, 181), 39 B_TRANSLATE_SYSTEM_NAME("ProcessController"), B_TITLED_WINDOW, 40 B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) 41 { 42 Preferences preferences(kPreferencesFileName); 43 preferences.SaveInt32(kCurrentVersion, kVersionName); 44 preferences.LoadWindowPosition(this, kPosPrefName); 45 46 SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767); 47 BRect rect = Bounds(); 48 49 BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); 50 topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 51 AddChild(topView); 52 53 // set up a rectangle && instantiate a new view 54 // view rect should be same size as window rect but with left top at (0, 0) 55 rect.Set(0, 0, 15, 15); 56 rect.OffsetTo((Bounds().Width() - 16) / 2, (Bounds().Height() - 16) / 2); 57 topView->AddChild(new ProcessController(rect)); 58 59 // make window visible 60 Show(); 61 fDraggersAreDrawn = BDragger::AreDraggersDrawn(); 62 BDragger::ShowAllDraggers(); 63 } 64 65 66 PCWindow::~PCWindow() 67 { 68 if (!fDraggersAreDrawn) 69 BDragger::HideAllDraggers(); 70 } 71 72 73 bool 74 PCWindow::QuitRequested() 75 { 76 Preferences tPreferences(kPreferencesFileName); 77 tPreferences.SaveInt32(kCurrentVersion, kVersionName); 78 tPreferences.SaveWindowPosition(this, kPosPrefName); 79 80 be_app->PostMessage(B_QUIT_REQUESTED); 81 return true; 82 } 83