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
This commit is contained in:
parent
0692dc0cdd
commit
215b13a369
@ -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 <Application.h>
|
||||
#include <Alert.h>
|
||||
@ -9,10 +7,11 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#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();
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,10 +16,6 @@ private:
|
||||
rgb_color desktopColor;
|
||||
int32 fWidth;
|
||||
int32 fHeight;
|
||||
#ifdef USE_BITMAPS
|
||||
BBitmap *fScreen1,
|
||||
*fScreen2;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,20 +7,20 @@
|
||||
#include <MenuField.h>
|
||||
#include <Messenger.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <String.h>
|
||||
#include <Screen.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#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);
|
||||
|
Loading…
Reference in New Issue
Block a user