1 /* 2 * Copyright 2000, Georges-Edouard Berenger. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "PCWorld.h" 8 #include "PCWindow.h" 9 #include "Preferences.h" 10 #include "ProcessController.h" 11 #include "Utilities.h" 12 13 #include <Alert.h> 14 #include <Application.h> 15 #include <Catalog.h> 16 #include <Deskbar.h> 17 #include <Dragger.h> 18 #include <Roster.h> 19 #include <StringView.h> 20 21 22 PCWindow::PCWindow() 23 : 24 BWindow(BRect(100, 150, 131, 181), 25 B_TRANSLATE_SYSTEM_NAME("ProcessController"), B_TITLED_WINDOW, 26 B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) 27 { 28 Preferences preferences(kPreferencesFileName); 29 preferences.SaveInt32(kCurrentVersion, kVersionName); 30 preferences.LoadWindowPosition(this, kPosPrefName); 31 32 SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767); 33 BRect rect = Bounds(); 34 35 BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); 36 topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 37 AddChild(topView); 38 39 // set up a rectangle && instantiate a new view 40 // view rect should be same size as window rect but with left top at (0, 0) 41 rect.Set(0, 0, 15, 15); 42 rect.OffsetTo((Bounds().Width() - 16) / 2, (Bounds().Height() - 16) / 2); 43 topView->AddChild(new ProcessController(rect)); 44 45 // make window visible 46 Show(); 47 fDraggersAreDrawn = BDragger::AreDraggersDrawn(); 48 BDragger::ShowAllDraggers(); 49 } 50 51 52 PCWindow::~PCWindow() 53 { 54 if (!fDraggersAreDrawn) 55 BDragger::HideAllDraggers(); 56 } 57 58 59 bool 60 PCWindow::QuitRequested() 61 { 62 Preferences tPreferences(kPreferencesFileName); 63 tPreferences.SaveInt32(kCurrentVersion, kVersionName); 64 tPreferences.SaveWindowPosition(this, kPosPrefName); 65 66 be_app->PostMessage(B_QUIT_REQUESTED); 67 return true; 68 } 69