From 215b13a369ccb9327c5881736eddf68e0c2f7390 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 27 May 2004 07:19:38 +0000 Subject: [PATCH] A patch from Sergei Panteleev: - for very high resolutions, the preview image wasn't drawn. Fixed. - preview image wasn't drawn if you clicked the Return/Default buttons without applying the changes. Fixed. Took the chance to cleanup some code a bit. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7661 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/prefs/screen/Screen.cpp | 11 +- src/prefs/screen/ScreenDrawView.cpp | 283 +++++++++++++--------------- src/prefs/screen/ScreenDrawView.h | 4 - src/prefs/screen/ScreenWindow.cpp | 26 ++- 4 files changed, 155 insertions(+), 169 deletions(-) diff --git a/src/prefs/screen/Screen.cpp b/src/prefs/screen/Screen.cpp index 77fa1b31d6..5d880a1a74 100644 --- a/src/prefs/screen/Screen.cpp +++ b/src/prefs/screen/Screen.cpp @@ -1,7 +1,5 @@ -// Screen V0.80 by Rafael Romo for the OpenBeOS Preferences team. -// web.tiscalinet.it/rockman -// rockman@tiscalinet.it -// Additional code by Stefano Ceccherini ( burton666@freemail.it ) +// Original author: Rafael Romo +// Additional code by Stefano Ceccherini, Andrew Bachmann, Sergei Panteleev #include #include @@ -9,10 +7,11 @@ #include #include +#include "Constants.h" #include "ScreenApplication.h" #include "ScreenWindow.h" #include "ScreenSettings.h" -#include "Constants.h" + ScreenApplication::ScreenApplication() : BApplication(kAppSignature), @@ -25,7 +24,7 @@ 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 the OpenBeOS team", "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT); aboutAlert->SetShortcut(0, B_OK); aboutAlert->Go(); diff --git a/src/prefs/screen/ScreenDrawView.cpp b/src/prefs/screen/ScreenDrawView.cpp index ad955f2c45..ba5ab7e40b 100644 --- a/src/prefs/screen/ScreenDrawView.cpp +++ b/src/prefs/screen/ScreenDrawView.cpp @@ -17,7 +17,9 @@ ScreenDrawView::ScreenDrawView(BRect rect, char *name) { BScreen screen(B_MAIN_SCREEN_ID); if (!screen.IsValid()) - ; //Debugger() ? + ; // TODO: Debugger()? Actually, the check shouldn't + // be needed, as the only situation where the screen wouldn't + // be valid is when a BApplication has not been created desktopColor = screen.DesktopColor(current_workspace()); @@ -26,19 +28,11 @@ ScreenDrawView::ScreenDrawView(BRect rect, char *name) fWidth = mode.virtual_width; fHeight = mode.virtual_height; -#ifdef USE_BITMAPS - fScreen1 = BTranslationUtils::GetBitmap("screen_1"); - fScreen2 = BTranslationUtils::GetBitmap("screen_2"); -#endif } ScreenDrawView::~ScreenDrawView() { -#ifdef USE_BITMAPS - delete fScreen1; - delete fScreen2; -#endif } @@ -52,14 +46,138 @@ ScreenDrawView::MouseDown(BPoint point) void ScreenDrawView::Draw(BRect updateRect) { -#ifndef USE_BITMAPS rgb_color red = { 228, 0, 0, 255 }; rgb_color black = { 0, 0, 0, 255 }; rgb_color darkColor = {160, 160, 160, 255}; - //FIXME: Make the draw code resolution independent - if (fWidth == 1600) - { + // TODO: Make the draw code resolution independent, if possible. + // Using a scaled BPicture doesn't look so nice + if (fWidth == 1600) { + SetHighColor(darkColor); + + FillRoundRect(Bounds(), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(Bounds(), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0)); + + } else if (fWidth == 1280) { + SetHighColor(darkColor); + + FillRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(15.0, 70.0), BPoint(16.0, 70.0)); + + } else if (fWidth == 1152) { + SetHighColor(darkColor); + + FillRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(19.0, 66.0), BPoint(20.0, 66.0)); + + } else if (fWidth == 1024) { + SetHighColor(darkColor); + + FillRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(22.0, 62.0), BPoint(23.0, 62.0)); + } else if (fWidth == 800) { + SetHighColor(darkColor); + + FillRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(29.0, 56.0), BPoint(30.0, 56.0)); + + } else if (fWidth == 640) { + SetHighColor(darkColor); + + FillRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); + + SetHighColor(desktopColor); + + FillRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); + + SetHighColor(black); + + StrokeRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); + + SetHighColor(red); + + StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0)); + + } else { SetHighColor(darkColor); FillRoundRect(Bounds(), 3.0, 3.0); @@ -80,145 +198,6 @@ ScreenDrawView::Draw(BRect updateRect) StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0)); } - else if(fWidth == 1280) - { - SetHighColor(darkColor); - - FillRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); - - SetHighColor(desktopColor); - - FillRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); - - SetHighColor(red); - - StrokeLine(BPoint(15.0, 70.0), BPoint(16.0, 70.0)); - } - else if(fWidth == 1152) - { - SetHighColor(darkColor); - - FillRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); - - SetHighColor(desktopColor); - - FillRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); - - SetHighColor(red); - - StrokeLine(BPoint(19.0, 66.0), BPoint(20.0, 66.0)); - } - else if(fWidth == 1024) - { - SetHighColor(darkColor); - - FillRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); - - SetHighColor(desktopColor); - - FillRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); - - SetHighColor(red); - - StrokeLine(BPoint(22.0, 62.0), BPoint(23.0, 62.0)); - } - else if(fWidth == 800) - { - SetHighColor(darkColor); - - FillRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); - - SetHighColor(desktopColor); - - FillRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); - - SetHighColor(red); - - StrokeLine(BPoint(29.0, 56.0), BPoint(30.0, 56.0)); - } - else if(fWidth == 640) - { - SetHighColor(darkColor); - - FillRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); - - SetHighColor(desktopColor); - - FillRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); - - SetHighColor(black); - - StrokeRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); - - SetHighColor(red); - - StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0)); - } -#else - BRect bounds(Bounds()); - - SetHighColor(desktopColor); - - 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; - 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; - - DrawBitmapAsync(fScreen2, dest2); - Flush(); -#endif - } diff --git a/src/prefs/screen/ScreenDrawView.h b/src/prefs/screen/ScreenDrawView.h index f80d07f88d..469bda1d11 100644 --- a/src/prefs/screen/ScreenDrawView.h +++ b/src/prefs/screen/ScreenDrawView.h @@ -16,10 +16,6 @@ private: rgb_color desktopColor; int32 fWidth; int32 fHeight; -#ifdef USE_BITMAPS - BBitmap *fScreen1, - *fScreen2; -#endif }; #endif diff --git a/src/prefs/screen/ScreenWindow.cpp b/src/prefs/screen/ScreenWindow.cpp index 4e492b45ea..930ad8bd9f 100644 --- a/src/prefs/screen/ScreenWindow.cpp +++ b/src/prefs/screen/ScreenWindow.cpp @@ -7,20 +7,20 @@ #include #include #include -#include #include +#include #include -#include -#include #include +#include +#include -#include "RefreshWindow.h" -#include "ScreenWindow.h" -#include "ScreenDrawView.h" -#include "ScreenSettings.h" #include "AlertWindow.h" #include "Constants.h" +#include "RefreshWindow.h" +#include "ScreenDrawView.h" +#include "ScreenSettings.h" +#include "ScreenWindow.h" #include "Utility.h" static uint32 @@ -36,12 +36,14 @@ colorspace_to_bpp(uint32 colorspace) } } + static void colorspace_to_string(uint32 colorspace, char dest[]) { sprintf(dest,"%lu Bits/Pixel",colorspace_to_bpp(colorspace)); } + static uint32 string_to_colorspace(const char* string) { @@ -424,6 +426,11 @@ ScreenWindow::MessageReceived(BMessage* message) } else { fRefreshMenu->ItemAt(0)->SetMarked(true); } + + BMessage newMessage(UPDATE_DESKTOP_MSG); + const char *resolution = fResolutionMenu->FindMarked()->Label(); + newMessage.AddString("resolution", resolution); + PostMessage(&newMessage, fScreenDrawView); CheckApplyEnabled(); break; } @@ -456,6 +463,11 @@ ScreenWindow::MessageReceived(BMessage* message) fRefreshMenu->Superitem()->SetLabel(string.String()); } + BMessage newMessage(UPDATE_DESKTOP_MSG); + const char *resolution = fInitialResolution->Label(); + newMessage.AddString("resolution", resolution); + PostMessage(&newMessage, fScreenDrawView); + if (message->what == SET_INITIAL_MODE_MSG) { BScreen screen(B_MAIN_SCREEN_ID);