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