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:
parent
e1403feb25
commit
e14977562f
@ -2,28 +2,29 @@
|
||||
#define CONSTANTS_H
|
||||
|
||||
//Messages
|
||||
#define WORKSPACE_CHECK_MSG 'wchk'
|
||||
#define BUTTON_DEFAULTS_MSG 'bdef'
|
||||
#define BUTTON_REVERT_MSG 'brev'
|
||||
#define BUTTON_APPLY_MSG 'bapl'
|
||||
#define BUTTON_DONE_MSG 'bdon'
|
||||
#define BUTTON_CANCEL_MSG 'bcnc'
|
||||
#define BUTTON_KEEP_MSG 'bkep'
|
||||
#define POP_WORKSPACE_CHANGED_MSG 'pwsc'
|
||||
#define POP_RESOLUTION_MSG 'pres'
|
||||
#define POP_COLORS_MSG 'pclr'
|
||||
#define POP_REFRESH_MSG 'prfr'
|
||||
#define POP_OTHER_REFRESH_MSG 'porf'
|
||||
#define UPDATE_DESKTOP_COLOR_MSG 'udsc'
|
||||
#define UPDATE_DESKTOP_MSG 'udsk'
|
||||
#define SLIDER_MODIFICATION_MSG 'sldm'
|
||||
#define SLIDER_INVOKE_MSG 'sldi'
|
||||
#define SET_INITIAL_MODE_MSG 'sinm'
|
||||
#define SET_CUSTOM_REFRESH_MSG 'scrf'
|
||||
#define DIM_COUNT_MSG 'scrf'
|
||||
#define MAKE_INITIAL_MSG 'mkin'
|
||||
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';
|
||||
|
||||
//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
|
||||
|
@ -2,17 +2,17 @@
|
||||
#include <Window.h>
|
||||
#include <Locker.h>
|
||||
#include <Slider.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include "RefreshSlider.h"
|
||||
#include "Constants.h"
|
||||
|
||||
RefreshSlider::RefreshSlider(BRect frame)
|
||||
: BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, 900),
|
||||
fStatus(new char[64])
|
||||
: BSlider(frame, "Screen", "Refresh Rate:", new BMessage(SLIDER_INVOKE_MSG), 450, gMaxRefresh * 10),
|
||||
fStatus(new char[32])
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,18 +77,7 @@ RefreshSlider::UpdateText() const
|
||||
{
|
||||
if (fStatus && Window()->Lock())
|
||||
{
|
||||
BString String;
|
||||
|
||||
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);
|
||||
|
||||
sprintf(fStatus, "%.1f Hz", (float)Value() / 10);
|
||||
return fStatus;
|
||||
}
|
||||
else
|
||||
|
@ -7,14 +7,14 @@ class RefreshSlider : public BSlider
|
||||
{
|
||||
|
||||
public:
|
||||
RefreshSlider(BRect frame);
|
||||
~RefreshSlider();
|
||||
RefreshSlider(BRect frame);
|
||||
~RefreshSlider();
|
||||
virtual void DrawFocusMark();
|
||||
virtual char* UpdateText() const;
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
|
||||
private:
|
||||
char* fStatus;
|
||||
char* fStatus;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,8 @@ RefreshWindow::RefreshWindow(BRect frame, int32 value)
|
||||
AddChild(fRefreshView);
|
||||
|
||||
BRect SliderRect;
|
||||
BString maxRefresh;
|
||||
maxRefresh << gMaxRefresh;
|
||||
|
||||
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->SetHashMarkCount(10);
|
||||
fRefreshSlider->SetLimitLabels("45.0", "90.0");
|
||||
fRefreshSlider->SetLimitLabels("45.0", maxRefresh.String());
|
||||
fRefreshSlider->SetKeyIncrementValue(1);
|
||||
fRefreshSlider->SetValue(value);
|
||||
fRefreshSlider->SetSnoozeAmount(1);
|
||||
|
@ -38,34 +38,12 @@ ScreenApplication::MessageReceived(BMessage* message)
|
||||
switch(message->what)
|
||||
{
|
||||
case SET_INITIAL_MODE_MSG:
|
||||
{
|
||||
fScreenWindow->PostMessage(new BMessage(SET_INITIAL_MODE_MSG));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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:
|
||||
{
|
||||
fScreenWindow->PostMessage(new BMessage(MAKE_INITIAL_MSG));
|
||||
|
||||
fScreenWindow->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
|
@ -405,7 +405,8 @@ ScreenWindow::MessageReceived(BMessage* message)
|
||||
|
||||
String << Other->Label();
|
||||
|
||||
String.Truncate(7);
|
||||
int32 point = String.FindFirst('z');
|
||||
String.Truncate(point + 1);
|
||||
|
||||
fRefreshMenu->Superitem()->SetLabel(String.String());
|
||||
|
||||
@ -435,17 +436,18 @@ ScreenWindow::MessageReceived(BMessage* message)
|
||||
|
||||
if (fInitialRefresh == Other)
|
||||
{
|
||||
BString string;
|
||||
|
||||
BString string;
|
||||
string << fInitialRefreshN;
|
||||
|
||||
string.Truncate(4);
|
||||
|
||||
int32 point = string.FindFirst('.');
|
||||
string.Truncate(point + 2);
|
||||
|
||||
string << " Hz/Other...";
|
||||
|
||||
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String());
|
||||
|
||||
string.Truncate(7);
|
||||
point = string.FindFirst('/');
|
||||
string.Truncate(point);
|
||||
|
||||
fRefreshMenu->Superitem()->SetLabel(string.String());
|
||||
}
|
||||
@ -469,10 +471,15 @@ ScreenWindow::MessageReceived(BMessage* message)
|
||||
BString menuLabel = fResolutionMenu->FindMarked()->Label();
|
||||
int32 space = menuLabel.FindFirst(' ');
|
||||
menuLabel.MoveInto(string, 0, space);
|
||||
menuLabel.Remove(0, 3);
|
||||
menuLabel.Remove(0, 3);
|
||||
|
||||
width = atoi(string.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++)
|
||||
{
|
||||
@ -482,12 +489,8 @@ ScreenWindow::MessageReceived(BMessage* message)
|
||||
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) * fCustomRefresh / 1000);
|
||||
else
|
||||
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) * refresh / 1000);
|
||||
|
||||
|
||||
if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel"))
|
||||
{
|
||||
@ -510,12 +513,11 @@ ScreenWindow::MessageReceived(BMessage* message)
|
||||
mode->v_display_start = 0;
|
||||
|
||||
if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces"))
|
||||
{
|
||||
int32 button;
|
||||
|
||||
{
|
||||
BAlert *WorkspacesAlert = new BAlert("WorkspacesAlert", "Change all workspaces?
|
||||
This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
button = WorkspacesAlert->Go();
|
||||
This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
|
||||
int32 button = WorkspacesAlert->Go();
|
||||
|
||||
if (button == 1)
|
||||
break;
|
||||
@ -556,17 +558,17 @@ This action cannot be reverted", "Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WAR
|
||||
{
|
||||
Other->SetMarked(true);
|
||||
|
||||
BString String;
|
||||
|
||||
BString String;
|
||||
String << fInitialRefreshN;
|
||||
|
||||
String.Truncate(4);
|
||||
int32 point = String.FindFirst('.');
|
||||
String.Truncate(point + 2);
|
||||
|
||||
String << " Hz/Other...";
|
||||
|
||||
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(String.String());
|
||||
|
||||
String.Truncate(7);
|
||||
point = String.FindFirst('/');
|
||||
String.Truncate(point);
|
||||
|
||||
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);
|
||||
|
||||
BString String;
|
||||
|
||||
BString String;
|
||||
String << fCustomRefresh;
|
||||
|
||||
String.Truncate(4);
|
||||
int32 point = String.FindFirst('.');
|
||||
String.Truncate(point + 2);
|
||||
|
||||
String << " Hz/Other...";
|
||||
|
||||
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());
|
||||
|
||||
|
@ -8,16 +8,12 @@ rgb_color whiteColor = { 255, 255, 255, 255 };
|
||||
rgb_color redColor = { 228, 0, 0, 255 };
|
||||
|
||||
float round(float n, int32 max)
|
||||
{
|
||||
float result;
|
||||
int32 tmp;
|
||||
max *= 10;
|
||||
{
|
||||
max = (int32)pow(10, (float)max);
|
||||
|
||||
n *= max;
|
||||
n += 0.5;
|
||||
|
||||
tmp = (int32)floor(n);
|
||||
result = (float)tmp / (max);
|
||||
|
||||
return result;
|
||||
int32 tmp = (int32)floor(n);
|
||||
return (float)tmp / (max);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user