* Made the refresh selection window font sensitive.
* Nicer separation from RefreshSlider. * Got rid of the RefreshView class (a BStringView does its job now). * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17147 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
#ifndef CONSTANTS_H
|
#ifndef CONSTANTS_H
|
||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
// Messages
|
// Messages
|
||||||
static const uint32 WORKSPACE_CHECK_MSG = 'wchk';
|
static const uint32 WORKSPACE_CHECK_MSG = 'wchk';
|
||||||
static const uint32 BUTTON_LAUNCH_BACKGROUNDS_MSG = 'blbk';
|
static const uint32 BUTTON_LAUNCH_BACKGROUNDS_MSG = 'blbk';
|
||||||
@@ -16,7 +20,6 @@ static const uint32 BUTTON_DEFAULTS_MSG = 'bdef';
|
|||||||
static const uint32 BUTTON_REVERT_MSG = 'brev';
|
static const uint32 BUTTON_REVERT_MSG = 'brev';
|
||||||
static const uint32 BUTTON_APPLY_MSG = 'bapl';
|
static const uint32 BUTTON_APPLY_MSG = 'bapl';
|
||||||
static const uint32 BUTTON_DONE_MSG = 'bdon';
|
static const uint32 BUTTON_DONE_MSG = 'bdon';
|
||||||
static const uint32 BUTTON_CANCEL_MSG = 'bcnc';
|
|
||||||
static const uint32 BUTTON_KEEP_MSG = 'bkep';
|
static const uint32 BUTTON_KEEP_MSG = 'bkep';
|
||||||
static const uint32 POP_WORKSPACE_CHANGED_MSG = 'pwsc';
|
static const uint32 POP_WORKSPACE_CHANGED_MSG = 'pwsc';
|
||||||
static const uint32 POP_RESOLUTION_MSG = 'pres';
|
static const uint32 POP_RESOLUTION_MSG = 'pres';
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ Preference Screen :
|
|||||||
MonitorView.cpp
|
MonitorView.cpp
|
||||||
multimon.cpp
|
multimon.cpp
|
||||||
RefreshSlider.cpp
|
RefreshSlider.cpp
|
||||||
RefreshView.cpp
|
|
||||||
RefreshWindow.cpp
|
RefreshWindow.cpp
|
||||||
ScreenApplication.cpp
|
ScreenApplication.cpp
|
||||||
ScreenMode.cpp
|
ScreenMode.cpp
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2006, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rafael Romo
|
||||||
|
* Stefano Ceccherini ([email protected])
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "RefreshSlider.h"
|
#include "RefreshSlider.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
RefreshSlider::RefreshSlider(BRect frame)
|
RefreshSlider::RefreshSlider(BRect frame, float min, float max, uint32 resizingMode)
|
||||||
:BSlider(frame, "Screen", "Refresh Rate:",
|
: BSlider(frame, "Screen", "Refresh Rate:",
|
||||||
new BMessage(SLIDER_INVOKE_MSG), gMinRefresh * 10, gMaxRefresh * 10),
|
new BMessage(SLIDER_INVOKE_MSG), rintf(min * 10), rintf(max * 10),
|
||||||
fStatus(new char[32])
|
B_BLOCK_THUMB, resizingMode),
|
||||||
{
|
fStatus(new (std::nothrow) char[32])
|
||||||
|
{
|
||||||
|
BString minRefresh;
|
||||||
|
minRefresh << (uint32)min;
|
||||||
|
BString maxRefresh;
|
||||||
|
maxRefresh << (uint32)max;
|
||||||
|
SetLimitLabels(minRefresh.String(), maxRefresh.String());
|
||||||
|
|
||||||
|
SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
|
SetHashMarkCount(uint32(max - min) / 5 + 1);
|
||||||
|
|
||||||
|
SetKeyIncrementValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,10 +90,8 @@ RefreshSlider::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
char*
|
char*
|
||||||
RefreshSlider::UpdateText() const
|
RefreshSlider::UpdateText() const
|
||||||
{
|
{
|
||||||
if (fStatus) {
|
if (fStatus != NULL)
|
||||||
sprintf(fStatus, "%.1f Hz", (float)Value() / 10);
|
snprintf(fStatus, 32, "%.1f Hz", (float)Value() / 10);
|
||||||
return fStatus;
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return fStatus;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,30 @@
|
|||||||
#ifndef __REFRESHSLIDER_H
|
/*
|
||||||
#define __REFRESHSLIDER_H
|
* Copyright 2001-2006, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rafael Romo
|
||||||
|
* Stefano Ceccherini ([email protected])
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef REFRESH_SLIDER_H
|
||||||
|
#define REFRESH_SLIDER_H
|
||||||
|
|
||||||
|
|
||||||
#include <Slider.h>
|
#include <Slider.h>
|
||||||
|
|
||||||
class RefreshSlider : public BSlider
|
|
||||||
{
|
class RefreshSlider : public BSlider {
|
||||||
public:
|
public:
|
||||||
RefreshSlider(BRect frame);
|
RefreshSlider(BRect frame, float min, float max, uint32 resizingMode);
|
||||||
~RefreshSlider();
|
virtual ~RefreshSlider();
|
||||||
virtual void DrawFocusMark();
|
|
||||||
virtual char *UpdateText() const;
|
virtual void DrawFocusMark();
|
||||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
virtual char* UpdateText() const;
|
||||||
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
private:
|
|
||||||
char* fStatus;
|
private:
|
||||||
|
char* fStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // REFRESH_SLIDER_H
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
#include "RefreshView.h"
|
|
||||||
|
|
||||||
RefreshView::RefreshView(BRect rect, char *name)
|
|
||||||
: BBox(rect, name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RefreshView::Draw(BRect updateRect)
|
|
||||||
{
|
|
||||||
rgb_color black = { 0, 0, 0, 255 };
|
|
||||||
|
|
||||||
BBox::Draw(updateRect);
|
|
||||||
|
|
||||||
SetHighColor(black);
|
|
||||||
SetLowColor(ViewColor());
|
|
||||||
|
|
||||||
DrawString("Type or use the left and right arrow keys.", BPoint(10.0, 23.0));
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#ifndef __REFRESHVIEW_H
|
|
||||||
#define __REFRESHVIEW_H
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
|
|
||||||
class RefreshView : public BBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RefreshView(BRect frame, char *name);
|
|
||||||
virtual void Draw(BRect updateRect);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -10,68 +10,66 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "RefreshWindow.h"
|
#include "RefreshWindow.h"
|
||||||
#include "RefreshView.h"
|
|
||||||
#include "RefreshSlider.h"
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
#include "RefreshSlider.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
RefreshWindow::RefreshWindow(BRect frame, float current, float min, float max)
|
RefreshWindow::RefreshWindow(BPoint position, float current, float min, float max)
|
||||||
: BWindow(frame, "Refresh Rate", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE,
|
: BWindow(BRect(0, 0, 300, 200), "Refresh Rate", B_MODAL_WINDOW,
|
||||||
B_ALL_WORKSPACES)
|
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS, B_ALL_WORKSPACES)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
|
||||||
bounds.InsetBy(-1, -1);
|
|
||||||
|
|
||||||
fRefreshView = new RefreshView(bounds, "RefreshView");
|
|
||||||
AddChild(fRefreshView);
|
|
||||||
|
|
||||||
min = ceilf(min);
|
min = ceilf(min);
|
||||||
max = floorf(max);
|
max = floorf(max);
|
||||||
|
|
||||||
BRect sliderRect;
|
BView* topView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
BString maxRefresh;
|
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
maxRefresh << (uint32)min;
|
AddChild(topView);
|
||||||
BString minRefresh;
|
|
||||||
minRefresh << (uint32)max;
|
|
||||||
|
|
||||||
sliderRect.Set(10.0, 35.0, 299.0, 60.0);
|
BRect rect = Bounds().InsetByCopy(8, 8);
|
||||||
|
BStringView* stringView = new BStringView(rect, "info",
|
||||||
|
"Type or use the left and right arrow keys.");
|
||||||
|
stringView->ResizeToPreferred();
|
||||||
|
topView->AddChild(stringView);
|
||||||
|
|
||||||
fRefreshSlider = new RefreshSlider(sliderRect);
|
rect.top += stringView->Bounds().Height() + 14;
|
||||||
|
fRefreshSlider = new RefreshSlider(rect, min, max, B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
|
||||||
fRefreshSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
|
||||||
fRefreshSlider->SetHashMarkCount(uint32(max - min) / 5 + 1);
|
|
||||||
fRefreshSlider->SetLimitLabels(minRefresh.String(), maxRefresh.String());
|
|
||||||
fRefreshSlider->SetKeyIncrementValue(1);
|
|
||||||
fRefreshSlider->SetValue(rint(current * 10));
|
fRefreshSlider->SetValue(rint(current * 10));
|
||||||
fRefreshSlider->SetSnoozeAmount(1);
|
|
||||||
fRefreshSlider->SetModificationMessage(new BMessage(SLIDER_MODIFICATION_MSG));
|
fRefreshSlider->SetModificationMessage(new BMessage(SLIDER_MODIFICATION_MSG));
|
||||||
|
float width, height;
|
||||||
|
fRefreshSlider->GetPreferredSize(&width, &height);
|
||||||
|
fRefreshSlider->ResizeTo(rect.Width(), height);
|
||||||
|
topView->AddChild(fRefreshSlider);
|
||||||
|
|
||||||
fRefreshView->AddChild(fRefreshSlider);
|
BButton* doneButton = new BButton(rect, "DoneButton", "Done",
|
||||||
|
new BMessage(BUTTON_DONE_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
doneButton->ResizeToPreferred();
|
||||||
|
doneButton->MoveTo(Bounds().Width() - doneButton->Bounds().Width() - 8,
|
||||||
|
Bounds().Height() - doneButton->Bounds().Height() - 8);
|
||||||
|
topView->AddChild(doneButton);
|
||||||
|
|
||||||
BRect ButtonRect(219.0, 97.0, 230.0, 120.0);
|
BButton* button = new BButton(doneButton->Frame(), "CancelButton", "Cancel",
|
||||||
|
new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
|
button->ResizeToPreferred();
|
||||||
|
button->MoveBy(-button->Bounds().Width() - 10, 0);
|
||||||
|
topView->AddChild(button);
|
||||||
|
|
||||||
fDoneButton = new BButton(ButtonRect, "DoneButton", "Done",
|
doneButton->MakeDefault(true);
|
||||||
new BMessage(BUTTON_DONE_MSG));
|
|
||||||
|
|
||||||
fDoneButton->ResizeToPreferred();
|
width = stringView->Bounds().Width() + 100;
|
||||||
fDoneButton->MakeDefault(true);
|
if (width < Bounds().Width())
|
||||||
|
width = Bounds().Width();
|
||||||
fRefreshView->AddChild(fDoneButton);
|
height = fRefreshSlider->Frame().bottom + button->Bounds().Height() + 20.0f;
|
||||||
|
|
||||||
ButtonRect.Set(130.0, 97.0, 200.0, 120.0);
|
ResizeTo(width, height);
|
||||||
|
MoveTo(position.x - width / 2.5f, position.y - height / 1.9f);
|
||||||
fCancelButton = new BButton(ButtonRect, "CancelButton", "Cancel",
|
|
||||||
new BMessage(BUTTON_CANCEL_MSG));
|
|
||||||
|
|
||||||
fCancelButton->ResizeToPreferred();
|
|
||||||
|
|
||||||
fRefreshView->AddChild(fCancelButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,36 +83,23 @@ RefreshWindow::WindowActivated(bool active)
|
|||||||
void
|
void
|
||||||
RefreshWindow::MessageReceived(BMessage* message)
|
RefreshWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch (message->what) {
|
||||||
{
|
|
||||||
case BUTTON_DONE_MSG:
|
case BUTTON_DONE_MSG:
|
||||||
{
|
{
|
||||||
BMessage message(SET_CUSTOM_REFRESH_MSG);
|
|
||||||
|
|
||||||
float value = (float)fRefreshSlider->Value() / 10;
|
float value = (float)fRefreshSlider->Value() / 10;
|
||||||
|
|
||||||
|
BMessage message(SET_CUSTOM_REFRESH_MSG);
|
||||||
message.AddFloat("refresh", value);
|
message.AddFloat("refresh", value);
|
||||||
be_app->PostMessage(&message);
|
be_app->PostMessage(&message);
|
||||||
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BUTTON_CANCEL_MSG:
|
|
||||||
{
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case SLIDER_INVOKE_MSG:
|
case SLIDER_INVOKE_MSG:
|
||||||
{
|
|
||||||
fRefreshSlider->MakeFocus(true);
|
fRefreshSlider->MakeFocus(true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -13,21 +13,18 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "RefreshView.h"
|
class BSlider;
|
||||||
#include "RefreshSlider.h"
|
|
||||||
|
|
||||||
class RefreshWindow : public BWindow {
|
class RefreshWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
RefreshWindow(BRect frame, float current, float min, float max);
|
RefreshWindow(BPoint position, float current, float min, float max);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefreshView *fRefreshView;
|
BSlider* fRefreshSlider;
|
||||||
RefreshSlider *fRefreshSlider;
|
|
||||||
BButton *fDoneButton;
|
|
||||||
BButton *fCancelButton;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REFRESH_WINDOW_H
|
#endif // REFRESH_WINDOW_H
|
||||||
|
|||||||
@@ -820,10 +820,8 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
if (max > gMaxRefresh)
|
if (max > gMaxRefresh)
|
||||||
max = gMaxRefresh;
|
max = gMaxRefresh;
|
||||||
|
|
||||||
BRect frame(Frame());
|
RefreshWindow *fRefreshWindow = new RefreshWindow(
|
||||||
RefreshWindow *fRefreshWindow = new RefreshWindow(BRect(frame.left + 201.0,
|
fRefreshField->ConvertToScreen(B_ORIGIN), fSelected.refresh, min, max);
|
||||||
frame.top + 34.0, frame.left + 509.0, frame.top + 169.0),
|
|
||||||
fSelected.refresh, min, max);
|
|
||||||
fRefreshWindow->Show();
|
fRefreshWindow->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user