Check-in for Stefano Ceccherini: cleanup the code a bit, removed the hardcode colors

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3438 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marc Flerackers 2003-06-06 08:48:56 +00:00
parent 908eaf852b
commit 1f46aaf9f1
22 changed files with 284 additions and 342 deletions

View File

@ -5,12 +5,11 @@
#include "AlertView.h" #include "AlertView.h"
#include "Bitmaps.h" #include "Bitmaps.h"
#include "Constants.h" #include "Constants.h"
#include "Utility.h"
AlertView::AlertView(BRect frame, char *name) 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; count = 8;
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT); 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);
@ -20,34 +19,32 @@ AlertView::AlertView(BRect frame, char *name)
void void
AlertView::AttachedToWindow() AlertView::AttachedToWindow()
{ {
SetViewColor(greyColor); rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(grey);
} }
void void
AlertView::Draw(BRect updateRect) 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)); FillRect(BRect(0.0, 0.0, 30.0, 100.0));
SetDrawingMode(B_OP_ALPHA); SetDrawingMode(B_OP_ALPHA);
DrawBitmap(fBitmap, BPoint(18.0, 6.0)); DrawBitmap(fBitmap, BPoint(18.0, 6.0));
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
SetHighColor(black);
SetHighColor(blackColor);
SetFont(be_bold_font); SetFont(be_bold_font);
DrawString("Do you wish to keep these settings?", BPoint(60.0, 20.0)); DrawString("Do you wish to keep these settings?", BPoint(60.0, 20.0));
MovePenTo(60.0, 37.0);
fString.Truncate(0); fString.Truncate(0);
fString << "Settings will revert in " << count << " seconds.";
fString << "Settings will revert in " << Count << " seconds."; DrawString(fString.String(), BPoint(60, 37));
DrawString(fString.String());
} }

View File

@ -1,21 +1,20 @@
#ifndef ALERTVIEW_H #ifndef __ALERTVIEW_H
#define ALERTVIEW_H #define __ALERTVIEW_H
#include <String.h> #include <String.h>
#include <View.h> #include <View.h>
class AlertView : public BView class AlertView : public BView
{ {
public: public:
AlertView(BRect frame, char *name); AlertView(BRect frame, char *name);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
int32 Count; int32 count;
private: private:
BBitmap *fBitmap; BBitmap *fBitmap;
BString fString; BString fString;
}; };
#endif #endif

View File

