|
|
1.1 root 1: {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\ftech Symbol;\f1\fmodern Courier;}
2: \paperw12380
3: \paperh13360
4: \margl120
5: \margr0
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 ChangeManager \
25:
26: \fs16 \
27:
28: \pard\tx7140\b0\fs28\li2100 INHERITS FROM Responder : Object\
29:
30: \fs16 \
31:
32: \fs28 DECLARED IN ChangeManager.h\
33:
34: \fs16 \
35: \
36: \
37:
38: \fs28 CLASS DESCRIPTION\
39:
40: \fs16 \
41:
42: \pard\tx3120\tx3620\tx4120\fs28\li2620 The ChangeManager class is the part of the undo mechanism that collects change objects and manipulates the undo and redo menu items. This class works with the Change class to provide a simple way to implement multi-level undo. Change managers communicate with change objects through the responder chain. By deriving window delegates from ChangeManager you can easily implement document-level undo. By installing a change manager as an application delegate you can also implement
43: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 application
44: \pard\tx3120\tx3620\tx4120\li2620 wide undo.\
45:
46: \fs16 \
47:
48: \pard\tx7140\li2100 \
49: \
50:
51: \fs28 INSTANCE VARIABLES\
52:
53: \fs16 \
54:
55: \pard\tx7140\tx10180\tx10680\i\fs28\fi-5040\li7660 Inherited from Object
56: \i0 Class isa;\
57: \
58:
59: \i Inherited from Responder
60: \i0 id nextResponder;\
61: \
62:
63: \pard\tx6140\tx8920\tx9420\i\fi-3540\li6140 Declared in ChangeManager
64: \i0 List *_changesList;\
65: Change *_lastChange;\
66: Change *_nextChange;\
67: Change *_changeInProgress;\
68: int _numberOfDoneChanges;\
69: int _numberOfUndoneChanges;\
70: int _numberOfDoneChangesAtLastClean;\
71: BOOL _someChangesForgotten;\
72: int _changesDisabled;\
73:
74: \pard\tx7140\tx10180\tx10680\fs16\fi-5040\li7660 \
75:
76: \fs28 \
77:
78: \fs16 \
79:
80: \fs28 _changesList A list of changes that have been made.\
81: \
82: _lastChange The id of the change that can be undone.\
83: \
84: _nextChange The id of the change that can be redone.\
85: \
86: _changeInProgress The id of the change which is currently underway.\
87: \
88: _numberOfDoneChanges The number of changes made.\
89: \
90: _numberOfUndoneChanges The number of changes that have been undone.\
91: \
92: _numberofDoneChangesAtLastClean A count of changes made when
93: \b clean
94: \b0 was last called.\
95: \
96: _someChangesForgotten YES if some changes have been thrown away\
97: \
98: _changesDisabled The number of nested calls to
99: \b disableChanges:
100: \b0 .\
101:
102: \fs16 \
103:
104: \pard\tx7140\li2100 \
105: \
106:
107: \fs28 METHOD TYPES\
108:
109: \fs16 \
110:
111: \pard\tx7140\tx10180\tx10680\fs28\fi-5040\li7660 Initializing and freeing
112: \f2 -
113: \f0 init\
114: � free\
115: \
116: Disabling undo � disableChanges:\
117: � enableChanges:\
118: \
119: Examining state � canUndo\
120: � canRedo\
121: � isDirty\
122: \
123: Setting state � dirty:\
124: � clean:\
125: � reset:\
126: \
127: Validating Menu Commands � validateCommand:\
128: \
129: Undoing and Redoing � undoOrRedoChange:\
130: � undoChange:\
131: � redoChange:\
132: \
133: Tracking change progress � changeInProgress:\
134: � changeComplete:\
135: \
136: Subclass notification � changeWasDone\
137: � changeWasUndone\
138: � changeWasRedone\
139:
140: \pard\tx7140\fs16\li2100 \
141: \
142:
143: \fs28 INSTANCE METHODS\
144:
145: \fs16 \
146:
147: \b \
148:
149: \fs28 canRedo\
150:
151: \pard\f2\b0\fi-1020\li3620 -
152: \f0 (BOOL)
153: \b canRedo\
154:
155: \fs16 \
156:
157: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns YES if there is a Change that can be redone. The name of this Change will be visible in the redo or undo/redo menu item. You should not need to override this method.\
158:
159: \fs16 \
160:
161: \fs28 See also:
162: \b � validateCommand:
163: \b0 \
164:
165: \fs16 \
166:
167: \pard\tx7140\b\li2100 \
168:
169: \fs28 canUndo\
170:
171: \pard\f2\b0\fi-1020\li3620 -
172: \f0 (BOOL)
173: \b canUndo\
174:
175: \fs16 \
176:
177: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns YES if there is a Change that can be undone. The name of this Change will be visible in the undo or undo/redo menu item. You should not override this method.\
178:
179: \fs16 \
180:
181: \fs28 See also:
182: \b � validateCommand:
183: \b0\fs16 \
184:
185: \pard\tx7140\b\li2100 \
186: \
187:
188: \fs28 changeComplete:\
189:
190: \pard\f2\b0\fi-1020\li3620 -
191: \f0\b changeComplete:
192: \b0\i change\
193:
194: \fs16\fi0 \
195:
196: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Called by Change objects to signify that
197: \i change
198: \i0 is done. The receiving ChangeManager will then ask
199: \i change
200: \i0 to save the new state information via
201: \b saveAfterChange
202: \b0 . Just before returning, the
203: \b changeComplete:
204: \b0 method sends a
205: \b changeWasDone
206: \b0 message to self, which provides subclasses of ChangeManager with an opportunity to react to the change. You should never call
207: \b changeComplete:
208: \b0 directly, nor should you override it.\
209:
210: \fs16 \
211:
212: \fs28 See also:
213: \b � changeInProgress:, � changeWasDone, � saveAfterChange
214: \b0 (Change)
215: \fs16 \
216:
217: \pard\tx7140\b\li2100 \
218: \
219:
220: \fs28 changeInProgress:\
221:
222: \pard\f2\b0\fi-1020\li3620 -
223: \f0\b changeInProgress:
224: \b0\i change\
225:
226: \fs16\fi0 \
227:
228: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Called by Change objects to signify that a
229: \i change
230: \i0 is about to be made. If changes have been disabled using
231: \b disableChanges:
232: \b0 then
233: \b changeInProgress:
234: \b0 will send a
235: \b disable
236: \b0 message to
237: \i change
238: \i0 and immediately return. If changes have not been disabled, the receiving ChangeManager tries to find a home for
239: \i change
240: \i0 . If another Change is already in progress that Change is sent an
241: \b incorporateChange:
242: \b0 message with
243: \i change
244: \i0 as the argument. If the Change in progress returns YES then
245: \i change
246: \i0 is sent a
247: \b saveBeforeChange
248: \b0 message, otherwise it is sent a
249: \b disable
250: \b0 message. If there is no Change already in progress, but there is a previous completed Change then the previous Change is sent a
251: \b subsumeChange:
252: \b0 message with
253: \i change
254: \i0 as the argument. If the previous Change returns YES then
255: \i change
256: \i0 is sent a
257: \b disable
258: \b0 message. If the previous Change returns NO, or if there is no previous Change,
259: \i change
260: \i0 is sent a
261: \b saveBeforeChange
262: \b0 message and set to be the current Change in progress, and the previous Change, if there is one, is sent a
263: \b finishChange
264: \b0 message. You should never need to call
265: \b changeInProgress:
266: \b0 directly, nor should you need to override it.\
267:
268: \fs16 \
269:
270: \fs28 See also: �
271: \b changeComplete:, � saveBeforeChange
272: \b0 (Change), �
273: \b incorporateChange:
274: \b0 (Change), �
275: \b subsumeChange:
276: \b0 (Change), �
277: \b finishChange
278: \b0 (Change)
279: \fs16 \
280:
281: \pard\tx7140\b\li2100 \
282: \
283:
284: \fs28 changeWasDone\
285:
286: \pard\f2\b0\fi-1020\li3620 -
287: \f0\b changeWasDone\
288:
289: \b0\i\fs16\fi0 \
290:
291: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Override this method if your subclass needs to know when a change has been made. For example, this hook can be used to update the close box on a document window to reflect the dirty state of the ChangeManager. You should not call this method directly.\
292:
293: \fs16 \
294:
295: \fs28 See also:
296: \b � changeWasRedone, � changeWasUndone, � isDirty\
297:
298: \pard\tx7140\fs16\li2100 \
299: \
300:
301: \fs28 changeWasRedone\
302:
303: \pard\f2\b0\fi-1020\li3620 -
304: \f0\b changeWasRedone\
305:
306: \b0\i\fs16\fi0 \
307:
308: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Override this method if your subclass needs to know when a change has been redone. For example, this hook can be used to update the close box on a document window to reflect the dirty state of the ChangeManager. You should not call this method directly.\
309:
310: \fs16 \
311:
312: \fs28 See also:
313: \b � changeWasDone, � changeWasUndone, � isDirty\
314:
315: \pard\tx7140\fs16\li2100 \
316: \
317:
318: \fs28 changeWasUndone\
319:
320: \pard\f2\b0\fi-1020\li3620 -
321: \f0\b changeWasUndone\
322:
323: \b0\i\fs16\fi0 \
324:
325: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Override this method if your subclass needs to know when a change has been undone. For example, this hook can be used to update the close box on a document window to reflect the dirty state of the ChangeManager. You should not call this method directly.\
326:
327: \fs16 \
328:
329: \fs28 See also:
330: \b � changeWasDone, � changeWasRedone, � isDirty\
331:
332: \pard\tx7140\fs16\li2100 \
333: \
334:
335: \fs28 clean:\
336:
337: \pard\f2\b0\fi-1020\li3620 -
338: \f0\b clean:
339: \b0\i sender\
340:
341: \fs16 \
342:
343: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Tells the receiving ChangeManager to consider its current state to be clean. Calls to
344: \b isDirty
345: \b0 will return NO until further change activity occurs. In ChangeManagers that correspond to documents, you should call
346: \b clean:
347: \b0 each time the document is saved. By doing this, the
348: \b isDirty
349: \b0 method can be used to tell whether the saved representation of the document matches the internal memory representation. When overriding this method you should begin your method with �[super
350: \b clean
351: \b0 :sender]�.\
352:
353: \fs16 \
354:
355: \fs28 See also: �
356: \b dirty:
357: \b0 , �
358: \b reset:
359: \b0 ,
360: \b � isDirty
361: \b0 \
362:
363: \fs16 \
364:
365: \pard\tx7140\b\li2100 \
366:
367: \fs28 dirty:\
368:
369: \pard\f2\b0\fi-1020\li3620 -
370: \f0\b dirty:
371: \b0\i sender
372: \b\i0 \
373:
374: \b0\i\fs16 \
375:
376: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Forces the receiving ChangeManager to appear dirty. Call this method when your code as made a change that wasn't recorded with a Change object. After a
377: \b dirty
378: \b0 message is received the
379: \b isDirty
380: \b0 method will return YES until a
381: \b clean:
382: \b0 or
383: \b reset:
384: \b0 message is received. When overriding this method you should begin your method with �[super
385: \b dirty
386: \b0 :sender]�.\
387:
388: \fs16 \
389:
390: \fs28 See also:
391: \b � clean:, � reset:, � isDirty
392: \b0 \
393:
394: \fs16 \
395:
396: \pard\tx7140\b\li2100 \
397:
398: \fs28 disableChanges:\
399:
400: \pard\f2\b0\fi-1020\li3620 -
401: \f0\b disableChanges:
402: \b0\i sender
403: \b\i0 \
404:
405: \fs16 \
406:
407: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 This method increments the receiver's changesDisabled instance variable. As long as changesDisabled is non-zero, new change objects will be disabled. You should not need to override this method.\
408:
409: \fs16 \
410:
411: \fs28 See also:
412: \b � enableChanges, � disable
413: \b0 (Change)\
414:
415: \fs16 \
416:
417: \pard\tx7140\b\li2100 \
418:
419: \fs28 enableChanges:\
420:
421: \pard\f2\b0\fi-1020\li3620 -
422: \f0\b enableChanges:
423: \b0\i sender\
424:
425: \fs16 \
426:
427: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Decrements the receiver's changesDisabled instance variable. You should not need to override this method.\
428:
429: \fs16 \
430:
431: \fs28 See also:
432: \b � disableChanges\
433:
434: \b0\fs16 \
435:
436: \pard\tx7140\b\li2100 \
437:
438: \fs28 free\
439:
440: \pard\f2\b0\fi-1020\li3620 -
441: \f0\b free\
442:
443: \fs16 \
444:
445: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Calls
446: \b reset:
447: \b0 to clean out any change objects and frees the ChangeManager object.\
448:
449: \b\fs16 \
450:
451: \pard\tx7140\li2100 \
452:
453: \fs28 init\
454:
455: \pard\f2\b0\fi-1020\li3620 -
456: \f0\b init\
457:
458: \fs16 \
459:
460: \pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Initializes the
461: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 receiver
462: \pard\tx3120\tx3620\tx4120\li2620 , a newly allocated ChangeManager object.\
463:
464: \b\fs16 \
465: \
466:
467: \pard\tx7140\fs28\li2100 isDirty\
468:
469: \pard\f2\b0\fi-1020\li3620 -
470: \f0 (BOOL)
471: \b isDirty
472: \b0\i \
473:
474: \fs16 \
475:
476: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Returns NO if no net change activity has
477: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 occurred
478: \pard\tx3120\tx3620\tx4120\li2620 since the ChangeManager was initialized or since the last
479: \b clean:
480: \b0 or
481: \b reset:
482: \b0 message was received. For example, if a single Change has been undone and then redone since the last
483: \b clean:
484: \b0 message, then isDirty will return NO. The completion of the next new, non-disabled Change will cause
485: \b isDirty
486: \b0 to return YES. You should not need to override this method.\
487:
488: \fs16 \
489:
490: \fs28 See also:
491: \b � disableChanges:, � clean:, � dirty:, � reset:
492: \b0 \
493:
494: \i \
495:
496: \pard\tx7140\b\i0\li2100 redoChange:\
497:
498: \pard\f2\b0\fi-1020\li3620 -
499: \f0\b redoChange:
500: \b0\i sender\
501:
502: \fs16\fi0 \
503:
504: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method should be the action performed by the redo menu item in an application with multiple-undo. The
505: \b redoChange:
506: \b0 method sends a
507: \b redoChange
508: \b0 message to the last Change that was undone. The name of this Change will then appear in the undo menu item. Your application should not use both
509: \b redoChange:
510: \b0 and
511: \b undoOrRedoChange:
512: \b0 at the same time. You should not need to override this method.\
513:
514: \fs16 \
515:
516: \fs28 See also:
517: \b � undoChange:, � undoOrRedoChange:
518: \b0\fs16 \
519:
520: \pard\tx7140\b\li2100 \
521: \
522:
523: \fs28 reset:\
524:
525: \pard\f2\b0\fi-1020\li3620 -
526: \f0\b reset:
527: \b0\i sender\
528:
529: \fs16 \
530:
531: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 Causes the receiving ChangeManager to free all the Change objects that it is managing. The state of the ChangeManager is re-initialized to the state after it first received the
532: \b init
533: \b0 message. When overriding this method you should begin your method with �[super
534: \b reset
535: \b0 :sender]�.
536: \b \
537:
538: \fs16 \
539:
540: \pard\tx7140\li2100 \
541:
542: \fs28 undoChange:\
543:
544: \pard\f2\b0\fi-1020\li3620 -
545: \f0\b undoChange:
546: \b0\i sender\
547:
548: \fs16\fi0 \
549:
550: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method should be the action performed by the undo menu item in an application with multiple-undo. The
551: \b undoChange:
552: \b0 method sends an
553: \b undoChange
554: \b0 message to the last Change that was done or redone. The name of this Change will then appear in the redo menu item. Your application should not use both
555: \b undoChange:
556: \b0 and
557: \b undoOrRedoChange:
558: \b0 at the same time. You should not need to override this method.\
559:
560: \fs16 \
561:
562: \fs28 See also:
563: \b � redoChange:, � undoOrRedoChange:
564: \b0\fs16 \
565:
566: \pard\tx7140\b\li2100 \
567: \
568:
569: \fs28 undoOrRedoChange:\
570:
571: \pard\f2\b0\fi-1020\li3620 -
572: \f0\b undoOrRedoChange:
573: \b0\i sender\
574:
575: \fs16 \
576:
577: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method should be the action performed by the undo menu item in an application offering single-level undo. If the last change has already been done, then it will be undone. If was just undone, then it will be redone. In order to make your application use single-level undo you must edit ChangeManager.m and define the N_LEVEL_UNDO constant to be 1. Your application should not use both
578: \b undoChange:
579: \b0 and
580: \b undoOrRedoChange:
581: \b0 at the same time. You should not need to override this method.\
582: \
583: Although
584: \b undoOrRedoChange:
585: \b0 is really intended for applications with single-level undo, it will attempt to do something reasonable in applications with multiple-undo. If there is a Change that can be undone
586: \b undoOrRedoChange:
587: \b0 sends an
588: \b undoChange
589: \b0 message to the Change. If there is no Change that can be undone, but there is a Change that can be redone then
590: \b undoOrRedoChang
591: \b0 e: sends a
592: \b redoChange
593: \b0 message to the Change.\
594:
595: \fs16 \
596:
597: \fs28 See also:
598: \b � undoChange:, � redoChange:
599: \b0\fs16 \
600:
601: \pard\tx7140\b\li2100 \
602: \
603:
604: \fs28 validateCommand:\
605:
606: \pard\f2\b0\fi-1020\li3620 -
607: \f0 (BOOL)
608: \b validateCommand:
609: \b0\i menuCell\
610:
611: \fs16 \
612:
613: \pard\tx3120\tx3620\tx4120\i0\fs28\li2620 This method can be used to change the state of menu items corresponding to undo, redo and undo/redo. Use this method as the update action for menu cells that invoke
614: \b undoChange:
615: \b0 ,
616: \b redoChange:
617: \b0 , or
618: \b undoOrRedoChange:
619: \b0 . The value returned is YES if the command specified in the update action of
620: \i menuCell
621: \i0 is valid.\
622: \
623: Independent of whether the command is valid or not, the change manager may update the title of
624: \i menuCell
625: \i0 to contain the correct name of the current changes.\
626:
627: \fs16 \
628:
629: \fs28 See also:
630: \b � undoChange:, � redoChange:, � undoOrRedoChange:, � setUpdateAction:forMenu:
631: \b0 (MenuCell)
632: \b\fs16 \
633:
634: \pard\tx7140\li2100 \
635: \
636:
637: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.