Compare commits
No commits in common. "f33e0aca06a988fcd5eaecfe9a8644ec7e649010" and "59ac3aeb0ac23c2978de86e9f74539f2eeecde29" have entirely different histories.
f33e0aca06
...
59ac3aeb0a
11 changed files with 126 additions and 170 deletions
84
App.cpp
Normal file
84
App.cpp
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
#include "App.h"
|
||||||
|
#include <Application.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 <GroupLayoutBuilder.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <format>
|
||||||
|
#include <iostream>
|
||||||
|
#include "Contacts.h"
|
||||||
|
|
||||||
|
// quick and dirty function to quickly make text labels
|
||||||
|
BStringView *MakeText(const char* text)
|
||||||
|
{
|
||||||
|
return new BStringView("rstr", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
App::App(void) : BApplication(std::format("application/x-vnd.{}-{}", APP_AUTHOR, APP_NAME).c_str())
|
||||||
|
{
|
||||||
|
std::cout << "hello world!!\n";
|
||||||
|
// Initialize BRect frame for window
|
||||||
|
BRect frame(100, 100, 500, 400);
|
||||||
|
|
||||||
|
// Initialize parent group for all UI elements to sit in. This is so they all get grouped nicely together
|
||||||
|
BGroupLayout *pGroup = new BGroupLayout(B_HORIZONTAL);
|
||||||
|
// Create window
|
||||||
|
BWindow *window = new BWindow(frame, std::format("{} by {}", APP_NAME, APP_AUTHOR).c_str(), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS);
|
||||||
|
|
||||||
|
// Set window layout to parent group created earlier
|
||||||
|
window->SetLayout(pGroup);
|
||||||
|
|
||||||
|
// Initialize special UI group for all of our "real" elements
|
||||||
|
BGroupLayout *uGroup = new BGroupLayout(B_HORIZONTAL, 100);
|
||||||
|
// Add label group to parent group
|
||||||
|
pGroup->AddItem(uGroup);
|
||||||
|
|
||||||
|
// Center label group
|
||||||
|
uGroup->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
|
||||||
|
// And finally, add a button!!
|
||||||
|
BButton *connectButton = new BButton(frame, "connect", "Connect to XMPP", new BMessage(msgConnectButtonClicked));
|
||||||
|
connectButton->SetTarget(this);
|
||||||
|
|
||||||
|
uGroup->AddView(connectButton);
|
||||||
|
|
||||||
|
window->Show();
|
||||||
|
|
||||||
|
App::ConnectWindow = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what) {
|
||||||
|
case msgConnectButtonClicked:
|
||||||
|
{
|
||||||
|
printf("Connect button clicked...\n");
|
||||||
|
App::ConnectWindow->Hide();
|
||||||
|
App::ContactsWindow = ShowContacts();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
printf("Unknown message received: %d\n", msg->what);
|
||||||
|
BApplication::MessageReceived(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
App *app = new App();
|
||||||
|
app->Run();
|
||||||
|
|
||||||
|
delete app;
|
||||||
|
return 0;
|
||||||
|
}
|
24
App.h
Normal file
24
App.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef APP_H
|
||||||
|
#define APP_H
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#define APP_NAME "Renga"
|
||||||
|
#define APP_AUTHOR "hex_andre"
|
||||||
|
|
||||||
|
const uint32 msgConnectButtonClicked = 'mCBC';
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
|
||||||
|
class App : public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
App(void);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
BWindow *ConnectWindow;
|
||||||
|
BWindow *ContactsWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
14
Contacts.cpp
Normal file
14
Contacts.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "Contacts.h"
|
||||||
|
#include "App.h"
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
BWindow *ShowContacts()
|
||||||
|
{
|
||||||
|
// POS W H
|
||||||
|
BRect frame(200,200,600,400);
|
||||||
|
BWindow *window = new BWindow(frame, "Contacts List", B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_QUIT_ON_WINDOW_CLOSE);
|
||||||
|
window->Show();
|
||||||
|
return window;
|
||||||
|
}
|
3
Contacts.h
Normal file
3
Contacts.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "App.h"
|
||||||
|
#include <Window.h>
|
||||||
|
extern BWindow *ShowContacts();
|
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ FLAGS=-lbe -std=c++20 -lstdc++
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(CPP) $(shell find ./src | grep cpp) -o $(BINARY) $(FLAGS)
|
$(CPP) *.cpp -o $(BINARY) $(FLAGS)
|
||||||
test: build
|
test: build
|
||||||
./renga
|
./renga
|
||||||
|
|
||||||
|
|
17
src/App.cpp
17
src/App.cpp
|
@ -1,17 +0,0 @@
|
||||||
#include "App.h"
|
|
||||||
#include "gui/MainWindow.h"
|
|
||||||
|
|
||||||
App::App(void) : BApplication(kSignature)
|
|
||||||
{
|
|
||||||
MainWindow *mainWindow = new MainWindow();
|
|
||||||
mainWindow->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
App *app = new App();
|
|
||||||
app->Run();
|
|
||||||
|
|
||||||
delete app;
|
|
||||||
return 0;
|
|
||||||
}
|
|
23
src/App.h
23
src/App.h
|
@ -1,23 +0,0 @@
|
||||||
#ifndef APP_H
|
|
||||||
#define APP_H
|
|
||||||
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <gloox/connectionlistener.h>
|
|
||||||
#include <gloox/presencehandler.h>
|
|
||||||
#include <Application.h>
|
|
||||||
|
|
||||||
#define kSignature "application/x-vnd.iwakura-Renga"
|
|
||||||
|
|
||||||
class Client : public gloox::ConnectionListener, gloox::PresenceHandler {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class App : public BApplication
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
App(void);
|
|
||||||
Client *client;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,11 +0,0 @@
|
||||||
#include "Contacts.h"
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Rect.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
|
|
||||||
Contacts::Contacts(void)
|
|
||||||
: BWindow(BRect(200,200,600,400), TITLE, B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_QUIT_ON_WINDOW_CLOSE)
|
|
||||||
{
|
|
||||||
AddChild(new BStringView("label", "Placeholder label (contact list to be added)"));
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef CONTACTS_H
|
|
||||||
#define CONTACTS_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#define TITLE "Contact List"
|
|
||||||
|
|
||||||
class Contacts : public BWindow {
|
|
||||||
public:
|
|
||||||
Contacts(void);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,87 +0,0 @@
|
||||||
#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", new BMessage(msgConnectButtonClicked));
|
|
||||||
BTextControl *pwInput = new BTextControl("pwinput", "Password:", "Placeholder", new BMessage(msgConnectButtonClicked));
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <gloox/connectionlistener.h>
|
|
||||||
#include <gloox/presencehandler.h>
|
|
||||||
|
|
||||||
const uint32 msgConnectButtonClicked = 'mCBC';
|
|
||||||
|
|
||||||
class MainWindow : public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MainWindow(void);
|
|
||||||
virtual void MessageReceived(BMessage *msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue