From 396208b2461a2254f63084fe619fd8911c46f671 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 14 Jan 2011 08:51:52 -0500 Subject: [PATCH] Remove the old BSLineNumberView --- MacGDBp.xcodeproj/project.pbxproj | 6 -- Source/BSLineNumberView.h | 32 ------- Source/BSLineNumberView.mm | 152 ------------------------------ Source/BSSourceView.h | 2 - 4 files changed, 192 deletions(-) delete mode 100644 Source/BSLineNumberView.h delete mode 100644 Source/BSLineNumberView.mm diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index d8d145d..7a1b78a 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ 1E67E6FD0F3C052000E68F1B /* PreferencesPathsArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E67E6FC0F3C052000E68F1B /* PreferencesPathsArrayController.m */; }; 1E6B5947116106FE001189D2 /* LoggingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E6B5946116106FE001189D2 /* LoggingController.m */; }; 1E6B594C11610993001189D2 /* Log.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E6B594A11610993001189D2 /* Log.xib */; }; - 1E7188680D839F6300969277 /* BSLineNumberView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188630D839F6300969277 /* BSLineNumberView.mm */; }; 1E7188690D839F6300969277 /* BSSourceView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188650D839F6300969277 /* BSSourceView.mm */; }; 1E822CDD0DA28AC30027A23F /* Breakpoint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E822CDC0DA28AC30027A23F /* Breakpoint.m */; }; 1E9582620E252474001A3D89 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E9582600E252474001A3D89 /* Preferences.xib */; }; @@ -91,8 +90,6 @@ 1E6B5945116106FE001189D2 /* LoggingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LoggingController.h; path = Source/LoggingController.h; sourceTree = ""; }; 1E6B5946116106FE001189D2 /* LoggingController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LoggingController.m; path = Source/LoggingController.m; sourceTree = ""; }; 1E6B594B11610993001189D2 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Log.xib; sourceTree = ""; }; - 1E7188620D839F6300969277 /* BSLineNumberView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSLineNumberView.h; path = Source/BSLineNumberView.h; sourceTree = ""; }; - 1E7188630D839F6300969277 /* BSLineNumberView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BSLineNumberView.mm; path = Source/BSLineNumberView.mm; sourceTree = ""; }; 1E7188640D839F6300969277 /* BSSourceView.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = BSSourceView.h; path = Source/BSSourceView.h; sourceTree = ""; }; 1E7188650D839F6300969277 /* BSSourceView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BSSourceView.mm; path = Source/BSSourceView.mm; sourceTree = ""; }; 1E822CDB0DA28AC30027A23F /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Breakpoint.h; path = Source/Breakpoint.h; sourceTree = ""; }; @@ -251,8 +248,6 @@ children = ( 1EEBFD080D3599E8008F835B /* BSSplitView.h */, 1EEBFD070D3599E8008F835B /* BSSplitView.m */, - 1E7188620D839F6300969277 /* BSLineNumberView.h */, - 1E7188630D839F6300969277 /* BSLineNumberView.mm */, 1E7188640D839F6300969277 /* BSSourceView.h */, 1E7188650D839F6300969277 /* BSSourceView.mm */, 1EDA9CF612DD13B300596211 /* BSLineNumberRulerView.h */, @@ -447,7 +442,6 @@ 1E02C5F60C610724006F1752 /* DebuggerController.m in Sources */, 1E35FC760C6579CA0030F527 /* NSXMLElementAdditions.m in Sources */, 1EEBFD090D3599E8008F835B /* BSSplitView.m in Sources */, - 1E7188680D839F6300969277 /* BSLineNumberView.mm in Sources */, 1E7188690D839F6300969277 /* BSSourceView.mm in Sources */, 1E822CDD0DA28AC30027A23F /* Breakpoint.m in Sources */, 1E4C7AF90DA401C7000A9DC7 /* BreakpointManager.m in Sources */, diff --git a/Source/BSLineNumberView.h b/Source/BSLineNumberView.h deleted file mode 100644 index f8aabb3..0000000 --- a/Source/BSLineNumberView.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * MacGDBp - * Copyright (c) 2007 - 2011, Blue Static - * - * This program 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 2 of the - * License, or (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#import - -@class BSSourceView; - -@interface BSLineNumberView : NSView -{ - BSSourceView* sourceView; - NSRange lineNumberRange; - NSSet* markers; -} - -@property(readwrite, assign) BSSourceView* sourceView; -@property(readonly) NSRange lineNumberRange; -@property(readwrite, retain) NSSet* markers; - -@end diff --git a/Source/BSLineNumberView.mm b/Source/BSLineNumberView.mm deleted file mode 100644 index 1e4a41d..0000000 --- a/Source/BSLineNumberView.mm +++ /dev/null @@ -1,152 +0,0 @@ -/* - * MacGDBp - * Copyright (c) 2007 - 2011, Blue Static - * - * This program 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 2 of the - * License, or (at your option) any later version. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#import "BSLineNumberView.h" -#import "Breakpoint.h" -#import "BSSourceView.h" - -@interface BSLineNumberView (Private) -- (void)drawMarkerInRect:(NSRect)rect; -@end - -@implementation BSLineNumberView - -@synthesize sourceView, lineNumberRange, markers; - -/** - * Initializer for the line number view - */ -- (id)initWithFrame:(NSRect)frame -{ - if (self = [super initWithFrame:frame]) - { - lineNumberRange = NSMakeRange(0, 0); - } - return self; -} - -/** - * Flip the coordinates - */ -- (BOOL)isFlipped -{ - return YES; -} - -/** - * Draws the line numbers whenever necessary - */ -- (void)drawRect:(NSRect)rect -{ - // background color - [[NSColor colorWithDeviceRed:0.871 green:0.871 blue:0.871 alpha:1] set]; - [NSBezierPath fillRect:rect]; - - [[NSColor blackColor] set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y)]; - - [[NSColor grayColor] set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.size.height) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.size.height)]; - - // font attributes for the line number - NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Monaco" size:9.0], NSFontAttributeName, [NSColor grayColor], NSForegroundColorAttributeName, nil]; - - lineNumberRange = NSMakeRange(0, 0); - - unsigned i = 0, line = 1; - while (i < [[[sourceView textView] layoutManager] numberOfGlyphs]) - { - NSRange fragRange; - NSRect fragRect = [self convertRect:[[[sourceView textView] layoutManager] lineFragmentRectForGlyphAtIndex:i effectiveRange:&fragRange] fromView:[sourceView textView]]; - fragRect.origin.x = rect.origin.x; // horizontal scrolling matters not - fragRect.size.width = [self bounds].size.width; - - // we want to paint the top and bottom line number even if they're cut off - NSRect testRect = rect; - testRect.origin.y -= fragRect.size.height - 1; - testRect.size.height += fragRect.size.height - 1; - if (NSPointInRect(fragRect.origin, testRect)) - { - lineNumberRange.location = (lineNumberRange.length == 0 ? line : lineNumberRange.location); - lineNumberRange.length++; - NSString* num = [NSString stringWithFormat:@"%u", line]; - NSSize strSize = [num sizeWithAttributes:attrs]; - [num drawAtPoint:NSMakePoint([self frame].size.width - strSize.width - 3, fragRect.origin.y + ((fragRect.size.height - strSize.height) / 2)) withAttributes:attrs]; - Breakpoint* test = [[Breakpoint alloc] initWithLine:line inFile:[sourceView file]]; - if ([markers containsObject:test]) - { - [self drawMarkerInRect:fragRect]; - } - [test release]; - } - - i += fragRange.length; - line++; - } -} - -/** - * Handles the mouse down event (which is adding, deleting, and toggling breakpoints) - */ -- (void)mouseDown:(NSEvent*)event -{ - NSTextView* textView = [sourceView textView]; - - NSPoint clickLoc = [self convertPoint:[event locationInWindow] fromView:nil]; - - unsigned line = 1; - unsigned i = 0; - while (i < [[textView layoutManager] numberOfGlyphs]) - { - NSRange fragRange; - NSRect fragRect = [[textView layoutManager] lineFragmentRectForGlyphAtIndex:i effectiveRange:&fragRange]; - fragRect.size.width = [self bounds].size.width; - if (NSPointInRect(clickLoc, fragRect)) - { - [[sourceView delegate] gutterClickedAtLine:(line + lineNumberRange.location - 1) forFile:[sourceView file]]; - return; - } - - i += fragRange.length; - line++; - } -} - -#pragma mark Private - -/** - * Draws a marker in a given rectangle - */ -- (void)drawMarkerInRect:(NSRect)rect -{ - NSBezierPath* path = [NSBezierPath bezierPath]; - - [path moveToPoint:NSMakePoint(rect.origin.x + 2, rect.origin.y + 2)]; // initial origin - [path lineToPoint:NSMakePoint(rect.size.width - 7, rect.origin.y + 2)]; // upper right - [path lineToPoint:NSMakePoint(rect.size.width - 2, rect.origin.y + (rect.size.height / 2))]; // point - [path lineToPoint:NSMakePoint(rect.size.width - 7, rect.origin.y + rect.size.height - 2)]; // lower right - [path lineToPoint:NSMakePoint(rect.origin.x + 2, rect.origin.y + rect.size.height - 2)]; // lower left - [path lineToPoint:NSMakePoint(rect.origin.x + 2, rect.origin.y + 1)]; // upper left - - [[NSColor colorWithDeviceRed:0.004 green:0.557 blue:0.851 alpha:1.0] set]; - [path fill]; - - [[NSColor colorWithDeviceRed:0.0 green:0.404 blue:0.804 alpha:1.0] set]; - [path setLineWidth:2]; - [path stroke]; -} - -@end diff --git a/Source/BSSourceView.h b/Source/BSSourceView.h index c2494d6..65517d4 100644 --- a/Source/BSSourceView.h +++ b/Source/BSSourceView.h @@ -16,8 +16,6 @@ #import -#import "BSLineNumberView.h" - @class BSLineNumberRulerView; @protocol BSSourceViewDelegate; -- 2.43.5