1 /* 2 Project: Graphos 3 GRDrawableObject.h 4 5 Copyright (C) 2008-2015 GNUstep Application Project 6 7 Author: Ing. Riccardo Mottola 8 9 Created: 2008-02-25 10 11 This application is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public 13 License as published by the Free Software Foundation; either 14 version 2 of the License, or (at your option) any later version. 15 16 This application is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 Library General Public License for more details. 20 21 You should have received a copy of the GNU General Public 22 License along with this library; if not, write to the Free 23 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 */ 25 26 /** 27 * DrawableObject is a superclass for every graphics object of Graphos. 28 * It is abstract and created to standardize behaviour, it is not instantiatable itself. 29 */ 30 31 #import <Foundation/Foundation.h> 32 #import <AppKit/NSColor.h> 33 34 #ifndef MAC_OS_X_VERSION_10_4 35 #define MAC_OS_X_VERSION_10_4 1040 36 #endif 37 38 #if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) && !defined(CGFloat) 39 #define NSUInteger unsigned 40 #define NSInteger int 41 #define CGFloat float 42 #endif 43 44 @class GRDocView; 45 @class GRObjectEditor; 46 47 @interface GRDrawableObject : NSObject <NSCopying> 48 { 49 GRDocView *docView; 50 GRObjectEditor *editor; 51 BOOL visible, locked; 52 CGFloat zmFactor; 53 BOOL stroked, filled; 54 NSColor *fillColor; 55 NSColor *strokeColor; 56 } 57 58 /** return a fresh allocated editor corresponding to the current object */ 59 - (GRObjectEditor *)allocEditor; 60 61 - (id)initInView:(GRDocView *)aView zoomFactor:(CGFloat)zf withProperties:(NSDictionary *)properties; 62 - (id)initFromData:(NSDictionary *)description inView:(GRDocView *)aView zoomFactor:(CGFloat)zf; 63 64 /** 65 * Returns a description of the object, used for saving to file. 66 * This method must be overridden by each drawable object. 67 */ 68 - (NSDictionary *)objectDescription; 69 70 /** Returns if the point should select the object. 71 For example, for a Box it checks if the point is within the Rect, 72 for a Bezier path if the point is on its path */ 73 - (BOOL)objectHitForSelection:(NSPoint)p; 74 75 - (GRDocView *)view; 76 - (GRObjectEditor *)editor; 77 78 /** returns if the object is currently visible */ 79 - (BOOL)visible; 80 81 /** sets if the object is visible */ 82 - (void)setVisible:(BOOL)value; 83 84 /** returns if the object is locked */ 85 - (BOOL)locked; 86 87 /** locks an object */ 88 - (void)setLocked:(BOOL)value; 89 90 /** current zoom factor */ 91 - (CGFloat)zoomFactor; 92 93 /** the zoom factor is used to draw an object in the proper size 94 * when zooming in our out the view 95 */ 96 - (void)setZoomFactor:(CGFloat)f; 97 98 - (void)setStrokeColor:(NSColor *)c; 99 - (NSColor *)strokeColor; 100 - (void)setFillColor:(NSColor *)c; 101 - (NSColor *)fillColor; 102 - (void)setFilled:(BOOL)value; 103 - (BOOL)isFilled; 104 - (void)setStroked:(BOOL)value; 105 - (BOOL)isStroked; 106 107 /** 108 * Draws the object in the view. Called from GRDocView. 109 * This method must be subclassed. 110 */ 111 - (void)draw; 112 113 @end 114