Ticket #5889: tracker.2.patch
File tracker.2.patch, 25.5 KB (added by , 14 years ago) |
---|
-
VolumeWindow.cpp
85 85 } 86 86 } 87 87 88 BMenuItem* item = fMenuBar->FindItem( B_TRANSLATE("Unmount"));88 BMenuItem* item = fMenuBar->FindItem(kUnmountVolume); 89 89 if (item) 90 90 item->SetEnabled(ejectableVolumeSelected); 91 91 } -
SettingsViews.cpp
44 44 #include <Box.h> 45 45 #include <Button.h> 46 46 #include <Catalog.h> 47 #include <ControlLook.h> 48 #include <GroupLayoutBuilder.h> 47 49 #include <Locale.h> 48 50 #include <MenuField.h> 49 51 #include <ColorControl.h> … … 83 85 #undef B_TRANSLATE_CONTEXT 84 86 #define B_TRANSLATE_CONTEXT "libtracker" 85 87 86 SettingsView::SettingsView( BRect rect, const char *name)87 : B View(rect, name, B_FOLLOW_ALL, 0)88 SettingsView::SettingsView() 89 : BGroupView() 88 90 { 89 91 } 90 92 … … 165 167 // #pragma mark - 166 168 167 169 168 DesktopSettingsView::DesktopSettingsView( BRect rect)169 : SettingsView( rect, "DesktopSettingsView")170 DesktopSettingsView::DesktopSettingsView() 171 : SettingsView() 170 172 { 171 rect.OffsetTo(B_ORIGIN); 172 fShowDisksIconRadioButton = new BRadioButton(rect, "", 173 fShowDisksIconRadioButton = new BRadioButton("", 173 174 B_TRANSLATE("Show Disks icon"), 174 175 new BMessage(kShowDisksIconChanged)); 175 fShowDisksIconRadioButton->ResizeToPreferred();176 AddChild(fShowDisksIconRadioButton);177 176 178 const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing; 179 rect.OffsetBy(0, itemSpacing); 180 181 fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "", 177 fMountVolumesOntoDesktopRadioButton = new BRadioButton("", 182 178 B_TRANSLATE("Show volumes on Desktop"), 183 179 new BMessage(kVolumesOnDesktopChanged)); 184 AddChild(fMountVolumesOntoDesktopRadioButton);185 fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();186 180 187 rect.OffsetBy(20, itemSpacing); 188 189 fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "", 181 fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox("", 190 182 B_TRANSLATE("Show shared volumes on Desktop"), 191 183 new BMessage(kVolumesOnDesktopChanged)); 192 AddChild(fMountSharedVolumesOntoDesktopCheckBox);193 fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();194 184 195 rect.OffsetBy(-20, itemSpacing); 196 197 rect = Bounds(); 198 rect.top = rect.bottom; 199 fMountButton = new BButton(rect, "", 185 fMountButton = new BButton("", 200 186 B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS), 201 new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 202 fMountButton->ResizeToPreferred(); 203 fMountButton->MoveBy(0, -fMountButton->Bounds().Height()); 204 AddChild(fMountButton); 187 new BMessage(kRunAutomounterSettings)); 205 188 206 fMountButton->SetTarget(be_app); 207 } 189 const float spacing = be_control_look->DefaultItemSpacing(); 208 190 191 BGroupLayoutBuilder(this) 192 .AddGroup(B_VERTICAL) 193 .Add(fShowDisksIconRadioButton) 194 .Add(fMountVolumesOntoDesktopRadioButton) 195 .AddGroup(B_VERTICAL) 196 .Add(fMountSharedVolumesOntoDesktopCheckBox) 197 .SetInsets(20, 0, 0, 0) 198 .End() 199 .AddGlue() 200 .AddGroup(B_HORIZONTAL) 201 .Add(fMountButton) 202 .AddGlue() 203 .End() 204 .End() 205 .SetInsets(spacing, spacing, spacing, spacing); 209 206 210 void 211 DesktopSettingsView::GetPreferredSize(float *_width, float *_height) 212 { 213 if (_width != NULL) { 214 *_width = fMountSharedVolumesOntoDesktopCheckBox->Frame().right; 215 } 216 217 if (_height != NULL) { 218 *_height = fMountSharedVolumesOntoDesktopCheckBox->Frame().bottom + 8 219 + fMountButton->Bounds().Height(); 220 } 207 fMountButton->SetTarget(be_app); 221 208 } 222 209 223 210 … … 414 401 // #pragma mark - 415 402 416 403 417 WindowsSettingsView::WindowsSettingsView( BRect rect)418 : SettingsView( rect, "WindowsSettingsView")404 WindowsSettingsView::WindowsSettingsView() 405 : SettingsView() 419 406 { 420 rect.OffsetTo(B_ORIGIN); 421 fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "", 407 fShowFullPathInTitleBarCheckBox = new BCheckBox("", 422 408 B_TRANSLATE("Show folder location in title tab"), 423 409 new BMessage(kWindowsShowFullPathChanged)); 424 fShowFullPathInTitleBarCheckBox->ResizeToPreferred();425 AddChild(fShowFullPathInTitleBarCheckBox);426 410 427 const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing; 428 rect.OffsetBy(0, itemSpacing); 429 430 fSingleWindowBrowseCheckBox = new BCheckBox(rect, "", 411 fSingleWindowBrowseCheckBox = new BCheckBox("", 431 412 B_TRANSLATE("Single window navigation"), 432 413 new BMessage(kSingleWindowBrowseChanged)); 433 fSingleWindowBrowseCheckBox->ResizeToPreferred();434 AddChild(fSingleWindowBrowseCheckBox);435 414 436 rect.OffsetBy(20, itemSpacing); 437 438 fShowNavigatorCheckBox = new BCheckBox(rect, "", 415 fShowNavigatorCheckBox = new BCheckBox("", 439 416 B_TRANSLATE("Show navigator"), 440 417 new BMessage(kShowNavigatorChanged)); 441 fShowNavigatorCheckBox->ResizeToPreferred();442 AddChild(fShowNavigatorCheckBox);443 418 444 rect.OffsetBy(-20, itemSpacing); 445 446 fOutlineSelectionCheckBox = new BCheckBox(rect, "", 419 fOutlineSelectionCheckBox = new BCheckBox("", 447 420 B_TRANSLATE("Outline selection rectangle only"), 448 421 new BMessage(kTransparentSelectionChanged)); 449 fOutlineSelectionCheckBox->ResizeToPreferred();450 AddChild(fOutlineSelectionCheckBox);451 422 452 rect.OffsetBy(0, itemSpacing); 453 454 fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "", 423 fSortFolderNamesFirstCheckBox = new BCheckBox("", 455 424 B_TRANSLATE("List folders first"), 456 425 new BMessage(kSortFolderNamesFirstChanged)); 457 fSortFolderNamesFirstCheckBox->ResizeToPreferred();458 AddChild(fSortFolderNamesFirstCheckBox);459 426 460 rect.OffsetBy(0, itemSpacing); 461 462 fTypeAheadFilteringCheckBox = new BCheckBox(rect, "", 427 fTypeAheadFilteringCheckBox = new BCheckBox("", 463 428 B_TRANSLATE("Enable type-ahead filtering"), 464 429 new BMessage(kTypeAheadFilteringChanged)); 465 fTypeAheadFilteringCheckBox->ResizeToPreferred();466 AddChild(fTypeAheadFilteringCheckBox);467 }468 430 431 const float spacing = be_control_look->DefaultItemSpacing(); 469 432 470 void 471 WindowsSettingsView::GetPreferredSize(float *_width, float *_height) 472 { 473 if (_width != NULL) 474 *_width = fOutlineSelectionCheckBox->Frame().right; 475 476 if (_height != NULL) 477 *_height = fSortFolderNamesFirstCheckBox->Frame().bottom; 433 BGroupLayoutBuilder(this) 434 .AddGroup(B_VERTICAL) 435 .AddGroup(B_VERTICAL) 436 .Add(fShowFullPathInTitleBarCheckBox) 437 .Add(fSingleWindowBrowseCheckBox) 438 .End() 439 .AddGroup(B_VERTICAL) 440 .Add(fShowNavigatorCheckBox) 441 .SetInsets(20, 0, 0, 0) 442 .End() 443 .AddGroup(B_VERTICAL) 444 .Add(fOutlineSelectionCheckBox) 445 .Add(fSortFolderNamesFirstCheckBox) 446 .Add(fTypeAheadFilteringCheckBox) 447 .End() 448 .AddGlue() 449 .End() 450 .SetInsets(spacing, spacing, spacing, spacing); 478 451 } 479 452 480 453 … … 719 692 // #pragma mark - 720 693 721 694 722 TimeFormatSettingsView::TimeFormatSettingsView( BRect rect)723 : SettingsView( rect, "WindowsSettingsView")695 TimeFormatSettingsView::TimeFormatSettingsView() 696 : SettingsView() 724 697 { 725 rect.OffsetTo(B_ORIGIN);726 698 727 font_height fontHeight; 728 be_bold_font->GetHeight(&fontHeight); 729 730 rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10; 731 BBox *clockBox = new BBox(rect, "Clock"); 699 BBox* clockBox = new BBox("Clock"); 732 700 clockBox->SetLabel(B_TRANSLATE("Clock")); 733 AddChild(clockBox);734 701 735 rect.left = 8; 736 rect.top = rect.bottom - 8; 737 f24HrRadioButton = new BRadioButton(rect, "", 702 f24HrRadioButton = new BRadioButton("", 738 703 B_TRANSLATE("24 hour"), 739 704 new BMessage(kSettingsContentsModified)); 740 f24HrRadioButton->ResizeToPreferred();741 clockBox->AddChild(f24HrRadioButton);742 705 743 const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing; 744 rect.OffsetBy(0, itemSpacing); 745 746 f12HrRadioButton = new BRadioButton(rect, "", 706 f12HrRadioButton = new BRadioButton("", 747 707 B_TRANSLATE("12 hour"), 748 708 new BMessage(kSettingsContentsModified)); 749 f12HrRadioButton->ResizeToPreferred();750 clockBox->AddChild(f12HrRadioButton);751 709 752 float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f; 753 clockBox->ResizeTo(width, clockBox->Bounds().Height() 754 + 3 * f12HrRadioButton->Frame().Height()); 710 const float spacing = be_control_look->DefaultItemSpacing(); 755 711 756 rect = clockBox->Frame(); 757 rect.OffsetBy(rect.Width() + 8, 0); 758 BBox *dateFormatBox = new BBox(rect, "Date order"); 712 BGroupView* view = new BGroupView(); 713 BGroupLayoutBuilder(view) 714 .AddGroup(B_VERTICAL) 715 .Add(f24HrRadioButton) 716 .Add(f12HrRadioButton) 717 .AddGlue() 718 .SetInsets(spacing, spacing, spacing, spacing) 719 .End(); 720 721 clockBox->AddChild(view); 722 723 BBox* dateFormatBox = new BBox("Date order"); 759 724 dateFormatBox->SetLabel(B_TRANSLATE("Date order")); 760 AddChild(dateFormatBox);761 725 762 rect = f24HrRadioButton->Frame(); 763 fYMDRadioButton = new BRadioButton(rect, "", 726 fYMDRadioButton = new BRadioButton("", 764 727 B_TRANSLATE("Year-month-day"), 765 728 new BMessage(kSettingsContentsModified)); 766 fYMDRadioButton->ResizeToPreferred();767 dateFormatBox->AddChild(fYMDRadioButton);768 729 769 rect.OffsetBy(0, itemSpacing); 770 771 fDMYRadioButton = new BRadioButton(rect, "", 730 fDMYRadioButton = new BRadioButton("", 772 731 B_TRANSLATE("Day-month-year"), 773 732 new BMessage(kSettingsContentsModified)); 774 fDMYRadioButton->ResizeToPreferred();775 dateFormatBox->AddChild(fDMYRadioButton);776 733 777 rect.OffsetBy(0, itemSpacing); 778 779 fMDYRadioButton = new BRadioButton(rect, "", 734 fMDYRadioButton = new BRadioButton("", 780 735 B_TRANSLATE("Month-day-year"), 781 736 new BMessage(kSettingsContentsModified)); 782 fMDYRadioButton->ResizeToPreferred();783 dateFormatBox->AddChild(fMDYRadioButton);784 737 785 dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16, 786 dateFormatBox->Bounds().Height()); 738 view = new BGroupView(); 739 BGroupLayoutBuilder(view) 740 .AddGroup(B_VERTICAL) 741 .Add(fYMDRadioButton) 742 .Add(fDMYRadioButton) 743 .Add(fMDYRadioButton) 744 .AddGlue() 745 .SetInsets(spacing, spacing, spacing, spacing) 746 .End(); 787 747 788 BPopUpMenu *menu = new BPopUpMenu("Separator"); 748 dateFormatBox->AddChild(view); 749 750 BPopUpMenu* menu = new BPopUpMenu("Separator"); 789 751 menu->AddItem(new BMenuItem(B_TRANSLATE("None"), 790 752 new BMessage(kSettingsContentsModified))); 791 753 menu->AddItem(new BMenuItem(B_TRANSLATE("Space"), … … 795 757 menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified))); 796 758 menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified))); 797 759 798 rect.left = 0; 799 rect.top = clockBox->Frame().bottom + 8; 800 rect.right = Bounds().Width() - 8; 801 rect.bottom = rect.top + itemSpacing; 802 fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu); 803 fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f); 760 fSeparatorMenuField = new BMenuField("Separator", "Separator:", menu); 804 761 fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT); 805 fSeparatorMenuField->ResizeToPreferred();806 AddChild(fSeparatorMenuField);807 762 808 rect.OffsetBy(0, itemSpacing + 10);763 BStringView* exampleView = new BStringView("", B_TRANSLATE("Examples:")); 809 764 810 BStringView* exampleView = new BStringView(rect, "", B_TRANSLATE("Examples:")); 811 exampleView->ResizeToPreferred(); 812 AddChild(exampleView); 765 fLongDateExampleView = new BStringView("", ""); 813 766 814 rect.OffsetBy(0, itemSpacing);767 fShortDateExampleView = new BStringView("", ""); 815 768 816 fLongDateExampleView = new BStringView(rect, "", ""); 817 fLongDateExampleView->ResizeToPreferred(); 818 AddChild(fLongDateExampleView); 769 BGroupLayoutBuilder(this) 770 .AddGroup(B_VERTICAL) 771 .AddGroup(B_HORIZONTAL) 772 .Add(clockBox) 773 .Add(dateFormatBox) 774 .End() 775 .AddGroup(B_HORIZONTAL) 776 .Add(fSeparatorMenuField) 777 .AddGlue() 778 .End() 779 .AddGroup(B_HORIZONTAL) 780 .Add(exampleView) 781 .AddGlue() 782 .End() 783 .AddGroup(B_HORIZONTAL) 784 .Add(fLongDateExampleView) 785 .AddGlue() 786 .End() 787 .AddGroup(B_HORIZONTAL) 788 .Add(fShortDateExampleView) 789 .AddGlue() 790 .End() 791 .AddGlue() 792 .SetInsets(spacing, spacing, spacing, spacing) 793 .End(); 819 794 820 rect.OffsetBy(0, itemSpacing);821 822 fShortDateExampleView = new BStringView(rect, "", "");823 fShortDateExampleView->ResizeToPreferred();824 AddChild(fShortDateExampleView);825 826 795 _UpdateExamples(); 827 796 } 828 797 829 798 830 799 void 831 TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)832 {833 if (_width != NULL) {834 BView* view = fMDYRadioButton->Parent();835 if (view != NULL)836 *_width = view->Frame().right;837 else838 *_width = Bounds().Width();839 }840 841 if (_height != NULL)842 *_height = fShortDateExampleView->Frame().bottom;843 }844 845 846 void847 800 TimeFormatSettingsView::AttachedToWindow() 848 801 { 849 802 f24HrRadioButton->SetTarget(this); … … 1070 1023 // #pragma mark - 1071 1024 1072 1025 1073 SpaceBarSettingsView::SpaceBarSettingsView( BRect rect)1074 : SettingsView( rect, "SpaceBarSettingsView")1026 SpaceBarSettingsView::SpaceBarSettingsView() 1027 : SettingsView() 1075 1028 { 1076 rect.OffsetTo(B_ORIGIN); 1077 fSpaceBarShowCheckBox = new BCheckBox(rect, "", 1029 fSpaceBarShowCheckBox = new BCheckBox("", 1078 1030 B_TRANSLATE("Show space bars on volumes"), 1079 1031 new BMessage(kUpdateVolumeSpaceBar)); 1080 fSpaceBarShowCheckBox->ResizeToPreferred();1081 AddChild(fSpaceBarShowCheckBox);1082 1032 1083 rect = fSpaceBarShowCheckBox->Frame(); 1084 rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing); 1085 1086 BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING); 1033 BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING); 1087 1034 menu->SetFont(be_plain_font); 1088 1035 1089 BMenuItem *item;1036 BMenuItem* item; 1090 1037 menu->AddItem(item = new BMenuItem( 1091 1038 B_TRANSLATE("Used space color"), 1092 1039 new BMessage(kSpaceBarSwitchColor))); … … 1099 1046 B_TRANSLATE("Warning space color"), 1100 1047 new BMessage(kSpaceBarSwitchColor))); 1101 1048 1102 BBox *box = new BBox(rect); 1103 box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu)); 1104 AddChild(box); 1049 BBox* box = new BBox("box"); 1050 box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu)); 1105 1051 1106 1052 fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height() 1107 1053 + 8 + kItemExtraSpacing), 1108 1054 B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged)); 1109 1055 fColorControl->SetValue(TrackerSettings().UsedSpaceColor()); 1110 fColorControl->ResizeToPreferred();1111 1056 box->AddChild(fColorControl); 1112 1057 1113 box->ResizeTo(fColorControl->Bounds().Width() + 16, 1114 fColorControl->Frame().bottom + 8); 1115 } 1058 const float spacing = be_control_look->DefaultItemSpacing(); 1116 1059 1060 BGroupLayoutBuilder(this) 1061 .AddGroup(B_VERTICAL) 1062 .Add(fSpaceBarShowCheckBox) 1063 .Add(box) 1064 .AddGlue() 1065 .End() 1066 .SetInsets(spacing, spacing, spacing, spacing); 1117 1067 1118 SpaceBarSettingsView::~SpaceBarSettingsView()1119 {1120 1068 } 1121 1069 1122 1070 1123 void 1124 SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height) 1071 SpaceBarSettingsView::~SpaceBarSettingsView() 1125 1072 { 1126 BView* view = fColorControl->Parent();1127 if (view == NULL)1128 BView::GetPreferredSize(_width, _height);1129 1130 if (_width != NULL) {1131 float width = fSpaceBarShowCheckBox->Bounds().Width();1132 if (view->Bounds().Width() > width)1133 width = view->Bounds().Width();1134 1135 *_width = width;1136 }1137 1138 if (_height != NULL)1139 *_height = view->Frame().bottom;1140 1073 } 1141 1074 1142 1075 … … 1327 1260 // #pragma mark - 1328 1261 1329 1262 1330 TrashSettingsView::TrashSettingsView( BRect rect)1331 : SettingsView( rect, "TrashSettingsView")1263 TrashSettingsView::TrashSettingsView() 1264 : SettingsView() 1332 1265 { 1333 rect.OffsetTo(B_ORIGIN); 1334 fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "", 1266 fDontMoveFilesToTrashCheckBox = new BCheckBox("", 1335 1267 B_TRANSLATE("Don't move files to Trash"), 1336 1268 new BMessage(kDontMoveFilesToTrashChanged)); 1337 fDontMoveFilesToTrashCheckBox->ResizeToPreferred();1338 AddChild(fDontMoveFilesToTrashCheckBox);1339 1269 1340 rect = fDontMoveFilesToTrashCheckBox->Frame(); 1341 rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing); 1342 1343 fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "", 1270 fAskBeforeDeleteFileCheckBox = new BCheckBox("", 1344 1271 B_TRANSLATE("Ask before delete"), 1345 1272 new BMessage(kAskBeforeDeleteFileChanged)); 1346 fAskBeforeDeleteFileCheckBox->ResizeToPreferred();1347 AddChild(fAskBeforeDeleteFileCheckBox);1348 }1349 1273 1274 const float spacing = be_control_look->DefaultItemSpacing(); 1350 1275 1351 void 1352 TrashSettingsView::GetPreferredSize(float *_width, float *_height)1353 { 1354 if (_width != NULL) {1355 float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();1356 if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())1357 width = fAskBeforeDeleteFileCheckBox->Bounds().Width();1276 BGroupLayoutBuilder(this) 1277 .AddGroup(B_VERTICAL) 1278 .Add(fDontMoveFilesToTrashCheckBox) 1279 .Add(fAskBeforeDeleteFileCheckBox) 1280 .AddGlue() 1281 .End() 1282 .SetInsets(spacing, spacing, spacing, spacing); 1358 1283 1359 *_width = width;1360 }1361 1362 if (_height != NULL)1363 *_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;1364 1284 } 1365 1285 1366 1286 -
TrackerSettingsWindow.cpp
33 33 */ 34 34 35 35 #include <Catalog.h> 36 #include <ControlLook.h> 37 #include <LayoutBuilder.h> 36 38 #include <Locale.h> 37 39 38 40 #include "SettingsViews.h" 39 41 #include "TrackerSettings.h" 40 42 #include "TrackerSettingsWindow.h" 41 43 42 //#include <CheckBox.h>43 44 #include <ScrollView.h> 44 45 45 46 … … 73 74 BWindow(BRect(80, 80, 450, 350), B_TRANSLATE("Tracker preferences"), 74 75 B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE 75 76 | B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE 76 | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE )77 | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) 77 78 { 78 BRect rect = Bounds(); 79 BView *topView = new BView(rect, "Background", B_FOLLOW_ALL, 0); 80 topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 81 AddChild(topView); 79 fSettingsTypeListView = new BListView("List View", B_SINGLE_SELECTION_LIST); 82 80 83 rect.InsetBy(10, 10); 84 rect.right = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons")) 85 + rect.left + (float)B_V_SCROLL_BAR_WIDTH + 40.0f; 86 fSettingsTypeListView = new BListView(rect, "List View", B_SINGLE_SELECTION_LIST, 87 B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM); 81 // TODO: Get width of listview using longest translated label. 82 float width = be_plain_font->StringWidth(B_TRANSLATE("Volume Icons")) 83 + (float)B_V_SCROLL_BAR_WIDTH + 40.0f; 84 fSettingsTypeListView->SetExplicitMinSize(BSize(width, 0)); 85 fSettingsTypeListView->SetExplicitMaxSize( BSize(width, B_SIZE_UNLIMITED)); 86 88 87 BScrollView* scrollView = new BScrollView("scrollview", fSettingsTypeListView, 89 B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true); 90 topView->AddChild(scrollView); 88 B_FRAME_EVENTS | B_WILL_DRAW, false, true); 91 89 92 rect = scrollView->Frame(); 93 rect.left = rect.right + 10; 94 rect.top = rect.bottom; 95 fDefaultsButton = new BButton(rect, "Defaults", B_TRANSLATE("Defaults"), 96 new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 97 fDefaultsButton->ResizeToPreferred(); 90 fDefaultsButton = new BButton("Defaults", B_TRANSLATE("Defaults"), 91 new BMessage(kDefaultsButtonPressed)); 98 92 fDefaultsButton->SetEnabled(false); 99 fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height());100 93 101 rect = fDefaultsButton->Frame(); 102 rect.left = rect.right + 10; 103 fRevertButton = new BButton(rect, "Revert", B_TRANSLATE("Revert"), 104 new BMessage(kRevertButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 94 fRevertButton = new BButton("Revert", B_TRANSLATE("Revert"), 95 new BMessage(kRevertButtonPressed)); 105 96 fRevertButton->SetEnabled(false); 106 fRevertButton->ResizeToPreferred();107 97 108 rect = scrollView->Frame(); 109 rect.left = rect.right + 10; 110 rect.right = Bounds().right - 10; 111 rect.bottom = fDefaultsButton->Frame().top - 10; 112 fSettingsContainerBox = new BBox(rect, NULL, B_FOLLOW_ALL); 113 topView->AddChild(fSettingsContainerBox); 114 topView->AddChild(fDefaultsButton); 115 topView->AddChild(fRevertButton); 98 fSettingsContainerBox = new BBox("SettingsContainerBox"); 99 100 const float spacing = be_control_look->DefaultItemSpacing(); 116 101 117 rect = _SettingsFrame(); 102 BLayoutBuilder::Group<>(this) 103 .AddGroup(B_HORIZONTAL, spacing) 104 .Add(scrollView) 105 .AddGroup(B_VERTICAL, spacing) 106 .Add(fSettingsContainerBox) 107 .AddGroup(B_HORIZONTAL, spacing) 108 .Add(fDefaultsButton) 109 .Add(fRevertButton) 110 .AddGlue() 111 .End() 112 .End() 113 .SetInsets(spacing, spacing, spacing, spacing) 114 .End(); 118 115 119 116 fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Desktop"), 120 new DesktopSettingsView( rect)));117 new DesktopSettingsView())); 121 118 fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Windows"), 122 new WindowsSettingsView( rect)));119 new WindowsSettingsView())); 123 120 fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Date & Time"), 124 new TimeFormatSettingsView( rect)));121 new TimeFormatSettingsView())); 125 122 fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Trash"), 126 new TrashSettingsView( rect)));123 new TrashSettingsView())); 127 124 fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Volume icons"), 128 new SpaceBarSettingsView( rect)));125 new SpaceBarSettingsView())); 129 126 130 // compute preferred view size131 132 float minWidth = 0, minHeight = 0;133 134 for (int32 i = 0; i < fSettingsTypeListView->CountItems(); i++) {135 SettingsView* view = ((SettingsItem *)fSettingsTypeListView->ItemAt(i))->View();136 137 float width, height;138 view->GetPreferredSize(&width, &height);139 140 if (minWidth < width)141 minWidth = width;142 if (minHeight < height)143 minHeight = height;144 }145 146 ResizeBy(max_c(minWidth - rect.Width(), 0), max_c(minHeight - rect.Height(), 0));147 // make sure window is large enough to contain all views148 149 127 fSettingsTypeListView->SetSelectionMessage(new BMessage(kSettingsViewChanged)); 150 128 fSettingsTypeListView->Select(0); 151 129 } … … 232 210 } 233 211 234 212 235 BRect236 TrackerSettingsWindow::_SettingsFrame()237 {238 font_height fontHeight;239 be_bold_font->GetHeight(&fontHeight);240 241 BRect rect = fSettingsContainerBox->Bounds().InsetByCopy(8, 8);242 rect.top += ceilf(fontHeight.ascent + fontHeight.descent);243 244 return rect;245 }246 247 248 213 void 249 214 TrackerSettingsWindow::_HandleChangedContents() 250 215 { … … 324 289 view->Hide(); 325 290 fSettingsContainerBox->AddChild(view); 326 291 327 // Resize view after it has been attached to the window, so that328 // it's resizing modes are respected329 BRect rect = _SettingsFrame();330 view->ResizeTo(rect.Width(), rect.Height());331 292 view->Show(); 332 293 } 333 294 } -
SettingsViews.h
36 36 #define _SETTINGS_VIEWS 37 37 38 38 #include <CheckBox.h> 39 #include <GroupView.h> 39 40 #include <RadioButton.h> 40 41 #include <TextControl.h> 41 42 #include <ColorControl.h> … … 51 52 52 53 namespace BPrivate { 53 54 54 class SettingsView : public B View {55 class SettingsView : public BGroupView { 55 56 public: 56 SettingsView( BRect frame, const char *name);57 SettingsView(); 57 58 virtual ~SettingsView(); 58 59 59 60 virtual void SetDefaults(); … … 64 65 virtual bool IsRevertable() const; 65 66 66 67 protected: 67 typedef B View _inherited;68 typedef BGroupView _inherited; 68 69 }; 69 70 70 71 class DesktopSettingsView : public SettingsView { 71 72 public: 72 DesktopSettingsView( BRect frame);73 DesktopSettingsView(); 73 74 74 75 virtual void MessageReceived(BMessage *message); 75 76 virtual void AttachedToWindow(); 76 virtual void GetPreferredSize(float *_width, float *_height);77 77 78 78 virtual void SetDefaults(); 79 79 virtual bool IsDefaultable() const; … … 102 102 103 103 class WindowsSettingsView : public SettingsView { 104 104 public: 105 WindowsSettingsView( BRect frame);105 WindowsSettingsView(); 106 106 107 107 virtual void MessageReceived(BMessage *message); 108 108 virtual void AttachedToWindow(); 109 virtual void GetPreferredSize(float *_width, float *_height);110 109 111 110 virtual void SetDefaults(); 112 111 virtual bool IsDefaultable() const; … … 136 135 137 136 class TimeFormatSettingsView : public SettingsView { 138 137 public: 139 TimeFormatSettingsView( BRect frame);138 TimeFormatSettingsView(); 140 139 141 140 virtual void MessageReceived(BMessage *message); 142 141 virtual void AttachedToWindow(); 143 virtual void GetPreferredSize(float *_width, float *_height);144 142 145 143 virtual void SetDefaults(); 146 144 virtual bool IsDefaultable() const; … … 175 173 176 174 class SpaceBarSettingsView : public SettingsView { 177 175 public: 178 SpaceBarSettingsView( BRect frame);176 SpaceBarSettingsView(); 179 177 virtual ~SpaceBarSettingsView(); 180 178 181 179 virtual void MessageReceived(BMessage *message); 182 180 virtual void AttachedToWindow(); 183 virtual void GetPreferredSize(float *_width, float *_height);184 181 185 182 virtual void SetDefaults(); 186 183 virtual bool IsDefaultable() const; … … 205 202 206 203 class TrashSettingsView : public SettingsView { 207 204 public: 208 TrashSettingsView( BRect frame);205 TrashSettingsView(); 209 206 210 207 virtual void MessageReceived(BMessage *message); 211 208 virtual void AttachedToWindow(); 212 virtual void GetPreferredSize(float *_width, float *_height);213 209 214 210 virtual void SetDefaults(); 215 211 virtual bool IsDefaultable() const; -
ContainerWindow.cpp
2195 2195 bool poseViewIsQuery = TargetModel()->IsQuery(); 2196 2196 // if the view is a query pose view, add edit query menu item 2197 2197 2198 BMenuItem* item = menu->FindItem( B_TRANSLATE("Edit query"));2198 BMenuItem* item = menu->FindItem(kEditQuery); 2199 2199 if (!poseViewIsQuery && !queryInSelection && item) 2200 2200 item->Menu()->RemoveItem(item); 2201 2201 … … 3024 3024 3025 3025 if (context == kMenuBarContext || context == kWindowPopUpContext) { 3026 3026 BMenu* sizeMenu = NULL; 3027 if (BMenuItem* item = menu->FindItem( B_TRANSLATE("Icon view"))) {3027 if (BMenuItem* item = menu->FindItem(kIconMode)) { 3028 3028 sizeMenu = item->Submenu(); 3029 3029 } 3030 3030 -
TrackerSettingsWindow.h
57 57 58 58 private: 59 59 SettingsView *_ViewAt(int32 i); 60 BRect _SettingsFrame();61 60 62 61 void _HandleChangedContents(); 63 62 void _HandlePressedDefaultsButton();