* 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
This commit is contained in:
Jérôme Duval
2010-01-10 22:57:21 +00:00
parent d9e36ee1c2
commit 550d47d912
2 changed files with 61 additions and 31 deletions
+31
View File
@@ -35,6 +35,9 @@
#include <Sound.h> #include <Sound.h>
static const char kSettingsFile[] = "Sounds_Settings";
HWindow::HWindow(BRect rect, const char *name) HWindow::HWindow(BRect rect, const char *name)
: _inherited(rect, name, B_TITLED_WINDOW, 0), : _inherited(rect, name, B_TITLED_WINDOW, 0),
fFilePanel(NULL), fFilePanel(NULL),
@@ -49,6 +52,20 @@ HWindow::HWindow(BRect rect, const char *name)
fFilePanel = new BFilePanel(); fFilePanel = new BFilePanel();
fFilePanel->SetTarget(this); 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 fFilePanel;
delete fPlayer; 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 bool
HWindow::QuitRequested() HWindow::QuitRequested()
{ {
fFrame = Frame();
fEventList->RemoveAll(); fEventList->RemoveAll();
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
+30 -31
View File
@@ -1,28 +1,25 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2010 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval
// * Oliver Ruiz Dorantes
// * Atsushi Takamatsu
// File: HWindow.h */
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
// Description: Sounds Preferences
// Created : November 24, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef __HWINDOW_H__ #ifndef __HWINDOW_H__
#define __HWINDOW_H__ #define __HWINDOW_H__
#include <Window.h> #include <Window.h>
#include <FilePanel.h> #include <FilePanel.h>
#include <FileGameSound.h> #include <FileGameSound.h>
class HEventList; class HEventList;
class HTypeList; class HTypeList;
enum{ enum{
M_PLAY_MESSAGE = 'MPLM', M_PLAY_MESSAGE = 'MPLM',
M_STOP_MESSAGE = 'MSTO', M_STOP_MESSAGE = 'MSTO',
@@ -35,23 +32,25 @@ enum{
M_OPEN_WITH = 'MOPW' M_OPEN_WITH = 'MOPW'
}; };
class HWindow :public BWindow {
class HWindow : public BWindow {
public: public:
HWindow(BRect rect ,const char* name); HWindow(BRect rect, const char* name);
protected: protected:
virtual ~HWindow(); virtual ~HWindow();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void DispatchMessage(BMessage *message virtual void DispatchMessage(BMessage *message,
,BHandler *handler); BHandler *handler);
void InitGUI(); void InitGUI();
void SetupMenuField(); void SetupMenuField();
void Pulse(); void Pulse();
private: private:
//HTypeList* fTypeList; typedef BWindow _inherited;
HEventList* fEventList; HEventList* fEventList;
typedef BWindow _inherited; BFilePanel* fFilePanel;
BFilePanel* fFilePanel; BFileGameSound* fPlayer;
BFileGameSound *fPlayer; BRect fFrame;
}; };
#endif
#endif // __HWINDOW_H__