Mercurial > sdl-ios-xcode
comparison src/video/bwindow/SDL_sysmouse.cc @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 376665398b25 |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
24 #include <AppKit.h> | 24 #include <AppKit.h> |
25 #include <GameKit.h> | 25 #include <GameKit.h> |
26 | 26 |
27 #include "SDL_BWin.h" | 27 #include "SDL_BWin.h" |
28 | 28 |
29 extern "C" { | 29 extern "C" |
30 { | |
30 | 31 |
31 #include "SDL_sysmouse_c.h" | 32 #include "SDL_sysmouse_c.h" |
32 | 33 |
33 /* Convert bits to padded bytes */ | 34 /* Convert bits to padded bytes */ |
34 #define PADDED_BITS(bits) ((bits+7)/8) | 35 #define PADDED_BITS(bits) ((bits+7)/8) |
35 | 36 |
36 /* The implementation dependent data for the window manager cursor */ | 37 /* The implementation dependent data for the window manager cursor */ |
37 struct WMcursor { | 38 struct WMcursor |
38 char *bits; | 39 { |
39 }; | 40 char *bits; |
41 }; | |
40 | 42 |
41 /* Can this be done in the BeOS? */ | 43 /* Can this be done in the BeOS? */ |
42 WMcursor *BE_CreateWMCursor(_THIS, | 44 WMcursor *BE_CreateWMCursor (_THIS, |
43 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | 45 Uint8 * data, Uint8 * mask, int w, int h, |
44 { | 46 int hot_x, int hot_y) |
45 WMcursor *cursor; | 47 { |
46 int allowed_x; | 48 WMcursor *cursor; |
47 int allowed_y; | 49 int allowed_x; |
48 int run, pad, i; | 50 int allowed_y; |
49 char *cptr; | 51 int run, pad, i; |
52 char *cptr; | |
50 | 53 |
51 allowed_x = 16; /* BeOS limitation */ | 54 allowed_x = 16; /* BeOS limitation */ |
52 allowed_y = 16; /* BeOS limitation */ | 55 allowed_y = 16; /* BeOS limitation */ |
53 if ( (w > allowed_x) || (h > allowed_y) ) { | 56 if ((w > allowed_x) || (h > allowed_y)) |
54 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", | 57 { |
55 allowed_x, allowed_y); | 58 SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", |
56 return(NULL); | 59 allowed_x, allowed_y); |
57 } | 60 return (NULL); |
61 } | |
58 | 62 |
59 /* Allocate the cursor */ | 63 /* Allocate the cursor */ |
60 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); | 64 cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); |
61 if ( cursor == NULL ) { | 65 if (cursor == NULL) { |
62 SDL_OutOfMemory(); | 66 SDL_OutOfMemory (); |
63 return(NULL); | 67 return (NULL); |
64 } | 68 } |
65 cursor->bits = (char *)SDL_malloc(4+2*((allowed_x/8)*allowed_y)); | 69 cursor->bits = |
66 if ( cursor->bits == NULL ) { | 70 (char *) SDL_malloc (4 + 2 * ((allowed_x / 8) * allowed_y)); |
67 SDL_free(cursor); | 71 if (cursor->bits == NULL) { |
68 SDL_OutOfMemory(); | 72 SDL_free (cursor); |
69 return(NULL); | 73 SDL_OutOfMemory (); |
70 } | 74 return (NULL); |
71 cursor->bits[0] = allowed_y; /* Size of the cursor */ | 75 } |
72 cursor->bits[1] = 1; /* Bit depth of cursor */ | 76 cursor->bits[0] = allowed_y; /* Size of the cursor */ |
73 cursor->bits[2] = hot_y; | 77 cursor->bits[1] = 1; /* Bit depth of cursor */ |
74 cursor->bits[3] = hot_x; | 78 cursor->bits[2] = hot_y; |
75 cptr = &cursor->bits[4]; | 79 cursor->bits[3] = hot_x; |
80 cptr = &cursor->bits[4]; | |
76 | 81 |
77 /* Pad out to the normal cursor size */ | 82 /* Pad out to the normal cursor size */ |
78 run = PADDED_BITS(w); | 83 run = PADDED_BITS (w); |
79 pad = PADDED_BITS(allowed_x)-run; | 84 pad = PADDED_BITS (allowed_x) - run; |
80 for ( i=0; i<h; ++i ) { | 85 for (i = 0; i < h; ++i) { |
81 SDL_memcpy(cptr, data, run); | 86 SDL_memcpy (cptr, data, run); |
82 SDL_memset(cptr+run, 0, pad); | 87 SDL_memset (cptr + run, 0, pad); |
83 data += run; | 88 data += run; |
84 cptr += (run+pad); | 89 cptr += (run + pad); |
85 } | 90 } |
86 for ( ; i<allowed_y; ++i ) { | 91 for (; i < allowed_y; ++i) { |
87 SDL_memset(cptr, 0, run+pad); | 92 SDL_memset (cptr, 0, run + pad); |
88 cptr += (run+pad); | 93 cptr += (run + pad); |
89 } | 94 } |
90 for ( i=0; i<h; ++i ) { | 95 for (i = 0; i < h; ++i) { |
91 /* FIXME: The mask should be OR'd with the data to turn | 96 /* FIXME: The mask should be OR'd with the data to turn |
92 inverted color pixels black, since inverted color pixels | 97 inverted color pixels black, since inverted color pixels |
93 aren't supported under BeOS. | 98 aren't supported under BeOS. |
94 */ | 99 */ |
95 SDL_memcpy(cptr, mask, run); | 100 SDL_memcpy (cptr, mask, run); |
96 SDL_memset(cptr+run, 0, pad); | 101 SDL_memset (cptr + run, 0, pad); |
97 mask += run; | 102 mask += run; |
98 cptr += (run+pad); | 103 cptr += (run + pad); |
99 } | 104 } |
100 for ( ; i<allowed_y; ++i ) { | 105 for (; i < allowed_y; ++i) { |
101 SDL_memset(cptr, 0, run+pad); | 106 SDL_memset (cptr, 0, run + pad); |
102 cptr += (run+pad); | 107 cptr += (run + pad); |
103 } | 108 } |
104 return(cursor); | 109 return (cursor); |
105 } | 110 } |
106 | 111 |
107 int BE_ShowWMCursor(_THIS, WMcursor *cursor) | 112 int BE_ShowWMCursor (_THIS, WMcursor * cursor) |
108 { | 113 { |
109 if ( be_app->Lock() ) { | 114 if (be_app->Lock ()) { |
110 if ( cursor == NULL ) { | 115 if (cursor == NULL) { |
111 if ( SDL_BlankCursor != NULL ) { | 116 if (SDL_BlankCursor != NULL) { |
112 be_app->SetCursor(SDL_BlankCursor->bits); | 117 be_app->SetCursor (SDL_BlankCursor->bits); |
113 } | 118 } |
114 } else { | 119 } else { |
115 be_app->SetCursor(cursor->bits); | 120 be_app->SetCursor (cursor->bits); |
116 } | 121 } |
117 be_app->Unlock(); | 122 be_app->Unlock (); |
118 } | 123 } |
119 return(1); | 124 return (1); |
120 } | 125 } |
121 | 126 |
122 void BE_FreeWMCursor(_THIS, WMcursor *cursor) | 127 void BE_FreeWMCursor (_THIS, WMcursor * cursor) |
123 { | 128 { |
124 SDL_free(cursor->bits); | 129 SDL_free (cursor->bits); |
125 SDL_free(cursor); | 130 SDL_free (cursor); |
126 } | 131 } |
127 | 132 |
128 /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */ | 133 /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */ |
129 void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | 134 void BE_WarpWMCursor (_THIS, Uint16 x, Uint16 y) |
130 { | 135 { |
131 BPoint pt(x, y); | 136 BPoint pt (x, y); |
132 SDL_Win->Lock(); | 137 SDL_Win->Lock (); |
133 SDL_Win->ConvertToScreen(&pt); | 138 SDL_Win->ConvertToScreen (&pt); |
134 SDL_Win->Unlock(); | 139 SDL_Win->Unlock (); |
135 set_mouse_position((int32)pt.x, (int32)pt.y); | 140 set_mouse_position ((int32) pt.x, (int32) pt.y); |
136 } | 141 } |
137 | 142 |
138 }; /* Extern C */ | 143 }; /* Extern C */ |
144 | |
145 /* vi: set ts=4 sw=4 expandtab: */ |