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:
parent
31bc74d4bf
commit
aa366c07b1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2012-2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PROMPT_WINDOW_H_
|
||||
@ -10,6 +10,7 @@
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class BStringView;
|
||||
class BTextControl;
|
||||
|
||||
|
||||
@ -17,8 +18,9 @@ class PromptWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
// PromptWindow takes ownership of message
|
||||
PromptWindow(const char* title, const char* label, BMessenger target,
|
||||
BMessage* message = NULL);
|
||||
PromptWindow(const char* title,
|
||||
const char* label, const char* info,
|
||||
BMessenger target, BMessage* message = NULL);
|
||||
~PromptWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
@ -27,6 +29,7 @@ public:
|
||||
status_t SetMessage(BMessage* message);
|
||||
private:
|
||||
BTextControl* fTextControl;
|
||||
BStringView* fInfoView;
|
||||
BMessenger fTarget;
|
||||
BMessage* fMessage;
|
||||
};
|
||||
|
@ -1517,7 +1517,8 @@ VariablesView::MessageReceived(BMessage* message)
|
||||
promptMessage->AddPointer("node", fVariableTable
|
||||
->SelectionModel()->NodeAt(0));
|
||||
PromptWindow* promptWindow = new(std::nothrow) PromptWindow(
|
||||
"Specify Type", "Type: ", BMessenger(this), promptMessage);
|
||||
"Specify Type", "Type: ", NULL, BMessenger(this),
|
||||
promptMessage);
|
||||
if (promptWindow == NULL)
|
||||
return;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2012-2013, Rene Gollent, rene@gollent.com.
|
||||
* 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user