renga/App.cpp
2025-02-08 10:29:06 +00:00

55 lines
1.4 KiB
C++

#include "App.h"
#include <Application.h>
#include <GroupLayout.h>
#include <InterfaceDefs.h>
#include <Layout.h>
#include <LayoutItem.h>
#include <Rect.h>
#include <Window.h>
#include <String.h>
#include <StringView.h>
#include <GroupLayoutBuilder.h>
// quick and dirty function to quickly make text labels
BStringView *MakeText(const char* text)
{
return new BStringView("rstr", text);
}
App::App(void) : BApplication("application/x-vnd.hex-Renga")
{
// 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, "Hello World!", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
// Set window layout to parent group created earlier
window->SetLayout(pGroup);
// Initialize special "label" group for all of our labels
BGroupLayout *lGroup = new BGroupLayout(B_HORIZONTAL, 100);
// Add label group to parent group
pGroup->AddItem(lGroup);
// Center label group
lGroup->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
// And finally, add allat labels!!
lGroup->AddView(MakeText("label 1"));
lGroup->AddView(MakeText("label 2"));
lGroup->AddView(MakeText("label 3"));
window->Show();
}
int main(void)
{
App *app = new App();
app->Run();
delete app;
return 0;
}