File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Draw / graphicsUndo.subproj / EndEditingGraphicsChange.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:38 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#import "drawundo.h"

/*
 * This change is created when the user finishes editing a text
 * graphic. Undoing this change inserts the re-inserts the text
 * editing cursor in the text. More significantly, undoing this
 * change swaps the contents of the TextGraphic back into the
 * field editor so that it is ready to edit.
 */

@interface EndEditingGraphicsChange(PrivateMethods)

@end

@implementation EndEditingGraphicsChange

- initGraphicView:aGraphicView graphic:aGraphic
{
    [super init];
    graphicView = aGraphicView;
    graphic = aGraphic;

    return self;
}

- free
{
    if ([self hasBeenDone] && [graphic isEmpty])
        [graphic free];
    return [super free];
}

- (const char *)changeName
{
    return NXLocalStringFromTable("Operations", "End Editing", NULL, "The operation of ending the editing process and proceding onto some other operation.");
}

- undoChange
{
    if ([graphic isEmpty])
	[graphicView insertGraphic:graphic];
    [graphic prepareFieldEditor];    
    [NXApp startEditMode];
    return [super undoChange];
}

- redoChange
{
/* 
 * The order of the next two statements is important.
 * If endEditMode were sent before resignFieldEditor 
 * it would send resetCursor to the document which would
 * make the window the first responder which would end
 * up sending textDidEnd:endChar: to the TextGraphic.
 * Then in the next line we'd send resignFieldEditor to
 * the TextGraphic even though it had already resigned 
 * the field editor.
 */
    [graphic resignFieldEditor];
    [NXApp endEditMode];
    if ([graphic isEmpty])
	[graphicView removeGraphic:graphic];
    return [super redoChange];
}

@end

unix.superglobalmegacorp.com

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