This commit is contained in:
Santiago Lema 2024-09-29 19:37:24 -03:00
parent 6be1aad043
commit 13fb5cf3b3
5 changed files with 27 additions and 7 deletions

View file

@ -11,6 +11,8 @@
#include <LayoutBuilder.h>
#include <Menu.h>
#include <MenuBar.h>
#include <Button.h>
#include <View.h>
#include <cstdio>
@ -23,11 +25,12 @@ static const uint32 kMsgOpenFile = 'fopn';
static const uint32 kMsgSaveFile = 'fsav';
static const uint32 kSendPrompt = 'kspt';
static const uint32 kQuestionChanged = 'kqch';
MainWindow::MainWindow()
:
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE("BeDumb"), B_TITLED_WINDOW,
BWindow(BRect(100, 100, 600, 400), B_TRANSLATE("BeDumb"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
BMenuBar* menuBar = _BuildMenu();
@ -36,13 +39,23 @@ MainWindow::MainWindow()
.Add(menuBar)
.AddGlue()
.End();
BTextControl* input = new BTextControl(B_TRANSLATE("question"), "", new BMessage(kQuestionChanged));
BTextView* answerView = new BTextView("answer", B_WILL_DRAW | B_FOLLOW_ALL_SIDES);
BButton *sendButton = new BButton("send",B_TRANSLATE("ask"),new BMessage(kSendPrompt), B_WILL_DRAW | B_NAVIGABLE);
//BLayoutItem * addMe = new BLayoutItem():
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL, 0)
// .Add(new BTextControl("Input 1", "Label 1", "Default text"))
// .Add(new BButton("Go", new BMessage(kSendPrompt))
.Add(input)
.Add(sendButton)
.End()
// .Add(new BTextView("Text View", new BRect(0, 0, 10, 10), B_FOLLOW_ALL_SIDES, B_WILL_DRAW))
.Add(answerView)
.SetInsets(5, 5, 5, 5)
.End();
@ -76,6 +89,13 @@ MainWindow::MessageReceived(BMessage* message)
printf("Save\n");
} break;
case kSendPrompt:
{
printf("Sending Prompt...");
} break;
default:
{
BWindow::MessageReceived(message);