Maximum refresh selectable at compile time, some minor fixes, some cleanups
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,28 +2,29 @@
|
|||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
//Messages
|
//Messages
|
||||||
#define WORKSPACE_CHECK_MSG 'wchk'
|
static const int32 WORKSPACE_CHECK_MSG = 'wchk';
|
||||||
#define BUTTON_DEFAULTS_MSG 'bdef'
|
static const int32 BUTTON_DEFAULTS_MSG = 'bdef';
|
||||||
#define BUTTON_REVERT_MSG 'brev'
|
static const int32 BUTTON_REVERT_MSG = 'brev';
|
||||||
#define BUTTON_APPLY_MSG 'bapl'
|
static const int32 BUTTON_APPLY_MSG = 'bapl';
|
||||||
#define BUTTON_DONE_MSG 'bdon'
|
static const int32 BUTTON_DONE_MSG = 'bdon';
|
||||||
#define BUTTON_CANCEL_MSG 'bcnc'
|
static const int32 BUTTON_CANCEL_MSG = 'bcnc';
|
||||||
#define BUTTON_KEEP_MSG 'bkep'
|
static const int32 BUTTON_KEEP_MSG = 'bkep';
|
||||||
#define POP_WORKSPACE_CHANGED_MSG 'pwsc'
|
static const int32 POP_WORKSPACE_CHANGED_MSG = 'pwsc';
|
||||||
#define POP_RESOLUTION_MSG 'pres'
|
static const int32 POP_RESOLUTION_MSG = 'pres';
|
||||||
#define POP_COLORS_MSG 'pclr'
|
static const int32 POP_COLORS_MSG = 'pclr';
|
||||||
#define POP_REFRESH_MSG 'prfr'
|
static const int32 POP_REFRESH_MSG = 'prfr';
|
||||||
#define POP_OTHER_REFRESH_MSG 'porf'
|
static const int32 POP_OTHER_REFRESH_MSG = 'porf';
|
||||||
#define UPDATE_DESKTOP_COLOR_MSG 'udsc'
|
static const int32 UPDATE_DESKTOP_COLOR_MSG = 'udsc';
|
||||||
#define UPDATE_DESKTOP_MSG 'udsk'
|
static const int32 UPDATE_DESKTOP_MSG = 'udsk';
|
||||||
#define SLIDER_MODIFICATION_MSG 'sldm'
|
static const int32 SLIDER_MODIFICATION_MSG = 'sldm';
|
||||||
#define SLIDER_INVOKE_MSG 'sldi'
|
static const int32 SLIDER_INVOKE_MSG = 'sldi';
|
||||||
#define SET_INITIAL_MODE_MSG 'sinm'
|
static const int32 SET_INITIAL_MODE_MSG = 'sinm';
|
||||||
#define SET_CUSTOM_REFRESH_MSG 'scrf'
|
static const int32 SET_CUSTOM_REFRESH_MSG = 'scrf';
|
||||||
#define DIM_COUNT_MSG 'scrf'
|
static const int32 DIM_COUNT_MSG = 'scrf';
|
||||||
#define MAKE_INITIAL_MSG 'mkin'
|
static const int32 MAKE_INITIAL_MSG = 'mkin';
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
static const char kAppSignature[] = "application/x-vnd.RR-SCRN";
|
static const char kAppSignature[] = "application/x-vnd.Be-SCRN";
|
||||||
|
static const int32 gMaxRefresh = 120; //This is the maximum selectable refresh
|
||||||
|
|
||||||
#endif //CONSTANTS_H
|
#endif //CONSTANTS_H
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Slider.h>
|
#include <Slider.h>
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "RefreshSlider.h"
|
#include "RefreshSlider.h"
|
||||||
#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, 900),
|
: BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, gMaxRefresh * 10),
|
||||||
fStatus(new char[64])
|
fStatus(new char[32])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,18 +77,7 @@ RefreshSlider::UpdateText() const
|
|||||||
{
|
{
|
||||||
if (fStatus && Window()->Lock())
|
if (fStatus && Window()->Lock())
|
||||||
{
|
{
|
||||||
BString String;
|
sprintf(fStatus, "%.1f Hz", (float)Value() / 10);
|
||||||
|
|
||||||
String << Value();
|
|
||||||
String.CopyInto(fStatus, 0, String.Length() + 1);
|
|
||||||
|
|
||||||
char Last = fStatus[2];
|
|
||||||
|
|
||||||
String.Truncate(2);
|
|
||||||
String << "." << Last << " Hz";
|
|
||||||
|
|
||||||
String.CopyInto(fStatus, 0, String.Length() + 1);
|
|
||||||
|
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
|
|||||||
AddChild(fRefreshView);
|
AddChild(fRefreshView);
|
||||||
|
|
||||||
BRect SliderRect;
|
BRect SliderRect;
|
||||||
|
BString maxRefresh;
|
||||||
|
maxRefresh << gMaxRefresh;
|
||||||
|
|
||||||
SliderRect.Set(10.0, 35.0, 299.0, 60.0);
|
SliderRect.Set(10.0, 35.0, 299.0, 60.0);
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ 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", "90.0");
|
fRefreshSlider->SetLimitLabels("45.0", maxRefresh.String());
|
||||||
fRefreshSlider->SetKeyIncrementValue(1);
|
fRefreshSlider->SetKeyIncrementValue(1);
|
||||||
fRefreshSlider->SetValue(value);
|
fRefreshSlider->SetValue(value);
|
||||||
fRefreshSlider->SetSnoozeAmount(1);
|
fRefreshSlider->SetSnoozeAmount(1);
|
||||||
|
|||||||
@@ -38,34 +38,12 @@ ScreenApplication::MessageReceived(BMessage* message)
|
|||||||
switch(message->what)
|
switch(message->what)
|
||||||
{
|
{
|
||||||
case SET_INITIAL_MODE_MSG:
|
case SET_INITIAL_MODE_MSG:
|
||||||
{
|
|
||||||
fScreenWindow->PostMessage(new BMessage(SET_INITIAL_MODE_MSG));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SET_CUSTOM_REFRESH_MSG:
|
case SET_CUSTOM_REFRESH_MSG:
|
||||||
{
|
|
||||||
BMessage message(SET_CUSTOM_REFRESH_MSG);
|
|
||||||
|
|
||||||
float Value;
|
|
||||||
|
|
||||||
message.FindFloat("refresh", &Value);
|
|
||||||
|
|
||||||
message.AddFloat("refresh", Value);
|
|
||||||
|
|
||||||
fScreenWindow->PostMessage(&message);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MAKE_INITIAL_MSG:
|
case MAKE_INITIAL_MSG:
|
||||||
{
|
{
|
||||||
fScreenWindow->PostMessage(new BMessage(MAKE_INITIAL_MSG));
|
fScreenWindow->PostMessage(message);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(message);
|
BApplication::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -405,7 +405,8 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
String << Other->Label();
|
String << Other->Label();
|
||||||
|
|
||||||
String.Truncate(7);
|
int32 point = String.FindFirst('z');
|
||||||
|
String.Truncate(point + 1);
|
||||||
|
|
||||||
fRefreshMenu->Superitem()->SetLabel(String.String());
|
fRefreshMenu->Superitem()->SetLabel(String.String());
|
||||||
|
|
||||||
@@ -435,17 +436,18 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
if (fInitialRefresh == Other)
|
if (fInitialRefresh == Other)
|
||||||
{
|
{
|
||||||
BString string;
|
BString string;
|
||||||
|
|
||||||
string << fInitialRefreshN;
|
string << fInitialRefreshN;
|
||||||
|
|
||||||
string.Truncate(4);
|
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());
|
||||||
|
|
||||||
string.Truncate(7);
|
point = string.FindFirst('/');
|
||||||
|
string.Truncate(point);
|
||||||
|
|
||||||
fRefreshMenu->Superitem()->SetLabel(string.String());
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
||||||
}
|
}
|
||||||
@@ -469,10 +471,15 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
BString menuLabel = fResolutionMenu->FindMarked()->Label();
|
BString menuLabel = fResolutionMenu->FindMarked()->Label();
|
||||||
int32 space = menuLabel.FindFirst(' ');
|
int32 space = menuLabel.FindFirst(' ');
|
||||||
menuLabel.MoveInto(string, 0, space);
|
menuLabel.MoveInto(string, 0, space);
|
||||||
menuLabel.Remove(0, 3);
|
menuLabel.Remove(0, 3);
|
||||||
|
|
||||||
width = atoi(string.String());
|
width = atoi(string.String());
|
||||||
height = atoi(menuLabel.String());
|
height = atoi(menuLabel.String());
|
||||||
refresh = atof(fRefreshMenu->FindMarked()->Label());
|
|
||||||
|
if (fRefreshMenu->FindMarked() == fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG))
|
||||||
|
refresh = fCustomRefresh;
|
||||||
|
else
|
||||||
|
refresh = atof(fRefreshMenu->FindMarked()->Label());
|
||||||
|
|
||||||
for(uint32 c = 0; c < fTotalModes; c++)
|
for(uint32 c = 0; c < fTotalModes; c++)
|
||||||
{
|
{
|
||||||
@@ -482,12 +489,8 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
mode = &fSupportedModes[c];
|
mode = &fSupportedModes[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fRefreshMenu->FindMarked() == fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG))
|
mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) * refresh / 1000);
|
||||||
mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) * fCustomRefresh / 1000);
|
|
||||||
else
|
|
||||||
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"))
|
||||||
{
|
{
|
||||||
@@ -510,12 +513,11 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
mode->v_display_start = 0;
|
mode->v_display_start = 0;
|
||||||
|
|
||||||
if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces"))
|
if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces"))
|
||||||
{
|
{
|
||||||
int32 button;
|
|
||||||
|
|
||||||
BAlert *WorkspacesAlert = new BAlert("WorkspacesAlert", "Change all workspaces?
|
BAlert *WorkspacesAlert = new BAlert("WorkspacesAlert", "Change all workspaces?
|
||||||
This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
button = WorkspacesAlert->Go();
|
|
||||||
|
int32 button = WorkspacesAlert->Go();
|
||||||
|
|
||||||
if (button == 1)
|
if (button == 1)
|
||||||
break;
|
break;
|
||||||
@@ -556,17 +558,17 @@ This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WAR
|
|||||||
{
|
{
|
||||||
Other->SetMarked(true);
|
Other->SetMarked(true);
|
||||||
|
|
||||||
BString String;
|
BString String;
|
||||||
|
|
||||||
String << fInitialRefreshN;
|
String << fInitialRefreshN;
|
||||||
|
int32 point = String.FindFirst('.');
|
||||||
String.Truncate(4);
|
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());
|
||||||
|
|
||||||
String.Truncate(7);
|
point = String.FindFirst('/');
|
||||||
|
String.Truncate(point);
|
||||||
|
|
||||||
fRefreshMenu->Superitem()->SetLabel(String.String());
|
fRefreshMenu->Superitem()->SetLabel(String.String());
|
||||||
}
|
}
|
||||||
@@ -584,17 +586,17 @@ This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WAR
|
|||||||
|
|
||||||
Other->SetMarked(true);
|
Other->SetMarked(true);
|
||||||
|
|
||||||
BString String;
|
BString String;
|
||||||
|
|
||||||
String << fCustomRefresh;
|
String << fCustomRefresh;
|
||||||
|
int32 point = String.FindFirst('.');
|
||||||
String.Truncate(4);
|
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());
|
||||||
|
|
||||||
String.Truncate(7);
|
point = String.FindFirst('z');
|
||||||
|
String.Truncate(point + 1);
|
||||||
|
|
||||||
fRefreshMenu->Superitem()->SetLabel(String.String());
|
fRefreshMenu->Superitem()->SetLabel(String.String());
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,12 @@ rgb_color whiteColor = { 255, 255, 255, 255 };
|
|||||||
rgb_color redColor = { 228, 0, 0, 255 };
|
rgb_color redColor = { 228, 0, 0, 255 };
|
||||||
|
|
||||||
float round(float n, int32 max)
|
float round(float n, int32 max)
|
||||||
{
|
{
|
||||||
float result;
|
max = (int32)pow(10, (float)max);
|
||||||
int32 tmp;
|
|
||||||
max *= 10;
|
|
||||||
|
|
||||||
n *= max;
|
n *= max;
|
||||||
n += 0.5;
|
n += 0.5;
|
||||||
|
|
||||||
tmp = (int32)floor(n);
|
int32 tmp = (int32)floor(n);
|
||||||
result = (float)tmp / (max);
|
return (float)tmp / (max);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user