diff --git a/src/prefs/devices/Devices.cpp b/src/prefs/devices/Devices.cpp new file mode 100644 index 0000000000..e7264298a3 --- /dev/null +++ b/src/prefs/devices/Devices.cpp @@ -0,0 +1,71 @@ +/* + +Devices by Sikosis + +(C)2003 OBOS + +*/ + +// Includes -------------------------------------------------------------------------------------------------- // +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Devices.h" +#include "DevicesWindows.h" +#include "DevicesViews.h" +#include "DevicesConstants.h" +// ---------------------------------------------------------------------------------------------------------- // + +DevicesWindow *ptrDevicesWindow; + +// Devices -- constructor +Devices::Devices() : BApplication (APP_SIGNATURE) +{ + // Default Window Size - even though we centre the form to the current screen size + BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame()); + + float FormTopDefault = 0; + float FormLeftDefault = 0; + float FormWidthDefault = 396; + float FormHeightDefault = 400; + + BRect DevicesWindowRect(FormTopDefault,FormLeftDefault,FormLeftDefault+FormWidthDefault,FormTopDefault+FormHeightDefault); + + ptrDevicesWindow = new DevicesWindow(DevicesWindowRect); +} +// ---------------------------------------------------------------------------------------------------------- // + + +// Devices::MessageReceived -- handles incoming messages +void Devices::MessageReceived (BMessage *message) +{ + switch(message->what) + { + default: + BApplication::MessageReceived(message); // pass it along ... + break; + } +} +// ---------------------------------------------------------------------------------------------------------- // + +// Devices Main +int main(void) +{ + Devices theApp; + theApp.Run(); + return 0; +} +// end ------------------------------------------------------------------------------------------------------ // diff --git a/src/prefs/devices/Devices.h b/src/prefs/devices/Devices.h new file mode 100644 index 0000000000..f172a91fd5 --- /dev/null +++ b/src/prefs/devices/Devices.h @@ -0,0 +1,24 @@ +/* + +Devices Header by Sikosis + +(C)2003 OBOS + +*/ + +#ifndef __DEVICES_H__ +#define __DEVICES_H__ + +extern const char *APP_SIGNATURE; + +class Devices : public BApplication +{ + public: + Devices(); + virtual void MessageReceived(BMessage *message); + + private: + +}; + +#endif \ No newline at end of file diff --git a/src/prefs/devices/Devices.rsrc b/src/prefs/devices/Devices.rsrc new file mode 100644 index 0000000000..d05691305e Binary files /dev/null and b/src/prefs/devices/Devices.rsrc differ diff --git a/src/prefs/devices/DevicesConstants.h b/src/prefs/devices/DevicesConstants.h new file mode 100644 index 0000000000..ae9fa55764 --- /dev/null +++ b/src/prefs/devices/DevicesConstants.h @@ -0,0 +1,15 @@ +/* + +Devices Constants by Sikosis + +(C)2003 + +*/ + +#ifndef __DEVICESCONSTANTS_H__ +#define __DEVICESCONSTANTS_H__ + +// Constants ------------------------------------------------------------------------------------------------- // +const char *APP_SIGNATURE = "application/x-vnd.OBOS.Devices"; // Application Signature and Title + +#endif \ No newline at end of file diff --git a/src/prefs/devices/DevicesViews.cpp b/src/prefs/devices/DevicesViews.cpp new file mode 100644 index 0000000000..b55f6d07c6 --- /dev/null +++ b/src/prefs/devices/DevicesViews.cpp @@ -0,0 +1,36 @@ +/* + +DevicesViews by Sikosis + +(C)2003 OBOS + +*/ + +// Includes -------------------------------------------------------------------------------------------------- // +#include +#include +#include +#include +#include +#include + +#include "DevicesWindows.h" +#include "DevicesViews.h" +//#include "DevicesConstants.h" +// ------------------------------------------------------------------------------------------------------------- // + +// DevicesView - Constructor +DevicesView::DevicesView (BRect frame) : BView (frame, "DevicesView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); +} +// ---------------------------------------------------------------------------------------------------------- // + + +void DevicesView::Draw(BRect updateRect) +{ + BRect r; + r = Bounds(); +} +// ---------------------------------------------------------------------------------------------------------- // + diff --git a/src/prefs/devices/DevicesViews.h b/src/prefs/devices/DevicesViews.h new file mode 100644 index 0000000000..c7fee958f0 --- /dev/null +++ b/src/prefs/devices/DevicesViews.h @@ -0,0 +1,22 @@ +/* + +Devices Views Header by Sikosis + +(C)2003 OBOS + +*/ + +#ifndef __DEVICESVIEWS_H__ +#define __DEVICESVIEWS_H__ + +#include "Devices.h" +#include "DevicesWindows.h" + +class DevicesView : public BView +{ + public: + DevicesView(BRect frame); + virtual void Draw(BRect updateRect); +}; + +#endif diff --git a/src/prefs/devices/DevicesWindow.cpp b/src/prefs/devices/DevicesWindow.cpp new file mode 100644 index 0000000000..db7a243f4f --- /dev/null +++ b/src/prefs/devices/DevicesWindow.cpp @@ -0,0 +1,149 @@ +/* + +Devices - DevicesWindow by Sikosis + +(C)2003 OBOS + +*/ + + +// Includes -------------------------------------------------------------------------------------------------- // +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Devices.h" +#include "DevicesViews.h" +#include "DevicesWindows.h" + +const uint32 MENU_FILE_ABOUT_DEVICES = 'mfad'; +const uint32 MENU_FILE_QUIT = 'mfqt'; +const uint32 MENU_DEVICES_REMOVE_JUMPERED_DEVICE = 'mdrj'; +const uint32 MENU_DEVICES_NEW_JUMPERED_DEVICE = 'mdnj'; +const uint32 MENU_DEVICES_RESOURCE_USAGE = 'mdru'; + + +// 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); +} +// ---------------------------------------------------------------------------------------------------------- // + + +// DevicesWindow - Constructor +DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "OBOS Devices Alpha", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0) +{ + InitWindow(); + CenterWindowOnScreen(this); + Show(); +} + + +// DevicesWindow - Destructor +DevicesWindow::~DevicesWindow() +{ + exit(0); +} + + +// DevicesWindow::InitWindow -- Initialization Commands here +void DevicesWindow::InitWindow(void) +{ + int LeftMargin = 16; + int RightMargin = 246; + BRect r; + r = Bounds(); // the whole view + + BMenu *FileMenu; + BMenu *DevicesMenu; + + // Add the menu bar + menubar = new BMenuBar(r, "menu_bar"); + + // Add File menu to menu bar + FileMenu = new BMenu("File"); + FileMenu->AddItem(new BMenuItem("About Devices" B_UTF8_ELLIPSIS, new BMessage(MENU_FILE_ABOUT_DEVICES), NULL)); + FileMenu->AddSeparatorItem(); + FileMenu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q')); + + DevicesMenu = new BMenu("Devices"); + DevicesMenu->AddItem(new BMenuItem("New Jumpered Device", new BMessage(MENU_DEVICES_NEW_JUMPERED_DEVICE), NULL)); + DevicesMenu->AddItem(new BMenuItem("Remove Jumpered Device", new BMessage(MENU_DEVICES_REMOVE_JUMPERED_DEVICE), 'R')); + DevicesMenu->AddSeparatorItem(); + DevicesMenu->AddItem(new BMenuItem("Resource Usage", new BMessage(MENU_DEVICES_RESOURCE_USAGE), 'U')); + + menubar->AddItem(FileMenu); + menubar->AddItem(DevicesMenu); + + stvDeviceName = new BStringView(BRect(LeftMargin, 16, 150, 40), "DeviceName", "Device Name"); + stvCurrentState = new BStringView(BRect(RightMargin, 16, r.right-10, 40), "CurrentState", "Current State"); + + // Create a basic View + AddChild(ptrDevicesView = new DevicesView(r)); + + ptrDevicesView->AddChild(menubar); + ptrDevicesView->AddChild(stvDeviceName); + ptrDevicesView->AddChild(stvCurrentState); +} +// ---------------------------------------------------------------------------------------------------------- // + + +// DevicesWindow::FrameResized +void DevicesWindow::FrameResized (float width, float height) +{ + BRect r; + r = Bounds(); + + // enforce width but not height +} +// ---------------------------------------------------------------------------------------------------------- // + + +// DevicesWindow::QuitRequested -- Post a message to the app to quit +bool DevicesWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} +// ---------------------------------------------------------------------------------------------------------- // + + +// DevicesWindow::MessageReceived -- receives messages +void DevicesWindow::MessageReceived (BMessage *message) +{ + switch(message->what) + { + case MENU_FILE_ABOUT_DEVICES: + (new BAlert("", "Devices\n\n\t'Just write a simple app to add a jumpered\n\tdevice to the system', he said.\n\n\tAnd many years later another he said\n\t'recreate it' ;)", "OK"))->Go(); + break; + case MENU_FILE_QUIT: + QuitRequested(); + break; + default: + BWindow::MessageReceived(message); + break; + } +} +// ---------------------------------------------------------------------------------------------------------- // + + diff --git a/src/prefs/devices/DevicesWindows.h b/src/prefs/devices/DevicesWindows.h new file mode 100644 index 0000000000..5046ef82da --- /dev/null +++ b/src/prefs/devices/DevicesWindows.h @@ -0,0 +1,35 @@ +/* + +Devices Windows Header by Sikosis + +(C)2003 OBOS + +*/ + +#ifndef __DEVICESWINDOWS_H__ +#define __DEVICESWINDOWS_H__ + +#include "Devices.h" +#include "DevicesViews.h" + +class DevicesView; + +class DevicesWindow : public BWindow +{ + public: + DevicesWindow(BRect frame); + ~DevicesWindow(); + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + virtual void FrameResized(float width, float height); + private: + void InitWindow(void); + + BStringView *stvDeviceName; + BStringView *stvCurrentState; + BMenuBar *menubar; + + DevicesView* ptrDevicesView; +}; + +#endif diff --git a/src/prefs/devices/Jamfile b/src/prefs/devices/Jamfile new file mode 100644 index 0000000000..1bb5fadf0d --- /dev/null +++ b/src/prefs/devices/Jamfile @@ -0,0 +1,13 @@ +SubDir OBOS_TOP src prefs devices ; + +AddResources Devices : Devices.rsrc ; + +UsePrivateHeaders Devices ; + +Preference Devices : + Devices.cpp + DevicesWindow.cpp + DevicesViews.cpp +; + +LinkSharedOSLibs Devices : be ; \ No newline at end of file