2019-01-20 04:48:43 +00:00
|
|
|
#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>
|
2019-01-20 23:31:11 +00:00
|
|
|
#include <LibGUI/GButton.h>
|
2019-01-20 04:48:43 +00:00
|
|
|
#include <LibGUI/GEventLoop.h>
|
2019-01-26 05:39:13 +00:00
|
|
|
#include <LibGUI/GTextBox.h>
|
2019-01-27 19:22:06 +00:00
|
|
|
#include <LibGUI/GCheckBox.h>
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
static GWindow* make_font_test_window();
|
2019-01-20 23:31:11 +00:00
|
|
|
static GWindow* make_launcher_window();
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2019-01-20 06:03:38 +00:00
|
|
|
GEventLoop loop;
|
2019-01-20 23:31:11 +00:00
|
|
|
auto* font_test_window = make_font_test_window();
|
|
|
|
font_test_window->show();
|
|
|
|
|
|
|
|
auto* launcher_window = make_launcher_window();
|
|
|
|
launcher_window->show();
|
2019-01-20 04:48:43 +00:00
|
|
|
return loop.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
GWindow* make_font_test_window()
|
|
|
|
{
|
|
|
|
auto* window = new GWindow;
|
|
|
|
window->set_title("Font test");
|
2019-01-20 05:02:09 +00:00
|
|
|
window->set_rect({ 440, 100, 300, 80 });
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
auto* widget = new GWidget;
|
|
|
|
window->set_main_widget(widget);
|
2019-01-20 23:46:08 +00:00
|
|
|
widget->set_relative_rect({ 0, 0, 300, 80 });
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
auto* l1 = new GLabel(widget);
|
2019-01-20 23:46:08 +00:00
|
|
|
l1->set_relative_rect({ 0, 0, 300, 20 });
|
|
|
|
l1->set_text("0123456789");
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
auto* l2 = new GLabel(widget);
|
2019-01-20 23:46:08 +00:00
|
|
|
l2->set_relative_rect({ 0, 20, 300, 20 });
|
|
|
|
l2->set_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
auto* l3 = new GLabel(widget);
|
2019-01-20 23:46:08 +00:00
|
|
|
l3->set_relative_rect({ 0, 40, 300, 20 });
|
|
|
|
l3->set_text("abcdefghijklmnopqrstuvwxyz");
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
auto* l4 = new GLabel(widget);
|
2019-01-20 23:46:08 +00:00
|
|
|
l4->set_relative_rect({ 0, 60, 300, 20 });
|
|
|
|
l4->set_text("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
|
2019-01-20 04:48:43 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
2019-01-20 23:31:11 +00:00
|
|
|
|
|
|
|
GWindow* make_launcher_window()
|
|
|
|
{
|
|
|
|
auto* window = new GWindow;
|
|
|
|
window->set_title("Launcher");
|
2019-01-25 14:52:55 +00:00
|
|
|
window->set_rect({ 100, 400, 100, 200 });
|
2019-01-20 23:31:11 +00:00
|
|
|
|
|
|
|
auto* widget = new GWidget;
|
|
|
|
window->set_main_widget(widget);
|
2019-01-25 14:52:55 +00:00
|
|
|
widget->set_relative_rect({ 0, 0, 100, 200 });
|
2019-01-20 23:31:11 +00:00
|
|
|
|
|
|
|
auto* label = new GLabel(widget);
|
2019-01-25 14:52:55 +00:00
|
|
|
label->set_relative_rect({ 0, 0, 100, 20 });
|
2019-01-20 23:46:08 +00:00
|
|
|
label->set_text("Apps");
|
2019-01-20 23:31:11 +00:00
|
|
|
|
2019-01-21 01:56:25 +00:00
|
|
|
auto* terminal_button = new GButton(widget);
|
2019-01-25 14:52:55 +00:00
|
|
|
terminal_button->set_relative_rect({ 5, 20, 90, 20 });
|
2019-01-21 01:56:25 +00:00
|
|
|
terminal_button->set_caption("Terminal");
|
2019-01-20 23:31:11 +00:00
|
|
|
|
2019-01-21 01:56:25 +00:00
|
|
|
terminal_button->on_click = [label] (GButton&) {
|
|
|
|
pid_t child_pid = fork();
|
|
|
|
if (!child_pid) {
|
2019-01-20 23:31:11 +00:00
|
|
|
execve("/bin/Terminal", nullptr, nullptr);
|
|
|
|
ASSERT_NOT_REACHED();
|
2019-01-21 01:56:25 +00:00
|
|
|
} else {
|
|
|
|
char buffer[32];
|
|
|
|
sprintf(buffer, "PID: %d", child_pid);
|
|
|
|
label->set_text(buffer);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto* guitest_button = new GButton(widget);
|
2019-01-25 14:52:55 +00:00
|
|
|
guitest_button->set_relative_rect({ 5, 50, 90, 20 });
|
2019-01-21 01:56:25 +00:00
|
|
|
guitest_button->set_caption("guitest");
|
|
|
|
|
|
|
|
guitest_button->on_click = [label] (GButton&) {
|
|
|
|
pid_t child_pid = fork();
|
|
|
|
if (!child_pid) {
|
|
|
|
execve("/bin/guitest", nullptr, nullptr);
|
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
} else {
|
|
|
|
char buffer[32];
|
|
|
|
sprintf(buffer, "PID: %d", child_pid);
|
|
|
|
label->set_text(buffer);
|
2019-01-20 23:31:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-21 01:18:16 +00:00
|
|
|
auto* dummy_button = new GButton(widget);
|
2019-01-25 14:52:55 +00:00
|
|
|
dummy_button->set_relative_rect({ 5, 80, 90, 20 });
|
2019-01-21 01:18:16 +00:00
|
|
|
dummy_button->set_caption("Dummy");
|
|
|
|
|
2019-01-26 05:39:13 +00:00
|
|
|
auto* textbox = new GTextBox(widget);
|
|
|
|
textbox->set_relative_rect({ 5, 110, 90, 20 });
|
2019-01-26 10:24:16 +00:00
|
|
|
textbox->on_return_pressed = [window] (GTextBox& textbox) {
|
|
|
|
window->set_title(textbox.text());
|
|
|
|
};
|
|
|
|
|
|
|
|
auto* other_textbox = new GTextBox(widget);
|
|
|
|
other_textbox->set_relative_rect({ 5, 140, 90, 20 });
|
2019-01-26 05:39:13 +00:00
|
|
|
|
2019-01-27 19:22:06 +00:00
|
|
|
auto* checkbox = new GCheckBox(widget);
|
|
|
|
checkbox->set_relative_rect({ 5, 170, 90, 20 });
|
|
|
|
checkbox->set_caption("CheckBox");
|
|
|
|
|
2019-01-26 05:39:13 +00:00
|
|
|
window->set_focused_widget(textbox);
|
|
|
|
|
2019-01-20 23:31:11 +00:00
|
|
|
return window;
|
|
|
|
}
|