ui fixes
This commit is contained in:
parent
2e82ca6791
commit
720dcbb381
3 changed files with 69 additions and 71 deletions
BIN
DumBer
BIN
DumBer
Binary file not shown.
|
@ -3,7 +3,6 @@
|
|||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <Url.h>
|
||||
|
@ -14,6 +13,7 @@
|
|||
#include <LayoutBuilder.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include <View.h>
|
||||
|
@ -38,23 +38,18 @@ MainWindow::MainWindow()
|
|||
: BWindow(BRect(100, 100, 600, 400), B_TRANSLATE("BeDumb"), B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) {
|
||||
|
||||
|
||||
BMenuBar *menuBar = _BuildMenu();
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0).Add(menuBar).AddGlue().End();
|
||||
|
||||
_inputField =
|
||||
new BTextControl("", "What is the matrix ?", new BMessage(kQuestionChanged));
|
||||
|
||||
_inputField = new BTextControl("", "What is the matrix ?",
|
||||
new BMessage(kQuestionChanged));
|
||||
|
||||
_progress = new BStatusBar("prog");
|
||||
_progress->SetMaxValue(100);
|
||||
_progress->SetTo(0);
|
||||
_progress->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
|
||||
_answerView = new BTextView("answer");
|
||||
|
||||
BStringView *header = new BStringView("biglabel", "Let's Be Dumber!");
|
||||
BFont font;
|
||||
header->GetFont(&font);
|
||||
|
@ -81,9 +76,20 @@ MainWindow::MainWindow()
|
|||
new BButton("send", B_TRANSLATE("Send"), new BMessage(kSendPrompt),
|
||||
B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
_answerView = new BTextView("answer", B_WILL_DRAW | B_FOLLOW_ALL);
|
||||
_answerView->MakeEditable(false); // Disable editing
|
||||
_answerView->MakeSelectable(true); // Enable text selection
|
||||
|
||||
//_answerView->SetWordWrap(true);
|
||||
BScrollView *scrollView =
|
||||
new BScrollView("scroll_view", _answerView, 0, 0, false,
|
||||
true); // horizontal and vertical scrollbars
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||
|
||||
.AddGlue(0.1)
|
||||
.Add(header)
|
||||
.AddGlue(0.1)
|
||||
|
||||
.AddGroup(B_HORIZONTAL, 0, 1)
|
||||
.Add(_inputField)
|
||||
|
@ -92,9 +98,10 @@ MainWindow::MainWindow()
|
|||
.End()
|
||||
.End()
|
||||
|
||||
.AddGlue(0.1)
|
||||
.Add(scrollView)
|
||||
.Add(_progress)
|
||||
.Add(_infoView)
|
||||
.Add(_answerView)
|
||||
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
|
||||
|
@ -165,8 +172,6 @@ void MainWindow::MessageReceived(BMessage *message) {
|
|||
_infoView->SetText("HttpRedirect...");
|
||||
} break;
|
||||
|
||||
|
||||
|
||||
case UrlEvent::RequestCompleted: {
|
||||
printf("RequestCompleted\n");
|
||||
auto identifier = message->GetInt32(UrlEventData::Id, -1);
|
||||
|
@ -186,7 +191,6 @@ void MainWindow::MessageReceived(BMessage *message) {
|
|||
|
||||
} break;
|
||||
|
||||
|
||||
case UrlEvent::HttpStatus: {
|
||||
|
||||
printf("HttpStatus\n");
|
||||
|
@ -217,22 +221,18 @@ void MainWindow::MessageReceived(BMessage *message) {
|
|||
}
|
||||
} break;
|
||||
|
||||
|
||||
|
||||
default: {
|
||||
// message->PrintToStream();
|
||||
BWindow::MessageReceived(message); // call the parent handler for other messages
|
||||
BWindow::MessageReceived(
|
||||
message); // call the parent handler for other messages
|
||||
// _infoView->SetText(message->FindMessage());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} // end switch
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
|
||||
void MainWindow::sendQuery() {
|
||||
|
||||
if (_lastResult)
|
||||
|
@ -241,7 +241,7 @@ void MainWindow::sendQuery() {
|
|||
_progress->SetMaxValue(100);
|
||||
_progress->SetTo(0);
|
||||
|
||||
auto url = BUrl("https://www.link-u.com/ip/");
|
||||
auto url = BUrl("https://www.lema.org/");
|
||||
BHttpRequest request = BHttpRequest(url);
|
||||
|
||||
printf("Sending Prompt to server: %s\n", url.UrlString().String());
|
||||
|
@ -250,11 +250,8 @@ void MainWindow::sendQuery() {
|
|||
if (_lastResult) {
|
||||
printf("Result has identity: %d\n", _lastResult->Identity());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BMenuBar *MainWindow::_BuildMenu() {
|
||||
|
||||
BMenuBar *menuBar = new BMenuBar("menubar");
|
||||
|
@ -283,11 +280,11 @@ BMenuBar *MainWindow::_BuildMenu() {
|
|||
item->SetTarget(be_app);
|
||||
menu->AddItem(item);
|
||||
|
||||
item = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||
item =
|
||||
new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||
menu->AddItem(item);
|
||||
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ private:
|
|||
BTextView * _infoView;
|
||||
BTextControl* _inputField;
|
||||
BStatusBar* _progress;
|
||||
|
||||
BMenuItem *fSaveMenuItem;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue