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:
Jonas Sundström
2009-10-15 22:09:37 +00:00
parent 51f2ac8647
commit 18ba9ea5c9
2 changed files with 107 additions and 106 deletions
+31 -34
View File
@@ -58,15 +58,8 @@ static void
ErrorAlert(const char* message, status_t err, BWindow *window = NULL)
{
BAlert *alert = new BAlert("", message, "OK");
if (window != NULL) {
alert->MoveTo(
window->Frame().left +
window->Bounds().right / 2 -
alert->Bounds().right / 2,
window->Frame().top +
window->Bounds().bottom / 2 -
alert->Bounds().bottom / 2);
}
if (window != NULL)
alert->CenterIn(window->Frame());
alert->Go();
printf("%s\n%s [%lx]", message, strerror(err), err);
@@ -158,19 +151,13 @@ CodyCam::~CodyCam()
void
CodyCam::ReadyToRun()
{
/* create the window for the app */
fWindow = new VideoWindow(BRect(28, 28, 28, 28),
(const char*) "CodyCam", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
/* set up the node connections */
status_t status = _SetUpNodes();
if (status != B_OK) {
// This error is not needed because _SetUpNodes handles displaying any
// errors it runs into.
// ErrorAlert("Error setting up nodes", status);
if (status != B_OK)
return;
}
((VideoWindow*)fWindow)->ApplyControls();
@@ -329,7 +316,6 @@ CodyCam::_SetUpNodes()
/* set time sources */
status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node);
if (status != B_OK) {
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->Add(fServerSetting = new StringValueSetting("Server", "ftp.my.server",
"server address expected", ""));
fSettings->Add(fLoginSetting = new StringValueSetting("Login", "loginID",
"login ID expected", ""));
fSettings->Add(fPasswordSetting = new StringValueSetting("Password", "password",
"password expected", ""));
fSettings->Add(fDirectorySetting = new StringValueSetting("Directory", "web/images",
"destination directory expected", ""));
fSettings->Add(fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1));
fSettings->Add(fFilenameSetting = new StringValueSetting("StillImageFilename",
"codycam.jpg", "still image filename expected", ""));
fSettings->Add(fImageFormatSettings = new StringValueSetting("ImageFileFormat",
"JPEG Image", "image file format expected", ""));
fSettings->Add(fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate",
fServerSetting = new StringValueSetting("Server", "ftp.my.server",
"server address expected", "");
fLoginSetting = new StringValueSetting("Login", "loginID",
"login ID expected", "");
fPasswordSetting = new StringValueSetting("Password", "password",
"password expected", "");
fDirectorySetting = new StringValueSetting("Directory", "web/images",
"destination directory expected", "");
fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1);
fFilenameSetting = new StringValueSetting("StillImageFilename",
"codycam.jpg", "still image filename expected", "");
fImageFormatSettings = new StringValueSetting("ImageFileFormat",
"JPEG Image", "image file format expected", "");
fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate",
"Every 5 minutes", kCaptureRate, "capture rate expected",
"unrecognized capture rate specified"));
fSettings->Add(fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient",
"unrecognized capture rate specified");
fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient",
"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();
}
@@ -945,3 +941,4 @@ int main() {
app.Run();
return 0;
}
+10 -6
View File
@@ -1,4 +1,3 @@
/* CodyCam.h */
#ifndef CODYCAM_H
#define CODYCAM_H
@@ -18,7 +17,6 @@
#include <Window.h>
class BMediaRoster;
@@ -112,8 +110,9 @@ class CodyCam : public BApplication {
class VideoWindow : public BWindow {
public:
VideoWindow(BRect frame, const char* title, window_type type,
uint32 flags, port_id* consumerport);
VideoWindow(BRect frame, const char* title,
window_type type, uint32 flags,
port_id* consumerport);
~VideoWindow();
virtual bool QuitRequested();
@@ -127,7 +126,8 @@ class VideoWindow : public BWindow {
private:
void _BuildCaptureControls(BView* theView);
void _SetUpSettings(const char* filename, const char* dirname);
void _SetUpSettings(const char* filename,
const char* dirname);
void _QuitSettings();
private:
@@ -157,6 +157,7 @@ class VideoWindow : public BWindow {
ftp_msg_info fFtpInfo;
Settings* fSettings;
StringValueSetting* fServerSetting;
StringValueSetting* fLoginSetting;
StringValueSetting* fPasswordSetting;
@@ -164,6 +165,7 @@ class VideoWindow : public BWindow {
BooleanValueSetting* fPassiveFtpSetting;
StringValueSetting* fFilenameSetting;
StringValueSetting* fImageFormatSettings;
EnumeratedStringValueSetting* fUploadClientSetting;
EnumeratedStringValueSetting* fCaptureRateSetting;
};
@@ -171,7 +173,8 @@ class VideoWindow : public BWindow {
class ControlWindow : public BWindow {
public:
ControlWindow(const BRect& frame, BView* controls, media_node node);
ControlWindow(const BRect& frame, BView* controls,
media_node node);
void MessageReceived(BMessage* message);
bool QuitRequested();
@@ -181,3 +184,4 @@ class ControlWindow : public BWindow {
};
#endif // CODYCAM_H