[Chlor-commits] SF.net SVN: chlor: [544] trunk/src
Status: Pre-Alpha
Brought to you by:
lenny222
From: Chlor c. to s. <chl...@li...> - 2007-05-27 22:18:06
|
Revision: 544 http://svn.sourceforge.net/chlor/?rev=544&view=rev Author: lenny222 Date: 2007-05-27 15:18:03 -0700 (Sun, 27 May 2007) Log Message: ----------- rename Modified Paths: -------------- trunk/src/Chlor.xcodeproj/project.pbxproj trunk/src/gui/tools/CSelectionTool.m trunk/src/gui/tools/CSelectionToolResizeState.h Added Paths: ----------- trunk/src/gui/tools/CSelectionToolMoveState.h trunk/src/gui/tools/CSelectionToolMoveState.m trunk/src/gui/tools/CSelectionToolRectangleState.h trunk/src/gui/tools/CSelectionToolRectangleState.m Removed Paths: ------------- trunk/src/gui/tools/CSelectionToolMoveObjectsState.h trunk/src/gui/tools/CSelectionToolMoveObjectsState.m trunk/src/gui/tools/CSelectionToolSelectState.h trunk/src/gui/tools/CSelectionToolSelectState.m Modified: trunk/src/Chlor.xcodeproj/project.pbxproj =================================================================== (Binary files differ) Modified: trunk/src/gui/tools/CSelectionTool.m =================================================================== --- trunk/src/gui/tools/CSelectionTool.m 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionTool.m 2007-05-27 22:18:03 UTC (rev 544) @@ -22,8 +22,8 @@ #import "CSelectionTool.h" #import "CSelectionToolState.h" #import "CSelectionToolMoveState.h" +#import "CSelectionToolRectangleState.h" #import "CSelectionToolResizeState.h" -#import "CSelectionToolSelectState.h" @implementation CSelectionTool @@ -112,7 +112,7 @@ if( [[selection objects] count] < 1 ) { // Activate the object selection state. - m_activeState = [CSelectionToolSelectState sharedSelectionToolSelectState]; + m_activeState = [CSelectionToolRectangleState sharedSelectionToolSelectState]; } // The document selection is not empty. else Deleted: trunk/src/gui/tools/CSelectionToolMoveObjectsState.h =================================================================== --- trunk/src/gui/tools/CSelectionToolMoveObjectsState.h 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionToolMoveObjectsState.h 2007-05-27 22:18:03 UTC (rev 544) @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2007 Lennart Kudling - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#import <Cocoa/Cocoa.h> -@class CAffineTrafo; -@class CSelection; -#import "CSelectionToolState.h" - -/** - * The selection tool state for moving objects. - */ -@interface CSelectionToolMoveObjectsState : CSelectionToolState -{ - /** - * The resulting affine transformation visitor (@see m_affineMap). - */ - CAffineTrafo* m_affineTrafo; - - /** - * The manipulated objects which are drawn during object moving. - */ - CSelection* m_copiedObjects; -} - -/** - * Returns the singleton instance. - */ -+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState; - -@end Deleted: trunk/src/gui/tools/CSelectionToolMoveObjectsState.m =================================================================== --- trunk/src/gui/tools/CSelectionToolMoveObjectsState.m 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionToolMoveObjectsState.m 2007-05-27 22:18:03 UTC (rev 544) @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2007 Lennart Kudling - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#import "CAffineMap.h" -#import "CAffineTrafo.h" -#import "CContourRenderer.h" -#import "ChlorDocument.h" -#import "CSelectionTool.h" -#import "CSelectionToolMoveObjectsState.h" - -@implementation CSelectionToolMoveObjectsState - -- (id) init -{ - self = [super init]; - - if( self ) - { - m_affineTrafo = [[CAffineTrafo alloc] init]; - m_copiedObjects = nil; - } - - return self; -} - -- (void) dealloc -{ - [m_copiedObjects release]; - [m_affineTrafo release]; - [super dealloc]; -} - -- (void) cancel -{ - // Release the copied objects. - [m_copiedObjects release]; - m_copiedObjects = nil; - - // Get the selection. - CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection]; - - // Reshow the selection. - [selection show]; - - // Clear the selection. - [selection clear]; -} - -- (void) drawRect: (NSRect) rect -{ - // Convert NSRect to CGRect. - CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ); - // Get context. - CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - - // Draw the copied objects. - CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer]; - - [copiedObjectsRenderer setDrawingBoundary: drawRect]; - [copiedObjectsRenderer setContext: context]; - [copiedObjectsRenderer visitSelection: m_copiedObjects]; -} - -- (void) finish -{ - // Release the copied objects. - [m_copiedObjects release]; - m_copiedObjects = nil; - - // Get the document. - ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document]; - - // Make the document transform the selection. - [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]] - thenBy: [[CAffineMap allocWithZone:[self zone]] init] - actionName: NSLocalizedString( - @"Move Objects", - @"Name of undo/redo action for moving objects" )]; - - // Reshow the selection. - [[document selection] show]; -} - -- (void) updateInternalState -{ - // Release the copied objects. - [m_copiedObjects release]; - - // Get the selection tool. - CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; - - // Get the selection. - CSelection* selection = [[[[selectionTool view] mainController] document] selection]; - - // Copy the selected objects. - m_copiedObjects = [selection copy]; - - // Calculate the movement. - double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x; - double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y; - - // Set the affine map. - [[m_affineTrafo affineMap] reset]; - [[m_affineTrafo affineMap] translateX: dx Y: dy]; - - // Apply the affine transformation to the copied objects. - [m_affineTrafo visitSelection: m_copiedObjects]; - - // Show the copied objects. - [m_copiedObjects show]; -} - -+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState -{ - static CSelectionToolMoveObjectsState* s_instance = nil; - - if( !s_instance ) - s_instance = [[CSelectionToolMoveObjectsState alloc] init]; - - return s_instance; -} - -- (void) start -{ - // Get the document selection. - CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection]; - - // Hide the selection. - [selection hide]; -} - -@end Added: trunk/src/gui/tools/CSelectionToolMoveState.h =================================================================== --- trunk/src/gui/tools/CSelectionToolMoveState.h (rev 0) +++ trunk/src/gui/tools/CSelectionToolMoveState.h 2007-05-27 22:18:03 UTC (rev 544) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2007 Lennart Kudling + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: CSelectionToolMoveState.h 531 2007-05-27 01:27:33Z lenny222 $ + */ + +#import <Cocoa/Cocoa.h> +@class CAffineTrafo; +@class CSelection; +#import "CSelectionToolState.h" + +/** + * The selection tool state for moving objects. + */ +@interface CSelectionToolMoveState : CSelectionToolState +{ + /** + * The resulting affine transformation visitor (@see m_affineMap). + */ + CAffineTrafo* m_affineTrafo; + + /** + * The manipulated objects which are drawn during object moving. + */ + CSelection* m_copiedObjects; +} + +/** + * Returns the singleton instance. + */ ++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState; + +@end Added: trunk/src/gui/tools/CSelectionToolMoveState.m =================================================================== --- trunk/src/gui/tools/CSelectionToolMoveState.m (rev 0) +++ trunk/src/gui/tools/CSelectionToolMoveState.m 2007-05-27 22:18:03 UTC (rev 544) @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2007 Lennart Kudling + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: CSelectionToolMoveState.m 533 2007-05-27 11:19:37Z lenny222 $ + */ + +#import "CAffineMap.h" +#import "CAffineTrafo.h" +#import "CContourRenderer.h" +#import "ChlorDocument.h" +#import "CSelectionTool.h" +#import "CSelectionToolMoveState.h" + +@implementation CSelectionToolMoveState + +- (id) init +{ + self = [super init]; + + if( self ) + { + m_affineTrafo = [[CAffineTrafo alloc] init]; + m_copiedObjects = nil; + } + + return self; +} + +- (void) dealloc +{ + [m_copiedObjects release]; + [m_affineTrafo release]; + [super dealloc]; +} + +- (void) cancel +{ + // Release the copied objects. + [m_copiedObjects release]; + m_copiedObjects = nil; + + // Get the selection. + CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection]; + + // Reshow the selection. + [selection show]; + + // Clear the selection. + [selection clear]; +} + +- (void) drawRect: (NSRect) rect +{ + // Convert NSRect to CGRect. + CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ); + // Get context. + CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; + + // Draw the copied objects. + CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer]; + + [copiedObjectsRenderer setDrawingBoundary: drawRect]; + [copiedObjectsRenderer setContext: context]; + [copiedObjectsRenderer visitSelection: m_copiedObjects]; +} + +- (void) finish +{ + // Release the copied objects. + [m_copiedObjects release]; + m_copiedObjects = nil; + + // Get the document. + ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document]; + + // Make the document transform the selection. + [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]] + thenBy: [[CAffineMap allocWithZone:[self zone]] init] + actionName: NSLocalizedString( + @"Move Objects", + @"Name of undo/redo action for moving objects" )]; + + // Show the selection agin. + [[document selection] show]; +} + +- (void) updateInternalState +{ + // Release the copied objects. + [m_copiedObjects release]; + + // Get the selection tool. + CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; + + // Get the selection. + CSelection* selection = [[[[selectionTool view] mainController] document] selection]; + + // Copy the selected objects. + m_copiedObjects = [selection copy]; + + // Calculate the movement. + double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x; + double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y; + + // Set the affine map. + [[m_affineTrafo affineMap] reset]; + [[m_affineTrafo affineMap] translateX: dx Y: dy]; + + // Apply the affine transformation to the copied objects. + [m_affineTrafo visitSelection: m_copiedObjects]; + + // Show the copied objects. + [m_copiedObjects show]; +} + ++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState +{ + static CSelectionToolMoveState* s_instance = nil; + + if( !s_instance ) + s_instance = [[CSelectionToolMoveState alloc] init]; + + return s_instance; +} + +- (void) start +{ + // Get the document selection. + CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection]; + + // Hide the document selection. + [selection hide]; +} + +@end Copied: trunk/src/gui/tools/CSelectionToolRectangleState.h (from rev 533, trunk/src/gui/tools/CSelectionToolSelectState.h) =================================================================== --- trunk/src/gui/tools/CSelectionToolRectangleState.h (rev 0) +++ trunk/src/gui/tools/CSelectionToolRectangleState.h 2007-05-27 22:18:03 UTC (rev 544) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2007 Lennart Kudling + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +@class CRect; +#import "CSelectionToolState.h" + +/** + * The selection tool state for selecting objects with the selction rectangle. + */ +@interface CSelectionToolRectangleState : CSelectionToolState +{ + /** + * The selection rectangle. + */ + CRect* m_selectionRectangle; +} + +/** + * Returns the singleton instance. + */ ++ (CSelectionToolRectangleState*) sharedSelectionToolSelectState; + +@end Copied: trunk/src/gui/tools/CSelectionToolRectangleState.m (from rev 541, trunk/src/gui/tools/CSelectionToolSelectState.m) =================================================================== --- trunk/src/gui/tools/CSelectionToolRectangleState.m (rev 0) +++ trunk/src/gui/tools/CSelectionToolRectangleState.m 2007-05-27 22:18:03 UTC (rev 544) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2007 Lennart Kudling + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#import "CFindObjectsInRectangleVisitor.h" +#import "CRect.h" +#import "CSelection.h" +#import "CSelectionTool.h" +#import "CSelectionToolRectangleState.h" + +@implementation CSelectionToolRectangleState + +- (id) init +{ + self = [super init]; + + if( self ) + { + m_selectionRectangle = [[CRect alloc] init]; + } + + return self; +} + +- (void) cancel +{ +} + +- (void) dealloc +{ + [m_selectionRectangle release]; + [super dealloc]; +} + +- (void) drawRect: (NSRect) rect +{ + // Get context. + CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; + + // Fill CGRect for drawing. + CGRect drawRect = [m_selectionRectangle rectangle].cgRect; + drawRect.origin.x = drawRect.origin.x + 0.5; + drawRect.origin.y = drawRect.origin.y + 0.5; + + // Define dash pattern. + float dashes[ 2 ] = { 2.0, 2.0 }; + + CGContextBeginPath( context ); + CGContextAddRect( context, drawRect ); + CGContextSetRGBFillColor( context, 0.0, 0.0, 0.0, 0.1 ); + CGContextSetRGBStrokeColor( context, 0.0, 0.0, 0.0, 0.7 ); + CGContextSetLineWidth( context, 1.0 ); + CGContextSetLineDash( context, 0.0, dashes, 2 ); + CGContextDrawPath( context, kCGPathFillStroke ); + + CGContextAddRect( context, drawRect ); + CGContextSetRGBStrokeColor( context, 1.0, 1.0, 1.0, 0.7 ); + CGContextSetLineDash( context, 2.0, dashes, 2 ); + CGContextStrokePath( context ); +} + +- (void) finish +{ + if( ![m_selectionRectangle isEmpty] ) + { + // Get the selection tool. + CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; + + // Get the selection. + CSelection* selection = [[[[selectionTool view] mainController] document] selection]; + + // Find all objects within m_selectionRectangle. + CFindObjectsInRectangleVisitor* findVisior = [[CFindObjectsInRectangleVisitor alloc] init]; + [findVisior setRectangleOfInterest: m_selectionRectangle]; + [findVisior visitDocument: [[[selectionTool view] mainController] document]]; + + // Clear the selection if the Shift key is not down. + if( ![selectionTool shiftKeyIsDown] ) + [selection clear]; + + // Add the found objects to the document selection. + [selection addObjectsFromArray: [findVisior objects]]; + + // Release the find visitor. + [findVisior release]; + } +} + +- (void) updateInternalState +{ + // Get the selection tool. + CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; + + [m_selectionRectangle + setPointX: [selectionTool mouseDownPos].x + y: [[CSelectionTool sharedSelectionTool] mouseDownPos].y]; + [m_selectionRectangle + addPointX: [selectionTool currentMousePos].x + y: [[CSelectionTool sharedSelectionTool] currentMousePos].y]; +} + ++ (CSelectionToolRectangleState*) sharedSelectionToolSelectState +{ + static CSelectionToolRectangleState* s_instance = nil; + + if( !s_instance ) + s_instance = [[CSelectionToolRectangleState alloc] init]; + + return s_instance; +} + +- (void) start +{ + [self updateInternalState]; +} + +@end + Modified: trunk/src/gui/tools/CSelectionToolResizeState.h =================================================================== --- trunk/src/gui/tools/CSelectionToolResizeState.h 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionToolResizeState.h 2007-05-27 22:18:03 UTC (rev 544) @@ -28,15 +28,18 @@ /** * Carries the origin of the transformation (set during start method) */ - NSPoint m_resizeOrigin; + NSPoint m_resizeOrigin; + /** * The translation map to move the objects to the origin */ CAffineMap* transMap; + /** * The translation map to scale and move the objects back to their original position */ CAffineMap* scaleTransMap; + /** * If true, limits mouse movements to its x part, ignoring all y values */ Deleted: trunk/src/gui/tools/CSelectionToolSelectState.h =================================================================== --- trunk/src/gui/tools/CSelectionToolSelectState.h 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionToolSelectState.h 2007-05-27 22:18:03 UTC (rev 544) @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2007 Lennart Kudling - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -@class CRect; -#import "CSelectionToolState.h" - -/** - * The selection tool state for selecting objects with the selction rectangle. - */ -@interface CSelectionToolSelectState : CSelectionToolState -{ - /** - * The selection rectangle. - */ - CRect* m_selectionRectangle; -} - -/** - * Returns the singleton instance. - */ -+ (CSelectionToolSelectState*) sharedSelectionToolSelectState; - -@end Deleted: trunk/src/gui/tools/CSelectionToolSelectState.m =================================================================== --- trunk/src/gui/tools/CSelectionToolSelectState.m 2007-05-27 22:13:22 UTC (rev 543) +++ trunk/src/gui/tools/CSelectionToolSelectState.m 2007-05-27 22:18:03 UTC (rev 544) @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2007 Lennart Kudling - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#import "CFindObjectsInRectangleVisitor.h" -#import "CRect.h" -#import "CSelection.h" -#import "CSelectionTool.h" -#import "CSelectionToolSelectState.h" - -@implementation CSelectionToolSelectState - -- (id) init -{ - self = [super init]; - - if( self ) - { - m_selectionRectangle = [[CRect alloc] init]; - } - - return self; -} - -- (void) cancel -{ -} - -- (void) dealloc -{ - [m_selectionRectangle release]; - [super dealloc]; -} - -- (void) drawRect: (NSRect) rect -{ - // Get context. - CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - - // Fill CGRect for drawing. - CGRect drawRect = [m_selectionRectangle rectangle].cgRect; - drawRect.origin.x = drawRect.origin.x + 0.5; - drawRect.origin.y = drawRect.origin.y + 0.5; - - // Define dash pattern. - float dashes[ 2 ] = { 2.0, 2.0 }; - - CGContextBeginPath( context ); - CGContextAddRect( context, drawRect ); - CGContextSetRGBFillColor( context, 0.0, 0.0, 0.0, 0.1 ); - CGContextSetRGBStrokeColor( context, 0.0, 0.0, 0.0, 0.7 ); - CGContextSetLineWidth( context, 1.0 ); - CGContextSetLineDash( context, 0.0, dashes, 2 ); - CGContextDrawPath( context, kCGPathFillStroke ); - - CGContextAddRect( context, drawRect ); - CGContextSetRGBStrokeColor( context, 1.0, 1.0, 1.0, 0.7 ); - CGContextSetLineDash( context, 2.0, dashes, 2 ); - CGContextStrokePath( context ); -} - -- (void) finish -{ - if( ![m_selectionRectangle isEmpty] ) - { - // Get the selection tool. - CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; - - // Get the selection. - CSelection* selection = [[[[selectionTool view] mainController] document] selection]; - - // Find all objects within m_selectionRectangle. - CFindObjectsInRectangleVisitor* findVisior = [[CFindObjectsInRectangleVisitor alloc] init]; - [findVisior setRectangleOfInterest: m_selectionRectangle]; - [findVisior visitDocument: [[[selectionTool view] mainController] document]]; - - // Clear the selection if the Shift key is not down. - if( ![selectionTool shiftKeyIsDown] ) - [selection clear]; - - // Add the found objects to the document selection. - [selection addObjectsFromArray: [findVisior objects]]; - - // Release the find visitor. - [findVisior release]; - } -} - -- (void) updateInternalState -{ - // Get the selection tool. - CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool]; - - [m_selectionRectangle - setPointX: [selectionTool mouseDownPos].x - y: [[CSelectionTool sharedSelectionTool] mouseDownPos].y]; - [m_selectionRectangle - addPointX: [selectionTool currentMousePos].x - y: [[CSelectionTool sharedSelectionTool] currentMousePos].y]; -} - -+ (CSelectionToolSelectState*) sharedSelectionToolSelectState -{ - static CSelectionToolSelectState* s_instance = nil; - - if( !s_instance ) - s_instance = [[CSelectionToolSelectState alloc] init]; - - return s_instance; -} - -- (void) start -{ - [self updateInternalState]; -} - -@end - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |