Huge commit. Fixed screen preflet. It does work now. Still has some minor bugs, but it's fully functional.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2070 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,27 +4,29 @@
|
|||||||
|
|
||||||
#include "AlertView.h"
|
#include "AlertView.h"
|
||||||
#include "Bitmaps.h"
|
#include "Bitmaps.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 = 10;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlertView::AttachedToWindow()
|
|
||||||
|
void
|
||||||
|
AlertView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
rgb_color greyColor = {216, 216, 216, 255};
|
|
||||||
SetViewColor(greyColor);
|
SetViewColor(greyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlertView::Draw(BRect updateRect)
|
|
||||||
{
|
void
|
||||||
rgb_color darkColor = {184, 184, 184, 255};
|
AlertView::Draw(BRect updateRect)
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
{
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
FillRect(BRect(0.0, 0.0, 30.0, 100.0));
|
FillRect(BRect(0.0, 0.0, 30.0, 100.0));
|
||||||
@@ -39,9 +41,7 @@ void AlertView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
SetFont(be_bold_font);
|
SetFont(be_bold_font);
|
||||||
|
|
||||||
MovePenTo(60.0, 20.0);
|
DrawString("Do you wish to keep these settings?", BPoint(60.0, 20.0));
|
||||||
|
|
||||||
DrawString("Do you wish to keep these settings?");
|
|
||||||
|
|
||||||
MovePenTo(60.0, 37.0);
|
MovePenTo(60.0, 37.0);
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ 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;
|
||||||
|
|||||||
@@ -49,16 +49,20 @@ AlertWindow::AlertWindow(BRect frame)
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlertWindow::QuitRequested()
|
|
||||||
|
bool
|
||||||
|
AlertWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
delete fRunner;
|
delete fRunner;
|
||||||
|
|
||||||
Quit();
|
Quit();
|
||||||
|
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlertWindow::MessageReceived(BMessage *message)
|
|
||||||
|
void
|
||||||
|
AlertWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (message->what)
|
switch (message->what)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef CONSTANTS_H
|
#ifndef CONSTANTS_H
|
||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
|
//Messages
|
||||||
#define WORKSPACE_CHECK_MSG 'wchk'
|
#define WORKSPACE_CHECK_MSG 'wchk'
|
||||||
#define BUTTON_DEFAULTS_MSG 'bdef'
|
#define BUTTON_DEFAULTS_MSG 'bdef'
|
||||||
#define BUTTON_REVERT_MSG 'brev'
|
#define BUTTON_REVERT_MSG 'brev'
|
||||||
@@ -22,4 +23,7 @@
|
|||||||
#define DIM_COUNT_MSG 'scrf'
|
#define DIM_COUNT_MSG 'scrf'
|
||||||
#define MAKE_INITIAL_MSG 'mkin'
|
#define MAKE_INITIAL_MSG 'mkin'
|
||||||
|
|
||||||
#endif
|
//Constants
|
||||||
|
static const char kAppSignature[] = "application/x-vnd.RR-SCRN";
|
||||||
|
|
||||||
|
#endif //CONSTANTS_H
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ SubDir OBOS_TOP src prefs screen ;
|
|||||||
|
|
||||||
AddResources Screen : Screen.rsrc ;
|
AddResources Screen : Screen.rsrc ;
|
||||||
|
|
||||||
Preference Screen : AlertView.cpp AlertWindow.cpp RefreshSlider.cpp RefreshView.cpp RefreshWindow.cpp Screen.cpp ScreenDrawView.cpp ScreenSettings.cpp ScreenView.cpp ScreenWindow.cpp ;
|
Preference Screen : AlertView.cpp AlertWindow.cpp RefreshSlider.cpp RefreshView.cpp RefreshWindow.cpp Screen.cpp ScreenDrawView.cpp ScreenSettings.cpp ScreenView.cpp ScreenWindow.cpp Utility.cpp ;
|
||||||
|
|
||||||
LinkSharedOSLibs Screen : be root ;
|
LinkSharedOSLibs Screen : be root ;
|
||||||
|
|||||||
@@ -11,41 +11,40 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
RefreshSlider::RefreshSlider(BRect frame)
|
RefreshSlider::RefreshSlider(BRect frame)
|
||||||
: BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, 845)
|
: BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, 900),
|
||||||
{
|
fStatus(new char[64])
|
||||||
fStatus = (char*)malloc(64);
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RefreshSlider::~RefreshSlider()
|
RefreshSlider::~RefreshSlider()
|
||||||
{
|
{
|
||||||
if (fStatus)
|
delete[] fStatus;
|
||||||
free(fStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshSlider::DrawFocusMark()
|
|
||||||
|
void
|
||||||
|
RefreshSlider::DrawFocusMark()
|
||||||
{
|
{
|
||||||
if (IsFocus())
|
if (IsFocus())
|
||||||
{
|
{
|
||||||
rgb_color blueColor = {0, 0, 229, 255};
|
rgb_color blueColor = { 0, 0, 229, 255 };
|
||||||
|
|
||||||
BRect Rect;
|
BRect rect(ThumbFrame());
|
||||||
|
BView *view = OffscreenView();
|
||||||
|
|
||||||
|
rect.InsetBy(2.0, 2.0);
|
||||||
|
rect.right--;
|
||||||
|
rect.bottom--;
|
||||||
|
|
||||||
BView *View;
|
view->SetHighColor(blueColor);
|
||||||
|
view->StrokeRect(rect);
|
||||||
Rect = ThumbFrame();
|
|
||||||
|
|
||||||
View = OffscreenView();
|
|
||||||
|
|
||||||
Rect.InsetBy(2.0, 2.0);
|
|
||||||
Rect.right = Rect.right - 1;
|
|
||||||
Rect.bottom = Rect.bottom - 1;
|
|
||||||
|
|
||||||
View->SetHighColor(blueColor);
|
|
||||||
View->StrokeRect(Rect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
|
|
||||||
|
void
|
||||||
|
RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
|
||||||
{
|
{
|
||||||
switch ( *bytes )
|
switch ( *bytes )
|
||||||
{
|
{
|
||||||
@@ -72,30 +71,25 @@ void RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* RefreshSlider::UpdateText() const
|
|
||||||
|
char*
|
||||||
|
RefreshSlider::UpdateText() const
|
||||||
{
|
{
|
||||||
if (fStatus && Window()->Lock())
|
if (fStatus && Window()->Lock())
|
||||||
{
|
{
|
||||||
BString String;
|
BString String;
|
||||||
|
|
||||||
String << Value();
|
String << Value();
|
||||||
|
String.CopyInto(fStatus, 0, String.Length() + 1);
|
||||||
int32 Len = String.Length()+1;
|
|
||||||
strcpy(fStatus, String.LockBuffer(Len));
|
|
||||||
|
|
||||||
char Last = fStatus[2];
|
|
||||||
|
|
||||||
String.UnlockBuffer(Len);
|
char Last = fStatus[2];
|
||||||
|
|
||||||
String.Truncate(2);
|
String.Truncate(2);
|
||||||
|
|
||||||
String << "." << Last << " Hz";
|
String << "." << Last << " Hz";
|
||||||
|
|
||||||
strcpy(fStatus, String.LockBuffer(Len));
|
String.CopyInto(fStatus, 0, String.Length() + 1);
|
||||||
|
|
||||||
String.UnlockBuffer(Len);
|
return fStatus;
|
||||||
|
|
||||||
return(fStatus);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,36 +1,39 @@
|
|||||||
#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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshView::AttachedToWindow()
|
|
||||||
|
void
|
||||||
|
RefreshView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
rgb_color greyColor = {216, 216, 216, 255};
|
|
||||||
SetViewColor(greyColor);
|
SetViewColor(greyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshView::Draw(BRect updateRect)
|
|
||||||
|
void
|
||||||
|
RefreshView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
rgb_color whiteColor = {255, 255, 255, 255};
|
rgb_color darkColor = { 128, 128, 128, 255 };
|
||||||
rgb_color darkColor = {128, 128, 128, 255};
|
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
|
|
||||||
|
BRect bounds(Bounds());
|
||||||
SetHighColor(whiteColor);
|
SetHighColor(whiteColor);
|
||||||
|
|
||||||
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(darkColor);
|
||||||
|
|
||||||
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(blackColor);
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
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)
|
||||||
{
|
{
|
||||||
int32 Value = value * 10;
|
|
||||||
|
|
||||||
frame = Bounds();
|
frame = Bounds();
|
||||||
|
|
||||||
fRefreshView = new RefreshView(frame, "RefreshView");
|
fRefreshView = new RefreshView(frame, "RefreshView");
|
||||||
@@ -29,20 +27,18 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
|
|||||||
|
|
||||||
fRefreshSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
fRefreshSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
fRefreshSlider->SetHashMarkCount(10);
|
fRefreshSlider->SetHashMarkCount(10);
|
||||||
fRefreshSlider->SetLimitLabels("45.0", "84.5");
|
fRefreshSlider->SetLimitLabels("45.0", "90.0");
|
||||||
fRefreshSlider->SetKeyIncrementValue(1);
|
fRefreshSlider->SetKeyIncrementValue(1);
|
||||||
fRefreshSlider->SetValue(Value);
|
fRefreshSlider->SetValue(value);
|
||||||
fRefreshSlider->SetSnoozeAmount(1);
|
fRefreshSlider->SetSnoozeAmount(1);
|
||||||
fRefreshSlider->SetModificationMessage(new BMessage(SLIDER_MODIFICATION_MSG));
|
fRefreshSlider->SetModificationMessage(new BMessage(SLIDER_MODIFICATION_MSG));
|
||||||
|
|
||||||
fRefreshView->AddChild(fRefreshSlider);
|
fRefreshView->AddChild(fRefreshSlider);
|
||||||
|
|
||||||
BRect ButtonRect;
|
BRect ButtonRect(219.0, 97.0, 230.0, 120.0);
|
||||||
|
|
||||||
ButtonRect.Set(219.0, 97.0, 230.0, 120.0);
|
|
||||||
|
|
||||||
fDoneButton = new BButton(ButtonRect, "DoneButton", "Done",
|
fDoneButton = new BButton(ButtonRect, "DoneButton", "Done",
|
||||||
new BMessage(BUTTON_DONE_MSG));
|
new BMessage(BUTTON_DONE_MSG));
|
||||||
|
|
||||||
fDoneButton->ResizeToPreferred();
|
fDoneButton->ResizeToPreferred();
|
||||||
fDoneButton->MakeDefault(true);
|
fDoneButton->MakeDefault(true);
|
||||||
@@ -52,7 +48,7 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
|
|||||||
ButtonRect.Set(130.0, 97.0, 200.0, 120.0);
|
ButtonRect.Set(130.0, 97.0, 200.0, 120.0);
|
||||||
|
|
||||||
fCancelButton = new BButton(ButtonRect, "CancelButton", "Cancel",
|
fCancelButton = new BButton(ButtonRect, "CancelButton", "Cancel",
|
||||||
new BMessage(BUTTON_CANCEL_MSG));
|
new BMessage(BUTTON_CANCEL_MSG));
|
||||||
|
|
||||||
fCancelButton->ResizeToPreferred();
|
fCancelButton->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -63,32 +59,25 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
|
|||||||
PostMessage(SLIDER_INVOKE_MSG);
|
PostMessage(SLIDER_INVOKE_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RefreshWindow::QuitRequested()
|
|
||||||
|
void
|
||||||
|
RefreshWindow::WindowActivated(bool active)
|
||||||
{
|
{
|
||||||
return(true);
|
fRefreshSlider->MakeFocus(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshWindow::WindowActivated(bool active)
|
|
||||||
{
|
|
||||||
if (active == true)
|
|
||||||
fRefreshSlider->MakeFocus(true);
|
|
||||||
else
|
|
||||||
fRefreshSlider->MakeFocus(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefreshWindow::MessageReceived(BMessage* message)
|
void
|
||||||
|
RefreshWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch(message->what)
|
||||||
{
|
{
|
||||||
case BUTTON_DONE_MSG:
|
case BUTTON_DONE_MSG:
|
||||||
{
|
{
|
||||||
BMessenger Messenger("application/x-vnd.RR-SCRN");
|
BMessenger Messenger(kAppSignature);
|
||||||
|
|
||||||
BMessage Message(SET_CUSTOM_REFRESH_MSG);
|
BMessage Message(SET_CUSTOM_REFRESH_MSG);
|
||||||
|
|
||||||
float Value;
|
float Value = (float)fRefreshSlider->Value() / 10;
|
||||||
|
|
||||||
Value = (float)fRefreshSlider->Value() / 10;
|
|
||||||
|
|
||||||
Message.AddFloat("refresh", Value);
|
Message.AddFloat("refresh", Value);
|
||||||
|
|
||||||
@@ -114,8 +103,7 @@ void RefreshWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,9 @@ class RefreshWindow : public BWindow
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RefreshWindow(BRect frame, int32 value);
|
RefreshWindow(BRect frame, int32 value);
|
||||||
virtual bool QuitRequested();
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void WindowActivated(bool active);
|
||||||
virtual void WindowActivated(bool active);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefreshView *fRefreshView;
|
RefreshView *fRefreshView;
|
||||||
|
|||||||
+23
-19
@@ -1,6 +1,7 @@
|
|||||||
// Screen V0.9 build 1 by Rafael Romo for the OpenBeOS Preferences team.
|
// Screen V1.00 by Rafael Romo for the OpenBeOS Preferences team.
|
||||||
// web.tiscalinet.it/rockman
|
// web.tiscalinet.it/rockman
|
||||||
// [email protected]
|
// [email protected]
|
||||||
|
// Modified by Stefano Ceccherini ( [email protected] )
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -14,21 +15,25 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
ScreenApplication::ScreenApplication()
|
ScreenApplication::ScreenApplication()
|
||||||
: BApplication("application/x-vnd.RR-SCRN")
|
:
|
||||||
|
BApplication(kAppSignature),
|
||||||
|
fScreenWindow(new ScreenWindow(new ScreenSettings()))
|
||||||
{
|
{
|
||||||
fScreenWindow = new ScreenWindow(new ScreenSettings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenApplication::AboutRequested()
|
|
||||||
|
void
|
||||||
|
ScreenApplication::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *AboutAlert = new BAlert("About", "Screen by Rafael Romo\nThe OBOS place to configure your monitor",
|
BAlert *AboutAlert = new BAlert("About", "Screen by Rafael Romo, Stefano Ceccherini\nThe OBOS place to configure your monitor",
|
||||||
"Ok", NULL, NULL,
|
"Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
||||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
|
||||||
AboutAlert->SetShortcut(0, B_OK);
|
AboutAlert->SetShortcut(0, B_OK);
|
||||||
AboutAlert->Go();
|
AboutAlert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenApplication::MessageReceived(BMessage* message)
|
|
||||||
|
void
|
||||||
|
ScreenApplication::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch(message->what)
|
||||||
{
|
{
|
||||||
@@ -41,17 +46,15 @@ void ScreenApplication::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case SET_CUSTOM_REFRESH_MSG:
|
case SET_CUSTOM_REFRESH_MSG:
|
||||||
{
|
{
|
||||||
BMessage *Message;
|
BMessage message(SET_CUSTOM_REFRESH_MSG);
|
||||||
|
|
||||||
Message = new BMessage(SET_CUSTOM_REFRESH_MSG);
|
|
||||||
|
|
||||||
float Value;
|
float Value;
|
||||||
|
|
||||||
message->FindFloat("refresh", &Value);
|
message.FindFloat("refresh", &Value);
|
||||||
|
|
||||||
Message->AddFloat("refresh", Value);
|
message.AddFloat("refresh", Value);
|
||||||
|
|
||||||
fScreenWindow->PostMessage(Message);
|
fScreenWindow->PostMessage(&message);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -64,17 +67,18 @@ void ScreenApplication::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(message);
|
BApplication::MessageReceived(message);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
ScreenApplication MyApplication;
|
ScreenApplication Application;
|
||||||
|
|
||||||
MyApplication.Run();
|
Application.Run();
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ 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;
|
||||||
|
|||||||
@@ -1,46 +1,55 @@
|
|||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Screen.h>
|
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <String.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "ScreenDrawView.h"
|
#include "ScreenDrawView.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
#include "Utility.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),
|
||||||
|
fScreen(new BScreen(B_MAIN_SCREEN_ID))
|
||||||
|
|
||||||
{
|
{
|
||||||
fScreen = new BScreen(B_MAIN_SCREEN_ID);
|
if (!fScreen->IsValid())
|
||||||
|
; //Debugger() ?
|
||||||
|
|
||||||
desktopColor = fScreen->DesktopColor(current_workspace());
|
desktopColor = fScreen->DesktopColor(current_workspace());
|
||||||
|
|
||||||
display_mode Mode;
|
display_mode mode;
|
||||||
|
fScreen->GetMode(&mode);
|
||||||
fScreen->GetMode(&Mode);
|
|
||||||
|
|
||||||
fResolution = Mode.virtual_width;
|
fResolution = mode.virtual_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenDrawView::AttachedToWindow()
|
|
||||||
|
void
|
||||||
|
ScreenDrawView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
rgb_color greyColor = {216, 216, 216, 255};
|
rgb_color greyColor = { 216, 216, 216, 255 };
|
||||||
SetViewColor(greyColor);
|
SetViewColor(greyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenDrawView::MouseDown(BPoint point)
|
|
||||||
|
void
|
||||||
|
ScreenDrawView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
be_roster->Launch("application/x-vnd.Be-BACK");
|
be_roster->Launch("application/x-vnd.Be-BACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenDrawView::Draw(BRect updateRect)
|
|
||||||
|
void
|
||||||
|
ScreenDrawView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
|
//FIXME: Make the draw code resolution independent
|
||||||
if (fResolution == 1600)
|
if (fResolution == 1600)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
@@ -65,8 +74,6 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
else if(fResolution == 1280)
|
else if(fResolution == 1280)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
@@ -91,8 +98,6 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
else if(fResolution == 1152)
|
else if(fResolution == 1152)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
@@ -117,8 +122,6 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
else if(fResolution == 1024)
|
else if(fResolution == 1024)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
@@ -143,7 +146,6 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
else if(fResolution == 800)
|
else if(fResolution == 800)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
rgb_color redColor = {228, 0, 0, 255};
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
@@ -169,8 +171,6 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
else if(fResolution == 640)
|
else if(fResolution == 640)
|
||||||
{
|
{
|
||||||
rgb_color darkColor = {160, 160, 160, 255};
|
rgb_color darkColor = {160, 160, 160, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
rgb_color redColor = {228, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(darkColor);
|
SetHighColor(darkColor);
|
||||||
|
|
||||||
@@ -194,31 +194,18 @@ void ScreenDrawView::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenDrawView::MessageReceived(BMessage* message)
|
|
||||||
|
void
|
||||||
|
ScreenDrawView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch(message->what)
|
||||||
{
|
{
|
||||||
case UPDATE_DESKTOP_MSG:
|
case UPDATE_DESKTOP_MSG:
|
||||||
{
|
{
|
||||||
const char *Resolution;
|
BString Resolution;
|
||||||
int32 NextfResolution;
|
|
||||||
|
|
||||||
message->FindString("resolution", &Resolution);
|
message->FindString("resolution", &Resolution);
|
||||||
|
|
||||||
if (strcmp(Resolution, "640 x 480") == 0)
|
int32 NextfResolution = atoi(Resolution.String());
|
||||||
NextfResolution = 640;
|
|
||||||
else if (strcmp(Resolution, "800 x 600") == 0)
|
|
||||||
NextfResolution = 800;
|
|
||||||
else if (strcmp(Resolution, "1024 x 768") == 0)
|
|
||||||
NextfResolution = 1024;
|
|
||||||
else if (strcmp(Resolution, "1152 x 864") == 0)
|
|
||||||
NextfResolution = 1152;
|
|
||||||
else if (strcmp(Resolution, "1280 x 1024") == 0)
|
|
||||||
NextfResolution = 1280;
|
|
||||||
else if (strcmp(Resolution, "1600 x 1200") == 0)
|
|
||||||
NextfResolution = 1600;
|
|
||||||
else
|
|
||||||
NextfResolution = 640;
|
|
||||||
|
|
||||||
if (fResolution != NextfResolution)
|
if (fResolution != NextfResolution)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,37 +3,43 @@
|
|||||||
|
|
||||||
#include "ScreenSettings.h"
|
#include "ScreenSettings.h"
|
||||||
|
|
||||||
const char ScreenSettings::fScreenSettingsFile[] = "RRScreen_Data";
|
const char ScreenSettings::fScreenSettingsFile[] = "OBOS_Screen_data";
|
||||||
|
|
||||||
ScreenSettings::ScreenSettings()
|
ScreenSettings::ScreenSettings()
|
||||||
{
|
{
|
||||||
|
BScreen screen(B_MAIN_SCREEN_ID);
|
||||||
|
|
||||||
|
if (!screen.IsValid())
|
||||||
|
; //Debugger() ?
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK)
|
||||||
{
|
{
|
||||||
path.Append(fScreenSettingsFile);
|
path.Append(fScreenSettingsFile);
|
||||||
|
|
||||||
BFile file(path.Path(), B_READ_ONLY);
|
BFile file(path.Path(), B_READ_ONLY);
|
||||||
if (file.InitCheck() == B_OK && file.Read(&fWindowFrame, sizeof(BRect)) == sizeof(BRect))
|
if (file.InitCheck() == B_OK)
|
||||||
{
|
{
|
||||||
BScreen Screen;
|
file.Read(&fWindowFrame, sizeof(BRect));
|
||||||
if (Screen.Frame().right >= fWindowFrame.right
|
|
||||||
&& Screen.Frame().bottom >= fWindowFrame.bottom)
|
if (screen.Frame().right >= fWindowFrame.right
|
||||||
|
&& screen.Frame().bottom >= fWindowFrame.bottom)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BScreen Screen;
|
fWindowFrame = screen.Frame();
|
||||||
fWindowFrame = Screen.Frame();
|
fWindowFrame.left = (fWindowFrame.right / 2) - 178;
|
||||||
fWindowFrame.left = (Screen.Frame().right / 2) - 178;
|
fWindowFrame.top = (fWindowFrame.right / 2) - 101;
|
||||||
fWindowFrame.top = (Screen.Frame().right / 2) - 101;
|
|
||||||
fWindowFrame.right = fWindowFrame.left + 356;
|
fWindowFrame.right = fWindowFrame.left + 356;
|
||||||
fWindowFrame.bottom = fWindowFrame.top + 202;
|
fWindowFrame.bottom = fWindowFrame.top + 202;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScreenSettings::~ScreenSettings()
|
ScreenSettings::~ScreenSettings()
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) < B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path.Append(fScreenSettingsFile);
|
path.Append(fScreenSettingsFile);
|
||||||
@@ -43,7 +49,9 @@ ScreenSettings::~ScreenSettings()
|
|||||||
file.Write(&fWindowFrame, sizeof(BRect));
|
file.Write(&fWindowFrame, sizeof(BRect));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettings::SetWindowFrame(BRect frame)
|
|
||||||
|
void
|
||||||
|
ScreenSettings::SetWindowFrame(BRect frame)
|
||||||
{
|
{
|
||||||
fWindowFrame = frame;
|
fWindowFrame = frame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "ScreenView.h"
|
#include "ScreenView.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
ScreenView::ScreenView(BRect rect, char *name)
|
ScreenView::ScreenView(BRect rect, char *name)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenView::AttachedToWindow()
|
|
||||||
|
void
|
||||||
|
ScreenView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
rgb_color greyColor = {216, 216, 216, 255};
|
|
||||||
SetViewColor(greyColor);
|
SetViewColor(greyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenView::Draw(BRect updateRect)
|
|
||||||
|
void
|
||||||
|
ScreenView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
rgb_color whiteColor = {255, 255, 255, 255};
|
|
||||||
rgb_color darkColor = {128, 128, 128, 255};
|
rgb_color darkColor = {128, 128, 128, 255};
|
||||||
rgb_color blackColor = {0, 0, 0, 255};
|
|
||||||
|
|
||||||
SetHighColor(whiteColor);
|
SetHighColor(whiteColor);
|
||||||
|
|
||||||
|
|||||||
+129
-715
File diff suppressed because it is too large
Load Diff
@@ -16,13 +16,13 @@ class ScreenWindow : public BWindow
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenWindow(ScreenSettings *Settings);
|
ScreenWindow(ScreenSettings *Settings);
|
||||||
virtual ~ScreenWindow();
|
virtual ~ScreenWindow();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void WorkspaceActivated(int32 ws, bool state);
|
virtual void WorkspaceActivated(int32 ws, bool state);
|
||||||
virtual void FrameMoved(BPoint position);
|
virtual void FrameMoved(BPoint position);
|
||||||
virtual void ScreenChanged(BRect frame, color_space mode);
|
virtual void ScreenChanged(BRect frame, color_space mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CheckApplyEnabled();
|
void CheckApplyEnabled();
|
||||||
@@ -51,6 +51,8 @@ private:
|
|||||||
BMenuItem *fInitialColors;
|
BMenuItem *fInitialColors;
|
||||||
BMenuItem *fInitialRefresh;
|
BMenuItem *fInitialRefresh;
|
||||||
display_mode fInitialMode;
|
display_mode fInitialMode;
|
||||||
|
display_mode *fSupportedModes;
|
||||||
|
uint32 fTotalModes;
|
||||||
float fCustomRefresh;
|
float fCustomRefresh;
|
||||||
float fInitialRefreshN;
|
float fInitialRefreshN;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user