Add an information blurb option to PromptWindow.

- PromptWindow now takes a parameter which contains optional
  informational text to display above the text control.

- Adjust callers.
This commit is contained in:
Rene Gollent
2013-04-27 14:04:33 -04:00
parent 31bc74d4bf
commit aa366c07b1
3 changed files with 16 additions and 6 deletions
+8 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2012, Rene Gollent, [email protected].
* Copyright 2012-2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "PromptWindow.h"
@@ -7,6 +7,7 @@
#include <Button.h>
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <StringView.h>
#include <TextControl.h>
@@ -14,13 +15,14 @@ static const uint32 kAcceptInput = 'acin';
PromptWindow::PromptWindow(const char* title, const char* label,
BMessenger target, BMessage* message)
const char* info, BMessenger target, BMessage* message)
:
BWindow(BRect(), title, B_FLOATING_WINDOW, B_NOT_RESIZABLE
| B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fTarget(target),
fMessage(message)
{
fInfoView = new BStringView("info", info);
fTextControl = new BTextControl("promptcontrol", label, NULL,
new BMessage(kAcceptInput));
BButton* cancelButton = new BButton("Cancel", new
@@ -28,11 +30,15 @@ PromptWindow::PromptWindow(const char* title, const char* label,
BButton* acceptButton = new BButton("Accept", new
BMessage(kAcceptInput));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(fInfoView)
.Add(fTextControl)
.AddGroup(B_HORIZONTAL)
.Add(acceptButton)
.Add(cancelButton);
if (info == NULL)
fInfoView->Hide();
fTextControl->TextView()->SetExplicitMinSize(BSize(
fTextControl->TextView()->StringWidth("1234567890"), B_SIZE_UNSET));
fTextControl->SetTarget(this);