Mercurial > sdl-ios-xcode
comparison src/video/bwindow/SDL_sysmouse.cc @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
39 { | 39 { |
40 char *bits; | 40 char *bits; |
41 }; | 41 }; |
42 | 42 |
43 /* Can this be done in the BeOS? */ | 43 /* Can this be done in the BeOS? */ |
44 WMcursor *BE_CreateWMCursor (_THIS, | 44 WMcursor *BE_CreateWMCursor(_THIS, |
45 Uint8 * data, Uint8 * mask, int w, int h, | 45 Uint8 * data, Uint8 * mask, int w, int h, |
46 int hot_x, int hot_y) | 46 int hot_x, int hot_y) |
47 { | 47 { |
48 WMcursor *cursor; | 48 WMcursor *cursor; |
49 int allowed_x; | 49 int allowed_x; |
50 int allowed_y; | 50 int allowed_y; |
51 int run, pad, i; | 51 int run, pad, i; |
53 | 53 |
54 allowed_x = 16; /* BeOS limitation */ | 54 allowed_x = 16; /* BeOS limitation */ |
55 allowed_y = 16; /* BeOS limitation */ | 55 allowed_y = 16; /* BeOS limitation */ |
56 if ((w > allowed_x) || (h > allowed_y)) | 56 if ((w > allowed_x) || (h > allowed_y)) |
57 { | 57 { |
58 SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", | 58 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", |
59 allowed_x, allowed_y); | 59 allowed_x, allowed_y); |
60 return (NULL); | 60 return (NULL); |
61 } | 61 } |
62 | 62 |
63 /* Allocate the cursor */ | 63 /* Allocate the cursor */ |
64 cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); | 64 cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); |
65 if (cursor == NULL) { | 65 if (cursor == NULL) { |
66 SDL_OutOfMemory (); | 66 SDL_OutOfMemory(); |
67 return (NULL); | 67 return (NULL); |
68 } | 68 } |
69 cursor->bits = | 69 cursor->bits = |
70 (char *) SDL_malloc (4 + 2 * ((allowed_x / 8) * allowed_y)); | 70 (char *) SDL_malloc(4 + 2 * ((allowed_x / 8) * allowed_y)); |
71 if (cursor->bits == NULL) { | 71 if (cursor->bits == NULL) { |
72 SDL_free (cursor); | 72 SDL_free(cursor); |
73 SDL_OutOfMemory (); | 73 SDL_OutOfMemory(); |
74 return (NULL); | 74 return (NULL); |
75 } | 75 } |
76 cursor->bits[0] = allowed_y; /* Size of the cursor */ | 76 cursor->bits[0] = allowed_y; /* Size of the cursor */ |
77 cursor->bits[1] = 1; /* Bit depth of cursor */ | 77 cursor->bits[1] = 1; /* Bit depth of cursor */ |
78 cursor->bits[2] = hot_y; | 78 cursor->bits[2] = hot_y; |
79 cursor->bits[3] = hot_x; | 79 cursor->bits[3] = hot_x; |
80 cptr = &cursor->bits[4]; | 80 cptr = &cursor->bits[4]; |
81 | 81 |
82 /* Pad out to the normal cursor size */ | 82 /* Pad out to the normal cursor size */ |
83 run = PADDED_BITS (w); | 83 run = PADDED_BITS(w); |
84 pad = PADDED_BITS (allowed_x) - run; | 84 pad = PADDED_BITS(allowed_x) - run; |
85 for (i = 0; i < h; ++i) { | 85 for (i = 0; i < h; ++i) { |
86 SDL_memcpy (cptr, data, run); | 86 SDL_memcpy(cptr, data, run); |
87 SDL_memset (cptr + run, 0, pad); | 87 SDL_memset(cptr + run, 0, pad); |
88 data += run; | 88 data += run; |
89 cptr += (run + pad); | 89 cptr += (run + pad); |
90 } | 90 } |
91 for (; i < allowed_y; ++i) { | 91 for (; i < allowed_y; ++i) { |
92 SDL_memset (cptr, 0, run + pad); | 92 SDL_memset(cptr, 0, run + pad); |
93 cptr += (run + pad); | 93 cptr += (run + pad); |
94 } | 94 } |
95 for (i = 0; i < h; ++i) { | 95 for (i = 0; i < h; ++i) { |
96 /* 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 |
97 inverted color pixels black, since inverted color pixels | 97 inverted color pixels black, since inverted color pixels |
98 aren't supported under BeOS. | 98 aren't supported under BeOS. |
99 */ | 99 */ |
100 SDL_memcpy (cptr, mask, run); | 100 SDL_memcpy(cptr, mask, run); |
101 SDL_memset (cptr + run, 0, pad); | 101 SDL_memset(cptr + run, 0, pad); |
102 mask += run; | 102 mask += run; |
103 cptr += (run + pad); | 103 cptr += (run + pad); |
104 } | 104 } |
105 for (; i < allowed_y; ++i) { | 105 for (; i < allowed_y; ++i) { |
106 SDL_memset (cptr, 0, run + pad); | 106 SDL_memset(cptr, 0, run + pad); |
107 cptr += (run + pad); | 107 cptr += (run + pad); |
108 } | 108 } |
109 return (cursor); | 109 return (cursor); |
110 } | 110 } |
111 | 111 |
112 int BE_ShowWMCursor (_THIS, WMcursor * cursor) | 112 int BE_ShowWMCursor(_THIS, WMcursor * cursor) |
113 { | 113 { |
114 if (be_app->Lock ()) { | 114 if (be_app->Lock()) { |
115 if (cursor == NULL) { | 115 if (cursor == NULL) { |
116 if (SDL_BlankCursor != NULL) { | 116 if (SDL_BlankCursor != NULL) { |
117 be_app->SetCursor (SDL_BlankCursor->bits); | 117 be_app->SetCursor(SDL_BlankCursor->bits); |
118 } | 118 } |
119 } else { | 119 } else { |
120 be_app->SetCursor (cursor->bits); | 120 be_app->SetCursor(cursor->bits); |
121 } | 121 } |
122 be_app->Unlock (); | 122 be_app->Unlock(); |
123 } | 123 } |
124 return (1); | 124 return (1); |
125 } | 125 } |
126 | 126 |
127 void BE_FreeWMCursor (_THIS, WMcursor * cursor) | 127 void BE_FreeWMCursor(_THIS, WMcursor * cursor) |
128 { | 128 { |
129 SDL_free (cursor->bits); | 129 SDL_free(cursor->bits); |
130 SDL_free (cursor); | 130 SDL_free(cursor); |
131 } | 131 } |
132 | 132 |
133 /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */ | 133 /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */ |
134 void BE_WarpWMCursor (_THIS, Uint16 x, Uint16 y) | 134 void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y) |
135 { | 135 { |
136 BPoint pt (x, y); | 136 BPoint pt(x, y); |
137 SDL_Win->Lock (); | 137 SDL_Win->Lock(); |
138 SDL_Win->ConvertToScreen (&pt); | 138 SDL_Win->ConvertToScreen(&pt); |
139 SDL_Win->Unlock (); | 139 SDL_Win->Unlock(); |
140 set_mouse_position ((int32) pt.x, (int32) pt.y); | 140 set_mouse_position((int32) pt.x, (int32) pt.y); |
141 } | 141 } |
142 | 142 |
143 }; /* Extern C */ | 143 }; /* Extern C */ |
144 | 144 |
145 /* vi: set ts=4 sw=4 expandtab: */ | 145 /* vi: set ts=4 sw=4 expandtab: */ |