diff --git a/src/prefs/screen/AlertView.cpp b/src/prefs/screen/AlertView.cpp index 0cac17f031..bf59b8e4ad 100644 --- a/src/prefs/screen/AlertView.cpp +++ b/src/prefs/screen/AlertView.cpp @@ -5,12 +5,11 @@ #include "AlertView.h" #include "Bitmaps.h" #include "Constants.h" -#include "Utility.h" AlertView::AlertView(BRect frame, char *name) : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) { - Count = 8; + count = 8; fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT); fBitmap->SetBits(BitmapBits, 32 * 32, 0, B_COLOR_8_BIT); @@ -20,34 +19,32 @@ AlertView::AlertView(BRect frame, char *name) void AlertView::AttachedToWindow() { - SetViewColor(greyColor); + rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR); + + SetViewColor(grey); } void AlertView::Draw(BRect updateRect) { - SetHighColor(darkColor); + rgb_color dark = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT); + rgb_color black = { 0, 0, 0, 255 }; + SetHighColor(dark); FillRect(BRect(0.0, 0.0, 30.0, 100.0)); SetDrawingMode(B_OP_ALPHA); - DrawBitmap(fBitmap, BPoint(18.0, 6.0)); SetDrawingMode(B_OP_OVER); - - SetHighColor(blackColor); - + SetHighColor(black); SetFont(be_bold_font); DrawString("Do you wish to keep these settings?", BPoint(60.0, 20.0)); - MovePenTo(60.0, 37.0); - fString.Truncate(0); + fString << "Settings will revert in " << count << " seconds."; - fString << "Settings will revert in " << Count << " seconds."; - - DrawString(fString.String()); + DrawString(fString.String(), BPoint(60, 37)); } diff --git a/src/prefs/screen/AlertView.h b/src/prefs/screen/AlertView.h index 41c368b832..f3077d660c 100644 --- a/src/prefs/screen/AlertView.h +++ b/src/prefs/screen/AlertView.h @@ -1,21 +1,20 @@ -#ifndef ALERTVIEW_H -#define ALERTVIEW_H +#ifndef __ALERTVIEW_H +#define __ALERTVIEW_H #include #include class AlertView : public BView { - public: AlertView(BRect frame, char *name); virtual void AttachedToWindow(); virtual void Draw(BRect updateRect); - int32 Count; + int32 count; -private: - BBitmap *fBitmap; - BString fString; +private: + BBitmap *fBitmap; + BString fString; }; #endif diff --git a/src/prefs/screen/AlertWindow.cpp b/src/prefs/screen/AlertWindow.cpp index 898bf2f1b1..4839ef3667 100644 --- a/src/prefs/screen/AlertWindow.cpp +++ b/src/prefs/screen/AlertWindow.cpp @@ -45,8 +45,6 @@ AlertWindow::AlertWindow(BRect frame) BMessenger Messenger(this); fRunner = new BMessageRunner(Messenger, new BMessage(DIM_COUNT_MSG), 1000000, 10); - - Show(); } @@ -86,11 +84,11 @@ AlertWindow::MessageReceived(BMessage *message) case DIM_COUNT_MSG: { - fAlertView->Count = fAlertView->Count - 1; + fAlertView->count -= 1; fAlertView->Invalidate(BRect(180.0, 20.0, 260.0, 50.0)); - if (fAlertView->Count == 0) + if (fAlertView->count == 0) PostMessage(BUTTON_REVERT_MSG); break; diff --git a/src/prefs/screen/AlertWindow.h b/src/prefs/screen/AlertWindow.h index f769ce85fc..aae6caee47 100644 --- a/src/prefs/screen/AlertWindow.h +++ b/src/prefs/screen/AlertWindow.h @@ -1,21 +1,20 @@ -#ifndef ALERTWINDOW_H -#define ALERTWINDOW_H +#ifndef __ALERTWINDOW_H +#define __ALERTWINDOW_H #include "AlertView.h" class AlertWindow : public BWindow { - public: - AlertWindow(BRect frame); - virtual bool QuitRequested(); - virtual void MessageReceived(BMessage *message); + AlertWindow(BRect frame); + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); private: - AlertView *fAlertView; - BMessageRunner *fRunner; - BButton *fRevertButton; - BButton *fKeepButton; + AlertView *fAlertView; + BMessageRunner *fRunner; + BButton *fRevertButton; + BButton *fKeepButton; }; #endif diff --git a/src/prefs/screen/Constants.h b/src/prefs/screen/Constants.h index 1214b14056..a45402711c 100644 --- a/src/prefs/screen/Constants.h +++ b/src/prefs/screen/Constants.h @@ -2,26 +2,26 @@ #define CONSTANTS_H //Messages -static const int32 WORKSPACE_CHECK_MSG = 'wchk'; -static const int32 BUTTON_DEFAULTS_MSG = 'bdef'; -static const int32 BUTTON_REVERT_MSG = 'brev'; -static const int32 BUTTON_APPLY_MSG = 'bapl'; -static const int32 BUTTON_DONE_MSG = 'bdon'; -static const int32 BUTTON_CANCEL_MSG = 'bcnc'; -static const int32 BUTTON_KEEP_MSG = 'bkep'; -static const int32 POP_WORKSPACE_CHANGED_MSG = 'pwsc'; -static const int32 POP_RESOLUTION_MSG = 'pres'; -static const int32 POP_COLORS_MSG = 'pclr'; -static const int32 POP_REFRESH_MSG = 'prfr'; -static const int32 POP_OTHER_REFRESH_MSG = 'porf'; -static const int32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; -static const int32 UPDATE_DESKTOP_MSG = 'udsk'; -static const int32 SLIDER_MODIFICATION_MSG = 'sldm'; -static const int32 SLIDER_INVOKE_MSG = 'sldi'; -static const int32 SET_INITIAL_MODE_MSG = 'sinm'; -static const int32 SET_CUSTOM_REFRESH_MSG = 'scrf'; -static const int32 DIM_COUNT_MSG = 'scrf'; -static const int32 MAKE_INITIAL_MSG = 'mkin'; +static const uint32 WORKSPACE_CHECK_MSG = 'wchk'; +static const uint32 BUTTON_DEFAULTS_MSG = 'bdef'; +static const uint32 BUTTON_REVERT_MSG = 'brev'; +static const uint32 BUTTON_APPLY_MSG = 'bapl'; +static const uint32 BUTTON_DONE_MSG = 'bdon'; +static const uint32 BUTTON_CANCEL_MSG = 'bcnc'; +static const uint32 BUTTON_KEEP_MSG = 'bkep'; +static const uint32 POP_WORKSPACE_CHANGED_MSG = 'pwsc'; +static const uint32 POP_RESOLUTION_MSG = 'pres'; +static const uint32 POP_COLORS_MSG = 'pclr'; +static const uint32 POP_REFRESH_MSG = 'prfr'; +static const uint32 POP_OTHER_REFRESH_MSG = 'porf'; +static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; +static const uint32 UPDATE_DESKTOP_MSG = 'udsk'; +static const uint32 SLIDER_MODIFICATION_MSG = 'sldm'; +static const uint32 SLIDER_INVOKE_MSG = 'sldi'; +static const uint32 SET_INITIAL_MODE_MSG = 'sinm'; +static const uint32 SET_CUSTOM_REFRESH_MSG = 'scrf'; +static const uint32 DIM_COUNT_MSG = 'scrf'; +static const uint32 MAKE_INITIAL_MSG = 'mkin'; //Constants static const char kAppSignature[] = "application/x-vnd.Be-SCRN"; diff --git a/src/prefs/screen/RefreshSlider.cpp b/src/prefs/screen/RefreshSlider.cpp index e1f7f3eccc..29f9ee1786 100644 --- a/src/prefs/screen/RefreshSlider.cpp +++ b/src/prefs/screen/RefreshSlider.cpp @@ -26,9 +26,8 @@ RefreshSlider::~RefreshSlider() void RefreshSlider::DrawFocusMark() { - if (IsFocus()) - { - rgb_color blueColor = { 0, 0, 229, 255 }; + if (IsFocus()) { + rgb_color blue = { 0, 0, 229, 255 }; BRect rect(ThumbFrame()); BView *view = OffscreenView(); @@ -37,7 +36,7 @@ RefreshSlider::DrawFocusMark() rect.right--; rect.bottom--; - view->SetHighColor(blueColor); + view->SetHighColor(blue); view->StrokeRect(rect); } } @@ -46,7 +45,7 @@ RefreshSlider::DrawFocusMark() void RefreshSlider::KeyDown(const char *bytes, int32 numBytes) { - switch ( *bytes ) + switch (*bytes) { case B_LEFT_ARROW: { @@ -75,14 +74,11 @@ RefreshSlider::KeyDown(const char *bytes, int32 numBytes) char* RefreshSlider::UpdateText() const { - if (fStatus && Window()->Lock()) - { + if (fStatus) { sprintf(fStatus, "%.1f Hz", (float)Value() / 10); return fStatus; } - else - { + else return NULL; - } } diff --git a/src/prefs/screen/RefreshSlider.h b/src/prefs/screen/RefreshSlider.h index e50c36e6e9..6139dd10bc 100644 --- a/src/prefs/screen/RefreshSlider.h +++ b/src/prefs/screen/RefreshSlider.h @@ -1,17 +1,16 @@ -#ifndef REFRESHSLIDER_H -#define REFRESHSLIDER_H +#ifndef __REFRESHSLIDER_H +#define __REFRESHSLIDER_H #include class RefreshSlider : public BSlider { - public: RefreshSlider(BRect frame); ~RefreshSlider(); - virtual void DrawFocusMark(); - virtual char* UpdateText() const; - virtual void KeyDown(const char *bytes, int32 numBytes); + virtual void DrawFocusMark(); + virtual char *UpdateText() const; + virtual void KeyDown(const char *bytes, int32 numBytes); private: char* fStatus; diff --git a/src/prefs/screen/RefreshView.cpp b/src/prefs/screen/RefreshView.cpp index 26b8f00d51..09afd88313 100644 --- a/src/prefs/screen/RefreshView.cpp +++ b/src/prefs/screen/RefreshView.cpp @@ -1,7 +1,6 @@ #include #include "RefreshView.h" -#include "Utility.h" RefreshView::RefreshView(BRect rect, char *name) : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) @@ -12,27 +11,30 @@ RefreshView::RefreshView(BRect rect, char *name) void RefreshView::AttachedToWindow() { - SetViewColor(greyColor); + rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR); + SetViewColor(grey); } void RefreshView::Draw(BRect updateRect) { - rgb_color darkColor = { 128, 128, 128, 255 }; + 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(whiteColor); + 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(darkColor); + 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(blackColor); + SetHighColor(black); SetLowColor(ViewColor()); DrawString("Type or use the left and right arrow keys.", BPoint(10.0, 23.0)); diff --git a/src/prefs/screen/RefreshView.h b/src/prefs/screen/RefreshView.h index e6e79a9880..436ea5f4bf 100644 --- a/src/prefs/screen/RefreshView.h +++ b/src/prefs/screen/RefreshView.h @@ -1,15 +1,14 @@ -#ifndef REFRESHVIEW_H -#define REFRESHVIEW_H +#ifndef __REFRESHVIEW_H +#define __REFRESHVIEW_H #include class RefreshView : public BView { - public: - RefreshView(BRect frame, char *name); - virtual void AttachedToWindow(); - virtual void Draw(BRect updateRect); + RefreshView(BRect frame, char *name); + virtual void AttachedToWindow(); + virtual void Draw(BRect updateRect); }; #endif diff --git a/src/prefs/screen/RefreshWindow.cpp b/src/prefs/screen/RefreshWindow.cpp index ae5796ba91..e24910ba42 100644 --- a/src/prefs/screen/RefreshWindow.cpp +++ b/src/prefs/screen/RefreshWindow.cpp @@ -13,9 +13,9 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value) : BWindow(frame, "Refresh Rate", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES) { - frame = Bounds(); + BRect bounds(Bounds()); - fRefreshView = new RefreshView(frame, "RefreshView"); + fRefreshView = new RefreshView(bounds, "RefreshView"); AddChild(fRefreshView); @@ -55,9 +55,7 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value) fCancelButton->ResizeToPreferred(); fRefreshView->AddChild(fCancelButton); - - Show(); - + PostMessage(SLIDER_INVOKE_MSG); } @@ -76,14 +74,13 @@ RefreshWindow::MessageReceived(BMessage* message) { case BUTTON_DONE_MSG: { - BMessenger Messenger(kAppSignature); - BMessage Message(SET_CUSTOM_REFRESH_MSG); + BMessenger messenger(kAppSignature); + BMessage message(SET_CUSTOM_REFRESH_MSG); - float Value = (float)fRefreshSlider->Value() / 10; + float value = (float)fRefreshSlider->Value() / 10; - Message.AddFloat("refresh", Value); - - Messenger.SendMessage(&Message); + message.AddFloat("refresh", value); + messenger.SendMessage(&message); PostMessage(B_QUIT_REQUESTED); diff --git a/src/prefs/screen/Screen.cpp b/src/prefs/screen/Screen.cpp index 0888a6c101..f63f03aace 100644 --- a/src/prefs/screen/Screen.cpp +++ b/src/prefs/screen/Screen.cpp @@ -1,7 +1,7 @@ -// Screen V1.00 by Rafael Romo for the OpenBeOS Preferences team. +// Screen V0.80 by Rafael Romo for the OpenBeOS Preferences team. // web.tiscalinet.it/rockman // rockman@tiscalinet.it -// Modified by Stefano Ceccherini ( burton666@freemail.it ) +// Additional code by Stefano Ceccherini ( burton666@freemail.it ) #include #include @@ -15,10 +15,10 @@ #include "Constants.h" ScreenApplication::ScreenApplication() - : - BApplication(kAppSignature), + : BApplication(kAppSignature), fScreenWindow(new ScreenWindow(new ScreenSettings())) { + fScreenWindow->Show(); } @@ -54,9 +54,9 @@ ScreenApplication::MessageReceived(BMessage* message) int main() { - ScreenApplication Application; + ScreenApplication app; - Application.Run(); + app.Run(); - return(0); + return 0; } diff --git a/src/prefs/screen/Screen.rsrc b/src/prefs/screen/Screen.rsrc index 92d88ec011..c724a5eb3a 100644 Binary files a/src/prefs/screen/Screen.rsrc and b/src/prefs/screen/Screen.rsrc differ diff --git a/src/prefs/screen/ScreenApplication.h b/src/prefs/screen/ScreenApplication.h index c5da2326be..f9fde753e2 100644 --- a/src/prefs/screen/ScreenApplication.h +++ b/src/prefs/screen/ScreenApplication.h @@ -1,19 +1,16 @@ -#ifndef SCREENAPPLICATION_H -#define SCREENAPPLICATION_H +#ifndef __SCREENAPPLICATION_H +#define __SCREENAPPLICATION_H #include "ScreenWindow.h" class ScreenApplication : public BApplication { - public: ScreenApplication(); virtual void MessageReceived(BMessage *message); virtual void AboutRequested(); - private: - ScreenWindow *fScreenWindow; - bool NeedWindow; + ScreenWindow *fScreenWindow; }; #endif diff --git a/src/prefs/screen/ScreenDrawView.cpp b/src/prefs/screen/ScreenDrawView.cpp index ae0fcfe608..60b3dfb883 100644 --- a/src/prefs/screen/ScreenDrawView.cpp +++ b/src/prefs/screen/ScreenDrawView.cpp @@ -7,9 +7,8 @@ #include -#include "ScreenDrawView.h" #include "Constants.h" -#include "Utility.h" +#include "ScreenDrawView.h" ScreenDrawView::ScreenDrawView(BRect rect, char *name) : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) @@ -45,16 +44,18 @@ ScreenDrawView::MouseDown(BPoint point) void ScreenDrawView::Draw(BRect updateRect) { + 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 (fResolution == 1600) - { - rgb_color darkColor = {160, 160, 160, 255}; - + if (fResolution == 1600) + { SetHighColor(darkColor); FillRoundRect(Bounds(), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(Bounds(), 3.0, 3.0); @@ -62,23 +63,21 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0)); } else if(fResolution == 1280) { - rgb_color darkColor = {160, 160, 160, 255}; - SetHighColor(darkColor); FillRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); @@ -86,23 +85,21 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(15.0, 70.0), BPoint(16.0, 70.0)); } else if(fResolution == 1152) { - rgb_color darkColor = {160, 160, 160, 255}; - SetHighColor(darkColor); FillRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); @@ -110,23 +107,21 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(19.0, 66.0), BPoint(20.0, 66.0)); } else if(fResolution == 1024) { - rgb_color darkColor = {160, 160, 160, 255}; - SetHighColor(darkColor); FillRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); @@ -134,24 +129,21 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(22.0, 62.0), BPoint(23.0, 62.0)); } else if(fResolution == 800) { - rgb_color darkColor = {160, 160, 160, 255}; - rgb_color redColor = {228, 0, 0, 255}; - SetHighColor(darkColor); FillRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); @@ -159,23 +151,21 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(29.0, 56.0), BPoint(30.0, 56.0)); } else if(fResolution == 640) { - rgb_color darkColor = {160, 160, 160, 255}; - SetHighColor(darkColor); FillRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); @@ -183,11 +173,11 @@ ScreenDrawView::Draw(BRect updateRect) FillRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); - SetHighColor(blackColor); + SetHighColor(black); StrokeRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0); - SetHighColor(redColor); + SetHighColor(red); StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0)); } @@ -201,14 +191,13 @@ ScreenDrawView::MessageReceived(BMessage* message) { case UPDATE_DESKTOP_MSG: { - BString Resolution; - message->FindString("resolution", &Resolution); + BString resolution; + message->FindString("resolution", &resolution); - int32 NextfResolution = atoi(Resolution.String()); + int32 nextfResolution = atoi(resolution.String()); - if (fResolution != NextfResolution) - { - fResolution = NextfResolution; + if (fResolution != nextfResolution) { + fResolution = nextfResolution; Invalidate(); } @@ -226,8 +215,7 @@ ScreenDrawView::MessageReceived(BMessage* message) } default: - BView::MessageReceived(message); - + BView::MessageReceived(message); break; } } diff --git a/src/prefs/screen/ScreenDrawView.h b/src/prefs/screen/ScreenDrawView.h index dc5cc7781f..61065c9779 100644 --- a/src/prefs/screen/ScreenDrawView.h +++ b/src/prefs/screen/ScreenDrawView.h @@ -1,21 +1,20 @@ -#ifndef SCREENDRAWVIEW_H -#define SCREENDRAWVIEW_H +#ifndef __SCREENDRAWVIEW_H +#define __SCREENDRAWVIEW_H #include class ScreenDrawView : public BView { - public: - ScreenDrawView(BRect frame, char *name); - virtual void AttachedToWindow(); - virtual void Draw(BRect updateRect); - virtual void MessageReceived(BMessage *message); - virtual void MouseDown(BPoint point); + ScreenDrawView(BRect frame, char *name); + virtual void AttachedToWindow(); + virtual void Draw(BRect updateRect); + virtual void MessageReceived(BMessage *message); + virtual void MouseDown(BPoint point); private: - rgb_color desktopColor; - int32 fResolution; + rgb_color desktopColor; + int32 fResolution; }; #endif diff --git a/src/prefs/screen/ScreenSettings.h b/src/prefs/screen/ScreenSettings.h index 95d1f6410f..9416f65dc7 100644 --- a/src/prefs/screen/ScreenSettings.h +++ b/src/prefs/screen/ScreenSettings.h @@ -1,21 +1,20 @@ -#ifndef SCREENSETTINGS_H -#define SCREENSETTINGS_H +#ifndef __SCREENSETTINGS_H +#define __SCREENSETTINGS_H #include class ScreenSettings { - public: - ScreenSettings(); - virtual ~ScreenSettings(); + ScreenSettings(); + virtual ~ScreenSettings(); - BRect WindowFrame() const { return fWindowFrame; }; - void SetWindowFrame(BRect); + BRect WindowFrame() const { return fWindowFrame; }; + void SetWindowFrame(BRect); private: - static const char fScreenSettingsFile[]; - BRect fWindowFrame; + static const char fScreenSettingsFile[]; + BRect fWindowFrame; }; #endif diff --git a/src/prefs/screen/ScreenView.cpp b/src/prefs/screen/ScreenView.cpp index 80cd09d230..fe479bd6bf 100644 --- a/src/prefs/screen/ScreenView.cpp +++ b/src/prefs/screen/ScreenView.cpp @@ -12,24 +12,29 @@ ScreenView::ScreenView(BRect rect, char *name) void ScreenView::AttachedToWindow() { - SetViewColor(greyColor); + rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR); + SetViewColor(grey); } void ScreenView::Draw(BRect updateRect) { - rgb_color darkColor = {128, 128, 128, 255}; + 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 }; - SetHighColor(whiteColor); + BRect bounds(Bounds()); - StrokeLine(BPoint(Bounds().left, Bounds().top), BPoint(Bounds().right, Bounds().top)); - StrokeLine(BPoint(Bounds().left, Bounds().top), BPoint(Bounds().left, Bounds().bottom)); + SetHighColor(white); - SetHighColor(darkColor); + StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top)); + StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.left, bounds.bottom)); - StrokeLine(BPoint(Bounds().left, Bounds().bottom), BPoint(Bounds().right, Bounds().bottom)); - StrokeLine(BPoint(Bounds().right, Bounds().bottom), BPoint(Bounds().right, Bounds().top)); + SetHighColor(dark3); - SetHighColor(blackColor); + 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 index c9817ed8a7..011a038813 100644 --- a/src/prefs/screen/ScreenView.h +++ b/src/prefs/screen/ScreenView.h @@ -1,15 +1,14 @@ -#ifndef SCREENVIEW_H -#define SCREENVIEW_H +#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); + 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 d799009fda..2cfea1ef4c 100644 --- a/src/prefs/screen/ScreenWindow.cpp +++ b/src/prefs/screen/ScreenWindow.cpp @@ -27,53 +27,46 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) BRect frame(Bounds()); BScreen screen(B_MAIN_SCREEN_ID); - if (!screen.IsValid()) { - //What could we do? - //debugger() ? - } + if (!screen.IsValid()) + ;//debugger() ? + screen.GetModeList(&fSupportedModes, &fTotalModes); fScreenView = new ScreenView(frame, "ScreenView"); - AddChild(fScreenView); fSettings = Settings; - BRect ScreenBoxRect; - BRect ScreenDrawViewRect; + 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; - - ScreenBoxRect.Set(11.0, 18.0, 153.0, 155.0); - + fScreenBox = new BBox(ScreenBoxRect); fScreenBox->SetBorder(B_FANCY_BORDER); - - ScreenDrawViewRect.Set(20.0, 16.0, 122.0, 93.0); - + fScreenDrawView = new ScreenDrawView(ScreenDrawViewRect, "ScreenDrawView"); - BString String; + BString string; - String << count_workspaces(); + string << count_workspaces(); - fWorkspaceCountMenu = new BPopUpMenu(String.String(), true, true); + fWorkspaceCountMenu = new BPopUpMenu(string.String(), true, true); - for (int32 Count = 1; Count <= 32; Count++) - { - String.Truncate(0); - String << Count; - fWorkspaceCountMenu->AddItem(new BMenuItem(String.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG))); + for (int32 count = 1; count <= 32; count++) { + string.Truncate(0); + string << count; + fWorkspaceCountMenu->AddItem(new BMenuItem(string.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG))); } - String.Truncate(0); - String << count_workspaces(); + string.Truncate(0); + string << count_workspaces(); - BMenuItem *Marked = fWorkspaceCountMenu->FindItem(String.String()); - Marked->SetMarked(true); + BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String()); + marked->SetMarked(true); WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0); @@ -81,10 +74,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fWorkspaceCountField->SetDivider(91.0); - fScreenBox->AddChild(fScreenDrawView); - - fScreenBox->AddChild(fWorkspaceCountField); - + fScreenBox->AddChild(fScreenDrawView); + fScreenBox->AddChild(fWorkspaceCountField); fScreenView->AddChild(fScreenBox); fWorkspaceMenu = new BPopUpMenu("Current Workspace", true, true); @@ -107,7 +98,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) ButtonRect.Set(88.0, 114.0, 200.0, 150.0); fApplyButton = new BButton(ButtonRect, "ApplyButton", "Apply", - new BMessage(BUTTON_APPLY_MSG)); + new BMessage(BUTTON_APPLY_MSG)); fApplyButton->AttachedToWindow(); fApplyButton->ResizeToPreferred(); @@ -115,7 +106,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fControlsBox->AddChild(fApplyButton); - fResolutionMenu = new BPopUpMenu("640 x 480", true, true); + fResolutionMenu = new BPopUpMenu("", true, true); for (uint32 c = 0; c < fTotalModes; c++) { BString mode; mode << (int32)fSupportedModes[c].virtual_width << " x " << (int32)fSupportedModes[c].virtual_height; @@ -123,19 +114,18 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fResolutionMenu->AddItem(new BMenuItem(mode.String(), new BMessage(POP_RESOLUTION_MSG))); } - ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0); fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true); - Marked = fResolutionMenu->ItemAt(0); - Marked->SetMarked(true); + marked = fResolutionMenu->ItemAt(0); + marked->SetMarked(true); fResolutionField->SetDivider(55.0); fControlsBox->AddChild(fResolutionField); - fColorsMenu = new BPopUpMenu("8 Bits/Pixel", true, true); + fColorsMenu = new BPopUpMenu("", true, true); // Get the supported colorspaces for (uint32 c = 0; c < fTotalModes; c++) { @@ -154,24 +144,24 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) colorSpace = "32 Bits/Pixel"; break; } + if (!fColorsMenu->FindItem(colorSpace.String())) fColorsMenu->AddItem(new BMenuItem(colorSpace.String(), - new BMessage(POP_COLORS_MSG))); - + new BMessage(POP_COLORS_MSG))); } ControlMenuRect.Set(50.0, 58.0, 171.0, 76.0); fColorsField = new BMenuField(ControlMenuRect, "ColorsMenu", "Colors:", fColorsMenu, true); - Marked = fColorsMenu->ItemAt(0); - Marked->SetMarked(true); + marked = fColorsMenu->ItemAt(0); + marked->SetMarked(true); fColorsField->SetDivider(38.0); fControlsBox->AddChild(fColorsField); - fRefreshMenu = new BPopUpMenu("60 Hz", true, true); + fRefreshMenu = new BPopUpMenu("", true, true); fRefreshMenu->AddItem(new BMenuItem("56 Hz", new BMessage(POP_REFRESH_MSG))); fRefreshMenu->AddItem(new BMenuItem("60 Hz", new BMessage(POP_REFRESH_MSG))); fRefreshMenu->AddItem(new BMenuItem("70 Hz", new BMessage(POP_REFRESH_MSG))); @@ -183,8 +173,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fRefreshField = new BMenuField(ControlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true); - Marked = fRefreshMenu->FindItem("60 Hz"); - Marked->SetMarked(true); + marked = fRefreshMenu->FindItem("60 Hz"); + marked->SetMarked(true); fRefreshField->SetDivider(69.0); @@ -219,35 +209,38 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fInitialMode = mode; - String.Truncate(0); + string.Truncate(0); - String << (uint32)mode.virtual_width << " x " << (uint32)mode.virtual_height; + string << (uint32)mode.virtual_width << " x " << (uint32)mode.virtual_height; - Marked = fResolutionMenu->FindItem(String.String()); - Marked->SetMarked(true); + marked = fResolutionMenu->FindItem(string.String()); + marked->SetMarked(true); - fInitialResolution = Marked; + fInitialResolution = marked; - if (mode.space == B_CMAP8){ - Marked = fColorsMenu->FindItem("8 Bits/Pixel"); - Marked->SetMarked(true); - - } else if (mode.space == B_RGB15) { - Marked = fColorsMenu->FindItem("15 Bits/Pixel"); - Marked->SetMarked(true); + switch (mode.space) { + case B_RGB32: + marked = fColorsMenu->FindItem("32 Bits/Pixel"); + break; - } else if (mode.space == B_RGB16) { - Marked = fColorsMenu->FindItem("16 Bits/Pixel"); - Marked->SetMarked(true); + case B_RGB16: + marked = fColorsMenu->FindItem("16 Bits/Pixel"); + break; + + case B_RGB15: + marked = fColorsMenu->FindItem("15 Bits/Pixel"); + break; - } else if (mode.space == B_RGB32) { - Marked = fColorsMenu->FindItem("32 Bits/Pixel"); - Marked->SetMarked(true); + case B_CMAP8: + default: + marked = fColorsMenu->FindItem("8 Bits/Pixel"); + break; } - fInitialColors = Marked; + marked->SetMarked(true); + fInitialColors = marked; - String.Truncate(0); + string.Truncate(0); float total_size = mode.timing.h_total * mode.timing.v_total; @@ -255,39 +248,37 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings) fCustomRefresh = fInitialRefreshN; - String << fInitialRefreshN << " Hz"; + string << fInitialRefreshN << " Hz"; - Marked = fRefreshMenu->FindItem(String.String()); + marked = fRefreshMenu->FindItem(string.String()); - if (Marked != NULL) { + if (marked != NULL) { - Marked->SetMarked(true); - fInitialRefresh = Marked; + marked->SetMarked(true); + fInitialRefresh = marked; } else { - BMenuItem *Other = fRefreshMenu->FindItem("Other..."); - String.Truncate(0); + BMenuItem *other = fRefreshMenu->FindItem("Other..."); + string.Truncate(0); - String << fInitialRefreshN; + string << fInitialRefreshN; - int32 point = String.FindFirst('.'); - String.Truncate(point + 2); + int32 point = string.FindFirst('.'); + string.Truncate(point + 2); - String << " Hz/Other..."; + string << " Hz/Other..."; - Other->SetLabel(String.String()); - Other->SetMarked(true); + other->SetLabel(string.String()); + other->SetMarked(true); - point = String.FindFirst('/'); - String.Truncate(point); + point = string.FindFirst('/'); + string.Truncate(point); - fRefreshMenu->Superitem()->SetLabel(String.String()); + fRefreshMenu->Superitem()->SetLabel(string.String()); - fInitialRefresh = Other; + fInitialRefresh = other; } - - Show(); } ScreenWindow::~ScreenWindow() @@ -384,13 +375,13 @@ ScreenWindow::MessageReceived(BMessage* message) { CheckApplyEnabled(); - BMessage *Message = new BMessage(UPDATE_DESKTOP_MSG); + BMessage *newMessage = new BMessage(UPDATE_DESKTOP_MSG); - const char *Resolution = fResolutionMenu->FindMarked()->Label(); + const char *resolution = fResolutionMenu->FindMarked()->Label(); - Message->AddString("resolution", Resolution); + newMessage->AddString("resolution", resolution); - PostMessage(Message, fScreenDrawView); + PostMessage(newMessage, fScreenDrawView); break; } @@ -404,30 +395,32 @@ ScreenWindow::MessageReceived(BMessage* message) case POP_REFRESH_MSG: { - CheckApplyEnabled(); - + CheckApplyEnabled(); break; } case POP_OTHER_REFRESH_MSG: { + BRect frame(Frame()); + CheckApplyEnabled(); int32 value = (int32)(fCustomRefresh * 10); - - fRefreshWindow = new RefreshWindow(BRect((Frame().left + 201.0), - (Frame().top + 34.0), (Frame().left + 509.0), - (Frame().top + 169.0)), value); - - BMenuItem *Other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); - BString String; + RefreshWindow *fRefreshWindow = new RefreshWindow(BRect((frame.left + 201.0), + (frame.top + 34.0), (frame.left + 509.0), + (frame.top + 169.0)), value); + fRefreshWindow->Show(); - String << Other->Label(); + BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); - int32 point = String.FindFirst('z'); - String.Truncate(point + 1); + BString string; - fRefreshMenu->Superitem()->SetLabel(String.String()); + string << other->Label(); + + int32 point = string.FindFirst('z'); + string.Truncate(point + 1); + + fRefreshMenu->Superitem()->SetLabel(string.String()); break; } @@ -452,10 +445,9 @@ ScreenWindow::MessageReceived(BMessage* message) CheckApplyEnabled(); - BMenuItem *Other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); + BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); - if (fInitialRefresh == Other) - { + if (fInitialRefresh == other) { BString string; string << fInitialRefreshN; @@ -472,13 +464,13 @@ ScreenWindow::MessageReceived(BMessage* message) fRefreshMenu->Superitem()->SetLabel(string.String()); } - if (message->what == SET_INITIAL_MODE_MSG) - { + if (message->what == SET_INITIAL_MODE_MSG) { + BScreen screen(B_MAIN_SCREEN_ID); if (!screen.IsValid()) break; - screen.SetMode(&fInitialMode); + screen.SetMode(&fInitialMode, true); } break; } @@ -509,8 +501,8 @@ 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)) @@ -520,29 +512,22 @@ ScreenWindow::MessageReceived(BMessage* message) mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) * refresh / 1000); - if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel")) - { + if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel")) mode->space = B_CMAP8; - } - else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("15 Bits/Pixel")) - { + else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("15 Bits/Pixel")) mode->space = B_RGB15; - } - else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("16 Bits/Pixel")) - { + 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->h_display_start = 0; mode->v_display_start = 0; - if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) - { - BAlert *WorkspacesAlert = new BAlert("WorkspacesAlert", "Change all workspaces?\nThis action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) { + BAlert *WorkspacesAlert = + new BAlert("WorkspacesAlert", "Change all workspaces?\nThis action cannot be reverted", + "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 button = WorkspacesAlert->Go(); @@ -552,8 +537,7 @@ ScreenWindow::MessageReceived(BMessage* message) int32 old = current_workspace(); int32 totalWorkspaces = count_workspaces(); - for (int32 count = 0; count < totalWorkspaces; count ++) - { + for (int32 count = 0; count < totalWorkspaces; count ++) { activate_workspace(count); screen.SetMode(mode, true); } @@ -563,14 +547,14 @@ ScreenWindow::MessageReceived(BMessage* message) else screen.SetMode(mode); - BRect Rect(100.0, 100.0, 400.0, 193.0); + BRect rect(100.0, 100.0, 400.0, 193.0); - Rect.left = (screen.Frame().right / 2) - 150; - Rect.top = (screen.Frame().bottom / 2) - 42; - Rect.right = Rect.left + 300.0; - Rect.bottom = Rect.top + 93.0; + rect.left = (screen.Frame().right / 2) - 150; + rect.top = (screen.Frame().bottom / 2) - 42; + rect.right = rect.left + 300.0; + rect.bottom = rect.top + 93.0; - new AlertWindow(Rect); + (new AlertWindow(rect))->Show(); fApplyButton->SetEnabled(false); @@ -581,26 +565,25 @@ ScreenWindow::MessageReceived(BMessage* message) { message->FindFloat("refresh", &fCustomRefresh); - BMenuItem *Other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); + BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); - Other->SetMarked(true); + other->SetMarked(true); - BString String; - String << fCustomRefresh; - int32 point = String.FindFirst('.'); - String.Truncate(point + 2); + BString string; + string << fCustomRefresh; + int32 point = string.FindFirst('.'); + string.Truncate(point + 2); - String << " Hz/Other..."; + string << " Hz/Other..."; - fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(String.String()); + fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String()); - point = String.FindFirst('/'); - String.Truncate(point); + point = string.FindFirst('/'); + string.Truncate(point); - fRefreshMenu->Superitem()->SetLabel(String.String()); + fRefreshMenu->Superitem()->SetLabel(string.String()); - if (fCustomRefresh != fInitialRefreshN) - { + if (fCustomRefresh != fInitialRefreshN) { fApplyButton->SetEnabled(true); fRevertButton->SetEnabled(true); } diff --git a/src/prefs/screen/ScreenWindow.h b/src/prefs/screen/ScreenWindow.h index 252088d0a2..4efa3399b1 100644 --- a/src/prefs/screen/ScreenWindow.h +++ b/src/prefs/screen/ScreenWindow.h @@ -1,5 +1,5 @@ -#ifndef SCREENWINDOW_H -#define SCREENWINDOW_H +#ifndef __SCREENWINDOW_H +#define __SCREENWINDOW_H #include #include @@ -26,10 +26,10 @@ public: private: void CheckApplyEnabled(); + ScreenSettings *fSettings; ScreenView *fScreenView; ScreenDrawView *fScreenDrawView; - RefreshWindow *fRefreshWindow; BPopUpMenu *fWorkspaceMenu; BMenuField *fWorkspaceField; BPopUpMenu *fWorkspaceCountMenu; diff --git a/src/prefs/screen/Utility.cpp b/src/prefs/screen/Utility.cpp index fc0254ee9e..0d20599a1e 100644 --- a/src/prefs/screen/Utility.cpp +++ b/src/prefs/screen/Utility.cpp @@ -1,11 +1,5 @@ #include "Utility.h" #include - -rgb_color blackColor = { 0, 0, 0, 255 }; -rgb_color greyColor = { 216, 216, 216, 255 }; -rgb_color darkColor = { 184, 184, 184, 255 }; -rgb_color whiteColor = { 255, 255, 255, 255 }; -rgb_color redColor = { 228, 0, 0, 255 }; float round(float n, int32 max) { diff --git a/src/prefs/screen/Utility.h b/src/prefs/screen/Utility.h index 41ce436da7..1986046475 100644 --- a/src/prefs/screen/Utility.h +++ b/src/prefs/screen/Utility.h @@ -1,16 +1,8 @@ #ifndef __UTILITY_H #define __UTILITY_H -#include #include extern float round(float n, int32 max); - -//Colors -extern rgb_color blackColor; -extern rgb_color greyColor; -extern rgb_color darkColor; -extern rgb_color whiteColor; -extern rgb_color redColor; -#endif //__UTILITY_H \ No newline at end of file +#endif //__UTILITY_H