source: abuse/tags/pd/macabuse/imlib/port/mac/mouse.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
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
9extern CWindowPtr mainwin;
10extern int PixMult;
11
12unsigned char def_mouse[]=
13    { 0,2,0,0,0,0,0,0,
14      2,1,2,0,0,0,0,0,
15      2,1,1,2,0,0,0,0,
16      2,1,1,1,2,0,0,0,
17      2,1,1,1,1,2,0,0,
18      2,1,1,1,1,1,2,0,
19      0,2,1,1,2,2,0,0,
20      0,0,2,1,1,2,0,0,
21      0,0,2,1,1,2,0,0,
22      0,0,0,2,2,0,0,0 };
23
24
25void JCMouse::set_shape(image *im, int centerx, int centery)
26{
27  sp->change_visual(im,1);
28  cx=-centerx;
29  cy=-centery;
30}
31
32JCMouse::JCMouse(image *Screen, palette *pal)
33{
34  image *im;
35  int br,dr,h;
36  filter f;
37  but=0;
38  cx=cy=0;
39  here=1;
40  sp=NULL;
41  if (here)                     // is it here?
42  {
43    screen=Screen;
44    br=pal->brightest(1);
45    dr=pal->darkest(1);
46    f.set(1,br);
47    f.set(2,dr);
48    im=new image(8,10,def_mouse);
49    f.apply(im);
50    sp=new sprite(Screen,im,100,100);
51  }
52  mx=Screen->width()/2;
53  my=Screen->height()/2;
54
55}
56
57void JCMouse::update(int newx, int newy, int new_but)
58{
59  int butn,xx,yy;
60  Point p;
61
62  if (newx<0)
63  {
64    lx=mx; ly=my; lbut=but;
65
66          ::GetMouse(&p);
67          mx = p.h/PixMult;
68          my = p.v/PixMult;
69
70    but=Button();
71  }
72  else
73  {
74        mx=newx; my=newy; but=new_but;
75  }
76}
77
78void JCMouse::set_position(int new_mx, int new_my)
79{
80  mx=new_mx;
81  my=new_my;
82//  XWarpPointer(display,mainwin,mainwin,0,0,0,0,new_mx,new_my);
83}
84
85JCMouse::~JCMouse()
86{
87  if (sp)
88  {
89    delete sp->visual;
90    delete sp;
91  }
92}
93
94
95
96
Note: See TracBrowser for help on using the repository browser.