Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
63
Task/Window-creation-X11/BaCon/window-creation-x11.bacon
Normal file
63
Task/Window-creation-X11/BaCon/window-creation-x11.bacon
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
'--- added a flush to exit cleanly
|
||||
PRAGMA LDFLAGS `pkg-config --cflags --libs x11`
|
||||
PRAGMA INCLUDE <X11/Xlib.h>
|
||||
PRAGMA INCLUDE <X11/Xutil.h>
|
||||
|
||||
OPTION PARSE FALSE
|
||||
|
||||
'---XLIB is so ugly
|
||||
ALIAS XNextEvent TO EVENT
|
||||
ALIAS XOpenDisplay TO DISPLAY
|
||||
ALIAS DefaultScreen TO SCREEN
|
||||
ALIAS XCreateSimpleWindow TO CREATE
|
||||
ALIAS XCloseDisplay TO CLOSE_DISPLAY
|
||||
ALIAS XSelectInput TO EVENT_TYPE
|
||||
ALIAS XMapWindow TO MAP_EVENT
|
||||
ALIAS XFillRectangle TO FILL_RECTANGLE
|
||||
ALIAS XDrawString TO DRAW_STRING
|
||||
ALIAS XFlush TO FLUSH
|
||||
|
||||
|
||||
'---pointer to X Display structure
|
||||
DECLARE d TYPE Display*
|
||||
|
||||
'---pointer to the newly created window
|
||||
'DECLARE w TYPE WINDOW
|
||||
|
||||
'---pointer to the XEvent
|
||||
DECLARE e TYPE XEvent
|
||||
|
||||
DECLARE msg TYPE char*
|
||||
|
||||
'--- number of screen to place the window on
|
||||
DECLARE s TYPE int
|
||||
|
||||
|
||||
|
||||
msg = "Hello, World!"
|
||||
|
||||
|
||||
d = DISPLAY(NULL)
|
||||
IF d == NULL THEN
|
||||
EPRINT "Cannot open display" FORMAT "%s%s\n"
|
||||
END
|
||||
END IF
|
||||
|
||||
s = SCREEN(d)
|
||||
w = CREATE(d, RootWindow(d, s), 10, 10, 100, 100, 1,BlackPixel(d, s), WhitePixel(d, s))
|
||||
|
||||
EVENT_TYPE(d, w, ExposureMask | KeyPressMask)
|
||||
MAP_EVENT(d, w)
|
||||
|
||||
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
|
||||
FLUSH(d)
|
||||
CLOSE_DISPLAY(d)
|
||||
Loading…
Add table
Add a link
Reference in a new issue