1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +00:00

Start bringing up LibGUI properly (formerly Widgets.)

This commit is contained in:
Andreas Kling 2019-01-20 05:48:43 +01:00
parent b91479d9b9
commit 8eae89a405
17 changed files with 258 additions and 33 deletions

1
Userland/.gitignore vendored
View file

@ -22,4 +22,5 @@ touch
sync
more
guitest
guitest2
sysctl

View file

@ -20,6 +20,7 @@ OBJS = \
touch.o \
more.o \
guitest.o \
guitest2.o \
sysctl.o
APPS = \
@ -45,6 +46,7 @@ APPS = \
sync \
more \
guitest \
guitest2 \
sysctl
ARCH_FLAGS =
@ -131,6 +133,9 @@ more: more.o
guitest: guitest.o
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
guitest2: guitest2.o
$(LD) -o $@ $(LDFLAGS) $< ../LibGUI/LibGUI.a ../LibC/LibC.a
sysctl: sysctl.o
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a

54
Userland/guitest2.cpp Normal file
View file

@ -0,0 +1,54 @@
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <assert.h>
#include <Kernel/Syscall.h>
#include <SharedGraphics/GraphicsBitmap.h>
#include <SharedGraphics/Painter.h>
#include <LibGUI/GWindow.h>
#include <LibGUI/GWidget.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GEventLoop.h>
static GWindow* make_font_test_window();
int main(int argc, char** argv)
{
auto* window = make_font_test_window();
window->show();
GEventLoop loop;
return loop.exec();
}
GWindow* make_font_test_window()
{
auto* window = new GWindow;
window->set_title("Font test");
window->set_rect({ 140, 100, 300, 80 });
auto* widget = new GWidget;
window->set_main_widget(widget);
widget->setWindowRelativeRect({ 0, 0, 300, 80 });
auto* l1 = new GLabel(widget);
l1->setWindowRelativeRect({ 0, 0, 300, 20 });
l1->setText("0123456789");
auto* l2 = new GLabel(widget);
l2->setWindowRelativeRect({ 0, 20, 300, 20 });
l2->setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
auto* l3 = new GLabel(widget);
l3->setWindowRelativeRect({ 0, 40, 300, 20 });
l3->setText("abcdefghijklmnopqrstuvwxyz");
auto* l4 = new GLabel(widget);
l4->setWindowRelativeRect({ 0, 60, 300, 20 });
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
return window;
}