* 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>
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;
+30 -31
View File
@@ -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 <Window.h>
#include <FilePanel.h>
#include <FileGameSound.h>
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__