From 1802977b95d29198f27535b1b731d1180c083667 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Wed, 11 Jan 2017 16:33:00 +0100 Subject: made new subdir --- tikzit/src/common/PickSupport.m | 232 ---------------------------------------- 1 file changed, 232 deletions(-) delete mode 100644 tikzit/src/common/PickSupport.m (limited to 'tikzit/src/common/PickSupport.m') diff --git a/tikzit/src/common/PickSupport.m b/tikzit/src/common/PickSupport.m deleted file mode 100644 index 560fc2c..0000000 --- a/tikzit/src/common/PickSupport.m +++ /dev/null @@ -1,232 +0,0 @@ -// -// PickSupport.m -// TikZiT -// -// Copyright 2010 Aleks Kissinger. All rights reserved. -// -// -// This file is part of TikZiT. -// -// TikZiT is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// TikZiT is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with TikZiT. If not, see . -// - -#import "PickSupport.h" - - -@implementation PickSupport - -- (void) postNodeSelectionChanged { - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeSelectionChanged" - object:self]; -} - -- (void) postEdgeSelectionChanged { - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeSelectionChanged" - object:self]; -} - -- (id) init { - self = [super init]; - - if (self) { -#if __has_feature(objc_arc) - selectedNodes = [NSMutableSet set]; - selectedEdges = [NSMutableSet set]; -#else - selectedNodes = [[NSMutableSet set] retain]; - selectedEdges = [[NSMutableSet set] retain]; -#endif - } - - return self; -} - -+ (PickSupport*)pickSupport { -#if __has_feature(objc_arc) - return [[PickSupport alloc] init]; -#else - return [[[PickSupport alloc] init] autorelease]; -#endif -} - -@synthesize selectedNodes; -- (void)addSelectedNodesObject:(Node*)node { - return [self selectNode:node]; -} -- (void)addSelectedNodes:(NSSet*)nodes { - return [self selectAllNodes:nodes replacingSelection:NO]; -} -- (void)removeSelectedNodesObject:(Node*)node { - return [self deselectNode:node]; -} -- (void)removeSelectedNodes:(NSSet*)nodes { - if ([selectedNodes count] > 0) { - [selectedNodes minusSet:nodes]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeSelectionReplaced" - object:self]; - [self postNodeSelectionChanged]; - } -} - -@synthesize selectedEdges; -- (void)addSelectedEdgesObject:(Edge*)edge { - return [self selectEdge:edge]; -} -- (void)addSelectedEdges:(NSSet*)edges { - if (selectedEdges == edges) { - return; - } - if ([edges count] == 0) { - return; - } - - [selectedEdges unionSet:edges]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeSelectionReplaced" - object:self]; - [self postEdgeSelectionChanged]; -} -- (void)removeSelectedEdgesObject:(Edge*)edge { - return [self deselectEdge:edge]; -} -- (void)removeSelectedEdges:(NSSet*)edges { - if ([selectedEdges count] > 0 && [edges count] > 0) { - [selectedEdges minusSet:edges]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeSelectionReplaced" - object:self]; - [self postEdgeSelectionChanged]; - } -} - -- (BOOL)isNodeSelected:(Node*)nd { - return [selectedNodes containsObject:nd]; -} - -- (BOOL)isEdgeSelected:(Edge*)e { - return [selectedEdges containsObject:e]; -} - -- (void)selectNode:(Node*)nd { - if (nd != nil && ![selectedNodes member:nd]) { - [selectedNodes addObject:nd]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeSelected" - object:self - userInfo:[NSDictionary dictionaryWithObject:nd forKey:@"node"]]; - [self postNodeSelectionChanged]; - } -} - -- (void)deselectNode:(Node*)nd { - if (nd != nil && [selectedNodes member:nd]) { - [selectedNodes removeObject:nd]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeDeselected" - object:self - userInfo:[NSDictionary dictionaryWithObject:nd forKey:@"node"]]; - [self postNodeSelectionChanged]; - } -} - -- (void)selectEdge:(Edge*)e { - if (e != nil && ![selectedEdges member:e]) { - [selectedEdges addObject:e]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeSelected" - object:self - userInfo:[NSDictionary dictionaryWithObject:e forKey:@"edge"]]; - [self postEdgeSelectionChanged]; - } -} - -- (void)deselectEdge:(Edge*)e { - if (e != nil && [selectedEdges member:e]) { - [selectedEdges removeObject:e]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeDeselected" - object:self - userInfo:[NSDictionary dictionaryWithObject:e forKey:@"edge"]]; - [self postEdgeSelectionChanged]; - } -} - -- (void)toggleNodeSelected:(Node*)nd { - if ([self isNodeSelected:nd]) - [self deselectNode:nd]; - else - [self selectNode:nd]; -} - -- (void)selectAllNodes:(NSSet*)nodes { - [self selectAllNodes:nodes replacingSelection:YES]; -} - -- (void)selectAllNodes:(NSSet*)nodes replacingSelection:(BOOL)replace { - if (selectedNodes == nodes) { - return; - } - if (!replace && [nodes count] == 0) { - return; - } - - if (replace) { -#if ! __has_feature(objc_arc) - [selectedNodes release]; -#endif - selectedNodes = [nodes mutableCopy]; - } else { - [selectedNodes unionSet:nodes]; - } - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeSelectionReplaced" - object:self]; - [self postNodeSelectionChanged]; -} - -- (void)deselectAllNodes { - if ([selectedNodes count] > 0) { - [selectedNodes removeAllObjects]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"NodeSelectionReplaced" - object:self]; - [self postNodeSelectionChanged]; - } -} - -- (void)deselectAllEdges { - if ([selectedEdges count] > 0) { - [selectedEdges removeAllObjects]; - [[NSNotificationCenter defaultCenter] - postNotificationName:@"EdgeSelectionReplaced" - object:self]; - [self postEdgeSelectionChanged]; - } -} - -- (void)dealloc { -#if ! __has_feature(objc_arc) - [selectedNodes release]; - [selectedEdges release]; - - [super dealloc]; -#endif -} - -@end - -// vi:ft=objc:ts=4:noet:sts=4:sw=4 -- cgit v1.2.3