| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | |
| 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | |
| 26 | |
| 27 #include "config.h" | |
| 28 #include "Cursor.h" | |
| 29 #include "Image.h" | |
| 30 #include "IntPoint.h" | |
| 31 #include "NativeImageSkia.h" | |
| 32 #include "NotImplemented.h" | |
| 33 | |
| 34 #include "webkit/glue/webkit_resources.h" | |
| 35 #include "webkit/glue/webkit_glue.h" | |
| 36 | |
| 37 #define ALPHA_CURSORS | |
| 38 | |
| 39 namespace WebCore { | |
| 40 | |
| 41 Cursor::Cursor(const Cursor& other) | |
| 42 : m_impl(other.m_impl) | |
| 43 { | |
| 44 } | |
| 45 | |
| 46 Cursor::Cursor(Image* img, const IntPoint& hotspot) | |
| 47 { | |
| 48 // If we don't have a valid bitmap, then fallback to the default | |
| 49 // cursor (ARROW). | |
| 50 NativeImageSkia* bitmap = img->nativeImageForCurrentFrame(); | |
| 51 if (!bitmap) | |
| 52 return; | |
| 53 | |
| 54 m_impl.set_type(WebCursor::CUSTOM); | |
| 55 m_impl.set_hotspot(hotspot.x(), hotspot.y()); | |
| 56 m_impl.set_bitmap(*bitmap); | |
| 57 } | |
| 58 | |
| 59 Cursor::~Cursor() | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 Cursor& Cursor::operator=(const Cursor& other) | |
| 64 { | |
| 65 m_impl = other.m_impl; | |
| 66 return *this; | |
| 67 } | |
| 68 | |
| 69 Cursor::Cursor(PlatformCursor c) | |
| 70 : m_impl(c) | |
| 71 { | |
| 72 } | |
| 73 | |
| 74 const Cursor& pointerCursor() | |
| 75 { | |
| 76 static Cursor c = WebCursor::ARROW; | |
| 77 return c; | |
| 78 } | |
| 79 | |
| 80 const Cursor& crossCursor() | |
| 81 { | |
| 82 static Cursor c = WebCursor::CROSS; | |
| 83 return c; | |
| 84 } | |
| 85 | |
| 86 const Cursor& handCursor() | |
| 87 { | |
| 88 static Cursor c = WebCursor::HAND; | |
| 89 return c; | |
| 90 } | |
| 91 | |
| 92 const Cursor& iBeamCursor() | |
| 93 { | |
| 94 static Cursor c = WebCursor::IBEAM; | |
| 95 return c; | |
| 96 } | |
| 97 | |
| 98 const Cursor& waitCursor() | |
| 99 { | |
| 100 static Cursor c = WebCursor::WAIT; | |
| 101 return c; | |
| 102 } | |
| 103 | |
| 104 const Cursor& helpCursor() | |
| 105 { | |
| 106 static Cursor c = WebCursor::HELP; | |
| 107 return c; | |
| 108 } | |
| 109 | |
| 110 const Cursor& eastResizeCursor() | |
| 111 { | |
| 112 static Cursor c = WebCursor::SIZEWE; | |
| 113 return c; | |
| 114 } | |
| 115 | |
| 116 const Cursor& northResizeCursor() | |
| 117 { | |
| 118 static Cursor c = WebCursor::SIZENS; | |
| 119 return c; | |
| 120 } | |
| 121 | |
| 122 const Cursor& northEastResizeCursor() | |
| 123 { | |
| 124 static Cursor c = WebCursor::SIZENESW; | |
| 125 return c; | |
| 126 } | |
| 127 | |
| 128 const Cursor& northWestResizeCursor() | |
| 129 { | |
| 130 static Cursor c = WebCursor::SIZENWSE; | |
| 131 return c; | |
| 132 } | |
| 133 | |
| 134 const Cursor& southResizeCursor() | |
| 135 { | |
| 136 static Cursor c = WebCursor::SIZENS; | |
| 137 return c; | |
| 138 } | |
| 139 | |
| 140 const Cursor& southEastResizeCursor() | |
| 141 { | |
| 142 static Cursor c = WebCursor::SIZENWSE; | |
| 143 return c; | |
| 144 } | |
| 145 | |
| 146 const Cursor& southWestResizeCursor() | |
| 147 { | |
| 148 static Cursor c = WebCursor::SIZENESW; | |
| 149 return c; | |
| 150 } | |
| 151 | |
| 152 const Cursor& westResizeCursor() | |
| 153 { | |
| 154 static Cursor c = WebCursor::SIZEWE; | |
| 155 return c; | |
| 156 } | |
| 157 | |
| 158 const Cursor& northSouthResizeCursor() | |
| 159 { | |
| 160 static Cursor c = WebCursor::SIZENS; | |
| 161 return c; | |
| 162 } | |
| 163 | |
| 164 const Cursor& eastWestResizeCursor() | |
| 165 { | |
| 166 static Cursor c = WebCursor::SIZEWE; | |
| 167 return c; | |
| 168 } | |
| 169 | |
| 170 const Cursor& northEastSouthWestResizeCursor() | |
| 171 { | |
| 172 static Cursor c = WebCursor::SIZENESW; | |
| 173 return c; | |
| 174 } | |
| 175 | |
| 176 const Cursor& northWestSouthEastResizeCursor() | |
| 177 { | |
| 178 static Cursor c = WebCursor::SIZENWSE; | |
| 179 return c; | |
| 180 } | |
| 181 | |
| 182 const Cursor& columnResizeCursor() | |
| 183 { | |
| 184 static Cursor c = WebCursor::COLRESIZE; | |
| 185 return c; | |
| 186 } | |
| 187 | |
| 188 const Cursor& rowResizeCursor() | |
| 189 { | |
| 190 static Cursor c = WebCursor::ROWRESIZE; | |
| 191 return c; | |
| 192 } | |
| 193 | |
| 194 const Cursor& middlePanningCursor() | |
| 195 { | |
| 196 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_MIDDLE); | |
| 197 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 198 return c; | |
| 199 } | |
| 200 | |
| 201 const Cursor& eastPanningCursor() | |
| 202 { | |
| 203 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_EAST); | |
| 204 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 205 return c; | |
| 206 } | |
| 207 | |
| 208 const Cursor& northPanningCursor() | |
| 209 { | |
| 210 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH); | |
| 211 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 212 return c; | |
| 213 } | |
| 214 | |
| 215 const Cursor& northEastPanningCursor() | |
| 216 { | |
| 217 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH_EAST); | |
| 218 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 219 return c; | |
| 220 } | |
| 221 | |
| 222 const Cursor& northWestPanningCursor() | |
| 223 { | |
| 224 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH_WEST); | |
| 225 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 226 return c; | |
| 227 } | |
| 228 | |
| 229 const Cursor& southPanningCursor() | |
| 230 { | |
| 231 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH); | |
| 232 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 233 return c; | |
| 234 } | |
| 235 | |
| 236 const Cursor& southEastPanningCursor() | |
| 237 { | |
| 238 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH_EAST); | |
| 239 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 240 return c; | |
| 241 } | |
| 242 | |
| 243 const Cursor& southWestPanningCursor() | |
| 244 { | |
| 245 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH_WEST); | |
| 246 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 247 return c; | |
| 248 } | |
| 249 | |
| 250 const Cursor& westPanningCursor() | |
| 251 { | |
| 252 SkBitmap* bitmap = webkit_glue::GetBitmapResource(IDC_PAN_WEST); | |
| 253 static Cursor c = WebCursor(bitmap, 7, 7); | |
| 254 return c; | |
| 255 } | |
| 256 | |
| 257 const Cursor& moveCursor() | |
| 258 { | |
| 259 static Cursor c = WebCursor::SIZEALL; | |
| 260 return c; | |
| 261 } | |
| 262 | |
| 263 const Cursor& verticalTextCursor() | |
| 264 { | |
| 265 static Cursor c = WebCursor::VERTICALTEXT; | |
| 266 return c; | |
| 267 } | |
| 268 | |
| 269 const Cursor& cellCursor() | |
| 270 { | |
| 271 static Cursor c = WebCursor::CELL; | |
| 272 return c; | |
| 273 } | |
| 274 | |
| 275 const Cursor& contextMenuCursor() | |
| 276 { | |
| 277 return pointerCursor(); | |
| 278 } | |
| 279 | |
| 280 const Cursor& aliasCursor() | |
| 281 { | |
| 282 static Cursor c = WebCursor::ALIAS; | |
| 283 return c; | |
| 284 } | |
| 285 | |
| 286 const Cursor& progressCursor() | |
| 287 { | |
| 288 static Cursor c = WebCursor::APPSTARTING; | |
| 289 return c; | |
| 290 } | |
| 291 | |
| 292 const Cursor& noDropCursor() | |
| 293 { | |
| 294 return notAllowedCursor(); | |
| 295 } | |
| 296 | |
| 297 const Cursor& copyCursor() | |
| 298 { | |
| 299 static Cursor c = WebCursor::COPYCUR; | |
| 300 return c; | |
| 301 } | |
| 302 | |
| 303 const Cursor& noneCursor() | |
| 304 { | |
| 305 return pointerCursor(); | |
| 306 } | |
| 307 | |
| 308 const Cursor& notAllowedCursor() | |
| 309 { | |
| 310 static Cursor c = WebCursor::NO; | |
| 311 return c; | |
| 312 } | |
| 313 | |
| 314 const Cursor& zoomInCursor() | |
| 315 { | |
| 316 static Cursor c = WebCursor::ZOOMIN; | |
| 317 return c; | |
| 318 } | |
| 319 | |
| 320 const Cursor& zoomOutCursor() | |
| 321 { | |
| 322 static Cursor c = WebCursor::ZOOMOUT; | |
| 323 return c; | |
| 324 } | |
| 325 | |
| 326 } | |
| OLD | NEW |