mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
Imported SettingsViews.cpp 1.11, .h 1.9, TrackerSettingsWindow.cpp 1.8, .h 1.3,
and SelectionWindow.cpp 1.3. This fixes bug #656. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17921 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e57995449d
commit
190650c3c7
@ -48,27 +48,25 @@ const int frameThickness = 9;
|
||||
const uint32 kSelectButtonPressed = 'sbpr';
|
||||
|
||||
SelectionWindow::SelectionWindow(BContainerWindow *window)
|
||||
: BWindow(BRect(0, 0, 270, 0),
|
||||
"Select", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
|
||||
| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
|
||||
| B_NOT_ANCHORED_ON_ACTIVATE),
|
||||
fParentWindow(window)
|
||||
: BWindow(BRect(0, 0, 270, 0), "Select", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
|
||||
| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
|
||||
| B_NOT_ANCHORED_ON_ACTIVATE),
|
||||
fParentWindow(window)
|
||||
{
|
||||
if (window->Feel() & kPrivateDesktopWindowFeel)
|
||||
if (window->Feel() & kPrivateDesktopWindowFeel) {
|
||||
// The window will not show up if we have B_FLOATING_SUBSET_WINDOW_FEEL
|
||||
// and use it with the desktop window since it's never in front.
|
||||
SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
|
||||
}
|
||||
|
||||
AddToSubset(fParentWindow);
|
||||
|
||||
BRect backgroundRect = Bounds();
|
||||
backgroundRect.InsetBy(-1, -1);
|
||||
BView *backgroundView = new BBox(backgroundRect, "bgView", B_FOLLOW_ALL);
|
||||
BView *backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(backgroundView);
|
||||
|
||||
BMenu *menu = new BPopUpMenu("");
|
||||
|
||||
menu->AddItem(new BMenuItem("starts with", NULL));
|
||||
menu->AddItem(new BMenuItem("ends with", NULL));
|
||||
menu->AddItem(new BMenuItem("contains", NULL));
|
||||
@ -78,14 +76,14 @@ SelectionWindow::SelectionWindow(BContainerWindow *window)
|
||||
menu->SetLabelFromMarked(true);
|
||||
menu->ItemAt(3)->SetMarked(true);
|
||||
// Set wildcard matching to default.
|
||||
|
||||
|
||||
// Set up the menu field
|
||||
fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0),
|
||||
NULL, "Name", menu);
|
||||
backgroundView->AddChild(fMatchingTypeMenuField);
|
||||
fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth("Name") + 8);
|
||||
fMatchingTypeMenuField->ResizeToPreferred();
|
||||
|
||||
|
||||
// Set up the expression text control
|
||||
fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField->
|
||||
Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL,
|
||||
@ -93,13 +91,13 @@ SelectionWindow::SelectionWindow(BContainerWindow *window)
|
||||
backgroundView->AddChild(fExpressionTextControl);
|
||||
fExpressionTextControl->ResizeToPreferred();
|
||||
fExpressionTextControl->MakeFocus(true);
|
||||
|
||||
|
||||
// Set up the Invert checkbox
|
||||
fInverseCheckBox = new BCheckBox(BRect(7, fExpressionTextControl->Frame().bottom
|
||||
+ 6, 6, 6), NULL, "Invert", NULL);
|
||||
backgroundView->AddChild(fInverseCheckBox);
|
||||
fInverseCheckBox->ResizeToPreferred();
|
||||
|
||||
|
||||
// Set up the Ignore Case checkbox
|
||||
fIgnoreCaseCheckBox = new BCheckBox(BRect(fInverseCheckBox->Frame().right + 10,
|
||||
fInverseCheckBox->Frame().top, 6, 6), NULL, "Ignore case", NULL);
|
||||
@ -110,17 +108,17 @@ SelectionWindow::SelectionWindow(BContainerWindow *window)
|
||||
// Set up the Select button
|
||||
fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, "Select",
|
||||
new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT);
|
||||
|
||||
|
||||
backgroundView->AddChild(fSelectButton);
|
||||
fSelectButton->ResizeToPreferred();
|
||||
fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
|
||||
fExpressionTextControl->Frame().bottom + 9);
|
||||
fSelectButton->MakeDefault(true);
|
||||
#if !B_BEOS_VERSION_DANO
|
||||
#if !B_BEOS_VERSION_DANO
|
||||
fSelectButton->SetLowColor(backgroundView->ViewColor());
|
||||
fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
font_height fh;
|
||||
be_plain_font->GetHeight(&fh);
|
||||
// Center the checkboxes vertically to the button
|
||||
@ -140,45 +138,43 @@ SelectionWindow::SelectionWindow(BContainerWindow *window)
|
||||
Lock();
|
||||
ResizeTo(minWidth, fSelectButton->Frame().bottom + 6);
|
||||
|
||||
SetSizeLimits(
|
||||
/* Minimum Width */ minWidth,
|
||||
/* Maximum Width */ 1280,
|
||||
/* Minimum Height */ Bounds().bottom,
|
||||
/* Maximum Height */ Bounds().bottom);
|
||||
SetSizeLimits(minWidth, 1280, Bounds().bottom, Bounds().bottom);
|
||||
|
||||
MoveCloseToMouse();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectionWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kSelectButtonPressed:
|
||||
{
|
||||
Hide();
|
||||
// Order of posting and hiding important
|
||||
// since we want to activate the target
|
||||
// window when the message arrives.
|
||||
// (Hide is synhcronous, while PostMessage is not.)
|
||||
// See PoseView::SelectMatchingEntries().
|
||||
|
||||
BMessage *selectionInfo = new BMessage(kSelectMatchingEntries);
|
||||
selectionInfo->AddInt32("ExpressionType", ExpressionType());
|
||||
BString expression;
|
||||
Expression(expression);
|
||||
selectionInfo->AddString("Expression", expression.String());
|
||||
selectionInfo->AddBool("InvertSelection", Invert());
|
||||
selectionInfo->AddBool("IgnoreCase", IgnoreCase());
|
||||
fParentWindow->PostMessage(selectionInfo);
|
||||
}
|
||||
{
|
||||
Hide();
|
||||
// Order of posting and hiding important
|
||||
// since we want to activate the target
|
||||
// window when the message arrives.
|
||||
// (Hide is synhcronous, while PostMessage is not.)
|
||||
// See PoseView::SelectMatchingEntries().
|
||||
|
||||
BMessage *selectionInfo = new BMessage(kSelectMatchingEntries);
|
||||
selectionInfo->AddInt32("ExpressionType", ExpressionType());
|
||||
BString expression;
|
||||
Expression(expression);
|
||||
selectionInfo->AddString("Expression", expression.String());
|
||||
selectionInfo->AddBool("InvertSelection", Invert());
|
||||
selectionInfo->AddBool("IgnoreCase", IgnoreCase());
|
||||
fParentWindow->PostMessage(selectionInfo);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
_inherited::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SelectionWindow::QuitRequested()
|
||||
{
|
||||
@ -186,73 +182,77 @@ SelectionWindow::QuitRequested()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectionWindow::MoveCloseToMouse()
|
||||
{
|
||||
uint32 buttons;
|
||||
BPoint mousePosition;
|
||||
|
||||
|
||||
ChildAt((int32)0)->GetMouse(&mousePosition, &buttons);
|
||||
ConvertToScreen(&mousePosition);
|
||||
|
||||
|
||||
// Position the window centered around the mouse...
|
||||
BPoint windowPosition = BPoint(mousePosition.x - Frame().Width() / 2,
|
||||
mousePosition.y - Frame().Height() / 2);
|
||||
|
||||
|
||||
// ... unless that's outside of the current screen size:
|
||||
BScreen screen;
|
||||
windowPosition.x = MAX(0, MIN(screen.Frame().right - Frame().Width(),
|
||||
windowPosition.x));
|
||||
windowPosition.y = MAX(0, MIN(screen.Frame().bottom - Frame().Height(),
|
||||
windowPosition.y));
|
||||
|
||||
|
||||
MoveTo(windowPosition);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TrackerStringExpressionType
|
||||
SelectionWindow::ExpressionType() const
|
||||
{
|
||||
if (!fMatchingTypeMenuField->LockLooper())
|
||||
return kNone;
|
||||
|
||||
|
||||
BMenuItem *item = fMatchingTypeMenuField->Menu()->FindMarked();
|
||||
if (!item) {
|
||||
fMatchingTypeMenuField->UnlockLooper();
|
||||
return kNone;
|
||||
}
|
||||
|
||||
|
||||
int32 index = fMatchingTypeMenuField->Menu()->IndexOf(item);
|
||||
|
||||
fMatchingTypeMenuField->UnlockLooper();
|
||||
|
||||
|
||||
if (index < kStartsWith || index > kRegexpMatch)
|
||||
return kNone;
|
||||
|
||||
|
||||
TrackerStringExpressionType typeArray[] = { kStartsWith, kEndsWith,
|
||||
kContains, kGlobMatch, kRegexpMatch};
|
||||
|
||||
|
||||
return typeArray[index];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SelectionWindow::Expression(BString &result) const
|
||||
{
|
||||
if (!fExpressionTextControl->LockLooper())
|
||||
return;
|
||||
|
||||
|
||||
result = fExpressionTextControl->Text();
|
||||
|
||||
fExpressionTextControl->UnlockLooper();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SelectionWindow::IgnoreCase() const
|
||||
{
|
||||
if (!fIgnoreCaseCheckBox->LockLooper())
|
||||
return true; // default action.
|
||||
|
||||
if (!fIgnoreCaseCheckBox->LockLooper()) {
|
||||
// default action.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ignore = fIgnoreCaseCheckBox->Value() != 0;
|
||||
|
||||
fIgnoreCaseCheckBox->UnlockLooper();
|
||||
@ -260,12 +260,15 @@ SelectionWindow::IgnoreCase() const
|
||||
return ignore;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SelectionWindow::Invert() const
|
||||
{
|
||||
if (!fInverseCheckBox->LockLooper())
|
||||
return false; // default action.
|
||||
|
||||
if (!fInverseCheckBox->LockLooper()) {
|
||||
// default action.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool inverse = fInverseCheckBox->Value() != 0;
|
||||
|
||||
fInverseCheckBox->UnlockLooper();
|
||||
|
@ -50,8 +50,6 @@ All rights reserved.
|
||||
|
||||
|
||||
static const uint32 kSpaceBarSwitchColor = 'SBsc';
|
||||
static const float kBorderSpacing = 5.0f;
|
||||
static const float kItemHeight = 18.0f;
|
||||
static const float kItemExtraSpacing = 2.0f;
|
||||
static const float kIndentSpacing = 12.0f;
|
||||
|
||||
@ -73,7 +71,7 @@ send_bool_notices(uint32 what, const char *name, bool value)
|
||||
|
||||
|
||||
SettingsView::SettingsView(BRect rect, const char *name)
|
||||
: BView(rect, name, B_FOLLOW_ALL_SIDES, 0)
|
||||
: BView(rect, name, B_FOLLOW_ALL, 0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -144,59 +142,65 @@ SettingsView::IsRevertable() const
|
||||
DesktopSettingsView::DesktopSettingsView(BRect rect)
|
||||
: SettingsView(rect, "DesktopSettingsView")
|
||||
{
|
||||
BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width()
|
||||
- 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fShowDisksIconRadioButton = new BRadioButton(frame, "", "Show Disks Icon",
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fShowDisksIconRadioButton = new BRadioButton(rect, "", "Show Disks Icon",
|
||||
new BMessage(kShowDisksIconChanged));
|
||||
AddChild(fShowDisksIconRadioButton);
|
||||
fShowDisksIconRadioButton->ResizeToPreferred();
|
||||
AddChild(fShowDisksIconRadioButton);
|
||||
|
||||
const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fMountVolumesOntoDesktopRadioButton =
|
||||
new BRadioButton(frame, "", "Show Volumes On Desktop",
|
||||
new BMessage(kVolumesOnDesktopChanged));
|
||||
fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
|
||||
"Show Volumes On Desktop", new BMessage(kVolumesOnDesktopChanged));
|
||||
AddChild(fMountVolumesOntoDesktopRadioButton);
|
||||
fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
|
||||
|
||||
frame.OffsetBy(20, itemSpacing);
|
||||
rect.OffsetBy(20, itemSpacing);
|
||||
|
||||
fMountSharedVolumesOntoDesktopCheckBox =
|
||||
new BCheckBox(frame, "", "Show Shared Volumes On Desktop",
|
||||
new BMessage(kVolumesOnDesktopChanged));
|
||||
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
|
||||
"Show Shared Volumes On Desktop", new BMessage(kVolumesOnDesktopChanged));
|
||||
AddChild(fMountSharedVolumesOntoDesktopCheckBox);
|
||||
fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
|
||||
|
||||
frame.OffsetBy(-20, 2 * itemSpacing);
|
||||
rect.OffsetBy(-20, 2 * itemSpacing);
|
||||
|
||||
fIntegrateNonBootBeOSDesktopsCheckBox =
|
||||
new BCheckBox(frame, "", "Integrate Non-Boot BeOS Desktops",
|
||||
new BMessage(kDesktopIntegrationChanged));
|
||||
fIntegrateNonBootBeOSDesktopsCheckBox = new BCheckBox(rect, "",
|
||||
"Integrate Non-Boot BeOS Desktops", new BMessage(kDesktopIntegrationChanged));
|
||||
AddChild(fIntegrateNonBootBeOSDesktopsCheckBox);
|
||||
fIntegrateNonBootBeOSDesktopsCheckBox->ResizeToPreferred();
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fEjectWhenUnmountingCheckBox =
|
||||
new BCheckBox(frame, "", "Eject When Unmounting",
|
||||
new BMessage(kEjectWhenUnmountingChanged));
|
||||
fEjectWhenUnmountingCheckBox = new BCheckBox(rect, "", "Eject When Unmounting",
|
||||
new BMessage(kEjectWhenUnmountingChanged));
|
||||
AddChild(fEjectWhenUnmountingCheckBox);
|
||||
fEjectWhenUnmountingCheckBox->ResizeToPreferred();
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect = Bounds();
|
||||
rect.top = rect.bottom;
|
||||
fMountButton = new BButton(rect, "", "Mount Settings" B_UTF8_ELLIPSIS,
|
||||
new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fMountButton->ResizeToPreferred();
|
||||
fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
|
||||
AddChild(fMountButton);
|
||||
|
||||
BButton *button =
|
||||
new BButton(BRect(kBorderSpacing, rect.Height() - kBorderSpacing - 20,
|
||||
kBorderSpacing + 100, rect.Height() - kBorderSpacing),
|
||||
"", "Mount Settings"B_UTF8_ELLIPSIS, new BMessage(kRunAutomounterSettings));
|
||||
AddChild(button);
|
||||
fMountButton->SetTarget(be_app);
|
||||
}
|
||||
|
||||
button->ResizeToPreferred();
|
||||
button->MoveBy(0, rect.Height() - kBorderSpacing - button->Frame().bottom);
|
||||
button->SetTarget(be_app);
|
||||
|
||||
void
|
||||
DesktopSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL) {
|
||||
*_width = max_c(fIntegrateNonBootBeOSDesktopsCheckBox->Frame().right,
|
||||
fMountSharedVolumesOntoDesktopCheckBox->Frame().right);
|
||||
}
|
||||
|
||||
if (_height != NULL) {
|
||||
*_height = fEjectWhenUnmountingCheckBox->Frame().bottom + 8
|
||||
+ fMountButton->Bounds().Height();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -438,50 +442,51 @@ DesktopSettingsView::IsRevertable() const
|
||||
WindowsSettingsView::WindowsSettingsView(BRect rect)
|
||||
: SettingsView(rect, "WindowsSettingsView")
|
||||
{
|
||||
BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width()
|
||||
- 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fShowFullPathInTitleBarCheckBox = new BCheckBox(frame, "", "Show Full Path In Title Bar",
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "", "Show Full Path In Title Bar",
|
||||
new BMessage(kWindowsShowFullPathChanged));
|
||||
AddChild(fShowFullPathInTitleBarCheckBox);
|
||||
fShowFullPathInTitleBarCheckBox->ResizeToPreferred();
|
||||
AddChild(fShowFullPathInTitleBarCheckBox);
|
||||
|
||||
const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing;
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
fSingleWindowBrowseCheckBox = new BCheckBox(frame, "", "Single Window Browse",
|
||||
fSingleWindowBrowseCheckBox = new BCheckBox(rect, "", "Single Window Browse",
|
||||
new BMessage(kSingleWindowBrowseChanged));
|
||||
AddChild(fSingleWindowBrowseCheckBox);
|
||||
fSingleWindowBrowseCheckBox->ResizeToPreferred();
|
||||
AddChild(fSingleWindowBrowseCheckBox);
|
||||
|
||||
frame.OffsetBy(20, itemSpacing);
|
||||
rect.OffsetBy(20, itemSpacing);
|
||||
|
||||
fShowNavigatorCheckBox = new BCheckBox(frame, "", "Show Navigator",
|
||||
fShowNavigatorCheckBox = new BCheckBox(rect, "", "Show Navigator",
|
||||
new BMessage(kShowNavigatorChanged));
|
||||
AddChild(fShowNavigatorCheckBox);
|
||||
fShowNavigatorCheckBox->ResizeToPreferred();
|
||||
AddChild(fShowNavigatorCheckBox);
|
||||
|
||||
frame.OffsetBy(-20, itemSpacing);
|
||||
rect.OffsetBy(-20, itemSpacing);
|
||||
|
||||
fShowSelectionWhenInactiveCheckBox = new BCheckBox(frame, "", "Show Selection When Inactive",
|
||||
new BMessage(kShowSelectionWhenInactiveChanged));
|
||||
AddChild(fShowSelectionWhenInactiveCheckBox);
|
||||
fShowSelectionWhenInactiveCheckBox->ResizeToPreferred();
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
fOutlineSelectionCheckBox = new BCheckBox(frame, "", "Outline Selection Rectangle Only",
|
||||
fOutlineSelectionCheckBox = new BCheckBox(rect, "", "Outline Selection Rectangle Only",
|
||||
new BMessage(kTransparentSelectionChanged));
|
||||
AddChild(fOutlineSelectionCheckBox);
|
||||
fOutlineSelectionCheckBox->ResizeToPreferred();
|
||||
AddChild(fOutlineSelectionCheckBox);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fSortFolderNamesFirstCheckBox = new BCheckBox(frame, "", "Sort Folder Names First",
|
||||
fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "", "Sort Folder Names First",
|
||||
new BMessage(kSortFolderNamesFirstChanged));
|
||||
AddChild(fSortFolderNamesFirstCheckBox);
|
||||
fSortFolderNamesFirstCheckBox->ResizeToPreferred();
|
||||
AddChild(fSortFolderNamesFirstCheckBox);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WindowsSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL)
|
||||
*_width = fOutlineSelectionCheckBox->Frame().right;
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fSortFolderNamesFirstCheckBox->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
@ -491,7 +496,6 @@ WindowsSettingsView::AttachedToWindow()
|
||||
fSingleWindowBrowseCheckBox->SetTarget(this);
|
||||
fShowNavigatorCheckBox->SetTarget(this);
|
||||
fShowFullPathInTitleBarCheckBox->SetTarget(this);
|
||||
fShowSelectionWhenInactiveCheckBox->SetTarget(this);
|
||||
fOutlineSelectionCheckBox->SetTarget(this);
|
||||
fSortFolderNamesFirstCheckBox->SetTarget(this);
|
||||
}
|
||||
@ -532,19 +536,6 @@ WindowsSettingsView::MessageReceived(BMessage *message)
|
||||
Window()->PostMessage(kSettingsContentsModified);
|
||||
break;
|
||||
|
||||
case kShowSelectionWhenInactiveChanged:
|
||||
{
|
||||
settings.SetShowSelectionWhenInactive(
|
||||
fShowSelectionWhenInactiveCheckBox->Value() == 1);
|
||||
|
||||
// Make the notification message and send it to the tracker:
|
||||
send_bool_notices(kShowSelectionWhenInactiveChanged,
|
||||
"ShowSelectionWhenInactive", fShowSelectionWhenInactiveCheckBox->Value() == 1);
|
||||
|
||||
Window()->PostMessage(kSettingsContentsModified);
|
||||
break;
|
||||
}
|
||||
|
||||
case kTransparentSelectionChanged:
|
||||
{
|
||||
settings.SetTransparentSelection(
|
||||
@ -601,12 +592,6 @@ WindowsSettingsView::SetDefaults()
|
||||
tracker->SendNotices(kShowNavigatorChanged);
|
||||
}
|
||||
|
||||
if (!settings.ShowSelectionWhenInactive()) {
|
||||
settings.SetShowSelectionWhenInactive(true);
|
||||
send_bool_notices(kShowSelectionWhenInactiveChanged,
|
||||
"ShowSelectionWhenInactive", true);
|
||||
}
|
||||
|
||||
if (!settings.TransparentSelection()) {
|
||||
settings.SetTransparentSelection(true);
|
||||
send_bool_notices(kTransparentSelectionChanged,
|
||||
@ -647,12 +632,6 @@ WindowsSettingsView::Revert()
|
||||
tracker->SendNotices(kShowNavigatorChanged);
|
||||
}
|
||||
|
||||
if (settings.ShowSelectionWhenInactive() != fShowSelectionWhenInactive) {
|
||||
settings.SetShowSelectionWhenInactive(fShowSelectionWhenInactive);
|
||||
send_bool_notices(kShowSelectionWhenInactiveChanged,
|
||||
"ShowSelectionWhenInactive", fShowSelectionWhenInactive);
|
||||
}
|
||||
|
||||
if (settings.TransparentSelection() != fTransparentSelection) {
|
||||
settings.SetTransparentSelection(fTransparentSelection);
|
||||
send_bool_notices(kTransparentSelectionChanged,
|
||||
@ -678,7 +657,6 @@ WindowsSettingsView::ShowCurrentSettings()
|
||||
fSingleWindowBrowseCheckBox->SetValue(settings.SingleWindowBrowse());
|
||||
fShowNavigatorCheckBox->SetEnabled(settings.SingleWindowBrowse());
|
||||
fShowNavigatorCheckBox->SetValue(settings.ShowNavigator());
|
||||
fShowSelectionWhenInactiveCheckBox->SetValue(settings.ShowSelectionWhenInactive());
|
||||
fOutlineSelectionCheckBox->SetValue(settings.TransparentSelection()
|
||||
? B_CONTROL_OFF : B_CONTROL_ON);
|
||||
fSortFolderNamesFirstCheckBox->SetValue(settings.SortFolderNamesFirst());
|
||||
@ -693,7 +671,6 @@ WindowsSettingsView::RecordRevertSettings()
|
||||
fShowFullPathInTitleBar = settings.ShowFullPathInTitleBar();
|
||||
fSingleWindowBrowse = settings.SingleWindowBrowse();
|
||||
fShowNavigator = settings.ShowNavigator();
|
||||
fShowSelectionWhenInactive = settings.ShowSelectionWhenInactive();
|
||||
fTransparentSelection = settings.TransparentSelection();
|
||||
fSortFolderNamesFirst = settings.SortFolderNamesFirst();
|
||||
}
|
||||
@ -707,7 +684,6 @@ WindowsSettingsView::IsRevertable() const
|
||||
return fShowFullPathInTitleBar != settings.ShowFullPathInTitleBar()
|
||||
|| fSingleWindowBrowse != settings.SingleWindowBrowse()
|
||||
|| fShowNavigator != settings.ShowNavigator()
|
||||
|| fShowSelectionWhenInactive != settings.ShowSelectionWhenInactive()
|
||||
|| fTransparentSelection != settings.TransparentSelection()
|
||||
|| fSortFolderNamesFirst != settings.SortFolderNamesFirst();
|
||||
}
|
||||
@ -716,319 +692,68 @@ WindowsSettingsView::IsRevertable() const
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
FilePanelSettingsView::FilePanelSettingsView(BRect rect)
|
||||
: SettingsView(rect, "FilePanelSettingsView")
|
||||
{
|
||||
BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width()
|
||||
- 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fDesktopFilePanelRootCheckBox = new BCheckBox(frame, "", "File Panel Root is Desktop",
|
||||
new BMessage(kDesktopFilePanelRootChanged));
|
||||
AddChild(fDesktopFilePanelRootCheckBox);
|
||||
fDesktopFilePanelRootCheckBox->ResizeToPreferred();
|
||||
|
||||
const float itemSpacing = fDesktopFilePanelRootCheckBox->Bounds().Height() + kItemExtraSpacing;
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
BRect recentBoxFrame(kBorderSpacing, frame.bottom, rect.Width() - kBorderSpacing, frame.top);
|
||||
|
||||
BBox *recentBox = new BBox(recentBoxFrame, "recentBox");
|
||||
recentBox->SetLabel("Recent" B_UTF8_ELLIPSIS);
|
||||
|
||||
AddChild(recentBox);
|
||||
|
||||
frame = recentBoxFrame.OffsetToCopy(0,0);
|
||||
frame.OffsetTo(kBorderSpacing, 3 * kBorderSpacing);
|
||||
|
||||
frame.right = StringWidth("##Applications###10##");
|
||||
float divider = StringWidth("Applications") + 10;
|
||||
|
||||
fRecentDocumentsTextControl = new BTextControl(frame, "", "Documents", "10",
|
||||
new BMessage(kFavoriteCountChanged));
|
||||
|
||||
fRecentDocumentsTextControl->SetDivider(divider);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
fRecentFoldersTextControl = new BTextControl(frame, "", "Folders", "10",
|
||||
new BMessage(kFavoriteCountChanged));
|
||||
|
||||
fRecentFoldersTextControl->SetDivider(divider);
|
||||
|
||||
recentBox->AddChild(fRecentDocumentsTextControl);
|
||||
recentBox->AddChild(fRecentFoldersTextControl);
|
||||
|
||||
recentBox->ResizeTo(recentBox->Frame().Width(), fRecentFoldersTextControl->Frame().bottom + kBorderSpacing);
|
||||
|
||||
be_app->LockLooper();
|
||||
be_app->StartWatching(this, kFavoriteCountChangedExternally);
|
||||
be_app->UnlockLooper();
|
||||
}
|
||||
|
||||
|
||||
FilePanelSettingsView::~FilePanelSettingsView()
|
||||
{
|
||||
be_app->LockLooper();
|
||||
be_app->StopWatching(this, kFavoriteCountChangedExternally);
|
||||
be_app->UnlockLooper();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::AttachedToWindow()
|
||||
{
|
||||
fDesktopFilePanelRootCheckBox->SetTarget(this);
|
||||
fRecentDocumentsTextControl->SetTarget(this);
|
||||
fRecentFoldersTextControl->SetTarget(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::MessageReceived(BMessage *message)
|
||||
{
|
||||
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
||||
if (!tracker)
|
||||
return;
|
||||
TrackerSettings settings;
|
||||
|
||||
switch (message->what) {
|
||||
case kDesktopFilePanelRootChanged:
|
||||
{
|
||||
settings.SetDesktopFilePanelRoot(fDesktopFilePanelRootCheckBox->Value() == 1);
|
||||
|
||||
// Make the notification message and send it to the tracker:
|
||||
BMessage message;
|
||||
message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1);
|
||||
tracker->SendNotices(kDesktopFilePanelRootChanged, &message);
|
||||
|
||||
Window()->PostMessage(kSettingsContentsModified);
|
||||
break;
|
||||
}
|
||||
|
||||
case kFavoriteCountChanged:
|
||||
{
|
||||
_GetAndRefreshDisplayedFigures();
|
||||
settings.SetRecentDocumentsCount(fDisplayedDocCount);
|
||||
settings.SetRecentFoldersCount(fDisplayedFolderCount);
|
||||
|
||||
// Make the notification message and send it to the tracker:
|
||||
BMessage message;
|
||||
message.AddInt32("RecentDocuments", fDisplayedDocCount);
|
||||
message.AddInt32("RecentFolders", fDisplayedFolderCount);
|
||||
tracker->SendNotices(kFavoriteCountChanged, &message);
|
||||
|
||||
Window()->PostMessage(kSettingsContentsModified);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_OBSERVER_NOTICE_CHANGE:
|
||||
{
|
||||
int32 observerWhat;
|
||||
if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK
|
||||
&& (uint32)observerWhat == kFavoriteCountChangedExternally) {
|
||||
int32 count;
|
||||
if (message->FindInt32("RecentApplications", &count) == B_OK) {
|
||||
settings.SetRecentApplicationsCount(count);
|
||||
ShowCurrentSettings();
|
||||
}
|
||||
|
||||
if (message->FindInt32("RecentDocuments", &count) == B_OK) {
|
||||
settings.SetRecentDocumentsCount(count);
|
||||
ShowCurrentSettings();
|
||||
}
|
||||
|
||||
if (message->FindInt32("RecentFolders", &count) == B_OK) {
|
||||
settings.SetRecentFoldersCount(count);
|
||||
ShowCurrentSettings();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
_inherited::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::SetDefaults()
|
||||
{
|
||||
TrackerSettings settings;
|
||||
|
||||
settings.SetDesktopFilePanelRoot(true);
|
||||
settings.SetRecentDocumentsCount(10);
|
||||
settings.SetRecentFoldersCount(10);
|
||||
|
||||
ShowCurrentSettings();
|
||||
_SendNotices();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::Revert()
|
||||
{
|
||||
TrackerSettings settings;
|
||||
|
||||
settings.SetDesktopFilePanelRoot(fDesktopFilePanelRoot);
|
||||
settings.SetRecentDocumentsCount(fRecentDocuments);
|
||||
settings.SetRecentFoldersCount(fRecentFolders);
|
||||
|
||||
ShowCurrentSettings();
|
||||
_SendNotices();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::_SendNotices()
|
||||
{
|
||||
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
||||
if (!tracker)
|
||||
return;
|
||||
|
||||
TrackerSettings settings;
|
||||
|
||||
// Make the notification message and send it to the tracker:
|
||||
|
||||
BMessage message;
|
||||
message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1);
|
||||
tracker->SendNotices(kDesktopFilePanelRootChanged, &message);
|
||||
|
||||
int32 recentApplications, recentDocuments, recentFolders;
|
||||
settings.RecentCounts(&recentApplications, &recentDocuments, &recentFolders);
|
||||
|
||||
message.AddInt32("RecentDocuments", recentDocuments);
|
||||
message.AddInt32("RecentFolders", recentFolders);
|
||||
tracker->SendNotices(kFavoriteCountChanged, &message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::ShowCurrentSettings()
|
||||
{
|
||||
TrackerSettings settings;
|
||||
|
||||
fDesktopFilePanelRootCheckBox->SetValue(settings.DesktopFilePanelRoot());
|
||||
|
||||
int32 recentApplications, recentDocuments, recentFolders;
|
||||
settings.RecentCounts(&recentApplications, &recentDocuments, &recentFolders);
|
||||
|
||||
BString docCountText;
|
||||
docCountText << recentDocuments;
|
||||
fRecentDocumentsTextControl->SetText(docCountText.String());
|
||||
|
||||
BString folderCountText;
|
||||
folderCountText << recentFolders;
|
||||
fRecentFoldersTextControl->SetText(folderCountText.String());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::RecordRevertSettings()
|
||||
{
|
||||
TrackerSettings settings;
|
||||
|
||||
fDesktopFilePanelRoot = settings.DesktopFilePanelRoot();
|
||||
settings.RecentCounts(&fRecentApplications, &fRecentDocuments, &fRecentFolders);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FilePanelSettingsView::IsRevertable() const
|
||||
{
|
||||
_GetAndRefreshDisplayedFigures();
|
||||
|
||||
return fDesktopFilePanelRoot != (fDesktopFilePanelRootCheckBox->Value() > 0)
|
||||
|| fDisplayedDocCount != fRecentDocuments
|
||||
|| fDisplayedFolderCount != fRecentFolders;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FilePanelSettingsView::_GetAndRefreshDisplayedFigures() const
|
||||
{
|
||||
sscanf(fRecentDocumentsTextControl->Text(), "%ld", &fDisplayedDocCount);
|
||||
sscanf(fRecentFoldersTextControl->Text(), "%ld", &fDisplayedFolderCount);
|
||||
|
||||
BString docCountText;
|
||||
docCountText << fDisplayedDocCount;
|
||||
fRecentDocumentsTextControl->SetText(docCountText.String());
|
||||
|
||||
BString folderCountText;
|
||||
folderCountText << fDisplayedFolderCount;
|
||||
fRecentFoldersTextControl->SetText(folderCountText.String());
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
|
||||
: SettingsView(rect, "WindowsSettingsView")
|
||||
{
|
||||
BRect clockBoxFrame = BRect(kBorderSpacing, kBorderSpacing,
|
||||
rect.Width() / 2 - 4 * kBorderSpacing, kBorderSpacing + 5 * kItemHeight);
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
|
||||
BBox *clockBox = new BBox(clockBoxFrame, "Clock");
|
||||
font_height fontHeight;
|
||||
be_bold_font->GetHeight(&fontHeight);
|
||||
|
||||
rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10;
|
||||
BBox *clockBox = new BBox(rect, "Clock");
|
||||
clockBox->SetLabel("Clock");
|
||||
|
||||
AddChild(clockBox);
|
||||
|
||||
BRect frame = BRect(kBorderSpacing, 2.5f*kBorderSpacing,
|
||||
clockBoxFrame.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
f24HrRadioButton = new BRadioButton(frame, "", "24 Hour",
|
||||
rect.left = 8;
|
||||
rect.top = rect.bottom - 8;
|
||||
f24HrRadioButton = new BRadioButton(rect, "", "24 Hour",
|
||||
new BMessage(kSettingsContentsModified));
|
||||
clockBox->AddChild(f24HrRadioButton);
|
||||
f24HrRadioButton->ResizeToPreferred();
|
||||
clockBox->AddChild(f24HrRadioButton);
|
||||
|
||||
const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing;
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
f12HrRadioButton = new BRadioButton(frame, "", "12 Hour",
|
||||
f12HrRadioButton = new BRadioButton(rect, "", "12 Hour",
|
||||
new BMessage(kSettingsContentsModified));
|
||||
clockBox->AddChild(f12HrRadioButton);
|
||||
f12HrRadioButton->ResizeToPreferred();
|
||||
clockBox->AddChild(f12HrRadioButton);
|
||||
|
||||
clockBox->ResizeTo(clockBox->Bounds().Width(), f12HrRadioButton->Frame().bottom + kBorderSpacing);
|
||||
float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f;
|
||||
clockBox->ResizeTo(width, clockBox->Bounds().Height()
|
||||
+ 3 * f12HrRadioButton->Frame().Height());
|
||||
|
||||
BRect dateFormatBoxFrame = BRect(clockBoxFrame.right + kBorderSpacing, kBorderSpacing,
|
||||
rect.right - kBorderSpacing, kBorderSpacing + 5 * itemSpacing);
|
||||
|
||||
BBox *dateFormatBox = new BBox(dateFormatBoxFrame, "Date Order");
|
||||
rect = clockBox->Frame();
|
||||
rect.OffsetBy(rect.Width() + 8, 0);
|
||||
BBox *dateFormatBox = new BBox(rect, "Date Order");
|
||||
dateFormatBox->SetLabel("Date Order");
|
||||
|
||||
AddChild(dateFormatBox);
|
||||
|
||||
frame = BRect(kBorderSpacing, 2.5f*kBorderSpacing,
|
||||
dateFormatBoxFrame.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fYMDRadioButton = new BRadioButton(frame, "", "Year-Month-Day",
|
||||
rect = f24HrRadioButton->Frame();
|
||||
fYMDRadioButton = new BRadioButton(rect, "", "Year-Month-Day",
|
||||
new BMessage(kSettingsContentsModified));
|
||||
dateFormatBox->AddChild(fYMDRadioButton);
|
||||
fYMDRadioButton->ResizeToPreferred();
|
||||
dateFormatBox->AddChild(fYMDRadioButton);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fDMYRadioButton = new BRadioButton(frame, "", "Day-Month-Year",
|
||||
fDMYRadioButton = new BRadioButton(rect, "", "Day-Month-Year",
|
||||
new BMessage(kSettingsContentsModified));
|
||||
dateFormatBox->AddChild(fDMYRadioButton);
|
||||
fDMYRadioButton->ResizeToPreferred();
|
||||
dateFormatBox->AddChild(fDMYRadioButton);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fMDYRadioButton = new BRadioButton(frame, "", "Month-Day-Year",
|
||||
fMDYRadioButton = new BRadioButton(rect, "", "Month-Day-Year",
|
||||
new BMessage(kSettingsContentsModified));
|
||||
dateFormatBox->AddChild(fMDYRadioButton);
|
||||
fMDYRadioButton->ResizeToPreferred();
|
||||
dateFormatBox->AddChild(fMDYRadioButton);
|
||||
|
||||
dateFormatBox->ResizeTo(dateFormatBox->Bounds().Width(), fMDYRadioButton->Frame().bottom + kBorderSpacing);
|
||||
dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16,
|
||||
dateFormatBox->Bounds().Height());
|
||||
|
||||
BPopUpMenu *menu = new BPopUpMenu("Separator");
|
||||
|
||||
menu->AddItem(new BMenuItem("None", new BMessage(kSettingsContentsModified)));
|
||||
menu->AddItem(new BMenuItem("Space", new BMessage(kSettingsContentsModified)));
|
||||
menu->AddItem(new BMenuItem("-", new BMessage(kSettingsContentsModified)));
|
||||
@ -1036,35 +761,54 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
|
||||
menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified)));
|
||||
menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified)));
|
||||
|
||||
frame = BRect(clockBox->Frame().left, dateFormatBox->Frame().bottom + kBorderSpacing,
|
||||
rect.right - kBorderSpacing, dateFormatBox->Frame().bottom + kBorderSpacing + itemSpacing);
|
||||
|
||||
fSeparatorMenuField = new BMenuField(frame, "Separator", "Separator", menu);
|
||||
rect.left = 0;
|
||||
rect.top = clockBox->Frame().bottom + 8;
|
||||
rect.right = Bounds().Width() - 8;
|
||||
rect.bottom = rect.top + itemSpacing;
|
||||
fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu);
|
||||
fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f);
|
||||
fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT);
|
||||
fSeparatorMenuField->ResizeToPreferred();
|
||||
AddChild(fSeparatorMenuField);
|
||||
|
||||
frame.OffsetBy(0, 30.0f);
|
||||
rect.OffsetBy(0, itemSpacing + 10);
|
||||
|
||||
BStringView *exampleView = new BStringView(frame, "", "Examples:");
|
||||
AddChild(exampleView);
|
||||
BStringView *exampleView = new BStringView(rect, "", "Examples:");
|
||||
exampleView->ResizeToPreferred();
|
||||
AddChild(exampleView);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fLongDateExampleView = new BStringView(frame, "", "");
|
||||
AddChild(fLongDateExampleView);
|
||||
fLongDateExampleView = new BStringView(rect, "", "");
|
||||
fLongDateExampleView->ResizeToPreferred();
|
||||
AddChild(fLongDateExampleView);
|
||||
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
rect.OffsetBy(0, itemSpacing);
|
||||
|
||||
fShortDateExampleView = new BStringView(frame, "", "");
|
||||
AddChild(fShortDateExampleView);
|
||||
fShortDateExampleView = new BStringView(rect, "", "");
|
||||
fShortDateExampleView->ResizeToPreferred();
|
||||
AddChild(fShortDateExampleView);
|
||||
|
||||
_UpdateExamples();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL) {
|
||||
BView* view = fMDYRadioButton->Parent();
|
||||
if (view != NULL)
|
||||
*_width = view->Frame().right;
|
||||
else
|
||||
*_width = Bounds().Width();
|
||||
}
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fShortDateExampleView->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TimeFormatSettingsView::AttachedToWindow()
|
||||
{
|
||||
@ -1284,16 +1028,15 @@ TimeFormatSettingsView::_UpdateExamples()
|
||||
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||
: SettingsView(rect, "SpaceBarSettingsView")
|
||||
{
|
||||
BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width()
|
||||
- 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fSpaceBarShowCheckBox = new BCheckBox(frame, "", "Show Space Bars On Volumes",
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fSpaceBarShowCheckBox = new BCheckBox(rect, "", "Show Space Bars On Volumes",
|
||||
new BMessage(kUpdateVolumeSpaceBar));
|
||||
AddChild(fSpaceBarShowCheckBox);
|
||||
fSpaceBarShowCheckBox->ResizeToPreferred();
|
||||
float itemSpacing = fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing;
|
||||
frame.OffsetBy(0, itemSpacing);
|
||||
|
||||
AddChild(fSpaceBarShowCheckBox);
|
||||
|
||||
rect = fSpaceBarShowCheckBox->Frame();
|
||||
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
|
||||
|
||||
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
|
||||
menu->SetFont(be_plain_font);
|
||||
|
||||
@ -1304,8 +1047,8 @@ SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||
menu->AddItem(new BMenuItem("Free Space Color", new BMessage(kSpaceBarSwitchColor)));
|
||||
menu->AddItem(new BMenuItem("Warning Space Color", new BMessage(kSpaceBarSwitchColor)));
|
||||
|
||||
BBox *box = new BBox(frame);
|
||||
box->SetLabel(fColorPicker = new BMenuField(frame, NULL, NULL, menu));
|
||||
BBox *box = new BBox(rect);
|
||||
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
|
||||
AddChild(box);
|
||||
|
||||
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
|
||||
@ -1314,6 +1057,7 @@ SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
||||
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
|
||||
fColorControl->ResizeToPreferred();
|
||||
box->AddChild(fColorControl);
|
||||
|
||||
box->ResizeTo(fColorControl->Bounds().Width() + 16,
|
||||
fColorControl->Frame().bottom + 8);
|
||||
}
|
||||
@ -1324,6 +1068,26 @@ SpaceBarSettingsView::~SpaceBarSettingsView()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
BView* view = fColorControl->Parent();
|
||||
if (view == NULL)
|
||||
BView::GetPreferredSize(_width, _height);
|
||||
|
||||
if (_width != NULL) {
|
||||
float width = fSpaceBarShowCheckBox->Bounds().Width();
|
||||
if (view->Bounds().Width() > width)
|
||||
width = view->Bounds().Width();
|
||||
|
||||
*_width = width;
|
||||
}
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = view->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpaceBarSettingsView::AttachedToWindow()
|
||||
{
|
||||
@ -1500,20 +1264,35 @@ SpaceBarSettingsView::IsRevertable() const
|
||||
TrashSettingsView::TrashSettingsView(BRect rect)
|
||||
: SettingsView(rect, "TrashSettingsView")
|
||||
{
|
||||
BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width()
|
||||
- 2 * kBorderSpacing, kBorderSpacing + kItemHeight);
|
||||
|
||||
fDontMoveFilesToTrashCheckBox = new BCheckBox(frame, "", "Don't Move Files To Trash",
|
||||
rect.OffsetTo(B_ORIGIN);
|
||||
fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "", "Don't Move Files To Trash",
|
||||
new BMessage(kDontMoveFilesToTrashChanged));
|
||||
AddChild(fDontMoveFilesToTrashCheckBox);
|
||||
fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
|
||||
AddChild(fDontMoveFilesToTrashCheckBox);
|
||||
|
||||
frame.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
|
||||
rect = fDontMoveFilesToTrashCheckBox->Frame();
|
||||
rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
|
||||
|
||||
fAskBeforeDeleteFileCheckBox = new BCheckBox(frame, "", "Ask Before Delete",
|
||||
fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "", "Ask Before Delete",
|
||||
new BMessage(kAskBeforeDeleteFileChanged));
|
||||
AddChild(fAskBeforeDeleteFileCheckBox);
|
||||
fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
|
||||
AddChild(fAskBeforeDeleteFileCheckBox);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrashSettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
{
|
||||
if (_width != NULL) {
|
||||
float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();
|
||||
if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())
|
||||
width = fAskBeforeDeleteFileCheckBox->Bounds().Width();
|
||||
|
||||
*_width = width;
|
||||
}
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@ All rights reserved.
|
||||
|
||||
const uint32 kSettingsContentsModified = 'Scmo';
|
||||
|
||||
class BButton;
|
||||
class BMenuField;
|
||||
class BStringView;
|
||||
|
||||
@ -71,6 +72,7 @@ class DesktopSettingsView : public SettingsView {
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
@ -86,6 +88,7 @@ class DesktopSettingsView : public SettingsView {
|
||||
BCheckBox *fMountSharedVolumesOntoDesktopCheckBox;
|
||||
BCheckBox *fIntegrateNonBootBeOSDesktopsCheckBox;
|
||||
BCheckBox *fEjectWhenUnmountingCheckBox;
|
||||
BButton *fMountButton;
|
||||
|
||||
bool fShowDisksIcon;
|
||||
bool fMountVolumesOntoDesktop;
|
||||
@ -102,6 +105,7 @@ class WindowsSettingsView : public SettingsView {
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
@ -120,56 +124,19 @@ class WindowsSettingsView : public SettingsView {
|
||||
bool fShowFullPathInTitleBar;
|
||||
bool fSingleWindowBrowse;
|
||||
bool fShowNavigator;
|
||||
bool fShowSelectionWhenInactive;
|
||||
bool fTransparentSelection;
|
||||
bool fSortFolderNamesFirst;
|
||||
|
||||
typedef SettingsView _inherited;
|
||||
};
|
||||
|
||||
class FilePanelSettingsView : public SettingsView {
|
||||
public:
|
||||
FilePanelSettingsView(BRect frame);
|
||||
virtual ~FilePanelSettingsView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
virtual void ShowCurrentSettings();
|
||||
virtual void RecordRevertSettings();
|
||||
virtual bool IsRevertable() const;
|
||||
|
||||
|
||||
private:
|
||||
void _GetAndRefreshDisplayedFigures() const;
|
||||
void _SendNotices();
|
||||
|
||||
BCheckBox *fDesktopFilePanelRootCheckBox;
|
||||
|
||||
BTextControl *fRecentApplicationsTextControl; // Not used for the moment.
|
||||
BTextControl *fRecentDocumentsTextControl;
|
||||
BTextControl *fRecentFoldersTextControl;
|
||||
|
||||
bool fDesktopFilePanelRoot;
|
||||
int32 fRecentApplications; // Not used for the moment,
|
||||
int32 fRecentDocuments;
|
||||
int32 fRecentFolders;
|
||||
|
||||
mutable int32 fDisplayedAppCount; // Not used for the moment.
|
||||
mutable int32 fDisplayedDocCount;
|
||||
mutable int32 fDisplayedFolderCount;
|
||||
|
||||
typedef SettingsView _inherited;
|
||||
};
|
||||
|
||||
class TimeFormatSettingsView : public SettingsView {
|
||||
public:
|
||||
TimeFormatSettingsView(BRect frame);
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
@ -208,6 +175,7 @@ class SpaceBarSettingsView : public SettingsView {
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
@ -235,7 +203,8 @@ class TrashSettingsView : public SettingsView {
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
|
||||
virtual void SetDefaults();
|
||||
virtual void Revert();
|
||||
virtual void ShowCurrentSettings();
|
||||
|
@ -37,12 +37,26 @@ All rights reserved.
|
||||
#include "TrackerSettings.h"
|
||||
#include "TrackerSettingsWindow.h"
|
||||
|
||||
#include <CheckBox.h>
|
||||
//#include <CheckBox.h>
|
||||
#include <ScrollView.h>
|
||||
|
||||
|
||||
const BPoint kSettingsWindowOffset(30, 30);
|
||||
const float kSettingsWindowsWidth = 370;
|
||||
const float kSettingsWindowsHeight = 270;
|
||||
namespace BPrivate {
|
||||
|
||||
class SettingsItem : public BStringItem {
|
||||
public:
|
||||
SettingsItem(const char *label, SettingsView *view);
|
||||
|
||||
void DrawItem(BView *owner, BRect rect, bool drawEverything);
|
||||
|
||||
SettingsView *View();
|
||||
|
||||
private:
|
||||
SettingsView *fSettingsView;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
const uint32 kSettingsViewChanged = 'Svch';
|
||||
const uint32 kDefaultsButtonPressed = 'Apbp';
|
||||
@ -50,85 +64,81 @@ const uint32 kRevertButtonPressed = 'Rebp';
|
||||
|
||||
|
||||
TrackerSettingsWindow::TrackerSettingsWindow()
|
||||
: BWindow(BRect(kSettingsWindowOffset.x, kSettingsWindowOffset.y,
|
||||
kSettingsWindowOffset.x + kSettingsWindowsWidth,
|
||||
kSettingsWindowOffset.y + kSettingsWindowsHeight),
|
||||
"Tracker Settings", B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
||||
| B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE
|
||||
| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
: BWindow(BRect(80, 80, 450, 350), "Tracker Settings", B_TITLED_WINDOW,
|
||||
B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_NO_WORKSPACE_ACTIVATION
|
||||
| B_NOT_ANCHORED_ON_ACTIVATE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
{
|
||||
BView *backgroundView = new BView(Bounds(), "Background", B_FOLLOW_ALL_SIDES, 0);
|
||||
BRect rect = Bounds();
|
||||
BView *topView = new BView(rect, "Background", B_FOLLOW_ALL, 0);
|
||||
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(topView);
|
||||
|
||||
backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(backgroundView);
|
||||
|
||||
const float kBorderDistance = 12;
|
||||
const float kListViewWidth = 90;
|
||||
const float kListViewHeight = kSettingsWindowsHeight - 2 * kBorderDistance;
|
||||
const float kBoxWidth = kSettingsWindowsWidth - kListViewWidth - 3 * (kBorderDistance - 1);
|
||||
const float kBoxHeight = kListViewHeight - 30;
|
||||
|
||||
BRect listViewRect(kBorderDistance, kBorderDistance, kBorderDistance + kListViewWidth,
|
||||
kBorderDistance + kListViewHeight);
|
||||
|
||||
BBox *borderBox = new BBox(listViewRect.InsetByCopy(-2, -2));
|
||||
|
||||
backgroundView->AddChild(borderBox);
|
||||
|
||||
listViewRect.OffsetTo(2, 2);
|
||||
listViewRect.right -= 1;
|
||||
|
||||
fSettingsTypeListView = new BListView(listViewRect, "List View");
|
||||
|
||||
borderBox->AddChild(fSettingsTypeListView);
|
||||
|
||||
fSettingsContainerBox = new BBox(BRect(kBorderDistance + kListViewWidth + kBorderDistance,
|
||||
kBorderDistance, kBorderDistance + kListViewWidth + kBorderDistance + kBoxWidth,
|
||||
kBorderDistance + kBoxHeight));
|
||||
|
||||
backgroundView->AddChild(fSettingsContainerBox);
|
||||
|
||||
const float kButtonTop = fSettingsContainerBox->Frame().bottom + kBorderDistance;
|
||||
const float kDefaultsButtonLeft = fSettingsContainerBox->Frame().left;
|
||||
const float kButtonWidth = 45;
|
||||
const float kButtonHeight = 20;
|
||||
|
||||
fDefaultsButton = new BButton(BRect(kDefaultsButtonLeft, kButtonTop,
|
||||
kDefaultsButtonLeft + kButtonWidth, kButtonTop + kButtonHeight),
|
||||
"Defaults", "Defaults", new BMessage(kDefaultsButtonPressed));
|
||||
|
||||
backgroundView->AddChild(fDefaultsButton);
|
||||
rect.InsetBy(10, 10);
|
||||
rect.right = rect.left + be_plain_font->StringWidth("Volume Icons")
|
||||
+ B_V_SCROLL_BAR_WIDTH + 40.0f;
|
||||
fSettingsTypeListView = new BListView(rect, "List View", B_SINGLE_SELECTION_LIST,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
|
||||
BScrollView* scrollView = new BScrollView("scrollview", fSettingsTypeListView,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||
topView->AddChild(scrollView);
|
||||
|
||||
rect = scrollView->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
rect.top = rect.bottom;
|
||||
fDefaultsButton = new BButton(rect, "Defaults", "Defaults",
|
||||
new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fDefaultsButton->ResizeToPreferred();
|
||||
fDefaultsButton->SetEnabled(true);
|
||||
|
||||
fRevertButton = new BButton(BRect(fDefaultsButton->Frame().right + kBorderDistance,
|
||||
kButtonTop, fDefaultsButton->Frame().right + kBorderDistance + kButtonWidth, kButtonTop
|
||||
+ kButtonHeight), "Revert", "Revert", new BMessage(kRevertButtonPressed));
|
||||
fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height());
|
||||
topView->AddChild(fDefaultsButton);
|
||||
|
||||
rect = fDefaultsButton->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
fRevertButton = new BButton(rect, "Revert", "Revert",
|
||||
new BMessage(kRevertButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fRevertButton->SetEnabled(false);
|
||||
fRevertButton->ResizeToPreferred();
|
||||
backgroundView->AddChild(fRevertButton);
|
||||
topView->AddChild(fRevertButton);
|
||||
|
||||
BRect SettingsViewSize = fSettingsContainerBox->Bounds().InsetByCopy(5, 5);
|
||||
rect = scrollView->Frame();
|
||||
rect.left = rect.right + 10;
|
||||
rect.right = Bounds().right - 10;
|
||||
rect.bottom = fDefaultsButton->Frame().top - 10;
|
||||
fSettingsContainerBox = new BBox(rect, NULL, B_FOLLOW_ALL);
|
||||
topView->AddChild(fSettingsContainerBox);
|
||||
|
||||
SettingsViewSize.top += 10;
|
||||
rect = _SettingsFrame();
|
||||
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("Desktop",
|
||||
new DesktopSettingsView(SettingsViewSize)));
|
||||
new DesktopSettingsView(rect)));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("Windows",
|
||||
new WindowsSettingsView(SettingsViewSize)));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("File Panel",
|
||||
new FilePanelSettingsView(SettingsViewSize)));
|
||||
new WindowsSettingsView(rect)));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("Time Format",
|
||||
new TimeFormatSettingsView(SettingsViewSize)));
|
||||
new TimeFormatSettingsView(rect)));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("Trash",
|
||||
new TrashSettingsView(SettingsViewSize)));
|
||||
new TrashSettingsView(rect)));
|
||||
fSettingsTypeListView->AddItem(new SettingsItem("Volume Icons",
|
||||
new SpaceBarSettingsView(SettingsViewSize)));
|
||||
new SpaceBarSettingsView(rect)));
|
||||
|
||||
// compute preferred view size
|
||||
|
||||
float minWidth = 0, minHeight = 0;
|
||||
|
||||
for (int32 i = 0; i < fSettingsTypeListView->CountItems(); i++) {
|
||||
SettingsView* view = ((SettingsItem *)fSettingsTypeListView->ItemAt(i))->View();
|
||||
|
||||
float width, height;
|
||||
view->GetPreferredSize(&width, &height);
|
||||
|
||||
if (minWidth < width)
|
||||
minWidth = width;
|
||||
if (minHeight < height)
|
||||
minHeight = height;
|
||||
}
|
||||
|
||||
ResizeBy(max_c(minWidth - rect.Width(), 0), max_c(minHeight - rect.Height(), 0));
|
||||
// make sure window is large enough to contain all views
|
||||
|
||||
fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged));
|
||||
|
||||
fSettingsTypeListView->Select(0);
|
||||
}
|
||||
|
||||
@ -158,19 +168,19 @@ TrackerSettingsWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kSettingsContentsModified:
|
||||
HandleChangedContents();
|
||||
_HandleChangedContents();
|
||||
break;
|
||||
|
||||
case kDefaultsButtonPressed:
|
||||
HandlePressedDefaultsButton();
|
||||
_HandlePressedDefaultsButton();
|
||||
break;
|
||||
|
||||
case kRevertButtonPressed:
|
||||
HandlePressedRevertButton();
|
||||
_HandlePressedRevertButton();
|
||||
break;
|
||||
|
||||
case kSettingsViewChanged:
|
||||
HandleChangedSettingsView();
|
||||
_HandleChangedSettingsView();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -186,8 +196,8 @@ TrackerSettingsWindow::Show()
|
||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
ViewAt(i)->RecordRevertSettings();
|
||||
ViewAt(i)->ShowCurrentSettings();
|
||||
_ViewAt(i)->RecordRevertSettings();
|
||||
_ViewAt(i)->ShowCurrentSettings();
|
||||
}
|
||||
|
||||
fSettingsTypeListView->Invalidate();
|
||||
@ -199,7 +209,7 @@ TrackerSettingsWindow::Show()
|
||||
|
||||
|
||||
SettingsView *
|
||||
TrackerSettingsWindow::ViewAt(int32 i)
|
||||
TrackerSettingsWindow::_ViewAt(int32 i)
|
||||
{
|
||||
if (!Lock())
|
||||
return NULL;
|
||||
@ -212,15 +222,28 @@ TrackerSettingsWindow::ViewAt(int32 i)
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
TrackerSettingsWindow::_SettingsFrame()
|
||||
{
|
||||
font_height fontHeight;
|
||||
be_bold_font->GetHeight(&fontHeight);
|
||||
|
||||
BRect rect = fSettingsContainerBox->Bounds().InsetByCopy(8, 8);
|
||||
rect.top += ceilf(fontHeight.ascent + fontHeight.descent);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::HandleChangedContents()
|
||||
TrackerSettingsWindow::_HandleChangedContents()
|
||||
{
|
||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||
|
||||
bool revertable = false;
|
||||
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
revertable |= ViewAt(i)->IsRevertable();
|
||||
revertable |= _ViewAt(i)->IsRevertable();
|
||||
}
|
||||
|
||||
fSettingsTypeListView->Invalidate();
|
||||
@ -231,33 +254,33 @@ TrackerSettingsWindow::HandleChangedContents()
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::HandlePressedDefaultsButton()
|
||||
TrackerSettingsWindow::_HandlePressedDefaultsButton()
|
||||
{
|
||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||
|
||||
for (int32 i = 0; i < itemCount; i++)
|
||||
ViewAt(i)->SetDefaults();
|
||||
_ViewAt(i)->SetDefaults();
|
||||
|
||||
HandleChangedContents();
|
||||
_HandleChangedContents();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::HandlePressedRevertButton()
|
||||
TrackerSettingsWindow::_HandlePressedRevertButton()
|
||||
{
|
||||
int32 itemCount = fSettingsTypeListView->CountItems();
|
||||
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
if (ViewAt(i)->IsRevertable())
|
||||
ViewAt(i)->Revert();
|
||||
if (_ViewAt(i)->IsRevertable())
|
||||
_ViewAt(i)->Revert();
|
||||
}
|
||||
|
||||
HandleChangedContents();
|
||||
_HandleChangedContents();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackerSettingsWindow::HandleChangedSettingsView()
|
||||
TrackerSettingsWindow::_HandleChangedSettingsView()
|
||||
{
|
||||
int32 currentSelection = fSettingsTypeListView->CurrentSelection();
|
||||
if (currentSelection < 0)
|
||||
@ -273,8 +296,17 @@ TrackerSettingsWindow::HandleChangedSettingsView()
|
||||
|
||||
if (selectedItem) {
|
||||
fSettingsContainerBox->SetLabel(selectedItem->Text());
|
||||
selectedItem->View()->SetViewColor(fSettingsContainerBox->ViewColor());
|
||||
fSettingsContainerBox->AddChild(selectedItem->View());
|
||||
|
||||
BView *view = selectedItem->View();
|
||||
view->SetViewColor(fSettingsContainerBox->ViewColor());
|
||||
view->Hide();
|
||||
fSettingsContainerBox->AddChild(view);
|
||||
|
||||
// Resize view after it has been attached to the window, so that
|
||||
// it's resizing modes are respected
|
||||
BRect rect = _SettingsFrame();
|
||||
view->ResizeTo(rect.Width(), rect.Height());
|
||||
view->Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _TRACKER_SETTINGS_WINDOW
|
||||
#define _TRACKER_SETTINGS_WINDOW
|
||||
#ifndef TRACKER_SETTINGS_WINDOW_H
|
||||
#define TRACKER_SETTINGS_WINDOW_H
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
@ -54,14 +54,16 @@ class TrackerSettingsWindow : public BWindow {
|
||||
void MessageReceived(BMessage *message);
|
||||
void Show();
|
||||
|
||||
SettingsView *ViewAt(int32 i);
|
||||
|
||||
void HandleChangedContents();
|
||||
void HandlePressedDefaultsButton();
|
||||
void HandlePressedRevertButton();
|
||||
void HandleChangedSettingsView();
|
||||
|
||||
private:
|
||||
SettingsView *_ViewAt(int32 i);
|
||||
BRect _SettingsFrame();
|
||||
|
||||
void _HandleChangedContents();
|
||||
void _HandlePressedDefaultsButton();
|
||||
void _HandlePressedRevertButton();
|
||||
void _HandleChangedSettingsView();
|
||||
|
||||
BListView *fSettingsTypeListView;
|
||||
BBox *fSettingsContainerBox;
|
||||
BButton *fDefaultsButton;
|
||||
@ -70,21 +72,8 @@ class TrackerSettingsWindow : public BWindow {
|
||||
typedef BWindow _inherited;
|
||||
};
|
||||
|
||||
|
||||
class SettingsItem : public BStringItem {
|
||||
public:
|
||||
SettingsItem(const char *label, SettingsView *view);
|
||||
|
||||
void DrawItem(BView *owner, BRect rect, bool drawEverything);
|
||||
|
||||
SettingsView *View();
|
||||
|
||||
private:
|
||||
SettingsView *fSettingsView;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
#endif // _TRACKER_SETTINGS_WINDOW
|
||||
#endif // TRACKER_SETTINGS_WINDOW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user