Annotation of Examples/AppKit/CalculatorLab/SimpleCalc.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     SimpleCalc -- Randy Nelson
                      3:  *     A general class that directly supports a calculator interface
                      4:  *     Created 8-8-90
                      5:  *
                      6:  *     You may freely copy, distribute and reuse the code in this example.
                      7:  *     NeXT disclaims any warranty of any kind, expressed or implied, as to
                      8:  *     its fitness for any particular use.
                      9:  */
                     10: 
                     11: #import <objc/Object.h>
                     12: 
                     13: @interface SimpleCalc:Object
                     14: {
                     15:     id infoPanel;
                     16:     id helpPanel;
                     17:     
                     18:     id         display;        /* a text object -- to show the output and input */
                     19: 
                     20:     id         enterKey;       /* outlet to set the key equivalents */
                     21:     
                     22:     id         stringSet;      /* our string external to the source */
                     23:     
                     24:     int        operator;       /* represents the current operator or zero */
                     25:     
                     26:     double     accumulator;    /* a buffer to hold the first number entered */
                     27:     
                     28:     BOOL    numberHasADecimal,
                     29:            startingSecondNumber,
                     30:            treatingOperationKeyLikeEqualKey,
                     31:            noFirstNumber;      /* flags that describe the calculators state */
                     32: }
                     33: 
                     34: - doInit;
                     35: /* initialize an instance of the class and its flags for start-up
                     36:  * also used by the clear all key
                     37:  */
                     38: 
                     39: - numberKeys:sender;
                     40: /* sent by any number key or the decimal point key in the interface (0-9, .)
                     41:  * appends the character to display using appendToDisplay:
                     42:  * erases the previous number if startingSecondNumber
                     43:  */
                     44: 
                     45: - numberDirectFromDisplay:sender;
                     46: /* sent as the action of displayer -- allows direct entry of numbers
                     47:  * startingSecondNumber gets YES
                     48:  */
                     49:  
                     50: - equalsKey:sender;
                     51: /* sent by the equals key in the interface (=)
                     52:  * at this point accumulator holds the first number
                     53:  * operator holds an int defined to an operation
                     54:  * displayer hold the second number
                     55:  * performs the operation and leaves the result in the dsplayer
                     56:  */
                     57: 
                     58: - operationKeys:sender;
                     59: /* sent by the operation keys in the interface (+, -, * and /)
                     60:  * sets the value of operation
                     61:  * acts like equals to chain a calculation when
                     62:  * treatingOperationKeyLikeEqualKey
                     63:  */
                     64:  
                     65: - clearKeys:sender;
                     66: /* sent by either clear key in the interface(clear, clear all)
                     67:  * clear -- zeros the display -- allows re-enetering a number
                     68:  * clear all -- resets by calling init
                     69:  */
                     70: 
                     71: - decimal;
                     72: /* called by numberKeys: when it finds the number is a decimal point
                     73:  * checks first if numberHasADecimal already
                     74:  * if not -- appendToDisplay: a decimal point
                     75:  */
                     76:  
                     77: - appendToDisplay:(const char *)theDigit;
                     78: /* sent by objects wanting to append a digit to the number in the displayer
                     79:  * removes the leading zeros a zero value displayer has
                     80:  * unless there is a decimal point
                     81:  */
                     82:  
                     83: - appDidInit:sender;
                     84: /* handles some key equivalent setting and orders the window front
                     85:  * should be Application's delegate to receive
                     86:  */
                     87: 
                     88: - windowWillClose:sender;
                     89: /* quits app when window is closed
                     90:  * for example -- app's quit menu item can send performClose: to window
                     91:  * should be Window's delegate to receive
                     92:  */
                     93:  
                     94: - infoPanel:sender;
                     95: - helpPanel:sender;
                     96: /* sent by the menu in interface
                     97:  * creates the panels as they are needed
                     98:  */
                     99: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.