1/* 2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "Cursor.h" 28#include "Image.h" 29 30#include <wx/defs.h> 31#include <wx/cursor.h> 32#include <wx/image.h> 33 34namespace WebCore { 35 36Cursor::Cursor(const Cursor& other) 37 : m_impl(other.m_impl) 38{ 39} 40 41Cursor::Cursor(Image* image, const IntPoint&) 42{ 43 m_impl = 0; 44 // FIXME: figure out why the below code causes a crash 45 //m_impl = new wxCursor( image->getWxBitmap()->ConvertToImage() ); 46} 47 48Cursor::~Cursor() 49{ 50} 51 52Cursor& Cursor::operator=(const Cursor& other) 53{ 54 m_impl = other.m_impl; 55 return *this; 56} 57 58Cursor::Cursor(wxCursor* c) 59 : m_impl(c) 60{ 61} 62 63const Cursor& pointerCursor() 64{ 65 static Cursor c = new wxCursor(wxCURSOR_ARROW); 66 return c; 67} 68 69const Cursor& crossCursor() 70{ 71 static Cursor c = new wxCursor(wxCURSOR_CROSS); 72 return c; 73} 74 75const Cursor& handCursor() 76{ 77 static Cursor c = new wxCursor(wxCURSOR_HAND); 78 return c; 79} 80 81const Cursor& iBeamCursor() 82{ 83 static Cursor c = new wxCursor(wxCURSOR_IBEAM); 84 return c; 85} 86 87const Cursor& waitCursor() 88{ 89 static Cursor c = new wxCursor(wxCURSOR_WAIT); 90 return c; 91} 92 93const Cursor& helpCursor() 94{ 95 static Cursor c = new wxCursor(wxCURSOR_QUESTION_ARROW); 96 return c; 97} 98 99const Cursor& eastResizeCursor() 100{ 101 static Cursor c = new wxCursor(wxCURSOR_SIZEWE); 102 return c; 103} 104 105const Cursor& northResizeCursor() 106{ 107 static Cursor c = new wxCursor(wxCURSOR_SIZENS); 108 return c; 109} 110 111const Cursor& northEastResizeCursor() 112{ 113 static Cursor c = new wxCursor(wxCURSOR_SIZENESW); 114 return c; 115} 116 117const Cursor& northWestResizeCursor() 118{ 119 static Cursor c = new wxCursor(wxCURSOR_SIZENWSE); 120 return c; 121} 122 123const Cursor& southResizeCursor() 124{ 125 static Cursor c = northResizeCursor(); 126 return c; 127} 128 129const Cursor& southEastResizeCursor() 130{ 131 static Cursor c = northWestResizeCursor(); 132 return c; 133} 134 135const Cursor& southWestResizeCursor() 136{ 137 static Cursor c = northEastResizeCursor(); 138 return c; 139} 140 141const Cursor& westResizeCursor() 142{ 143 static Cursor c = eastResizeCursor(); 144 return c; 145} 146 147const Cursor& northSouthResizeCursor() 148{ 149 static Cursor c = northResizeCursor(); 150 return c; 151} 152 153const Cursor& eastWestResizeCursor() 154{ 155 static Cursor c = eastResizeCursor(); 156 return c; 157} 158 159const Cursor& northEastSouthWestResizeCursor() 160{ 161 static Cursor c = northEastResizeCursor(); 162 return c; 163} 164 165const Cursor& northWestSouthEastResizeCursor() 166{ 167 static Cursor c = northWestResizeCursor(); 168 return c; 169} 170 171const Cursor& columnResizeCursor() 172{ 173 // FIXME: Windows does not have a standard column resize cursor 174 static Cursor c = new wxCursor(wxCURSOR_SIZING); 175 return c; 176} 177 178const Cursor& rowResizeCursor() 179{ 180 // FIXME: Windows does not have a standard row resize cursor 181 static Cursor c = new wxCursor(wxCURSOR_SIZING); 182 return c; 183} 184 185const Cursor& middlePanningCursor() 186{ 187 return moveCursor(); 188} 189 190const Cursor& eastPanningCursor() 191{ 192 return eastResizeCursor(); 193} 194 195const Cursor& northPanningCursor() 196{ 197 return northResizeCursor(); 198} 199 200const Cursor& northEastPanningCursor() 201{ 202 return northEastResizeCursor(); 203} 204 205const Cursor& northWestPanningCursor() 206{ 207 return northWestResizeCursor(); 208} 209 210const Cursor& southPanningCursor() 211{ 212 return southResizeCursor(); 213} 214 215const Cursor& southEastPanningCursor() 216{ 217 return southEastResizeCursor(); 218} 219 220const Cursor& southWestPanningCursor() 221{ 222 return southWestResizeCursor(); 223} 224 225const Cursor& westPanningCursor() 226{ 227 return westResizeCursor(); 228} 229 230const Cursor& verticalTextCursor() 231{ 232 return iBeamCursor(); 233} 234 235const Cursor& cellCursor() 236{ 237 return pointerCursor(); 238} 239 240const Cursor& contextMenuCursor() 241{ 242 return handCursor(); 243} 244 245const Cursor& noDropCursor() 246{ 247 return pointerCursor(); 248} 249 250const Cursor& progressCursor() 251{ 252 return waitCursor(); 253} 254 255const Cursor& aliasCursor() 256{ 257 return pointerCursor(); 258} 259 260const Cursor& copyCursor() 261{ 262 return pointerCursor(); 263} 264 265const Cursor& noneCursor() 266{ 267 // TODO: Determine if we can find a better cursor for this. 268 return pointerCursor(); 269} 270 271const Cursor& notAllowedCursor() 272{ 273 static Cursor c = new wxCursor(wxCURSOR_NO_ENTRY); 274 return c; 275} 276 277const Cursor& zoomInCursor() 278{ 279 static Cursor c = new wxCursor(wxCURSOR_MAGNIFIER); 280 return c; 281} 282 283const Cursor& zoomOutCursor() 284{ 285 // TODO: Find a way to implement in/out magnifiers in wx. 286 return zoomInCursor(); 287} 288 289const Cursor& grabCursor() 290{ 291 // TODO: Determine if we can find a better cursor for this. 292 return pointerCursor(); 293} 294 295const Cursor& grabbingCursor() 296{ 297 // TODO: Determine if we can find a better cursor for this. 298 return pointerCursor(); 299} 300 301const Cursor& moveCursor() 302{ 303 static Cursor c = new wxCursor(wxCURSOR_SIZING); 304 return c; 305} 306 307} 308