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 <Deskbar.h> 30 #include <Dragger.h> 31 #include <Roster.h> 32 #include <StringView.h> 33 34 35 PCWindow::PCWindow() 36 : BWindow(BRect(100, 150, 131, 181), "ProcessController", B_TITLED_WINDOW, 37 B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) 38 { 39 GebsPreferences preferences(kPreferencesFileName); 40 preferences.SaveInt32(kCurrentVersion, kVersionName); 41 preferences.LoadWindowPosition(this, kPosPrefName); 42 43 SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767); 44 BRect rect = Bounds(); 45 46 BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); 47 topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 48 AddChild(topView); 49 50 // set up a rectangle && instantiate a new view 51 // view rect should be same size as window rect but with left top at (0, 0) 52 rect.Set(0, 0, 15, 15); 53 rect.OffsetTo((Bounds().Width() - 16) / 2, (Bounds().Height() - 16) / 2); 54 topView->AddChild(new ProcessController(rect)); 55 56 // make window visible 57 Show(); 58 fDraggersAreDrawn = BDragger::AreDraggersDrawn(); 59 BDragger::ShowAllDraggers(); 60 } 61 62 63 PCWindow::~PCWindow() 64 { 65 if (!fDraggersAreDrawn) 66 BDragger::HideAllDraggers(); 67 } 68 69 70 bool 71 PCWindow::QuitRequested() 72 { 73 GebsPreferences tPreferences(kPreferencesFileName); 74 tPreferences.SaveWindowPosition(this, kPosPrefName); 75 76 be_app->PostMessage(B_QUIT_REQUESTED); 77 return true; 78 } 79 80