-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.hpp
73 lines (58 loc) · 1.55 KB
/
window.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <X11/Xlib.h> //-lX11
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;
#define EXIT_B 9
#define LEFT_B 113
#define RIGHT_B 114
#define UP_B 111
#define DOWN_B 116
Display *dis;
int scr;
Window win;
XFontStruct *fontInfo;
int sx = 300, sy = 300;
GC gc;
unsigned long black, white, red, blue, green;
unsigned long RGB(int r, int g, int b){
return b + (g << 8) + (r << 16);
}
void draw(){
XClearWindow(dis, win);
}
void create(){
if((dis = XOpenDisplay(NULL)) == NULL){
cout<<"Cannot open dispay\n";
exit(0);
}
if ( (fontInfo = XLoadQueryFont(dis, "*-courier-*" )) == NULL){
printf("Font not found!\n");
exit(1);
}
Font fnt = XLoadFont(dis, "*-courier-*");
black = RGB(0, 0, 0);
white = RGB(255, 255, 255);
red = RGB(255, 100, 100);
blue = RGB(100, 100, 255);
green = RGB(0, 200, 50);
scr = DefaultScreen(dis);
win = XCreateSimpleWindow(dis, DefaultRootWindow(dis), 0, 0, sx, sy, 5, green, blue);
XSetStandardProperties(dis, win, "Nira", "Microsystem", None, NULL, 0, NULL);
//XSelectInput(dis, win, Expose | ButtonPressMask | KeyPressMask);
XSelectInput(dis, win, ButtonPressMask | KeyPressMask);
gc = XCreateGC(dis, win, 0,0);
XSetFont(dis, gc, fnt);
XSetBackground(dis, gc, green);
XSetForeground(dis, gc, blue);
XClearWindow(dis, win);
XMapRaised(dis, win);
}
void close(){
XFreeGC(dis, gc);
XDestroyWindow(dis, win);
XCloseDisplay(dis);
exit(0);
}