* The window is now maximized on startup if there is no settings file.
This fixes bug #407. * The OpenWindow was not really font-sensitive (fixed window size). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17245 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -96,7 +96,9 @@ Settings::Settings()
|
||||
fMessage(kMsgDiskProbeSettings),
|
||||
fUpdated(false)
|
||||
{
|
||||
fMessage.AddRect("window_frame", BRect(50, 50, 550, 500));
|
||||
BScreen screen;
|
||||
fMessage.AddRect("window_frame", BRect(50, 50, screen.Frame().Width() - 50,
|
||||
screen.Frame().Height() - 50));
|
||||
fMessage.AddInt32("base_type", kHexBase);
|
||||
fMessage.AddFloat("font_size", 12.0f);
|
||||
fMessage.AddBool("case_sensitive", true);
|
||||
|
||||
@@ -43,7 +43,7 @@ FileWindow::FileWindow(BRect rect, entry_ref *ref, const BMessage *settings)
|
||||
|
||||
// add the menu
|
||||
|
||||
BMenuBar *menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
|
||||
BMenuBar *menuBar = new BMenuBar(BRect(0, 0, Bounds().Width(), 8), "menu bar");
|
||||
AddChild(menuBar);
|
||||
|
||||
BMenu *menu = new BMenu("File");
|
||||
|
||||
@@ -20,11 +20,10 @@
|
||||
|
||||
static const uint32 kMsgProbeFile = 'prDv';
|
||||
static const uint32 kMsgProbeDevice = 'prFl';
|
||||
static const uint32 kMsgCancel = 'Canc';
|
||||
|
||||
|
||||
OpenWindow::OpenWindow()
|
||||
: BWindow(BRect(0, 0, 350, 100), "DiskProbe", B_TITLED_WINDOW,
|
||||
: BWindow(BRect(0, 0, 35, 10), "DiskProbe", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
BView *view = new BView(Bounds(), B_EMPTY_STRING, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
@@ -38,29 +37,46 @@ OpenWindow::OpenWindow()
|
||||
|
||||
BRect rect = Bounds().InsetByCopy(8, 8);
|
||||
BMenuField *field = new BMenuField(rect, "devices", "Examine Device:", fDevicesMenu);
|
||||
field->SetDivider(field->StringWidth(field->Label()) + 8);
|
||||
field->ResizeToPreferred();
|
||||
field->SetDivider(field->StringWidth(field->Label()) + 8);
|
||||
view->AddChild(field);
|
||||
|
||||
BButton *button = new BButton(BRect(10, 10, 20, 20), "file", "Probe Device", new BMessage(kMsgProbeDevice));
|
||||
button->ResizeToPreferred();
|
||||
rect = button->Bounds();
|
||||
button->MoveTo(Bounds().Width() - 8 - rect.Width(), Bounds().Height() - 8 - rect.Height());
|
||||
view->AddChild(button);
|
||||
BButton *probeDeviceButton = new BButton(BRect(10, 10, 20, 20), "file", "Probe Device",
|
||||
new BMessage(kMsgProbeDevice), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
probeDeviceButton->ResizeToPreferred();
|
||||
rect = probeDeviceButton->Bounds();
|
||||
probeDeviceButton->MoveTo(Bounds().Width() - 8 - rect.Width(),
|
||||
Bounds().Height() - 8 - rect.Height());
|
||||
view->AddChild(probeDeviceButton);
|
||||
|
||||
// MakeDefault() may change the size and location of the button
|
||||
rect = button->Frame();
|
||||
button->MakeDefault(true);
|
||||
rect = probeDeviceButton->Frame();
|
||||
float width = rect.Width() + 58.0f;
|
||||
probeDeviceButton->MakeDefault(true);
|
||||
|
||||
button = new BButton(rect, "file", "Probe File" B_UTF8_ELLIPSIS, new BMessage(kMsgProbeFile));
|
||||
BButton *button = new BButton(rect, "file", "Probe File" B_UTF8_ELLIPSIS,
|
||||
new BMessage(kMsgProbeFile), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
button->ResizeToPreferred();
|
||||
button->MoveBy(-button->Bounds().Width() - 8, 0);
|
||||
view->AddChild(button);
|
||||
width += button->Bounds().Width();
|
||||
|
||||
button = new BButton(button->Frame(), "cancel", "Cancel", new BMessage(kMsgCancel));
|
||||
button = new BButton(button->Frame(), "cancel", "Cancel",
|
||||
new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
button->ResizeToPreferred();
|
||||
button->MoveBy(-button->Bounds().Width() - 8, 0);
|
||||
view->AddChild(button);
|
||||
width += button->Bounds().Width();
|
||||
|
||||
// make sure the window is large enough
|
||||
|
||||
if (width < Bounds().Width())
|
||||
width = Bounds().Width();
|
||||
float height = button->Bounds().Height() + 24.0f + field->Frame().bottom;
|
||||
if (height < Bounds().Height())
|
||||
height = Bounds().Height();
|
||||
|
||||
ResizeTo(width, height);
|
||||
|
||||
BScreen screen(this);
|
||||
MoveTo(screen.Frame().left + (screen.Frame().Width() - Frame().Width()) / 2,
|
||||
@@ -92,11 +108,6 @@ OpenWindow::MessageReceived(BMessage *message)
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case kMsgCancel:
|
||||
if (QuitRequested())
|
||||
Quit();
|
||||
break;
|
||||
|
||||
case B_SIMPLE_DATA: {
|
||||
// if it's a file drop, open it
|
||||
entry_ref ref;
|
||||
|
||||
Reference in New Issue
Block a user