mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Separated out GormWindowEditor.h and added documentation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21546 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
391b37df31
commit
37d98a0127
10 changed files with 256 additions and 147 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-07-26 22:56 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GNUmakefile: Added new GormWindowEditor.h file.
|
||||
* GormCore/GormWindowEditor.m: Reorganized methods, extracted .h
|
||||
* GormCore/GormWindowEditor.h: New file.
|
||||
* GormCore/NSCell+GormAdditions.h
|
||||
* GormCore/NSColorWell+GormExtensions.h
|
||||
* GormCore/NSColorWell+GormExtensions.m
|
||||
* GormCore/NSFontManager+GormExtensions.h
|
||||
* GormCore/NSFontManager+GormExtensions.m
|
||||
* GormCore/NSView+GormExtensions.h: Added documentation.
|
||||
|
||||
2005-07-26 21:02 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Palettes/2Controls/GormNSTextFieldInspector.gorm: Correct
|
||||
|
|
|
@ -81,6 +81,7 @@ GormCore_HEADER_FILES = \
|
|||
GormViewWindow.h \
|
||||
GormViewWithContentViewEditor.h \
|
||||
GormViewWithSubviewsEditor.h \
|
||||
GormWindowEditor.h \
|
||||
NSCell+GormAdditions.h \
|
||||
NSColorWell+GormExtensions.h \
|
||||
NSFontManager+GormExtensions.h \
|
||||
|
|
108
GormCore/GormWindowEditor.h
Normal file
108
GormCore/GormWindowEditor.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
/* GormWindowEditor.h
|
||||
*
|
||||
* Copyright (C) 1999,2004,2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
||||
* Date: 1999
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Date: 2004,2005
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
*
|
||||
* 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 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_GormWindowEditor_h
|
||||
#define INCLUDED_GormWindowEditor_h
|
||||
|
||||
#include <InterfaceBuilder/IBDocuments.h>
|
||||
#include <InterfaceBuilder/IBEditors.h>
|
||||
#include <GormCore/GormViewWithContentViewEditor.h>
|
||||
|
||||
@class NSMutableArray, NSString, NSView, NSPasteboard;
|
||||
|
||||
@interface GormWindowEditor : GormViewWithContentViewEditor
|
||||
{
|
||||
NSView *edit_view;
|
||||
NSMutableArray *subeditors;
|
||||
BOOL isLinkSource;
|
||||
NSPasteboard *dragPb;
|
||||
NSString *dragType;
|
||||
}
|
||||
/**
|
||||
* Returns YES, if the reciever accepts any of the pasteboard items in types.
|
||||
*/
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types;
|
||||
|
||||
/**
|
||||
* Activates the editor
|
||||
*/
|
||||
- (BOOL) activate;
|
||||
|
||||
/**
|
||||
* Instantiate with anObject in the document aDocument.
|
||||
*/
|
||||
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument;
|
||||
|
||||
/**
|
||||
* Change the font.
|
||||
*/
|
||||
- (void) changeFont: (id) sender;
|
||||
|
||||
/**
|
||||
* Close the editor. This will also call the deactivate method.
|
||||
*/
|
||||
- (void) close;
|
||||
|
||||
/**
|
||||
* Close any and all editors which are subordinate to this one.
|
||||
*/
|
||||
- (void) closeSubeditors;
|
||||
|
||||
/**
|
||||
* Deactivate the editor.
|
||||
*/
|
||||
- (void) deactivate;
|
||||
|
||||
/**
|
||||
* Delete the current selection.
|
||||
*/
|
||||
- (void) deleteSelection;
|
||||
|
||||
/**
|
||||
* Return the document which the object the receiver is edited is located in.
|
||||
*/
|
||||
- (id<IBDocuments>) document;
|
||||
|
||||
/**
|
||||
* Call with success or failure of the drag operation.
|
||||
*/
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
|
||||
|
||||
/**
|
||||
* Returns NSDragOperationNone.
|
||||
*/
|
||||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag;
|
||||
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL)flag;
|
||||
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)anObject;
|
||||
- (void) orderFront;
|
||||
- (void) pasteInSelection;
|
||||
- (void) resetObject: (id)anObject;
|
||||
@end
|
||||
|
||||
#endif
|
|
@ -1,9 +1,11 @@
|
|||
/* GormWindowEditor.m
|
||||
*
|
||||
* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2004,2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
||||
* Date: 1999
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Date: 2004,2005
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
*
|
||||
|
@ -29,6 +31,7 @@
|
|||
#include "GormViewWithContentViewEditor.h"
|
||||
#include "GormInternalViewEditor.h"
|
||||
#include "GormViewKnobs.h"
|
||||
#include "GormWindowEditor.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -117,35 +120,52 @@
|
|||
@end
|
||||
|
||||
|
||||
|
||||
@interface GormWindowEditor : GormViewWithContentViewEditor
|
||||
{
|
||||
NSView *edit_view;
|
||||
NSMutableArray *subeditors;
|
||||
BOOL isLinkSource;
|
||||
NSPasteboard *dragPb;
|
||||
NSString *dragType;
|
||||
}
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types;
|
||||
- (BOOL) activate;
|
||||
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument;
|
||||
- (void) changeFont: (id) sender;
|
||||
- (void) close;
|
||||
- (void) closeSubeditors;
|
||||
- (void) deactivate;
|
||||
- (void) deleteSelection;
|
||||
- (id<IBDocuments>) document;
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
|
||||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag;
|
||||
- (void) makeSelectionVisible: (BOOL)flag;
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)anObject;
|
||||
- (void) orderFront;
|
||||
- (void) pasteInSelection;
|
||||
- (void) resetObject: (id)anObject;
|
||||
@end
|
||||
|
||||
@implementation GormWindowEditor
|
||||
|
||||
- (id) initWithObject: (id)anObject
|
||||
inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if ((self = [super initWithFrame: NSZeroRect]) == nil)
|
||||
return nil;
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: IBWillCloseDocumentNotification
|
||||
object: aDocument];
|
||||
|
||||
_displaySelection = YES;
|
||||
ASSIGN(_editedObject, anObject);
|
||||
|
||||
// we don't retain the document...
|
||||
document = aDocument;
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
GormLinkPboardType, IBViewPboardType, nil]];
|
||||
|
||||
selection = [[NSMutableArray alloc] init];
|
||||
subeditors = [[NSMutableArray alloc] init];
|
||||
|
||||
activated = NO;
|
||||
closed = NO;
|
||||
|
||||
[self activate];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (closed == NO)
|
||||
[self close];
|
||||
|
||||
RELEASE(selection);
|
||||
RELEASE(subeditors);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
|
||||
{
|
||||
NSDebugLog(@"acceptsFirstMouse");
|
||||
|
@ -189,6 +209,17 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[contentViewEditor deactivate];
|
||||
[_EO unsetInitialFirstResponder];
|
||||
activated = NO;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
- (void) changeFont: (id)sender
|
||||
{
|
||||
NSDebugLog(@"changeFont");
|
||||
|
@ -227,78 +258,9 @@
|
|||
NSLog(@"copySelection");
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[contentViewEditor deactivate];
|
||||
[_EO unsetInitialFirstResponder];
|
||||
activated = NO;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (closed == NO)
|
||||
[self close];
|
||||
|
||||
RELEASE(selection);
|
||||
RELEASE(subeditors);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
- (id) retain
|
||||
{
|
||||
NSLog(@"Being retained... %d: %@", [self retainCount], self);
|
||||
return [super retain];
|
||||
}
|
||||
|
||||
- (oneway void) release
|
||||
{
|
||||
NSLog(@"Being released... %d: %@", [self retainCount], self);
|
||||
[super release];
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dragging source protocol implementation
|
||||
*/
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f
|
||||
{
|
||||
/*
|
||||
* Notification that a drag failed/succeeded.
|
||||
*/
|
||||
|
||||
NSDebugLog(@"draggedImage");
|
||||
|
||||
if(f == NO)
|
||||
{
|
||||
NSRunAlertPanel(nil, _(@"Window drag failed."),
|
||||
_(@"OK"), nil, nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag
|
||||
{
|
||||
NSDebugLog(@"draggingSourceOperationMaskForLocal");
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
NSLog(@"deleteSelection");
|
||||
}
|
||||
|
||||
- (void) drawSelection
|
||||
|
@ -311,39 +273,6 @@
|
|||
return document;
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)anObject
|
||||
inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if ((self = [super initWithFrame: NSZeroRect]) == nil)
|
||||
return nil;
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: IBWillCloseDocumentNotification
|
||||
object: aDocument];
|
||||
|
||||
_displaySelection = YES;
|
||||
ASSIGN(_editedObject, anObject);
|
||||
|
||||
// we don't retain the document...
|
||||
document = aDocument;
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
GormLinkPboardType, IBViewPboardType, nil]];
|
||||
|
||||
selection = [[NSMutableArray alloc] init];
|
||||
subeditors = [[NSMutableArray alloc] init];
|
||||
|
||||
activated = NO;
|
||||
closed = NO;
|
||||
|
||||
[self activate];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL)flag
|
||||
{
|
||||
if (flag == NO)
|
||||
|
@ -420,21 +349,37 @@
|
|||
NSDebugLog(@"validateEditing");
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain: (id) aNotification
|
||||
/*
|
||||
* Dragging source protocol implementation
|
||||
*/
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f
|
||||
{
|
||||
NSDebugLog(@"windowDidBecomeMain %@", selection);
|
||||
if ([NSApp isConnecting] == NO)
|
||||
/*
|
||||
* Notification that a drag failed/succeeded.
|
||||
*/
|
||||
|
||||
NSDebugLog(@"draggedImage");
|
||||
|
||||
if(f == NO)
|
||||
{
|
||||
[document setSelectionFromEditor: self];
|
||||
NSDebugLog(@"windowDidBecomeMain %@", selection);
|
||||
[self makeSelectionVisible: YES];
|
||||
NSRunAlertPanel(nil, _(@"Window drag failed."),
|
||||
_(@"OK"), nil, nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain: (id) aNotification
|
||||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag
|
||||
{
|
||||
NSDebugLog(@"windowDidResignMain");
|
||||
// [document setSelectionFromEditor: self];
|
||||
[self makeSelectionVisible: NO];
|
||||
NSDebugLog(@"draggingSourceOperationMaskForLocal");
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
@class NSText;
|
||||
|
||||
@interface NSCell (GormAdditions)
|
||||
/**
|
||||
* This methods is comes directly from NSCell.m
|
||||
* The only additions is [textObject setUsesFontPanel: NO]
|
||||
* We do this because we want to have control over the font
|
||||
* panel changes.
|
||||
*/
|
||||
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObject;
|
||||
@end
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include <AppKit/NSColorWell.h>
|
||||
|
||||
@interface NSColorWell (GormExtensions)
|
||||
/**
|
||||
* Changes the color without sending the action associated with it.
|
||||
*/
|
||||
- (void) setColorWithoutAction: (NSColor *)color;
|
||||
@end
|
||||
|
||||
|
|
|
@ -27,15 +27,13 @@
|
|||
#include "NSColorWell+GormExtensions.h"
|
||||
|
||||
@implementation NSColorWell (GormExtensions)
|
||||
|
||||
/**
|
||||
* Changes the color without sending the action associated with it.
|
||||
*/
|
||||
- (void) setColorWithoutAction: (NSColor *)color
|
||||
{
|
||||
ASSIGN(_the_color, color);
|
||||
/*
|
||||
* Experimentation with NeXTstep shows that when the color of an active
|
||||
* colorwell is set, the color of the shared color panel is set too,
|
||||
* though this does not raise the color panel, only the event of
|
||||
* activation does that.
|
||||
*/
|
||||
if ([self isActive])
|
||||
{
|
||||
NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
|
||||
|
@ -44,4 +42,5 @@
|
|||
}
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -28,7 +28,14 @@
|
|||
#include <AppKit/NSFontManager.h>
|
||||
|
||||
@interface NSFontManager (GormExtensions)
|
||||
|
||||
/**
|
||||
* Override for sendAction in NSFontManager. This method calls the action on the
|
||||
* last edited object if the attempt to send the action to the first responder is
|
||||
* unsuccessful. This allows the font to be more easily set.
|
||||
*/
|
||||
- (BOOL) sendAction;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
@end
|
||||
|
||||
@implementation GormDocument (FontManagerMethod)
|
||||
/**
|
||||
* Get the last editor selected by the document.
|
||||
*/
|
||||
- (id) lastEditor
|
||||
{
|
||||
return lastEditor;
|
||||
|
@ -41,6 +44,11 @@
|
|||
|
||||
@implementation NSFontManager (GormExtensions)
|
||||
|
||||
/**
|
||||
* Override for sendAction in NSFontManager. This method calls the action on the
|
||||
* last edited object if the attempt to send the action to the first responder is
|
||||
* unsuccessful. This allows the font to be more easily set.
|
||||
*/
|
||||
- (BOOL) sendAction
|
||||
{
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
|
|
|
@ -30,9 +30,29 @@
|
|||
@class NSArray;
|
||||
|
||||
@interface NSView (GormExtensions)
|
||||
/**
|
||||
* All superviews of the receiver.
|
||||
*/
|
||||
- (NSArray *) superviews;
|
||||
|
||||
/**
|
||||
* Returns YES if the receiver has an instance of the Class cls
|
||||
* as a superview.
|
||||
*/
|
||||
- (BOOL) hasSuperviewKindOfClass: (Class)cls;
|
||||
|
||||
/**
|
||||
* Move the subview sv in reciever to the end of the reciever's
|
||||
* display list. This has the effect of making it appear in front
|
||||
* of the other views.
|
||||
*/
|
||||
- (void) moveViewToFront: (NSView *)sv;
|
||||
|
||||
/**
|
||||
* Move the subview sv in reciever to the beginning of the reciever's
|
||||
* display list. This has the effect of making it appear in back
|
||||
* of the other views.
|
||||
*/
|
||||
- (void) moveViewToBack: (NSView *)sv;
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue