The beginning of the partitioning dialog. Well, the very beginning. ;-)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2798 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-02-22 23:48:06 +00:00
parent 32de23c976
commit 8b56dae30c
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,71 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#include <DiskScannerAddOn.h>
#include <Screen.h>
#include "PartitioningDialog.h"
// constructor
PartitioningDialog::PartitioningDialog(BRect dialogCenter)
: BWindow(BRect(0, 0, 1, 1), "Partitioning Parameters", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE),
fEditor(NULL),
fEditorView(NULL),
fBlocker(-1),
fCancelled(NULL),
fCenter()
{
fBlocker = create_sem(0, "partitioning dialog blocker");
// calculate the dialog center point
if (!dialogCenter.IsValid())
dialogCenter = BScreen().Frame();
fCenter = dialogCenter.LeftTop() + dialogCenter.RightBottom();
fCenter.x /= 2;
fCenter.y /= 2;
}
// destructor
PartitioningDialog::~PartitioningDialog()
{
if (fBlocker >= 0)
delete_sem(fBlocker);
}
// Go
status_t
PartitioningDialog::Go(BDiskScannerParameterEditor *editor, bool *_cancelled)
{
status_t error = (editor ? B_OK : B_BAD_VALUE);
// set the parameter editor and view
if (error == B_OK) {
fEditor = editor;
fEditorView = editor->View();
if (!fEditorView)
error = B_ERROR;
}
bool wasRun = false;
// fire up the window
if (error == B_OK) {
if (fBlocker >= 0) {
sem_id blocker = fBlocker;
bool cancelled = true;
fCancelled = &cancelled;
Run();
wasRun = true;
acquire_sem(blocker);
if (cancelled)
error = B_ERROR;
if (_cancelled)
*_cancelled = cancelled;
} else
error = fBlocker;
}
// delete the window if not run
if (!wasRun)
delete this;
return error;
}

View File

@ -0,0 +1,35 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#ifndef _PARTITIONING_DIALOG_H
#define _PARTITIONING_DIALOG_H
#include <OS.h>
#include <Window.h>
class BDiskScannerParameterEditor;
namespace BPrivate {
class PartitioningDialog : public BWindow {
public:
PartitioningDialog(BRect dialogCenter);
virtual ~PartitioningDialog();
status_t Go(BDiskScannerParameterEditor *editor, bool *cancelled);
private:
BDiskScannerParameterEditor *fEditor;
BView *fEditorView;
sem_id fBlocker;
bool *fCancelled;
BPoint fCenter;
};
} // namespace BPrivate
using BPrivate::PartitioningDialog;
#endif // _PARTITIONING_DIALOG_H