@ -45,8 +45,6 @@ AlertWindow::AlertWindow(BRect frame)
BMessenger Messenger(this); BMessenger Messenger(this);
fRunner = new BMessageRunner(Messenger, new BMessage(DIM_COUNT_MSG), 1000000, 10); fRunner = new BMessageRunner(Messenger, new BMessage(DIM_COUNT_MSG), 1000000, 10);
Show();
} }
@ -86,11 +84,11 @@ AlertWindow::MessageReceived(BMessage *message)
case DIM_COUNT_MSG: case DIM_COUNT_MSG:
{ {
fAlertView->Count = fAlertView->Count - 1; fAlertView->count -= 1;
fAlertView->Invalidate(BRect(180.0, 20.0, 260.0, 50.0)); fAlertView->Invalidate(BRect(180.0, 20.0, 260.0, 50.0));
if (fAlertView->Count == 0) if (fAlertView->count == 0)
PostMessage(BUTTON_REVERT_MSG); PostMessage(BUTTON_REVERT_MSG);
break; break;

View File

@ -1,21 +1,20 @@
#ifndef ALERTWINDOW_H #ifndef __ALERTWINDOW_H
#define ALERTWINDOW_H #define __ALERTWINDOW_H
#include "AlertView.h" #include "AlertView.h"
class AlertWindow : public BWindow class AlertWindow : public BWindow
{ {
public: public:
AlertWindow(BRect frame); AlertWindow(BRect frame);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
private: private:
AlertView *fAlertView; AlertView *fAlertView;
BMessageRunner *fRunner; BMessageRunner *fRunner;
BButton *fRevertButton; BButton *fRevertButton;
BButton *fKeepButton; BButton *fKeepButton;
}; };
#endif #endif

View File

@ -2,26 +2,26 @@
#define CONSTANTS_H #define CONSTANTS_H
//Messages //Messages
static const int32 WORKSPACE_CHECK_MSG = 'wchk'; static const uint32 WORKSPACE_CHECK_MSG = 'wchk';
static const int32 BUTTON_DEFAULTS_MSG = 'bdef'; static const uint32 BUTTON_DEFAULTS_MSG = 'bdef';
static const int32 BUTTON_REVERT_MSG = 'brev'; static const uint32 BUTTON_REVERT_MSG = 'brev';
static const int32 BUTTON_APPLY_MSG = 'bapl'; static const uint32 BUTTON_APPLY_MSG = 'bapl';
static const int32 BUTTON_DONE_MSG = 'bdon'; static const uint32 BUTTON_DONE_MSG = 'bdon';
static const int32 BUTTON_CANCEL_MSG = 'bcnc'; static const uint32 BUTTON_CANCEL_MSG = 'bcnc';
static const int32 BUTTON_KEEP_MSG = 'bkep'; static const uint32 BUTTON_KEEP_MSG = 'bkep';
static const int32 POP_WORKSPACE_CHANGED_MSG = 'pwsc'; static const uint32 POP_WORKSPACE_CHANGED_MSG = 'pwsc';
static const int32 POP_RESOLUTION_MSG = 'pres'; static const uint32 POP_RESOLUTION_MSG = 'pres';
static const int32 POP_COLORS_MSG = 'pclr'; static const uint32 POP_COLORS_MSG = 'pclr';
static const int32 POP_REFRESH_MSG = 'prfr'; static const uint32 POP_REFRESH_MSG = 'prfr';
static const int32 POP_OTHER_REFRESH_MSG = 'porf'; static const uint32 POP_OTHER_REFRESH_MSG = 'porf';
static const int32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc';
static const int32 UPDATE_DESKTOP_MSG = 'udsk'; static const uint32 UPDATE_DESKTOP_MSG = 'udsk';
static const int32 SLIDER_MODIFICATION_MSG = 'sldm'; static const uint32 SLIDER_MODIFICATION_MSG = 'sldm';
static const int32 SLIDER_INVOKE_MSG = 'sldi'; static const uint32 SLIDER_INVOKE_MSG = 'sldi';
static const int32 SET_INITIAL_MODE_MSG = 'sinm'; static const uint32 SET_INITIAL_MODE_MSG = 'sinm';
static const int32 SET_CUSTOM_REFRESH_MSG = 'scrf'; static const uint32 SET_CUSTOM_REFRESH_MSG = 'scrf';
static const int32 DIM_COUNT_MSG = 'scrf'; static const uint32 DIM_COUNT_MSG = 'scrf';
static const int32 MAKE_INITIAL_MSG = 'mkin'; static const uint32 MAKE_INITIAL_MSG = 'mkin';
//Constants //Constants
static const char kAppSignature[] = "application/x-vnd.Be-SCRN"; static const char kAppSignature[] = "application/x-vnd.Be-SCRN";

View File

@ -26,9 +26,8 @@ RefreshSlider::~RefreshSlider()
void void
RefreshSlider::DrawFocusMark() RefreshSlider::DrawFocusMark()
{ {
if (IsFocus()) if (IsFocus()) {
{ rgb_color blue = { 0, 0, 229, 255 };
rgb_color blueColor = { 0, 0, 229, 255 };
BRect rect(ThumbFrame()); BRect rect(ThumbFrame());
BView *view = OffscreenView(); BView *view = OffscreenView();
@ -37,7 +36,7 @@ RefreshSlider::DrawFocusMark()
rect.right--; rect.right--;
rect.bottom--; rect.bottom--;
view->SetHighColor(blueColor); view->SetHighColor(blue);
view->StrokeRect(rect); view->StrokeRect(rect);
} }
} }
@ -46,7 +45,7 @@ RefreshSlider::DrawFocusMark()
void void
RefreshSlider::KeyDown(const char *bytes, int32 numBytes) RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
{ {
switch ( *bytes ) switch (*bytes)
{ {
case B_LEFT_ARROW: case B_LEFT_ARROW:
{ {
@ -75,14 +74,11 @@ RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
char* char*
RefreshSlider::UpdateText() const RefreshSlider::UpdateText() const
{ {
if (fStatus && Window()->Lock()) if (fStatus) {
{
sprintf(fStatus, "%.1f Hz", (float)Value() / 10); sprintf(fStatus, "%.1f Hz", (float)Value() / 10);
return fStatus; return fStatus;
} }
else else
{
return NULL; return NULL;
}
} }

View File

@ -1,17 +1,16 @@
#ifndef REFRESHSLIDER_H #ifndef __REFRESHSLIDER_H
#define REFRESHSLIDER_H #define __REFRESHSLIDER_H
#include <Slider.h> #include <Slider.h>
class RefreshSlider : public BSlider class RefreshSlider : public BSlider
{ {
public: public:
RefreshSlider(BRect frame); RefreshSlider(BRect frame);
~RefreshSlider(); ~RefreshSlider();
virtual void DrawFocusMark(); virtual void DrawFocusMark();
virtual char* UpdateText() const; virtual char *UpdateText() const;
virtual void KeyDown(const char *bytes, int32 numBytes); virtual void KeyDown(const char *bytes, int32 numBytes);
private: private:
char* fStatus; char* fStatus;

View File

@ -1,7 +1,6 @@
#include <View.h> #include <View.h>
#include "RefreshView.h" #include "RefreshView.h"
#include "Utility.h"
RefreshView::RefreshView(BRect rect, char *name) RefreshView::RefreshView(BRect rect, char *name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
@ -12,27 +11,30 @@ RefreshView::RefreshView(BRect rect, char *name)
void void
RefreshView::AttachedToWindow() RefreshView::AttachedToWindow()
{ {
SetViewColor(greyColor); rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(grey);
} }
void void
RefreshView::Draw(BRect updateRect) 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()); 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.right, bounds.top));
StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.left, bounds.bottom)); 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.left, bounds.bottom), BPoint(bounds.right, bounds.bottom));
StrokeLine(BPoint(bounds.right, bounds.bottom), BPoint(bounds.right, bounds.top)); StrokeLine(BPoint(bounds.right, bounds.bottom), BPoint(bounds.right, bounds.top));
SetHighColor(blackColor); SetHighColor(black);
SetLowColor(ViewColor()); SetLowColor(ViewColor());
DrawString("Type or use the left and right arrow keys.", BPoint(10.0, 23.0)); DrawString("Type or use the left and right arrow keys.", BPoint(10.0, 23.0));

View File

@ -1,15 +1,14 @@
#ifndef REFRESHVIEW_H #ifndef __REFRESHVIEW_H
#define REFRESHVIEW_H #define __REFRESHVIEW_H
#include <View.h> #include <View.h>
class RefreshView : public BView class RefreshView : public BView
{ {
public: public:
RefreshView(BRect frame, char *name); RefreshView(BRect frame, char *name);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
}; };
#endif #endif

View File

@ -13,9 +13,9 @@
RefreshWindow::RefreshWindow(BRect frame, int32 value) RefreshWindow::RefreshWindow(BRect frame, int32 value)
: BWindow(frame, "Refresh Rate", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES) : 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); AddChild(fRefreshView);
@ -56,8 +56,6 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
fRefreshView->AddChild(fCancelButton); fRefreshView->AddChild(fCancelButton);
Show();
PostMessage(SLIDER_INVOKE_MSG); PostMessage(SLIDER_INVOKE_MSG);
} }
@ -76,14 +74,13 @@ RefreshWindow::MessageReceived(BMessage* message)
{ {
case BUTTON_DONE_MSG: case BUTTON_DONE_MSG:
{ {
BMessenger Messenger(kAppSignature); BMessenger messenger(kAppSignature);
BMessage Message(SET_CUSTOM_REFRESH_MSG); BMessage message(SET_CUSTOM_REFRESH_MSG);
float Value = (float)fRefreshSlider->Value() / 10; float value = (float)fRefreshSlider->Value() / 10;
Message.AddFloat("refresh", Value); message.AddFloat("refresh", value);
messenger.SendMessage(&message);
Messenger.SendMessage(&Message);
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);

View File

@ -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 // web.tiscalinet.it/rockman
// rockman@tiscalinet.it // rockman@tiscalinet.it
// Modified by Stefano Ceccherini ( burton666@freemail.it ) // Additional code by Stefano Ceccherini ( burton666@freemail.it )
#include <Application.h> #include <Application.h>
#include <Alert.h> #include <Alert.h>
@ -15,10 +15,10 @@
#include "Constants.h" #include "Constants.h"
ScreenApplication::ScreenApplication() ScreenApplication::ScreenApplication()
: : BApplication(kAppSignature),
BApplication(kAppSignature),
fScreenWindow(new ScreenWindow(new ScreenSettings())) fScreenWindow(new ScreenWindow(new ScreenSettings()))
{ {
fScreenWindow->Show();
} }
@ -54,9 +54,9 @@ ScreenApplication::MessageReceived(BMessage* message)
int int
main() main()
{ {
ScreenApplication Application; ScreenApplication app;
Application.Run(); app.Run();
return(0); return 0;
} }

Binary file not shown.

View File

@ -1,19 +1,16 @@
#ifndef SCREENAPPLICATION_H #ifndef __SCREENAPPLICATION_H
#define SCREENAPPLICATION_H #define __SCREENAPPLICATION_H
#include "ScreenWindow.h" #include "ScreenWindow.h"
class ScreenApplication : public BApplication class ScreenApplication : public BApplication
{ {
public: public:
ScreenApplication(); ScreenApplication();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void AboutRequested(); virtual void AboutRequested();
private: private:
ScreenWindow *fScreenWindow; ScreenWindow *fScreenWindow;
bool NeedWindow;
}; };
#endif #endif

View File

@ -7,9 +7,8 @@
#include <cstdlib> #include <cstdlib>
#include "ScreenDrawView.h"
#include "Constants.h" #include "Constants.h"
#include "Utility.h" #include "ScreenDrawView.h"
ScreenDrawView::ScreenDrawView(BRect rect, char *name) ScreenDrawView::ScreenDrawView(BRect rect, char *name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
@ -45,16 +44,18 @@ ScreenDrawView::MouseDown(BPoint point)
void void
ScreenDrawView::Draw(BRect updateRect) 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 //FIXME: Make the draw code resolution independent
if (fResolution == 1600) if (fResolution == 1600)
{ {
rgb_color darkColor = {160, 160, 160, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(Bounds(), 3.0, 3.0); FillRoundRect(Bounds(), 3.0, 3.0);
SetHighColor(blackColor); SetHighColor(black);
StrokeRoundRect(Bounds(), 3.0, 3.0); 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); 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); 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)); StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0));
} }
else if(fResolution == 1280) else if(fResolution == 1280)
{ {
rgb_color darkColor = {160, 160, 160, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0); 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); 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); 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); 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)); StrokeLine(BPoint(15.0, 70.0), BPoint(16.0, 70.0));
} }
else if(fResolution == 1152) else if(fResolution == 1152)
{ {
rgb_color darkColor = {160, 160, 160, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0); 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); 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); 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); 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)); StrokeLine(BPoint(19.0, 66.0), BPoint(20.0, 66.0));
} }
else if(fResolution == 1024) else if(fResolution == 1024)
{ {
rgb_color darkColor = {160, 160, 160, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0); 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); 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); 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); 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)); StrokeLine(BPoint(22.0, 62.0), BPoint(23.0, 62.0));
} }
else if(fResolution == 800) else if(fResolution == 800)
{ {
rgb_color darkColor = {160, 160, 160, 255};
rgb_color redColor = {228, 0, 0, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0); 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); 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); 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); 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)); StrokeLine(BPoint(29.0, 56.0), BPoint(30.0, 56.0));
} }
else if(fResolution == 640) else if(fResolution == 640)
{ {
rgb_color darkColor = {160, 160, 160, 255};
SetHighColor(darkColor); SetHighColor(darkColor);
FillRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0); 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); 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); 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); 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)); StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0));
} }
@ -201,14 +191,13 @@ ScreenDrawView::MessageReceived(BMessage* message)
{ {
case UPDATE_DESKTOP_MSG: case UPDATE_DESKTOP_MSG:
{ {
BString Resolution; BString resolution;
message->FindString("resolution", &Resolution); message->FindString("resolution", &resolution);
int32 NextfResolution = atoi(Resolution.String()); int32 nextfResolution = atoi(resolution.String());
if (fResolution != NextfResolution) if (fResolution != nextfResolution) {
{ fResolution = nextfResolution;
fResolution = NextfResolution;
Invalidate(); Invalidate();
} }
@ -227,7 +216,6 @@ ScreenDrawView::MessageReceived(BMessage* message)
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
break; break;
} }
} }

