1 /* 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 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 #ifndef Cursor_h 27 #define Cursor_h 28 29 #include "core/platform/graphics/Image.h" 30 #include "core/platform/graphics/IntPoint.h" 31 #include "wtf/Assertions.h" 32 #include "wtf/RefPtr.h" 33 34 namespace WebCore { 35 36 class Cursor { 37 WTF_MAKE_FAST_ALLOCATED; 38 public: 39 enum Type { 40 Pointer = 0, 41 Cross, 42 Hand, 43 IBeam, 44 Wait, 45 Help, 46 EastResize, 47 NorthResize, 48 NorthEastResize, 49 NorthWestResize, 50 SouthResize, 51 SouthEastResize, 52 SouthWestResize, 53 WestResize, 54 NorthSouthResize, 55 EastWestResize, 56 NorthEastSouthWestResize, 57 NorthWestSouthEastResize, 58 ColumnResize, 59 RowResize, 60 MiddlePanning, 61 EastPanning, 62 NorthPanning, 63 NorthEastPanning, 64 NorthWestPanning, 65 SouthPanning, 66 SouthEastPanning, 67 SouthWestPanning, 68 WestPanning, 69 Move, 70 VerticalText, 71 Cell, 72 ContextMenu, 73 Alias, 74 Progress, 75 NoDrop, 76 Copy, 77 None, 78 NotAllowed, 79 ZoomIn, 80 ZoomOut, 81 Grab, 82 Grabbing, 83 Custom 84 }; 85 86 static const Cursor& fromType(Cursor::Type); 87 88 Cursor() 89 // This is an invalid Cursor and should never actually get used. 90 : m_type(static_cast<Type>(-1)) 91 { 92 } 93 94 Cursor(Image*, const IntPoint& hotSpot); 95 96 // Hot spot is in image pixels. 97 Cursor(Image*, const IntPoint& hotSpot, float imageScaleFactor); 98 99 Cursor(const Cursor&); 100 ~Cursor(); 101 Cursor& operator=(const Cursor&); 102 103 explicit Cursor(Type); 104 Type type() const 105 { 106 ASSERT(m_type >= 0 && m_type <= Custom); 107 return m_type; 108 } 109 Image* image() const { return m_image.get(); } 110 const IntPoint& hotSpot() const { return m_hotSpot; } 111 // Image scale in image pixels per logical (UI) pixel. 112 float imageScaleFactor() const { return m_imageScaleFactor; } 113 114 private: 115 Type m_type; 116 RefPtr<Image> m_image; 117 IntPoint m_hotSpot; 118 float m_imageScaleFactor; 119 }; 120 121 IntPoint determineHotSpot(Image*, const IntPoint& specifiedHotSpot); 122 123 const Cursor& pointerCursor(); 124 const Cursor& crossCursor(); 125 const Cursor& handCursor(); 126 const Cursor& moveCursor(); 127 const Cursor& iBeamCursor(); 128 const Cursor& waitCursor(); 129 const Cursor& helpCursor(); 130 const Cursor& eastResizeCursor(); 131 const Cursor& northResizeCursor(); 132 const Cursor& northEastResizeCursor(); 133 const Cursor& northWestResizeCursor(); 134 const Cursor& southResizeCursor(); 135 const Cursor& southEastResizeCursor(); 136 const Cursor& southWestResizeCursor(); 137 const Cursor& westResizeCursor(); 138 const Cursor& northSouthResizeCursor(); 139 const Cursor& eastWestResizeCursor(); 140 const Cursor& northEastSouthWestResizeCursor(); 141 const Cursor& northWestSouthEastResizeCursor(); 142 const Cursor& columnResizeCursor(); 143 const Cursor& rowResizeCursor(); 144 const Cursor& middlePanningCursor(); 145 const Cursor& eastPanningCursor(); 146 const Cursor& northPanningCursor(); 147 const Cursor& northEastPanningCursor(); 148 const Cursor& northWestPanningCursor(); 149 const Cursor& southPanningCursor(); 150 const Cursor& southEastPanningCursor(); 151 const Cursor& southWestPanningCursor(); 152 const Cursor& westPanningCursor(); 153 const Cursor& verticalTextCursor(); 154 const Cursor& cellCursor(); 155 const Cursor& contextMenuCursor(); 156 const Cursor& noDropCursor(); 157 const Cursor& notAllowedCursor(); 158 const Cursor& progressCursor(); 159 const Cursor& aliasCursor(); 160 const Cursor& zoomInCursor(); 161 const Cursor& zoomOutCursor(); 162 const Cursor& copyCursor(); 163 const Cursor& noneCursor(); 164 const Cursor& grabCursor(); 165 const Cursor& grabbingCursor(); 166 167 } // namespace WebCore 168 169 #endif // Cursor_h 170