Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 118 lines (85 sloc) 4.386 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
//
// UKPaintTool.h
// ULIPaintView
//
// Created by Uli Kusterer on Fri Oct 31 2003.
// Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//

/*
Base class for all our paint tools. ULIPaintView only knows how to do tracking
etc. for this one tool, and the tools then decide what to react to and what
to ignore.
*/

#import <AppKit/AppKit.h>

@class ULIPaintView;


@interface ULIPaintTool : NSObject
{
IBOutlet ULIPaintView* owner;
IBOutlet NSButton* toolButton;
}


+(id) paintToolWithPaintView: (ULIPaintView*)pv;


-(id) initWithPaintView: (ULIPaintView*)pv;


-(IBAction) chooseTool: (id)sender;


-(void) setOwner: (ULIPaintView*)o;
-(ULIPaintView*)owner;


-(NSButton*) toolButton;
-(void) setToolButton: (NSButton*)b;


/* Sent immediately before the first draw[Temporary]TrackingToolShapeFrom:to: message:
If you need 'trackingDidEnd', just do your clean-up in drawFinalToolShapeFrom:to: or
drawDisposableToolShapeFrom:to: */
-(void) trackingWillStart;

/* Override this to draw a shape during tracking:
The drawings you do in here will be undone before you're called again. */
-(void) drawTemporaryTrackingToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos;

/* Override this to draw a brush during tracking:
The drawings you do in here will end up in the actual image buffer. */
-(void) drawTrackingToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos;

/* Override this to draw a shape once tracking has finished:
The drawings you do here will end up in the actual image buffer. */
-(void) drawFinalToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos; // By default calls through to drawTemporaryTrackingToolShapeFrom:to:

/* The following is the "final" method for markers:
This draws into the tracking buffer, and will be erased as soon as tracking starts. */
-(void) drawDisposableToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos;


/* If you're doing something like a Text tool, where the tool just creates an editable area,
Override this:
You'll want to draw some sort of outline in drawTemporaryTrackingToolShapeFrom:to: and
create the text box in drawFinalToolShapeFrom:to:, and then delete it from this method. */
-(void) paintToolWillUnload: (id)sender;
-(void) paintToolDidLoad: (id)sender;

/* If you're drawing a shape, this will generate a rect from the two points that can be drawn: */
-(NSRect) rectFrom: (NSPoint)prevPos to: (NSPoint)currPos;

/* Like rectFrom:to: but then outsets the rectangle by a bit (usually the line
size plus a bit of slop). This is useful for getting the rect to update after
drawing something: */
-(NSRect) rectWithLineSizeFrom: (NSPoint)prevPos to: (NSPoint)currPos; // Uses paint view's default line size.
-(NSRect) rectWithLineSize: (NSSize)lineSize from: (NSPoint)prevPos to: (NSPoint)currPos;

// Return a cursor for use when this tool is current:
-(NSCursor*) drawingCursor;
-(NSCursor*) selectionCursor; // When mouse is over selection. Defaults to drawingCursor.


// Return an image to use as the icon for this tool in the tool palette:
-(NSImage*) toolIcon; // By default loads the image named toolIconName.

// Return the name of an image to use as the icon for this tool in the tool palette.
-(NSString*) toolIconName;

-(BOOL) adjustCoordinates; // Do we want this tool to get coordinates offset to draw on full pixels instead of between? Defaults to YES.

-(void) restoreSavedShapeFrom: (NSPoint)startPos to: (NSPoint*)endPos;
-(BOOL) isSaveableTool;

@end
Something went wrong with that request. Please try again.