View File

@ -1,21 +1,20 @@
#ifndef SCREENDRAWVIEW_H #ifndef __SCREENDRAWVIEW_H
#define SCREENDRAWVIEW_H #define __SCREENDRAWVIEW_H
#include <View.h> #include <View.h>
class ScreenDrawView : public BView class ScreenDrawView : public BView
{ {
public: public:
ScreenDrawView(BRect frame, char *name); ScreenDrawView(BRect frame, char *name);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void MouseDown(BPoint point); virtual void MouseDown(BPoint point);
private: private:
rgb_color desktopColor; rgb_color desktopColor;
int32 fResolution; int32 fResolution;
}; };
#endif #endif

View File

@ -1,21 +1,20 @@
#ifndef SCREENSETTINGS_H #ifndef __SCREENSETTINGS_H
#define SCREENSETTINGS_H #define __SCREENSETTINGS_H
#include <View.h> #include <View.h>
class ScreenSettings class ScreenSettings
{ {
public: public:
ScreenSettings(); ScreenSettings();
virtual ~ScreenSettings(); virtual ~ScreenSettings();
BRect WindowFrame() const { return fWindowFrame; }; BRect WindowFrame() const { return fWindowFrame; };
void SetWindowFrame(BRect); void SetWindowFrame(BRect);
private: private:
static const char fScreenSettingsFile[]; static const char fScreenSettingsFile[];
BRect fWindowFrame; BRect fWindowFrame;
}; };
#endif #endif

