87 lines
2.2 KiB
C++
87 lines
2.2 KiB
C++
#include "MainWindow.h"
|
|
#include <Alignment.h>
|
|
#include <Application.h>
|
|
#include <GridLayout.h>
|
|
#include <GroupLayout.h>
|
|
#include <InterfaceDefs.h>
|
|
#include <Layout.h>
|
|
#include <LayoutItem.h>
|
|
#include <Message.h>
|
|
#include <Rect.h>
|
|
#include <String.h>
|
|
#include <StringView.h>
|
|
#include <TextView.h>
|
|
#include <View.h>
|
|
#include <Window.h>
|
|
#include <GroupLayoutBuilder.h>
|
|
#include <GridLayoutBuilder.h>
|
|
#include <Button.h>
|
|
#include <cstdio>
|
|
#include "Contacts.h"
|
|
#include <TextControl.h>
|
|
|
|
MainWindow::MainWindow(void)
|
|
: BWindow(BRect(100, 100, 500, 400), "Renga", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
|
|
{
|
|
// parent layout (defines the entire window layout)
|
|
BGroupLayout *pGroup = new BGroupLayout(B_HORIZONTAL);
|
|
SetLayout(pGroup);
|
|
|
|
// make sure window uses window colors set in haiku preferences (equivelant to system themes)
|
|
pGroup->View()->AdoptSystemColors();
|
|
|
|
// prepare "renga" text banner
|
|
BStringView *banner = new BStringView("banner", "Renga");
|
|
|
|
banner->SetHighColor(135,1,1);
|
|
banner->SetFontSize(28.0);
|
|
|
|
// ui layout (parent of all UI elements visible to the user)
|
|
BGridLayout *uiElems = new BGridLayout(10, 0);
|
|
|
|
pGroup->AddItem(uiElems);
|
|
|
|
// center the entire UI
|
|
uiElems->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
|
|
|
BButton *connectButton = new BButton(Frame(), "connect", "Connect!", new BMessage(msgConnectButtonClicked));
|
|
connectButton->SetTarget(this);
|
|
|
|
BTextControl *jidInput = new BTextControl("jidinput", "JID:", "Placeholder", NULL);
|
|
BTextControl *pwInput = new BTextControl("pwinput", "Password:", "Placeholder", NULL);
|
|
|
|
pwInput->TextView()->HideTyping(true);
|
|
|
|
jidInput->SetExplicitSize(BSize(200,23));
|
|
pwInput->SetExplicitSize(BSize(200,23));
|
|
|
|
uiElems->AddView(banner, 0, 0);
|
|
uiElems->AddView(jidInput, 0, 1);
|
|
uiElems->AddView(pwInput, 0, 2);
|
|
uiElems->AddView(connectButton, 0, 3);
|
|
uiElems->SetMinRowHeight(3, 75);
|
|
uiElems->SetMinRowHeight(0, 25);
|
|
|
|
Show();
|
|
}
|
|
|
|
|
|
void MainWindow::MessageReceived(BMessage *msg)
|
|
{
|
|
switch(msg->what) {
|
|
case msgConnectButtonClicked:
|
|
{
|
|
printf("Connect button clicked...\n");
|
|
|
|
Hide();
|
|
Contacts *contacts = new Contacts();
|
|
contacts->Show();
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
printf("Unknown message received: %d\n", msg->what);
|
|
break;
|
|
}
|
|
}
|
|
}
|