Re-styled and (hopefully) finalized.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5f1aaa70ce
commit
f141dd5709
@ -41,7 +41,8 @@ public:
|
||||
void SetPassword(char *pw){strncpy(password,pw,B_PATH_NAME_LENGTH-1);}
|
||||
void SetNetworkPassword(bool np) {isNetworkPWD=np;}
|
||||
void SetModuleName(const char *mn) {strncpy(moduleName,mn,B_PATH_NAME_LENGTH-1);}
|
||||
void SetState(BMessage *);
|
||||
void SetState(BMessage *in) {stateMsg=*in;}
|
||||
BMessage *GetSettings(void);
|
||||
void SaveSettings (void);
|
||||
private:
|
||||
bool parseSettings(BMessage *newSSMessage);
|
||||
@ -60,7 +61,7 @@ private:
|
||||
bool isNetworkPWD;
|
||||
|
||||
char moduleName[B_PATH_NAME_LENGTH];
|
||||
BMessage stateMsg;
|
||||
BMessage stateMsg, msg;
|
||||
};
|
||||
|
||||
|
||||
|
@ -69,8 +69,6 @@ filter_result SSISFilter::Filter(BMessage *msg,BList *outList) {
|
||||
lastEventTime=real_time_clock();
|
||||
if (msg->what==B_SCREEN_CHANGED)
|
||||
UpdateRectangles();
|
||||
else if (enabled)
|
||||
Banish();
|
||||
else if (msg->what==B_MOUSE_MOVED) {
|
||||
BPoint pos;
|
||||
msg->FindPoint("where",&pos);
|
||||
@ -82,9 +80,13 @@ filter_result SSISFilter::Filter(BMessage *msg,BList *outList) {
|
||||
Cornered(DOWNLEFT);
|
||||
else if (bottomRight.Contains(pos))
|
||||
Cornered(DOWNRIGHT);
|
||||
else
|
||||
else {
|
||||
Cornered(NONE);
|
||||
Banish();
|
||||
}
|
||||
}
|
||||
else
|
||||
Banish();
|
||||
}
|
||||
|
||||
SSISFilter::~SSISFilter() {
|
||||
|
@ -2,129 +2,177 @@
|
||||
#include <stdio.h>
|
||||
|
||||
BScreenSaver::BScreenSaver(BMessage *archive,
|
||||
image_id) : ticksize(50000),looponcount(0),loopoffcount(0) {
|
||||
image_id) : ticksize(50000),looponcount(0),loopoffcount(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BScreenSaver::~BScreenSaver() {
|
||||
BScreenSaver::~BScreenSaver()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BScreenSaver::InitCheck() {
|
||||
BScreenSaver::InitCheck()
|
||||
{
|
||||
return B_OK; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BScreenSaver::StartSaver(BView *view, bool preview) {
|
||||
BScreenSaver::StartSaver(BView *view, bool preview)
|
||||
{
|
||||
return B_OK; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::StopSaver() {
|
||||
BScreenSaver::StopSaver()
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::Draw(BView *view, int32 frame)
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::DirectConnected(direct_buffer_info *info) {
|
||||
BScreenSaver::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::DirectDraw(int32 frame) {
|
||||
BScreenSaver::DirectDraw(int32 frame)
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::StartConfig(BView *configView) {
|
||||
BScreenSaver::StartConfig(BView *configView)
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::StopConfig() {
|
||||
BScreenSaver::StopConfig()
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::SupplyInfo(BMessage *info) const {
|
||||
BScreenSaver::SupplyInfo(BMessage *info) const
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::ModulesChanged(const BMessage *info) {
|
||||
BScreenSaver::ModulesChanged(const BMessage *info)
|
||||
{
|
||||
return; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BScreenSaver::SaveState(BMessage *into) const {
|
||||
BScreenSaver::SaveState(BMessage *into) const
|
||||
{
|
||||
return B_ERROR; // This method is meant to be overridden
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::SetTickSize(bigtime_t ts) {
|
||||
BScreenSaver::SetTickSize(bigtime_t ts)
|
||||
{
|
||||
ticksize = ts;
|
||||
}
|
||||
|
||||
|
||||
bigtime_t
|
||||
BScreenSaver::TickSize() const {
|
||||
BScreenSaver::TickSize() const
|
||||
{
|
||||
return ticksize;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::SetLoop(int32 on_count, int32 off_count) {
|
||||
BScreenSaver::SetLoop(int32 on_count, int32 off_count)
|
||||
{
|
||||
looponcount = on_count;
|
||||
loopoffcount = off_count;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BScreenSaver::LoopOnCount() const {
|
||||
BScreenSaver::LoopOnCount() const
|
||||
{
|
||||
return looponcount;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BScreenSaver::LoopOffCount() const {
|
||||
BScreenSaver::LoopOffCount() const
|
||||
{
|
||||
return loopoffcount;
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver1() {
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver2() {
|
||||
BScreenSaver::_ReservedScreenSaver1()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver3() {
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver4() {
|
||||
BScreenSaver::_ReservedScreenSaver2()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver5() {
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver6() {
|
||||
BScreenSaver::_ReservedScreenSaver3()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver7() {
|
||||
}
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver8() {
|
||||
BScreenSaver::_ReservedScreenSaver4()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver5()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver6()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver7()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BScreenSaver::_ReservedScreenSaver8()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
void ReservedScreenSaver1__12BScreenSaver () {}
|
||||
void ReservedScreenSaver2__12BScreenSaver () {}
|
||||
|
@ -7,11 +7,14 @@
|
||||
#include "String.h" // BString def
|
||||
#include <stdio.h>
|
||||
|
||||
ScreenSaverPrefs::ScreenSaverPrefs(void) {
|
||||
ScreenSaverPrefs::ScreenSaverPrefs(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Load the flattened settings BMessage from disk and parse it.
|
||||
bool ScreenSaverPrefs::LoadSettings(void) {
|
||||
bool
|
||||
ScreenSaverPrefs::LoadSettings(void)
|
||||
{
|
||||
bool ok;
|
||||
char pathAndFile[B_PATH_NAME_LENGTH];
|
||||
BPath path;
|
||||
@ -21,8 +24,7 @@ bool ScreenSaverPrefs::LoadSettings(void) {
|
||||
strncpy(pathAndFile,path.Path(),B_PATH_NAME_LENGTH-1);
|
||||
strncat(pathAndFile,"/ScreenSaver_settings",B_PATH_NAME_LENGTH-1);
|
||||
BFile ssSettings(pathAndFile,B_READ_ONLY);
|
||||
if (B_OK==ssSettings.InitCheck())
|
||||
{ // File exists. Unflatten the message and call the settings parser.
|
||||
if (B_OK==ssSettings.InitCheck()) { // File exists. Unflatten the message and call the settings parser.
|
||||
BMessage settings;
|
||||
settings.Unflatten(&ssSettings);
|
||||
ok=parseSettings (&settings);
|
||||
@ -31,13 +33,19 @@ bool ScreenSaverPrefs::LoadSettings(void) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
void setOnValue(BMessage *msg, char *name, int &result) {
|
||||
|
||||
void
|
||||
setOnValue(BMessage *msg, char *name, int &result)
|
||||
{
|
||||
int32 value;
|
||||
if (B_OK == msg->FindInt32(name,&value)) // If screen saving is even enabled
|
||||
result=value;
|
||||
}
|
||||
|
||||
bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
||||
|
||||
bool
|
||||
ScreenSaverPrefs::parseSettings (BMessage *msg)
|
||||
{
|
||||
int temp;
|
||||
const char *strPtr;
|
||||
char pathAndFile[B_PATH_NAME_LENGTH];
|
||||
@ -77,12 +85,11 @@ bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
||||
if ((start=strstr(buffer,"PASSWORD =")))
|
||||
strncpy(password, start+10,strlen(start-11));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg->FindString("lockpassword",&strPtr);
|
||||
if (strPtr)
|
||||
strncpy(password,strPtr,B_PATH_NAME_LENGTH-1);
|
||||
}
|
||||
}
|
||||
} else
|
||||
password[0]='\0';
|
||||
if (B_OK != msg->FindString("modulename",&strPtr))
|
||||
@ -94,11 +101,13 @@ bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
||||
BString stateMsgName("modulesettings_");
|
||||
stateMsgName+=moduleName;
|
||||
msg->FindMessage(stateMsgName.String(),&stateMsg); // Doesn't matter if it fails - stateMsg would just continue to be empty
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BMessage *ScreenSaverPrefs::GetSettings (void) {
|
||||
|
||||
BMessage *
|
||||
ScreenSaverPrefs::GetSettings (void)
|
||||
{
|
||||
msg.MakeEmpty();
|
||||
msg.AddRect("windowframe",windowFrame);
|
||||
msg.AddInt32("windowtab",windowTab);
|
||||
@ -118,7 +127,10 @@ BMessage *ScreenSaverPrefs::GetSettings (void) {
|
||||
return &msg;
|
||||
}
|
||||
|
||||
void ScreenSaverPrefs::SaveSettings (void) {
|
||||
|
||||
void
|
||||
ScreenSaverPrefs::SaveSettings (void)
|
||||
{
|
||||
GetSettings();
|
||||
BPath path;
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||
|
@ -7,24 +7,34 @@
|
||||
#include "FindDirectory.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int32 threadFunc(void *data) {
|
||||
int32
|
||||
threadFunc(void *data)
|
||||
{
|
||||
ScreenSaverThread *ss=(ScreenSaverThread *)data;
|
||||
ss->thread();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
ScreenSaverThread::ScreenSaverThread(BWindow *wnd, BView *vw, ScreenSaverPrefs *p) :
|
||||
saver(NULL),win(wnd),view(vw), pref(p), frame(0),snoozeCount(0),addon_image(0) {
|
||||
saver(NULL),win(wnd),view(vw), pref(p), frame(0),snoozeCount(0),addon_image(0)
|
||||
{
|
||||
dwin=reinterpret_cast<BDirectWindow *>(wnd);
|
||||
}
|
||||
|
||||
void ScreenSaverThread::quit(void) {
|
||||
|
||||
void
|
||||
ScreenSaverThread::quit(void)
|
||||
{
|
||||
saver->StopSaver();
|
||||
if (win)
|
||||
win->Hide();
|
||||
}
|
||||
|
||||
void ScreenSaverThread::thread() {
|
||||
|
||||
void
|
||||
ScreenSaverThread::thread()
|
||||
{
|
||||
win->Lock();
|
||||
view->SetViewColor(0,0,0);
|
||||
view->SetLowColor(0,0,0);
|
||||
@ -38,8 +48,7 @@ void ScreenSaverThread::thread() {
|
||||
} else if (saver->LoopOnCount() && (frame>=saver->LoopOnCount())) { // Time to nap
|
||||
frame=0;
|
||||
snoozeCount=saver->LoopOffCount();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
win->Lock();
|
||||
if (dwin)
|
||||
saver->DirectDraw(frame);
|
||||
@ -50,54 +59,55 @@ void ScreenSaverThread::thread() {
|
||||
}
|
||||
}
|
||||
|
||||
BScreenSaver *ScreenSaverThread::LoadAddOn() {
|
||||
|
||||
BScreenSaver *
|
||||
ScreenSaverThread::LoadAddOn()
|
||||
{
|
||||
BScreenSaver *(*instantiate)(BMessage *, image_id );
|
||||
if (addon_image) { // This is a new set of preferences. Free up what we did have
|
||||
unload_add_on(addon_image);
|
||||
}
|
||||
}
|
||||
char temp[B_PATH_NAME_LENGTH];
|
||||
if (B_OK==find_directory(B_BEOS_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||
addon_image = load_add_on(temp);
|
||||
}
|
||||
}
|
||||
if (addon_image<0) {
|
||||
//printf ("Unable to open add-on: %s\n",temp);
|
||||
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||
if (B_OK==find_directory(B_COMMON_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||
addon_image = load_add_on(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addon_image<0) {
|
||||
//printf ("Unable to open add-on: %s\n",temp);
|
||||
if (B_OK==find_directory(B_USER_ADDONS_DIRECTORY,NULL,false,temp,B_PATH_NAME_LENGTH)) {
|
||||
sprintf (temp,"%s/Screen Savers/%s",temp,pref->ModuleName());
|
||||
addon_image = load_add_on(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addon_image<0) {
|
||||
printf ("Unable to open add-on: %s\n",temp);
|
||||
printf ("add on image = %ld!\n",addon_image);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Look for the one C function that should exist.
|
||||
status_t retVal;
|
||||
if (B_OK != (retVal=get_image_symbol(addon_image, "instantiate_screen_saver", B_SYMBOL_TYPE_TEXT,(void **) &instantiate))) {
|
||||
printf ("Unable to find the instantiator\n");
|
||||
printf ("Error = %ld\n",retVal);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
} else
|
||||
saver=instantiate(pref->GetState(),addon_image);
|
||||
if (B_OK!=saver->InitCheck()) {
|
||||
printf ("InitCheck() Failed!\n");
|
||||
unload_add_on(addon_image);
|
||||
delete saver;
|
||||
saver=NULL;
|
||||
return NULL;
|
||||
}
|
||||
if (B_OK!=saver->InitCheck()) {
|
||||
printf ("InitCheck() Failed!\n");
|
||||
unload_add_on(addon_image);
|
||||
delete saver;
|
||||
saver=NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return saver;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef __CONSTANTS__
|
||||
#define __CONSTANTS__
|
||||
|
||||
static const char *times[]={"30 seconds", "1 minute", "1 minute 30 seconds",
|
||||
int secondsToSlider(int val);
|
||||
|
||||
static const char *kTimes[]={"30 seconds", "1 minute", "1 minute 30 seconds",
|
||||
"2 minutes", "2 minutes 30 seconds", "3 minutes",
|
||||
"4 minutes", "5 minutes", "6 minutes",
|
||||
"7 minutes", "8 minutes", "9 minutes",
|
||||
@ -11,7 +13,7 @@ static const char *times[]={"30 seconds", "1 minute", "1 minute 30 s
|
||||
"2 hours", "2 hours 30 minutes", "3 hours",
|
||||
"4 hours", "5 hours"};
|
||||
|
||||
static const int timeInSeconds[]={ 30, 60, 90,
|
||||
static const int kTimeInSeconds[]={ 30, 60, 90,
|
||||
120, 150, 180,
|
||||
240, 300, 360,
|
||||
420, 480, 540,
|
||||
@ -21,28 +23,66 @@ static const int timeInSeconds[]={ 30, 60, 90,
|
||||
7200, 9000, 10800,
|
||||
14400, 18000};
|
||||
|
||||
int secondsToSlider(int);
|
||||
inline BPoint
|
||||
scaleDirect(float x, float y,BRect area)
|
||||
{
|
||||
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
|
||||
}
|
||||
|
||||
const int TAB1_CHG ='TAB1';
|
||||
const int TAB2_CHG ='TAB2';
|
||||
const int PWBUTTON ='PWBT';
|
||||
const int DONE_CLICKED ='DONE';
|
||||
const int CANCEL_CLICKED ='CNCL';
|
||||
const int BUTTON_CHANGED ='BTNC';
|
||||
const int SHOW ='SHOW';
|
||||
const int POPULATE ='POPU';
|
||||
const int UTILIZE ='UTIL';
|
||||
const int SAVER_SEL ='SSEL';
|
||||
const int TEST_BTN ='TEST';
|
||||
const int ADD_BTN ='ADD ';
|
||||
const int UPDATELIST ='UPDL';
|
||||
|
||||
const rgb_color black = {0,0,0,0};
|
||||
const rgb_color darkGrey = {150,150,150,0};
|
||||
const rgb_color grey = {200,200,200,0};
|
||||
const rgb_color lightBlue = {200,200,255,0};
|
||||
const rgb_color lightGreen = {255,200,200,0};
|
||||
const rgb_color red = {255,100,100,0};
|
||||
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area)
|
||||
{
|
||||
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
|
||||
}
|
||||
|
||||
static const float kPositionalX[]= {0,.1,.25,.3,.7,.75,.9,1.0};
|
||||
static const float kPositionalY[]= {0,.1,.7,.8,.9,1.0};
|
||||
|
||||
inline BPoint
|
||||
scale(int x, int y,BRect area)
|
||||
{
|
||||
return scaleDirect(kPositionalX[x],kPositionalY[y],area);
|
||||
}
|
||||
|
||||
|
||||
inline BRect
|
||||
scale(int x1, int x2, int y1, int y2,BRect area)
|
||||
{
|
||||
return scaleDirect(kPositionalX[x1],kPositionalX[x2],kPositionalY[y1],kPositionalY[y2],area);
|
||||
}
|
||||
|
||||
|
||||
inline BPoint
|
||||
scale3(int x, int y,BRect area,bool invertX,bool invertY)
|
||||
{
|
||||
float arrowX[]= {0,.25,.5,.66667,.90,.9};
|
||||
float arrowY[]= {0,.15,.25,.3333333,.6666667,1.0};
|
||||
|
||||
return scaleDirect(((invertX)?1-arrowX[x]:arrowX[x]),((invertY)?1-arrowY[y]:arrowY[y]),area);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const int kTab1_chg ='TAB1';
|
||||
const int kTab2_chg ='TAB2';
|
||||
const int kPwbutton ='PWBT';
|
||||
const int kDone_clicked ='DONE';
|
||||
const int kCancel_clicked ='CNCL';
|
||||
const int kButton_changed ='BTNC';
|
||||
const int kShow ='SHOW';
|
||||
const int kPopulate ='POPU';
|
||||
const int kUtilize ='UTIL';
|
||||
const int kSaver_sel ='SSEL';
|
||||
const int kTest_btn ='TEST';
|
||||
const int kAdd_btn ='ADD ';
|
||||
const int kUpdatelist ='UPDL';
|
||||
|
||||
const rgb_color kBlack = {0,0,0,0};
|
||||
const rgb_color kDarkGrey = {150,150,150,0};
|
||||
const rgb_color kGrey = {200,200,200,0};
|
||||
const rgb_color kLightBlue = {200,200,255,0};
|
||||
const rgb_color kLightGreen = {255,200,200,0};
|
||||
const rgb_color kRed = {255,100,100,0};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -5,48 +5,27 @@
|
||||
#include <Shape.h>
|
||||
#include <stdio.h>
|
||||
|
||||
inline BPoint scaleDirect(float x, float y,BRect area) {
|
||||
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
|
||||
}
|
||||
|
||||
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area) {
|
||||
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
|
||||
}
|
||||
|
||||
float positionalX[]= {0,.1,.25,.3,.7,.75,.9,1.0};
|
||||
float positionalY[]= {0,.1,.7,.8,.9,1.0};
|
||||
|
||||
inline BPoint scale(int x, int y,BRect area) { return scaleDirect(positionalX[x],positionalY[y],area); }
|
||||
inline BRect scale(int x1, int x2, int y1, int y2,BRect area) { return scaleDirect(positionalX[x1],positionalX[x2],positionalY[y1],positionalY[y2],area); }
|
||||
|
||||
int secondsToSlider(int val) {
|
||||
int count=sizeof(timeInSeconds)/sizeof(int);
|
||||
int t;
|
||||
for (t=0;t<count;t++)
|
||||
if (timeInSeconds[t]==val)
|
||||
return t;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MouseAreaView::Draw(BRect update) {
|
||||
void
|
||||
MouseAreaView::Draw(BRect update)
|
||||
{
|
||||
SetViewColor(216,216,216);
|
||||
// Top of monitor
|
||||
SetHighColor(grey);
|
||||
SetHighColor(kGrey);
|
||||
FillRoundRect(scale(0,7,0,3,Bounds()),4,4);
|
||||
SetHighColor(black);
|
||||
SetHighColor(kBlack);
|
||||
StrokeRoundRect(scale(0,7,0,3,Bounds()),4,4);
|
||||
SetHighColor(lightBlue);
|
||||
screenArea=scale(1,6,1,2,Bounds());
|
||||
FillRect(screenArea);
|
||||
SetHighColor(darkGrey);
|
||||
StrokeRect(screenArea);
|
||||
SetHighColor(kLightBlue);
|
||||
fScreenArea=scale(1,6,1,2,Bounds());
|
||||
FillRect(fScreenArea);
|
||||
SetHighColor(kDarkGrey);
|
||||
StrokeRect(fScreenArea);
|
||||
// Base of monitor
|
||||
SetHighColor(grey);
|
||||
SetHighColor(kGrey);
|
||||
FillTriangle(scale(1,5,Bounds()),scale(3,4,Bounds()),scale(3,5,Bounds()));
|
||||
FillTriangle(scale(4,5,Bounds()),scale(4,4,Bounds()),scale(6,5,Bounds()));
|
||||
FillRect(scale(3,4,4,5,Bounds()));
|
||||
FillRect(scale(3,4,3,4,Bounds()));
|
||||
SetHighColor(black);
|
||||
SetHighColor(kBlack);
|
||||
StrokeRect(scale(3,4,3,4,Bounds()));
|
||||
StrokeLine(scale(2,4,Bounds()),scale(1,5,Bounds()));
|
||||
StrokeLine(scale(6,5,Bounds()),scale(1,5,Bounds()));
|
||||
@ -54,33 +33,32 @@ void MouseAreaView::Draw(BRect update) {
|
||||
DrawArrow();
|
||||
}
|
||||
|
||||
float arrowX[]= {0,.25,.5,.66667,.90,.9};
|
||||
float arrowY[]= {0,.15,.25,.3333333,.6666667,1.0};
|
||||
|
||||
inline BPoint scale3(int x, int y,BRect area,bool invertX,bool invertY) {
|
||||
return scaleDirect(((invertX)?1-arrowX[x]:arrowX[x]),((invertY)?1-arrowY[y]:arrowY[y]),area); }
|
||||
|
||||
BRect getArrowSize(BRect area,bool isCentered)
|
||||
BRect
|
||||
getArrowSize(BRect area,bool isCentered)
|
||||
{
|
||||
int size=area.IntegerWidth();
|
||||
int temp=area.IntegerHeight();
|
||||
if (temp<size)
|
||||
size=temp;
|
||||
size/=3;
|
||||
BRect foo(0,0,size,size);
|
||||
int areaWidth=area.IntegerWidth();
|
||||
int areaHeight=area.IntegerHeight();
|
||||
if (areaHeight<areaWidth)
|
||||
areaWidth=areaHeight;
|
||||
areaWidth/=3;
|
||||
BRect foo(0,0,areaWidth,areaWidth);
|
||||
if (isCentered)
|
||||
foo.OffsetBy(area.left+area.Width()/2-(size/2),area.top+area.Height()/2-(size/2));
|
||||
foo.OffsetBy(area.left+area.Width()/2-(areaWidth/2),area.top+area.Height()/2-(areaWidth/2));
|
||||
return (foo);
|
||||
}
|
||||
|
||||
void MouseAreaView::DrawArrow(void) {
|
||||
if (currentDirection!=NONE) {
|
||||
BRect area(getArrowSize(screenArea,false));
|
||||
bool invertX=(currentDirection==UPRIGHT||currentDirection==DOWNRIGHT);
|
||||
bool invertY=(currentDirection==UPRIGHT||currentDirection==UPLEFT);
|
||||
|
||||
void
|
||||
MouseAreaView::DrawArrow(void)
|
||||
{
|
||||
if (fCurrentDirection!=NONE) {
|
||||
BRect area(getArrowSize(fScreenArea,false));
|
||||
bool invertX=(fCurrentDirection==UPRIGHT||fCurrentDirection==DOWNRIGHT);
|
||||
bool invertY=(fCurrentDirection==UPRIGHT||fCurrentDirection==UPLEFT);
|
||||
|
||||
float size=area.Width();
|
||||
MovePenTo(((invertX)?screenArea.right-size-2:2+screenArea.left),((!invertY)?screenArea.bottom-size-2:2+screenArea.top));
|
||||
MovePenTo(((invertX)?fScreenArea.right-size-2:2+fScreenArea.left),((!invertY)?fScreenArea.bottom-size-2:2+fScreenArea.top));
|
||||
BShape arrow;
|
||||
arrow.MoveTo(scale3(0,1,area,invertX,invertY));
|
||||
arrow.LineTo(scale3(0,5,area,invertX,invertY));
|
||||
@ -91,34 +69,31 @@ void MouseAreaView::DrawArrow(void) {
|
||||
arrow.LineTo(scale3(1,2,area,invertX,invertY));
|
||||
arrow.LineTo(scale3(0,1,area,invertX,invertY));
|
||||
arrow.Close();
|
||||
SetHighColor(black);
|
||||
SetHighColor(kBlack);
|
||||
FillShape(&arrow,B_SOLID_HIGH);
|
||||
}
|
||||
else {
|
||||
// PushState();
|
||||
BRect area(getArrowSize(screenArea,true));
|
||||
SetHighColor(red);
|
||||
} else {
|
||||
BRect area(getArrowSize(fScreenArea,true));
|
||||
SetHighColor(kRed);
|
||||
SetPenSize(2);
|
||||
StrokeEllipse(area);
|
||||
StrokeLine(BPoint(area.right,area.top),BPoint(area.left,area.bottom));
|
||||
// PopState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MouseAreaView::MouseUp(BPoint point) {
|
||||
if (screenArea.Contains(point)) {
|
||||
if (getArrowSize(screenArea,true).Contains(point))
|
||||
currentDirection=NONE;
|
||||
void MouseAreaView::MouseUp(BPoint point)
|
||||
{
|
||||
if (fScreenArea.Contains(point)) {
|
||||
if (getArrowSize(fScreenArea,true).Contains(point))
|
||||
fCurrentDirection=NONE;
|
||||
else {
|
||||
float centerX=screenArea.left+(screenArea.Width()/2);
|
||||
float centerY=screenArea.top+(screenArea.Height()/2);
|
||||
float centerX=fScreenArea.left+(fScreenArea.Width()/2);
|
||||
float centerY=fScreenArea.top+(fScreenArea.Height()/2);
|
||||
if (point.x<centerX)
|
||||
currentDirection=((point.y<centerY)?UPLEFT:DOWNLEFT);
|
||||
fCurrentDirection=((point.y<centerY)?UPLEFT:DOWNLEFT);
|
||||
else
|
||||
currentDirection=((point.y<centerY)?UPRIGHT:DOWNRIGHT);
|
||||
fCurrentDirection=((point.y<centerY)?UPRIGHT:DOWNRIGHT);
|
||||
}
|
||||
Draw(screenArea);
|
||||
}
|
||||
Draw(fScreenArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,14 @@ class MouseAreaView : public BView
|
||||
public:
|
||||
MouseAreaView(BRect frame, const char *name) : BView (frame,name,B_FOLLOW_NONE,B_WILL_DRAW)
|
||||
{ SetViewColor(216,216,216);
|
||||
currentDirection=NONE;}
|
||||
fCurrentDirection=NONE;}
|
||||
|
||||
virtual void Draw(BRect update);
|
||||
virtual void MouseUp(BPoint point);
|
||||
void DrawArrow(void);
|
||||
inline arrowDirection getDirection(void) {return currentDirection;}
|
||||
void setDirection(arrowDirection direction) {currentDirection=direction;Draw(BRect (0,0,100,100));}
|
||||
inline arrowDirection getDirection(void) {return fCurrentDirection;}
|
||||
void setDirection(arrowDirection direction) {fCurrentDirection=direction;Draw(BRect (0,0,100,100));}
|
||||
private:
|
||||
BRect screenArea;
|
||||
arrowDirection currentDirection;
|
||||
BRect fScreenArea;
|
||||
arrowDirection fCurrentDirection;
|
||||
};
|
||||
|
@ -9,53 +9,67 @@
|
||||
#include <Screen.h>
|
||||
#include <String.h>
|
||||
|
||||
inline BPoint scaleDirect(float x, float y,BRect area) {
|
||||
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
|
||||
static float sampleX[]= {0,.05,.15,.7,.725,.8,.825,.85,.950,1.0};
|
||||
static float sampleY[]= {0,.05,.90,.95,.966,.975,1.0};
|
||||
inline BPoint
|
||||
scale2(int x, int y,BRect area)
|
||||
{
|
||||
return scaleDirect(sampleX[x],sampleY[y],area);
|
||||
}
|
||||
|
||||
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area) {
|
||||
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
|
||||
|
||||
inline BRect
|
||||
scale2(int x1, int x2, int y1, int y2,BRect area)
|
||||
{
|
||||
return scaleDirect(sampleX[x1],sampleX[x2],sampleY[y1],sampleY[y2],area);
|
||||
}
|
||||
|
||||
float sampleX[]= {0,.05,.15,.7,.725,.8,.825,.85,.950,1.0};
|
||||
float sampleY[]= {0,.05,.90,.95,.966,.975,1.0};
|
||||
inline BPoint scale2(int x, int y,BRect area) { return scaleDirect(sampleX[x],sampleY[y],area); }
|
||||
inline BRect scale2(int x1, int x2, int y1, int y2,BRect area) { return scaleDirect(sampleX[x1],sampleX[x2],sampleY[y1],sampleY[y2],area); }
|
||||
|
||||
PreviewView::PreviewView(BRect frame, const char *name,ScreenSaverPrefs *prefp)
|
||||
: BView (frame,name,B_FOLLOW_NONE,B_WILL_DRAW),
|
||||
saver (NULL),configView(NULL),sst(NULL),threadID(0),prefPtr(prefp) {
|
||||
fSaver (NULL),fConfigView(NULL),fSst(NULL),fThreadID(-1),fPrefPtr(prefp)
|
||||
{
|
||||
SetViewColor(216,216,216);
|
||||
}
|
||||
|
||||
PreviewView::~PreviewView() {
|
||||
if (threadID)
|
||||
kill_thread(threadID);
|
||||
|
||||
PreviewView::~PreviewView()
|
||||
{
|
||||
if (fThreadID>=0)
|
||||
kill_thread(fThreadID);
|
||||
}
|
||||
|
||||
void PreviewView::SetScreenSaver(BString name) {
|
||||
if (threadID)
|
||||
kill_thread(threadID);
|
||||
if (sst)
|
||||
delete sst;
|
||||
if (configView) {
|
||||
RemoveChild(configView);
|
||||
delete configView;
|
||||
}
|
||||
|
||||
configView=new BView(scale2(1,8,1,2,Bounds()),"previewArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||
configView->SetViewColor(0,0,0);
|
||||
AddChild(configView);
|
||||
|
||||
sst=new ScreenSaverThread(Window(),configView,prefPtr);
|
||||
saver=sst->LoadAddOn();
|
||||
if (saver) {
|
||||
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,sst);
|
||||
resume_thread(threadID);
|
||||
void
|
||||
PreviewView::SetScreenSaver(BString name)
|
||||
{
|
||||
if (fThreadID>=0) {
|
||||
kill_thread(fThreadID);
|
||||
fThreadID=-1;
|
||||
}
|
||||
if (fSst)
|
||||
delete fSst;
|
||||
if (fConfigView) {
|
||||
RemoveChild(fConfigView);
|
||||
delete fConfigView;
|
||||
}
|
||||
|
||||
fConfigView=new BView(scale2(1,8,1,2,Bounds()),"previewArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||
fConfigView->SetViewColor(0,0,0);
|
||||
AddChild(fConfigView);
|
||||
|
||||
fSst=new ScreenSaverThread(Window(),fConfigView,fPrefPtr);
|
||||
fSaver=fSst->LoadAddOn();
|
||||
if (fSaver) {
|
||||
fThreadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,fSst);
|
||||
resume_thread(fThreadID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PreviewView::Draw(BRect update) {
|
||||
void
|
||||
PreviewView::Draw(BRect update)
|
||||
{
|
||||
SetViewColor(216,216,216);
|
||||
|
||||
SetHighColor(184,184,184);
|
||||
@ -65,8 +79,7 @@ void PreviewView::Draw(BRect update) {
|
||||
SetHighColor(96,96,96);
|
||||
StrokeRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline
|
||||
StrokeRoundRect(scale2(0,9,0,3,Bounds()),4,4); // Outline outer shape
|
||||
SetHighColor(black);
|
||||
// FillRoundRect(scale2(1,8,1,2,Bounds()),4,4);// Screen itself
|
||||
SetHighColor(kBlack);
|
||||
|
||||
SetHighColor(184,184,184);
|
||||
BRect outerShape=scale2(2,7,2,6,Bounds());
|
||||
|
@ -12,13 +12,13 @@ public:
|
||||
~PreviewView();
|
||||
void Draw(BRect update);
|
||||
void SetScreenSaver(BString name);
|
||||
BScreenSaver *ScreenSaver(void) {return saver;}
|
||||
BScreenSaver *ScreenSaver(void) {return fSaver;}
|
||||
private:
|
||||
BScreenSaver* saver;
|
||||
BView *configView;
|
||||
ScreenSaverThread *sst;
|
||||
thread_id threadID;
|
||||
ScreenSaverPrefs *prefPtr;
|
||||
BScreenSaver* fSaver;
|
||||
BView *fConfigView;
|
||||
ScreenSaverThread *fSst;
|
||||
thread_id fThreadID;
|
||||
ScreenSaverPrefs *fPrefPtr;
|
||||
|
||||
}; // end class PreviewView
|
||||
|
||||
|
@ -7,15 +7,21 @@
|
||||
|
||||
const char *APP_SIG = "application/x-vnd.OBOS.ScreenSaver";
|
||||
|
||||
ScreenSaverPrefsApp::~ScreenSaverPrefsApp(void) {
|
||||
ScreenSaverPrefsApp::~ScreenSaverPrefsApp(void)
|
||||
{
|
||||
}
|
||||
|
||||
ScreenSaverPrefsApp::ScreenSaverPrefsApp(void) : BApplication(APP_SIG) {
|
||||
|
||||
ScreenSaverPrefsApp::ScreenSaverPrefsApp(void) : BApplication(APP_SIG)
|
||||
{
|
||||
m_MainForm = new ScreenSaverWin();
|
||||
m_MainForm->Show();
|
||||
}
|
||||
|
||||
void ScreenSaverPrefsApp::RefsReceived(BMessage *msg) {
|
||||
|
||||
void
|
||||
ScreenSaverPrefsApp::RefsReceived(BMessage *msg)
|
||||
{
|
||||
entry_ref ref;
|
||||
BEntry e;
|
||||
BPath p;
|
||||
@ -26,19 +32,22 @@ void ScreenSaverPrefsApp::RefsReceived(BMessage *msg) {
|
||||
char temp[2*B_PATH_NAME_LENGTH];
|
||||
sprintf (temp,"cp %s '/boot/home/config/add-ons/Screen Savers/'\n",p.Path());
|
||||
system(temp);
|
||||
m_MainForm->PostMessage(new BMessage(UPDATELIST));
|
||||
m_MainForm->PostMessage(new BMessage(kUpdatelist));
|
||||
}
|
||||
|
||||
void ScreenSaverPrefsApp::MessageReceived(BMessage *message) {
|
||||
|
||||
void ScreenSaverPrefsApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case B_READY_TO_RUN:
|
||||
break;
|
||||
default: {
|
||||
BApplication::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
ScreenSaverPrefsApp app;
|
||||
app.Run();
|
||||
|
@ -24,52 +24,70 @@ const int32 zero=0;
|
||||
void drawPositionalMonitor(BView *view,BRect areaToDrawIn,int state);
|
||||
BView *drawSampleMonitor(BView *view, BRect area);
|
||||
|
||||
|
||||
int
|
||||
secondsToSlider(int val)
|
||||
{
|
||||
int count=sizeof(kTimeInSeconds)/sizeof(int);
|
||||
for (int t=0;t<count;t++)
|
||||
if (kTimeInSeconds[t]==val)
|
||||
return t;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct SSListItem {
|
||||
BString fileName;
|
||||
BString displayName;
|
||||
};
|
||||
|
||||
void ScreenSaverWin::SaverSelected(void) {
|
||||
if (ListView1->CurrentSelection()>=0) {
|
||||
void
|
||||
ScreenSaverWin::SaverSelected(void)
|
||||
{
|
||||
if (fListView1->CurrentSelection()>=0) {
|
||||
SSListItem* listItem;
|
||||
if (previewDisplay->ScreenSaver())
|
||||
previewDisplay->ScreenSaver()->StopConfig();
|
||||
listItem = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()));
|
||||
if (fPreviewDisplay->ScreenSaver())
|
||||
fPreviewDisplay->ScreenSaver()->StopConfig();
|
||||
listItem = reinterpret_cast<SSListItem*>(fAddonList->ItemAt(fListView1->CurrentSelection()));
|
||||
BString settingsMsgName(listItem->fileName);
|
||||
previewDisplay->SetScreenSaver(settingsMsgName);
|
||||
if (settingsArea) {
|
||||
ModuleSettingsBox->RemoveChild(settingsArea);
|
||||
delete settingsArea;
|
||||
}
|
||||
BRect bnds=ModuleSettingsBox->Bounds();
|
||||
fPreviewDisplay->SetScreenSaver(settingsMsgName);
|
||||
if (fSettingsArea) {
|
||||
fModuleSettingsBox->RemoveChild(fSettingsArea);
|
||||
delete fSettingsArea;
|
||||
}
|
||||
BRect bnds=fModuleSettingsBox->Bounds();
|
||||
bnds.InsetBy(5,10);
|
||||
settingsArea=new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||
settingsArea->SetViewColor(216,216,216);
|
||||
ModuleSettingsBox->AddChild(settingsArea);
|
||||
fSettingsArea=new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||
fSettingsArea->SetViewColor(216,216,216);
|
||||
fModuleSettingsBox->AddChild(fSettingsArea);
|
||||
|
||||
if (previewDisplay->ScreenSaver())
|
||||
previewDisplay->ScreenSaver()->StartConfig(settingsArea);
|
||||
if (fPreviewDisplay->ScreenSaver())
|
||||
fPreviewDisplay->ScreenSaver()->StartConfig(fSettingsArea);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSaverWin::MessageReceived(BMessage *msg) {
|
||||
|
||||
void
|
||||
ScreenSaverWin::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case PWBUTTON:
|
||||
pwMessenger->SendMessage(SHOW);
|
||||
case kPwbutton:
|
||||
fPwMessenger->SendMessage(kShow);
|
||||
break;
|
||||
case B_QUIT_REQUESTED:
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
case SAVER_SEL:
|
||||
case kSaver_sel:
|
||||
SaverSelected();
|
||||
break;
|
||||
case TEST_BTN:
|
||||
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",prefs.GetSettings());
|
||||
case kTest_btn:
|
||||
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",fPrefs.GetSettings());
|
||||
break;
|
||||
case ADD_BTN:
|
||||
filePanel->Show();
|
||||
case kAdd_btn:
|
||||
fFilePanel->Show();
|
||||
break;
|
||||
case UPDATELIST:
|
||||
case kUpdatelist:
|
||||
populateScreenSaverList();
|
||||
break;
|
||||
}
|
||||
@ -77,54 +95,61 @@ void ScreenSaverWin::MessageReceived(BMessage *msg) {
|
||||
BWindow::MessageReceived(msg);
|
||||
}
|
||||
|
||||
bool ScreenSaverWin::QuitRequested() {
|
||||
|
||||
bool
|
||||
ScreenSaverWin::QuitRequested()
|
||||
{
|
||||
updateStatus();
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return(true);
|
||||
}
|
||||
|
||||
void ScreenSaverWin::updateStatus(void) {
|
||||
|
||||
void
|
||||
ScreenSaverWin::updateStatus(void)
|
||||
{
|
||||
DisableUpdates();
|
||||
// Policy - enable and disable controls as per checkboxes, etc
|
||||
PasswordCheckbox->SetEnabled(EnableCheckbox->Value());
|
||||
TurnOffScreenCheckBox->SetEnabled(EnableCheckbox->Value());
|
||||
RunSlider->SetEnabled(EnableCheckbox->Value());
|
||||
TurnOffSlider->SetEnabled(EnableCheckbox->Value() && TurnOffScreenCheckBox->Value());
|
||||
TurnOffSlider->SetEnabled(false); // This never seems to turn on in the R5 version
|
||||
TurnOffScreenCheckBox->SetEnabled(false);
|
||||
PasswordSlider->SetEnabled(EnableCheckbox->Value() && PasswordCheckbox->Value());
|
||||
PasswordButton->SetEnabled(EnableCheckbox->Value() && PasswordCheckbox->Value());
|
||||
fPasswordCheckbox->SetEnabled(fEnableCheckbox->Value());
|
||||
fTurnOffScreenCheckBox->SetEnabled(fEnableCheckbox->Value());
|
||||
fRunSlider->SetEnabled(fEnableCheckbox->Value());
|
||||
fTurnOffSlider->SetEnabled(fEnableCheckbox->Value() && fTurnOffScreenCheckBox->Value());
|
||||
fTurnOffSlider->SetEnabled(false); // This never seems to turn on in the R5 version
|
||||
fTurnOffScreenCheckBox->SetEnabled(false);
|
||||
fPasswordSlider->SetEnabled(fEnableCheckbox->Value() && fPasswordCheckbox->Value());
|
||||
fPasswordButton->SetEnabled(fEnableCheckbox->Value() && fPasswordCheckbox->Value());
|
||||
// Set the labels for the sliders
|
||||
RunSlider->SetLabel(times[RunSlider->Value()]);
|
||||
TurnOffSlider->SetLabel(times[TurnOffSlider->Value()]);
|
||||
PasswordSlider->SetLabel(times[PasswordSlider->Value()]);
|
||||
fRunSlider->SetLabel(kTimes[fRunSlider->Value()]);
|
||||
fTurnOffSlider->SetLabel(kTimes[fTurnOffSlider->Value()]);
|
||||
fPasswordSlider->SetLabel(kTimes[fPasswordSlider->Value()]);
|
||||
EnableUpdates();
|
||||
// Update the saved preferences
|
||||
prefs.SetWindowFrame(Frame());
|
||||
prefs.SetWindowTab(tabView->Selection());
|
||||
prefs.SetTimeFlags(EnableCheckbox->Value());
|
||||
prefs.SetBlankTime(timeInSeconds[RunSlider->Value()]);
|
||||
prefs.SetOffTime(timeInSeconds[TurnOffSlider->Value()]);
|
||||
prefs.SetSuspendTime(timeInSeconds[TurnOffSlider->Value()]);
|
||||
prefs.SetStandbyTime(timeInSeconds[TurnOffSlider->Value()]);
|
||||
prefs.SetBlankCorner(fadeNow->getDirection());
|
||||
prefs.SetNeverBlankCorner(fadeNever->getDirection());
|
||||
prefs.SetLockEnable(PasswordCheckbox->Value());
|
||||
prefs.SetPasswordTime(timeInSeconds[PasswordSlider->Value()]);
|
||||
int selection=ListView1->CurrentSelection(0);
|
||||
//const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
|
||||
fPrefs.SetWindowFrame(Frame());
|
||||
fPrefs.SetWindowTab(fTabView->Selection());
|
||||
fPrefs.SetTimeFlags(fEnableCheckbox->Value());
|
||||
fPrefs.SetBlankTime(kTimeInSeconds[fRunSlider->Value()]);
|
||||
fPrefs.SetOffTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
||||
fPrefs.SetSuspendTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
||||
fPrefs.SetStandbyTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
||||
fPrefs.SetBlankCorner(fFadeNow->getDirection());
|
||||
fPrefs.SetNeverBlankCorner(fFadeNever->getDirection());
|
||||
fPrefs.SetLockEnable(fPasswordCheckbox->Value());
|
||||
fPrefs.SetPasswordTime(kTimeInSeconds[fPasswordSlider->Value()]);
|
||||
int selection=fListView1->CurrentSelection(0);
|
||||
if (selection>=0)
|
||||
prefs.SetModuleName(((BStringItem *)(ListView1->ItemAt(selection)))->Text());
|
||||
fPrefs.SetModuleName(((BStringItem *)(fListView1->ItemAt(selection)))->Text());
|
||||
// TODO - Tell the password window to update its stuff
|
||||
BMessage ssState;
|
||||
if ((previewDisplay->ScreenSaver()) && (previewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
|
||||
prefs.SetState(&ssState);
|
||||
prefs.SaveSettings();
|
||||
if ((fPreviewDisplay->ScreenSaver()) && (fPreviewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
|
||||
fPrefs.SetState(&ssState);
|
||||
fPrefs.SaveSettings();
|
||||
};
|
||||
|
||||
void ScreenSaverWin::SetupForm(void) {
|
||||
|
||||
filePanel=new BFilePanel();
|
||||
void
|
||||
ScreenSaverWin::SetupForm(void)
|
||||
{
|
||||
fFilePanel=new BFilePanel();
|
||||
|
||||
BRect r;
|
||||
BView *background;
|
||||
@ -138,59 +163,61 @@ void ScreenSaverWin::SetupForm(void) {
|
||||
|
||||
// Add the tab view to the background
|
||||
r.InsetBy(0,3);
|
||||
tabView = new BTabView(r, "tab_view");
|
||||
tabView->SetViewColor(216,216,216,0);
|
||||
r = tabView->Bounds();
|
||||
fTabView = new BTabView(r, "tab_view");
|
||||
fTabView->SetViewColor(216,216,216,0);
|
||||
r = fTabView->Bounds();
|
||||
r.InsetBy(0,4);
|
||||
r.bottom -= tabView->TabHeight();
|
||||
r.bottom -= fTabView->TabHeight();
|
||||
|
||||
// Time to load the settings into a message and implement them...
|
||||
prefs.LoadSettings();
|
||||
prefs.WindowFrame().PrintToStream();
|
||||
fPrefs.LoadSettings();
|
||||
|
||||
tab = new BTab();
|
||||
tabView->AddTab(tab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
|
||||
fTabView->AddTab(fTab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
|
||||
tab->SetLabel("Fade");
|
||||
|
||||
tab = new BTab();
|
||||
tabView->AddTab(tab1=new BView(r,"Modules",B_FOLLOW_NONE,0), tab);
|
||||
fTabView->AddTab(fTab1=new BView(r,"Modules",B_FOLLOW_NONE,0), tab);
|
||||
tab->SetLabel("Modules");
|
||||
background->AddChild(tabView);
|
||||
background->AddChild(fTabView);
|
||||
|
||||
// Create the controls inside the tabs
|
||||
setupTab2();
|
||||
setupTab1();
|
||||
|
||||
// Create the password editing window
|
||||
pwWin=new pwWindow;
|
||||
pwMessenger=new BMessenger (NULL,pwWin);
|
||||
pwWin->Run();
|
||||
fPwWin=new pwWindow;
|
||||
fPwMessenger=new BMessenger (NULL,fPwWin);
|
||||
fPwWin->Run();
|
||||
|
||||
MoveTo(prefs.WindowFrame().left,prefs.WindowFrame().top);
|
||||
ResizeTo(prefs.WindowFrame().right-prefs.WindowFrame().left,prefs.WindowFrame().bottom-prefs.WindowFrame().top);
|
||||
tabView->Select(prefs.WindowTab());
|
||||
EnableCheckbox->SetValue(prefs.TimeFlags());
|
||||
RunSlider->SetValue(secondsToSlider(prefs.BlankTime()));
|
||||
TurnOffSlider->SetValue(secondsToSlider(prefs.OffTime()));
|
||||
fadeNow->setDirection(prefs.GetBlankCorner());
|
||||
fadeNever->setDirection(prefs.GetNeverBlankCorner());
|
||||
PasswordCheckbox->SetValue(prefs.LockEnable());
|
||||
PasswordSlider->SetValue(secondsToSlider(prefs.PasswordTime()));
|
||||
const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
|
||||
long count=ListView1->CountItems();
|
||||
if (prefs.ModuleName() && ptr)
|
||||
MoveTo(fPrefs.WindowFrame().left,fPrefs.WindowFrame().top);
|
||||
ResizeTo(fPrefs.WindowFrame().right-fPrefs.WindowFrame().left,fPrefs.WindowFrame().bottom-fPrefs.WindowFrame().top);
|
||||
fTabView->Select(fPrefs.WindowTab());
|
||||
fEnableCheckbox->SetValue(fPrefs.TimeFlags());
|
||||
fRunSlider->SetValue(secondsToSlider(fPrefs.BlankTime()));
|
||||
fTurnOffSlider->SetValue(secondsToSlider(fPrefs.OffTime()));
|
||||
fFadeNow->setDirection(fPrefs.GetBlankCorner());
|
||||
fFadeNever->setDirection(fPrefs.GetNeverBlankCorner());
|
||||
fPasswordCheckbox->SetValue(fPrefs.LockEnable());
|
||||
fPasswordSlider->SetValue(secondsToSlider(fPrefs.PasswordTime()));
|
||||
const BStringItem **ptr = (const BStringItem **)(fListView1->Items());
|
||||
long count=fListView1->CountItems();
|
||||
if (fPrefs.ModuleName() && ptr)
|
||||
for ( long i = 0; i < count; i++ ) {
|
||||
if (BString(prefs.ModuleName())==((*ptr++)->Text())) {
|
||||
ListView1->Select(count=i); // Clever bit here - intentional assignment.
|
||||
if (BString(fPrefs.ModuleName())==((*ptr++)->Text())) {
|
||||
fListView1->Select(count=i); // Clever bit here - intentional assignment.
|
||||
SaverSelected();
|
||||
ListView1->ScrollToSelection();
|
||||
}
|
||||
fListView1->ScrollToSelection();
|
||||
}
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
|
||||
// Set the common Look and Feel stuff for a given control
|
||||
void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
|
||||
void
|
||||
commonLookAndFeel(BView *widget,bool isSlider,bool isControl)
|
||||
{
|
||||
{rgb_color clr = {216,216,216,255}; widget->SetViewColor(clr);}
|
||||
if (isSlider) {
|
||||
BSlider *slid=dynamic_cast<BSlider *>(widget);
|
||||
@ -203,7 +230,7 @@ void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
|
||||
slid->SetLabel("0 minutes");
|
||||
slid->SetValue(0);
|
||||
slid->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
{rgb_color clr = {0,0,0,0}; widget->SetHighColor(clr);}
|
||||
widget->SetFlags(B_WILL_DRAW|B_NAVIGABLE);
|
||||
widget->SetResizingMode(B_FOLLOW_NONE);
|
||||
@ -212,11 +239,14 @@ void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
|
||||
if (isControl) {
|
||||
BControl *wid=dynamic_cast<BControl *>(widget);
|
||||
wid->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Iterate over a directory, adding the directories files to the list
|
||||
void addScreenSaversToList (directory_which dir, BList *list) {
|
||||
void
|
||||
addScreenSaversToList (directory_which dir, BList *list)
|
||||
{
|
||||
BPath path;
|
||||
find_directory(dir,&path);
|
||||
path.Append("Screen Savers",true);
|
||||
@ -236,152 +266,163 @@ void addScreenSaversToList (directory_which dir, BList *list) {
|
||||
tempListItem->displayName = thisName;
|
||||
|
||||
list->AddItem(tempListItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sorting function for SSListItems
|
||||
int compareSSListItems(const void* left, const void* right) {
|
||||
int
|
||||
compareSSListItems(const void* left, const void* right)
|
||||
{
|
||||
SSListItem* leftItem = *(SSListItem **)left;
|
||||
SSListItem* rightItem = *(SSListItem **)right;
|
||||
|
||||
return leftItem->displayName.Compare(rightItem->displayName);
|
||||
}
|
||||
|
||||
void ScreenSaverWin::populateScreenSaverList(void) {
|
||||
if (!AddonList)
|
||||
AddonList = new BList;
|
||||
|
||||
void
|
||||
ScreenSaverWin::populateScreenSaverList(void)
|
||||
{
|
||||
if (!fAddonList)
|
||||
fAddonList = new BList;
|
||||
else
|
||||
for (void *i=AddonList->RemoveItem(zero);i;i=AddonList->RemoveItem(zero))
|
||||
for (void *i=fAddonList->RemoveItem(zero);i;i=fAddonList->RemoveItem(zero))
|
||||
delete ((SSListItem *)i);
|
||||
|
||||
SSListItem* tempListItem = new SSListItem;
|
||||
tempListItem->fileName = "";
|
||||
tempListItem->displayName = "Blackness";
|
||||
AddonList->AddItem(tempListItem);
|
||||
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, AddonList );
|
||||
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, AddonList );
|
||||
AddonList->SortItems(compareSSListItems);
|
||||
fAddonList->AddItem(tempListItem);
|
||||
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, fAddonList );
|
||||
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, fAddonList );
|
||||
fAddonList->SortItems(compareSSListItems);
|
||||
|
||||
// Add the strings in the BList to a BListView
|
||||
ListView1->DeselectAll();
|
||||
for (void *i=ListView1->RemoveItem(zero);i;i=ListView1->RemoveItem(zero))
|
||||
fListView1->DeselectAll();
|
||||
for (void *i=fListView1->RemoveItem(zero);i;i=fListView1->RemoveItem(zero))
|
||||
delete ((BStringItem *)i);
|
||||
|
||||
int numItems = AddonList->CountItems();
|
||||
int numItems = fAddonList->CountItems();
|
||||
for( int i = 0; i < numItems; ++i ) {
|
||||
SSListItem* item = (SSListItem*)(AddonList->ItemAt(i));
|
||||
ListView1->AddItem( new BStringItem(item->displayName.String()) );
|
||||
}
|
||||
SSListItem* item = (SSListItem*)(fAddonList->ItemAt(i));
|
||||
fListView1->AddItem( new BStringItem(item->displayName.String()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create the controls for the first tab
|
||||
void ScreenSaverWin::setupTab1(void) {
|
||||
void
|
||||
ScreenSaverWin::setupTab1(void)
|
||||
{
|
||||
int columns[4]={15,150,180,430};
|
||||
int rows[6]={15,120,135,255,263,280};
|
||||
|
||||
{rgb_color clr = {216,216,216,255}; tab1->SetViewColor(clr);}
|
||||
tab1->AddChild( ModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
|
||||
ModuleSettingsBox->SetLabel("Module settings");
|
||||
ModuleSettingsBox->SetBorder(B_FANCY_BORDER);
|
||||
{rgb_color clr = {216,216,216,255}; fTab1->SetViewColor(clr);}
|
||||
fTab1->AddChild( fModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
|
||||
fModuleSettingsBox->SetLabel("Module settings");
|
||||
fModuleSettingsBox->SetBorder(B_FANCY_BORDER);
|
||||
|
||||
ListView1 = new BListView(BRect(columns[0],rows[2],columns[1]+3,rows[3]),"ListView1",B_SINGLE_SELECTION_LIST);
|
||||
tab1->AddChild(new BScrollView("scroll_list",ListView1,B_FOLLOW_NONE,0,false,true));
|
||||
commonLookAndFeel(ModuleSettingsBox,false,false);
|
||||
{rgb_color clr = {255,255,255,0}; ListView1->SetViewColor(clr);}
|
||||
ListView1->SetListType(B_SINGLE_SELECTION_LIST);
|
||||
fListView1 = new BListView(BRect(columns[0],rows[2],columns[1]+3,rows[3]),"ListView1",B_SINGLE_SELECTION_LIST);
|
||||
fTab1->AddChild(new BScrollView("scroll_list",fListView1,B_FOLLOW_NONE,0,false,true));
|
||||
commonLookAndFeel(fModuleSettingsBox,false,false);
|
||||
{rgb_color clr = {255,255,255,0}; fListView1->SetViewColor(clr);}
|
||||
fListView1->SetListType(B_SINGLE_SELECTION_LIST);
|
||||
|
||||
// selection message for screensaver list
|
||||
ListView1->SetSelectionMessage( new BMessage( SAVER_SEL ) );
|
||||
fListView1->SetSelectionMessage( new BMessage( kSaver_sel ) );
|
||||
|
||||
tab1->AddChild( TestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (TEST_BTN)));
|
||||
commonLookAndFeel(TestButton,false,true);
|
||||
TestButton->SetLabel("Test");
|
||||
fTab1->AddChild( fTestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (kTest_btn)));
|
||||
commonLookAndFeel(fTestButton,false,true);
|
||||
fTestButton->SetLabel("Test");
|
||||
|
||||
tab1->AddChild( AddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (ADD_BTN)));
|
||||
commonLookAndFeel(AddButton,false,true);
|
||||
AddButton->SetLabel("Add...");
|
||||
fTab1->AddChild( fAddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (kAdd_btn)));
|
||||
commonLookAndFeel(fAddButton,false,true);
|
||||
fAddButton->SetLabel("Add...");
|
||||
|
||||
tab1->AddChild(previewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&prefs));
|
||||
fTab1->AddChild(fPreviewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&fPrefs));
|
||||
populateScreenSaverList();
|
||||
}
|
||||
|
||||
|
||||
// Create the controls for the second tab
|
||||
void ScreenSaverWin::setupTab2(void) {
|
||||
void
|
||||
ScreenSaverWin::setupTab2(void)
|
||||
{
|
||||
font_height stdFontHt;
|
||||
be_plain_font->GetHeight(&stdFontHt);
|
||||
int stringHeight=(int)(stdFontHt.ascent+stdFontHt.descent),sliderHeight=30;
|
||||
int topEdge;
|
||||
{rgb_color clr = {216,216,216,255}; tab2->SetViewColor(clr);}
|
||||
tab2->AddChild( EnableScreenSaverBox = new BBox(BRect(11,13,437,280),"EnableScreenSaverBox"));
|
||||
commonLookAndFeel(EnableScreenSaverBox,false,false);
|
||||
{rgb_color clr = {216,216,216,255}; fTab2->SetViewColor(clr);}
|
||||
fTab2->AddChild( fEnableScreenSaverBox = new BBox(BRect(11,13,437,280),"EnableScreenSaverBox"));
|
||||
commonLookAndFeel(fEnableScreenSaverBox,false,false);
|
||||
|
||||
EnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (TAB2_CHG));
|
||||
EnableScreenSaverBox->SetLabel(EnableCheckbox);
|
||||
EnableScreenSaverBox->SetBorder(B_FANCY_BORDER);
|
||||
fEnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (kTab2_chg));
|
||||
fEnableScreenSaverBox->SetLabel(fEnableCheckbox);
|
||||
fEnableScreenSaverBox->SetBorder(B_FANCY_BORDER);
|
||||
|
||||
// Run Module
|
||||
topEdge=26;
|
||||
EnableScreenSaverBox->AddChild( StringView1 = new BStringView(BRect(21,topEdge,101,topEdge+stringHeight),"StringView1","Run module"));
|
||||
commonLookAndFeel(StringView1,false,false);
|
||||
StringView1->SetText("Run module");
|
||||
StringView1->SetAlignment(B_ALIGN_LEFT);
|
||||
fEnableScreenSaverBox->AddChild( fStringView1 = new BStringView(BRect(21,topEdge,101,topEdge+stringHeight),"StringView1","Run module"));
|
||||
commonLookAndFeel(fStringView1,false,false);
|
||||
fStringView1->SetText("Run module");
|
||||
fStringView1->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
EnableScreenSaverBox->AddChild( RunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(TAB2_CHG), 0, 25));
|
||||
RunSlider->SetModificationMessage(new BMessage(TAB2_CHG));
|
||||
commonLookAndFeel(RunSlider,true,true);
|
||||
fEnableScreenSaverBox->AddChild( fRunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(kTab2_chg), 0, 25));
|
||||
fRunSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
||||
commonLookAndFeel(fRunSlider,true,true);
|
||||
float w,h;
|
||||
RunSlider->GetPreferredSize(&w,&h);
|
||||
fRunSlider->GetPreferredSize(&w,&h);
|
||||
sliderHeight=(int)h;
|
||||
|
||||
// Turn Off
|
||||
topEdge+=sliderHeight;
|
||||
EnableScreenSaverBox->AddChild( TurnOffScreenCheckBox = new BCheckBox(BRect(9,topEdge,107,topEdge+stringHeight),"TurnOffScreenCheckBox","Turn off screen", new BMessage (TAB2_CHG)));
|
||||
commonLookAndFeel(TurnOffScreenCheckBox,false,true);
|
||||
TurnOffScreenCheckBox->SetLabel("Turn off screen");
|
||||
TurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
|
||||
fEnableScreenSaverBox->AddChild( fTurnOffScreenCheckBox = new BCheckBox(BRect(9,topEdge,107,topEdge+stringHeight),"TurnOffScreenCheckBox","Turn off screen", new BMessage (kTab2_chg)));
|
||||
commonLookAndFeel(fTurnOffScreenCheckBox,false,true);
|
||||
fTurnOffScreenCheckBox->SetLabel("Turn off screen");
|
||||
fTurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
|
||||
|
||||
EnableScreenSaverBox->AddChild( TurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(TAB2_CHG), 0, 25));
|
||||
TurnOffSlider->SetModificationMessage(new BMessage(TAB2_CHG));
|
||||
commonLookAndFeel(TurnOffSlider,true,true);
|
||||
fEnableScreenSaverBox->AddChild( fTurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(kTab2_chg), 0, 25));
|
||||
fTurnOffSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
||||
commonLookAndFeel(fTurnOffSlider,true,true);
|
||||
|
||||
// Password
|
||||
topEdge+=sliderHeight;
|
||||
EnableScreenSaverBox->AddChild( PasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (TAB2_CHG)));
|
||||
commonLookAndFeel(PasswordCheckbox,false,true);
|
||||
PasswordCheckbox->SetLabel("Password lock");
|
||||
fEnableScreenSaverBox->AddChild( fPasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (kTab2_chg)));
|
||||
commonLookAndFeel(fPasswordCheckbox,false,true);
|
||||
fPasswordCheckbox->SetLabel("Password lock");
|
||||
|
||||
EnableScreenSaverBox->AddChild( PasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(TAB2_CHG), 0, 25));
|
||||
PasswordSlider->SetModificationMessage(new BMessage(TAB2_CHG));
|
||||
commonLookAndFeel(PasswordSlider,true,true);
|
||||
fEnableScreenSaverBox->AddChild( fPasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(kTab2_chg), 0, 25));
|
||||
fPasswordSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
||||
commonLookAndFeel(fPasswordSlider,true,true);
|
||||
|
||||
topEdge+=sliderHeight;
|
||||
EnableScreenSaverBox->AddChild( PasswordButton = new BButton(BRect(331,topEdge,405,topEdge+25),"PasswordButton","Password...", new BMessage (PWBUTTON)));
|
||||
commonLookAndFeel(PasswordButton,false,true);
|
||||
PasswordButton->SetLabel("Password...");
|
||||
fEnableScreenSaverBox->AddChild( fPasswordButton = new BButton(BRect(331,topEdge,405,topEdge+25),"PasswordButton","Password...", new BMessage (kPwbutton)));
|
||||
commonLookAndFeel(fPasswordButton,false,true);
|
||||
fPasswordButton->SetLabel("Password...");
|
||||
|
||||
// Bottom
|
||||
|
||||
EnableScreenSaverBox->AddChild(fadeNow=new MouseAreaView(BRect(20,205,80,260),"fadeNow"));
|
||||
EnableScreenSaverBox->AddChild(fadeNever=new MouseAreaView(BRect(220,205,280,260),"fadeNever"));
|
||||
fEnableScreenSaverBox->AddChild(fFadeNow=new MouseAreaView(BRect(20,205,80,260),"fadeNow"));
|
||||
fEnableScreenSaverBox->AddChild(fFadeNever=new MouseAreaView(BRect(220,205,280,260),"fadeNever"));
|
||||
|
||||
EnableScreenSaverBox->AddChild( FadeNowString = new BStringView(BRect(85,210,188,222),"FadeNowString","Fade now when"));
|
||||
commonLookAndFeel(FadeNowString,false,false);
|
||||
FadeNowString->SetText("Fade now when");
|
||||
FadeNowString->SetAlignment(B_ALIGN_LEFT);
|
||||
fEnableScreenSaverBox->AddChild( fFadeNowString = new BStringView(BRect(85,210,188,222),"FadeNowString","Fade now when"));
|
||||
commonLookAndFeel(fFadeNowString,false,false);
|
||||
fFadeNowString->SetText("Fade now when");
|
||||
fFadeNowString->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
EnableScreenSaverBox->AddChild( FadeNowString2 = new BStringView(BRect(85,225,188,237),"FadeNowString2","mouse is here"));
|
||||
commonLookAndFeel(FadeNowString2,false,false);
|
||||
FadeNowString2->SetText("mouse is here");
|
||||
FadeNowString2->SetAlignment(B_ALIGN_LEFT);
|
||||
fEnableScreenSaverBox->AddChild( fFadeNowString2 = new BStringView(BRect(85,225,188,237),"FadeNowString2","mouse is here"));
|
||||
commonLookAndFeel(fFadeNowString2,false,false);
|
||||
fFadeNowString2->SetText("mouse is here");
|
||||
fFadeNowString2->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
EnableScreenSaverBox->AddChild( DontFadeString = new BStringView(BRect(285,210,382,222),"DontFadeString","Don't fade when"));
|
||||
commonLookAndFeel(DontFadeString,false,false);
|
||||
DontFadeString->SetText("Don't fade when");
|
||||
DontFadeString->SetAlignment(B_ALIGN_LEFT);
|
||||
fEnableScreenSaverBox->AddChild( fDontFadeString = new BStringView(BRect(285,210,382,222),"DontFadeString","Don't fade when"));
|
||||
commonLookAndFeel(fDontFadeString,false,false);
|
||||
fDontFadeString->SetText("Don't fade when");
|
||||
fDontFadeString->SetAlignment(B_ALIGN_LEFT);
|
||||
|
||||
EnableScreenSaverBox->AddChild( DontFadeString2 = new BStringView(BRect(285,225,382,237),"DontFadeString2","mouse is here"));
|
||||
commonLookAndFeel(DontFadeString2,false,false);
|
||||
DontFadeString2->SetText("mouse is here");
|
||||
DontFadeString2->SetAlignment(B_ALIGN_LEFT);
|
||||
fEnableScreenSaverBox->AddChild( fDontFadeString2 = new BStringView(BRect(285,225,382,237),"DontFadeString2","mouse is here"));
|
||||
commonLookAndFeel(fDontFadeString2,false,false);
|
||||
fDontFadeString2->SetText("mouse is here");
|
||||
fDontFadeString2->SetAlignment(B_ALIGN_LEFT);
|
||||
}
|
||||
|
||||
|
@ -12,27 +12,27 @@ class PreviewView;
|
||||
class ScreenSaverWin: public BWindow {
|
||||
public:
|
||||
ScreenSaverWin(void) : BWindow(BRect(50,50,500,385),"OBOS Screen Saver Preferences",B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) ,
|
||||
fadeState(0),noFadeState(0),
|
||||
sampleView(NULL),
|
||||
tab1(NULL),tab2(NULL),
|
||||
tabView(NULL), ModuleSettingsBox(NULL),
|
||||
previewDisplay(NULL), ListView1(NULL),
|
||||
AddonList(NULL), SelectedAddonFileName(NULL),
|
||||
currentAddon(NULL), TestButton(NULL),
|
||||
AddButton(NULL), EnableScreenSaverBox(NULL),
|
||||
PasswordSlider(NULL), TurnOffSlider(NULL),
|
||||
RunSlider(NULL), StringView1(NULL),
|
||||
EnableCheckbox(NULL), PasswordCheckbox(NULL),
|
||||
TurnOffScreenCheckBox(NULL),
|
||||
TurnOffMinutes(NULL), RunMinutes(NULL),
|
||||
PasswordMinutes(NULL), PasswordButton(NULL),
|
||||
FadeNowString(NULL),
|
||||
FadeNowString2(NULL),
|
||||
DontFadeString(NULL), DontFadeString2(NULL),
|
||||
fadeNow(NULL),fadeNever(NULL),
|
||||
pwWin(NULL),
|
||||
pwMessenger(NULL), filePanel(NULL) ,
|
||||
settingsArea(NULL) {
|
||||
fFadeState(0),fNoFadeState(0),
|
||||
fSampleView(NULL),
|
||||
fTab1(NULL),fTab2(NULL),
|
||||
fTabView(NULL), fModuleSettingsBox(NULL),
|
||||
fPreviewDisplay(NULL), fListView1(NULL),
|
||||
fAddonList(NULL), fSelectedAddonFileName(NULL),
|
||||
fCurrentAddon(NULL), fTestButton(NULL),
|
||||
fAddButton(NULL), fEnableScreenSaverBox(NULL),
|
||||
fPasswordSlider(NULL), fTurnOffSlider(NULL),
|
||||
fRunSlider(NULL), fStringView1(NULL),
|
||||
fEnableCheckbox(NULL), fPasswordCheckbox(NULL),
|
||||
fTurnOffScreenCheckBox(NULL),
|
||||
fTurnOffMinutes(NULL), fRunMinutes(NULL),
|
||||
fPasswordMinutes(NULL), fPasswordButton(NULL),
|
||||
fFadeNowString(NULL),
|
||||
fFadeNowString2(NULL),
|
||||
fDontFadeString(NULL), fDontFadeString2(NULL),
|
||||
fFadeNow(NULL),fFadeNever(NULL),
|
||||
fPwWin(NULL),
|
||||
fPwMessenger(NULL), fFilePanel(NULL) ,
|
||||
fSettingsArea(NULL) {
|
||||
SetupForm();
|
||||
}
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
@ -48,46 +48,46 @@ private:
|
||||
void updateStatus(void);
|
||||
void SaverSelected(void);
|
||||
|
||||
ScreenSaverPrefs prefs;
|
||||
int fadeState,noFadeState;
|
||||
BView *sampleView;
|
||||
ScreenSaverPrefs fPrefs;
|
||||
int fFadeState,fNoFadeState;
|
||||
BView *fSampleView;
|
||||
|
||||
BView *tab1,*tab2;
|
||||
BTabView *tabView;
|
||||
BBox *ModuleSettingsBox;
|
||||
BView *fTab1,*fTab2;
|
||||
BTabView *fTabView;
|
||||
BBox *fModuleSettingsBox;
|
||||
|
||||
PreviewView *previewDisplay;
|
||||
BListView *ListView1;
|
||||
BList *AddonList;
|
||||
BString SelectedAddonFileName;
|
||||
image_id currentAddon;
|
||||
PreviewView *fPreviewDisplay;
|
||||
BListView *fListView1;
|
||||
BList *fAddonList;
|
||||
BString fSelectedAddonFileName;
|
||||
image_id fCurrentAddon;
|
||||
|
||||
BButton *TestButton;
|
||||
BButton *AddButton;
|
||||
BBox *EnableScreenSaverBox;
|
||||
BSlider *PasswordSlider;
|
||||
BSlider *TurnOffSlider;
|
||||
BSlider *RunSlider;
|
||||
BStringView *StringView1;
|
||||
BCheckBox *EnableCheckbox;
|
||||
BCheckBox *PasswordCheckbox;
|
||||
BCheckBox *TurnOffScreenCheckBox;
|
||||
BStringView *TurnOffMinutes;
|
||||
BStringView *RunMinutes;
|
||||
BStringView *PasswordMinutes;
|
||||
BButton *PasswordButton;
|
||||
BStringView *FadeNowString;
|
||||
BStringView *FadeNowString2;
|
||||
BStringView *DontFadeString;
|
||||
BStringView *DontFadeString2;
|
||||
BPicture samplePicture;
|
||||
MouseAreaView *fadeNow,*fadeNever;
|
||||
pwWindow *pwWin;
|
||||
BMessenger *pwMessenger;
|
||||
BButton *fTestButton;
|
||||
BButton *fAddButton;
|
||||
BBox *fEnableScreenSaverBox;
|
||||
BSlider *fPasswordSlider;
|
||||
BSlider *fTurnOffSlider;
|
||||
BSlider *fRunSlider;
|
||||
BStringView *fStringView1;
|
||||
BCheckBox *fEnableCheckbox;
|
||||
BCheckBox *fPasswordCheckbox;
|
||||
BCheckBox *fTurnOffScreenCheckBox;
|
||||
BStringView *fTurnOffMinutes;
|
||||
BStringView *fRunMinutes;
|
||||
BStringView *fPasswordMinutes;
|
||||
BButton *fPasswordButton;
|
||||
BStringView *fFadeNowString;
|
||||
BStringView *fFadeNowString2;
|
||||
BStringView *fDontFadeString;
|
||||
BStringView *fDontFadeString2;
|
||||
BPicture fSamplePicture;
|
||||
MouseAreaView *fFadeNow,*fFadeNever;
|
||||
pwWindow *fPwWin;
|
||||
BMessenger *fPwMessenger;
|
||||
|
||||
BMessage settings;
|
||||
BFilePanel *filePanel;
|
||||
BView *settingsArea;
|
||||
BMessage fSettings;
|
||||
BFilePanel *fFilePanel;
|
||||
BView *fSettingsArea;
|
||||
};
|
||||
|
||||
#endif // _ScreenSaver_H
|
||||
|
@ -3,87 +3,93 @@
|
||||
#include "RadioButton.h"
|
||||
#include "Alert.h"
|
||||
|
||||
void pwWindow::setup(void) {
|
||||
void
|
||||
pwWindow::setup(void)
|
||||
{
|
||||
BView *owner=new BView(Bounds(),"ownerView",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||
owner->SetViewColor(216,216,216);
|
||||
AddChild(owner);
|
||||
useNetwork=new BRadioButton(BRect(15,10,160,20),"useNetwork","Use Network password",new BMessage(BUTTON_CHANGED),B_FOLLOW_NONE);
|
||||
useNetwork->SetValue(1);
|
||||
owner->AddChild(useNetwork);
|
||||
useCustom=new BRadioButton(BRect(30,50,130,60),"useCustom","Use custom password",new BMessage(BUTTON_CHANGED),B_FOLLOW_NONE);
|
||||
fUseNetwork=new BRadioButton(BRect(15,10,160,20),"useNetwork","Use Network password",new BMessage(kButton_changed),B_FOLLOW_NONE);
|
||||
fUseNetwork->SetValue(1);
|
||||
owner->AddChild(fUseNetwork);
|
||||
fUseCustom=new BRadioButton(BRect(30,50,130,60),"fUseCustom","Use custom password",new BMessage(kButton_changed),B_FOLLOW_NONE);
|
||||
|
||||
customBox=new BBox(BRect(10,30,270,105),"custBeBox",B_FOLLOW_NONE);
|
||||
customBox->SetLabel(useCustom);
|
||||
password=new BTextControl(BRect(10,20,250,35),"pwdCntrl","Password:",NULL,B_FOLLOW_NONE);
|
||||
confirm=new BTextControl(BRect(10,45,250,60),"confirmCntrl","Confirm password:",NULL,B_FOLLOW_NONE);
|
||||
password->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
||||
password->SetDivider(90);
|
||||
password->TextView()->HideTyping(true);
|
||||
confirm->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
||||
confirm->SetDivider(90);
|
||||
confirm->TextView()->HideTyping(true);
|
||||
customBox->AddChild(password);
|
||||
customBox->AddChild(confirm);
|
||||
owner->AddChild(customBox);
|
||||
fCustomBox=new BBox(BRect(10,30,270,105),"custBeBox",B_FOLLOW_NONE);
|
||||
fCustomBox->SetLabel(fUseCustom);
|
||||
fPassword=new BTextControl(BRect(10,20,250,35),"pwdCntrl","Password:",NULL,B_FOLLOW_NONE);
|
||||
fConfirm=new BTextControl(BRect(10,45,250,60),"fConfirmCntrl","Confirm fPassword:",NULL,B_FOLLOW_NONE);
|
||||
fPassword->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
||||
fPassword->SetDivider(90);
|
||||
fPassword->TextView()->HideTyping(true);
|
||||
fConfirm->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
|
||||
fConfirm->SetDivider(90);
|
||||
fConfirm->TextView()->HideTyping(true);
|
||||
fCustomBox->AddChild(fPassword);
|
||||
fCustomBox->AddChild(fConfirm);
|
||||
owner->AddChild(fCustomBox);
|
||||
|
||||
done=new BButton(BRect(200,120,275,130),"done","Done",new BMessage (DONE_CLICKED),B_FOLLOW_NONE);
|
||||
cancel=new BButton(BRect(115,120,190,130),"cancel","Cancel",new BMessage (CANCEL_CLICKED),B_FOLLOW_NONE);
|
||||
owner->AddChild(done);
|
||||
owner->AddChild(cancel);
|
||||
done->MakeDefault(true);
|
||||
fDone=new BButton(BRect(200,120,275,130),"done","Done",new BMessage (kDone_clicked),B_FOLLOW_NONE);
|
||||
fCancel=new BButton(BRect(115,120,190,130),"cancel","Cancel",new BMessage (kCancel_clicked),B_FOLLOW_NONE);
|
||||
owner->AddChild(fDone);
|
||||
owner->AddChild(fCancel);
|
||||
fDone->MakeDefault(true);
|
||||
update();
|
||||
}
|
||||
|
||||
void pwWindow::update(void) {
|
||||
useNetPassword=(useCustom->Value()>0);
|
||||
confirm->SetEnabled(useNetPassword);
|
||||
password->SetEnabled(useNetPassword);
|
||||
void
|
||||
pwWindow::update(void)
|
||||
{
|
||||
fUseNetPassword=(fUseCustom->Value()>0);
|
||||
fConfirm->SetEnabled(fUseNetPassword);
|
||||
fPassword->SetEnabled(fUseNetPassword);
|
||||
}
|
||||
|
||||
void pwWindow::MessageReceived(BMessage *message) {
|
||||
|
||||
void
|
||||
pwWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case DONE_CLICKED:
|
||||
if (useCustom->Value())
|
||||
if (strcmp(password->Text(),confirm->Text())) {
|
||||
case kDone_clicked:
|
||||
if (fUseCustom->Value())
|
||||
if (strcmp(fPassword->Text(),fConfirm->Text())) {
|
||||
BAlert *alert=new BAlert("noMatch","Passwords don't match. Try again.","OK");
|
||||
alert->Go();
|
||||
}
|
||||
else {
|
||||
thePassword=password->Text();
|
||||
} else {
|
||||
fThePassword=fPassword->Text();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
password->SetText("");
|
||||
confirm->SetText("");
|
||||
fPassword->SetText("");
|
||||
fConfirm->SetText("");
|
||||
Hide();
|
||||
}
|
||||
break;
|
||||
case CANCEL_CLICKED:
|
||||
password->SetText("");
|
||||
confirm->SetText("");
|
||||
case kCancel_clicked:
|
||||
fPassword->SetText("");
|
||||
fConfirm->SetText("");
|
||||
Hide();
|
||||
break;
|
||||
case BUTTON_CHANGED:
|
||||
case kButton_changed:
|
||||
update();
|
||||
break;
|
||||
case SHOW:
|
||||
case kShow:
|
||||
Show();
|
||||
break;
|
||||
case POPULATE:
|
||||
message->ReplaceString("lockpassword", ((useNetPassword)?"":thePassword));
|
||||
message->ReplaceString("lockmethod", (useNetPassword?"network":"custom"));
|
||||
case kPopulate:
|
||||
message->ReplaceString("lockpassword", ((fUseNetPassword)?"":fThePassword));
|
||||
message->ReplaceString("lockmethod", (fUseNetPassword?"network":"custom"));
|
||||
message->SendReply(message);
|
||||
break;
|
||||
case UTILIZE: {
|
||||
case kUtilize: {
|
||||
BString temp;
|
||||
message->FindString("lockmethod",&temp);
|
||||
useNetPassword=(temp=="custom");
|
||||
if (!useNetPassword) {
|
||||
fUseNetPassword=(temp=="custom");
|
||||
if (!fUseNetPassword) {
|
||||
message->FindString("lockpassword",&temp);
|
||||
thePassword=temp;
|
||||
}
|
||||
break;
|
||||
fThePassword=temp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
|
@ -15,12 +15,12 @@ class pwWindow : public BWindow
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
BRadioButton *useNetwork,*useCustom;
|
||||
BBox *customBox;
|
||||
BTextControl *password,*confirm;
|
||||
BButton *cancel,*done;
|
||||
BString thePassword;
|
||||
bool useNetPassword;
|
||||
BRadioButton *fUseNetwork,*fUseCustom;
|
||||
BBox *fCustomBox;
|
||||
BTextControl *fPassword,*fConfirm;
|
||||
BButton *fCancel,*fDone;
|
||||
BString fThePassword;
|
||||
bool fUseNetPassword;
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,22 +8,30 @@
|
||||
// This is the BDirectWindow subclass that rendering occurs in.
|
||||
// A view is added to it so that BView based screensavers will work.
|
||||
SSAwindow::SSAwindow(BRect frame) : BDirectWindow(frame, "ScreenSaver Window",
|
||||
B_BORDERED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) , saver(NULL) {
|
||||
B_BORDERED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) , fSaver(NULL)
|
||||
{
|
||||
frame.OffsetTo(0,0);
|
||||
view=new BView(frame,"ScreenSaver View",B_FOLLOW_ALL,B_WILL_DRAW);
|
||||
AddChild (view);
|
||||
}
|
||||
fView=new BView(frame,"ScreenSaver View",B_FOLLOW_ALL,B_WILL_DRAW);
|
||||
AddChild (fView);
|
||||
}
|
||||
|
||||
SSAwindow::~SSAwindow() {
|
||||
|
||||
SSAwindow::~SSAwindow()
|
||||
{
|
||||
Hide();
|
||||
Sync();
|
||||
}
|
||||
}
|
||||
|
||||
bool SSAwindow::QuitRequested(void) {
|
||||
|
||||
bool
|
||||
SSAwindow::QuitRequested(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void SSAwindow::DirectConnected(direct_buffer_info *info) {
|
||||
if (saver)
|
||||
saver->DirectConnected(info);
|
||||
}
|
||||
void
|
||||
SSAwindow::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
if (fSaver)
|
||||
fSaver->DirectConnected(info);
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ public:
|
||||
~SSAwindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual void DirectConnected(direct_buffer_info *info);
|
||||
BView *view;
|
||||
void SetSaver(BScreenSaver *s) {saver=s;}
|
||||
void SetSaver(BScreenSaver *s) {fSaver=s;}
|
||||
|
||||
BView *fView;
|
||||
private:
|
||||
BScreenSaver *saver;
|
||||
BScreenSaver *fSaver;
|
||||
};
|
||||
|
@ -15,59 +15,70 @@
|
||||
|
||||
// Start the server application. Set pulse to fire once per second.
|
||||
// Run until the application quits.
|
||||
int main(int, char**) {
|
||||
int main(int, char**)
|
||||
{
|
||||
ScreenSaverApp myApplication;
|
||||
myApplication.Run();
|
||||
return(0);
|
||||
}
|
||||
|
||||
// Construct the server app. Doesn't do much, at this point.
|
||||
ScreenSaverApp::ScreenSaverApp() : BApplication("application/x-vnd.OBOS-ScreenSaverApp"),win(NULL) {
|
||||
blankTime=real_time_clock();
|
||||
ScreenSaverApp::ScreenSaverApp() : BApplication("application/x-vnd.OBOS-ScreenSaverApp"),fWin(NULL)
|
||||
{
|
||||
fBlankTime=real_time_clock();
|
||||
}
|
||||
|
||||
void ScreenSaverApp::ReadyToRun(void) {
|
||||
if (!pref.LoadSettings())
|
||||
|
||||
void
|
||||
ScreenSaverApp::ReadyToRun(void)
|
||||
{
|
||||
if (!fPref.LoadSettings())
|
||||
exit(1);
|
||||
else { // If everything works OK, create a BDirectWindow and start the render thread.
|
||||
BScreen theScreen(B_MAIN_SCREEN_ID);
|
||||
win=new SSAwindow(theScreen.Frame());
|
||||
pww=new pwWindow();
|
||||
thrd=new ScreenSaverThread(win,win->view,&pref);
|
||||
fWin=new SSAwindow(theScreen.Frame());
|
||||
fPww=new pwWindow();
|
||||
fThrd=new ScreenSaverThread(fWin,fWin->fView,&fPref);
|
||||
|
||||
saver=thrd->LoadAddOn();
|
||||
if (!saver)
|
||||
fSaver=fThrd->LoadAddOn();
|
||||
if (!fSaver)
|
||||
exit(1);
|
||||
win->SetSaver(saver);
|
||||
win->SetFullScreen(true);
|
||||
win->Show();
|
||||
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,thrd);
|
||||
resume_thread(threadID);
|
||||
fWin->SetSaver(fSaver);
|
||||
fWin->SetFullScreen(true);
|
||||
fWin->Show();
|
||||
fThreadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,fThrd);
|
||||
resume_thread(fThreadID);
|
||||
HideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSaverApp::ShowPW(void) {
|
||||
win->Lock();
|
||||
suspend_thread(threadID);
|
||||
if (B_OK==win->SetFullScreen(false)) {
|
||||
win->Sync();
|
||||
|
||||
void
|
||||
ScreenSaverApp::ShowPW(void)
|
||||
{
|
||||
fWin->Lock();
|
||||
suspend_thread(fThreadID);
|
||||
if (B_OK==fWin->SetFullScreen(false)) {
|
||||
fWin->Sync();
|
||||
ShowCursor();
|
||||
pww->Show();
|
||||
pww->Sync();
|
||||
fPww->Show();
|
||||
fPww->Sync();
|
||||
}
|
||||
win->Unlock();
|
||||
fWin->Unlock();
|
||||
}
|
||||
|
||||
void ScreenSaverApp::MessageReceived(BMessage *message) {
|
||||
|
||||
void
|
||||
ScreenSaverApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case 'DONE':
|
||||
if (strcmp(pww->GetPassword(),pref.Password())) {
|
||||
if (strcmp(fPww->GetPassword(),fPref.Password())) {
|
||||
beep();
|
||||
pww->Hide();
|
||||
win->SetFullScreen(true);
|
||||
if (threadID)
|
||||
resume_thread(threadID);
|
||||
fPww->Hide();
|
||||
fWin->SetFullScreen(true);
|
||||
if (fThreadID)
|
||||
resume_thread(fThreadID);
|
||||
}
|
||||
else {
|
||||
printf ("Quitting!\n");
|
||||
@ -75,7 +86,7 @@ void ScreenSaverApp::MessageReceived(BMessage *message) {
|
||||
}
|
||||
break;
|
||||
case 'MOO1':
|
||||
if (real_time_clock()-blankTime>pref.PasswordTime())
|
||||
if (real_time_clock()-fBlankTime>fPref.PasswordTime())
|
||||
ShowPW();
|
||||
else
|
||||
Quit();
|
||||
@ -85,11 +96,14 @@ void ScreenSaverApp::MessageReceived(BMessage *message) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool ScreenSaverApp::QuitRequested(void) {
|
||||
if (threadID)
|
||||
kill_thread(threadID);
|
||||
if (thrd)
|
||||
delete thrd;
|
||||
|
||||
|
||||
bool
|
||||
ScreenSaverApp::QuitRequested(void)
|
||||
{
|
||||
if (fThreadID)
|
||||
kill_thread(fThreadID);
|
||||
if (fThrd)
|
||||
delete fThrd;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ public:
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
void ShowPW(void);
|
||||
private:
|
||||
ScreenSaverPrefs pref;
|
||||
SSAwindow *win;
|
||||
BScreenSaver *saver;
|
||||
ScreenSaverThread *thrd;
|
||||
pwWindow *pww;
|
||||
ScreenSaverPrefs fPref;
|
||||
SSAwindow *fWin;
|
||||
BScreenSaver *fSaver;
|
||||
ScreenSaverThread *fThrd;
|
||||
pwWindow *fPww;
|
||||
|
||||
thread_id threadID;
|
||||
uint32 blankTime;
|
||||
thread_id fThreadID;
|
||||
uint32 fBlankTime;
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,28 +3,30 @@
|
||||
#include <stdio.h>
|
||||
#include "Application.h"
|
||||
|
||||
void pwWindow::setup(void) {
|
||||
void
|
||||
pwWindow::setup(void)
|
||||
{
|
||||
BScreen theScreen(B_MAIN_SCREEN_ID);
|
||||
MoveTo((theScreen.Frame().IntegerWidth()-Bounds().IntegerWidth())/2,(theScreen.Frame().IntegerHeight()-Bounds().IntegerHeight())/2);
|
||||
bgd=new BView (Bounds(),"bgdView",0,0);
|
||||
bgd->SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
bgd->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
bgd->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
AddChild(bgd);
|
||||
BRect bounds(bgd->Bounds());
|
||||
fBgd=new BView (Bounds(),"fBgdView",0,0);
|
||||
fBgd->SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
fBgd->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
fBgd->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
AddChild(fBgd);
|
||||
BRect bounds(fBgd->Bounds());
|
||||
bounds.InsetBy(5,5);
|
||||
|
||||
customBox=new BBox(bounds,"custBeBox",B_FOLLOW_NONE);
|
||||
customBox->SetLabel("Unlock screen saver");
|
||||
bgd->AddChild(customBox);
|
||||
fCustomBox=new BBox(bounds,"custBeBox",B_FOLLOW_NONE);
|
||||
fCustomBox->SetLabel("Unlock screen saver");
|
||||
fBgd->AddChild(fCustomBox);
|
||||
|
||||
password=new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter password:",NULL,B_FOLLOW_NONE);
|
||||
password->SetDivider(100);
|
||||
customBox->AddChild(password);
|
||||
fPassword=new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter fPassword:",NULL,B_FOLLOW_NONE);
|
||||
fPassword->SetDivider(100);
|
||||
fCustomBox->AddChild(fPassword);
|
||||
|
||||
unlock=new BButton(BRect(160,70,255,85),"unlock","Unlock",new BMessage ('DONE'),B_FOLLOW_NONE);
|
||||
unlock->SetTarget(NULL,be_app);
|
||||
customBox->AddChild(unlock);
|
||||
unlock->MakeDefault(true);
|
||||
fUnlock=new BButton(BRect(160,70,255,85),"fUnlock","Unlock",new BMessage ('DONE'),B_FOLLOW_NONE);
|
||||
fUnlock->SetTarget(NULL,be_app);
|
||||
fCustomBox->AddChild(fUnlock);
|
||||
fUnlock->MakeDefault(true);
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,15 @@ class pwWindow : public BWindow
|
||||
public:
|
||||
pwWindow (void) : BWindow(BRect(100,100,400,230),"pwView",B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL ,
|
||||
B_NOT_MOVABLE | B_NOT_CLOSABLE |B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS ,
|
||||
B_ALL_WORKSPACES), die(false) {setup();}
|
||||
B_ALL_WORKSPACES), fDie(false) {setup();}
|
||||
void setup(void);
|
||||
bool die;
|
||||
const char *GetPassword(void) {return password->Text();}
|
||||
const char *GetPassword(void) {return fPassword->Text();}
|
||||
|
||||
bool fDie;
|
||||
private:
|
||||
BView *bgd;
|
||||
BBox *customBox;
|
||||
BTextControl *password;
|
||||
BButton *unlock;
|
||||
BView *fBgd;
|
||||
BBox *fCustomBox;
|
||||
BTextControl *fPassword;
|
||||
BButton *fUnlock;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user