View File

@ -12,24 +12,29 @@ ScreenView::ScreenView(BRect rect, char *name)
void void
ScreenView::AttachedToWindow() ScreenView::AttachedToWindow()
{ {
SetViewColor(greyColor); rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR);
SetViewColor(grey);
} }
void void
ScreenView::Draw(BRect updateRect) 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)); SetHighColor(white);
StrokeLine(BPoint(Bounds().left, Bounds().top), BPoint(Bounds().left, Bounds().bottom));
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)); SetHighColor(dark3);
StrokeLine(BPoint(Bounds().right, Bounds().bottom), BPoint(Bounds().right, Bounds().top));
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);
} }

View File

@ -1,15 +1,14 @@
#ifndef SCREENVIEW_H #ifndef __SCREENVIEW_H
#define SCREENVIEW_H #define __SCREENVIEW_H
#include <View.h> #include <View.h>
class ScreenView : public BView class ScreenView : public BView
{ {
public: public:
ScreenView(BRect frame, char *name); ScreenView(BRect frame, char *name);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
}; };
#endif #endif

View File

@ -27,53 +27,46 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
BRect frame(Bounds()); BRect frame(Bounds());
BScreen screen(B_MAIN_SCREEN_ID); BScreen screen(B_MAIN_SCREEN_ID);
if (!screen.IsValid()) { if (!screen.IsValid())
//What could we do? ;//debugger() ?
//debugger() ?
}
screen.GetModeList(&fSupportedModes, &fTotalModes); screen.GetModeList(&fSupportedModes, &fTotalModes);
fScreenView = new ScreenView(frame, "ScreenView"); fScreenView = new ScreenView(frame, "ScreenView");
AddChild(fScreenView); AddChild(fScreenView);
fSettings = Settings; fSettings = Settings;
BRect ScreenBoxRect; BRect ScreenBoxRect(11.0, 18.0, 153.0, 155.0);
BRect ScreenDrawViewRect; BRect ScreenDrawViewRect(20.0, 16.0, 122.0, 93.0);
BRect ControlsBoxRect; BRect ControlsBoxRect;
BRect WorkspaceMenuRect; BRect WorkspaceMenuRect;
BRect WorkspaceCountMenuRect; BRect WorkspaceCountMenuRect;
BRect ControlMenuRect; BRect ControlMenuRect;
BRect ButtonRect; BRect ButtonRect;
ScreenBoxRect.Set(11.0, 18.0, 153.0, 155.0);
fScreenBox = new BBox(ScreenBoxRect); fScreenBox = new BBox(ScreenBoxRect);
fScreenBox->SetBorder(B_FANCY_BORDER); fScreenBox->SetBorder(B_FANCY_BORDER);
ScreenDrawViewRect.Set(20.0, 16.0, 122.0, 93.0);
fScreenDrawView = new ScreenDrawView(ScreenDrawViewRect, "ScreenDrawView"); 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++) for (int32 count = 1; count <= 32; count++) {
{ string.Truncate(0);
String.Truncate(0); string << count;
String << Count; fWorkspaceCountMenu->AddItem(new BMenuItem(string.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG)));
fWorkspaceCountMenu->AddItem(new BMenuItem(String.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG)));
} }
String.Truncate(0); string.Truncate(0);
String << count_workspaces(); string << count_workspaces();
BMenuItem *Marked = fWorkspaceCountMenu->FindItem(String.String()); BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String());
Marked->SetMarked(true); marked->SetMarked(true);
WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0); WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0);
@ -82,9 +75,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
fWorkspaceCountField->SetDivider(91.0); fWorkspaceCountField->SetDivider(91.0);
fScreenBox->AddChild(fScreenDrawView); fScreenBox->AddChild(fScreenDrawView);
fScreenBox->AddChild(fWorkspaceCountField); fScreenBox->AddChild(fWorkspaceCountField);
fScreenView->AddChild(fScreenBox); fScreenView->AddChild(fScreenBox);
fWorkspaceMenu = new BPopUpMenu("Current Workspace", true, true); 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); ButtonRect.Set(88.0, 114.0, 200.0, 150.0);
fApplyButton = new BButton(ButtonRect, "ApplyButton", "Apply", fApplyButton = new BButton(ButtonRect, "ApplyButton", "Apply",
new BMessage(BUTTON_APPLY_MSG)); new BMessage(BUTTON_APPLY_MSG));
fApplyButton->AttachedToWindow(); fApplyButton->AttachedToWindow();
fApplyButton->ResizeToPreferred(); fApplyButton->ResizeToPreferred();
@ -115,7 +106,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
fControlsBox->AddChild(fApplyButton); fControlsBox->AddChild(fApplyButton);
fResolutionMenu = new BPopUpMenu("640 x 480", true, true); fResolutionMenu = new BPopUpMenu("", true, true);
for (uint32 c = 0; c < fTotalModes; c++) { for (uint32 c = 0; c < fTotalModes; c++) {
BString mode; BString mode;
mode << (int32)fSupportedModes[c].virtual_width << " x " << (int32)fSupportedModes[c].virtual_height; 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(), fResolutionMenu->AddItem(new BMenuItem(mode.String(),
new BMessage(POP_RESOLUTION_MSG))); new BMessage(POP_RESOLUTION_MSG)));
} }
ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0); ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0);
fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true); fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true);
Marked = fResolutionMenu->ItemAt(0); marked = fResolutionMenu->ItemAt(0);
Marked->SetMarked(true); marked->SetMarked(true);
fResolutionField->SetDivider(55.0); fResolutionField->SetDivider(55.0);
fControlsBox->AddChild(fResolutionField); fControlsBox->AddChild(fResolutionField);
fColorsMenu = new BPopUpMenu("8 Bits/Pixel", true, true); fColorsMenu = new BPopUpMenu("", true, true);
// Get the supported colorspaces // Get the supported colorspaces
for (uint32 c = 0; c < fTotalModes; c++) { for (uint32 c = 0; c < fTotalModes; c++) {
@ -154,24 +144,24 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
colorSpace = "32 Bits/Pixel"; colorSpace = "32 Bits/Pixel";
break; break;
} }
if (!fColorsMenu->FindItem(colorSpace.String())) if (!fColorsMenu->FindItem(colorSpace.String()))
fColorsMenu->AddItem(new BMenuItem(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); 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 = fColorsMenu->ItemAt(0);
Marked->SetMarked(true); marked->SetMarked(true);
fColorsField->SetDivider(38.0); fColorsField->SetDivider(38.0);
fControlsBox->AddChild(fColorsField); 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("56 Hz", new BMessage(POP_REFRESH_MSG)));
fRefreshMenu->AddItem(new BMenuItem("60 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))); 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); fRefreshField = new BMenuField(ControlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true);
Marked = fRefreshMenu->FindItem("60 Hz"); marked = fRefreshMenu->FindItem("60 Hz");
Marked->SetMarked(true); marked->SetMarked(true);
fRefreshField->SetDivider(69.0); fRefreshField->SetDivider(69.0);
@ -219,35 +209,38 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
fInitialMode = mode; 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 = fResolutionMenu->FindItem(string.String());
Marked->SetMarked(true); marked->SetMarked(true);
fInitialResolution = Marked; fInitialResolution = marked;
if (mode.space == B_CMAP8){ switch (mode.space) {
Marked = fColorsMenu->FindItem("8 Bits/Pixel"); case B_RGB32:
Marked->SetMarked(true); marked = fColorsMenu->FindItem("32 Bits/Pixel");
break;
} else if (mode.space == B_RGB15) { case B_RGB16:
Marked = fColorsMenu->FindItem("15 Bits/Pixel"); marked = fColorsMenu->FindItem("16 Bits/Pixel");
Marked->SetMarked(true); break;
} else if (mode.space == B_RGB16) { case B_RGB15:
Marked = fColorsMenu->FindItem("16 Bits/Pixel"); marked = fColorsMenu->FindItem("15 Bits/Pixel");
Marked->SetMarked(true); break;
} else if (mode.space == B_RGB32) { case B_CMAP8:
Marked = fColorsMenu->FindItem("32 Bits/Pixel"); default:
Marked->SetMarked(true); 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; float total_size = mode.timing.h_total * mode.timing.v_total;
@ -255,39 +248,37 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
fCustomRefresh = fInitialRefreshN; 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); marked->SetMarked(true);
fInitialRefresh = Marked; fInitialRefresh = marked;
} else { } else {
BMenuItem *Other = fRefreshMenu->FindItem("Other..."); BMenuItem *other = fRefreshMenu->FindItem("Other...");
String.Truncate(0); string.Truncate(0);
String << fInitialRefreshN; string << fInitialRefreshN;
int32 point = String.FindFirst('.'); int32 point = string.FindFirst('.');
String.Truncate(point + 2); string.Truncate(point + 2);
String << " Hz/Other..."; string << " Hz/Other...";
Other->SetLabel(String.String()); other->SetLabel(string.String());
Other->SetMarked(true); other->SetMarked(true);
point = String.FindFirst('/'); point = string.FindFirst('/');
String.Truncate(point); string.Truncate(point);
fRefreshMenu->Superitem()->SetLabel(String.String()); fRefreshMenu->Superitem()->SetLabel(string.String());
fInitialRefresh = Other; fInitialRefresh = other;
} }
Show();
} }
ScreenWindow::~ScreenWindow() ScreenWindow::~ScreenWindow()
@ -384,13 +375,13 @@ ScreenWindow::MessageReceived(BMessage* message)
{ {
CheckApplyEnabled(); 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; break;
} }
@ -405,29 +396,31 @@ ScreenWindow::MessageReceived(BMessage* message)
case POP_REFRESH_MSG: case POP_REFRESH_MSG:
{ {
CheckApplyEnabled(); CheckApplyEnabled();
break; break;
} }
case POP_OTHER_REFRESH_MSG: case POP_OTHER_REFRESH_MSG:
{ {
BRect frame(Frame());
CheckApplyEnabled(); CheckApplyEnabled();
int32 value = (int32)(fCustomRefresh * 10); int32 value = (int32)(fCustomRefresh * 10);
fRefreshWindow = new RefreshWindow(BRect((Frame().left + 201.0), RefreshWindow *fRefreshWindow = new RefreshWindow(BRect((frame.left + 201.0),
(Frame().top + 34.0), (Frame().left + 509.0), (frame.top + 34.0), (frame.left + 509.0),
(Frame().top + 169.0)), value); (frame.top + 169.0)), value);
fRefreshWindow->Show();
BMenuItem *Other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG); BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
BString String; BString string;
String << Other->Label(); string << other->Label();
int32 point = String.FindFirst('z'); int32 point = string.FindFirst('z');
String.Truncate(point + 1); string.Truncate(point + 1);
fRefreshMenu->Superitem()->SetLabel(String.String()); fRefreshMenu->Superitem()->SetLabel(string.String());
break; break;
} }
@ -452,10 +445,9 @@ ScreenWindow::MessageReceived(BMessage* message)
CheckApplyEnabled(); 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; BString string;
string << fInitialRefreshN; string << fInitialRefreshN;
@ -472,13 +464,13 @@ ScreenWindow::MessageReceived(BMessage* message)
fRefreshMenu->Superitem()->SetLabel(string.String()); 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); BScreen screen(B_MAIN_SCREEN_ID);
if (!screen.IsValid()) if (!screen.IsValid())
break; break;
screen.SetMode(&fInitialMode); screen.SetMode(&fInitialMode, true);
} }
break; break;
} }
@ -509,8 +501,8 @@ ScreenWindow::MessageReceived(BMessage* message)
else else
refresh = atof(fRefreshMenu->FindMarked()->Label()); 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) if ((fSupportedModes[c].virtual_width == width)
&& (fSupportedModes[c].virtual_height == height)) && (fSupportedModes[c].virtual_height == height))
@ -521,28 +513,21 @@ ScreenWindow::MessageReceived(BMessage* message)
if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel")) if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel"))
{
mode->space = B_CMAP8; 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; 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; mode->space = B_RGB16;
}
else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("32 Bits/Pixel")) else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("32 Bits/Pixel"))
{
mode->space = B_RGB32; mode->space = B_RGB32;
}
mode->h_display_start = 0; mode->h_display_start = 0;
mode->v_display_start = 0; mode->v_display_start = 0;
if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) {
{ BAlert *WorkspacesAlert =
BAlert *WorkspacesAlert = new BAlert("WorkspacesAlert", "Change all workspaces?\nThis action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); 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(); int32 button = WorkspacesAlert->Go();
@ -552,8 +537,7 @@ ScreenWindow::MessageReceived(BMessage* message)
int32 old = current_workspace(); int32 old = current_workspace();
int32 totalWorkspaces = count_workspaces(); int32 totalWorkspaces = count_workspaces();
for (int32 count = 0; count < totalWorkspaces; count ++) for (int32 count = 0; count < totalWorkspaces; count ++) {
{
activate_workspace(count); activate_workspace(count);
screen.SetMode(mode, true); screen.SetMode(mode, true);
} }
@ -563,14 +547,14 @@ ScreenWindow::MessageReceived(BMessage* message)
else else
screen.SetMode(mode); 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.left = (screen.Frame().right / 2) - 150;
Rect.top = (screen.Frame().bottom / 2) - 42; rect.top = (screen.Frame().bottom / 2) - 42;
Rect.right = Rect.left + 300.0; rect.right = rect.left + 300.0;
Rect.bottom = Rect.top + 93.0; rect.bottom = rect.top + 93.0;
new AlertWindow(Rect); (new AlertWindow(rect))->Show();
fApplyButton->SetEnabled(false); fApplyButton->SetEnabled(false);
@ -581,26 +565,25 @@ ScreenWindow::MessageReceived(BMessage* message)
{ {
message->FindFloat("refresh", &fCustomRefresh); 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; BString string;
String << fCustomRefresh; string << fCustomRefresh;
int32 point = String.FindFirst('.'); int32 point = string.FindFirst('.');
String.Truncate(point + 2); 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('/'); point = string.FindFirst('/');
String.Truncate(point); string.Truncate(point);
fRefreshMenu->Superitem()->SetLabel(String.String()); fRefreshMenu->Superitem()->SetLabel(string.String());
if (fCustomRefresh != fInitialRefreshN) if (fCustomRefresh != fInitialRefreshN) {
{
fApplyButton->SetEnabled(true); fApplyButton->SetEnabled(true);
fRevertButton->SetEnabled(true); fRevertButton->SetEnabled(true);
} }

View File

@ -1,5 +1,5 @@
#ifndef SCREENWINDOW_H #ifndef __SCREENWINDOW_H
#define SCREENWINDOW_H #define __SCREENWINDOW_H
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <MenuField.h> #include <MenuField.h>
@ -26,10 +26,10 @@ public:
private: private:
void CheckApplyEnabled(); void CheckApplyEnabled();
ScreenSettings *fSettings; ScreenSettings *fSettings;
ScreenView *fScreenView; ScreenView *fScreenView;
ScreenDrawView *fScreenDrawView; ScreenDrawView *fScreenDrawView;
RefreshWindow *fRefreshWindow;
BPopUpMenu *fWorkspaceMenu; BPopUpMenu *fWorkspaceMenu;
BMenuField *fWorkspaceField; BMenuField *fWorkspaceField;
BPopUpMenu *fWorkspaceCountMenu; BPopUpMenu *fWorkspaceCountMenu;

View File

@ -1,12 +1,6 @@
#include "Utility.h" #include "Utility.h"
#include <math.h> #include <math.h>
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) float round(float n, int32 max)
{ {
max = (int32)pow(10, (float)max); max = (int32)pow(10, (float)max);

View File

@ -1,16 +1,8 @@
#ifndef __UTILITY_H #ifndef __UTILITY_H
#define __UTILITY_H #define __UTILITY_H
#include <InterfaceDefs.h>
#include <SupportDefs.h> #include <SupportDefs.h>
extern float round(float n, int32 max); 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 #endif //__UTILITY_H