Loads and Saves Window Position using Flatten BMessages
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,15 +8,19 @@ DUNWindow by Sikosis ([email protected])
|
|||||||
|
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Be.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <File.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <OutlineListView.h>
|
#include <OutlineListView.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
@@ -236,6 +240,16 @@ void DUNWindow::InitWindow(void) {
|
|||||||
|
|
||||||
// Add the Drawing View
|
// Add the Drawing View
|
||||||
AddChild(aDUNview = new DUNView(r));
|
AddChild(aDUNview = new DUNView(r));
|
||||||
|
|
||||||
|
// Load User Settings
|
||||||
|
BPath path;
|
||||||
|
find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||||
|
path.Append("DUN/OBOS_DUN_settings",true);
|
||||||
|
BFile file(path.Path(),B_READ_ONLY);
|
||||||
|
BMessage msg;
|
||||||
|
msg.Unflatten(&file);
|
||||||
|
LoadSettings (&msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------- //
|
// ------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
@@ -250,13 +264,52 @@ DUNWindow::~DUNWindow() {
|
|||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------- //
|
// ------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
// DUNWindow::QuitRequested -- Post a message to the app to quit
|
|
||||||
bool DUNWindow::QuitRequested() {
|
// DUNWindow::LoadSettings -- Loads your current DUN settings
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
void DUNWindow::LoadSettings(BMessage *msg)
|
||||||
return true;
|
{
|
||||||
|
BRect frame;
|
||||||
|
if (B_OK == msg->FindRect("windowframe",&frame)) {
|
||||||
|
MoveTo(frame.left,frame.top);
|
||||||
|
ResizeTo(frame.right-frame.left,frame.bottom-frame.top);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------- //
|
// ------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
// DUNWindow::SaveSettings -- Saves the Users DUN settings
|
||||||
|
void DUNWindow::SaveSettings(void)
|
||||||
|
{
|
||||||
|
BMessage msg;
|
||||||
|
msg.AddRect("windowframe",Frame());
|
||||||
|
|
||||||
|
/*int selection=ListView1->CurrentSelection(0);
|
||||||
|
if (selection>=0)
|
||||||
|
msg.AddString("modulename", ((BStringItem *)(ListView1->ItemAt(selection)))->Text());
|
||||||
|
msg.what=POPULATE; */
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
status_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||||
|
if (result == B_OK)
|
||||||
|
{
|
||||||
|
path.Append("DUN/OBOS_DUN_settings",true);
|
||||||
|
BFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
|
msg.Flatten(&file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
// DUNWindow::QuitRequested -- Post a message to the app to quit
|
||||||
|
bool DUNWindow::QuitRequested() {
|
||||||
|
SaveSettings();
|
||||||
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
// DUNWindow::MessageReceived -- receives messages
|
// DUNWindow::MessageReceived -- receives messages
|
||||||
void DUNWindow::MessageReceived (BMessage *message) {
|
void DUNWindow::MessageReceived (BMessage *message) {
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ public:
|
|||||||
~DUNWindow();
|
~DUNWindow();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
|
void LoadSettings(BMessage *msg);
|
||||||
|
void SaveSettings(void);
|
||||||
private:
|
private:
|
||||||
ModemWindow *modemWindow;
|
ModemWindow *modemWindow;
|
||||||
void InitWindow(void);
|
void InitWindow(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user