1a10cf76eSAxel Dörfler /* 28242ac7fSAxel Dörfler * Copyright 2001-2006, Haiku. 3a10cf76eSAxel Dörfler * Distributed under the terms of the MIT License. 4a10cf76eSAxel Dörfler * 5a10cf76eSAxel Dörfler * Authors: 6a10cf76eSAxel Dörfler * Rafael Romo 7a10cf76eSAxel Dörfler * Stefano Ceccherini (burton666@libero.it) 8a10cf76eSAxel Dörfler * Andrew Bachmann 9a10cf76eSAxel Dörfler * Thomas Kurschel 10a10cf76eSAxel Dörfler * Axel Dörfler, axeld@pinc-software.de 11df3f5bacSStephan Aßmus * Stephan Aßmus <superstippi@gmx.de> 12a10cf76eSAxel Dörfler */ 13a10cf76eSAxel Dörfler 14a10cf76eSAxel Dörfler 15a10cf76eSAxel Dörfler #include <Alert.h> 16a10cf76eSAxel Dörfler #include <Application.h> 17a10cf76eSAxel Dörfler #include <Box.h> 18a10cf76eSAxel Dörfler #include <Button.h> 19a10cf76eSAxel Dörfler #include <InterfaceDefs.h> 20df3f5bacSStephan Aßmus #include <MenuBar.h> 21a10cf76eSAxel Dörfler #include <MenuItem.h> 22a10cf76eSAxel Dörfler #include <MenuField.h> 23a10cf76eSAxel Dörfler #include <Messenger.h> 24a10cf76eSAxel Dörfler #include <PopUpMenu.h> 25a10cf76eSAxel Dörfler #include <Screen.h> 26a10cf76eSAxel Dörfler #include <String.h> 27df3f5bacSStephan Aßmus #include <Roster.h> 28a10cf76eSAxel Dörfler #include <Window.h> 29a10cf76eSAxel Dörfler 30a10cf76eSAxel Dörfler #include <cstdio> 31a10cf76eSAxel Dörfler #include <cstdlib> 32a10cf76eSAxel Dörfler #include <cstring> 33a10cf76eSAxel Dörfler 34a10cf76eSAxel Dörfler #include "AlertWindow.h" 35a10cf76eSAxel Dörfler #include "Constants.h" 36a10cf76eSAxel Dörfler #include "RefreshWindow.h" 37a10cf76eSAxel Dörfler #include "MonitorView.h" 38a10cf76eSAxel Dörfler #include "ScreenSettings.h" 39a10cf76eSAxel Dörfler #include "ScreenWindow.h" 40a10cf76eSAxel Dörfler #include "Utility.h" 41a10cf76eSAxel Dörfler 42a10cf76eSAxel Dörfler /* Note, this headers defines a *private* interface to the Radeon accelerant. 43a10cf76eSAxel Dörfler * It's a solution that works with the current BeOS interface that Haiku 44a10cf76eSAxel Dörfler * adopted. 45a10cf76eSAxel Dörfler * However, it's not a nice and clean solution. Don't use this header in any 46a10cf76eSAxel Dörfler * application if you can avoid it. No other driver is using this, or should 47a10cf76eSAxel Dörfler * be using this. 48a10cf76eSAxel Dörfler * It will be replaced as soon as we introduce an updated accelerant interface 49a10cf76eSAxel Dörfler * which may even happen before R1 hits the streets. 50a10cf76eSAxel Dörfler */ 51a10cf76eSAxel Dörfler 52a10cf76eSAxel Dörfler #include "multimon.h" // the usual: DANGER WILL, ROBINSON! 53a10cf76eSAxel Dörfler 54a10cf76eSAxel Dörfler 55c5d80d47SAxel Dörfler const char* kBackgroundsSignature = "application/x-vnd.haiku-backgrounds"; 56c5d80d47SAxel Dörfler 57a10cf76eSAxel Dörfler // list of officially supported colour spaces 58a10cf76eSAxel Dörfler static const struct { 59a10cf76eSAxel Dörfler color_space space; 60a10cf76eSAxel Dörfler int32 bits_per_pixel; 61a10cf76eSAxel Dörfler const char* label; 62a10cf76eSAxel Dörfler } kColorSpaces[] = { 63a10cf76eSAxel Dörfler { B_CMAP8, 8, "8 Bits/Pixel, 256 Colors" }, 64a10cf76eSAxel Dörfler { B_RGB15, 15, "15 Bits/Pixel, 32768 Colors" }, 65a10cf76eSAxel Dörfler { B_RGB16, 16, "16 Bits/Pixel, 65536 Colors" }, 66a10cf76eSAxel Dörfler { B_RGB32, 32, "32 Bits/Pixel, 16 Million Colors" } 67a10cf76eSAxel Dörfler }; 68a10cf76eSAxel Dörfler static const int32 kColorSpaceCount = sizeof(kColorSpaces) / sizeof(kColorSpaces[0]); 69a10cf76eSAxel Dörfler 70a10cf76eSAxel Dörfler // list of standard refresh rates 71a796facfSAxel Dörfler static const int32 kRefreshRates[] = { 60, 70, 72, 75, 80, 85, 95, 100 }; 72a10cf76eSAxel Dörfler static const int32 kRefreshRateCount = sizeof(kRefreshRates) / sizeof(kRefreshRates[0]); 73a10cf76eSAxel Dörfler 74a10cf76eSAxel Dörfler // list of combine modes 75a10cf76eSAxel Dörfler static const struct { 76a10cf76eSAxel Dörfler combine_mode mode; 77a10cf76eSAxel Dörfler const char *name; 78a10cf76eSAxel Dörfler } kCombineModes[] = { 79a10cf76eSAxel Dörfler { kCombineDisable, "disable" }, 80a10cf76eSAxel Dörfler { kCombineHorizontally, "horizontally" }, 81a10cf76eSAxel Dörfler { kCombineVertically, "vertically" } 82a10cf76eSAxel Dörfler }; 83a10cf76eSAxel Dörfler static const int32 kCombineModeCount = sizeof(kCombineModes) / sizeof(kCombineModes[0]); 84a10cf76eSAxel Dörfler 8529e8a73aSAxel Dörfler enum { 8629e8a73aSAxel Dörfler SHOW_COMBINE_FIELD = 0x01, 8729e8a73aSAxel Dörfler SHOW_SWAP_FIELD = 0x02, 8829e8a73aSAxel Dörfler SHOW_LAPTOP_PANEL_FIELD = 0x04, 8929e8a73aSAxel Dörfler SHOW_TV_STANDARD_FIELD = 0x08, 9029e8a73aSAxel Dörfler }; 9129e8a73aSAxel Dörfler 92a10cf76eSAxel Dörfler 93a10cf76eSAxel Dörfler static BString 94a10cf76eSAxel Dörfler tv_standard_to_string(uint32 mode) 95a10cf76eSAxel Dörfler { 96a10cf76eSAxel Dörfler switch (mode) { 97a10cf76eSAxel Dörfler case 0: return "disabled"; 98a10cf76eSAxel Dörfler case 1: return "NTSC"; 99a10cf76eSAxel Dörfler case 2: return "NTSC Japan"; 100a10cf76eSAxel Dörfler case 3: return "PAL BDGHI"; 101a10cf76eSAxel Dörfler case 4: return "PAL M"; 102a10cf76eSAxel Dörfler case 5: return "PAL N"; 103a10cf76eSAxel Dörfler case 6: return "SECAM"; 104a10cf76eSAxel Dörfler case 101: return "NTSC 443"; 105a10cf76eSAxel Dörfler case 102: return "PAL 60"; 106a10cf76eSAxel Dörfler case 103: return "PAL NC"; 107a10cf76eSAxel Dörfler default: 108a10cf76eSAxel Dörfler { 109a10cf76eSAxel Dörfler BString name; 110a10cf76eSAxel Dörfler name << "??? (" << mode << ")"; 111a10cf76eSAxel Dörfler 112a10cf76eSAxel Dörfler return name; 113a10cf76eSAxel Dörfler } 114a10cf76eSAxel Dörfler } 115a10cf76eSAxel Dörfler } 116a10cf76eSAxel Dörfler 117a10cf76eSAxel Dörfler 118a10cf76eSAxel Dörfler static void 119a10cf76eSAxel Dörfler resolution_to_string(screen_mode& mode, BString &string) 120a10cf76eSAxel Dörfler { 121a10cf76eSAxel Dörfler string << mode.width << " x " << mode.height; 122a10cf76eSAxel Dörfler } 123a10cf76eSAxel Dörfler 124a10cf76eSAxel Dörfler 125a10cf76eSAxel Dörfler static void 126a10cf76eSAxel Dörfler refresh_rate_to_string(float refresh, BString &string, 127a10cf76eSAxel Dörfler bool appendUnit = true, bool alwaysWithFraction = false) 128a10cf76eSAxel Dörfler { 129a10cf76eSAxel Dörfler snprintf(string.LockBuffer(32), 32, "%.*g", refresh >= 100.0 ? 4 : 3, refresh); 130a10cf76eSAxel Dörfler string.UnlockBuffer(); 131a10cf76eSAxel Dörfler 132a10cf76eSAxel Dörfler if (appendUnit) 133a10cf76eSAxel Dörfler string << " Hz"; 134a10cf76eSAxel Dörfler } 135a10cf76eSAxel Dörfler 136a10cf76eSAxel Dörfler 13707184a9eSAxel Dörfler static const char* 13807184a9eSAxel Dörfler screen_errors(status_t status) 13907184a9eSAxel Dörfler { 14007184a9eSAxel Dörfler switch (status) { 14107184a9eSAxel Dörfler case B_ENTRY_NOT_FOUND: 14207184a9eSAxel Dörfler return "Unknown Mode"; 14307184a9eSAxel Dörfler // TODO: add more? 14407184a9eSAxel Dörfler 14507184a9eSAxel Dörfler default: 14607184a9eSAxel Dörfler return strerror(status); 14707184a9eSAxel Dörfler } 14807184a9eSAxel Dörfler } 14907184a9eSAxel Dörfler 15029e8a73aSAxel Dörfler 15129e8a73aSAxel Dörfler static float 15229e8a73aSAxel Dörfler max_label_width(BMenuField* control, float widestLabel) 15329e8a73aSAxel Dörfler { 15429e8a73aSAxel Dörfler float labelWidth = control->StringWidth(control->Label()); 15529e8a73aSAxel Dörfler if (widestLabel < labelWidth) 15629e8a73aSAxel Dörfler return labelWidth; 15729e8a73aSAxel Dörfler return widestLabel; 15829e8a73aSAxel Dörfler } 15929e8a73aSAxel Dörfler 16029e8a73aSAxel Dörfler 16129e8a73aSAxel Dörfler static BRect 16229e8a73aSAxel Dörfler stack_and_align_menu_fields(const BList& menuFields) 16329e8a73aSAxel Dörfler { 16429e8a73aSAxel Dörfler float widestLabel = 0.0; 16529e8a73aSAxel Dörfler int32 count = menuFields.CountItems(); 16629e8a73aSAxel Dörfler for (int32 i = 0; i < count; i++) { 16729e8a73aSAxel Dörfler BMenuField* menuField = (BMenuField*)menuFields.ItemAtFast(i); 16829e8a73aSAxel Dörfler widestLabel = max_label_width(menuField, widestLabel); 16929e8a73aSAxel Dörfler } 17029e8a73aSAxel Dörfler 17129e8a73aSAxel Dörfler // add some room (but only if there is text at all) 17229e8a73aSAxel Dörfler if (widestLabel > 0.0) 17329e8a73aSAxel Dörfler widestLabel += 5.0; 17429e8a73aSAxel Dörfler 17529e8a73aSAxel Dörfler // make all controls the same width 17629e8a73aSAxel Dörfler float widestField = 0.0; 17729e8a73aSAxel Dörfler for (int32 i = 0; i < count; i++) { 17829e8a73aSAxel Dörfler BMenuField* menuField = (BMenuField*)menuFields.ItemAtFast(i); 17929e8a73aSAxel Dörfler menuField->SetAlignment(B_ALIGN_RIGHT); 18029e8a73aSAxel Dörfler menuField->SetDivider(widestLabel); 18129e8a73aSAxel Dörfler menuField->ResizeToPreferred(); 18229e8a73aSAxel Dörfler widestField = max_c(menuField->Bounds().Width(), widestField); 18329e8a73aSAxel Dörfler } 18429e8a73aSAxel Dörfler 18529e8a73aSAxel Dörfler // layout controls under each other, resize all to size 18629e8a73aSAxel Dörfler // of largest of them (they could still have different 18729e8a73aSAxel Dörfler // heights though) 18829e8a73aSAxel Dörfler BMenuField* topMenuField = (BMenuField*)menuFields.FirstItem(); 18929e8a73aSAxel Dörfler BPoint leftTop = topMenuField->Frame().LeftTop(); 19029e8a73aSAxel Dörfler BRect frame = topMenuField->Frame(); 19129e8a73aSAxel Dörfler 19229e8a73aSAxel Dörfler for (int32 i = 0; i < count; i++) { 19329e8a73aSAxel Dörfler BMenuField* menuField = (BMenuField*)menuFields.ItemAtFast(i); 19429e8a73aSAxel Dörfler menuField->MoveTo(leftTop); 19529e8a73aSAxel Dörfler float height = menuField->Bounds().Height(); 19629e8a73aSAxel Dörfler menuField->ResizeTo(widestField, height); 19729e8a73aSAxel Dörfler frame = frame | menuField->Frame(); 19829e8a73aSAxel Dörfler leftTop.y += height + 5.0; 19929e8a73aSAxel Dörfler } 20029e8a73aSAxel Dörfler 20129e8a73aSAxel Dörfler return frame; 20229e8a73aSAxel Dörfler } 203df3f5bacSStephan Aßmus 204df3f5bacSStephan Aßmus 2053dfd20c0SStephan Aßmus // #pragma mark - 2063dfd20c0SStephan Aßmus 2073dfd20c0SStephan Aßmus 2085a78744bSAxel Dörfler ScreenWindow::ScreenWindow(ScreenSettings *settings) 2095a78744bSAxel Dörfler : BWindow(settings->WindowFrame(), "Screen", B_TITLED_WINDOW, 210a10cf76eSAxel Dörfler B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES), 211a10cf76eSAxel Dörfler fScreenMode(this), 212a10cf76eSAxel Dörfler fChangingAllWorkspaces(false) 213a10cf76eSAxel Dörfler { 214a10cf76eSAxel Dörfler BScreen screen(this); 215a10cf76eSAxel Dörfler 216a10cf76eSAxel Dörfler fScreenMode.Get(fOriginal); 217a10cf76eSAxel Dörfler fActive = fSelected = fOriginal; 218a10cf76eSAxel Dörfler 219df3f5bacSStephan Aßmus BView *view = new BView(Bounds(), "ScreenView", B_FOLLOW_ALL, B_WILL_DRAW); 220a10cf76eSAxel Dörfler view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 221a10cf76eSAxel Dörfler AddChild(view); 222a10cf76eSAxel Dörfler 2235a78744bSAxel Dörfler fSettings = settings; 2245a78744bSAxel Dörfler 2255a78744bSAxel Dörfler // we need the "Current Workspace" first to get its height 2265a78744bSAxel Dörfler 2275a78744bSAxel Dörfler BPopUpMenu *popUpMenu = new BPopUpMenu("Current Workspace", true, true); 2285a78744bSAxel Dörfler fAllWorkspacesItem = new BMenuItem("All Workspaces", new BMessage(WORKSPACE_CHECK_MSG)); 2295a78744bSAxel Dörfler popUpMenu->AddItem(fAllWorkspacesItem); 2305a78744bSAxel Dörfler BMenuItem *item = new BMenuItem("Current Workspace", new BMessage(WORKSPACE_CHECK_MSG)); 2315a78744bSAxel Dörfler item->SetMarked(true); 2325a78744bSAxel Dörfler popUpMenu->AddItem(item); 2335a78744bSAxel Dörfler 234df3f5bacSStephan Aßmus BMenuField* workspaceMenuField = new BMenuField(BRect(0, 0, 100, 15), 2355a78744bSAxel Dörfler "WorkspaceMenu", NULL, popUpMenu, true); 2365a78744bSAxel Dörfler workspaceMenuField->ResizeToPreferred(); 237a10cf76eSAxel Dörfler 238a10cf76eSAxel Dörfler // box on the left with workspace count and monitor view 239a10cf76eSAxel Dörfler 2405a78744bSAxel Dörfler popUpMenu = new BPopUpMenu("", true, true); 241df3f5bacSStephan Aßmus fWorkspaceCountField = new BMenuField(BRect(0.0, 0.0, 50.0, 15.0), 242df3f5bacSStephan Aßmus "WorkspaceCountMenu", "Workspace count:", popUpMenu, true); 243df3f5bacSStephan Aßmus float labelWidth = fWorkspaceCountField->StringWidth(fWorkspaceCountField->Label()) + 5.0; 244df3f5bacSStephan Aßmus fWorkspaceCountField->SetDivider(labelWidth); 245df3f5bacSStephan Aßmus 246df3f5bacSStephan Aßmus fScreenBox = new BBox(BRect(0.0, 0.0, 100.0, 100.0), "left box"); 247df3f5bacSStephan Aßmus fScreenBox->AddChild(fWorkspaceCountField); 248a10cf76eSAxel Dörfler 249a10cf76eSAxel Dörfler for (int32 count = 1; count <= 32; count++) { 250a10cf76eSAxel Dörfler BString workspaceCount; 251a10cf76eSAxel Dörfler workspaceCount << count; 252a10cf76eSAxel Dörfler 253a10cf76eSAxel Dörfler BMessage *message = new BMessage(POP_WORKSPACE_CHANGED_MSG); 254a10cf76eSAxel Dörfler message->AddInt32("workspace count", count); 255a10cf76eSAxel Dörfler 256a10cf76eSAxel Dörfler popUpMenu->AddItem(new BMenuItem(workspaceCount.String(), 257a10cf76eSAxel Dörfler message)); 258a10cf76eSAxel Dörfler } 259a10cf76eSAxel Dörfler 2605a78744bSAxel Dörfler item = popUpMenu->ItemAt(count_workspaces() - 1); 261a10cf76eSAxel Dörfler if (item != NULL) 262a10cf76eSAxel Dörfler item->SetMarked(true); 263a10cf76eSAxel Dörfler 264df3f5bacSStephan Aßmus fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0), "monitor", 2655a78744bSAxel Dörfler screen.Frame().Width() + 1, screen.Frame().Height() + 1); 266df3f5bacSStephan Aßmus fScreenBox->AddChild(fMonitorView); 2675a78744bSAxel Dörfler 268df3f5bacSStephan Aßmus view->AddChild(fScreenBox); 269a10cf76eSAxel Dörfler 270a10cf76eSAxel Dörfler // box on the right with screen resolution, etc. 271a10cf76eSAxel Dörfler 272df3f5bacSStephan Aßmus fControlsBox = new BBox(BRect(0.0, 0.0, 100.0, 100.0)); 273df3f5bacSStephan Aßmus fControlsBox->SetLabel(workspaceMenuField); 274a10cf76eSAxel Dörfler 275a10cf76eSAxel Dörfler fResolutionMenu = new BPopUpMenu("resolution", true, true); 276a10cf76eSAxel Dörfler 277a10cf76eSAxel Dörfler uint16 previousWidth = 0, previousHeight = 0; 278a10cf76eSAxel Dörfler for (int32 i = 0; i < fScreenMode.CountModes(); i++) { 279a10cf76eSAxel Dörfler screen_mode mode = fScreenMode.ModeAt(i); 280a10cf76eSAxel Dörfler 281a10cf76eSAxel Dörfler if (mode.width == previousWidth && mode.height == previousHeight) 282a10cf76eSAxel Dörfler continue; 283a10cf76eSAxel Dörfler 284a10cf76eSAxel Dörfler previousWidth = mode.width; 285a10cf76eSAxel Dörfler previousHeight = mode.height; 286a10cf76eSAxel Dörfler 287a10cf76eSAxel Dörfler BMessage *message = new BMessage(POP_RESOLUTION_MSG); 288a10cf76eSAxel Dörfler message->AddInt32("width", mode.width); 289a10cf76eSAxel Dörfler message->AddInt32("height", mode.height); 290a10cf76eSAxel Dörfler 291a10cf76eSAxel Dörfler BString name; 292a10cf76eSAxel Dörfler name << mode.width << " x " << mode.height; 293a10cf76eSAxel Dörfler 294a10cf76eSAxel Dörfler fResolutionMenu->AddItem(new BMenuItem(name.String(), message)); 295a10cf76eSAxel Dörfler } 296a10cf76eSAxel Dörfler 29729e8a73aSAxel Dörfler BRect rect(0.0, 0.0, 200.0, 15.0); 298df3f5bacSStephan Aßmus // fResolutionField needs to be at the correct 299df3f5bacSStephan Aßmus // left-top offset, because all other menu fields 300df3f5bacSStephan Aßmus // will be layouted relative to it 301df3f5bacSStephan Aßmus fResolutionField = new BMenuField(rect.OffsetToCopy(10.0, 30.0), 302df3f5bacSStephan Aßmus "ResolutionMenu", "Resolution:", fResolutionMenu, true); 303df3f5bacSStephan Aßmus fControlsBox->AddChild(fResolutionField); 304a10cf76eSAxel Dörfler 305a10cf76eSAxel Dörfler fColorsMenu = new BPopUpMenu("colors", true, true); 306a10cf76eSAxel Dörfler 307a10cf76eSAxel Dörfler for (int32 i = 0; i < kColorSpaceCount; i++) { 308a10cf76eSAxel Dörfler BMessage *message = new BMessage(POP_COLORS_MSG); 309a10cf76eSAxel Dörfler message->AddInt32("bits_per_pixel", kColorSpaces[i].bits_per_pixel); 310a10cf76eSAxel Dörfler message->AddInt32("space", kColorSpaces[i].space); 311a10cf76eSAxel Dörfler 312a10cf76eSAxel Dörfler fColorsMenu->AddItem(new BMenuItem(kColorSpaces[i].label, message)); 313a10cf76eSAxel Dörfler } 314a10cf76eSAxel Dörfler 315df3f5bacSStephan Aßmus rect.OffsetTo(B_ORIGIN); 316df3f5bacSStephan Aßmus 317a10cf76eSAxel Dörfler fColorsField = new BMenuField(rect, "ColorsMenu", "Colors:", fColorsMenu, true); 318df3f5bacSStephan Aßmus fControlsBox->AddChild(fColorsField); 319a10cf76eSAxel Dörfler 320a10cf76eSAxel Dörfler fRefreshMenu = new BPopUpMenu("refresh rate", true, true); 321a10cf76eSAxel Dörfler 32229e8a73aSAxel Dörfler BMessage *message; 32329e8a73aSAxel Dörfler 32429e8a73aSAxel Dörfler float min, max; 32529e8a73aSAxel Dörfler if (fScreenMode.GetRefreshLimits(fActive, min, max) && min == max) { 32629e8a73aSAxel Dörfler // This is a special case for drivers that only support a single 32729e8a73aSAxel Dörfler // frequency, like the VESA driver 32829e8a73aSAxel Dörfler BString name; 32929e8a73aSAxel Dörfler name << min << " Hz"; 33029e8a73aSAxel Dörfler 33129e8a73aSAxel Dörfler message = new BMessage(POP_REFRESH_MSG); 33229e8a73aSAxel Dörfler message->AddFloat("refresh", min); 33329e8a73aSAxel Dörfler 33429e8a73aSAxel Dörfler fRefreshMenu->AddItem(item = new BMenuItem(name.String(), message)); 33529e8a73aSAxel Dörfler item->SetEnabled(false); 33629e8a73aSAxel Dörfler } else { 337a10cf76eSAxel Dörfler for (int32 i = 0; i < kRefreshRateCount; ++i) { 338a10cf76eSAxel Dörfler BString name; 339a10cf76eSAxel Dörfler name << kRefreshRates[i] << " Hz"; 340a10cf76eSAxel Dörfler 34129e8a73aSAxel Dörfler message = new BMessage(POP_REFRESH_MSG); 342a10cf76eSAxel Dörfler message->AddFloat("refresh", kRefreshRates[i]); 343a10cf76eSAxel Dörfler 344a10cf76eSAxel Dörfler fRefreshMenu->AddItem(new BMenuItem(name.String(), message)); 345a10cf76eSAxel Dörfler } 346a10cf76eSAxel Dörfler 34729e8a73aSAxel Dörfler message = new BMessage(POP_OTHER_REFRESH_MSG); 348a10cf76eSAxel Dörfler 349a10cf76eSAxel Dörfler fOtherRefresh = new BMenuItem("Other" B_UTF8_ELLIPSIS, message); 350a10cf76eSAxel Dörfler fRefreshMenu->AddItem(fOtherRefresh); 35129e8a73aSAxel Dörfler } 352a10cf76eSAxel Dörfler 353a10cf76eSAxel Dörfler fRefreshField = new BMenuField(rect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true); 354df3f5bacSStephan Aßmus fControlsBox->AddChild(fRefreshField); 355a10cf76eSAxel Dörfler 356df3f5bacSStephan Aßmus view->AddChild(fControlsBox); 357df3f5bacSStephan Aßmus 358df3f5bacSStephan Aßmus uint32 controlsFlags = 0; 359a10cf76eSAxel Dörfler 360a10cf76eSAxel Dörfler // enlarged area for multi-monitor settings 361a10cf76eSAxel Dörfler { 362a10cf76eSAxel Dörfler bool dummy; 363a10cf76eSAxel Dörfler uint32 dummy32; 364a10cf76eSAxel Dörfler bool multiMonSupport; 365a10cf76eSAxel Dörfler bool useLaptopPanelSupport; 366a10cf76eSAxel Dörfler bool tvStandardSupport; 367a10cf76eSAxel Dörfler 368a10cf76eSAxel Dörfler multiMonSupport = TestMultiMonSupport(&screen) == B_OK; 369a10cf76eSAxel Dörfler useLaptopPanelSupport = GetUseLaptopPanel(&screen, &dummy) == B_OK; 370a10cf76eSAxel Dörfler tvStandardSupport = GetTVStandard(&screen, &dummy32) == B_OK; 371df3f5bacSStephan Aßmus if (multiMonSupport) { 372df3f5bacSStephan Aßmus controlsFlags |= SHOW_COMBINE_FIELD; 373df3f5bacSStephan Aßmus controlsFlags |= SHOW_SWAP_FIELD; 374df3f5bacSStephan Aßmus } 375df3f5bacSStephan Aßmus if (useLaptopPanelSupport) 376df3f5bacSStephan Aßmus controlsFlags |= SHOW_LAPTOP_PANEL_FIELD; 377a10cf76eSAxel Dörfler 378a10cf76eSAxel Dörfler // even if there is no support, we still create all controls 379a10cf76eSAxel Dörfler // to make sure we don't access NULL pointers later on 380a10cf76eSAxel Dörfler 381a10cf76eSAxel Dörfler fCombineMenu = new BPopUpMenu("CombineDisplays", true, true); 382a10cf76eSAxel Dörfler 383a10cf76eSAxel Dörfler for (int32 i = 0; i < kCombineModeCount; i++) { 384a10cf76eSAxel Dörfler message = new BMessage(POP_COMBINE_DISPLAYS_MSG); 385a10cf76eSAxel Dörfler message->AddInt32("mode", kCombineModes[i].mode); 386a10cf76eSAxel Dörfler 387a10cf76eSAxel Dörfler fCombineMenu->AddItem(new BMenuItem(kCombineModes[i].name, message)); 388a10cf76eSAxel Dörfler } 389a10cf76eSAxel Dörfler 390df3f5bacSStephan Aßmus fCombineField = new BMenuField(rect, "CombineMenu", 391a10cf76eSAxel Dörfler "Combine Displays:", fCombineMenu, true); 392df3f5bacSStephan Aßmus fControlsBox->AddChild(fCombineField); 393a10cf76eSAxel Dörfler 394a10cf76eSAxel Dörfler if (!multiMonSupport) 395df3f5bacSStephan Aßmus fCombineField->Hide(); 396a10cf76eSAxel Dörfler 397a10cf76eSAxel Dörfler fSwapDisplaysMenu = new BPopUpMenu("SwapDisplays", true, true); 398a10cf76eSAxel Dörfler 399a10cf76eSAxel Dörfler // !order is important - we rely that boolean value == idx 400a10cf76eSAxel Dörfler message = new BMessage(POP_SWAP_DISPLAYS_MSG); 401a10cf76eSAxel Dörfler message->AddBool("swap", false); 402a10cf76eSAxel Dörfler fSwapDisplaysMenu->AddItem(new BMenuItem("no", message)); 403a10cf76eSAxel Dörfler 404a10cf76eSAxel Dörfler message = new BMessage(POP_SWAP_DISPLAYS_MSG); 405a10cf76eSAxel Dörfler message->AddBool("swap", true); 406a10cf76eSAxel Dörfler fSwapDisplaysMenu->AddItem(new BMenuItem("yes", message)); 407a10cf76eSAxel Dörfler 408df3f5bacSStephan Aßmus fSwapDisplaysField = new BMenuField(rect, "SwapMenu", "Swap Displays:", 409a10cf76eSAxel Dörfler fSwapDisplaysMenu, true); 410a10cf76eSAxel Dörfler 411df3f5bacSStephan Aßmus fControlsBox->AddChild(fSwapDisplaysField); 412a10cf76eSAxel Dörfler if (!multiMonSupport) 413df3f5bacSStephan Aßmus fSwapDisplaysField->Hide(); 414a10cf76eSAxel Dörfler 415a10cf76eSAxel Dörfler fUseLaptopPanelMenu = new BPopUpMenu("UseLaptopPanel", true, true); 416a10cf76eSAxel Dörfler 417a10cf76eSAxel Dörfler // !order is important - we rely that boolean value == idx 418a10cf76eSAxel Dörfler message = new BMessage(POP_USE_LAPTOP_PANEL_MSG); 419a10cf76eSAxel Dörfler message->AddBool("use", false); 420a10cf76eSAxel Dörfler fUseLaptopPanelMenu->AddItem(new BMenuItem("if needed", message)); 421a10cf76eSAxel Dörfler 422a10cf76eSAxel Dörfler message = new BMessage(POP_USE_LAPTOP_PANEL_MSG); 423a10cf76eSAxel Dörfler message->AddBool("use", true); 424a10cf76eSAxel Dörfler fUseLaptopPanelMenu->AddItem(new BMenuItem("always", message)); 425a10cf76eSAxel Dörfler 426df3f5bacSStephan Aßmus fUseLaptopPanelField = new BMenuField(rect, "UseLaptopPanel", "Use Laptop Panel:", 427a10cf76eSAxel Dörfler fUseLaptopPanelMenu, true); 428a10cf76eSAxel Dörfler 429df3f5bacSStephan Aßmus fControlsBox->AddChild(fUseLaptopPanelField); 430a10cf76eSAxel Dörfler if (!useLaptopPanelSupport) 431df3f5bacSStephan Aßmus fUseLaptopPanelField->Hide(); 432a10cf76eSAxel Dörfler 433a10cf76eSAxel Dörfler fTVStandardMenu = new BPopUpMenu("TVStandard", true, true); 434a10cf76eSAxel Dörfler 435a10cf76eSAxel Dörfler // arbitrary limit 436a10cf76eSAxel Dörfler uint32 i; 437a10cf76eSAxel Dörfler for (i = 0; i < 100; ++i) { 438a10cf76eSAxel Dörfler uint32 mode; 439a10cf76eSAxel Dörfler 440a10cf76eSAxel Dörfler if (GetNthSupportedTVStandard(&screen, i, &mode) != B_OK) 441a10cf76eSAxel Dörfler break; 442a10cf76eSAxel Dörfler 443a10cf76eSAxel Dörfler BString name = tv_standard_to_string(mode); 444a10cf76eSAxel Dörfler 445a10cf76eSAxel Dörfler message = new BMessage(POP_TV_STANDARD_MSG); 446a10cf76eSAxel Dörfler message->AddInt32("tv_standard", mode); 447a10cf76eSAxel Dörfler 448a10cf76eSAxel Dörfler fTVStandardMenu->AddItem(new BMenuItem(name.String(), message)); 449a10cf76eSAxel Dörfler } 450a10cf76eSAxel Dörfler 451df3f5bacSStephan Aßmus fTVStandardField = new BMenuField(rect, "tv standard", "Video Format:", 452a10cf76eSAxel Dörfler fTVStandardMenu, true); 453df3f5bacSStephan Aßmus fTVStandardField->SetAlignment(B_ALIGN_RIGHT); 454a10cf76eSAxel Dörfler 455df3f5bacSStephan Aßmus if (!tvStandardSupport || i == 0) { 456df3f5bacSStephan Aßmus fTVStandardField->Hide(); 457df3f5bacSStephan Aßmus } else { 458df3f5bacSStephan Aßmus controlsFlags |= SHOW_TV_STANDARD_FIELD; 459a10cf76eSAxel Dörfler } 460a10cf76eSAxel Dörfler 461df3f5bacSStephan Aßmus fControlsBox->AddChild(fTVStandardField); 462df3f5bacSStephan Aßmus } 463df3f5bacSStephan Aßmus 464df3f5bacSStephan Aßmus BRect buttonRect(0.0, 0.0, 30.0, 10.0); 465df3f5bacSStephan Aßmus fBackgroundsButton = new BButton(buttonRect, "BackgroundsButton", 466df3f5bacSStephan Aßmus "Set Background"B_UTF8_ELLIPSIS, new BMessage(BUTTON_LAUNCH_BACKGROUNDS_MSG)); 4673dfd20c0SStephan Aßmus fBackgroundsButton->SetFontSize(be_plain_font->Size() * 0.9); 468df3f5bacSStephan Aßmus fScreenBox->AddChild(fBackgroundsButton); 469df3f5bacSStephan Aßmus 470df3f5bacSStephan Aßmus fDefaultsButton = new BButton(buttonRect, "DefaultsButton", "Defaults", 471a10cf76eSAxel Dörfler new BMessage(BUTTON_DEFAULTS_MSG)); 472a10cf76eSAxel Dörfler view->AddChild(fDefaultsButton); 473a10cf76eSAxel Dörfler 474df3f5bacSStephan Aßmus fRevertButton = new BButton(buttonRect, "RevertButton", "Revert", 475a10cf76eSAxel Dörfler new BMessage(BUTTON_REVERT_MSG)); 476a10cf76eSAxel Dörfler fRevertButton->SetEnabled(false); 477a10cf76eSAxel Dörfler view->AddChild(fRevertButton); 478a10cf76eSAxel Dörfler 479df3f5bacSStephan Aßmus fApplyButton = new BButton(buttonRect, "ApplyButton", "Apply", 480df3f5bacSStephan Aßmus new BMessage(BUTTON_APPLY_MSG)); 481df3f5bacSStephan Aßmus fApplyButton->SetEnabled(false); 482df3f5bacSStephan Aßmus view->AddChild(fApplyButton); 4835a78744bSAxel Dörfler 484a10cf76eSAxel Dörfler UpdateControls(); 485df3f5bacSStephan Aßmus 486df3f5bacSStephan Aßmus LayoutControls(controlsFlags); 487a10cf76eSAxel Dörfler } 488a10cf76eSAxel Dörfler 489a10cf76eSAxel Dörfler 490a10cf76eSAxel Dörfler ScreenWindow::~ScreenWindow() 491a10cf76eSAxel Dörfler { 492a10cf76eSAxel Dörfler delete fSettings; 493a10cf76eSAxel Dörfler } 494a10cf76eSAxel Dörfler 495a10cf76eSAxel Dörfler 496a10cf76eSAxel Dörfler bool 497a10cf76eSAxel Dörfler ScreenWindow::QuitRequested() 498a10cf76eSAxel Dörfler { 499a10cf76eSAxel Dörfler fSettings->SetWindowFrame(Frame()); 500a10cf76eSAxel Dörfler be_app->PostMessage(B_QUIT_REQUESTED); 501a10cf76eSAxel Dörfler 502a10cf76eSAxel Dörfler return BWindow::QuitRequested(); 503a10cf76eSAxel Dörfler } 504a10cf76eSAxel Dörfler 505a10cf76eSAxel Dörfler 506a10cf76eSAxel Dörfler /** update resolution list according to combine mode 507a10cf76eSAxel Dörfler * (some resolution may not be combinable due to memory restrictions) 508a10cf76eSAxel Dörfler */ 509a10cf76eSAxel Dörfler 510a10cf76eSAxel Dörfler void 511a10cf76eSAxel Dörfler ScreenWindow::CheckResolutionMenu() 512a10cf76eSAxel Dörfler { 513a10cf76eSAxel Dörfler for (int32 i = 0; i < fResolutionMenu->CountItems(); i++) 514a10cf76eSAxel Dörfler fResolutionMenu->ItemAt(i)->SetEnabled(false); 515a10cf76eSAxel Dörfler 516a10cf76eSAxel Dörfler for (int32 i = 0; i < fScreenMode.CountModes(); i++) { 517a10cf76eSAxel Dörfler screen_mode mode = fScreenMode.ModeAt(i); 518a10cf76eSAxel Dörfler if (mode.combine != fSelected.combine) 519a10cf76eSAxel Dörfler continue; 520a10cf76eSAxel Dörfler 521a10cf76eSAxel Dörfler BString name; 522a10cf76eSAxel Dörfler name << mode.width << " x " << mode.height; 523a10cf76eSAxel Dörfler 524a10cf76eSAxel Dörfler BMenuItem *item = fResolutionMenu->FindItem(name.String()); 525a10cf76eSAxel Dörfler if (item != NULL) 526a10cf76eSAxel Dörfler item->SetEnabled(true); 527a10cf76eSAxel Dörfler } 528a10cf76eSAxel Dörfler } 529a10cf76eSAxel Dörfler 530a10cf76eSAxel Dörfler 531a10cf76eSAxel Dörfler /** update color and refresh options according to current mode 532a10cf76eSAxel Dörfler * (a color space is made active if there is any mode with 533a10cf76eSAxel Dörfler * given resolution and this colour space; same applies for 534a10cf76eSAxel Dörfler * refresh rate, though "Other…" is always possible) 535a10cf76eSAxel Dörfler */ 536a10cf76eSAxel Dörfler 537a10cf76eSAxel Dörfler void 538a10cf76eSAxel Dörfler ScreenWindow::CheckColorMenu() 539a10cf76eSAxel Dörfler { 540a10cf76eSAxel Dörfler for (int32 i = 0; i < kColorSpaceCount; i++) { 541a10cf76eSAxel Dörfler bool supported = false; 542a10cf76eSAxel Dörfler 543a10cf76eSAxel Dörfler for (int32 j = 0; j < fScreenMode.CountModes(); j++) { 544a10cf76eSAxel Dörfler screen_mode mode = fScreenMode.ModeAt(j); 545a10cf76eSAxel Dörfler 546a10cf76eSAxel Dörfler if (fSelected.width == mode.width 547a10cf76eSAxel Dörfler && fSelected.height == mode.height 548a10cf76eSAxel Dörfler && kColorSpaces[i].space == mode.space 549a10cf76eSAxel Dörfler && fSelected.combine == mode.combine) { 550a10cf76eSAxel Dörfler supported = true; 551a10cf76eSAxel Dörfler break; 552a10cf76eSAxel Dörfler } 553a10cf76eSAxel Dörfler } 554a10cf76eSAxel Dörfler 555a10cf76eSAxel Dörfler BMenuItem* item = fColorsMenu->ItemAt(i); 556a10cf76eSAxel Dörfler if (item) 557a10cf76eSAxel Dörfler item->SetEnabled(supported); 558a10cf76eSAxel Dörfler } 559a10cf76eSAxel Dörfler } 560a10cf76eSAxel Dörfler 561a10cf76eSAxel Dörfler 56229e8a73aSAxel Dörfler /** Enable/disable refresh options according to current mode. */ 563a10cf76eSAxel Dörfler 564a10cf76eSAxel Dörfler void 565a10cf76eSAxel Dörfler ScreenWindow::CheckRefreshMenu() 566a10cf76eSAxel Dörfler { 56729e8a73aSAxel Dörfler float min, max; 56829e8a73aSAxel Dörfler if (fScreenMode.GetRefreshLimits(fSelected, min, max) != B_OK || min == max) 56929e8a73aSAxel Dörfler return; 570a10cf76eSAxel Dörfler 57129e8a73aSAxel Dörfler for (int32 i = fRefreshMenu->CountItems(); i-- > 0;) { 57229e8a73aSAxel Dörfler BMenuItem* item = fRefreshMenu->ItemAt(i); 57329e8a73aSAxel Dörfler BMessage* message = item->Message(); 57429e8a73aSAxel Dörfler float refresh; 57529e8a73aSAxel Dörfler if (message != NULL && message->FindFloat("refresh", &refresh) == B_OK) 57629e8a73aSAxel Dörfler item->SetEnabled(refresh >= min && refresh <= max); 577a10cf76eSAxel Dörfler } 578a10cf76eSAxel Dörfler } 579a10cf76eSAxel Dörfler 580a10cf76eSAxel Dörfler 58129e8a73aSAxel Dörfler /** Activate appropriate menu item according to selected refresh rate */ 582a10cf76eSAxel Dörfler 583a10cf76eSAxel Dörfler void 584a10cf76eSAxel Dörfler ScreenWindow::UpdateRefreshControl() 585a10cf76eSAxel Dörfler { 586a10cf76eSAxel Dörfler BString string; 587a10cf76eSAxel Dörfler refresh_rate_to_string(fSelected.refresh, string); 588a10cf76eSAxel Dörfler 589a10cf76eSAxel Dörfler BMenuItem* item = fRefreshMenu->FindItem(string.String()); 590a10cf76eSAxel Dörfler if (item) { 591a10cf76eSAxel Dörfler if (!item->IsMarked()) 592a10cf76eSAxel Dörfler item->SetMarked(true); 59329e8a73aSAxel Dörfler 594a10cf76eSAxel Dörfler // "Other…" items only contains a refresh rate when active 595a10cf76eSAxel Dörfler fOtherRefresh->SetLabel("Other…"); 596a10cf76eSAxel Dörfler return; 597a10cf76eSAxel Dörfler } 598a10cf76eSAxel Dörfler 599a10cf76eSAxel Dörfler // this is a non-standard refresh rate 600a10cf76eSAxel Dörfler 601a10cf76eSAxel Dörfler fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh); 602a10cf76eSAxel Dörfler fOtherRefresh->SetMarked(true); 603a10cf76eSAxel Dörfler 604a10cf76eSAxel Dörfler fRefreshMenu->Superitem()->SetLabel(string.String()); 605a10cf76eSAxel Dörfler 606a10cf76eSAxel Dörfler string.Append("/Other" B_UTF8_ELLIPSIS); 607a10cf76eSAxel Dörfler fOtherRefresh->SetLabel(string.String()); 608a10cf76eSAxel Dörfler } 609a10cf76eSAxel Dörfler 610a10cf76eSAxel Dörfler 611a10cf76eSAxel Dörfler void 612a10cf76eSAxel Dörfler ScreenWindow::UpdateMonitorView() 613a10cf76eSAxel Dörfler { 614a10cf76eSAxel Dörfler BMessage updateMessage(UPDATE_DESKTOP_MSG); 615a10cf76eSAxel Dörfler updateMessage.AddInt32("width", fSelected.width); 616a10cf76eSAxel Dörfler updateMessage.AddInt32("height", fSelected.height); 617a10cf76eSAxel Dörfler 618a10cf76eSAxel Dörfler PostMessage(&updateMessage, fMonitorView); 619a10cf76eSAxel Dörfler } 620a10cf76eSAxel Dörfler 621a10cf76eSAxel Dörfler 622a10cf76eSAxel Dörfler void 623a10cf76eSAxel Dörfler ScreenWindow::UpdateControls() 624a10cf76eSAxel Dörfler { 625a10cf76eSAxel Dörfler BMenuItem* item = fSwapDisplaysMenu->ItemAt((int32)fSelected.swap_displays); 626a10cf76eSAxel Dörfler if (item && !item->IsMarked()) 627a10cf76eSAxel Dörfler item->SetMarked(true); 628a10cf76eSAxel Dörfler 629a10cf76eSAxel Dörfler item = fUseLaptopPanelMenu->ItemAt((int32)fSelected.use_laptop_panel); 630a10cf76eSAxel Dörfler if (item && !item->IsMarked()) 631a10cf76eSAxel Dörfler item->SetMarked(true); 632a10cf76eSAxel Dörfler 633a10cf76eSAxel Dörfler for (int32 i = 0; i < fTVStandardMenu->CountItems(); i++) { 634a10cf76eSAxel Dörfler item = fTVStandardMenu->ItemAt(i); 635a10cf76eSAxel Dörfler 636a10cf76eSAxel Dörfler uint32 tvStandard; 637a10cf76eSAxel Dörfler item->Message()->FindInt32("tv_standard", (int32 *)&tvStandard); 638a10cf76eSAxel Dörfler if (tvStandard == fSelected.tv_standard) { 639a10cf76eSAxel Dörfler if (!item->IsMarked()) 640a10cf76eSAxel Dörfler item->SetMarked(true); 641a10cf76eSAxel Dörfler break; 642a10cf76eSAxel Dörfler } 643a10cf76eSAxel Dörfler } 644a10cf76eSAxel Dörfler 645a10cf76eSAxel Dörfler CheckResolutionMenu(); 646a10cf76eSAxel Dörfler CheckColorMenu(); 647a10cf76eSAxel Dörfler CheckRefreshMenu(); 648a10cf76eSAxel Dörfler 649a10cf76eSAxel Dörfler BString string; 650a10cf76eSAxel Dörfler resolution_to_string(fSelected, string); 651a10cf76eSAxel Dörfler item = fResolutionMenu->FindItem(string.String()); 652a10cf76eSAxel Dörfler 653a10cf76eSAxel Dörfler if (item != NULL) { 654a10cf76eSAxel Dörfler if (!item->IsMarked()) 655a10cf76eSAxel Dörfler item->SetMarked(true); 656a10cf76eSAxel Dörfler } else { 657a10cf76eSAxel Dörfler // this is bad luck - if mode has been set via screen references, 658a10cf76eSAxel Dörfler // this case cannot occur; there are three possible solutions: 659a10cf76eSAxel Dörfler // 1. add a new resolution to list 660a10cf76eSAxel Dörfler // - we had to remove it as soon as a "valid" one is selected 661a10cf76eSAxel Dörfler // - we don't know which frequencies/bit depths are supported 662a10cf76eSAxel Dörfler // - as long as we haven't the GMT formula to create 663a10cf76eSAxel Dörfler // parameters for any resolution given, we cannot 664a10cf76eSAxel Dörfler // really set current mode - it's just not in the list 665a10cf76eSAxel Dörfler // 2. choose nearest resolution 666a10cf76eSAxel Dörfler // - probably a good idea, but implies coding and testing 667a10cf76eSAxel Dörfler // 3. choose lowest resolution 668a10cf76eSAxel Dörfler // - do you really think we are so lazy? yes, we are 669a10cf76eSAxel Dörfler item = fResolutionMenu->ItemAt(0); 670a10cf76eSAxel Dörfler if (item) 671a10cf76eSAxel Dörfler item->SetMarked(true); 672a10cf76eSAxel Dörfler 673a10cf76eSAxel Dörfler // okay - at least we set menu label to active resolution 674a10cf76eSAxel Dörfler fResolutionMenu->Superitem()->SetLabel(string.String()); 675a10cf76eSAxel Dörfler } 676a10cf76eSAxel Dörfler 677a10cf76eSAxel Dörfler // mark active combine mode 678a10cf76eSAxel Dörfler for (int32 i = 0; i < kCombineModeCount; i++) { 679a10cf76eSAxel Dörfler if (kCombineModes[i].mode == fSelected.combine) { 680a10cf76eSAxel Dörfler item = fCombineMenu->ItemAt(i); 681a10cf76eSAxel Dörfler if (item && !item->IsMarked()) 682a10cf76eSAxel Dörfler item->SetMarked(true); 683a10cf76eSAxel Dörfler break; 684a10cf76eSAxel Dörfler } 685a10cf76eSAxel Dörfler } 686a10cf76eSAxel Dörfler 687a10cf76eSAxel Dörfler item = fColorsMenu->ItemAt(0); 688a10cf76eSAxel Dörfler 689a10cf76eSAxel Dörfler for (int32 i = kColorSpaceCount; i-- > 0;) { 690a10cf76eSAxel Dörfler if (kColorSpaces[i].space == fSelected.space) { 691a10cf76eSAxel Dörfler item = fColorsMenu->ItemAt(i); 692a10cf76eSAxel Dörfler break; 693a10cf76eSAxel Dörfler } 694a10cf76eSAxel Dörfler } 695a10cf76eSAxel Dörfler 696a10cf76eSAxel Dörfler if (item && !item->IsMarked()) 697a10cf76eSAxel Dörfler item->SetMarked(true); 698a10cf76eSAxel Dörfler 699a10cf76eSAxel Dörfler string.Truncate(0); 700a10cf76eSAxel Dörfler string << fSelected.BitsPerPixel() << " Bits/Pixel"; 701a10cf76eSAxel Dörfler if (string != fColorsMenu->Superitem()->Label()) 702a10cf76eSAxel Dörfler fColorsMenu->Superitem()->SetLabel(string.String()); 703a10cf76eSAxel Dörfler 704a10cf76eSAxel Dörfler UpdateMonitorView(); 705a10cf76eSAxel Dörfler UpdateRefreshControl(); 706a10cf76eSAxel Dörfler 707a10cf76eSAxel Dörfler CheckApplyEnabled(); 708a10cf76eSAxel Dörfler } 709a10cf76eSAxel Dörfler 710a10cf76eSAxel Dörfler 711a10cf76eSAxel Dörfler /** reflect active mode in chosen settings */ 712a10cf76eSAxel Dörfler 713a10cf76eSAxel Dörfler void 714a10cf76eSAxel Dörfler ScreenWindow::UpdateActiveMode() 715a10cf76eSAxel Dörfler { 716a10cf76eSAxel Dörfler // usually, this function gets called after a mode 717a10cf76eSAxel Dörfler // has been set manually; still, as the graphics driver 718a10cf76eSAxel Dörfler // is free to fiddle with mode passed, we better ask 719a10cf76eSAxel Dörfler // what kind of mode we actually got 720a10cf76eSAxel Dörfler fScreenMode.Get(fActive); 721a10cf76eSAxel Dörfler fSelected = fActive; 722a10cf76eSAxel Dörfler 723a10cf76eSAxel Dörfler UpdateControls(); 724a10cf76eSAxel Dörfler } 725a10cf76eSAxel Dörfler 726a10cf76eSAxel Dörfler 727a10cf76eSAxel Dörfler void 728a10cf76eSAxel Dörfler ScreenWindow::ScreenChanged(BRect frame, color_space mode) 729a10cf76eSAxel Dörfler { 730a10cf76eSAxel Dörfler // move window on screen, if necessary 731a10cf76eSAxel Dörfler if (frame.right <= Frame().right 732a10cf76eSAxel Dörfler && frame.bottom <= Frame().bottom) { 733a10cf76eSAxel Dörfler MoveTo((frame.Width() - Frame().Width()) / 2, 734a10cf76eSAxel Dörfler (frame.Height() - Frame().Height()) / 2); 735a10cf76eSAxel Dörfler } 736a10cf76eSAxel Dörfler } 737a10cf76eSAxel Dörfler 738a10cf76eSAxel Dörfler 739a10cf76eSAxel Dörfler void 740a10cf76eSAxel Dörfler ScreenWindow::WorkspaceActivated(int32 workspace, bool state) 741a10cf76eSAxel Dörfler { 742a10cf76eSAxel Dörfler if (fChangingAllWorkspaces) { 743a10cf76eSAxel Dörfler // we're currently changing all workspaces, so there is no need 744a10cf76eSAxel Dörfler // to update the interface 745a10cf76eSAxel Dörfler return; 746a10cf76eSAxel Dörfler } 747a10cf76eSAxel Dörfler 748a10cf76eSAxel Dörfler fScreenMode.Get(fOriginal); 749a10cf76eSAxel Dörfler fScreenMode.UpdateOriginalMode(); 750a10cf76eSAxel Dörfler 751a10cf76eSAxel Dörfler // only override current settings if they have not been changed yet 752a10cf76eSAxel Dörfler if (fSelected == fActive) 753a10cf76eSAxel Dörfler UpdateActiveMode(); 754a10cf76eSAxel Dörfler 7556edaa0f6SStefano Ceccherini BMessage message(UPDATE_DESKTOP_COLOR_MSG); 7566edaa0f6SStefano Ceccherini PostMessage(&message, fMonitorView); 757a10cf76eSAxel Dörfler } 758a10cf76eSAxel Dörfler 759a10cf76eSAxel Dörfler 760a10cf76eSAxel Dörfler void 761a10cf76eSAxel Dörfler ScreenWindow::MessageReceived(BMessage* message) 762a10cf76eSAxel Dörfler { 763a10cf76eSAxel Dörfler switch (message->what) { 764a10cf76eSAxel Dörfler case WORKSPACE_CHECK_MSG: 765a10cf76eSAxel Dörfler CheckApplyEnabled(); 766a10cf76eSAxel Dörfler break; 767a10cf76eSAxel Dörfler 768a10cf76eSAxel Dörfler case POP_WORKSPACE_CHANGED_MSG: 769a10cf76eSAxel Dörfler { 770a10cf76eSAxel Dörfler int32 index; 771a10cf76eSAxel Dörfler if (message->FindInt32("index", &index) == B_OK) 772a10cf76eSAxel Dörfler set_workspace_count(index + 1); 773a10cf76eSAxel Dörfler break; 774a10cf76eSAxel Dörfler } 775a10cf76eSAxel Dörfler 776a10cf76eSAxel Dörfler case POP_RESOLUTION_MSG: 777a10cf76eSAxel Dörfler { 778a10cf76eSAxel Dörfler message->FindInt32("width", &fSelected.width); 779a10cf76eSAxel Dörfler message->FindInt32("height", &fSelected.height); 780a10cf76eSAxel Dörfler 781a10cf76eSAxel Dörfler CheckColorMenu(); 782a10cf76eSAxel Dörfler CheckRefreshMenu(); 783a10cf76eSAxel Dörfler 784a10cf76eSAxel Dörfler UpdateMonitorView(); 785a10cf76eSAxel Dörfler UpdateRefreshControl(); 786a10cf76eSAxel Dörfler 787a10cf76eSAxel Dörfler CheckApplyEnabled(); 788a10cf76eSAxel Dörfler break; 789a10cf76eSAxel Dörfler } 790a10cf76eSAxel Dörfler 791a10cf76eSAxel Dörfler case POP_COLORS_MSG: 792a10cf76eSAxel Dörfler { 793a10cf76eSAxel Dörfler message->FindInt32("space", (int32 *)&fSelected.space); 794a10cf76eSAxel Dörfler 795a10cf76eSAxel Dörfler BString string; 796a10cf76eSAxel Dörfler string << fSelected.BitsPerPixel() << " Bits/Pixel"; 797a10cf76eSAxel Dörfler fColorsMenu->Superitem()->SetLabel(string.String()); 798a10cf76eSAxel Dörfler 799a10cf76eSAxel Dörfler CheckApplyEnabled(); 800a10cf76eSAxel Dörfler break; 801a10cf76eSAxel Dörfler } 802a10cf76eSAxel Dörfler 803a10cf76eSAxel Dörfler case POP_REFRESH_MSG: 804a10cf76eSAxel Dörfler message->FindFloat("refresh", &fSelected.refresh); 805a10cf76eSAxel Dörfler fOtherRefresh->SetLabel("Other" B_UTF8_ELLIPSIS); 806a10cf76eSAxel Dörfler // revert "Other…" label - it might have had a refresh rate prefix 807a10cf76eSAxel Dörfler 808a10cf76eSAxel Dörfler CheckApplyEnabled(); 809a10cf76eSAxel Dörfler break; 810a10cf76eSAxel Dörfler 811a10cf76eSAxel Dörfler case POP_OTHER_REFRESH_MSG: 812a10cf76eSAxel Dörfler { 81329e8a73aSAxel Dörfler // make sure menu shows something useful 814a10cf76eSAxel Dörfler UpdateRefreshControl(); 815a10cf76eSAxel Dörfler 81629e8a73aSAxel Dörfler float min = 0, max = 999; 81729e8a73aSAxel Dörfler fScreenMode.GetRefreshLimits(fSelected, min, max); 81829e8a73aSAxel Dörfler if (min < gMinRefresh) 81929e8a73aSAxel Dörfler min = gMinRefresh; 82029e8a73aSAxel Dörfler if (max > gMaxRefresh) 82129e8a73aSAxel Dörfler max = gMaxRefresh; 82229e8a73aSAxel Dörfler 823*c5d10f7aSAxel Dörfler RefreshWindow *fRefreshWindow = new RefreshWindow( 824*c5d10f7aSAxel Dörfler fRefreshField->ConvertToScreen(B_ORIGIN), fSelected.refresh, min, max); 825a10cf76eSAxel Dörfler fRefreshWindow->Show(); 826a10cf76eSAxel Dörfler break; 827a10cf76eSAxel Dörfler } 828a10cf76eSAxel Dörfler 829a10cf76eSAxel Dörfler case SET_CUSTOM_REFRESH_MSG: 830a10cf76eSAxel Dörfler { 831a10cf76eSAxel Dörfler // user pressed "done" in "Other…" refresh dialog; 832a10cf76eSAxel Dörfler // select the refresh rate chosen 833a10cf76eSAxel Dörfler message->FindFloat("refresh", &fSelected.refresh); 834a10cf76eSAxel Dörfler 835a10cf76eSAxel Dörfler UpdateRefreshControl(); 836a10cf76eSAxel Dörfler CheckApplyEnabled(); 837a10cf76eSAxel Dörfler break; 838a10cf76eSAxel Dörfler } 839a10cf76eSAxel Dörfler 840a10cf76eSAxel Dörfler case POP_COMBINE_DISPLAYS_MSG: 841a10cf76eSAxel Dörfler { 842a10cf76eSAxel Dörfler // new combine mode has bee chosen 843a10cf76eSAxel Dörfler int32 mode; 844a10cf76eSAxel Dörfler if (message->FindInt32("mode", &mode) == B_OK) 845a10cf76eSAxel Dörfler fSelected.combine = (combine_mode)mode; 846a10cf76eSAxel Dörfler 847a10cf76eSAxel Dörfler CheckResolutionMenu(); 848a10cf76eSAxel Dörfler CheckApplyEnabled(); 849a10cf76eSAxel Dörfler break; 850a10cf76eSAxel Dörfler } 851a10cf76eSAxel Dörfler 852a10cf76eSAxel Dörfler case POP_SWAP_DISPLAYS_MSG: 853a10cf76eSAxel Dörfler message->FindBool("swap", &fSelected.swap_displays); 854a10cf76eSAxel Dörfler CheckApplyEnabled(); 855a10cf76eSAxel Dörfler break; 856a10cf76eSAxel Dörfler 857a10cf76eSAxel Dörfler case POP_USE_LAPTOP_PANEL_MSG: 858a10cf76eSAxel Dörfler message->FindBool("use", &fSelected.use_laptop_panel); 859a10cf76eSAxel Dörfler CheckApplyEnabled(); 860a10cf76eSAxel Dörfler break; 861a10cf76eSAxel Dörfler 862a10cf76eSAxel Dörfler case POP_TV_STANDARD_MSG: 863a10cf76eSAxel Dörfler message->FindInt32("tv_standard", (int32 *)&fSelected.tv_standard); 864a10cf76eSAxel Dörfler CheckApplyEnabled(); 865a10cf76eSAxel Dörfler break; 866a10cf76eSAxel Dörfler 867df3f5bacSStephan Aßmus case BUTTON_LAUNCH_BACKGROUNDS_MSG: 868c5d80d47SAxel Dörfler be_roster->Launch(kBackgroundsSignature); 869df3f5bacSStephan Aßmus break; 870df3f5bacSStephan Aßmus 871a10cf76eSAxel Dörfler case BUTTON_DEFAULTS_MSG: 872a10cf76eSAxel Dörfler { 873a10cf76eSAxel Dörfler fSelected.width = 640; 874a10cf76eSAxel Dörfler fSelected.height = 480; 875a10cf76eSAxel Dörfler fSelected.space = B_CMAP8; 876a10cf76eSAxel Dörfler fSelected.refresh = 60.0; 877a10cf76eSAxel Dörfler fSelected.combine = kCombineDisable; 878a10cf76eSAxel Dörfler fSelected.swap_displays = false; 879a10cf76eSAxel Dörfler fSelected.use_laptop_panel = false; 880a10cf76eSAxel Dörfler fSelected.tv_standard = 0; 881a10cf76eSAxel Dörfler 882a10cf76eSAxel Dörfler UpdateControls(); 883a10cf76eSAxel Dörfler break; 884a10cf76eSAxel Dörfler } 885a10cf76eSAxel Dörfler 886a10cf76eSAxel Dörfler case BUTTON_REVERT_MSG: 887a10cf76eSAxel Dörfler case SET_INITIAL_MODE_MSG: 888a10cf76eSAxel Dörfler fScreenMode.Revert(); 889a10cf76eSAxel Dörfler UpdateActiveMode(); 890a10cf76eSAxel Dörfler break; 891a10cf76eSAxel Dörfler 892a10cf76eSAxel Dörfler case BUTTON_APPLY_MSG: 893a10cf76eSAxel Dörfler Apply(); 894a10cf76eSAxel Dörfler break; 895a10cf76eSAxel Dörfler 896a10cf76eSAxel Dörfler case MAKE_INITIAL_MSG: { 897a10cf76eSAxel Dörfler // user pressed "keep" in confirmation box; 898a10cf76eSAxel Dörfler // select this mode in dialog and mark it as 899a10cf76eSAxel Dörfler // previous mode; if "all workspaces" is selected, 900a10cf76eSAxel Dörfler // distribute mode to all workspaces 901a10cf76eSAxel Dörfler 902a10cf76eSAxel Dörfler // use the mode that has eventually been set and 903a10cf76eSAxel Dörfler // thus we know to be working; it can differ from 904a10cf76eSAxel Dörfler // the mode selected by user due to hardware limitation 905a10cf76eSAxel Dörfler display_mode newMode; 906a10cf76eSAxel Dörfler BScreen screen(this); 907a10cf76eSAxel Dörfler screen.GetMode(&newMode); 908a10cf76eSAxel Dörfler 909a10cf76eSAxel Dörfler if (fAllWorkspacesItem->IsMarked()) { 910a10cf76eSAxel Dörfler int32 originatingWorkspace; 911a10cf76eSAxel Dörfler 912a10cf76eSAxel Dörfler // the original panel activates each workspace in turn; 913a10cf76eSAxel Dörfler // this is disguisting and there is a SetMode 914a10cf76eSAxel Dörfler // variant that accepts a workspace id, so let's take 915a10cf76eSAxel Dörfler // this one 916a10cf76eSAxel Dörfler originatingWorkspace = current_workspace(); 917a10cf76eSAxel Dörfler 918a10cf76eSAxel Dörfler // well, this "cannot be reverted" message is not 919a10cf76eSAxel Dörfler // entirely true - at least, you can revert it 920a10cf76eSAxel Dörfler // for current workspace; to not overwrite original 921a10cf76eSAxel Dörfler // mode during workspace switch, we use this flag 922a10cf76eSAxel Dörfler fChangingAllWorkspaces = true; 923a10cf76eSAxel Dörfler 924a10cf76eSAxel Dörfler for (int32 i = 0; i < count_workspaces(); i++) { 925a10cf76eSAxel Dörfler if (i != originatingWorkspace) 926a10cf76eSAxel Dörfler screen.SetMode(i, &newMode, true); 927a10cf76eSAxel Dörfler } 928a10cf76eSAxel Dörfler 929a10cf76eSAxel Dörfler fChangingAllWorkspaces = false; 930a10cf76eSAxel Dörfler } 931a10cf76eSAxel Dörfler 932cfa91cc4SAxel Dörfler fScreenMode.UpdateOriginalMode(); 933a10cf76eSAxel Dörfler UpdateActiveMode(); 934a10cf76eSAxel Dörfler break; 935a10cf76eSAxel Dörfler } 936a10cf76eSAxel Dörfler 937a10cf76eSAxel Dörfler default: 938a10cf76eSAxel Dörfler BWindow::MessageReceived(message); 939a10cf76eSAxel Dörfler break; 940a10cf76eSAxel Dörfler } 941a10cf76eSAxel Dörfler } 942a10cf76eSAxel Dörfler 943a10cf76eSAxel Dörfler 944a10cf76eSAxel Dörfler bool 945a10cf76eSAxel Dörfler ScreenWindow::CanApply() const 946a10cf76eSAxel Dörfler { 947a10cf76eSAxel Dörfler if (fAllWorkspacesItem->IsMarked()) 948a10cf76eSAxel Dörfler return true; 949a10cf76eSAxel Dörfler 950a10cf76eSAxel Dörfler return fSelected != fActive; 951a10cf76eSAxel Dörfler } 952a10cf76eSAxel Dörfler 953a10cf76eSAxel Dörfler 954a10cf76eSAxel Dörfler bool 955a10cf76eSAxel Dörfler ScreenWindow::CanRevert() const 956a10cf76eSAxel Dörfler { 957a10cf76eSAxel Dörfler if (fActive != fOriginal) 958a10cf76eSAxel Dörfler return true; 959a10cf76eSAxel Dörfler 960a10cf76eSAxel Dörfler return CanApply(); 961a10cf76eSAxel Dörfler } 962a10cf76eSAxel Dörfler 963a10cf76eSAxel Dörfler 964a10cf76eSAxel Dörfler void 965a10cf76eSAxel Dörfler ScreenWindow::CheckApplyEnabled() 966a10cf76eSAxel Dörfler { 967a10cf76eSAxel Dörfler fApplyButton->SetEnabled(CanApply()); 968a10cf76eSAxel Dörfler fRevertButton->SetEnabled(CanRevert()); 969a10cf76eSAxel Dörfler } 970a10cf76eSAxel Dörfler 971a10cf76eSAxel Dörfler 972a10cf76eSAxel Dörfler void 973a10cf76eSAxel Dörfler ScreenWindow::Apply() 974a10cf76eSAxel Dörfler { 975a10cf76eSAxel Dörfler if (fAllWorkspacesItem->IsMarked()) { 976a10cf76eSAxel Dörfler BAlert *workspacesAlert = new BAlert("WorkspacesAlert", 977a10cf76eSAxel Dörfler "Change all workspaces? This action cannot be reverted.", "Okay", "Cancel", 978a10cf76eSAxel Dörfler NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); 979a10cf76eSAxel Dörfler 980a10cf76eSAxel Dörfler if (workspacesAlert->Go() == 1) 981a10cf76eSAxel Dörfler return; 982a10cf76eSAxel Dörfler } 983a10cf76eSAxel Dörfler 98407184a9eSAxel Dörfler status_t status = fScreenMode.Set(fSelected); 98507184a9eSAxel Dörfler if (status == B_OK) { 986a10cf76eSAxel Dörfler fActive = fSelected; 987a10cf76eSAxel Dörfler 988a10cf76eSAxel Dörfler // ToDo: only show alert when this is an unknown mode 989a10cf76eSAxel Dörfler BWindow* window = new AlertWindow(this); 990a10cf76eSAxel Dörfler window->Show(); 99107184a9eSAxel Dörfler } else { 99207184a9eSAxel Dörfler char message[256]; 99307184a9eSAxel Dörfler snprintf(message, sizeof(message), 99407184a9eSAxel Dörfler "The screen mode could not be set:\n\t%s\n", screen_errors(status)); 99507184a9eSAxel Dörfler BAlert* alert = new BAlert("Screen Alert", message, "Okay", NULL, NULL, 99607184a9eSAxel Dörfler B_WIDTH_AS_USUAL, B_WARNING_ALERT); 99707184a9eSAxel Dörfler alert->Go(); 998a10cf76eSAxel Dörfler } 99907184a9eSAxel Dörfler } 100007184a9eSAxel Dörfler 1001df3f5bacSStephan Aßmus 1002df3f5bacSStephan Aßmus void 1003df3f5bacSStephan Aßmus ScreenWindow::LayoutControls(uint32 flags) 1004df3f5bacSStephan Aßmus { 1005df3f5bacSStephan Aßmus // layout the screen box and its controls 1006df3f5bacSStephan Aßmus fWorkspaceCountField->ResizeToPreferred(); 1007df3f5bacSStephan Aßmus 1008df3f5bacSStephan Aßmus float monitorViewHeight = fMonitorView->Bounds().Height(); 1009df3f5bacSStephan Aßmus float workspaceFieldHeight = fWorkspaceCountField->Bounds().Height(); 1010df3f5bacSStephan Aßmus float backgroundsButtonHeight = fBackgroundsButton->Bounds().Height(); 1011df3f5bacSStephan Aßmus 1012df3f5bacSStephan Aßmus float screenBoxWidth = fWorkspaceCountField->Bounds().Width() + 20.0; 1013df3f5bacSStephan Aßmus float screenBoxHeight = monitorViewHeight + 5.0 1014df3f5bacSStephan Aßmus + workspaceFieldHeight + 5.0 1015df3f5bacSStephan Aßmus + backgroundsButtonHeight 1016df3f5bacSStephan Aßmus + 20.0; 1017df3f5bacSStephan Aßmus 101829e8a73aSAxel Dörfler #ifdef __HAIKU__ 1019df3f5bacSStephan Aßmus fScreenBox->MoveTo(10.0, 10.0 + fControlsBox->TopBorderOffset()); 102029e8a73aSAxel Dörfler #else 102129e8a73aSAxel Dörfler fScreenBox->MoveTo(10.0, 10.0 + 3); 102229e8a73aSAxel Dörfler #endif 1023df3f5bacSStephan Aßmus fScreenBox->ResizeTo(screenBoxWidth, screenBoxHeight); 1024df3f5bacSStephan Aßmus 1025df3f5bacSStephan Aßmus float leftOffset = 10.0; 1026df3f5bacSStephan Aßmus float topOffset = 10.0; 1027df3f5bacSStephan Aßmus fMonitorView->MoveTo(leftOffset, topOffset); 1028df3f5bacSStephan Aßmus fMonitorView->ResizeTo(screenBoxWidth - 20.0, monitorViewHeight); 1029df3f5bacSStephan Aßmus fMonitorView->SetResizingMode(B_FOLLOW_ALL); 1030df3f5bacSStephan Aßmus topOffset += monitorViewHeight + 5.0; 1031df3f5bacSStephan Aßmus 1032df3f5bacSStephan Aßmus fWorkspaceCountField->MoveTo(leftOffset, topOffset); 1033df3f5bacSStephan Aßmus fWorkspaceCountField->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); 1034df3f5bacSStephan Aßmus topOffset += workspaceFieldHeight + 5.0; 1035df3f5bacSStephan Aßmus 1036df3f5bacSStephan Aßmus fBackgroundsButton->MoveTo(leftOffset, topOffset); 1037df3f5bacSStephan Aßmus fBackgroundsButton->ResizeTo(screenBoxWidth - 20.0, backgroundsButtonHeight); 1038df3f5bacSStephan Aßmus fBackgroundsButton->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); 1039df3f5bacSStephan Aßmus 1040df3f5bacSStephan Aßmus fControlsBox->MoveTo(fScreenBox->Frame().right + 10.0, 10.0); 1041df3f5bacSStephan Aßmus 1042df3f5bacSStephan Aßmus // layout the right side 1043df3f5bacSStephan Aßmus BRect controlsRect = LayoutMenuFields(flags); 1044df3f5bacSStephan Aßmus controlsRect.InsetBy(-10.0, -10.0); 1045df3f5bacSStephan Aßmus // adjust size of controls box and move aligned buttons along 1046df3f5bacSStephan Aßmus float xDiff = controlsRect.right - fControlsBox->Bounds().right; 1047df3f5bacSStephan Aßmus float yDiff = controlsRect.bottom - fControlsBox->Bounds().bottom; 1048df3f5bacSStephan Aßmus if (yDiff < 0.0) { 1049df3f5bacSStephan Aßmus // don't shrink vertically 1050df3f5bacSStephan Aßmus yDiff = 0.0; 1051df3f5bacSStephan Aßmus } 1052df3f5bacSStephan Aßmus 1053df3f5bacSStephan Aßmus fControlsBox->ResizeBy(xDiff, yDiff); 1054df3f5bacSStephan Aßmus 1055df3f5bacSStephan Aßmus // align bottom of boxen 1056df3f5bacSStephan Aßmus float boxBottomDiff = fControlsBox->Frame().bottom - fScreenBox->Frame().bottom; 1057df3f5bacSStephan Aßmus if (boxBottomDiff > 0) 1058df3f5bacSStephan Aßmus fScreenBox->ResizeBy(0.0, boxBottomDiff); 1059df3f5bacSStephan Aßmus else 1060df3f5bacSStephan Aßmus fControlsBox->ResizeBy(0.0, -boxBottomDiff); 1061df3f5bacSStephan Aßmus 1062df3f5bacSStephan Aßmus BRect boxFrame = fScreenBox->Frame() | fControlsBox->Frame(); 1063df3f5bacSStephan Aßmus 1064df3f5bacSStephan Aßmus // layout rest of buttons 1065df3f5bacSStephan Aßmus fDefaultsButton->ResizeToPreferred(); 1066df3f5bacSStephan Aßmus fDefaultsButton->MoveTo(boxFrame.left, boxFrame.bottom + 8); 1067df3f5bacSStephan Aßmus 1068df3f5bacSStephan Aßmus fRevertButton->ResizeToPreferred(); 1069df3f5bacSStephan Aßmus fRevertButton->MoveTo(fDefaultsButton->Frame().right + 10, 1070df3f5bacSStephan Aßmus fDefaultsButton->Frame().top); 1071df3f5bacSStephan Aßmus 1072df3f5bacSStephan Aßmus fApplyButton->ResizeToPreferred(); 1073df3f5bacSStephan Aßmus fApplyButton->MoveTo(boxFrame.right - fApplyButton->Bounds().Width(), 1074df3f5bacSStephan Aßmus fDefaultsButton->Frame().top); 1075df3f5bacSStephan Aßmus 1076df3f5bacSStephan Aßmus ResizeTo(boxFrame.right + 10, fDefaultsButton->Frame().bottom + 10); 1077df3f5bacSStephan Aßmus } 1078df3f5bacSStephan Aßmus 1079df3f5bacSStephan Aßmus 1080df3f5bacSStephan Aßmus BRect 1081df3f5bacSStephan Aßmus ScreenWindow::LayoutMenuFields(uint32 flags, bool sideBySide) 1082df3f5bacSStephan Aßmus { 1083df3f5bacSStephan Aßmus BList menuFields; 1084df3f5bacSStephan Aßmus menuFields.AddItem((void*)fResolutionField); 1085df3f5bacSStephan Aßmus menuFields.AddItem((void*)fColorsField); 1086df3f5bacSStephan Aßmus menuFields.AddItem((void*)fRefreshField); 1087df3f5bacSStephan Aßmus 1088df3f5bacSStephan Aßmus BRect frame; 1089df3f5bacSStephan Aßmus 1090df3f5bacSStephan Aßmus if (sideBySide) 1091df3f5bacSStephan Aßmus frame = stack_and_align_menu_fields(menuFields); 1092df3f5bacSStephan Aßmus 1093df3f5bacSStephan Aßmus if (sideBySide) 1094df3f5bacSStephan Aßmus menuFields.MakeEmpty(); 1095df3f5bacSStephan Aßmus 1096df3f5bacSStephan Aßmus if (flags & SHOW_COMBINE_FIELD) 1097df3f5bacSStephan Aßmus menuFields.AddItem((void*)fCombineField); 1098df3f5bacSStephan Aßmus if (flags & SHOW_SWAP_FIELD) 1099df3f5bacSStephan Aßmus menuFields.AddItem((void*)fSwapDisplaysField); 1100df3f5bacSStephan Aßmus if (flags & SHOW_LAPTOP_PANEL_FIELD) 1101df3f5bacSStephan Aßmus menuFields.AddItem((void*)fUseLaptopPanelField); 1102df3f5bacSStephan Aßmus if (flags & SHOW_TV_STANDARD_FIELD) 1103df3f5bacSStephan Aßmus menuFields.AddItem((void*)fTVStandardField); 1104df3f5bacSStephan Aßmus 1105df3f5bacSStephan Aßmus if (sideBySide) { 1106df3f5bacSStephan Aßmus if (menuFields.CountItems() > 0) { 1107df3f5bacSStephan Aßmus ((BMenuField*)menuFields.FirstItem())->MoveTo(frame.right + 8.0, frame.top); 1108df3f5bacSStephan Aßmus frame = frame | stack_and_align_menu_fields(menuFields); 1109df3f5bacSStephan Aßmus } 1110df3f5bacSStephan Aßmus } else { 1111df3f5bacSStephan Aßmus frame = stack_and_align_menu_fields(menuFields); 1112df3f5bacSStephan Aßmus } 1113df3f5bacSStephan Aßmus 1114df3f5bacSStephan Aßmus return frame; 1115df3f5bacSStephan Aßmus } 1116df3f5bacSStephan Aßmus 1117