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:
Michael Phipps
2004-05-03 22:41:30 +00:00
parent 5f1aaa70ce
commit f141dd5709
21 changed files with 768 additions and 585 deletions
+62 -22
View File
@@ -1,7 +1,9 @@
#ifndef __CONSTANTS__
#define __CONSTANTS__
static const char *times[]={"30 seconds", "1 minute", "1 minute 30 seconds",
int secondsToSlider(int val);
static const char *kTimes[]={"30 seconds", "1 minute", "1 minute 30 seconds",
"2 minutes", "2 minutes 30 seconds", "3 minutes",
"4 minutes", "5 minutes", "6 minutes",
"7 minutes", "8 minutes", "9 minutes",
@@ -11,7 +13,7 @@ static const char *times[]={"30 seconds", "1 minute", "1 minute 30 s
"2 hours", "2 hours 30 minutes", "3 hours",
"4 hours", "5 hours"};
static const int timeInSeconds[]={ 30, 60, 90,
static const int kTimeInSeconds[]={ 30, 60, 90,
120, 150, 180,
240, 300, 360,
420, 480, 540,
@@ -21,28 +23,66 @@ static const int timeInSeconds[]={ 30, 60, 90,
7200, 9000, 10800,
14400, 18000};
int secondsToSlider(int);
inline BPoint
scaleDirect(float x, float y,BRect area)
{
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
}
const int TAB1_CHG ='TAB1';
const int TAB2_CHG ='TAB2';
const int PWBUTTON ='PWBT';
const int DONE_CLICKED ='DONE';
const int CANCEL_CLICKED ='CNCL';
const int BUTTON_CHANGED ='BTNC';
const int SHOW ='SHOW';
const int POPULATE ='POPU';
const int UTILIZE ='UTIL';
const int SAVER_SEL ='SSEL';
const int TEST_BTN ='TEST';
const int ADD_BTN ='ADD ';
const int UPDATELIST ='UPDL';
const rgb_color black = {0,0,0,0};
const rgb_color darkGrey = {150,150,150,0};
const rgb_color grey = {200,200,200,0};
const rgb_color lightBlue = {200,200,255,0};
const rgb_color lightGreen = {255,200,200,0};
const rgb_color red = {255,100,100,0};
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area)
{
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
}
static const float kPositionalX[]= {0,.1,.25,.3,.7,.75,.9,1.0};
static const float kPositionalY[]= {0,.1,.7,.8,.9,1.0};
inline BPoint
scale(int x, int y,BRect area)
{
return scaleDirect(kPositionalX[x],kPositionalY[y],area);
}
inline BRect
scale(int x1, int x2, int y1, int y2,BRect area)
{
return scaleDirect(kPositionalX[x1],kPositionalX[x2],kPositionalY[y1],kPositionalY[y2],area);
}
inline BPoint
scale3(int x, int y,BRect area,bool invertX,bool invertY)
{
float arrowX[]= {0,.25,.5,.66667,.90,.9};
float arrowY[]= {0,.15,.25,.3333333,.6666667,1.0};
return scaleDirect(((invertX)?1-arrowX[x]:arrowX[x]),((invertY)?1-arrowY[y]:arrowY[y]),area);
}
const int kTab1_chg ='TAB1';
const int kTab2_chg ='TAB2';
const int kPwbutton ='PWBT';
const int kDone_clicked ='DONE';
const int kCancel_clicked ='CNCL';
const int kButton_changed ='BTNC';
const int kShow ='SHOW';
const int kPopulate ='POPU';
const int kUtilize ='UTIL';
const int kSaver_sel ='SSEL';
const int kTest_btn ='TEST';
const int kAdd_btn ='ADD ';
const int kUpdatelist ='UPDL';
const rgb_color kBlack = {0,0,0,0};
const rgb_color kDarkGrey = {150,150,150,0};
const rgb_color kGrey = {200,200,200,0};
const rgb_color kLightBlue = {200,200,255,0};
const rgb_color kLightGreen = {255,200,200,0};
const rgb_color kRed = {255,100,100,0};
#endif
+46 -71
View File
@@ -5,48 +5,27 @@
#include <Shape.h>
#include <stdio.h>
inline BPoint scaleDirect(float x, float y,BRect area) {
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
}
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area) {
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
}
float positionalX[]= {0,.1,.25,.3,.7,.75,.9,1.0};
float positionalY[]= {0,.1,.7,.8,.9,1.0};
inline BPoint scale(int x, int y,BRect area) { return scaleDirect(positionalX[x],positionalY[y],area); }
inline BRect scale(int x1, int x2, int y1, int y2,BRect area) { return scaleDirect(positionalX[x1],positionalX[x2],positionalY[y1],positionalY[y2],area); }
int secondsToSlider(int val) {
int count=sizeof(timeInSeconds)/sizeof(int);
int t;
for (t=0;t<count;t++)
if (timeInSeconds[t]==val)
return t;
return -1;
}
void MouseAreaView::Draw(BRect update) {
void
MouseAreaView::Draw(BRect update)
{
SetViewColor(216,216,216);
// Top of monitor
SetHighColor(grey);
SetHighColor(kGrey);
FillRoundRect(scale(0,7,0,3,Bounds()),4,4);
SetHighColor(black);
SetHighColor(kBlack);
StrokeRoundRect(scale(0,7,0,3,Bounds()),4,4);
SetHighColor(lightBlue);
screenArea=scale(1,6,1,2,Bounds());
FillRect(screenArea);
SetHighColor(darkGrey);
StrokeRect(screenArea);
SetHighColor(kLightBlue);
fScreenArea=scale(1,6,1,2,Bounds());
FillRect(fScreenArea);
SetHighColor(kDarkGrey);
StrokeRect(fScreenArea);
// Base of monitor
SetHighColor(grey);
SetHighColor(kGrey);
FillTriangle(scale(1,5,Bounds()),scale(3,4,Bounds()),scale(3,5,Bounds()));
FillTriangle(scale(4,5,Bounds()),scale(4,4,Bounds()),scale(6,5,Bounds()));
FillRect(scale(3,4,4,5,Bounds()));
FillRect(scale(3,4,3,4,Bounds()));
SetHighColor(black);
SetHighColor(kBlack);
StrokeRect(scale(3,4,3,4,Bounds()));
StrokeLine(scale(2,4,Bounds()),scale(1,5,Bounds()));
StrokeLine(scale(6,5,Bounds()),scale(1,5,Bounds()));
@@ -54,33 +33,32 @@ void MouseAreaView::Draw(BRect update) {
DrawArrow();
}
float arrowX[]= {0,.25,.5,.66667,.90,.9};
float arrowY[]= {0,.15,.25,.3333333,.6666667,1.0};
inline BPoint scale3(int x, int y,BRect area,bool invertX,bool invertY) {
return scaleDirect(((invertX)?1-arrowX[x]:arrowX[x]),((invertY)?1-arrowY[y]:arrowY[y]),area); }
BRect getArrowSize(BRect area,bool isCentered)
BRect
getArrowSize(BRect area,bool isCentered)
{
int size=area.IntegerWidth();
int temp=area.IntegerHeight();
if (temp<size)
size=temp;
size/=3;
BRect foo(0,0,size,size);
int areaWidth=area.IntegerWidth();
int areaHeight=area.IntegerHeight();
if (areaHeight<areaWidth)
areaWidth=areaHeight;
areaWidth/=3;
BRect foo(0,0,areaWidth,areaWidth);
if (isCentered)
foo.OffsetBy(area.left+area.Width()/2-(size/2),area.top+area.Height()/2-(size/2));
foo.OffsetBy(area.left+area.Width()/2-(areaWidth/2),area.top+area.Height()/2-(areaWidth/2));
return (foo);
}
void MouseAreaView::DrawArrow(void) {
if (currentDirection!=NONE) {
BRect area(getArrowSize(screenArea,false));
bool invertX=(currentDirection==UPRIGHT||currentDirection==DOWNRIGHT);
bool invertY=(currentDirection==UPRIGHT||currentDirection==UPLEFT);
void
MouseAreaView::DrawArrow(void)
{
if (fCurrentDirection!=NONE) {
BRect area(getArrowSize(fScreenArea,false));
bool invertX=(fCurrentDirection==UPRIGHT||fCurrentDirection==DOWNRIGHT);
bool invertY=(fCurrentDirection==UPRIGHT||fCurrentDirection==UPLEFT);
float size=area.Width();
MovePenTo(((invertX)?screenArea.right-size-2:2+screenArea.left),((!invertY)?screenArea.bottom-size-2:2+screenArea.top));
MovePenTo(((invertX)?fScreenArea.right-size-2:2+fScreenArea.left),((!invertY)?fScreenArea.bottom-size-2:2+fScreenArea.top));
BShape arrow;
arrow.MoveTo(scale3(0,1,area,invertX,invertY));
arrow.LineTo(scale3(0,5,area,invertX,invertY));
@@ -91,34 +69,31 @@ void MouseAreaView::DrawArrow(void) {
arrow.LineTo(scale3(1,2,area,invertX,invertY));
arrow.LineTo(scale3(0,1,area,invertX,invertY));
arrow.Close();
SetHighColor(black);
SetHighColor(kBlack);
FillShape(&arrow,B_SOLID_HIGH);
}
else {
// PushState();
BRect area(getArrowSize(screenArea,true));
SetHighColor(red);
} else {
BRect area(getArrowSize(fScreenArea,true));
SetHighColor(kRed);
SetPenSize(2);
StrokeEllipse(area);
StrokeLine(BPoint(area.right,area.top),BPoint(area.left,area.bottom));
// PopState();
}
}
}
void MouseAreaView::MouseUp(BPoint point) {
if (screenArea.Contains(point)) {
if (getArrowSize(screenArea,true).Contains(point))
currentDirection=NONE;
void MouseAreaView::MouseUp(BPoint point)
{
if (fScreenArea.Contains(point)) {
if (getArrowSize(fScreenArea,true).Contains(point))
fCurrentDirection=NONE;
else {
float centerX=screenArea.left+(screenArea.Width()/2);
float centerY=screenArea.top+(screenArea.Height()/2);
float centerX=fScreenArea.left+(fScreenArea.Width()/2);
float centerY=fScreenArea.top+(fScreenArea.Height()/2);
if (point.x<centerX)
currentDirection=((point.y<centerY)?UPLEFT:DOWNLEFT);
fCurrentDirection=((point.y<centerY)?UPLEFT:DOWNLEFT);
else
currentDirection=((point.y<centerY)?UPRIGHT:DOWNRIGHT);
fCurrentDirection=((point.y<centerY)?UPRIGHT:DOWNRIGHT);
}
Draw(screenArea);
}
Draw(fScreenArea);
}
}
+5 -5
View File
@@ -6,14 +6,14 @@ class MouseAreaView : public BView
public:
MouseAreaView(BRect frame, const char *name) : BView (frame,name,B_FOLLOW_NONE,B_WILL_DRAW)
{ SetViewColor(216,216,216);
currentDirection=NONE;}
fCurrentDirection=NONE;}
virtual void Draw(BRect update);
virtual void MouseUp(BPoint point);
void DrawArrow(void);
inline arrowDirection getDirection(void) {return currentDirection;}
void setDirection(arrowDirection direction) {currentDirection=direction;Draw(BRect (0,0,100,100));}
inline arrowDirection getDirection(void) {return fCurrentDirection;}
void setDirection(arrowDirection direction) {fCurrentDirection=direction;Draw(BRect (0,0,100,100));}
private:
BRect screenArea;
arrowDirection currentDirection;
BRect fScreenArea;
arrowDirection fCurrentDirection;
};
+46 -33
View File
@@ -9,53 +9,67 @@
#include <Screen.h>
#include <String.h>
inline BPoint scaleDirect(float x, float y,BRect area) {
return BPoint(area.Width()*x+area.left,area.Height()*y+area.top);
static float sampleX[]= {0,.05,.15,.7,.725,.8,.825,.85,.950,1.0};
static float sampleY[]= {0,.05,.90,.95,.966,.975,1.0};
inline BPoint
scale2(int x, int y,BRect area)
{
return scaleDirect(sampleX[x],sampleY[y],area);
}
inline BRect scaleDirect (float x1,float x2,float y1,float y2,BRect area) {
return BRect(area.Width()*x1+area.left,area.Height()*y1+area.top, area.Width()*x2+area.left,area.Height()*y2+area.top);
inline BRect
scale2(int x1, int x2, int y1, int y2,BRect area)
{
return scaleDirect(sampleX[x1],sampleX[x2],sampleY[y1],sampleY[y2],area);
}
float sampleX[]= {0,.05,.15,.7,.725,.8,.825,.85,.950,1.0};
float sampleY[]= {0,.05,.90,.95,.966,.975,1.0};
inline BPoint scale2(int x, int y,BRect area) { return scaleDirect(sampleX[x],sampleY[y],area); }
inline BRect scale2(int x1, int x2, int y1, int y2,BRect area) { return scaleDirect(sampleX[x1],sampleX[x2],sampleY[y1],sampleY[y2],area); }
PreviewView::PreviewView(BRect frame, const char *name,ScreenSaverPrefs *prefp)
: BView (frame,name,B_FOLLOW_NONE,B_WILL_DRAW),
saver (NULL),configView(NULL),sst(NULL),threadID(0),prefPtr(prefp) {
fSaver (NULL),fConfigView(NULL),fSst(NULL),fThreadID(-1),fPrefPtr(prefp)
{
SetViewColor(216,216,216);
}
PreviewView::~PreviewView() {
if (threadID)
kill_thread(threadID);
PreviewView::~PreviewView()
{
if (fThreadID>=0)
kill_thread(fThreadID);
}
void PreviewView::SetScreenSaver(BString name) {
if (threadID)
kill_thread(threadID);
if (sst)
delete sst;
if (configView) {
RemoveChild(configView);
delete configView;
}
configView=new BView(scale2(1,8,1,2,Bounds()),"previewArea",B_FOLLOW_NONE,B_WILL_DRAW);
configView->SetViewColor(0,0,0);
AddChild(configView);
sst=new ScreenSaverThread(Window(),configView,prefPtr);
saver=sst->LoadAddOn();
if (saver) {
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,sst);
resume_thread(threadID);
void
PreviewView::SetScreenSaver(BString name)
{
if (fThreadID>=0) {
kill_thread(fThreadID);
fThreadID=-1;
}
if (fSst)
delete fSst;
if (fConfigView) {
RemoveChild(fConfigView);
delete fConfigView;
}
fConfigView=new BView(scale2(1,8,1,2,Bounds()),"previewArea",B_FOLLOW_NONE,B_WILL_DRAW);
fConfigView->SetViewColor(0,0,0);
AddChild(fConfigView);
fSst=new ScreenSaverThread(Window(),fConfigView,fPrefPtr);
fSaver=fSst->LoadAddOn();
if (fSaver) {
fThreadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,fSst);
resume_thread(fThreadID);
}
}
void PreviewView::Draw(BRect update) {
void
PreviewView::Draw(BRect update)
{
SetViewColor(216,216,216);
SetHighColor(184,184,184);
@@ -65,8 +79,7 @@ void PreviewView::Draw(BRect update) {
SetHighColor(96,96,96);
StrokeRoundRect(scale2(2,7,3,6,Bounds()),2,2);// control console outline
StrokeRoundRect(scale2(0,9,0,3,Bounds()),4,4); // Outline outer shape
SetHighColor(black);
// FillRoundRect(scale2(1,8,1,2,Bounds()),4,4);// Screen itself
SetHighColor(kBlack);
SetHighColor(184,184,184);
BRect outerShape=scale2(2,7,2,6,Bounds());
+6 -6
View File
@@ -12,13 +12,13 @@ public:
~PreviewView();
void Draw(BRect update);
void SetScreenSaver(BString name);
BScreenSaver *ScreenSaver(void) {return saver;}
BScreenSaver *ScreenSaver(void) {return fSaver;}
private:
BScreenSaver* saver;
BView *configView;
ScreenSaverThread *sst;
thread_id threadID;
ScreenSaverPrefs *prefPtr;
BScreenSaver* fSaver;
BView *fConfigView;
ScreenSaverThread *fSst;
thread_id fThreadID;
ScreenSaverPrefs *fPrefPtr;
}; // end class PreviewView
+15 -6
View File
@@ -7,15 +7,21 @@
const char *APP_SIG = "application/x-vnd.OBOS.ScreenSaver";
ScreenSaverPrefsApp::~ScreenSaverPrefsApp(void) {
ScreenSaverPrefsApp::~ScreenSaverPrefsApp(void)
{
}
ScreenSaverPrefsApp::ScreenSaverPrefsApp(void) : BApplication(APP_SIG) {
ScreenSaverPrefsApp::ScreenSaverPrefsApp(void) : BApplication(APP_SIG)
{
m_MainForm = new ScreenSaverWin();
m_MainForm->Show();
}
void ScreenSaverPrefsApp::RefsReceived(BMessage *msg) {
void
ScreenSaverPrefsApp::RefsReceived(BMessage *msg)
{
entry_ref ref;
BEntry e;
BPath p;
@@ -26,19 +32,22 @@ void ScreenSaverPrefsApp::RefsReceived(BMessage *msg) {
char temp[2*B_PATH_NAME_LENGTH];
sprintf (temp,"cp %s '/boot/home/config/add-ons/Screen Savers/'\n",p.Path());
system(temp);
m_MainForm->PostMessage(new BMessage(UPDATELIST));
m_MainForm->PostMessage(new BMessage(kUpdatelist));
}
void ScreenSaverPrefsApp::MessageReceived(BMessage *message) {
void ScreenSaverPrefsApp::MessageReceived(BMessage *message)
{
switch(message->what) {
case B_READY_TO_RUN:
break;
default: {
BApplication::MessageReceived(message);
}
}
}
}
int main(void) {
ScreenSaverPrefsApp app;
app.Run();
+215 -174
View File
@@ -24,52 +24,70 @@ const int32 zero=0;
void drawPositionalMonitor(BView *view,BRect areaToDrawIn,int state);
BView *drawSampleMonitor(BView *view, BRect area);
int
secondsToSlider(int val)
{
int count=sizeof(kTimeInSeconds)/sizeof(int);
for (int t=0;t<count;t++)
if (kTimeInSeconds[t]==val)
return t;
return -1;
}
struct SSListItem {
BString fileName;
BString displayName;
};
void ScreenSaverWin::SaverSelected(void) {
if (ListView1->CurrentSelection()>=0) {
void
ScreenSaverWin::SaverSelected(void)
{
if (fListView1->CurrentSelection()>=0) {
SSListItem* listItem;
if (previewDisplay->ScreenSaver())
previewDisplay->ScreenSaver()->StopConfig();
listItem = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()));
if (fPreviewDisplay->ScreenSaver())
fPreviewDisplay->ScreenSaver()->StopConfig();
listItem = reinterpret_cast<SSListItem*>(fAddonList->ItemAt(fListView1->CurrentSelection()));
BString settingsMsgName(listItem->fileName);
previewDisplay->SetScreenSaver(settingsMsgName);
if (settingsArea) {
ModuleSettingsBox->RemoveChild(settingsArea);
delete settingsArea;
}
BRect bnds=ModuleSettingsBox->Bounds();
fPreviewDisplay->SetScreenSaver(settingsMsgName);
if (fSettingsArea) {
fModuleSettingsBox->RemoveChild(fSettingsArea);
delete fSettingsArea;
}
BRect bnds=fModuleSettingsBox->Bounds();
bnds.InsetBy(5,10);
settingsArea=new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
settingsArea->SetViewColor(216,216,216);
ModuleSettingsBox->AddChild(settingsArea);
fSettingsArea=new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
fSettingsArea->SetViewColor(216,216,216);
fModuleSettingsBox->AddChild(fSettingsArea);
if (previewDisplay->ScreenSaver())
previewDisplay->ScreenSaver()->StartConfig(settingsArea);
if (fPreviewDisplay->ScreenSaver())
fPreviewDisplay->ScreenSaver()->StartConfig(fSettingsArea);
}
}
void ScreenSaverWin::MessageReceived(BMessage *msg) {
void
ScreenSaverWin::MessageReceived(BMessage *msg)
{
switch(msg->what) {
case PWBUTTON:
pwMessenger->SendMessage(SHOW);
case kPwbutton:
fPwMessenger->SendMessage(kShow);
break;
case B_QUIT_REQUESTED:
be_app->PostMessage(B_QUIT_REQUESTED);
break;
case SAVER_SEL:
case kSaver_sel:
SaverSelected();
break;
case TEST_BTN:
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",prefs.GetSettings());
case kTest_btn:
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",fPrefs.GetSettings());
break;
case ADD_BTN:
filePanel->Show();
case kAdd_btn:
fFilePanel->Show();
break;
case UPDATELIST:
case kUpdatelist:
populateScreenSaverList();
break;
}
@@ -77,54 +95,61 @@ void ScreenSaverWin::MessageReceived(BMessage *msg) {
BWindow::MessageReceived(msg);
}
bool ScreenSaverWin::QuitRequested() {
bool
ScreenSaverWin::QuitRequested()
{
updateStatus();
be_app->PostMessage(B_QUIT_REQUESTED);
return(true);
}
void ScreenSaverWin::updateStatus(void) {
void
ScreenSaverWin::updateStatus(void)
{
DisableUpdates();
// Policy - enable and disable controls as per checkboxes, etc
PasswordCheckbox->SetEnabled(EnableCheckbox->Value());
TurnOffScreenCheckBox->SetEnabled(EnableCheckbox->Value());
RunSlider->SetEnabled(EnableCheckbox->Value());
TurnOffSlider->SetEnabled(EnableCheckbox->Value() && TurnOffScreenCheckBox->Value());
TurnOffSlider->SetEnabled(false); // This never seems to turn on in the R5 version
TurnOffScreenCheckBox->SetEnabled(false);
PasswordSlider->SetEnabled(EnableCheckbox->Value() && PasswordCheckbox->Value());
PasswordButton->SetEnabled(EnableCheckbox->Value() && PasswordCheckbox->Value());
fPasswordCheckbox->SetEnabled(fEnableCheckbox->Value());
fTurnOffScreenCheckBox->SetEnabled(fEnableCheckbox->Value());
fRunSlider->SetEnabled(fEnableCheckbox->Value());
fTurnOffSlider->SetEnabled(fEnableCheckbox->Value() && fTurnOffScreenCheckBox->Value());
fTurnOffSlider->SetEnabled(false); // This never seems to turn on in the R5 version
fTurnOffScreenCheckBox->SetEnabled(false);
fPasswordSlider->SetEnabled(fEnableCheckbox->Value() && fPasswordCheckbox->Value());
fPasswordButton->SetEnabled(fEnableCheckbox->Value() && fPasswordCheckbox->Value());
// Set the labels for the sliders
RunSlider->SetLabel(times[RunSlider->Value()]);
TurnOffSlider->SetLabel(times[TurnOffSlider->Value()]);
PasswordSlider->SetLabel(times[PasswordSlider->Value()]);
fRunSlider->SetLabel(kTimes[fRunSlider->Value()]);
fTurnOffSlider->SetLabel(kTimes[fTurnOffSlider->Value()]);
fPasswordSlider->SetLabel(kTimes[fPasswordSlider->Value()]);
EnableUpdates();
// Update the saved preferences
prefs.SetWindowFrame(Frame());
prefs.SetWindowTab(tabView->Selection());
prefs.SetTimeFlags(EnableCheckbox->Value());
prefs.SetBlankTime(timeInSeconds[RunSlider->Value()]);
prefs.SetOffTime(timeInSeconds[TurnOffSlider->Value()]);
prefs.SetSuspendTime(timeInSeconds[TurnOffSlider->Value()]);
prefs.SetStandbyTime(timeInSeconds[TurnOffSlider->Value()]);
prefs.SetBlankCorner(fadeNow->getDirection());
prefs.SetNeverBlankCorner(fadeNever->getDirection());
prefs.SetLockEnable(PasswordCheckbox->Value());
prefs.SetPasswordTime(timeInSeconds[PasswordSlider->Value()]);
int selection=ListView1->CurrentSelection(0);
//const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
fPrefs.SetWindowFrame(Frame());
fPrefs.SetWindowTab(fTabView->Selection());
fPrefs.SetTimeFlags(fEnableCheckbox->Value());
fPrefs.SetBlankTime(kTimeInSeconds[fRunSlider->Value()]);
fPrefs.SetOffTime(kTimeInSeconds[fTurnOffSlider->Value()]);
fPrefs.SetSuspendTime(kTimeInSeconds[fTurnOffSlider->Value()]);
fPrefs.SetStandbyTime(kTimeInSeconds[fTurnOffSlider->Value()]);
fPrefs.SetBlankCorner(fFadeNow->getDirection());
fPrefs.SetNeverBlankCorner(fFadeNever->getDirection());
fPrefs.SetLockEnable(fPasswordCheckbox->Value());
fPrefs.SetPasswordTime(kTimeInSeconds[fPasswordSlider->Value()]);
int selection=fListView1->CurrentSelection(0);
if (selection>=0)
prefs.SetModuleName(((BStringItem *)(ListView1->ItemAt(selection)))->Text());
fPrefs.SetModuleName(((BStringItem *)(fListView1->ItemAt(selection)))->Text());
// TODO - Tell the password window to update its stuff
BMessage ssState;
if ((previewDisplay->ScreenSaver()) && (previewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
prefs.SetState(&ssState);
prefs.SaveSettings();
if ((fPreviewDisplay->ScreenSaver()) && (fPreviewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
fPrefs.SetState(&ssState);
fPrefs.SaveSettings();
};
void ScreenSaverWin::SetupForm(void) {
filePanel=new BFilePanel();
void
ScreenSaverWin::SetupForm(void)
{
fFilePanel=new BFilePanel();
BRect r;
BView *background;
@@ -138,59 +163,61 @@ void ScreenSaverWin::SetupForm(void) {
// Add the tab view to the background
r.InsetBy(0,3);
tabView = new BTabView(r, "tab_view");
tabView->SetViewColor(216,216,216,0);
r = tabView->Bounds();
fTabView = new BTabView(r, "tab_view");
fTabView->SetViewColor(216,216,216,0);
r = fTabView->Bounds();
r.InsetBy(0,4);
r.bottom -= tabView->TabHeight();
r.bottom -= fTabView->TabHeight();
// Time to load the settings into a message and implement them...
prefs.LoadSettings();
prefs.WindowFrame().PrintToStream();
fPrefs.LoadSettings();
tab = new BTab();
tabView->AddTab(tab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
fTabView->AddTab(fTab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
tab->SetLabel("Fade");
tab = new BTab();
tabView->AddTab(tab1=new BView(r,"Modules",B_FOLLOW_NONE,0), tab);
fTabView->AddTab(fTab1=new BView(r,"Modules",B_FOLLOW_NONE,0), tab);
tab->SetLabel("Modules");
background->AddChild(tabView);
background->AddChild(fTabView);
// Create the controls inside the tabs
setupTab2();
setupTab1();
// Create the password editing window
pwWin=new pwWindow;
pwMessenger=new BMessenger (NULL,pwWin);
pwWin->Run();
fPwWin=new pwWindow;
fPwMessenger=new BMessenger (NULL,fPwWin);
fPwWin->Run();
MoveTo(prefs.WindowFrame().left,prefs.WindowFrame().top);
ResizeTo(prefs.WindowFrame().right-prefs.WindowFrame().left,prefs.WindowFrame().bottom-prefs.WindowFrame().top);
tabView->Select(prefs.WindowTab());
EnableCheckbox->SetValue(prefs.TimeFlags());
RunSlider->SetValue(secondsToSlider(prefs.BlankTime()));
TurnOffSlider->SetValue(secondsToSlider(prefs.OffTime()));
fadeNow->setDirection(prefs.GetBlankCorner());
fadeNever->setDirection(prefs.GetNeverBlankCorner());
PasswordCheckbox->SetValue(prefs.LockEnable());
PasswordSlider->SetValue(secondsToSlider(prefs.PasswordTime()));
const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
long count=ListView1->CountItems();
if (prefs.ModuleName() && ptr)
MoveTo(fPrefs.WindowFrame().left,fPrefs.WindowFrame().top);
ResizeTo(fPrefs.WindowFrame().right-fPrefs.WindowFrame().left,fPrefs.WindowFrame().bottom-fPrefs.WindowFrame().top);
fTabView->Select(fPrefs.WindowTab());
fEnableCheckbox->SetValue(fPrefs.TimeFlags());
fRunSlider->SetValue(secondsToSlider(fPrefs.BlankTime()));
fTurnOffSlider->SetValue(secondsToSlider(fPrefs.OffTime()));
fFadeNow->setDirection(fPrefs.GetBlankCorner());
fFadeNever->setDirection(fPrefs.GetNeverBlankCorner());
fPasswordCheckbox->SetValue(fPrefs.LockEnable());
fPasswordSlider->SetValue(secondsToSlider(fPrefs.PasswordTime()));
const BStringItem **ptr = (const BStringItem **)(fListView1->Items());
long count=fListView1->CountItems();
if (fPrefs.ModuleName() && ptr)
for ( long i = 0; i < count; i++ ) {
if (BString(prefs.ModuleName())==((*ptr++)->Text())) {
ListView1->Select(count=i); // Clever bit here - intentional assignment.
if (BString(fPrefs.ModuleName())==((*ptr++)->Text())) {
fListView1->Select(count=i); // Clever bit here - intentional assignment.
SaverSelected();
ListView1->ScrollToSelection();
}
fListView1->ScrollToSelection();
}
}
updateStatus();
}
// Set the common Look and Feel stuff for a given control
void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
void
commonLookAndFeel(BView *widget,bool isSlider,bool isControl)
{
{rgb_color clr = {216,216,216,255}; widget->SetViewColor(clr);}
if (isSlider) {
BSlider *slid=dynamic_cast<BSlider *>(widget);
@@ -203,7 +230,7 @@ void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
slid->SetLabel("0 minutes");
slid->SetValue(0);
slid->SetEnabled(true);
}
}
{rgb_color clr = {0,0,0,0}; widget->SetHighColor(clr);}
widget->SetFlags(B_WILL_DRAW|B_NAVIGABLE);
widget->SetResizingMode(B_FOLLOW_NONE);
@@ -212,11 +239,14 @@ void commonLookAndFeel(BView *widget,bool isSlider,bool isControl) {
if (isControl) {
BControl *wid=dynamic_cast<BControl *>(widget);
wid->SetEnabled(true);
}
}
}
// Iterate over a directory, adding the directories files to the list
void addScreenSaversToList (directory_which dir, BList *list) {
void
addScreenSaversToList (directory_which dir, BList *list)
{
BPath path;
find_directory(dir,&path);
path.Append("Screen Savers",true);
@@ -236,152 +266,163 @@ void addScreenSaversToList (directory_which dir, BList *list) {
tempListItem->displayName = thisName;
list->AddItem(tempListItem);
}
}
}
// sorting function for SSListItems
int compareSSListItems(const void* left, const void* right) {
int
compareSSListItems(const void* left, const void* right)
{
SSListItem* leftItem = *(SSListItem **)left;
SSListItem* rightItem = *(SSListItem **)right;
return leftItem->displayName.Compare(rightItem->displayName);
}
void ScreenSaverWin::populateScreenSaverList(void) {
if (!AddonList)
AddonList = new BList;
void
ScreenSaverWin::populateScreenSaverList(void)
{
if (!fAddonList)
fAddonList = new BList;
else
for (void *i=AddonList->RemoveItem(zero);i;i=AddonList->RemoveItem(zero))
for (void *i=fAddonList->RemoveItem(zero);i;i=fAddonList->RemoveItem(zero))
delete ((SSListItem *)i);
SSListItem* tempListItem = new SSListItem;
tempListItem->fileName = "";
tempListItem->displayName = "Blackness";
AddonList->AddItem(tempListItem);
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, AddonList );
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, AddonList );
AddonList->SortItems(compareSSListItems);
fAddonList->AddItem(tempListItem);
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, fAddonList );
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, fAddonList );
fAddonList->SortItems(compareSSListItems);
// Add the strings in the BList to a BListView
ListView1->DeselectAll();
for (void *i=ListView1->RemoveItem(zero);i;i=ListView1->RemoveItem(zero))
fListView1->DeselectAll();
for (void *i=fListView1->RemoveItem(zero);i;i=fListView1->RemoveItem(zero))
delete ((BStringItem *)i);
int numItems = AddonList->CountItems();
int numItems = fAddonList->CountItems();
for( int i = 0; i < numItems; ++i ) {
SSListItem* item = (SSListItem*)(AddonList->ItemAt(i));
ListView1->AddItem( new BStringItem(item->displayName.String()) );
}
SSListItem* item = (SSListItem*)(fAddonList->ItemAt(i));
fListView1->AddItem( new BStringItem(item->displayName.String()) );
}
}
// Create the controls for the first tab
void ScreenSaverWin::setupTab1(void) {
void
ScreenSaverWin::setupTab1(void)
{
int columns[4]={15,150,180,430};
int rows[6]={15,120,135,255,263,280};
{rgb_color clr = {216,216,216,255}; tab1->SetViewColor(clr);}
tab1->AddChild( ModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
ModuleSettingsBox->SetLabel("Module settings");
ModuleSettingsBox->SetBorder(B_FANCY_BORDER);
{rgb_color clr = {216,216,216,255}; fTab1->SetViewColor(clr);}
fTab1->AddChild( fModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
fModuleSettingsBox->SetLabel("Module settings");
fModuleSettingsBox->SetBorder(B_FANCY_BORDER);
ListView1 = new BListView(BRect(columns[0],rows[2],columns[1]+3,rows[3]),"ListView1",B_SINGLE_SELECTION_LIST);
tab1->AddChild(new BScrollView("scroll_list",ListView1,B_FOLLOW_NONE,0,false,true));
commonLookAndFeel(ModuleSettingsBox,false,false);
{rgb_color clr = {255,255,255,0}; ListView1->SetViewColor(clr);}
ListView1->SetListType(B_SINGLE_SELECTION_LIST);
fListView1 = new BListView(BRect(columns[0],rows[2],columns[1]+3,rows[3]),"ListView1",B_SINGLE_SELECTION_LIST);
fTab1->AddChild(new BScrollView("scroll_list",fListView1,B_FOLLOW_NONE,0,false,true));
commonLookAndFeel(fModuleSettingsBox,false,false);
{rgb_color clr = {255,255,255,0}; fListView1->SetViewColor(clr);}
fListView1->SetListType(B_SINGLE_SELECTION_LIST);
// selection message for screensaver list
ListView1->SetSelectionMessage( new BMessage( SAVER_SEL ) );
fListView1->SetSelectionMessage( new BMessage( kSaver_sel ) );
tab1->AddChild( TestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (TEST_BTN)));
commonLookAndFeel(TestButton,false,true);
TestButton->SetLabel("Test");
fTab1->AddChild( fTestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (kTest_btn)));
commonLookAndFeel(fTestButton,false,true);
fTestButton->SetLabel("Test");
tab1->AddChild( AddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (ADD_BTN)));
commonLookAndFeel(AddButton,false,true);
AddButton->SetLabel("Add...");
fTab1->AddChild( fAddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (kAdd_btn)));
commonLookAndFeel(fAddButton,false,true);
fAddButton->SetLabel("Add...");
tab1->AddChild(previewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&prefs));
fTab1->AddChild(fPreviewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&fPrefs));
populateScreenSaverList();
}
// Create the controls for the second tab
void ScreenSaverWin::setupTab2(void) {
void
ScreenSaverWin::setupTab2(void)
{
font_height stdFontHt;
be_plain_font->GetHeight(&stdFontHt);
int stringHeight=(int)(stdFontHt.ascent+stdFontHt.descent),sliderHeight=30;
int topEdge;
{rgb_color clr = {216,216,216,255}; tab2->SetViewColor(clr);}
tab2->AddChild( EnableScreenSaverBox = new BBox(BRect(11,13,437,280),"EnableScreenSaverBox"));
commonLookAndFeel(EnableScreenSaverBox,false,false);
{rgb_color clr = {216,216,216,255}; fTab2->SetViewColor(clr);}
fTab2->AddChild( fEnableScreenSaverBox = new BBox(BRect(11,13,437,280),"EnableScreenSaverBox"));
commonLookAndFeel(fEnableScreenSaverBox,false,false);
EnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (TAB2_CHG));
EnableScreenSaverBox->SetLabel(EnableCheckbox);
EnableScreenSaverBox->SetBorder(B_FANCY_BORDER);
fEnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (kTab2_chg));
fEnableScreenSaverBox->SetLabel(fEnableCheckbox);
fEnableScreenSaverBox->SetBorder(B_FANCY_BORDER);
// Run Module
topEdge=26;
EnableScreenSaverBox->AddChild( StringView1 = new BStringView(BRect(21,topEdge,101,topEdge+stringHeight),"StringView1","Run module"));
commonLookAndFeel(StringView1,false,false);
StringView1->SetText("Run module");
StringView1->SetAlignment(B_ALIGN_LEFT);
fEnableScreenSaverBox->AddChild( fStringView1 = new BStringView(BRect(21,topEdge,101,topEdge+stringHeight),"StringView1","Run module"));
commonLookAndFeel(fStringView1,false,false);
fStringView1->SetText("Run module");
fStringView1->SetAlignment(B_ALIGN_LEFT);
EnableScreenSaverBox->AddChild( RunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(TAB2_CHG), 0, 25));
RunSlider->SetModificationMessage(new BMessage(TAB2_CHG));
commonLookAndFeel(RunSlider,true,true);
fEnableScreenSaverBox->AddChild( fRunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(kTab2_chg), 0, 25));
fRunSlider->SetModificationMessage(new BMessage(kTab2_chg));
commonLookAndFeel(fRunSlider,true,true);
float w,h;
RunSlider->GetPreferredSize(&w,&h);
fRunSlider->GetPreferredSize(&w,&h);
sliderHeight=(int)h;
// Turn Off
topEdge+=sliderHeight;
EnableScreenSaverBox->AddChild( TurnOffScreenCheckBox = new BCheckBox(BRect(9,topEdge,107,topEdge+stringHeight),"TurnOffScreenCheckBox","Turn off screen", new BMessage (TAB2_CHG)));
commonLookAndFeel(TurnOffScreenCheckBox,false,true);
TurnOffScreenCheckBox->SetLabel("Turn off screen");
TurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
fEnableScreenSaverBox->AddChild( fTurnOffScreenCheckBox = new BCheckBox(BRect(9,topEdge,107,topEdge+stringHeight),"TurnOffScreenCheckBox","Turn off screen", new BMessage (kTab2_chg)));
commonLookAndFeel(fTurnOffScreenCheckBox,false,true);
fTurnOffScreenCheckBox->SetLabel("Turn off screen");
fTurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
EnableScreenSaverBox->AddChild( TurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(TAB2_CHG), 0, 25));
TurnOffSlider->SetModificationMessage(new BMessage(TAB2_CHG));
commonLookAndFeel(TurnOffSlider,true,true);
fEnableScreenSaverBox->AddChild( fTurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(kTab2_chg), 0, 25));
fTurnOffSlider->SetModificationMessage(new BMessage(kTab2_chg));
commonLookAndFeel(fTurnOffSlider,true,true);
// Password
topEdge+=sliderHeight;
EnableScreenSaverBox->AddChild( PasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (TAB2_CHG)));
commonLookAndFeel(PasswordCheckbox,false,true);
PasswordCheckbox->SetLabel("Password lock");
fEnableScreenSaverBox->AddChild( fPasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (kTab2_chg)));
commonLookAndFeel(fPasswordCheckbox,false,true);
fPasswordCheckbox->SetLabel("Password lock");
EnableScreenSaverBox->AddChild( PasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(TAB2_CHG), 0, 25));
PasswordSlider->SetModificationMessage(new BMessage(TAB2_CHG));
commonLookAndFeel(PasswordSlider,true,true);
fEnableScreenSaverBox->AddChild( fPasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(kTab2_chg), 0, 25));
fPasswordSlider->SetModificationMessage(new BMessage(kTab2_chg));
commonLookAndFeel(fPasswordSlider,true,true);
topEdge+=sliderHeight;
EnableScreenSaverBox->AddChild( PasswordButton = new BButton(BRect(331,topEdge,405,topEdge+25),"PasswordButton","Password...", new BMessage (PWBUTTON)));
commonLookAndFeel(PasswordButton,false,true);
PasswordButton->SetLabel("Password...");
fEnableScreenSaverBox->AddChild( fPasswordButton = new BButton(BRect(331,topEdge,405,topEdge+25),"PasswordButton","Password...", new BMessage (kPwbutton)));
commonLookAndFeel(fPasswordButton,false,true);
fPasswordButton->SetLabel("Password...");
// Bottom
EnableScreenSaverBox->AddChild(fadeNow=new MouseAreaView(BRect(20,205,80,260),"fadeNow"));
EnableScreenSaverBox->AddChild(fadeNever=new MouseAreaView(BRect(220,205,280,260),"fadeNever"));
fEnableScreenSaverBox->AddChild(fFadeNow=new MouseAreaView(BRect(20,205,80,260),"fadeNow"));
fEnableScreenSaverBox->AddChild(fFadeNever=new MouseAreaView(BRect(220,205,280,260),"fadeNever"));
EnableScreenSaverBox->AddChild( FadeNowString = new BStringView(BRect(85,210,188,222),"FadeNowString","Fade now when"));
commonLookAndFeel(FadeNowString,false,false);
FadeNowString->SetText("Fade now when");
FadeNowString->SetAlignment(B_ALIGN_LEFT);
fEnableScreenSaverBox->AddChild( fFadeNowString = new BStringView(BRect(85,210,188,222),"FadeNowString","Fade now when"));
commonLookAndFeel(fFadeNowString,false,false);
fFadeNowString->SetText("Fade now when");
fFadeNowString->SetAlignment(B_ALIGN_LEFT);
EnableScreenSaverBox->AddChild( FadeNowString2 = new BStringView(BRect(85,225,188,237),"FadeNowString2","mouse is here"));
commonLookAndFeel(FadeNowString2,false,false);
FadeNowString2->SetText("mouse is here");
FadeNowString2->SetAlignment(B_ALIGN_LEFT);
fEnableScreenSaverBox->AddChild( fFadeNowString2 = new BStringView(BRect(85,225,188,237),"FadeNowString2","mouse is here"));
commonLookAndFeel(fFadeNowString2,false,false);
fFadeNowString2->SetText("mouse is here");
fFadeNowString2->SetAlignment(B_ALIGN_LEFT);
EnableScreenSaverBox->AddChild( DontFadeString = new BStringView(BRect(285,210,382,222),"DontFadeString","Don't fade when"));
commonLookAndFeel(DontFadeString,false,false);
DontFadeString->SetText("Don't fade when");
DontFadeString->SetAlignment(B_ALIGN_LEFT);
fEnableScreenSaverBox->AddChild( fDontFadeString = new BStringView(BRect(285,210,382,222),"DontFadeString","Don't fade when"));
commonLookAndFeel(fDontFadeString,false,false);
fDontFadeString->SetText("Don't fade when");
fDontFadeString->SetAlignment(B_ALIGN_LEFT);
EnableScreenSaverBox->AddChild( DontFadeString2 = new BStringView(BRect(285,225,382,237),"DontFadeString2","mouse is here"));
commonLookAndFeel(DontFadeString2,false,false);
DontFadeString2->SetText("mouse is here");
DontFadeString2->SetAlignment(B_ALIGN_LEFT);
fEnableScreenSaverBox->AddChild( fDontFadeString2 = new BStringView(BRect(285,225,382,237),"DontFadeString2","mouse is here"));
commonLookAndFeel(fDontFadeString2,false,false);
fDontFadeString2->SetText("mouse is here");
fDontFadeString2->SetAlignment(B_ALIGN_LEFT);
}
+57 -57
View File
@@ -12,27 +12,27 @@ class PreviewView;
class ScreenSaverWin: public BWindow {
public:
ScreenSaverWin(void) : BWindow(BRect(50,50,500,385),"OBOS Screen Saver Preferences",B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) ,
fadeState(0),noFadeState(0),
sampleView(NULL),
tab1(NULL),tab2(NULL),
tabView(NULL), ModuleSettingsBox(NULL),
previewDisplay(NULL), ListView1(NULL),
AddonList(NULL), SelectedAddonFileName(NULL),
currentAddon(NULL), TestButton(NULL),
AddButton(NULL), EnableScreenSaverBox(NULL),
PasswordSlider(NULL), TurnOffSlider(NULL),
RunSlider(NULL), StringView1(NULL),
EnableCheckbox(NULL), PasswordCheckbox(NULL),
TurnOffScreenCheckBox(NULL),
TurnOffMinutes(NULL), RunMinutes(NULL),
PasswordMinutes(NULL), PasswordButton(NULL),
FadeNowString(NULL),
FadeNowString2(NULL),
DontFadeString(NULL), DontFadeString2(NULL),
fadeNow(NULL),fadeNever(NULL),
pwWin(NULL),
pwMessenger(NULL), filePanel(NULL) ,
settingsArea(NULL) {
fFadeState(0),fNoFadeState(0),
fSampleView(NULL),
fTab1(NULL),fTab2(NULL),
fTabView(NULL), fModuleSettingsBox(NULL),
fPreviewDisplay(NULL), fListView1(NULL),
fAddonList(NULL), fSelectedAddonFileName(NULL),
fCurrentAddon(NULL), fTestButton(NULL),
fAddButton(NULL), fEnableScreenSaverBox(NULL),
fPasswordSlider(NULL), fTurnOffSlider(NULL),
fRunSlider(NULL), fStringView1(NULL),
fEnableCheckbox(NULL), fPasswordCheckbox(NULL),
fTurnOffScreenCheckBox(NULL),
fTurnOffMinutes(NULL), fRunMinutes(NULL),
fPasswordMinutes(NULL), fPasswordButton(NULL),
fFadeNowString(NULL),
fFadeNowString2(NULL),
fDontFadeString(NULL), fDontFadeString2(NULL),
fFadeNow(NULL),fFadeNever(NULL),
fPwWin(NULL),
fPwMessenger(NULL), fFilePanel(NULL) ,
fSettingsArea(NULL) {
SetupForm();
}
virtual void MessageReceived(BMessage *message);
@@ -48,46 +48,46 @@ private:
void updateStatus(void);
void SaverSelected(void);
ScreenSaverPrefs prefs;
int fadeState,noFadeState;
BView *sampleView;
ScreenSaverPrefs fPrefs;
int fFadeState,fNoFadeState;
BView *fSampleView;
BView *tab1,*tab2;
BTabView *tabView;
BBox *ModuleSettingsBox;
BView *fTab1,*fTab2;
BTabView *fTabView;
BBox *fModuleSettingsBox;
PreviewView *previewDisplay;
BListView *ListView1;
BList *AddonList;
BString SelectedAddonFileName;
image_id currentAddon;
PreviewView *fPreviewDisplay;
BListView *fListView1;
BList *fAddonList;
BString fSelectedAddonFileName;
image_id fCurrentAddon;
BButton *TestButton;
BButton *AddButton;
BBox *EnableScreenSaverBox;
BSlider *PasswordSlider;
BSlider *TurnOffSlider;
BSlider *RunSlider;
BStringView *StringView1;
BCheckBox *EnableCheckbox;
BCheckBox *PasswordCheckbox;
BCheckBox *TurnOffScreenCheckBox;
BStringView *TurnOffMinutes;
BStringView *RunMinutes;
BStringView *PasswordMinutes;
BButton *PasswordButton;
BStringView *FadeNowString;
BStringView *FadeNowString2;
BStringView *DontFadeString;
BStringView *DontFadeString2;
BPicture samplePicture;
MouseAreaView *fadeNow,*fadeNever;
pwWindow *pwWin;
BMessenger *pwMessenger;
BButton *fTestButton;
BButton *fAddButton;
BBox *fEnableScreenSaverBox;
BSlider *fPasswordSlider;
BSlider *fTurnOffSlider;
BSlider *fRunSlider;
BStringView *fStringView1;
BCheckBox *fEnableCheckbox;
BCheckBox *fPasswordCheckbox;
BCheckBox *fTurnOffScreenCheckBox;
BStringView *fTurnOffMinutes;
BStringView *fRunMinutes;
BStringView *fPasswordMinutes;
BButton *fPasswordButton;
BStringView *fFadeNowString;
BStringView *fFadeNowString2;
BStringView *fDontFadeString;
BStringView *fDontFadeString2;
BPicture fSamplePicture;
MouseAreaView *fFadeNow,*fFadeNever;
pwWindow *fPwWin;
BMessenger *fPwMessenger;
BMessage settings;
BFilePanel *filePanel;
BView *settingsArea;
BMessage fSettings;
BFilePanel *fFilePanel;
BView *fSettingsArea;
};
#endif // _ScreenSaver_H
+57 -51
View File
@@ -3,87 +3,93 @@
#include "RadioButton.h"
#include "Alert.h"
void pwWindow::setup(void) {
void
pwWindow::setup(void)
{
BView *owner=new BView(Bounds(),"ownerView",B_FOLLOW_NONE,B_WILL_DRAW);
owner->SetViewColor(216,216,216);
AddChild(owner);
useNetwork=new BRadioButton(BRect(15,10,160,20),"useNetwork","Use Network password",new BMessage(BUTTON_CHANGED),B_FOLLOW_NONE);
useNetwork->SetValue(1);
owner->AddChild(useNetwork);
useCustom=new BRadioButton(BRect(30,50,130,60),"useCustom","Use custom password",new BMessage(BUTTON_CHANGED),B_FOLLOW_NONE);
fUseNetwork=new BRadioButton(BRect(15,10,160,20),"useNetwork","Use Network password",new BMessage(kButton_changed),B_FOLLOW_NONE);
fUseNetwork->SetValue(1);
owner->AddChild(fUseNetwork);
fUseCustom=new BRadioButton(BRect(30,50,130,60),"fUseCustom","Use custom password",new BMessage(kButton_changed),B_FOLLOW_NONE);
customBox=new BBox(BRect(10,30,270,105),"custBeBox",B_FOLLOW_NONE);
customBox->SetLabel(useCustom);
password=new BTextControl(BRect(10,20,250,35),"pwdCntrl","Password:",NULL,B_FOLLOW_NONE);
confirm=new BTextControl(BRect(10,45,250,60),"confirmCntrl","Confirm password:",NULL,B_FOLLOW_NONE);
password->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
password->SetDivider(90);
password->TextView()->HideTyping(true);
confirm->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
confirm->SetDivider(90);
confirm->TextView()->HideTyping(true);
customBox->AddChild(password);
customBox->AddChild(confirm);
owner->AddChild(customBox);
fCustomBox=new BBox(BRect(10,30,270,105),"custBeBox",B_FOLLOW_NONE);
fCustomBox->SetLabel(fUseCustom);
fPassword=new BTextControl(BRect(10,20,250,35),"pwdCntrl","Password:",NULL,B_FOLLOW_NONE);
fConfirm=new BTextControl(BRect(10,45,250,60),"fConfirmCntrl","Confirm fPassword:",NULL,B_FOLLOW_NONE);
fPassword->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
fPassword->SetDivider(90);
fPassword->TextView()->HideTyping(true);
fConfirm->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
fConfirm->SetDivider(90);
fConfirm->TextView()->HideTyping(true);
fCustomBox->AddChild(fPassword);
fCustomBox->AddChild(fConfirm);
owner->AddChild(fCustomBox);
done=new BButton(BRect(200,120,275,130),"done","Done",new BMessage (DONE_CLICKED),B_FOLLOW_NONE);
cancel=new BButton(BRect(115,120,190,130),"cancel","Cancel",new BMessage (CANCEL_CLICKED),B_FOLLOW_NONE);
owner->AddChild(done);
owner->AddChild(cancel);
done->MakeDefault(true);
fDone=new BButton(BRect(200,120,275,130),"done","Done",new BMessage (kDone_clicked),B_FOLLOW_NONE);
fCancel=new BButton(BRect(115,120,190,130),"cancel","Cancel",new BMessage (kCancel_clicked),B_FOLLOW_NONE);
owner->AddChild(fDone);
owner->AddChild(fCancel);
fDone->MakeDefault(true);
update();
}
void pwWindow::update(void) {
useNetPassword=(useCustom->Value()>0);
confirm->SetEnabled(useNetPassword);
password->SetEnabled(useNetPassword);
void
pwWindow::update(void)
{
fUseNetPassword=(fUseCustom->Value()>0);
fConfirm->SetEnabled(fUseNetPassword);
fPassword->SetEnabled(fUseNetPassword);
}
void pwWindow::MessageReceived(BMessage *message) {
void
pwWindow::MessageReceived(BMessage *message)
{
switch(message->what) {
case DONE_CLICKED:
if (useCustom->Value())
if (strcmp(password->Text(),confirm->Text())) {
case kDone_clicked:
if (fUseCustom->Value())
if (strcmp(fPassword->Text(),fConfirm->Text())) {
BAlert *alert=new BAlert("noMatch","Passwords don't match. Try again.","OK");
alert->Go();
}
else {
thePassword=password->Text();
} else {
fThePassword=fPassword->Text();
Hide();
}
}
else {
password->SetText("");
confirm->SetText("");
fPassword->SetText("");
fConfirm->SetText("");
Hide();
}
break;
case CANCEL_CLICKED:
password->SetText("");
confirm->SetText("");
case kCancel_clicked:
fPassword->SetText("");
fConfirm->SetText("");
Hide();
break;
case BUTTON_CHANGED:
case kButton_changed:
update();
break;
case SHOW:
case kShow:
Show();
break;
case POPULATE:
message->ReplaceString("lockpassword", ((useNetPassword)?"":thePassword));
message->ReplaceString("lockmethod", (useNetPassword?"network":"custom"));
case kPopulate:
message->ReplaceString("lockpassword", ((fUseNetPassword)?"":fThePassword));
message->ReplaceString("lockmethod", (fUseNetPassword?"network":"custom"));
message->SendReply(message);
break;
case UTILIZE: {
case kUtilize: {
BString temp;
message->FindString("lockmethod",&temp);
useNetPassword=(temp=="custom");
if (!useNetPassword) {
fUseNetPassword=(temp=="custom");
if (!fUseNetPassword) {
message->FindString("lockpassword",&temp);
thePassword=temp;
}
break;
fThePassword=temp;
}
break;
}
default:
BWindow::MessageReceived(message);
break;
+6 -6
View File
@@ -15,12 +15,12 @@ class pwWindow : public BWindow
virtual void MessageReceived(BMessage *message);
private:
BRadioButton *useNetwork,*useCustom;
BBox *customBox;
BTextControl *password,*confirm;
BButton *cancel,*done;
BString thePassword;
bool useNetPassword;
BRadioButton *fUseNetwork,*fUseCustom;
BBox *fCustomBox;
BTextControl *fPassword,*fConfirm;
BButton *fCancel,*fDone;
BString fThePassword;
bool fUseNetPassword;
};