// // MPExpressionView.h // MathKit // // Created by Kim Wittenburg on 17.04.14. // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // /*! @header This file contains the MPExpressionView class.

The MathKit Expression System

MathKit contains class es that make up the so called expression system. The expression system is divided into three layers: the model, the view and the controller layer. The MPExpressionView class represents the view layer and interacts with the Cocoa NSView system. The model is represented by the classes @link //apple_ref/occ/cl/MPExpression@/link and @link //apple_ref/occ/cl/MPFunction@/link. The controller layer between the two consists of the class @link //apple_ref/occ/cl/MPLayout@/link and its subclasses. The purpose of the expression system is presenting expressions to the user and offering possibilities to manipulate and work with expressions. */ @class MPExpressionView, MPExpressionStorage, MPFunction, MPRangePath; /*! @class MPExpressionView @abstract The MPExpressionView class is the front-end class of the MathKit expression system. @discussion The class draws the expression managed by the the back-end class @link //apple_ref/occ/cl/MPExpressionStorage@/link and is the interface between Application Kit's view system and the MathKit expression system. */ @interface MPExpressionView : NSView #pragma mark Creation Methods /*! @methodgroup Creation Methods */ /*! @method initWithFrame: @abstract Initializes a MPExpressionView instance. @discussion This method sets up all layers of the expression system including an empty expression storage. This method is the designated initializer of the MPExpressionView class. @param frameRect The frame rectangle for the created view. @return An initialized MPExpressionView or nil if the object could not be created. */ - (id)initWithFrame:(NSRect)frameRect; #pragma mark Properties /*! @methodgroup Properties */ /*! @property expressionStorage @abstract The receiver's expression storage. @discussion The expression storage maintains the contents of the receiver. User interactions change the underlying data. If the expression storage or the underlying expression change the expression storage updates the receiver. */ @property (nonatomic, strong) MPExpressionStorage *expressionStorage; /*! @property selection @abstract The receiver's selection. */ @property (nonatomic, strong) MPRangePath *selection; /*! @property mathError @abstract If set the receiver will display the localized description of the specified error. @discussion There can only be one math error at a time. This property should not be set simutaneously with the @link //apple_ref/occ/instp/MPExpressionView/syntaxErrors@/link property. */ @property (nonatomic, strong) NSError *mathError; /*! @property syntaxErrors @abstract If set the receiver will display a dropdown list of syntax errors. @discussion The array must only contain NSError instances. In addition to that every instance must contain a valid NSIndexPath for the @link //apple_ref/c/data/MPPathToExpressionKey@/link in its userDict acompanied by a NSRange wrapped in a NSValue instance for the @link //apple_ref/c/data/MPErrorRangeKey@/link. If the user selects an item from the dropdown list the part of the expression displayed by the receiver will be selected that is specified by the values in the corresponding NSError instance. */ @property (nonatomic, strong) NSArray *syntaxErrors; /*! @property target @abstract The target object to receive action messages from the receiver. */ @property (nonatomic, weak) id target; /*! @property action @abstract The receiver's action method to the specified selector. @discussion The action method is invoked when the user presses enter in the receiver. Typically this is understood as evaluation request. */ @property (nonatomic) SEL action; #pragma mark Actions /*! @methodgroup Actions */ /*! @method switchToRadians: @abstract Tells the receiver that it should switch the interpretation of trigonometric function values to radians. @param sender Typically the object that invoked the method. */ - (IBAction)switchToRadians:(id)sender; /*! @method switchToDegrees: @abstract Tells the receiver that it should switch the interpretation of trigonometric function values to degrees. @param sender Typically the object that invoked the method. */ - (IBAction)switchToDegrees:(id)sender; /*! @method switchRadiansDegrees: @abstract Tells the receiver that it should switch the interpretation of trigonometric function values. @discussion If the interpretation is currently degrees it is changed to radians or vice versa. @param sender Typically the object that invoked the method. */ - (IBAction)switchRadiansDegrees:(id)sender; /*! @method toggleFunctionsPopover: @abstract Tells the receiver to toggle the visibility of the functions popover. @discussion From the functions popover the user can select and insert functions into the displayed expression @param sender Typically the object that invoked the method. */ - (IBAction)toggleFunctionsPopover:(id)sender; @end