1 | #include "video.hpp" |
---|
2 | #include "sprite.hpp" |
---|
3 | #include "image.hpp" |
---|
4 | #include "filter.hpp" |
---|
5 | #include "mdlread.hpp" |
---|
6 | #include "monoprnt.hpp" |
---|
7 | #include "mouse.hpp" |
---|
8 | #include "xinclude.h" |
---|
9 | |
---|
10 | extern Window root,mainwin; |
---|
11 | extern Display *display; |
---|
12 | extern int screen_num; |
---|
13 | extern Colormap XCMap; |
---|
14 | extern Screen *screen_ptr; |
---|
15 | extern unsigned border_width,depth; |
---|
16 | extern GC gc; |
---|
17 | extern XFontStruct *font_info; |
---|
18 | extern XImage *XImg; |
---|
19 | extern int pixel_scale; |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | unsigned char def_mouse[]= |
---|
26 | { 0,2,0,0,0,0,0,0, |
---|
27 | 2,1,2,0,0,0,0,0, |
---|
28 | 2,1,1,2,0,0,0,0, |
---|
29 | 2,1,1,1,2,0,0,0, |
---|
30 | 2,1,1,1,1,2,0,0, |
---|
31 | 2,1,1,1,1,1,2,0, |
---|
32 | 0,2,1,1,2,2,0,0, |
---|
33 | 0,0,2,1,1,2,0,0, |
---|
34 | 0,0,2,1,1,2,0,0, |
---|
35 | 0,0,0,2,2,0,0,0 }; |
---|
36 | |
---|
37 | |
---|
38 | void JCMouse::set_shape(image *im, int centerx, int centery) |
---|
39 | { |
---|
40 | sp->change_visual(im,1); |
---|
41 | cx=-centerx; |
---|
42 | cy=-centery; |
---|
43 | } |
---|
44 | |
---|
45 | JCMouse::JCMouse(image *Screen, palette *pal) |
---|
46 | { |
---|
47 | image *im; |
---|
48 | int br,dr,h; |
---|
49 | filter f; |
---|
50 | but=0; |
---|
51 | cx=cy=0; |
---|
52 | here=1; |
---|
53 | sp=NULL; |
---|
54 | if (here) // is it here? |
---|
55 | { |
---|
56 | screen=Screen; |
---|
57 | br=pal->brightest(1); |
---|
58 | dr=pal->darkest(1); |
---|
59 | f.set(1,br); |
---|
60 | f.set(2,dr); |
---|
61 | im=new image(8,10,def_mouse); |
---|
62 | f.apply(im); |
---|
63 | sp=new sprite(Screen,im,100,100); |
---|
64 | } |
---|
65 | mx=Screen->width()/2; |
---|
66 | my=Screen->height()/2; |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | void JCMouse::update(int newx, int newy, int new_but) |
---|
71 | { |
---|
72 | int butn,xx,yy; |
---|
73 | if (newx<0) |
---|
74 | { |
---|
75 | Window w1,w2; |
---|
76 | int j; |
---|
77 | unsigned int mask; |
---|
78 | lx=mx; ly=my; lbut=but; |
---|
79 | XQueryPointer(display,mainwin,&w1,&w2,&j,&j,&mx,&my,&mask); |
---|
80 | but=((mask&Button1Mask)!=0)| |
---|
81 | ((mask&Button2Mask)!=0)<<2| |
---|
82 | ((mask&Button3Mask)!=0)<<1; |
---|
83 | } else |
---|
84 | { mx=newx; my=newy; but=new_but; } |
---|
85 | } |
---|
86 | |
---|
87 | void JCMouse::set_position(int new_mx, int new_my) |
---|
88 | { |
---|
89 | mx=new_mx; |
---|
90 | my=new_my; |
---|
91 | XWarpPointer(display,mainwin,mainwin,0,0,0,0,new_mx*pixel_scale,new_my*pixel_scale); |
---|
92 | } |
---|
93 | |
---|
94 | JCMouse::~JCMouse() |
---|
95 | { |
---|
96 | if (sp) |
---|
97 | { |
---|
98 | delete sp->visual; |
---|
99 | delete sp; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | |
---|