From 550d47d91221cf373f43ca7b7f91d735b9422e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 10 Jan 2010 22:57:21 +0000 Subject: [PATCH] * cleanup * save and restore window frame. Fixed bug #4307. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34998 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/sounds/HWindow.cpp | 31 +++++++++++++++ src/preferences/sounds/HWindow.h | 61 +++++++++++++++--------------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/preferences/sounds/HWindow.cpp b/src/preferences/sounds/HWindow.cpp index c176547b73..c7172d3233 100644 --- a/src/preferences/sounds/HWindow.cpp +++ b/src/preferences/sounds/HWindow.cpp @@ -35,6 +35,9 @@ #include +static const char kSettingsFile[] = "Sounds_Settings"; + + HWindow::HWindow(BRect rect, const char *name) : _inherited(rect, name, B_TITLED_WINDOW, 0), fFilePanel(NULL), @@ -49,6 +52,20 @@ HWindow::HWindow(BRect rect, const char *name) fFilePanel = new BFilePanel(); fFilePanel->SetTarget(this); + + BPath path; + BMessage msg; + + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append(kSettingsFile); + BFile file(path.Path(), B_READ_ONLY); + + if (file.InitCheck() == B_OK && msg.Unflatten(&file) == B_OK + && msg.FindRect("frame", &fFrame) == B_OK) { + MoveTo(fFrame.LeftTop()); + ResizeTo(fFrame.Width(), fFrame.Height()); + } + } } @@ -56,6 +73,18 @@ HWindow::~HWindow() { delete fFilePanel; delete fPlayer; + + BPath path; + BMessage msg; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append(kSettingsFile); + BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE); + + if (file.InitCheck() == B_OK) { + msg.AddRect("frame", fFrame); + msg.Flatten(&file); + } + } } @@ -407,6 +436,8 @@ HWindow::DispatchMessage(BMessage *message, BHandler *handler) bool HWindow::QuitRequested() { + fFrame = Frame(); + fEventList->RemoveAll(); be_app->PostMessage(B_QUIT_REQUESTED); return true; diff --git a/src/preferences/sounds/HWindow.h b/src/preferences/sounds/HWindow.h index e4c603bf96..706f43b344 100644 --- a/src/preferences/sounds/HWindow.h +++ b/src/preferences/sounds/HWindow.h @@ -1,28 +1,25 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2003, OpenBeOS -// -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// -// File: HWindow.h -// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu -// Description: Sounds Preferences -// Created : November 24, 2003 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - +/* + * Copyright 2003-2010 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval + * Oliver Ruiz Dorantes + * Atsushi Takamatsu + */ #ifndef __HWINDOW_H__ #define __HWINDOW_H__ + #include #include #include + class HEventList; class HTypeList; + enum{ M_PLAY_MESSAGE = 'MPLM', M_STOP_MESSAGE = 'MSTO', @@ -35,23 +32,25 @@ enum{ M_OPEN_WITH = 'MOPW' }; -class HWindow :public BWindow { + +class HWindow : public BWindow { public: - HWindow(BRect rect ,const char* name); + HWindow(BRect rect, const char* name); protected: - virtual ~HWindow(); - virtual void MessageReceived(BMessage *message); - virtual bool QuitRequested(); - virtual void DispatchMessage(BMessage *message - ,BHandler *handler); - void InitGUI(); - void SetupMenuField(); - void Pulse(); + virtual ~HWindow(); + virtual void MessageReceived(BMessage *message); + virtual bool QuitRequested(); + virtual void DispatchMessage(BMessage *message, + BHandler *handler); + void InitGUI(); + void SetupMenuField(); + void Pulse(); private: - //HTypeList* fTypeList; - HEventList* fEventList; - typedef BWindow _inherited; - BFilePanel* fFilePanel; - BFileGameSound *fPlayer; + typedef BWindow _inherited; + HEventList* fEventList; + BFilePanel* fFilePanel; + BFileGameSound* fPlayer; + BRect fFrame; }; -#endif + +#endif // __HWINDOW_H__