serenity/Widgets/test.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

2018-10-10 09:12:38 -04:00
#include "FrameBufferSDL.h"
#include "EventLoopSDL.h"
#include "RootWidget.h"
2018-10-10 10:49:36 -04:00
#include "Label.h"
2018-10-10 19:48:09 -04:00
#include "Button.h"
2018-10-10 20:50:08 -04:00
#include "TerminalWidget.h"
2018-10-11 10:52:40 -04:00
#include "WindowManager.h"
2018-10-11 19:03:22 -04:00
#include "Window.h"
2018-10-10 09:12:38 -04:00
#include <cstdio>
int main(int c, char** v)
{
FrameBufferSDL fb(800, 600);
fb.show();
EventLoopSDL loop;
RootWidget w;
WindowManager::the().setRootWidget(&w);
2018-10-11 10:52:40 -04:00
2018-10-12 04:06:50 -04:00
auto* fontTestWindow = new Window;
fontTestWindow->setTitle("Font test");
fontTestWindow->setRect({100, 100, 300, 80 });
auto* fontTestWindowWidget = new Widget;
fontTestWindow->setMainWidget(fontTestWindowWidget);
fontTestWindowWidget->setRect({0, 0, 300, 80 });
auto* l1 = new Label(fontTestWindowWidget);
l1->setRect(Rect(0, 0, 300, 20));
l1->setText("0123456789");
2018-10-12 04:06:50 -04:00
auto* l2 = new Label(fontTestWindowWidget);
l2->setRect(Rect(0, 20, 300, 20));
l2->setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
2018-10-12 04:06:50 -04:00
auto* l3 = new Label(fontTestWindowWidget);
l3->setRect(Rect(0, 40, 300, 20));
l3->setText("abcdefghijklmnopqrstuvwxyz");
2018-10-12 04:06:50 -04:00
auto* l4 = new Label(fontTestWindowWidget);
l4->setRect(Rect(0, 60, 300, 20));
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
2018-10-10 19:48:09 -04:00
auto* b = new Button(&w);
b->setRect(Rect(10, 10, 100, 30));
b->setCaption("Button!");
2018-10-10 10:49:36 -04:00
2018-10-11 19:03:22 -04:00
auto* win = new Window;
win->setTitle("Console");
win->setRect({100, 300, 644, 254});
auto* t = new TerminalWidget(nullptr);
2018-10-11 19:03:22 -04:00
win->setMainWidget(t);
2018-10-10 20:50:08 -04:00
2018-10-10 09:12:38 -04:00
return loop.exec();
}