Make use of BWindow::CenterIn() for placing the error alert. Partial clean-up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33605 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,15 +58,8 @@ static void
|
|||||||
ErrorAlert(const char* message, status_t err, BWindow *window = NULL)
|
ErrorAlert(const char* message, status_t err, BWindow *window = NULL)
|
||||||
{
|
{
|
||||||
BAlert *alert = new BAlert("", message, "OK");
|
BAlert *alert = new BAlert("", message, "OK");
|
||||||
if (window != NULL) {
|
if (window != NULL)
|
||||||
alert->MoveTo(
|
alert->CenterIn(window->Frame());
|
||||||
window->Frame().left +
|
|
||||||
window->Bounds().right / 2 -
|
|
||||||
alert->Bounds().right / 2,
|
|
||||||
window->Frame().top +
|
|
||||||
window->Bounds().bottom / 2 -
|
|
||||||
alert->Bounds().bottom / 2);
|
|
||||||
}
|
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
|
||||||
printf("%s\n%s [%lx]", message, strerror(err), err);
|
printf("%s\n%s [%lx]", message, strerror(err), err);
|
||||||
@@ -158,19 +151,13 @@ CodyCam::~CodyCam()
|
|||||||
void
|
void
|
||||||
CodyCam::ReadyToRun()
|
CodyCam::ReadyToRun()
|
||||||
{
|
{
|
||||||
/* create the window for the app */
|
|
||||||
fWindow = new VideoWindow(BRect(28, 28, 28, 28),
|
fWindow = new VideoWindow(BRect(28, 28, 28, 28),
|
||||||
(const char*) "CodyCam", B_TITLED_WINDOW,
|
(const char*) "CodyCam", B_TITLED_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
|
||||||
|
|
||||||
/* set up the node connections */
|
|
||||||
status_t status = _SetUpNodes();
|
status_t status = _SetUpNodes();
|
||||||
if (status != B_OK) {
|
if (status != B_OK)
|
||||||
// This error is not needed because _SetUpNodes handles displaying any
|
|
||||||
// errors it runs into.
|
|
||||||
// ErrorAlert("Error setting up nodes", status);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
((VideoWindow*)fWindow)->ApplyControls();
|
((VideoWindow*)fWindow)->ApplyControls();
|
||||||
|
|
||||||
@@ -329,7 +316,6 @@ CodyCam::_SetUpNodes()
|
|||||||
|
|
||||||
|
|
||||||
/* set time sources */
|
/* set time sources */
|
||||||
|
|
||||||
status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node);
|
status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
ErrorAlert("Can't set the timesource for the video source", status);
|
ErrorAlert("Can't set the timesource for the video source", status);
|
||||||
@@ -833,25 +819,35 @@ VideoWindow::_SetUpSettings(const char* filename, const char* dirname)
|
|||||||
{
|
{
|
||||||
fSettings = new Settings(filename, dirname);
|
fSettings = new Settings(filename, dirname);
|
||||||
|
|
||||||
fSettings->Add(fServerSetting = new StringValueSetting("Server", "ftp.my.server",
|
fServerSetting = new StringValueSetting("Server", "ftp.my.server",
|
||||||
"server address expected", ""));
|
"server address expected", "");
|
||||||
fSettings->Add(fLoginSetting = new StringValueSetting("Login", "loginID",
|
fLoginSetting = new StringValueSetting("Login", "loginID",
|
||||||
"login ID expected", ""));
|
"login ID expected", "");
|
||||||
fSettings->Add(fPasswordSetting = new StringValueSetting("Password", "password",
|
fPasswordSetting = new StringValueSetting("Password", "password",
|
||||||
"password expected", ""));
|
"password expected", "");
|
||||||
fSettings->Add(fDirectorySetting = new StringValueSetting("Directory", "web/images",
|
fDirectorySetting = new StringValueSetting("Directory", "web/images",
|
||||||
"destination directory expected", ""));
|
"destination directory expected", "");
|
||||||
fSettings->Add(fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1));
|
fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1);
|
||||||
fSettings->Add(fFilenameSetting = new StringValueSetting("StillImageFilename",
|
fFilenameSetting = new StringValueSetting("StillImageFilename",
|
||||||
"codycam.jpg", "still image filename expected", ""));
|
"codycam.jpg", "still image filename expected", "");
|
||||||
fSettings->Add(fImageFormatSettings = new StringValueSetting("ImageFileFormat",
|
fImageFormatSettings = new StringValueSetting("ImageFileFormat",
|
||||||
"JPEG Image", "image file format expected", ""));
|
"JPEG Image", "image file format expected", "");
|
||||||
fSettings->Add(fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate",
|
fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate",
|
||||||
"Every 5 minutes", kCaptureRate, "capture rate expected",
|
"Every 5 minutes", kCaptureRate, "capture rate expected",
|
||||||
"unrecognized capture rate specified"));
|
"unrecognized capture rate specified");
|
||||||
fSettings->Add(fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient",
|
fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient",
|
||||||
"FTP", kUploadClient, "upload client name expected",
|
"FTP", kUploadClient, "upload client name expected",
|
||||||
"unrecognized upload client specified"));
|
"unrecognized upload client specified");
|
||||||
|
|
||||||
|
fSettings->Add(fServerSetting);
|
||||||
|
fSettings->Add(fLoginSetting);
|
||||||
|
fSettings->Add(fPasswordSetting);
|
||||||
|
fSettings->Add(fDirectorySetting);
|
||||||
|
fSettings->Add(fPassiveFtpSetting);
|
||||||
|
fSettings->Add(fFilenameSetting);
|
||||||
|
fSettings->Add(fImageFormatSettings);
|
||||||
|
fSettings->Add(fCaptureRateSetting);
|
||||||
|
fSettings->Add(fUploadClientSetting);
|
||||||
|
|
||||||
fSettings->TryReadingSettings();
|
fSettings->TryReadingSettings();
|
||||||
}
|
}
|
||||||
@@ -945,3 +941,4 @@ int main() {
|
|||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+76
-72
@@ -1,4 +1,3 @@
|
|||||||
/* CodyCam.h */
|
|
||||||
#ifndef CODYCAM_H
|
#ifndef CODYCAM_H
|
||||||
#define CODYCAM_H
|
#define CODYCAM_H
|
||||||
|
|
||||||
@@ -18,7 +17,6 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BMediaRoster;
|
class BMediaRoster;
|
||||||
|
|
||||||
|
|
||||||
@@ -86,98 +84,104 @@ const char* kUploadClient[] = {
|
|||||||
|
|
||||||
|
|
||||||
class CodyCam : public BApplication {
|
class CodyCam : public BApplication {
|
||||||
public:
|
public:
|
||||||
CodyCam();
|
CodyCam();
|
||||||
virtual ~CodyCam();
|
virtual ~CodyCam();
|
||||||
|
|
||||||
void ReadyToRun();
|
void ReadyToRun();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _SetUpNodes();
|
status_t _SetUpNodes();
|
||||||
void _TearDownNodes();
|
void _TearDownNodes();
|
||||||
|
|
||||||
BMediaRoster* fMediaRoster;
|
BMediaRoster* fMediaRoster;
|
||||||
media_node fTimeSourceNode;
|
media_node fTimeSourceNode;
|
||||||
media_node fProducerNode;
|
media_node fProducerNode;
|
||||||
VideoConsumer* fVideoConsumer;
|
VideoConsumer* fVideoConsumer;
|
||||||
media_output fProducerOut;
|
media_output fProducerOut;
|
||||||
media_input fConsumerIn;
|
media_input fConsumerIn;
|
||||||
BWindow* fWindow;
|
BWindow* fWindow;
|
||||||
port_id fPort;
|
port_id fPort;
|
||||||
BWindow* fVideoControlWindow;
|
BWindow* fVideoControlWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class VideoWindow : public BWindow {
|
class VideoWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
VideoWindow(BRect frame, const char* title, window_type type,
|
VideoWindow(BRect frame, const char* title,
|
||||||
uint32 flags, port_id* consumerport);
|
window_type type, uint32 flags,
|
||||||
~VideoWindow();
|
port_id* consumerport);
|
||||||
|
~VideoWindow();
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
void ApplyControls();
|
void ApplyControls();
|
||||||
|
|
||||||
BView* VideoView();
|
BView* VideoView();
|
||||||
BStringView* StatusLine();
|
BStringView* StatusLine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _BuildCaptureControls(BView* theView);
|
void _BuildCaptureControls(BView* theView);
|
||||||
|
|
||||||
void _SetUpSettings(const char* filename, const char* dirname);
|
void _SetUpSettings(const char* filename,
|
||||||
void _QuitSettings();
|
const char* dirname);
|
||||||
|
void _QuitSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
media_node* fProducer;
|
media_node* fProducer;
|
||||||
port_id* fPortPtr;
|
port_id* fPortPtr;
|
||||||
|
|
||||||
BView* fView;
|
BView* fView;
|
||||||
BView* fVideoView;
|
BView* fVideoView;
|
||||||
|
|
||||||
BTextControl* fFileName;
|
BTextControl* fFileName;
|
||||||
BBox* fCaptureSetupBox;
|
BBox* fCaptureSetupBox;
|
||||||
BMenu* fCaptureRateMenu;
|
BMenu* fCaptureRateMenu;
|
||||||
BMenuField* fCaptureRateSelector;
|
BMenuField* fCaptureRateSelector;
|
||||||
BMenu* fImageFormatMenu;
|
BMenu* fImageFormatMenu;
|
||||||
BMenuField* fImageFormatSelector;
|
BMenuField* fImageFormatSelector;
|
||||||
BMenu* fUploadClientMenu;
|
BMenu* fUploadClientMenu;
|
||||||
BMenuField* fUploadClientSelector;
|
BMenuField* fUploadClientSelector;
|
||||||
BBox* fFtpSetupBox;
|
BBox* fFtpSetupBox;
|
||||||
BTextControl* fServerName;
|
BTextControl* fServerName;
|
||||||
BTextControl* fLoginId;
|
BTextControl* fLoginId;
|
||||||
BTextControl* fPassword;
|
BTextControl* fPassword;
|
||||||
BTextControl* fDirectory;
|
BTextControl* fDirectory;
|
||||||
BCheckBox* fPassiveFtp;
|
BCheckBox* fPassiveFtp;
|
||||||
BBox* fStatusBox;
|
BBox* fStatusBox;
|
||||||
BStringView* fStatusLine;
|
BStringView* fStatusLine;
|
||||||
|
|
||||||
ftp_msg_info fFtpInfo;
|
ftp_msg_info fFtpInfo;
|
||||||
|
|
||||||
Settings* fSettings;
|
Settings* fSettings;
|
||||||
StringValueSetting* fServerSetting;
|
|
||||||
StringValueSetting* fLoginSetting;
|
StringValueSetting* fServerSetting;
|
||||||
StringValueSetting* fPasswordSetting;
|
StringValueSetting* fLoginSetting;
|
||||||
StringValueSetting* fDirectorySetting;
|
StringValueSetting* fPasswordSetting;
|
||||||
BooleanValueSetting* fPassiveFtpSetting;
|
StringValueSetting* fDirectorySetting;
|
||||||
StringValueSetting* fFilenameSetting;
|
BooleanValueSetting* fPassiveFtpSetting;
|
||||||
StringValueSetting* fImageFormatSettings;
|
StringValueSetting* fFilenameSetting;
|
||||||
EnumeratedStringValueSetting* fUploadClientSetting;
|
StringValueSetting* fImageFormatSettings;
|
||||||
EnumeratedStringValueSetting* fCaptureRateSetting;
|
|
||||||
|
EnumeratedStringValueSetting* fUploadClientSetting;
|
||||||
|
EnumeratedStringValueSetting* fCaptureRateSetting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ControlWindow : public BWindow {
|
class ControlWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ControlWindow(const BRect& frame, BView* controls, media_node node);
|
ControlWindow(const BRect& frame, BView* controls,
|
||||||
void MessageReceived(BMessage* message);
|
media_node node);
|
||||||
bool QuitRequested();
|
void MessageReceived(BMessage* message);
|
||||||
|
bool QuitRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView* fView;
|
BView* fView;
|
||||||
media_node fNode;
|
media_node fNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CODYCAM_H
|
#endif // CODYCAM_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user