Optimised text edition reflection. Embedded editing will need more changes

in that respect, I fear...


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12400 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Philippe C.D. Robert 2002-02-03 19:31:28 +00:00
parent 6f74df7b63
commit 005848beb8
4 changed files with 80 additions and 27 deletions

View file

@ -48,6 +48,8 @@
- (void)windowDidBecomeKey:(NSNotification *)aNotification;
- (void)windowDidResignKey:(NSNotification *)aNotification;
- (void)textDidChange:(NSNotification *)aNotification;
@end
@interface NSObject (PCEditorDelegate )

View file

@ -79,6 +79,7 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
[window setContentView:scrollView];
[window setDelegate:self];
[window makeFirstResponder:view];
RELEASE(scrollView);
}
@ -102,12 +103,19 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
[view setText:text];
path = [file copy];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:view];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
RELEASE(window);
RELEASE(path);
@ -205,12 +213,12 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
{
NSString *text = [NSString stringWithContentsOfFile:path];
[view setText:text];
if( isEmbedded == NO )
{
[window setDocumentEdited:NO];
}
[view setText:text];
}
- (void)windowWillClose:(NSNotification *)aNotification
@ -237,4 +245,9 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
}
}
- (void)textDidChange:(NSNotification *)aNotification
{
[window setDocumentEdited:YES];
}
@end

View file

@ -48,10 +48,12 @@
unsigned int style = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask;
NSBrowser *browser;
NSRect _w_frame;
NSRect rect;
NSMatrix* matrix;
NSButtonCell* buttonCell = [[[NSButtonCell alloc] init] autorelease];
id textField;
id textView;
id scrollView;
id button;
PCSplitView *split;
@ -62,8 +64,8 @@
*
*/
_w_frame = NSMakeRect(100,100,560,440);
projectWindow = [[NSWindow alloc] initWithContentRect:_w_frame
rect = NSMakeRect(100,100,560,440);
projectWindow = [[NSWindow alloc] initWithContentRect:rect
styleMask:style
backing:NSBackingStoreBuffered
defer:YES];
@ -77,7 +79,7 @@
[browser setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
[browserController setBrowser:browser];
_w_frame.size.height -= 64;
rect.size.height -= 64;
[browserController setProject:self];
box = [[NSBox alloc] initWithFrame:NSMakeRect (-1,-1,562,252)];
@ -86,31 +88,64 @@
[box setContentViewMargins: NSMakeSize(0.0,0.0)];
[box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
/*
rect = [box frame];
rect.origin.x = -1;
rect.origin.y = -1;
rect.size.width += 2;
scrollView = [[NSScrollView alloc] initWithFrame:rect];
rect.origin.x = 0;
rect.origin.y = 0;
rect.size.height -= 24;
rect.size.width -= 4;
textView = [[NSTextView alloc] initWithFrame:rect];
[textView setText:@"This is a test"];
[textView setDrawsBackground:YES];
[textView setMinSize: NSMakeSize (0, 0)];
[textView setMaxSize:NSMakeSize(1e7, 1e7)];
[textView setRichText:NO];
[textView setEditable:YES];
[textView setSelectable:YES];
[textView setVerticallyResizable:YES];
[textView setHorizontallyResizable:NO];
[textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[textView setBackgroundColor:[NSColor whiteColor]];
[[textView textContainer] setWidthTracksTextView:YES];
[scrollView setDocumentView:textView];
[box addSubview:scrollView];
rect.size = NSMakeSize([scrollView contentSize].width,1e7);
[[textView textContainer] setContainerSize:rect.size];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
RELEASE(textView);
RELEASE(scrollView);
*/
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(16,200,500,21)];
[textField setAlignment: NSLeftTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"Welcome to the GNUstep ProjectCenter!"];
[textField setStringValue:@"Welcome to ProjectCenter.app"];
[box addSubview:textField];
RELEASE(textField);
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(16,178,500,21)];
[textField setAlignment: NSLeftTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"\tPlease send your feedback to phr@3dkit.org!"];
[box addSubview:textField];
RELEASE(textField);
_w_frame = [[projectWindow contentView] frame];
_w_frame.size.height -= 76;
_w_frame.size.width -= 16;
_w_frame.origin.x += 8;
split = [[PCSplitView alloc] initWithFrame:_w_frame];
rect = [[projectWindow contentView] frame];
rect.size.height -= 76;
rect.size.width -= 16;
rect.origin.x += 8;
split = [[PCSplitView alloc] initWithFrame:rect];
[split setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
_c_view = [projectWindow contentView];
@ -127,8 +162,8 @@
* Left button matrix
*/
_w_frame = NSMakeRect(8,372,240,60);
matrix = [[NSMatrix alloc] initWithFrame: _w_frame
rect = NSMakeRect(8,372,240,60);
matrix = [[NSMatrix alloc] initWithFrame: rect
mode: NSHighlightModeMatrix
prototype: buttonCell
numberOfRows: 1
@ -174,9 +209,9 @@
*
*/
_w_frame = NSMakeRect(100,100,272,80);
rect = NSMakeRect(100,100,272,80);
style = NSTitledWindowMask | NSClosableWindowMask;
buildTargetPanel = [[NSWindow alloc] initWithContentRect:_w_frame
buildTargetPanel = [[NSWindow alloc] initWithContentRect:rect
styleMask:style
backing:NSBackingStoreBuffered
defer:YES];

View file

@ -149,6 +149,8 @@
[[panel contentView] addSubview:replaceTextField];
RELEASE(replaceTextField);
[findTextField setNextResponder:replaceTextField];
// Options
rect = NSMakeRect(104,40,144 ,80);
box = [[NSBox alloc] initWithFrame:rect];
@ -236,6 +238,7 @@
[borderMatrix setTarget: self];
[borderMatrix setAction: @selector(buttonPressed:)];
[borderMatrix setAutosizesCells: NO];
[replaceTextField setNextResponder:borderMatrix];
cell = [borderMatrix cellAtRow:0 column:0];
[cell setTitle: @"Replace All"];
@ -328,7 +331,7 @@ static PCTextFinder *_finder = nil;
[self _initUI];
}
[panel makeKeyAndOrderFront:self];
[panel orderFront:self];
}
- (void)buttonPressed:(id)sender