|
|
1.1 root 1: {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\ftech Symbol;\f1\fmodern Courier;}
2: \paperw12380
3: \paperh13060
4: \margl120
5: \margr120
6: {\colortbl\red0\green0\blue0;}
7: \f0\b0\i0\ul0\ql\fs24\fi0\li0\gray0\up0\dn0 \
8:
9: \pard\tx3120\tx3620\tx4120\fs16\li2620 \
10:
11: \fs28 \
12:
13: \fs16 \
14:
15: \fs28 \
16:
17: \fs16 \
18:
19: \pard\b\li1100 \
20: \
21: \
22: \
23:
24: \fs36 Change \
25:
26: \fs16 \
27:
28: \pard\tx7140\b0\fs28\li2100 INHERITS FROM Object\
29:
30: \fs16 \
31:
32: \fs28 DECLARED IN Change.h\
33:
34: \fs16 \
35: \
36: \
37:
38: \fs28 CLASS DESCRIPTION\
39:
40: \fs16 \
41:
42: \pard\tx3120\tx3620\tx4120\fs28\li2620 The Change class is an abstract superclass that is part of the undo mechanism. Create subclasses of Change to represent user actions that should be undoable. Each time the user performs one of these actions, your application should create a change object (an instance of a subclass of Change).\
43:
44: \fs16 \
45:
46: \pard\tx7140\li2100 \
47: \
48:
49: \fs28 INSTANCE VARIABLES\
50:
51: \fs16 \
52:
53: \pard\tx7140\tx10180\tx10680\i\fs28\fi-5040\li7660 Inherited from Object
54: \i0 Class isa;\
55:
56: \fs16 \
57:
58: \pard\tx6140\tx8920\tx9420\i\fs28\fi-3540\li6140 Declared in Change
59: \i0
60: \pard\tx8920\tx8920\tx8920\tx8920\tx8920\tx9420\tx9420\tx9420\tx9420\tx9420\fi-520\li6640 struct \{\
61:
62: \fi0 unsigned int disabled:1;\
63: unsigned int hasBeenDone:1;\
64: unsigned int changeInProgress:1;\
65: unsigned int padding:29;\
66:
67: \pard\tx8920\tx8920\tx8920\tx8920\tx8920\tx8920\tx9420\tx9420\tx9420\tx9420\tx9420\tx9420\fi-520\li6640 \} _changeFlags;\
68: id _changeManager;\
69:
70: \pard\tx7140\tx10180\tx10680\fi-5040\li7660 \
71:
72: \fs16 \
73:
74: \fs28 _changeFlags.disabled YES if this change should not be remembered.\
75: \
76: _changeFlags.hasBeenDone YES after the change has been originally made or redone.\
77: \
78: _changeFlags.changeInProgress YES if the change has not yet been done the first time.\
79: \
80: _changeManager The id of the ChangeManager that owns this change.\
81:
82: \fs16 \
83:
84: \pard\tx7140\li2100 \
85: \
86:
87: \fs28 METHOD TYPES\
88:
89: \fs16 \
90:
91: \pard\tx7140\tx10180\tx10680\fs28\fi-5040\li7660 Initializing a Change
92: \f2 -
93: \f0 init\
94: \
95: Called by application code � startChange\
96: � startChangeIn:\
97: � endChange\
98: � changeManager\
99: \
100: Called by ChangeManager � disable\
101: � disabled\
102: � hasBeenDone\
103: � changeInProgress\
104: � changeName\
105: \
106: Used exclusively by ChangeManager � saveBeforeChange\
107: � saveAfterChange\
108: � undoChange\
109: � redoChange\
110: � subsumeChange:\
111: � incorporateChange:\
112: � finishChange\
113:
114: \pard\tx7140\fs16\li2100 \
115: \
116:
117: \fs28 INSTANCE METHODS\
118:
119: \fs16 \
120:
121: \b \
122:
123: \fs28 changeInProgress\
124:
125: \pard\f2\b0\fi-1020\li3620 -
126: \f0 (BOOL)
127: \b changeInProgress
128: \b0\i \
129:
130: \fs16 \
131:
132: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Returns YES if the receiving Change has been sent a
133: \b startChange
134: \b0 or
135: \b startChangeIn:
136: \b0 message but has not yet received an
137: \b endChange
138: \b0 message. You should not need to override this method.\
139:
140: \fs16 \
141:
142: \fs28 See also:
143: \b � startChange, � endChange
144: \b0\i \
145:
146: \fs16 \
147:
148: \pard\tx7140\b\i0\li2100 \
149:
150: \fs28 changeManager\
151:
152: \pard\f2\b0\fi-1020\li3620 -
153: \f0\b changeManager
154: \b0\i \
155:
156: \fs16 \
157:
158: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Returns the ChangeManager responsible for handling the receiving Change. This
159: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0
160: \pard\tx3120\tx3620\tx4120\li2620 method will return
161: \b nil
162: \b0 until either a
163: \b startChange
164: \b0 or
165: \b startChangeIn:
166: \b0 message has been sent to the Change, at which point the Change will find the responsible ChangeManager by searching up the responder chain for the nearest ChangeManager. You should not need to override this method.\
167:
168: \fs16 \
169:
170: \fs28 See also:
171: \b � startChange
172: \b0\i \
173:
174: \fs16 \
175:
176: \pard\tx7140\b\i0\li2100 \
177:
178: \fs28 changeName\
179:
180: \pard\f2\b0\fi-1020\li3620 -
181: \f0 (const char *)
182: \b changeName
183: \b0\i \
184:
185: \fs16 \
186:
187: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Override this method to return the name to be used by the ChangeManager in the Undo and Redo menu items.
188: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\i\fc0
189: \pard\tx3120\tx3620\tx4120\i0\li2620 This method is called by
190: \b validateCommand:
191: \b0 in the ChangeManager class.\
192:
193: \fs16 \
194:
195: \fs28 See also:
196: \b � validateCommand:
197: \b0 (ChangeManager)
198: \i \
199:
200: \fs16 \
201:
202: \pard\tx7140\b\i0\li2100 \
203:
204: \fs28 disable\
205:
206: \pard\f2\b0\fi-1020\li3620 -
207: \f0\b disable
208: \b0\i \
209:
210: \fs16 \
211:
212: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method is called to tell the receiving Change that it won't be recorded as an explicit change, and won't ever be asked to
213: \b undoChange
214: \b0 or
215: \b redoChange
216: \b0 . The actual changes represented by the change object will still take place, but the ChangeManager won't record them as a
217: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 separate
218: \pard\tx3120\tx3620\tx4120\li2620 action. ChangeManager does not send
219: \b saveBeforeChange
220: \b0 and
221: \b saveAfterChange
222: \b0 messages to disabled Change objects. A Change object will be disabled by its ChangeManager if any of the following conditions are true: changes have been explicitly disabled in the ChangeManager; the Change was initiated while another Change was already in progress and the Change in progress declined to
223: \b incorporateChange:
224: \b0 the new change; or the previous (complete) Change elects to
225: \b subsumeChange:
226: \b0 the new Change. You should not need to override this method.\
227:
228: \fs16 \
229:
230: \fs28 See also:
231: \b � saveBeforeChange, � saveAfterChange, � incorporateChange:, � subsumeChange:, � disableChanges:
232: \b0 (ChangeManager)\
233:
234: \fs16 \
235:
236: \pard\tx7140\b\li2100 \
237:
238: \fs28 disabled\
239:
240: \pard\f2\b0\fi-1020\li3620 -
241: \f0 (BOOL)
242: \b disabled\
243:
244: \fs16 \
245:
246: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns YES if the change object has received a
247: \b disable
248: \b0 message.\
249:
250: \fs16 \
251:
252: \fs28 See also:
253: \b � disable
254: \b0\fs16 \
255:
256: \pard\tx7140\b\li2100 \
257: \
258:
259: \fs28 endChange\
260:
261: \pard\f2\b0\fi-1020\li3620 -
262: \f0\b endChange\
263:
264: \fs16 \
265:
266: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Signals that a change is complete. This method should be called after the
267: \b startChange
268: \b0 method or
269: \b startChangeIn:
270: \b0 method has been sent to the same Change. If the receiver has not been disabled, the
271: \b endChange
272: \b0 method will send a
273: \b changeComplete:
274: \b0 message to the receiver's ChangeManager. Before this method returns, the ChangeManager will send a
275: \b saveAfterChange
276: \b0 message back to the Change. If the receiver has been disabled or was unable to find a ChangeManager when it started then
277: \b endChange
278: \b0 will cause the receiver to free itself. You should not need to override this method.\
279:
280: \fs16 \
281:
282: \fs28 See also:
283: \b � saveAfterChange
284: \b0 ,
285: \b � startChange, � changeComplete:
286: \b0 (ChangeManager)\
287:
288: \fs16 \
289: \
290:
291: \pard\tx7140\b\fs28\li2100 finishChange\
292:
293: \pard\f2\b0\fi-1020\li3620 -
294: \f0\b finishChange\
295:
296: \b0\i\fs16 \
297:
298: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 The vast majority of all subclasses of Change will not need to use this method. The
299: \b finishChange
300: \b0 method is intended to be overridden only in subclasses who's instances subsume other Change instances, and only then by subclasses that need to perform some special action after the last subsumable Change has been subsumed. ChangeManager sends
301: \b finishChange
302: \b0 just before the receiving Change is asked to
303: \b undoChange
304: \b0 or just after the receiving Change declines to
305: \b subsumeChange:
306: \b0 another Change. If a change is repeatedly undone and redone, the ChangeManager will repeatedly send the
307: \b finishChange
308: \b0 message to the same Change, so it is important that the Change keep track of whether this method has already been called.\
309:
310: \fs16 \
311:
312: \fs28 See also:
313: \b � subsumeChange:
314: \b0 \
315:
316: \pard\tx7140\b\li2100 \
317: hasBeenDone\
318:
319: \pard\f2\b0\fi-1020\li3620 -
320: \f0 (BOOL)
321: \b hasBeenDone\
322:
323: \fs16 \
324:
325: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns YES if the Change has been done for the first time or if the change has been redone. Specifically,
326: \b hasBeenDone
327: \b0 returns NO if the receiver has never been sent an
328: \b endChange
329: \b0 message or if the receiver has been sent an
330: \b undoChange
331: \b0 message more recently than a
332: \b redoChange
333: \b0 message.\
334:
335: \fs16 \
336:
337: \pard\tx7140\b\li2100 \
338:
339: \fs28 incorporateChange:\
340:
341: \pard\f2\b0\fi-1020\li3620 - (
342: \f0 BOOL
343: \f2 )
344: \f0\b incorporateChange:
345: \b0\i change\
346:
347: \fs16\fi0 \
348:
349: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 The
350: \b incorporateChange:
351: \b0 method is called by the ChangeManager if the receiving Change is in progress when a new
352: \i change
353: \i0 is initiated. The receiving Change is given the opportunity to incorporate the new
354: \i change
355: \i0 . This mechanism can be used when one user action would create multiple Change objects. For example, a paste command might
356: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 implemented
357: \pard\tx3120\tx3620\tx4120\li2620 using two independent, Change producing methods, one for deleting the current selection and one for creating the new selection. In this case, both the deletion Change and the creation Change should really be part of a single paste Change, which will incorporate them as sub-changes. Unlike
358: \b subsumeChange:
359: \b0 , this method is called only when a Change is in progress. \
360: \
361: Most subclasses of Change will not need to use this method. You should never need to call this method directly, although you may occasionally want to override it.
362: \fc0 Your implementation should return YES if the
363: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 specified
364: \pard\tx3120\tx3620\tx4120\li2620\fc0
365: \i change
366: \i0 should be incorporated into the receiving Change. By returning YES, the receiving Change accepts responsibility for the incorporated
367: \i change
368: \i0 , and the ChangeManager will not keep track of it nor free it. Your implementation should return NO when
369: \i change
370: \i0 can't or shouldn't be incorporated in the receiving Change. In this case,
371: \i change
372: \i0 will be disabled and ignored. The default implementation always returns NO. Note that in either case the receiving Change must still be able to undo any changes in state that happen from the time it receives a
373: \b startChange
374: \b0 message until it receives an
375: \b endChange
376: \b0 message.
377: \fs16 \
378:
379: \fs28 See also:
380: \b � disable, � subsumeChange:
381: \b0\fs16 \
382:
383: \pard\tx7140\b\li2100 \
384: \
385:
386: \fs28 init\
387:
388: \pard\f2\b0\fi-1020\li3620 -
389: \f0\b init\
390:
391: \fs16 \
392:
393: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Initializes the receiver, a newly allocated Change object.\
394:
395: \pard\tx7140\b\fs16\li2100 \
396: \
397:
398: \fs28 redoChange\
399:
400: \pard\f2\b0\fi-1020\li3620 -
401: \f0\b redoChange
402: \b0\i \
403:
404: \fs16 \
405:
406: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Called by the change manager to re-issue a change after it has been undone. This is accomplished by restoring the state of the application using the state information recorded by
407: \b saveAfterChange
408: \b0 . You should not need to call this method directly. When overriding this method you should end your method with �return [super
409: \b redoChange
410: \b0 ]�.\
411:
412: \fs16 \
413:
414: \fs28 See also:
415: \b � undoChange, � saveAfterChange\
416:
417: \fs16 \
418:
419: \pard\tx7140\li2100 \
420:
421: \fs28 saveAfterChange\
422:
423: \pard\f2\b0\fi-1020\li3620 -
424: \f0\b saveAfterChange
425: \b0\i \
426:
427: \fs16 \
428:
429: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Called by the ChangeManager after the receiving Change is sent an
430: \b endChange
431: \b0 message, provided the Change is not disabled. Override this method to save any state information modified during the course of the change. This state information can be used by the
432: \b redoChange
433: \b0 method to redo a change after it has been undone. You should not need to call this method directly. \
434:
435: \fs16 \
436:
437: \fs28 See also:
438: \b � saveBeforeChange, � redoChange
439: \b0 \
440:
441: \fs16 \
442:
443: \pard\tx7140\b\li2100 \
444:
445: \fs28 saveBeforeChange\
446:
447: \pard\f2\b0\fi-1020\li3620 -
448: \f0\b saveBeforeChange\
449:
450: \b0\i\fs16 \
451:
452: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Called by the ChangeManager after the receiving Change is sent a
453: \b startChange
454: \b0 or
455: \b startChangeIn:
456: \b0 message, provided the Change is not disabled. Override this method to save any state information necessary to undo the change later on. For example, if a change causes a variable to be updated, the
457: \b saveBeforeChange
458: \b0 method could save the current value of the variable for later use by
459: \b undoChange
460: \b0 . You should not need to call this method directly.\
461:
462: \fs16 \
463:
464: \fs28 See also:
465: \b � saveAfterChange, � undoChange
466: \b0 \
467:
468: \fs16 \
469:
470: \pard\tx7140\b\li2100 \
471:
472: \fs28 startChange\
473:
474: \pard\f2\b0\fi-1020\li3620 -
475: \f0\b startChange\
476:
477: \fs16 \
478:
479: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 This method, or its sibling method
480: \b startChangeIn:
481: \b0 , is called once per Change by your application code to signal that a change is about to take place. The Change will open a connection to the nearest ChangeManager on the responder chain. The id of this ChangeManager will be saved in the changeManager instance variable. If the application is not active
482: \b startChange
483: \b0 will fail to find a ChangeManager. Use
484: \b startChangeIn:
485: \b0 instead of
486: \b startChange
487: \b0 if the application is not active. The
488: \b startChange
489: \b0 method will return
490: \b nil
491: \b0 if no ChangeManager is found. If a ChangeManager is found, it will be sent a
492: \b\fc0 changeInProgress:
493: \b0 message and it will either send the Change either a
494: \b disable
495: \b0 message or a
496: \b saveBeforeChange
497: \b0 message before
498: \b startChange
499: \b0 returns. The code for causing the change should follow a call to
500: \b startChange
501: \b0 and should be followed directly by a call to
502: \b endChange
503: \b0 . You should not need to override this method.\
504:
505: \fs16 \
506:
507: \fs28 See also:
508: \b � endChange, � saveBeforeChange, � startChangeIn:, � isActive
509: \b0 (Application)
510: \b \
511:
512: \fs16 \
513:
514: \pard\tx7140\li2100 \
515:
516: \fs28 startChangeIn:\
517:
518: \pard\f2\b0\fi-1020\li3620 -
519: \f0\b startChangeIn:
520: \b0\i aView
521: \b\i0 \
522:
523: \fs16 \
524:
525: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 This method is identical to the
526: \b startChange
527: \b0 method, except that
528: \b startChangeIn:
529: \b0 may successfully locate a ChangeManager even if the application is not the active application, which
530: \b startChange
531: \b0 will not. In order to find a ChangeManager
532: \b startChangeIn:
533: \b0 must be passed
534: \i aView
535: \i0 in which the change is
536: \fc0 occurring, which it will use to find the beginning of the responder chain. You should not need to override this method.\
537:
538: \fs16 \
539:
540: \fs28 See also:
541: \b � endChange, � saveBeforeChange, � startChange, � isActive
542: \b0 (Application)
543: \b \
544:
545: \fs16 \
546:
547: \pard\tx7140\li2100 \
548:
549: \fs28 subsumeChange:\
550:
551: \pard\f2\b0\fi-1020\li3620 - (
552: \f0 BOOL
553: \f2 )
554: \f0\b subsumeChange:
555: \b0\i change\
556:
557: \fs16 \
558:
559: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method is called by the ChangeManager to offer the receiver (which is the last completed Change) the opportunity to subsume the next Change about to be performed by the application. Override this method when you want to coalesce a series of similar Changes into one large Change. For example, a series of cursor movements could be collapsed into a single Change. The first Change created by cursor movement would subsume all cursor Changes following it directly. The ChangeManager only calls this method on completed Changes.\
560: \
561: Most subclasses of Change will not need to use this method. You should never need to call this method directly, although you may occasionally want to override it. Your implementation should return YES if you wish to signal that
562: \i change
563: \i0 should be subsumed. In this case,
564: \i change
565: \i0 will be disabled and will be freed as soon as it receives an
566: \b endChange
567: \b0 message. Note that the current change is expected to be able to undo any changes in state that occur before
568: \i change
569: \i0 receives the
570: \b endChange
571: \b0 message. You should return NO when
572: \i change
573: \i0 cannot be subsumed by the current change. When this happens, the ChangeManager will send the receiver a
574: \b finishChange
575: \b0 message and then record
576: \i change
577: \i0 as an independent change The default implementation always returns NO.
578: \fs16 \
579:
580: \pard\tx7140\b\li2100 \
581:
582: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 See also:
583: \b � disable, � incorporateChange:\
584:
585: \b0\fs16 \
586:
587: \pard\tx7140\b\li2100 \
588:
589: \fs28 undoChange\
590:
591: \pard\f2\b0\fi-1020\li3620 -
592: \f0\b undoChange
593: \b0\i \
594:
595: \fs16 \
596:
597: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method tells the receiving Change to restore the state information first saved when
598: \b saveBeforeChange
599: \b0 was called. This information should be sufficient to restore the state of the application to the way it was before the change took place. This method may either be called to undo the Change after the first time the Change was made, or after a Change has been redone. You should not need to call this method directly. When overriding this method you should end your method with �return [super
600: \b undoChange
601: \b0 ]�.\
602:
603: \fs16 \
604:
605: \fs28 See also: �
606: \b redoChange
607: \b0 ,
608: \b � saveBeforeChange\
609:
610: \fs16 \
611:
612: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.