From 0055cc7415756395a89c41a56f7e4d2b34d10be5 Mon Sep 17 00:00:00 2001 From: Phil Greenway Date: Sat, 19 Jul 2003 11:53:38 +0000 Subject: [PATCH] Various changes to Devices. Add the ResourceUsagesWindow. Still need help on the "guts" of this project. Any devices nuts, please email me - phil@sikosis.com git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4014 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/prefs/devices/Devices.h | 2 +- src/prefs/devices/DevicesConstants.h | 1 + src/prefs/devices/DevicesViews.cpp | 7 ++ src/prefs/devices/DevicesViews.h | 7 ++ src/prefs/devices/DevicesWindow.cpp | 1 + src/prefs/devices/DevicesWindows.h | 13 +++ src/prefs/devices/ResourceUsageView.cpp | 29 +++++++ src/prefs/devices/ResourceUsageWindow.cpp | 99 +++++++++++++++++++++++ 8 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/prefs/devices/ResourceUsageView.cpp create mode 100644 src/prefs/devices/ResourceUsageWindow.cpp diff --git a/src/prefs/devices/Devices.h b/src/prefs/devices/Devices.h index 5e5b552248..f172a91fd5 100644 --- a/src/prefs/devices/Devices.h +++ b/src/prefs/devices/Devices.h @@ -21,4 +21,4 @@ class Devices : public BApplication }; -#endif +#endif \ No newline at end of file diff --git a/src/prefs/devices/DevicesConstants.h b/src/prefs/devices/DevicesConstants.h index 9ac82c4970..1636eebdb2 100644 --- a/src/prefs/devices/DevicesConstants.h +++ b/src/prefs/devices/DevicesConstants.h @@ -13,3 +13,4 @@ Devices Constants by Sikosis const char *APP_SIGNATURE = "application/x-vnd.OBOS.Devices"; // Application Signature and Title #endif + diff --git a/src/prefs/devices/DevicesViews.cpp b/src/prefs/devices/DevicesViews.cpp index b55f6d07c6..068926fe4b 100644 --- a/src/prefs/devices/DevicesViews.cpp +++ b/src/prefs/devices/DevicesViews.cpp @@ -34,3 +34,10 @@ void DevicesView::Draw(BRect updateRect) } // ---------------------------------------------------------------------------------------------------------- // + +// ResourceUsageView - Constructor +ResourceUsageView::ResourceUsageView (BRect frame) : BView (frame, "ResourceUsageView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); +} +// ---------------------------------------------------------------------------------------------------------- // diff --git a/src/prefs/devices/DevicesViews.h b/src/prefs/devices/DevicesViews.h index c7fee958f0..73fcd20100 100644 --- a/src/prefs/devices/DevicesViews.h +++ b/src/prefs/devices/DevicesViews.h @@ -19,4 +19,11 @@ class DevicesView : public BView virtual void Draw(BRect updateRect); }; + +class ResourceUsageView : public BView +{ + public: + ResourceUsageView(BRect frame); +}; + #endif diff --git a/src/prefs/devices/DevicesWindow.cpp b/src/prefs/devices/DevicesWindow.cpp index a6c728212c..c6965cdae4 100644 --- a/src/prefs/devices/DevicesWindow.cpp +++ b/src/prefs/devices/DevicesWindow.cpp @@ -286,3 +286,4 @@ void DevicesWindow::MessageReceived (BMessage *message) } } // ---------------------------------------------------------------------------------------------------------- // + diff --git a/src/prefs/devices/DevicesWindows.h b/src/prefs/devices/DevicesWindows.h index c24ff3410d..ac75c09873 100644 --- a/src/prefs/devices/DevicesWindows.h +++ b/src/prefs/devices/DevicesWindows.h @@ -34,4 +34,17 @@ class DevicesWindow : public BWindow DevicesView* ptrDevicesView; }; + +class ResourceUsageWindow : public BWindow +{ + public: + ResourceUsageWindow(BRect frame); + ~ResourceUsageWindow(); + virtual void MessageReceived(BMessage *message); + private: + void InitWindow(void); + ResourceUsageView* ptrResourceUsageView; +}; + #endif + diff --git a/src/prefs/devices/ResourceUsageView.cpp b/src/prefs/devices/ResourceUsageView.cpp new file mode 100644 index 0000000000..c5330ceb42 --- /dev/null +++ b/src/prefs/devices/ResourceUsageView.cpp @@ -0,0 +1,29 @@ +/* + +ResourceUsageView + +Author: Sikosis + +(C)2003 OBOS - Released under the MIT License + +*/ + +// Includes ------------------------------------------------------------------------------------------ // +#include +#include +#include +#include +#include +#include + +#include "DevicesWindows.h" +#include "DevicesViews.h" +// -------------------------------------------------------------------------------------------------- // + +// ResourceUsageView - Constructor +ResourceUsageView::ResourceUsageView (BRect frame) : BView (frame, "ResourceUsageView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); +} +// ------------------------------------------------------------------------------------------------- // +----------------------- // diff --git a/src/prefs/devices/ResourceUsageWindow.cpp b/src/prefs/devices/ResourceUsageWindow.cpp new file mode 100644 index 0000000000..bf14ad64f0 --- /dev/null +++ b/src/prefs/devices/ResourceUsageWindow.cpp @@ -0,0 +1,99 @@ +/* + +ResourceUsageWindow + +Author: Sikosis + +(C)2003 OBOS - Released under the MIT License + +*/ + +// Includes ------------------------------------------------------------------------------------------ // +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Devices.h" +#include "DevicesWindows.h" +#include "DevicesViews.h" +// -------------------------------------------------------------------------------------------------- // + +// CenterWindowOnScreen -- Centers the BWindow to the Current Screen +static void CenterWindowOnScreen(BWindow* w) +{ + BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame()); BPoint pt; + pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2; + pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2; + + if (screenFrame.Contains(pt)) + w->MoveTo(pt); +} +// -------------------------------------------------------------------------------------------------- // + +// ResourceUsageWindow - Constructor +ResourceUsageWindow::ResourceUsageWindow(BRect frame) : BWindow (frame, "ResourceUsageWindow", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0) +{ + InitWindow(); + CenterWindowOnScreen(this); + Show(); +} +// -------------------------------------------------------------------------------------------------- // + +// ResourceUsageWindow - Destructor +ResourceUsageWindow::~ResourceUsageWindow() +{ + exit(0); +} +// -------------------------------------------------------------------------------------------------- // + +// ResourceUsageWindow::InitWindow -- Initialization Commands here +void ResourceUsageWindow::InitWindow(void) +{ + BRect r; + r = Bounds(); // the whole view + + /*lsvProjectFiles = new BListView(BRect(5,5,200,80), "ltvProjectFiles", + B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS); + + //BListView *list = new BListView(r, "City", B_MULTIPLE_SELECTION_LIST); + lsvProjectFiles->AddItem(new BStringItem("Brisbane")); + lsvProjectFiles->AddItem(new BStringItem("Sydney")); + lsvProjectFiles->AddItem(new BStringItem("Melbourne")); + lsvProjectFiles->AddItem(new BStringItem("Adelaide")); + +// lsiItem = new BListItem(); + +// lsvProjectFiles.AddItem(lsiItem);*/ + + // Create the Views + AddChild(ptrResourceUsageView = new ResourceUsageView(r)); + //ptrResourceUsageView->AddChild(...); +} +// -------------------------------------------------------------------------------------------------- // + + +// ResourceUsageWindow::MessageReceived -- receives messages +void ResourceUsageWindow::MessageReceived (BMessage *message) +{ + switch(message->what) + { + default: + BWindow::MessageReceived(message); + break; + } +} +// -------------------------------------------------------------------------------------------------- // + +------------------------------------------------------------------------------------------ // +