1/* 2 NSCursor_PPUtilities.m 3 4 Copyright 2013-2018 Josh Freeman 5 http://www.twilightedge.com 6 7 This file is part of PikoPixel for Mac OS X and GNUstep. 8 PikoPixel is a graphical application for drawing & editing pixel-art images. 9 10 PikoPixel is free software: you can redistribute it and/or modify it under 11 the terms of the GNU Affero General Public License as published by the 12 Free Software Foundation, either version 3 of the License, or (at your 13 option) any later version approved for PikoPixel by its copyright holder (or 14 an authorized proxy). 15 16 PikoPixel is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 19 details. 20 21 You should have received a copy of the GNU Affero General Public License 22 along with this program. If not, see <http://www.gnu.org/licenses/>. 23*/ 24 25#import "NSCursor_PPUtilities.h" 26 27#import "PPCursorDefines.h" 28 29 30@implementation NSCursor (PPUtilities) 31 32+ (NSCursor *) ppPencilCursor 33{ 34 static NSCursor *pencilCursor = nil; 35 36 if (!pencilCursor) 37 { 38 pencilCursor = 39 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_Pencil] 40 hotSpot: kPPCursorHotSpotPoint_Pencil]; 41 } 42 43 return pencilCursor; 44} 45 46+ (NSCursor *) ppEraserCursor; 47{ 48 static NSCursor *eraserCursor = nil; 49 50 if (!eraserCursor) 51 { 52 eraserCursor = 53 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_Eraser] 54 hotSpot: kPPCursorHotSpotPoint_Eraser]; 55 } 56 57 return eraserCursor; 58} 59 60+ (NSCursor *) ppFillToolCursor; 61{ 62 static NSCursor *fillBucketCursor = nil; 63 64 if (!fillBucketCursor) 65 { 66 fillBucketCursor = 67 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_FillBucket] 68 hotSpot: kPPCursorHotSpotPoint_FillBucket]; 69 } 70 71 return fillBucketCursor; 72} 73 74+ (NSCursor *) ppLineToolCursor; 75{ 76 static NSCursor *lineToolCursor = nil; 77 78 if (!lineToolCursor) 79 { 80 lineToolCursor = 81 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_LineTool] 82 hotSpot: kPPCursorHotSpotPoint_LineTool]; 83 } 84 85 return lineToolCursor; 86} 87 88+ (NSCursor *) ppRectToolCursor; 89{ 90 static NSCursor *rectToolCursor = nil; 91 92 if (!rectToolCursor) 93 { 94 rectToolCursor = 95 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_RectTool] 96 hotSpot: kPPCursorHotSpotPoint_RectTool]; 97 } 98 99 return rectToolCursor; 100} 101 102+ (NSCursor *) ppOvalToolCursor; 103{ 104 static NSCursor *ovalToolCursor = nil; 105 106 if (!ovalToolCursor) 107 { 108 ovalToolCursor = 109 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_OvalTool] 110 hotSpot: kPPCursorHotSpotPoint_OvalTool]; 111 } 112 113 return ovalToolCursor; 114} 115 116+ (NSCursor *) ppFreehandSelectCursor; 117{ 118 static NSCursor *freehandSelectCursor = nil; 119 120 if (!freehandSelectCursor) 121 { 122 freehandSelectCursor = 123 [[NSCursor alloc] initWithImage: 124 [NSImage imageNamed: kPPCursorImageName_FreehandSelect] 125 hotSpot: kPPCursorHotSpotPoint_FreehandSelect]; 126 } 127 128 return freehandSelectCursor; 129} 130 131+ (NSCursor *) ppRectSelectCursor; 132{ 133 static NSCursor *rectSelectCursor = nil; 134 135 if (!rectSelectCursor) 136 { 137 rectSelectCursor = 138 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_RectSelect] 139 hotSpot: kPPCursorHotSpotPoint_RectSelect]; 140 } 141 142 return rectSelectCursor; 143} 144 145+ (NSCursor *) ppMagicWandCursor; 146{ 147 static NSCursor *magicWandCursor = nil; 148 149 if (!magicWandCursor) 150 { 151 magicWandCursor = 152 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_MagicWand] 153 hotSpot: kPPCursorHotSpotPoint_MagicWand]; 154 } 155 156 return magicWandCursor; 157} 158 159+ (NSCursor *) ppColorSamplerToolCursor; 160{ 161 static NSCursor *colorSamplerCursor = nil; 162 163 if (!colorSamplerCursor) 164 { 165 colorSamplerCursor = 166 [[NSCursor alloc] initWithImage: 167 [NSImage imageNamed: kPPCursorImageName_ColorSampler] 168 hotSpot: kPPCursorHotSpotPoint_ColorSampler]; 169 } 170 171 return colorSamplerCursor; 172} 173 174+ (NSCursor *) ppMoveToolCursor; 175{ 176 static NSCursor *moveToolCursor = nil; 177 178 if (!moveToolCursor) 179 { 180 moveToolCursor = 181 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_MoveTool] 182 hotSpot: kPPCursorHotSpotPoint_MoveTool]; 183 } 184 185 return moveToolCursor; 186} 187 188+ (NSCursor *) ppMoveSelectionOutlineToolCursor 189{ 190 static NSCursor *moveSelectionOutlineToolCursor = nil; 191 192 if (!moveSelectionOutlineToolCursor) 193 { 194 moveSelectionOutlineToolCursor = 195 [[NSCursor alloc] initWithImage: 196 [NSImage imageNamed: 197 kPPCursorImageName_MoveSelectionOutlineTool] 198 hotSpot: kPPCursorHotSpotPoint_MoveTool]; 199 } 200 201 return moveSelectionOutlineToolCursor; 202} 203 204+ (NSCursor *) ppMagnifierCursor; 205{ 206 static NSCursor *magnifierCursor = nil; 207 208 if (!magnifierCursor) 209 { 210 magnifierCursor = 211 [[NSCursor alloc] initWithImage: [NSImage imageNamed: kPPCursorImageName_Magnifier] 212 hotSpot: kPPCursorHotSpotPoint_Magnifier]; 213 } 214 215 return magnifierCursor; 216} 217 218+ (NSCursor *) ppColorRampToolCursor 219{ 220 static NSCursor *colorRampToolCursor = nil; 221 222 if (!colorRampToolCursor) 223 { 224 colorRampToolCursor = 225 [[NSCursor alloc] initWithImage: 226 [NSImage imageNamed: kPPCursorImageName_ColorRampTool] 227 hotSpot: kPPCursorHotSpotPoint_ColorRampTool]; 228 } 229 230 return colorRampToolCursor; 231} 232 233@end 234