diff --git a/src/prefs/screen/AlertView.cpp b/src/prefs/screen/AlertView.cpp index bf59b8e4ad..7381c8321b 100644 --- a/src/prefs/screen/AlertView.cpp +++ b/src/prefs/screen/AlertView.cpp @@ -7,12 +7,12 @@ #include "Constants.h" AlertView::AlertView(BRect frame, char *name) - : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) + :BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) { count = 8; fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT); - fBitmap->SetBits(BitmapBits, 32 * 32, 0, B_COLOR_8_BIT); + fBitmap->SetBits(bitmapBits, 32 * 32, 0, B_COLOR_8_BIT); } diff --git a/src/prefs/screen/AlertView.h b/src/prefs/screen/AlertView.h index f3077d660c..78d50a06f9 100644 --- a/src/prefs/screen/AlertView.h +++ b/src/prefs/screen/AlertView.h @@ -10,7 +10,7 @@ public: AlertView(BRect frame, char *name); virtual void AttachedToWindow(); virtual void Draw(BRect updateRect); - int32 count; + uint32 count; private: BBitmap *fBitmap; diff --git a/src/prefs/screen/AlertWindow.cpp b/src/prefs/screen/AlertWindow.cpp index 4839ef3667..67a1517584 100644 --- a/src/prefs/screen/AlertWindow.cpp +++ b/src/prefs/screen/AlertWindow.cpp @@ -1,12 +1,8 @@ -#include #include -#include -#include #include +#include #include -#include - #include "AlertWindow.h" #include "AlertView.h" #include "Constants.h" @@ -20,31 +16,28 @@ AlertWindow::AlertWindow(BRect frame) AddChild(fAlertView); - BRect ButtonRect; + BRect buttonRect; + buttonRect.Set(215.0, 59.0, 400.0, 190.0); - ButtonRect.Set(215.0, 59.0, 400.0, 190.0); - - fKeepButton = new BButton(ButtonRect, "KeepButton", "Keep", - new BMessage(BUTTON_KEEP_MSG)); + fKeepButton = new BButton(buttonRect, "KeepButton", "Keep", + new BMessage(BUTTON_KEEP_MSG)); fKeepButton->AttachedToWindow(); fKeepButton->ResizeToPreferred(); fAlertView->AddChild(fKeepButton); - ButtonRect.Set(130.0, 59.0, 400.0, 190.0); + buttonRect.Set(130.0, 59.0, 400.0, 190.0); - fRevertButton = new BButton(ButtonRect, "RevertButton", "Revert", - new BMessage(BUTTON_REVERT_MSG)); + fRevertButton = new BButton(buttonRect, "RevertButton", "Revert", + new BMessage(BUTTON_REVERT_MSG)); fRevertButton->AttachedToWindow(); fRevertButton->ResizeToPreferred(); fAlertView->AddChild(fRevertButton); - BMessenger Messenger(this); - - fRunner = new BMessageRunner(Messenger, new BMessage(DIM_COUNT_MSG), 1000000, 10); + fRunner = new BMessageRunner(this, new BMessage(DIM_COUNT_MSG), 1000000, 10); } @@ -53,9 +46,7 @@ AlertWindow::QuitRequested() { delete fRunner; - Quit(); - - return true; + return BWindow::QuitRequested(); } diff --git a/src/prefs/screen/Bitmaps.h b/src/prefs/screen/Bitmaps.h index 8ee7a9e4df..e2950a21e9 100644 --- a/src/prefs/screen/Bitmaps.h +++ b/src/prefs/screen/Bitmaps.h @@ -5,7 +5,7 @@ class Bitmap; -const unsigned char BitmapBits [] = { +const unsigned char bitmapBits [] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfa,0xfa,0xfa,0x00,0x00,0xff, diff --git a/src/prefs/screen/Jamfile b/src/prefs/screen/Jamfile index 6e82d11c47..2827bb26d0 100644 --- a/src/prefs/screen/Jamfile +++ b/src/prefs/screen/Jamfile @@ -2,8 +2,8 @@ SubDir OBOS_TOP src prefs screen ; SubDirC++Flags [ FDefines BEOS_R5_COMPATIBLE ] ; -AddResources Screen : Screen.rdef ; +AddResources Screen : Screen.rsrc ; -Preference Screen : AlertView.cpp AlertWindow.cpp RefreshSlider.cpp RefreshView.cpp RefreshWindow.cpp Screen.cpp ScreenDrawView.cpp ScreenSettings.cpp ScreenView.cpp ScreenWindow.cpp Utility.cpp ; +Preference Screen : AlertView.cpp AlertWindow.cpp RefreshSlider.cpp RefreshView.cpp RefreshWindow.cpp Screen.cpp ScreenDrawView.cpp ScreenSettings.cpp ScreenWindow.cpp Utility.cpp ; LinkSharedOSLibs Screen : be root ; diff --git a/src/prefs/screen/RefreshSlider.cpp b/src/prefs/screen/RefreshSlider.cpp index 29f9ee1786..d84c587ae8 100644 --- a/src/prefs/screen/RefreshSlider.cpp +++ b/src/prefs/screen/RefreshSlider.cpp @@ -1,17 +1,12 @@ -#include #include -#include -#include -#include -#include #include #include "RefreshSlider.h" #include "Constants.h" RefreshSlider::RefreshSlider(BRect frame) - : BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, gMaxRefresh * 10), + :BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, gMaxRefresh * 10), fStatus(new char[32]) { } diff --git a/src/prefs/screen/RefreshView.cpp b/src/prefs/screen/RefreshView.cpp index 09afd88313..d94c42bc77 100644 --- a/src/prefs/screen/RefreshView.cpp +++ b/src/prefs/screen/RefreshView.cpp @@ -1,38 +1,17 @@ -#include - #include "RefreshView.h" RefreshView::RefreshView(BRect rect, char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) + : BBox(rect, name) { } -void -RefreshView::AttachedToWindow() -{ - rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(grey); -} - - void RefreshView::Draw(BRect updateRect) { - rgb_color dark3 = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT); - rgb_color white = { 255, 255, 255, 255 }; rgb_color black = { 0, 0, 0, 255 }; - BRect bounds(Bounds()); - SetHighColor(white); - - StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top)); - StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.left, bounds.bottom)); - - SetHighColor(dark3); - - StrokeLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.right, bounds.bottom)); - StrokeLine(BPoint(bounds.right, bounds.bottom), BPoint(bounds.right, bounds.top)); + BBox::Draw(updateRect); SetHighColor(black); SetLowColor(ViewColor()); diff --git a/src/prefs/screen/RefreshView.h b/src/prefs/screen/RefreshView.h index 436ea5f4bf..af09113b4b 100644 --- a/src/prefs/screen/RefreshView.h +++ b/src/prefs/screen/RefreshView.h @@ -1,13 +1,12 @@ #ifndef __REFRESHVIEW_H #define __REFRESHVIEW_H -#include +#include -class RefreshView : public BView +class RefreshView : public BBox { public: RefreshView(BRect frame, char *name); - virtual void AttachedToWindow(); virtual void Draw(BRect updateRect); }; diff --git a/src/prefs/screen/RefreshWindow.cpp b/src/prefs/screen/RefreshWindow.cpp index e24910ba42..f1ee3d9148 100644 --- a/src/prefs/screen/RefreshWindow.cpp +++ b/src/prefs/screen/RefreshWindow.cpp @@ -1,9 +1,8 @@ -#include -#include -#include -#include - #include +#include +#include +#include +#include #include "RefreshWindow.h" #include "RefreshView.h" @@ -14,18 +13,18 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value) : BWindow(frame, "Refresh Rate", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES) { BRect bounds(Bounds()); + bounds.InsetBy(-1, -1); fRefreshView = new RefreshView(bounds, "RefreshView"); - AddChild(fRefreshView); - BRect SliderRect; + BRect sliderRect; BString maxRefresh; maxRefresh << gMaxRefresh; - SliderRect.Set(10.0, 35.0, 299.0, 60.0); + sliderRect.Set(10.0, 35.0, 299.0, 60.0); - fRefreshSlider = new RefreshSlider(SliderRect); + fRefreshSlider = new RefreshSlider(sliderRect); fRefreshSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fRefreshSlider->SetHashMarkCount(10); @@ -55,8 +54,6 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value) fCancelButton->ResizeToPreferred(); fRefreshView->AddChild(fCancelButton); - - PostMessage(SLIDER_INVOKE_MSG); } @@ -74,13 +71,12 @@ RefreshWindow::MessageReceived(BMessage* message) { case BUTTON_DONE_MSG: { - BMessenger messenger(kAppSignature); BMessage message(SET_CUSTOM_REFRESH_MSG); - + float value = (float)fRefreshSlider->Value() / 10; message.AddFloat("refresh", value); - messenger.SendMessage(&message); + be_app->PostMessage(&message); PostMessage(B_QUIT_REQUESTED); diff --git a/src/prefs/screen/Screen.cpp b/src/prefs/screen/Screen.cpp index f63f03aace..77fa1b31d6 100644 --- a/src/prefs/screen/Screen.cpp +++ b/src/prefs/screen/Screen.cpp @@ -25,10 +25,10 @@ ScreenApplication::ScreenApplication() void ScreenApplication::AboutRequested() { - BAlert *AboutAlert = new BAlert("About", "Screen by Rafael Romo, Stefano Ceccherini\nThe OBOS place to configure your monitor", + BAlert *aboutAlert = new BAlert("About", "Screen by Rafael Romo, Stefano Ceccherini\nThe OBOS place to configure your monitor", "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT); - AboutAlert->SetShortcut(0, B_OK); - AboutAlert->Go(); + aboutAlert->SetShortcut(0, B_OK); + aboutAlert->Go(); } diff --git a/src/prefs/screen/Screen.rdef b/src/prefs/screen/Screen.rdef index 8ffe32b018..d80a8331a6 100644 --- a/src/prefs/screen/Screen.rdef +++ b/src/prefs/screen/Screen.rdef @@ -1,33 +1,9 @@ resource(1, "BEOS:APP_FLAGS") #'APPF' $"00000000"; -resource(1, "BEOS:APP_VERSION") #'APPV' array -{ - $"000000000900000000000000000000000100000053637265656E20302E390000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"000000000000000000000000000000000000000053637265656E20302E390000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"000000000000000000000000000000000000000080031400FC1057608003FA80" - $"EC088C7400000000FC105780800329008005FF808002DD408000600380032900" - $"8005FF801B1B1B1BFC1057C0FC105A7C000000018003FA800000000180032900" - $"8005FF808002DD4080006003EC02ED808005FF8000000000FC1057D0EC112000" - $"EC01BCCC1B1B1B1B00000000FC105A7C000000018003FA800000000180006003" - $"000000018001DF1C8001DF2CEC02ED808003AA8000000000FC1058108003FA80" - $"EC01BCCCEC02ED80FC105810EC112000EC01BD2800000001FC10582000000000" - $"EC02ED84FFFFFFFFEC05B4FCFC1058B88005FF808002DD40FC1058508001926C" - $"FC1059B8EC02ED80FC105850EC112000EC01BD2880022F40FC105870EC112000" - $"8005FF80FFFFFFFFEC05B4FCFC1059380000000400040459800060038003FA80" - $"8005FF8000000000FC105890420C0000EC019AB40000010043300000EC112000" - $"8003AA8000000000" -}; +resource app_version { major = 0, minor = 8 }; -resource(101, "BEOS:L:STD_ICON") #'ICON' array +resource large_icon { $"FFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFF001B0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -63,7 +39,7 @@ resource(101, "BEOS:L:STD_ICON") #'ICON' array $"FFFFFFFF0000000E0F0F0F0F0F0F0F0E0F0FFFFFFFFFFF000000FFFFFFFFFFFF" }; -resource(101, "BEOS:M:STD_ICON") #'MICN' array +resource mini_icon { $"FFFFFF0000FFFFFFFFFFFFFFFFFFFFFF" $"FFFF001B1B0000FFFFFFFFFFFFFFFFFF" @@ -83,6 +59,6 @@ resource(101, "BEOS:M:STD_ICON") #'MICN' array $"FFFF00000E0F0F0F000000000000FFFF" }; -resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Be-SCRN"; +resource app_signature "application/x-vnd.Be-SCRN"; resource(1, "BEOS:FILE_TYPES") message; diff --git a/src/prefs/screen/ScreenApplication.h b/src/prefs/screen/ScreenApplication.h index f9fde753e2..53daf05d0c 100644 --- a/src/prefs/screen/ScreenApplication.h +++ b/src/prefs/screen/ScreenApplication.h @@ -1,8 +1,7 @@ #ifndef __SCREENAPPLICATION_H #define __SCREENAPPLICATION_H -#include "ScreenWindow.h" - +class ScreenWindow; class ScreenApplication : public BApplication { public: diff --git a/src/prefs/screen/ScreenDrawView.cpp b/src/prefs/screen/ScreenDrawView.cpp index fb2bd24ae9..ad955f2c45 100644 --- a/src/prefs/screen/ScreenDrawView.cpp +++ b/src/prefs/screen/ScreenDrawView.cpp @@ -1,19 +1,19 @@ #include -#include #include +#include #include #include #include #include -#include #include +#include #include "Constants.h" #include "ScreenDrawView.h" ScreenDrawView::ScreenDrawView(BRect rect, char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) + :BBox(rect, name) { BScreen screen(B_MAIN_SCREEN_ID); if (!screen.IsValid()) @@ -42,14 +42,6 @@ ScreenDrawView::~ScreenDrawView() } -void -ScreenDrawView::AttachedToWindow() -{ - rgb_color greyColor = { 216, 216, 216, 255 }; - SetViewColor(greyColor); -} - - void ScreenDrawView::MouseDown(BPoint point) { @@ -199,24 +191,32 @@ ScreenDrawView::Draw(BRect updateRect) StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0)); } #else + BRect bounds(Bounds()); + SetHighColor(desktopColor); - FillRect(Bounds()); + + FillRect(bounds); + + + SetDrawingMode(B_OP_OVER); + BRect bitmapBounds(fScreen1->Bounds()); BRect dest; - dest.left = Bounds().left; - dest.top = Bounds().top; - dest.right = Bounds().left + (bitmapBounds.Width() * 100) / fWidth; - dest.bottom = Bounds().top + (bitmapBounds.Height() * 100) / fHeight; - DrawBitmap(fScreen1, dest); + dest.left = bounds.left; + dest.top = bounds.top; + dest.right = bounds.left + (bitmapBounds.Width() * 100) / fWidth; + dest.bottom = bounds.top + (bitmapBounds.Height() * 100) / fHeight; + DrawBitmapAsync(fScreen1, dest); BRect bitmapBounds2(fScreen2->Bounds()); BRect dest2; - dest2.top = Bounds().top; - dest2.right = Bounds().right; - dest2.bottom = Bounds().top + (bitmapBounds2.Height() * 100) / fHeight; - dest2.left = Bounds().right - (bitmapBounds2.Width() * 100) / fWidth; + dest2.top = bounds.top; + dest2.right = bounds.right; + dest2.bottom = bounds.top + (bitmapBounds2.Height() * 100) / fHeight; + dest2.left = bounds.right - (bitmapBounds2.Width() * 100) / fWidth; - DrawBitmap(fScreen2, dest2); + DrawBitmapAsync(fScreen2, dest2); + Flush(); #endif } @@ -229,11 +229,11 @@ ScreenDrawView::MessageReceived(BMessage* message) { case UPDATE_DESKTOP_MSG: { - BString resolution; + BString resolution; message->FindString("resolution", &resolution); int32 nextWidth = atoi(resolution.String()); - resolution.Truncate(resolution.FindFirst('x') + 1); + resolution.Remove(0, resolution.FindFirst('x') + 1); if (fWidth != nextWidth) { fWidth = nextWidth; diff --git a/src/prefs/screen/ScreenDrawView.h b/src/prefs/screen/ScreenDrawView.h index d7354ccf83..f80d07f88d 100644 --- a/src/prefs/screen/ScreenDrawView.h +++ b/src/prefs/screen/ScreenDrawView.h @@ -1,14 +1,13 @@ #ifndef __SCREENDRAWVIEW_H #define __SCREENDRAWVIEW_H -#include +#include -class ScreenDrawView : public BView +class ScreenDrawView : public BBox { public: ScreenDrawView(BRect frame, char *name); ~ScreenDrawView(); - virtual void AttachedToWindow(); virtual void Draw(BRect updateRect); virtual void MessageReceived(BMessage *message); virtual void MouseDown(BPoint point); @@ -17,8 +16,10 @@ private: rgb_color desktopColor; int32 fWidth; int32 fHeight; +#ifdef USE_BITMAPS BBitmap *fScreen1, *fScreen2; +#endif }; #endif diff --git a/src/prefs/screen/ScreenView.cpp b/src/prefs/screen/ScreenView.cpp deleted file mode 100644 index fe479bd6bf..0000000000 --- a/src/prefs/screen/ScreenView.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include - -#include "ScreenView.h" -#include "Utility.h" - -ScreenView::ScreenView(BRect rect, char *name) - : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) -{ -} - - -void -ScreenView::AttachedToWindow() -{ - rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(grey); -} - - -void -ScreenView::Draw(BRect updateRect) -{ - rgb_color white = { 255, 255, 255, 255 }; - rgb_color dark3 = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT); - rgb_color black = { 0, 0, 0, 255 }; - - BRect bounds(Bounds()); - - SetHighColor(white); - - StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top)); - StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.left, bounds.bottom)); - - SetHighColor(dark3); - - StrokeLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.right, bounds.bottom)); - StrokeLine(BPoint(bounds.right, bounds.bottom), BPoint(bounds.right, bounds.top)); - - SetHighColor(black); -} diff --git a/src/prefs/screen/ScreenView.h b/src/prefs/screen/ScreenView.h deleted file mode 100644 index 011a038813..0000000000 --- a/src/prefs/screen/ScreenView.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __SCREENVIEW_H -#define __SCREENVIEW_H - -#include - -class ScreenView : public BView -{ -public: - ScreenView(BRect frame, char *name); - virtual void AttachedToWindow(); - virtual void Draw(BRect updateRect); -}; - -#endif diff --git a/src/prefs/screen/ScreenWindow.cpp b/src/prefs/screen/ScreenWindow.cpp index 272e9f1e2f..1774a8079c 100644 --- a/src/prefs/screen/ScreenWindow.cpp +++ b/src/prefs/screen/ScreenWindow.cpp @@ -1,22 +1,24 @@ #include #include +#include #include #include -#include #include +#include #include +#include #include #include #include -#include #include #include #include +#include "RefreshWindow.h" #include "ScreenWindow.h" #include "ScreenDrawView.h" -#include "ScreenView.h" +#include "ScreenSettings.h" #include "AlertWindow.h" #include "Constants.h" #include "Utility.h" @@ -38,13 +40,26 @@ colorspace_to_string(uint32 colorspace) } -static const char* -mode_to_string(display_mode mode) +static uint32 +string_to_colorspace(const char* string) { - char string[128]; - sprintf(string, "%d x %d", mode.virtual_width, mode.virtual_height); + if (!strcmp(string, "8 Bits/Pixel")) + return B_CMAP8; + else if (!strcmp(string, "15 Bits/Pixel")) + return B_RGB15; + else if (!strcmp(string, "16 Bits/Pixel")) + return B_RGB16; + else if (!strcmp(string, "32 Bits/Pixel")) + return B_RGB32; - return string; + return B_CMAP8; //Should return an error? +} + + +static void +mode_to_string(display_mode mode, char dest[]) +{ + sprintf(dest, "%d x %d", mode.virtual_width, mode.virtual_height); } @@ -59,26 +74,21 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) screen.GetModeList(&fSupportedModes, &fTotalModes); - fScreenView = new ScreenView(frame, "ScreenView"); + frame.InsetBy(-1, -1); + fScreenView = new BBox(frame, "ScreenView"); + fScreenDrawView = new ScreenDrawView(BRect(20.0, 16.0, 122.0, 93.0), "ScreenDrawView"); + AddChild(fScreenView); fSettings = Settings; - BRect ScreenBoxRect(11.0, 18.0, 153.0, 155.0); - BRect ScreenDrawViewRect(20.0, 16.0, 122.0, 93.0); - BRect ControlsBoxRect; - BRect WorkspaceMenuRect; - BRect WorkspaceCountMenuRect; - BRect ControlMenuRect; - BRect ButtonRect; - - BBox *screenBox = new BBox(ScreenBoxRect); + BRect screenBoxRect(11.0, 18.0, 153.0, 155.0); + BBox *screenBox = new BBox(screenBoxRect); screenBox->SetBorder(B_FANCY_BORDER); - - fScreenDrawView = new ScreenDrawView(ScreenDrawViewRect, "ScreenDrawView"); - - fWorkspaceCountMenu = new BPopUpMenu("", true, true); + fWorkspaceCountMenu = new BPopUpMenu("", true, true); + fWorkspaceCountField = new BMenuField(BRect(7.0, 107.0, 135.0, 127.0), "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true); + for (int32 count = 1; count <= 32; count++) { BString workspaceCount; workspaceCount << count; @@ -91,11 +101,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String()); marked->SetMarked(true); - - WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0); - - fWorkspaceCountField = new BMenuField(WorkspaceCountMenuRect, "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true); - + fWorkspaceCountField->SetDivider(91.0); screenBox->AddChild(fScreenDrawView); @@ -109,18 +115,15 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fCurrentWorkspaceItem->SetMarked(true); fWorkspaceMenu->AddItem(fCurrentWorkspaceItem); - WorkspaceMenuRect.Set(0.0, 0.0, 132.0, 18.0); + BRect workspaceMenuRect(0.0, 0.0, 132.0, 18.0); + fWorkspaceField = new BMenuField(workspaceMenuRect, "WorkspaceMenu", NULL, fWorkspaceMenu, true); - fWorkspaceField = new BMenuField(WorkspaceMenuRect, "WorkspaceMenu", NULL, fWorkspaceMenu, true); - - ControlsBoxRect.Set(164.0, 7.0, 345.0, 155.0); - - BBox *controlsBox = new BBox(ControlsBoxRect); + BRect controlsBoxRect(164.0, 7.0, 345.0, 155.0); + BBox *controlsBox = new BBox(controlsBoxRect); controlsBox->SetBorder(B_FANCY_BORDER); controlsBox->SetLabel(fWorkspaceField); - ButtonRect.Set(88.0, 114.0, 200.0, 150.0); - + BRect ButtonRect(88.0, 114.0, 200.0, 150.0); fApplyButton = new BButton(ButtonRect, "ApplyButton", "Apply", new BMessage(BUTTON_APPLY_MSG)); @@ -135,9 +138,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) CheckUpdateDisplayModes(); - ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0); - - fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true); + BRect controlMenuRect(33.0, 30.0, 171.0, 48.0); + fResolutionField = new BMenuField(controlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true); marked = fResolutionMenu->ItemAt(0); marked->SetMarked(true); @@ -146,9 +148,9 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) controlsBox->AddChild(fResolutionField); - ControlMenuRect.Set(50.0, 58.0, 171.0, 76.0); + controlMenuRect.Set(50.0, 58.0, 171.0, 76.0); - fColorsField = new BMenuField(ControlMenuRect, "ColorsMenu", "Colors:", fColorsMenu, true); + fColorsField = new BMenuField(controlMenuRect, "ColorsMenu", "Colors:", fColorsMenu, true); marked = fColorsMenu->ItemAt(0); marked->SetMarked(true); @@ -169,10 +171,11 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fRefreshMenu->AddItem(new BMenuItem("100 Hz", new BMessage(POP_REFRESH_MSG))); fRefreshMenu->AddItem(new BMenuItem("Other...", new BMessage(POP_OTHER_REFRESH_MSG))); - - ControlMenuRect.Set(19.0, 86.0, 171.0, 104.0); - fRefreshField = new BMenuField(ControlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true); + + controlMenuRect.Set(19.0, 86.0, 171.0, 104.0); + + fRefreshField = new BMenuField(controlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true); marked = fRefreshMenu->FindItem("60 Hz"); marked->SetMarked(true); @@ -204,10 +207,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fScreenView->AddChild(fRevertButton); - display_mode mode; - + display_mode mode; screen.GetMode(&mode); - fInitialMode = mode; string.Truncate(0); @@ -316,9 +317,9 @@ ScreenWindow::MessageReceived(BMessage* message) case POP_WORKSPACE_CHANGED_MSG: { - BMenuItem *Item = fWorkspaceCountMenu->FindMarked(); + BMenuItem *item = fWorkspaceCountMenu->FindMarked(); - set_workspace_count(fWorkspaceCountMenu->IndexOf(Item) + 1); + set_workspace_count(fWorkspaceCountMenu->IndexOf(item) + 1); break; } @@ -326,11 +327,12 @@ ScreenWindow::MessageReceived(BMessage* message) case POP_RESOLUTION_MSG: { CheckApplyEnabled(); - + BMessage newMessage(UPDATE_DESKTOP_MSG); const char *resolution = fResolutionMenu->FindMarked()->Label(); + //CheckModesByResolution(resolution); newMessage.AddString("resolution", resolution); PostMessage(&newMessage, fScreenDrawView); @@ -420,7 +422,7 @@ ScreenWindow::MessageReceived(BMessage* message) BScreen screen(B_MAIN_SCREEN_ID); if (!screen.IsValid()) break; - + screen.SetMode(&fInitialMode, true); } break; @@ -452,25 +454,16 @@ ScreenWindow::MessageReceived(BMessage* message) else refresh = atof(fRefreshMenu->FindMarked()->Label()); - for (uint32 c = 0; c < fTotalModes; c++) { - + for (uint32 c = 0; c < fTotalModes; c++) { if ((fSupportedModes[c].virtual_width == width) - && (fSupportedModes[c].virtual_height == height)) - + && (fSupportedModes[c].virtual_height == height) + && (fSupportedModes[c].space == string_to_colorspace(fColorsMenu->FindMarked()->Label()))) mode = &fSupportedModes[c]; } mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) * refresh / 1000); - if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel")) - mode->space = B_CMAP8; - else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("15 Bits/Pixel")) - mode->space = B_RGB15; - else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("16 Bits/Pixel")) - mode->space = B_RGB16; - else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("32 Bits/Pixel")) - mode->space = B_RGB32; - + //mode->space = string_to_colorspace(fColorsMenu->FindMarked()->Label()); mode->h_display_start = 0; mode->v_display_start = 0; @@ -486,19 +479,8 @@ ScreenWindow::MessageReceived(BMessage* message) break; } - - int32 old = current_workspace(); - int32 totalWorkspaces = count_workspaces(); - - for (int32 count = 0; count < totalWorkspaces; count ++) { - activate_workspace(count); - screen.SetMode(mode, true); - } - - activate_workspace(old); } - else - screen.SetMode(mode); + screen.SetMode(mode); BRect rect(100.0, 100.0, 400.0, 193.0); @@ -521,14 +503,13 @@ ScreenWindow::MessageReceived(BMessage* message) BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); other->SetMarked(true); - + BString string; string << fCustomRefresh; int32 point = string.FindFirst('.'); string.Truncate(point + 2); string << " Hz/Other..."; - fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String()); point = string.FindFirst('/'); @@ -552,7 +533,22 @@ ScreenWindow::MessageReceived(BMessage* message) display_mode mode; screen.GetMode(&mode); - screen.SetMode(&mode, true); + + if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) { + + int32 old = current_workspace(); + int32 totalWorkspaces = count_workspaces(); + fRevertButton->SetEnabled(false); + + for (int32 count = 1; count <= totalWorkspaces; count++) { + activate_workspace(count); + screen.SetMode(&mode, true); + } + + activate_workspace(old); + + } else + screen.SetMode(&mode, true); fInitialRefreshN = fCustomRefresh; fInitialResolution = fResolutionMenu->FindMarked(); @@ -581,7 +577,8 @@ ScreenWindow::CheckApplyEnabled() } else { fApplyButton->SetEnabled(false); fRevertButton->SetEnabled(false); - } + } + } @@ -591,8 +588,9 @@ ScreenWindow::CheckUpdateDisplayModes() uint32 c; // Add supported resolutions to the menu + char mode[128]; for (c = 0; c < fTotalModes; c++) { - const char *mode = mode_to_string(fSupportedModes[c]); + mode_to_string(fSupportedModes[c], mode); if (!fResolutionMenu->FindItem(mode)) fResolutionMenu->AddItem(new BMenuItem(mode, new BMessage(POP_RESOLUTION_MSG))); @@ -605,14 +603,44 @@ ScreenWindow::CheckUpdateDisplayModes() if (!fColorsMenu->FindItem(colorSpace)) fColorsMenu->AddItem(new BMenuItem(colorSpace, new BMessage(POP_COLORS_MSG))); } -/* - XXX: BeOS's BScreen limits the refresh to 85 hz. I hope that OpenBeOS BScreen will remove + + /*XXX: BeOS's BScreen limits the refresh to 85 hz (or is it the nvidia driver?). + I hope that OpenBeOS BScreen will remove this limitation. for (c = 0; c < fTotalModes; c++) { display_mode *mode = &fSupportedModes[c]; int32 refresh = (mode->timing.pixel_clock * 1000) / (mode->timing.h_total * mode->timing.v_total); - printf("%d\n", refresh); + printf("width %d, height %d, refresh %d\n", mode->virtual_width, mode->virtual_height, refresh); } */ } + + +void +ScreenWindow::CheckModesByResolution(const char *res) +{ + BString resolution(res); + + bool found = false; + uint32 c; + int32 width = atoi(resolution.String()); + resolution.Remove(0, resolution.FindFirst('x') + 1); + int32 height = atoi(resolution.String()); + + for (c = 0; c < fTotalModes; c++) { + if ((fSupportedModes[c].virtual_width == width) + && (fSupportedModes[c].virtual_height == height)) { + if (string_to_colorspace(fColorsMenu->FindMarked()->Label()) + == fSupportedModes[c].space) { + found = true; + break; + } + } + } + + if (!found) { + fColorsMenu->ItemAt(fColorsMenu->IndexOf(fColorsMenu->FindMarked()) - 1)->SetMarked(true); + printf("not found\n"); + } +} diff --git a/src/prefs/screen/ScreenWindow.h b/src/prefs/screen/ScreenWindow.h index d6b8e7217c..2a00689174 100644 --- a/src/prefs/screen/ScreenWindow.h +++ b/src/prefs/screen/ScreenWindow.h @@ -1,22 +1,20 @@ #ifndef __SCREENWINDOW_H #define __SCREENWINDOW_H -#include -#include -#include #include -#include - -#include "ScreenView.h" -#include "ScreenDrawView.h" -#include "RefreshWindow.h" -#include "ScreenSettings.h" +#include +class BBox; +class BPopUpMenu; +class BMenuField; +class RefreshWindow; +class ScreenDrawView; +class ScreenSettings; class ScreenWindow : public BWindow { public: - ScreenWindow(ScreenSettings *Settings); + ScreenWindow(ScreenSettings *settings); virtual ~ScreenWindow(); virtual bool QuitRequested(); virtual void MessageReceived(BMessage *message); @@ -27,10 +25,12 @@ public: private: void CheckApplyEnabled(); void CheckUpdateDisplayModes(); + void CheckModesByResolution(const char*); + BBox *fScreenView; ScreenSettings *fSettings; - ScreenView *fScreenView; ScreenDrawView *fScreenDrawView; + BPopUpMenu *fWorkspaceMenu; BMenuField *fWorkspaceField; BPopUpMenu *fWorkspaceCountMenu; @@ -46,12 +46,15 @@ private: BButton *fDefaultsButton; BButton *fApplyButton; BButton *fRevertButton; + BMenuItem *fInitialResolution; BMenuItem *fInitialColors; BMenuItem *fInitialRefresh; + display_mode fInitialMode; display_mode *fSupportedModes; uint32 fTotalModes; + float fCustomRefresh; float fInitialRefreshN; };