mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:57:47 +00:00
Let's use the existing Rect and Color types in the GUI API.
Any type that doesn't depend on indirect data can probably be used here.
This commit is contained in:
parent
b2d86b7597
commit
f7261d7b26
4 changed files with 68 additions and 23 deletions
50
Userland/guitest.cpp
Normal file
50
Userland/guitest.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <Kernel/GUITypes.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI_CreateWindowParameters wparams;
|
||||
wparams.rect = { 200, 200, 300, 200 };
|
||||
wparams.background_color = 0xffc0c0;
|
||||
strcpy(wparams.title, "GUI test app");
|
||||
int window_id = syscall(SC_gui_create_window, &wparams);
|
||||
if (window_id < 0) {
|
||||
perror("gui_create_window");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI_CreateWidgetParameters label_params;
|
||||
label_params.type = GUI_WidgetType::Label;
|
||||
label_params.rect = { 20, 20, 260, 20 };
|
||||
label_params.background_color = 0xffffff;
|
||||
label_params.opaque = true;
|
||||
strcpy(label_params.text, "Hello World!");
|
||||
int label_id = syscall(SC_gui_create_widget, window_id, &label_params);
|
||||
if (label_id < 0) {
|
||||
perror("gui_create_widget");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI_CreateWidgetParameters button_params;
|
||||
button_params.type = GUI_WidgetType::Button;
|
||||
button_params.rect = { 60, 60, 120, 20 };
|
||||
button_params.background_color = 0xffffff;
|
||||
button_params.opaque = true;
|
||||
strcpy(button_params.text, "I'm a button!");
|
||||
int button_id = syscall(SC_gui_create_widget, window_id, &button_params);
|
||||
if (button_id < 0) {
|
||||
perror("gui_create_widget");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue