repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / processcontroller / PCWindow.cpp
blob852e1795917b0e45fa0a6a345c7b49f613d11aa3
1 /*
2 ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
3 Copyright (C) 2004 beunited.org
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.
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.
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
21 #include "PCWorld.h"
22 #include "PCWindow.h"
23 #include "Preferences.h"
24 #include "ProcessController.h"
25 #include "Utilities.h"
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>
36 PCWindow::PCWindow()
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)
42 Preferences preferences(kPreferencesFileName);
43 preferences.SaveInt32(kCurrentVersion, kVersionName);
44 preferences.LoadWindowPosition(this, kPosPrefName);
46 SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767);
47 BRect rect = Bounds();
49 BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
50 topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
51 AddChild(topView);
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));
59 // make window visible
60 Show();
61 fDraggersAreDrawn = BDragger::AreDraggersDrawn();
62 BDragger::ShowAllDraggers();
66 PCWindow::~PCWindow()
68 if (!fDraggersAreDrawn)
69 BDragger::HideAllDraggers();
73 bool
74 PCWindow::QuitRequested()
76 Preferences tPreferences(kPreferencesFileName);
77 tPreferences.SaveInt32(kCurrentVersion, kVersionName);
78 tPreferences.SaveWindowPosition(this, kPosPrefName);
80 be_app->PostMessage(B_QUIT_REQUESTED);
81 return true;