Reported some changes I did a while ago and forgot to commit.
There were more but that will come later (Thomas' RadeonScreen changes). Vastly improved AlertView/AlertWindow to a cleaner design, the question mark bitmap is no longer hardcoded, but retrieved in the same way BAlert does it. Added license headers to the files updated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13195 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,27 +1,61 @@
|
||||
#include <Bitmap.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "AlertView.h"
|
||||
#include "Bitmaps.h"
|
||||
#include "Constants.h"
|
||||
|
||||
#include <Window.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Button.h>
|
||||
#include <StringView.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <Resources.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
AlertView::AlertView(BRect frame, char *name)
|
||||
:BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
// we will wait 8 seconds until we send a message
|
||||
fSeconds(8)
|
||||
{
|
||||
count = 8;
|
||||
|
||||
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT);
|
||||
fBitmap->SetBits(bitmapBits, 32 * 32, 0, B_COLOR_8_BIT);
|
||||
fBitmap = InitIcon();
|
||||
|
||||
BStringView *stringView = new BStringView(BRect(60, 20, 400, 36), NULL,
|
||||
"Do you wish to keep these settings?");
|
||||
stringView->SetFont(be_bold_font);
|
||||
stringView->ResizeToPreferred();
|
||||
AddChild(stringView);
|
||||
|
||||
fCountdownView = new BStringView(BRect(60, 37, 400, 50), "countdown", B_EMPTY_STRING);
|
||||
UpdateCountdownView();
|
||||
fCountdownView->ResizeToPreferred();
|
||||
AddChild(fCountdownView);
|
||||
|
||||
BButton *button = new BButton(BRect(215, 59, 400, 190), "KeepButton", "Keep", new BMessage(BUTTON_KEEP_MSG));
|
||||
button->ResizeToPreferred();
|
||||
AddChild(button);
|
||||
|
||||
button = new BButton(BRect(130, 59, 400, 199), "RevertButton", "Revert", new BMessage(BUTTON_REVERT_MSG));
|
||||
button->ResizeToPreferred();
|
||||
AddChild(button);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlertView::AttachedToWindow()
|
||||
{
|
||||
rgb_color grey = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
|
||||
SetViewColor(grey);
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,22 +63,59 @@ void
|
||||
AlertView::Draw(BRect updateRect)
|
||||
{
|
||||
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));
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
DrawBitmap(fBitmap, BPoint(18.0, 6.0));
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
SetHighColor(black);
|
||||
SetFont(be_bold_font);
|
||||
|
||||
DrawString("Do you wish to keep these settings?", BPoint(60.0, 20.0));
|
||||
|
||||
fString.Truncate(0);
|
||||
fString << "Settings will revert in " << count << " seconds.";
|
||||
|
||||
DrawString(fString.String(), BPoint(60, 37));
|
||||
|
||||
if (fBitmap != NULL) {
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
DrawBitmap(fBitmap, BPoint(18.0, 6.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlertView::Pulse()
|
||||
{
|
||||
if (--fSeconds == 0)
|
||||
Window()->PostMessage(BUTTON_REVERT_MSG);
|
||||
else
|
||||
UpdateCountdownView();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlertView::UpdateCountdownView()
|
||||
{
|
||||
BString string;
|
||||
string << "Settings will revert in " << fSeconds << " seconds.";
|
||||
fCountdownView->SetText(string.String());
|
||||
}
|
||||
|
||||
|
||||
BBitmap*
|
||||
AlertView::InitIcon()
|
||||
{
|
||||
// This is how BAlert gets to its icon
|
||||
BBitmap* icon = NULL;
|
||||
BPath path;
|
||||
if (find_directory(B_BEOS_SERVERS_DIRECTORY, &path) == B_OK) {
|
||||
path.Append("app_server");
|
||||
BResources resources;
|
||||
BFile file;
|
||||
if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK
|
||||
&& resources.SetTo(&file) == B_OK) {
|
||||
// Load the raw icon data
|
||||
size_t size;
|
||||
const void* data = resources.LoadResource('ICON', "warn", &size);
|
||||
if (data) {
|
||||
// Now build the bitmap
|
||||
icon = new BBitmap(BRect(0, 0, 31, 31), 0, B_CMAP8);
|
||||
icon->SetBits(data, size, 0, B_CMAP8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,38 @@
|
||||
#ifndef __ALERTVIEW_H
|
||||
#define __ALERTVIEW_H
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
#ifndef ALERT_VIEW_H
|
||||
#define ALERT_VIEW_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
|
||||
class AlertView : public BView
|
||||
{
|
||||
public:
|
||||
AlertView(BRect frame, char *name);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
uint32 count;
|
||||
|
||||
private:
|
||||
BBitmap *fBitmap;
|
||||
BString fString;
|
||||
class BBitmap;
|
||||
class BStringView;
|
||||
|
||||
|
||||
class AlertView : public BView {
|
||||
public:
|
||||
AlertView(BRect frame, char *name);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void Pulse();
|
||||
|
||||
private:
|
||||
void UpdateCountdownView();
|
||||
BBitmap *InitIcon();
|
||||
|
||||
BStringView *fCountdownView;
|
||||
BBitmap *fBitmap;
|
||||
int32 fSeconds;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* ALERT_VIEW_H */
|
||||
|
||||
@@ -1,93 +1,49 @@
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Window.h>
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
|
||||
#include "AlertWindow.h"
|
||||
#include "AlertView.h"
|
||||
#include "Constants.h"
|
||||
|
||||
AlertWindow::AlertWindow(BRect frame)
|
||||
: BWindow(frame, "Revert", B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
AlertWindow::AlertWindow(BRect frame, BMessenger target)
|
||||
: BWindow(frame, "Revert", B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
|
||||
fTarget(target)
|
||||
{
|
||||
frame = Bounds();
|
||||
|
||||
fAlertView = new AlertView(frame, "ScreenView");
|
||||
|
||||
fAlertView = new AlertView(Bounds(), "AlertView");
|
||||
AddChild(fAlertView);
|
||||
|
||||
BRect buttonRect;
|
||||
buttonRect.Set(215.0, 59.0, 400.0, 190.0);
|
||||
|
||||
fKeepButton = new BButton(buttonRect, "KeepButton", "Keep",
|
||||
new BMessage(BUTTON_KEEP_MSG));
|
||||
|
||||
fKeepButton->AttachedToWindow();
|
||||
fKeepButton->ResizeToPreferred();
|
||||
|
||||
fAlertView->AddChild(fKeepButton);
|
||||
|
||||
buttonRect.Set(130.0, 59.0, 400.0, 190.0);
|
||||
|
||||
fRevertButton = new BButton(buttonRect, "RevertButton", "Revert",
|
||||
new BMessage(BUTTON_REVERT_MSG));
|
||||
|
||||
fRevertButton->AttachedToWindow();
|
||||
fRevertButton->ResizeToPreferred();
|
||||
|
||||
fAlertView->AddChild(fRevertButton);
|
||||
|
||||
fRunner = new BMessageRunner(this, new BMessage(DIM_COUNT_MSG), 1000000, 10);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AlertWindow::QuitRequested()
|
||||
{
|
||||
delete fRunner;
|
||||
|
||||
return BWindow::QuitRequested();
|
||||
// the view displays a decrementing counter (until the user must take action)
|
||||
SetPulseRate(1000000); // every second
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlertWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what)
|
||||
{
|
||||
switch (message->what) {
|
||||
case BUTTON_KEEP_MSG:
|
||||
{
|
||||
be_app->PostMessage(MAKE_INITIAL_MSG);
|
||||
|
||||
fTarget.SendMessage(MAKE_INITIAL_MSG);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BUTTON_REVERT_MSG:
|
||||
{
|
||||
be_app->PostMessage(SET_INITIAL_MODE_MSG);
|
||||
|
||||
fTarget.SendMessage(SET_INITIAL_MODE_MSG);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DIM_COUNT_MSG:
|
||||
{
|
||||
fAlertView->count -= 1;
|
||||
|
||||
fAlertView->Invalidate(BRect(180.0, 20.0, 260.0, 50.0));
|
||||
|
||||
if (fAlertView->count == 0)
|
||||
PostMessage(BUTTON_REVERT_MSG);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
#ifndef __ALERTWINDOW_H
|
||||
#define __ALERTWINDOW_H
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
#ifndef ALERT_WINDOW_H
|
||||
#define ALERT_WINDOW_H
|
||||
|
||||
#include "AlertView.h"
|
||||
|
||||
class AlertWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
AlertWindow(BRect frame);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
#include <Window.h>
|
||||
#include <Messenger.h>
|
||||
|
||||
private:
|
||||
AlertView *fAlertView;
|
||||
BMessageRunner *fRunner;
|
||||
BButton *fRevertButton;
|
||||
BButton *fKeepButton;
|
||||
|
||||
class BMessageRunner;
|
||||
class BButton;
|
||||
class AlertView;
|
||||
|
||||
|
||||
class AlertWindow : public BWindow {
|
||||
public:
|
||||
AlertWindow(BRect frame, BMessenger target);
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
BMessenger fTarget;
|
||||
AlertView* fAlertView;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* ALERT_WINDOW_H */
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
#include <Bitmap.h>
|
||||
|
||||
class Bitmap;
|
||||
|
||||
const unsigned char bitmapBits [] = {
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfa,0xfa,0xfa,0x00,0x00,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0x00,
|
||||
0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
|
||||
0xfa,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
|
||||
0xfa,0xfa,0xfa,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
|
||||
0xfa,0xfa,0x3f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x3f,0x3f,0xfa,0xfa,0xfa,0xfa,0xfa,
|
||||
0xfa,0x3f,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0x3f,0x3f,0xfa,0xfa,0xfa,
|
||||
0x3f,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x3f,0x3f,0x3f,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xa5,0x00,0x00,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xa5,0xa5,0xa5,0xa5,0x00,0x00,0xf9,0xf9,0x5d,
|
||||
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xa5,0xa5,0xa5,0xa5,0x00,0x00,0x00,
|
||||
0xa5,0xa5,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0x00,0x00,0xa5,0xa5,0xa5,0xa5,0xa5,
|
||||
0xa5,0x00,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0x00,0x00,0xa5,0xa5,0xa5,
|
||||
0x00,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x00,0x00,0x00,
|
||||
0x5d,0x5d,0x5d,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x5d,0x00,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x5d,0x00,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xf9,0xf9,0xf9,0x5d,
|
||||
0x5d,0x00,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xf9,0xf9,0x5d,
|
||||
0x00,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
|
||||
0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,15 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
*/
|
||||
#ifndef CONSTANTS_H
|
||||
#define CONSTANTS_H
|
||||
|
||||
//Messages
|
||||
// Messages
|
||||
static const uint32 WORKSPACE_CHECK_MSG = 'wchk';
|
||||
static const uint32 BUTTON_DEFAULTS_MSG = 'bdef';
|
||||
static const uint32 BUTTON_REVERT_MSG = 'brev';
|
||||
@@ -23,9 +31,9 @@ static const uint32 SET_CUSTOM_REFRESH_MSG = 'scrf';
|
||||
static const uint32 DIM_COUNT_MSG = 'scrf';
|
||||
static const uint32 MAKE_INITIAL_MSG = 'mkin';
|
||||
|
||||
//Constants
|
||||
// Constants
|
||||
static const char kAppSignature[] = "application/x-vnd.Be-SCRN";
|
||||
static const int32 gMinRefresh = 45; //This is the minimum selectable refresh
|
||||
static const int32 gMaxRefresh = 140; //This is the maximum selectable refresh
|
||||
static const int32 gMinRefresh = 45; // This is the minimum selectable refresh
|
||||
static const int32 gMaxRefresh = 140; // This is the maximum selectable refresh
|
||||
|
||||
#endif //CONSTANTS_H
|
||||
#endif /* CONSTANTS_H */
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// Original author: Rafael Romo
|
||||
// Additional code by Stefano Ceccherini, Andrew Bachmann, Sergei Panteleev
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Andrew Bachmann
|
||||
* Sergei Panteleev
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Alert.h>
|
||||
@@ -24,7 +33,7 @@ ScreenApplication::ScreenApplication()
|
||||
void
|
||||
ScreenApplication::AboutRequested()
|
||||
{
|
||||
BAlert *aboutAlert = new BAlert("About", "Screen by the OpenBeOS team",
|
||||
BAlert *aboutAlert = new BAlert("About", "Screen preferences by the Haiku team",
|
||||
"Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
|
||||
aboutAlert->SetShortcut(0, B_OK);
|
||||
aboutAlert->Go();
|
||||
@@ -34,15 +43,13 @@ ScreenApplication::AboutRequested()
|
||||
void
|
||||
ScreenApplication::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
switch (message->what) {
|
||||
case SET_INITIAL_MODE_MSG:
|
||||
case SET_CUSTOM_REFRESH_MSG:
|
||||
case MAKE_INITIAL_MSG:
|
||||
{
|
||||
fScreenWindow->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
@@ -50,12 +57,14 @@ ScreenApplication::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
ScreenApplication app;
|
||||
|
||||
app.Run();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
* Andrew Bachmann
|
||||
*/
|
||||
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
@@ -23,16 +34,17 @@
|
||||
#include "ScreenWindow.h"
|
||||
#include "Utility.h"
|
||||
|
||||
|
||||
static uint32
|
||||
colorspace_to_bpp(uint32 colorspace)
|
||||
{
|
||||
switch (colorspace) {
|
||||
case B_RGB32: return 32;
|
||||
case B_RGB24: return 24;
|
||||
case B_RGB16: return 16;
|
||||
case B_RGB15: return 15;
|
||||
case B_CMAP8: return 8;
|
||||
default: return 0;
|
||||
case B_RGB32: return 32;
|
||||
case B_RGB24: return 24;
|
||||
case B_RGB16: return 16;
|
||||
case B_RGB15: return 15;
|
||||
case B_CMAP8: return 8;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +62,12 @@ string_to_colorspace(const char* string)
|
||||
uint32 bits = 0;
|
||||
sscanf(string,"%ld",&bits);
|
||||
switch (bits) {
|
||||
case 8: return B_CMAP8;
|
||||
case 15: return B_RGB15;
|
||||
case 16: return B_RGB16;
|
||||
case 24: return B_RGB24;
|
||||
case 32: return B_RGB32;
|
||||
default: return B_CMAP8; // Should return an error?
|
||||
case 8: return B_CMAP8;
|
||||
case 15: return B_RGB15;
|
||||
case 16: return B_RGB16;
|
||||
case 24: return B_RGB24;
|
||||
case 32: return B_RGB32;
|
||||
default: return B_CMAP8; // Should return an error?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,30 +122,29 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
||||
{
|
||||
BScreen screen(this);
|
||||
BRect frame(Bounds());
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
|
||||
if (!screen.IsValid())
|
||||
;//debugger() ?
|
||||
|
||||
fSupportedModes = NULL;
|
||||
fTotalModes = 0;
|
||||
screen.GetModeList(&fSupportedModes, &fTotalModes);
|
||||
|
||||
frame.InsetBy(-1, -1);
|
||||
fScreenView = new BBox(frame, "ScreenView");
|
||||
fScreenDrawView = new ScreenDrawView(BRect(20.0, 16.0, 122.0, 93.0), "ScreenDrawView");
|
||||
|
||||
AddChild(fScreenView);
|
||||
|
||||
BView *view = new BView(frame, "ScreenView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(view);
|
||||
|
||||
fSettings = Settings;
|
||||
|
||||
|
||||
BRect screenBoxRect(11.0, 18.0, 153.0, 155.0);
|
||||
BBox *screenBox = new BBox(screenBoxRect);
|
||||
screenBox->SetBorder(B_FANCY_BORDER);
|
||||
|
||||
|
||||
fScreenDrawView = new ScreenDrawView(BRect(20.0, 16.0, 122.0, 93.0), "ScreenDrawView");
|
||||
screenBox->AddChild(fScreenDrawView);
|
||||
|
||||
fWorkspaceCountMenu = new BPopUpMenu("", true, true);
|
||||
fWorkspaceCountField = new BMenuField(BRect(7.0, 107.0, 135.0, 127.0), "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true);
|
||||
screenBox->AddChild(fWorkspaceCountField);
|
||||
|
||||
for (int32 count = 1; count <= 32; count++) {
|
||||
BString workspaceCount;
|
||||
@@ -151,9 +162,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
|
||||
fWorkspaceCountField->SetDivider(91.0);
|
||||
|
||||
screenBox->AddChild(fScreenDrawView);
|
||||
screenBox->AddChild(fWorkspaceCountField);
|
||||
fScreenView->AddChild(screenBox);
|
||||
view->AddChild(screenBox);
|
||||
|
||||
fWorkspaceMenu = new BPopUpMenu("Current Workspace", true, true);
|
||||
fAllWorkspacesItem = new BMenuItem("All Workspaces", new BMessage(WORKSPACE_CHECK_MSG));
|
||||
@@ -224,7 +233,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
|
||||
controlsBox->AddChild(fRefreshField);
|
||||
|
||||
fScreenView->AddChild(controlsBox);
|
||||
view->AddChild(controlsBox);
|
||||
|
||||
ButtonRect.Set(10.0, 167, 100.0, 200.0);
|
||||
|
||||
@@ -234,7 +243,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
fDefaultsButton->AttachedToWindow();
|
||||
fDefaultsButton->ResizeToPreferred();
|
||||
|
||||
fScreenView->AddChild(fDefaultsButton);
|
||||
view->AddChild(fDefaultsButton);
|
||||
|
||||
ButtonRect.Set(95.0, 167, 160.0, 200.0);
|
||||
|
||||
@@ -245,13 +254,14 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
fRevertButton->ResizeToPreferred();
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
fScreenView->AddChild(fRevertButton);
|
||||
view->AddChild(fRevertButton);
|
||||
|
||||
SetStateByMode();
|
||||
|
||||
fCustomRefresh = fInitialRefreshN;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenWindow::SetStateByMode()
|
||||
{
|
||||
@@ -259,11 +269,6 @@ ScreenWindow::SetStateByMode()
|
||||
BMenuItem *marked;
|
||||
display_mode mode;
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
|
||||
if (!screen.IsValid()) {
|
||||
//debugger() ?
|
||||
return;
|
||||
}
|
||||
|
||||
screen.GetMode(&mode);
|
||||
fInitialMode = mode;
|
||||
@@ -271,16 +276,16 @@ ScreenWindow::SetStateByMode()
|
||||
char str[256];
|
||||
mode_to_string(mode,str);
|
||||
marked = fResolutionMenu->FindItem(str);
|
||||
if (marked) {
|
||||
if (marked)
|
||||
marked->SetMarked(true);
|
||||
}
|
||||
|
||||
fInitialResolution = marked;
|
||||
|
||||
colorspace_to_string(mode.space,str);
|
||||
marked = fColorsMenu->FindItem(str);
|
||||
if (marked) {
|
||||
if (marked)
|
||||
marked->SetMarked(true);
|
||||
}
|
||||
|
||||
fInitialColors = marked;
|
||||
|
||||
fInitialRefreshN = get_refresh_rate(mode);
|
||||
@@ -650,17 +655,17 @@ ScreenWindow::CheckModesByResolution(const char *res)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenWindow::ApplyMode()
|
||||
{
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
|
||||
if (!screen.IsValid())
|
||||
return;
|
||||
|
||||
|
||||
display_mode requested_mode;
|
||||
screen.GetMode(&requested_mode); // start with current mode timings
|
||||
|
||||
|
||||
BString menuLabel = fResolutionMenu->FindMarked()->Label();
|
||||
string_to_mode(menuLabel.String(),&requested_mode);
|
||||
requested_mode.space = string_to_colorspace(fColorsMenu->FindMarked()->Label());
|
||||
@@ -696,13 +701,13 @@ ScreenWindow::ApplyMode()
|
||||
string << str;
|
||||
mode_to_string(proposed_mode,str);
|
||||
string << " at " << str << " instead?";
|
||||
BAlert * BadColorsAlert =
|
||||
BAlert *badColorsAlert =
|
||||
new BAlert("BadColorsAlert", string.String(),
|
||||
"Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
int32 button = BadColorsAlert->Go();
|
||||
if (button == 1) {
|
||||
int32 button = badColorsAlert->Go();
|
||||
if (button == 1)
|
||||
return;
|
||||
}
|
||||
|
||||
requested_mode = proposed_mode;
|
||||
} else {
|
||||
display_mode proposed_mode = requested_mode;
|
||||
@@ -724,13 +729,13 @@ ScreenWindow::ApplyMode()
|
||||
string << str;
|
||||
mode_to_string(proposed_mode,str);
|
||||
string << " at " << str << " instead?";
|
||||
BAlert * BadModeAlert =
|
||||
BAlert *badModeAlert =
|
||||
new BAlert("BadModeAlert", string.String(),
|
||||
"Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
int32 button = BadModeAlert->Go();
|
||||
if (button == 1) {
|
||||
int32 button = badModeAlert->Go();
|
||||
if (button == 1)
|
||||
return;
|
||||
}
|
||||
|
||||
requested_mode = proposed_mode;
|
||||
}
|
||||
|
||||
@@ -793,8 +798,8 @@ ScreenWindow::ApplyMode()
|
||||
rect.top = (screen.Frame().bottom / 2) - 42;
|
||||
rect.right = rect.left + 300.0;
|
||||
rect.bottom = rect.top + 93.0;
|
||||
|
||||
(new AlertWindow(rect))->Show();
|
||||
|
||||
|
||||
(new AlertWindow(rect, this))->Show();
|
||||
|
||||
fApplyButton->SetEnabled(false);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#ifndef __SCREENWINDOW_H
|
||||
#define __SCREENWINDOW_H
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Stefano Ceccherini ([email protected])
|
||||
*/
|
||||
#ifndef SCREEN_WINDOW_H
|
||||
#define SCREEN_WINDOW_H
|
||||
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
@@ -10,58 +18,58 @@ class BMenuField;
|
||||
class RefreshWindow;
|
||||
class ScreenDrawView;
|
||||
class ScreenSettings;
|
||||
class ScreenWindow : public BWindow
|
||||
{
|
||||
|
||||
public:
|
||||
ScreenWindow(ScreenSettings *settings);
|
||||
virtual ~ScreenWindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void WorkspaceActivated(int32 ws, bool state);
|
||||
virtual void FrameMoved(BPoint position);
|
||||
virtual void ScreenChanged(BRect frame, color_space mode);
|
||||
|
||||
private:
|
||||
void SetStateByMode();
|
||||
void CheckApplyEnabled();
|
||||
void CheckUpdateDisplayModes();
|
||||
void CheckModesByResolution(const char*);
|
||||
void ApplyMode();
|
||||
class ScreenWindow : public BWindow {
|
||||
public:
|
||||
ScreenWindow(ScreenSettings *settings);
|
||||
virtual ~ScreenWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void WorkspaceActivated(int32 ws, bool state);
|
||||
virtual void FrameMoved(BPoint position);
|
||||
virtual void ScreenChanged(BRect frame, color_space mode);
|
||||
|
||||
private:
|
||||
void SetStateByMode();
|
||||
void CheckApplyEnabled();
|
||||
void CheckUpdateDisplayModes();
|
||||
void CheckModesByResolution(const char*);
|
||||
void ApplyMode();
|
||||
|
||||
BBox *fScreenView;
|
||||
ScreenSettings *fSettings;
|
||||
ScreenDrawView *fScreenDrawView;
|
||||
|
||||
BPopUpMenu *fWorkspaceMenu;
|
||||
BMenuField *fWorkspaceField;
|
||||
BPopUpMenu *fWorkspaceCountMenu;
|
||||
BMenuField *fWorkspaceCountField;
|
||||
BPopUpMenu *fResolutionMenu;
|
||||
BMenuField *fResolutionField;
|
||||
BPopUpMenu *fColorsMenu;
|
||||
BMenuField *fColorsField;
|
||||
BPopUpMenu *fRefreshMenu;
|
||||
BMenuField *fRefreshField;
|
||||
BMenuItem *fCurrentWorkspaceItem;
|
||||
BMenuItem *fAllWorkspacesItem;
|
||||
BButton *fDefaultsButton;
|
||||
BButton *fApplyButton;
|
||||
BButton *fRevertButton;
|
||||
|
||||
BMenuItem *fInitialResolution;
|
||||
BMenuItem *fInitialColors;
|
||||
BMenuItem *fInitialRefresh;
|
||||
BMenuItem *fOtherRefresh;
|
||||
|
||||
display_mode fInitialMode;
|
||||
display_mode *fSupportedModes;
|
||||
uint32 fTotalModes;
|
||||
|
||||
float fMinRefresh;
|
||||
float fMaxRefresh;
|
||||
float fCustomRefresh;
|
||||
float fInitialRefreshN;
|
||||
ScreenSettings *fSettings;
|
||||
|
||||
ScreenDrawView *fScreenDrawView;
|
||||
BPopUpMenu *fWorkspaceMenu;
|
||||
BMenuField *fWorkspaceField;
|
||||
BPopUpMenu *fWorkspaceCountMenu;
|
||||
BMenuField *fWorkspaceCountField;
|
||||
BPopUpMenu *fResolutionMenu;
|
||||
BMenuField *fResolutionField;
|
||||
BPopUpMenu *fColorsMenu;
|
||||
BMenuField *fColorsField;
|
||||
BPopUpMenu *fRefreshMenu;
|
||||
BMenuField *fRefreshField;
|
||||
BMenuItem *fCurrentWorkspaceItem;
|
||||
BMenuItem *fAllWorkspacesItem;
|
||||
BButton *fDefaultsButton;
|
||||
BButton *fApplyButton;
|
||||
BButton *fRevertButton;
|
||||
|
||||
BMenuItem *fInitialResolution;
|
||||
BMenuItem *fInitialColors;
|
||||
BMenuItem *fInitialRefresh;
|
||||
BMenuItem *fOtherRefresh;
|
||||
|
||||
display_mode fInitialMode;
|
||||
display_mode *fSupportedModes;
|
||||
uint32 fTotalModes;
|
||||
|
||||
float fMinRefresh;
|
||||
float fMaxRefresh;
|
||||
float fCustomRefresh;
|
||||
float fInitialRefreshN;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* SCREEN_WINDOW_H */
|
||||
|
||||
Reference in New Issue
Block a user