|
|
1.1 ! root 1: #import "drawundo.h" ! 2: ! 3: @interface UngroupGraphicsChange(PrivateMethods) ! 4: ! 5: @end ! 6: ! 7: @implementation UngroupGraphicsChange ! 8: ! 9: - initGraphicView:aGraphicView ! 10: { ! 11: [super init]; ! 12: graphicView = aGraphicView; ! 13: changeDetails = nil; ! 14: groups = nil; ! 15: ! 16: return self; ! 17: } ! 18: ! 19: - free ! 20: { ! 21: int i, count; ! 22: id group; ! 23: ! 24: if ([self hasBeenDone]) { ! 25: count = [groups count]; ! 26: for (i = 0; i < count; i++) { ! 27: group = [groups objectAt:i]; ! 28: [[group subGraphics] empty]; ! 29: [group free]; ! 30: } ! 31: } ! 32: [groups free]; ! 33: if (changeDetails != nil) { ! 34: [changeDetails freeObjects]; ! 35: [changeDetails free]; ! 36: } ! 37: return [super free]; ! 38: } ! 39: ! 40: - (const char *)changeName ! 41: { ! 42: return NXLocalStringFromTable("Operations", "Ungroup", NULL, "The operation of ungroup a bunch of graphical entities that are grouped together into a single graphical entity."); ! 43: } ! 44: ! 45: - saveBeforeChange ! 46: { ! 47: List *selectedGraphics; ! 48: int i, count; ! 49: id g; ! 50: id changeDetailClass; ! 51: ! 52: groups = [[List alloc] init]; ! 53: changeDetailClass = [self changeDetailClass]; ! 54: changeDetails = [[List alloc] init]; ! 55: ! 56: selectedGraphics = [graphicView selectedGraphics]; ! 57: count = [selectedGraphics count]; ! 58: for (i = 0; i < count; i++) { ! 59: g = [selectedGraphics objectAt:i]; ! 60: if ([g isKindOf:[Group class]]) { ! 61: [groups addObject:g]; ! 62: [changeDetails addObject:[[changeDetailClass alloc] initGraphic:g change:self]]; ! 63: } ! 64: } ! 65: [changeDetails makeObjectsPerform:@selector(recordGraphicPositionIn:) with:[graphicView graphics]]; ! 66: ! 67: count = [groups count]; ! 68: if (count == 0) ! 69: [self disable]; ! 70: ! 71: return self; ! 72: } ! 73: ! 74: - undoChange ! 75: { ! 76: List *allGraphics, *graphics; ! 77: int i, j, count, graphicCount; ! 78: NXRect affectedBounds; ! 79: id group, graphic, detail; ! 80: ! 81: allGraphics = [graphicView graphics]; ! 82: count = [changeDetails count]; ! 83: for (i = 0; i < count; i++) { ! 84: detail = [changeDetails objectAt:i]; ! 85: group = [detail graphic]; ! 86: graphics = [group subGraphics]; ! 87: graphicCount = [graphics count]; ! 88: for (j = 0; j < graphicCount; j++) { ! 89: graphic = [graphics objectAt:j]; ! 90: [graphic setCacheable:NO]; ! 91: [allGraphics removeObject:graphic]; ! 92: } ! 93: [allGraphics insertObject:group at:[detail graphicPosition]]; ! 94: } ! 95: ! 96: [graphicView getSelection]; ! 97: [graphicView setGroupInSlist:YES]; ! 98: [graphicView getBBox:&affectedBounds of:groups]; ! 99: [graphicView cache:&affectedBounds]; ! 100: [[graphicView window] flushWindow]; ! 101: [[[NXApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]]; ! 102: ! 103: return [super undoChange]; ! 104: } ! 105: ! 106: - redoChange ! 107: { ! 108: List *allGraphics; ! 109: int k; ! 110: int i, count; ! 111: NXRect affectedBounds; ! 112: id group; ! 113: ! 114: [graphicView getBBox:&affectedBounds of:groups]; ! 115: ! 116: allGraphics = [graphicView graphics]; ! 117: count = [groups count]; ! 118: for (i = 0; i < count; i++) { ! 119: group = [groups objectAt:i]; ! 120: k = [allGraphics indexOf:group]; ! 121: [allGraphics removeObjectAt:k]; ! 122: [group transferSubGraphicsTo:allGraphics at:k]; ! 123: } ! 124: ! 125: [graphicView getSelection]; ! 126: [graphicView resetGroupInSlist]; ! 127: [graphicView cache:&affectedBounds]; ! 128: [[graphicView window] flushWindow]; ! 129: [[[NXApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]]; ! 130: ! 131: ! 132: return [super redoChange]; ! 133: } ! 134: ! 135: - changeDetailClass ! 136: { ! 137: return [OrderChangeDetail class]; ! 138: } ! 139: ! 140: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.