diff --git a/src/prefs/devices/DevicesWindow.cpp b/src/prefs/devices/DevicesWindow.cpp index 5cbfe1ab63..d4544e772d 100644 --- a/src/prefs/devices/DevicesWindow.cpp +++ b/src/prefs/devices/DevicesWindow.cpp @@ -13,6 +13,13 @@ Devices - DevicesWindow by Sikosis #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -27,6 +34,7 @@ Devices - DevicesWindow by Sikosis #include #include #include + #include "Devices.h" #include "DevicesViews.h" #include "DevicesWindows.h" @@ -36,7 +44,6 @@ 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'; - const uint32 BTN_CONFIGURE = 'bcfg'; @@ -55,12 +62,23 @@ static void CenterWindowOnScreen(BWindow* w) // DevicesWindow - Constructor -DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "OBOS Devices Alpha", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0) +DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "OBOS Devices", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0) { InitWindow(); CenterWindowOnScreen(this); + + // Load User Settings + BPath path; + find_directory(B_USER_SETTINGS_DIRECTORY,&path); + path.Append("Devices_Settings",true); + BFile file(path.Path(),B_READ_ONLY); + BMessage msg; + msg.Unflatten(&file); + LoadSettings (&msg); + Show(); } +// ---------------------------------------------------------------------------------------------------------- // // DevicesWindow - Destructor @@ -68,6 +86,7 @@ DevicesWindow::~DevicesWindow() { exit(0); } +// ---------------------------------------------------------------------------------------------------------- // // DevicesWindow::InitWindow -- Initialization Commands here @@ -179,7 +198,6 @@ void DevicesWindow::InitWindow(void) ptrDevicesView->AddChild(outlinesv); ptrDevicesView->AddChild(btnConfigure); ptrDevicesView->AddChild(BottomFrame); - } // ---------------------------------------------------------------------------------------------------------- // @@ -198,22 +216,60 @@ void DevicesWindow::FrameResized (float width, float height) // DevicesWindow::QuitRequested -- Post a message to the app to quit bool DevicesWindow::QuitRequested() { - be_app->PostMessage(B_QUIT_REQUESTED); - return true; + SaveSettings(); + be_app->PostMessage(B_QUIT_REQUESTED); + return true; } // ---------------------------------------------------------------------------------------------------------- // +// DevicesWindow::LoadSettings -- Loads your current settings +void DevicesWindow::LoadSettings(BMessage *msg) +{ + BRect frame; + + if (B_OK == msg->FindRect("windowframe",&frame)) { + MoveTo(frame.left,frame.top); + ResizeTo(frame.right-frame.left,frame.bottom-frame.top); + } +} +// -------------------------------------------------------------------------------------------------------------- // + + +// DevicesWindow::SaveSettings -- Saves the Users settings +void DevicesWindow::SaveSettings(void) +{ + BMessage msg; + msg.AddRect("windowframe",Frame()); + + //printf("%i",outline-> + + BPath path; + status_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path); + if (result == B_OK) + { + path.Append("Devices_Settings",true); + BFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); + msg.Flatten(&file); + } +} +// ------------------------------------------------------------------------------- // + + // 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(); + { + (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(); + { + QuitRequested(); + } break; default: BWindow::MessageReceived(message); @@ -221,5 +277,3 @@ void DevicesWindow::MessageReceived (BMessage *message) } } // ---------------------------------------------------------------------------------------------------------- // - - diff --git a/src/prefs/devices/DevicesWindows.h b/src/prefs/devices/DevicesWindows.h index 5046ef82da..c24ff3410d 100644 --- a/src/prefs/devices/DevicesWindows.h +++ b/src/prefs/devices/DevicesWindows.h @@ -24,6 +24,8 @@ class DevicesWindow : public BWindow virtual void FrameResized(float width, float height); private: void InitWindow(void); + void LoadSettings(BMessage *msg); + void SaveSettings(void); BStringView *stvDeviceName; BStringView *stvCurrentState;