Now saves the current find settings, too (find mode and case sensitivity).

Updated the about requester to read "Haiku" instead of "OpenBeOS".


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8498 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-07-29 09:06:51 +00:00
parent b201976335
commit f0abe83f7b
3 changed files with 49 additions and 19 deletions

View File

@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License. ** Distributed under the terms of the Haiku License.
*/ */
@ -37,9 +37,13 @@ struct disk_probe_settings {
BRect window_frame; BRect window_frame;
int32 base_type; int32 base_type;
int32 font_size; int32 font_size;
int32 unknown; int32 flags;
}; };
enum disk_probe_flags {
kCaseSensitive = 0x01, // this flag alone is R5 DiskProbe settings compatible
kHexFindMode = 0x02,
};
class Settings { class Settings {
public: public:
@ -95,6 +99,8 @@ Settings::Settings()
fMessage.AddRect("window_frame", BRect(50, 50, 550, 500)); fMessage.AddRect("window_frame", BRect(50, 50, 550, 500));
fMessage.AddInt32("base_type", kHexBase); fMessage.AddInt32("base_type", kHexBase);
fMessage.AddFloat("font_size", 12.0f); fMessage.AddFloat("font_size", 12.0f);
fMessage.AddBool("case_sensitive", true);
fMessage.AddInt8("find_mode", kAsciiMode);
BFile file; BFile file;
if (Open(&file, B_READ_ONLY) != B_OK) if (Open(&file, B_READ_ONLY) != B_OK)
@ -123,6 +129,9 @@ Settings::Settings()
fMessage.ReplaceInt32("base_type", B_LENDIAN_TO_HOST_INT32(settings.base_type)); fMessage.ReplaceInt32("base_type", B_LENDIAN_TO_HOST_INT32(settings.base_type));
if (settings.font_size >= 0 && settings.font_size <= 72) if (settings.font_size >= 0 && settings.font_size <= 72)
fMessage.ReplaceFloat("font_size", float(B_LENDIAN_TO_HOST_INT32(settings.font_size))); fMessage.ReplaceFloat("font_size", float(B_LENDIAN_TO_HOST_INT32(settings.font_size)));
fMessage.ReplaceBool("case_sensitive", settings.flags & kCaseSensitive);
fMessage.ReplaceInt8("find_mode", settings.flags & kHexFindMode ? kHexMode : kAsciiMode);
} }
} }
@ -150,8 +159,8 @@ Settings::~Settings()
settings.base_type = B_HOST_TO_LENDIAN_INT32(fMessage.FindInt32("base_type")); settings.base_type = B_HOST_TO_LENDIAN_INT32(fMessage.FindInt32("base_type"));
settings.font_size = B_HOST_TO_LENDIAN_INT32(int32(fMessage.FindFloat("font_size") + 0.5f)); settings.font_size = B_HOST_TO_LENDIAN_INT32(int32(fMessage.FindFloat("font_size") + 0.5f));
settings.unknown = 1; settings.flags = B_HOST_TO_LENDIAN_INT32((fMessage.FindBool("case_sensitive") ? kCaseSensitive : 0)
// That's what DiskProbe R5 puts in there | (fMessage.FindInt8("find_mode") == kHexMode ? kHexFindMode : 0));
file.Write(&settings, sizeof(settings)); file.Write(&settings, sizeof(settings));
} }
@ -185,6 +194,14 @@ Settings::UpdateFrom(BMessage *message)
if (message->FindFloat("font_size", &fontSize) == B_OK) if (message->FindFloat("font_size", &fontSize) == B_OK)
fMessage.ReplaceFloat("font_size", fontSize); fMessage.ReplaceFloat("font_size", fontSize);
bool caseSensitive;
if (message->FindBool("case_sensitive", &caseSensitive) == B_OK)
fMessage.ReplaceBool("case_sensitive", caseSensitive);
int8 findMode;
if (message->FindInt8("find_mode", &findMode) == B_OK)
fMessage.ReplaceInt8("find_mode", findMode);
fUpdated = true; fUpdated = true;
} }
@ -387,7 +404,8 @@ DiskProbe::MessageReceived(BMessage *message)
if (fFindWindow == NULL) { if (fFindWindow == NULL) {
// open it! // open it!
fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80), *message, target); fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80), *message,
target, &fSettings.Message());
fFindWindow->Show(); fFindWindow->Show();
} else } else
fFindWindow->Activate(); fFindWindow->Activate();
@ -409,12 +427,12 @@ DiskProbe::MessageReceived(BMessage *message)
} }
void void
DiskProbe::AboutRequested() DiskProbe::AboutRequested()
{ {
BAlert *alert = new BAlert("about", "DiskProbe\n" BAlert *alert = new BAlert("about", "DiskProbe\n"
"\twritten by Axel Dörfler\n" "\twritten by Axel Dörfler\n"
"\tCopyright 2004, OpenBeOS.\n\n" "\tCopyright 2004, Haiku.\n\n"
"original Be version by Robert Polic\n", "Ok"); "original Be version by Robert Polic\n", "Ok");
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
BFont font; BFont font;

View File

@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License. ** Distributed under the terms of the Haiku License.
*/ */
@ -22,11 +22,6 @@
#include <string.h> #include <string.h>
enum find_mode {
kAsciiMode,
kHexMode
};
static const uint32 kMsgFindMode = 'FMde'; static const uint32 kMsgFindMode = 'FMde';
static const uint32 kMsgStartFind = 'SFnd'; static const uint32 kMsgStartFind = 'SFnd';
@ -369,7 +364,8 @@ FindTextView::GetData(BMessage &message)
// #pragma mark - // #pragma mark -
FindWindow::FindWindow(BRect rect, BMessage &previous, BMessenger &target) FindWindow::FindWindow(BRect rect, BMessage &previous, BMessenger &target,
const BMessage *settings)
: BWindow(rect, "Find", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), : BWindow(rect, "Find", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS),
fTarget(target) fTarget(target)
{ {
@ -378,7 +374,8 @@ FindWindow::FindWindow(BRect rect, BMessage &previous, BMessenger &target)
AddChild(view); AddChild(view);
int8 mode = kAsciiMode; int8 mode = kAsciiMode;
previous.FindInt8("find_mode", &mode); if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
settings->FindInt8("find_mode", &mode);
// add the top widgets // add the top widgets
@ -416,8 +413,10 @@ FindWindow::FindWindow(BRect rect, BMessage &previous, BMessenger &target)
fCaseCheckBox->ResizeToPreferred(); fCaseCheckBox->ResizeToPreferred();
fCaseCheckBox->MoveTo(5, button->Frame().top); fCaseCheckBox->MoveTo(5, button->Frame().top);
bool caseSensitive; bool caseSensitive;
if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
caseSensitive = true; if (settings == NULL || settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
caseSensitive = true;
}
fCaseCheckBox->SetValue(caseSensitive); fCaseCheckBox->SetValue(caseSensitive);
view->AddChild(fCaseCheckBox); view->AddChild(fCaseCheckBox);
@ -495,6 +494,12 @@ FindWindow::MessageReceived(BMessage *message)
bool bool
FindWindow::QuitRequested() FindWindow::QuitRequested()
{ {
// update the application's settings
BMessage update(kMsgSettingsChanged);
update.AddBool("case_sensitive", fCaseCheckBox->Value() != 0);
update.AddInt8("find_mode", fTextView->Mode());
be_app_messenger.SendMessage(&update);
be_app_messenger.SendMessage(kMsgFindWindowClosed); be_app_messenger.SendMessage(kMsgFindWindowClosed);
return true; return true;
} }

View File

@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License. ** Distributed under the terms of the Haiku License.
*/ */
#ifndef FIND_WINDOW_H #ifndef FIND_WINDOW_H
#define FIND_WINDOW_H #define FIND_WINDOW_H
@ -13,9 +13,16 @@ class FindTextView;
class BCheckBox; class BCheckBox;
enum find_mode {
kAsciiMode,
kHexMode
};
class FindWindow : public BWindow { class FindWindow : public BWindow {
public: public:
FindWindow(BRect rect, BMessage &previous, BMessenger &target); FindWindow(BRect rect, BMessage &previous, BMessenger &target,
const BMessage *settings = NULL);
virtual ~FindWindow(); virtual ~FindWindow();
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);