#include "MainWindow.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Contacts.h" #include 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; } } }