serenity/Widgets/test.cpp

64 lines
1.6 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-12 06:18:59 -04:00
#include "ClockWidget.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");
2018-10-12 06:18:59 -04:00
fontTestWindow->setRect({ 100, 100, 300, 80 });
2018-10-12 04:06:50 -04:00
auto* fontTestWindowWidget = new Widget;
fontTestWindow->setMainWidget(fontTestWindowWidget);
2018-10-12 06:18:59 -04:00
fontTestWindowWidget->setRect({ 0, 0, 300, 80 });
2018-10-12 04:06:50 -04:00
auto* l1 = new Label(fontTestWindowWidget);
2018-10-12 06:18:59 -04:00
l1->setRect({ 0, 0, 300, 20 });
l1->setText("0123456789");
2018-10-12 04:06:50 -04:00
auto* l2 = new Label(fontTestWindowWidget);
2018-10-12 06:18:59 -04:00
l2->setRect({ 0, 20, 300, 20 });
l2->setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
2018-10-12 04:06:50 -04:00
auto* l3 = new Label(fontTestWindowWidget);
2018-10-12 06:18:59 -04:00
l3->setRect({ 0, 40, 300, 20 });
l3->setText("abcdefghijklmnopqrstuvwxyz");
2018-10-12 04:06:50 -04:00
auto* l4 = new Label(fontTestWindowWidget);
2018-10-12 06:18:59 -04:00
l4->setRect({ 0, 60, 300, 20 });
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
2018-10-10 19:48:09 -04:00
auto* b = new Button(&w);
2018-10-12 06:18:59 -04:00
b->setRect({ 10, 10, 100, 30 });
2018-10-10 19:48:09 -04:00
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");
2018-10-12 06:18:59 -04:00
win->setRect({ 100, 300, 644, 254 });
2018-10-11 19:03:22 -04:00
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-12 06:18:59 -04:00
auto* clockWin = new Window;
clockWin->setTitle("Clock");
clockWin->setRect({ 500, 50, 100, 40 });
clockWin->setMainWidget(new ClockWidget);
2018-10-10 09:12:38 -04:00
return loop.exec();
}