Window creation/X11: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 657: | Line 657: | ||
<lang qbasic> |
<lang qbasic> |
||
'--- added a flush to exit cleanly |
'--- added a flush to exit cleanly |
||
PRAGMA LDFLAGS `pkg-config --cflags --libs x11` |
PRAGMA LDFLAGS `pkg-config --cflags --libs x11` |
||
PRAGMA INCLUDE <X11/Xlib.h> |
PRAGMA INCLUDE <X11/Xlib.h> |
||
PRAGMA INCLUDE <X11/Xutil.h> |
PRAGMA INCLUDE <X11/Xutil.h> |
||
PRAGMA INCLUDE <string.h> |
|||
⚫ | |||
⚫ | |||
'---XLIB is so ugly |
'---XLIB is so ugly |
||
ALIAS XNextEvent TO EVENT |
ALIAS XNextEvent TO EVENT |
||
Line 676: | Line 677: | ||
ALIAS XFlush TO FLUSH |
ALIAS XFlush TO FLUSH |
||
'---pointer to X Display structure |
'---pointer to X Display structure |
||
DECLARE d TYPE Display* |
DECLARE d TYPE Display* |
||
'---pointer to the newly created window |
'---pointer to the newly created window |
||
DECLARE w TYPE |
'DECLARE w TYPE WINDOW |
||
'---pointer to the XEvent |
'---pointer to the XEvent |
||
Line 689: | Line 691: | ||
'--- number of screen to place the window on |
'--- number of screen to place the window on |
||
DECLARE s TYPE int |
DECLARE s TYPE int |
||
msg = "Hello, World!" |
msg = "Hello, World!" |
||
d = DISPLAY(NULL) |
d = DISPLAY(NULL) |
||
IF d == NULL THEN |
IF d == NULL THEN |
||
EPRINT "Cannot open display" FORMAT "%s%s\n" |
|||
END |
|||
END IF |
END IF |
||
s = SCREEN(d) |
s = SCREEN(d) |
||
w = CREATE(d, RootWindow(d, s), 10, 10, 100, 100, 1,BlackPixel(d, s), WhitePixel(d, s)) |
w = CREATE(d, RootWindow(d, s), 10, 10, 100, 100, 1,BlackPixel(d, s), WhitePixel(d, s)) |
||
EVENT_TYPE(d, w, ExposureMask | KeyPressMask) |
EVENT_TYPE(d, w, ExposureMask | KeyPressMask) |
||
MAP_EVENT(d, w) |
MAP_EVENT(d, w) |
||
WHILE (1) |
WHILE (1) |
||
EVENT(d, &e) |
|||
IF e.type == Expose THEN |
|||
FILL_RECTANGLE(d, w, DefaultGC(d, s), 20, 20, 10, 10) |
|||
DRAW_STRING(d, w, DefaultGC(d, s), 10, 50, msg, strlen(msg)) |
|||
END IF |
|||
IF e.type == KeyPress THEN |
|||
BREAK |
|||
END IF |
|||
WEND |
WEND |
||
FLUSH(d) |
FLUSH(d) |
||
CLOSE_DISPLAY(d) |
CLOSE_DISPLAY(d) |
||
⚫ | |||
⚫ | |||
=={{header|C}}== |
=={{header|C}}== |