mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Fixes galore.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4866 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
23782dbb01
commit
33dbd8054f
10 changed files with 423 additions and 8 deletions
33
ChangeLog
33
ChangeLog
|
@ -1,4 +1,35 @@
|
|||
iThu Sep 9 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
1999-09-10 Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
|
||||
* Source/NSHelpManager.m: new file. See below for an explanation.
|
||||
* Headers/AppKit/NSHelpManager.h: new file.
|
||||
* Source/GSHelpManagerPanel.h: new file.
|
||||
* Source/GSHelpManagerPanel.m: new file, defines the help window
|
||||
used by NSHelpManager.
|
||||
* Source/NSWindow.m ([NSWindow -sendEvent:]): if we're in context
|
||||
help mode, call -helpRequested: instead of -mouseDown.
|
||||
* NSResponder.m ([NSResponder -helpRequested:]): if the current
|
||||
responder has context help, show it using NSHelpManager; else,
|
||||
pass to the next responder.
|
||||
|
||||
These changes and new files implement the NSHelpManager context
|
||||
help interface, which is defined on OpenStep 4.1 onward and Mac
|
||||
OS X Server.
|
||||
To define context help for any responder, call [[NSHelpManager
|
||||
sharedHelpManager] setContextHelp: (an NSAttributedString with the
|
||||
help) forObject: (the responder)]. For the user to see it, call
|
||||
[[NSApplication sharedApplication] activateContextHelpMode] for
|
||||
now, and the next time a user clicks on a responder, its help
|
||||
will be shown.
|
||||
The actiation of the context help mode will be automatic in the
|
||||
future.
|
||||
|
||||
1999-09-10 Michael Hanni <mhanni@sprintmail.com>
|
||||
|
||||
* Source/NSTabView.m: fixed a display problem. Tabs on the bottom
|
||||
of the view work, but some display niggles remain. (Note: we beat
|
||||
Apple on this one, heh.)
|
||||
|
||||
Thu Sep 9 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSButtonCell.m: implemented missing method ([-cellSize]).
|
||||
|
||||
|
|
11
Headers/gnustep/gui/GSHelpManagerPanel.h
Normal file
11
Headers/gnustep/gui/GSHelpManagerPanel.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#import <AppKit/AppKit.h>
|
||||
|
||||
@interface GSHelpManagerPanel: NSPanel
|
||||
{
|
||||
id textView;
|
||||
}
|
||||
|
||||
+sharedHelpManagerPanel;
|
||||
-init;
|
||||
-(void)setHelpText: (NSAttributedString*)helpText;
|
||||
@end
|
79
Headers/gnustep/gui/NSHelpManager.h
Normal file
79
Headers/gnustep/gui/NSHelpManager.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
NSHelpManager.m
|
||||
|
||||
Description...
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
Date: 1999
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GNUstep_H_NSHelpManager
|
||||
#define __GNUstep_H_NSHelpManager
|
||||
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
|
||||
@class NSAttributedString;
|
||||
|
||||
@interface NSBundle (NSHelpManager)
|
||||
- (NSAttributedString*) contextHelpForKey: (NSString*) key;
|
||||
@end
|
||||
|
||||
@interface NSApplication (NSHelpManager)
|
||||
- (void) showHelp: (id) sender;
|
||||
- (void) activateContextHelpMode: (id) sender;
|
||||
@end
|
||||
|
||||
@interface NSHelpManager: NSObject
|
||||
{
|
||||
@private
|
||||
NSMapTable* contextHelpTopics;
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (NSHelpManager*)sharedHelpManager;
|
||||
|
||||
+ (BOOL)isContextHelpModeActive;
|
||||
|
||||
+ (void)setContextHelpModeActive: (BOOL) flag;
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (NSAttributedString*) contextHelpForObject: (id)object;
|
||||
|
||||
- (void) removeContextHelpForObject: (id)object;
|
||||
|
||||
- (void) setContextHelp: (NSAttributedString*) help withObject: (id) object;
|
||||
|
||||
- (BOOL) showContextHelpForObject: (id)object locationHint: (NSPoint) point;
|
||||
|
||||
@end
|
||||
|
||||
// Notifications
|
||||
extern NSString* NSContextHelpModeDidActivateNotification;
|
||||
extern NSString* NSContextHelpModeDidDeactivateNotification;
|
||||
|
||||
#endif // GNUstep_H_NSHelpManager
|
|
@ -75,6 +75,7 @@ NSForm.m \
|
|||
NSFormCell.m \
|
||||
NSGraphicsContext.m \
|
||||
NSHelpPanel.m \
|
||||
NSHelpManager.m \
|
||||
NSImage.m \
|
||||
NSImageCell.m \
|
||||
NSImageRep.m \
|
||||
|
@ -126,6 +127,7 @@ NSView.m \
|
|||
NSWindow.m \
|
||||
NSWorkspace.m \
|
||||
GSComboSupport.m \
|
||||
GSHelpManagerPanel.m \
|
||||
GSTextStorage.m \
|
||||
GSTrackingRect.m \
|
||||
GSServicesManager.m \
|
||||
|
@ -181,6 +183,7 @@ AppKit/NSFormCell.h \
|
|||
AppKit/NSGraphics.h \
|
||||
AppKit/NSGraphicsContext.h \
|
||||
AppKit/NSHelpPanel.h \
|
||||
AppKit/NSHelpManager.h \
|
||||
AppKit/NSImage.h \
|
||||
AppKit/NSImageCell.h \
|
||||
AppKit/NSImageRep.h \
|
||||
|
|
85
Source/GSHelpManagerPanel.m
Normal file
85
Source/GSHelpManagerPanel.m
Normal file
|
@ -0,0 +1,85 @@
|
|||
#import <AppKit/AppKit.h>
|
||||
#import <AppKit/GSHelpManagerPanel.h>
|
||||
|
||||
@implementation GSHelpManagerPanel
|
||||
{
|
||||
id textView;
|
||||
}
|
||||
|
||||
static GSHelpManagerPanel* _GSsharedGSHelpPanel;
|
||||
|
||||
+sharedHelpManagerPanel
|
||||
{
|
||||
if(!_GSsharedGSHelpPanel)
|
||||
_GSsharedGSHelpPanel = [[GSHelpManagerPanel alloc] init];
|
||||
return _GSsharedGSHelpPanel;
|
||||
}
|
||||
|
||||
/* This window should not be destroyed... So we don't allow it to! */
|
||||
-retain
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
-release
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
-autorelease
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
-init
|
||||
{
|
||||
NSScrollView* scrollView;
|
||||
NSRect scrollViewRect = {{0, 0}, {470, 150}};
|
||||
NSRect winRect = {{100, 100}, {470, 150}};
|
||||
NSColor* backColor;
|
||||
unsigned int style = NSTitledWindowMask | NSClosableWindowMask
|
||||
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
||||
|
||||
[self initWithContentRect:winRect
|
||||
styleMask:style
|
||||
backing:NSBackingStoreRetained
|
||||
defer:NO];
|
||||
[self setRepresentedFilename: @"Help"];
|
||||
[self setDocumentEdited: NO];
|
||||
|
||||
scrollView = [[NSScrollView alloc] initWithFrame:scrollViewRect];
|
||||
[scrollView setHasHorizontalScroller:NO];
|
||||
[scrollView setHasVerticalScroller:YES];
|
||||
[scrollView setAutoresizingMask: NSViewHeightSizable];
|
||||
|
||||
textView = [NSText new];
|
||||
[textView setEditable: NO];
|
||||
[textView setRichText: YES];
|
||||
[textView setSelectable: YES];
|
||||
[textView setFrame:[[scrollView contentView] frame]];
|
||||
backColor = [NSColor colorWithCalibratedWhite:0.85 alpha:1.0]; // off white
|
||||
[textView setBackgroundColor:backColor];
|
||||
[scrollView setDocumentView:textView];
|
||||
[[self contentView] addSubview: scrollView];
|
||||
|
||||
[self setTitle:@"Help"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setHelpText: (NSAttributedString*) helpText
|
||||
{
|
||||
[textView setText: [helpText string]];
|
||||
}
|
||||
|
||||
-(BOOL) isFloatingPanel
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void) close
|
||||
{
|
||||
[NSApp stopModal];
|
||||
[super close];
|
||||
}
|
||||
@end
|
174
Source/NSHelpManager.m
Normal file
174
Source/NSHelpManager.m
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
NSHelpManager.m
|
||||
|
||||
NSHelpManager is the class responsible for managing context help
|
||||
for the application, and its mapping to the graphic elements.
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Pedro Ivo Andrade Tavares <ptavares@iname.com>
|
||||
Date: September 1999
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSHelpManager.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <AppKit/NSAttributedString.h>
|
||||
#include <AppKit/NSWorkspace.h>
|
||||
#include <AppKit/GSHelpManagerPanel.h>
|
||||
|
||||
@implementation NSBundle (NSHelpManager)
|
||||
|
||||
- (NSAttributedString*) contextHelpForKey: (NSString*) key
|
||||
{
|
||||
// FIXME
|
||||
/* There are some issues here. I still have to understand how
|
||||
does Help.plist work. */
|
||||
NSLog(@"contextHelpForKey not implemented yet.");
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSApplication (NSHelpManager)
|
||||
|
||||
- (void) showHelp: (id)sender
|
||||
{
|
||||
// FIXME
|
||||
/* This is obviously very restrictive. The ideal would be to check
|
||||
the Resources first, but this can be done later. */
|
||||
[[NSWorkspace sharedWorkspace] openFile: @"Help.rtf"];
|
||||
}
|
||||
|
||||
- (void) activateContextHelpMode: (id)sender
|
||||
{
|
||||
[NSHelpManager setContextHelpModeActive: YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSHelpManager
|
||||
{
|
||||
@private
|
||||
NSMapTable* contextHelpTopics;
|
||||
}
|
||||
|
||||
static NSHelpManager *_gnu_sharedHelpManager = nil;
|
||||
static BOOL _gnu_contextHelpActive = NO;
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (NSHelpManager*)sharedHelpManager
|
||||
{
|
||||
if (!_gnu_sharedHelpManager)
|
||||
{
|
||||
_gnu_sharedHelpManager = [NSHelpManager alloc];
|
||||
[_gnu_sharedHelpManager init];
|
||||
}
|
||||
return _gnu_sharedHelpManager;
|
||||
}
|
||||
|
||||
+ (BOOL)isContextHelpModeActive
|
||||
{
|
||||
return _gnu_contextHelpActive;
|
||||
}
|
||||
|
||||
+ (void)setContextHelpModeActive: (BOOL) flag
|
||||
{
|
||||
_gnu_contextHelpActive = flag;
|
||||
if (flag)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSContextHelpModeDidActivateNotification
|
||||
object: [self sharedHelpManager]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSContextHelpModeDidDeactivateNotification
|
||||
object: [self sharedHelpManager]];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (id) init
|
||||
{
|
||||
contextHelpTopics = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks,
|
||||
64);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSAttributedString*) contextHelpForObject: (id)object
|
||||
{
|
||||
/* Help is kept on the contextHelpTopics NSMapTable, with
|
||||
the object for it as the key.
|
||||
|
||||
Help is loaded on demand:
|
||||
If it's an NSAttributedString which is stored, then it's already
|
||||
loaded.
|
||||
If it's nil, there's no help for this object, and that's what we return.
|
||||
If it's an NSString, it's the path for the help, and we ask NSBundle
|
||||
for it (This part has to be written, so:) */
|
||||
// FIXME
|
||||
|
||||
id hc = NSMapGet(contextHelpTopics, object);
|
||||
if(hc)
|
||||
{
|
||||
if(![hc isKindOfClass: [NSAttributedString class]])
|
||||
{
|
||||
hc = [[NSBundle mainBundle] contextHelpForKey: hc];
|
||||
NSMapInsert(contextHelpTopics, object, hc);
|
||||
}
|
||||
}
|
||||
return hc;
|
||||
}
|
||||
|
||||
- (void) removeContextHelpForObject: (id)object
|
||||
{
|
||||
NSMapRemove(contextHelpTopics, object);
|
||||
}
|
||||
|
||||
- (void) setContextHelp: (NSAttributedString*) help withObject: (id) object
|
||||
{
|
||||
NSMapInsert(contextHelpTopics, object, help);
|
||||
}
|
||||
|
||||
- (BOOL) showContextHelpForObject: (id)object locationHint: (NSPoint) point
|
||||
{
|
||||
id contextHelp = [self contextHelpForObject: object];
|
||||
if (contextHelp)
|
||||
{
|
||||
[[GSHelpManagerPanel sharedHelpManagerPanel] setHelpText: contextHelp];
|
||||
[NSApp runModalForWindow: [GSHelpManagerPanel sharedHelpManagerPanel]];
|
||||
return YES;
|
||||
}
|
||||
else return NO;
|
||||
}
|
||||
|
||||
@end
|
|
@ -32,6 +32,7 @@
|
|||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSHelpManager.h>
|
||||
#include <objc/objc.h>
|
||||
|
||||
@implementation NSResponder
|
||||
|
@ -122,10 +123,15 @@
|
|||
|
||||
- (void) helpRequested: (NSEvent *)theEvent
|
||||
{
|
||||
if([[NSHelpManager sharedHelpManager]
|
||||
showContextHelpForObject: self
|
||||
locationHint: [theEvent locationInWindow]])
|
||||
{
|
||||
[NSHelpManager setContextHelpModeActive: NO];
|
||||
}
|
||||
else
|
||||
if (next_responder)
|
||||
return [next_responder helpRequested: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(helpRequested:)];
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *)theEvent
|
||||
|
|
|
@ -154,6 +154,9 @@
|
|||
|
||||
tab_selected_item = [tab_items indexOfObject:tab_selected];
|
||||
[tab_selected _setTabState:NSSelectedTab];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
if ([tab_selected view])
|
||||
[self addSubview:[tab_selected view]];
|
||||
|
||||
|
@ -162,8 +165,6 @@
|
|||
{
|
||||
[tab_delegate tabView:self didSelectTabViewItem:tab_selected];
|
||||
}
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +572,7 @@
|
|||
|
||||
// [self setNeedsDisplay:YES];
|
||||
|
||||
[window update];
|
||||
// [window update];
|
||||
|
||||
return [super hitTest:aPoint];
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <AppKit/PSOperators.h>
|
||||
#include <AppKit/NSDragging.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <AppKit/NSHelpManager.h>
|
||||
|
||||
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
||||
|
||||
|
@ -1446,10 +1447,28 @@ static NSRecursiveLock *windowsLock;
|
|||
{
|
||||
[self makeFirstResponder: v];
|
||||
if (is_key || [v acceptsFirstMouse: theEvent] == YES)
|
||||
[v mouseDown: theEvent];
|
||||
{
|
||||
if([NSHelpManager isContextHelpModeActive])
|
||||
{
|
||||
[v helpRequested: theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[v mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
[v mouseDown: theEvent];
|
||||
{
|
||||
if([NSHelpManager isContextHelpModeActive])
|
||||
{
|
||||
[v helpRequested: theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[v mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
||||
|
|
|
@ -130,6 +130,12 @@ NSString *NSControlTextDidChangeNotification =
|
|||
// NSDataLink global strings
|
||||
NSString *NSDataLinkFileNameExtension = @"dlf";
|
||||
|
||||
// NSHelpManager notifications;
|
||||
NSString *NSContextHelpModeDidActivateNotification =
|
||||
@"NSContextHelpModeDidActivateNotification";
|
||||
NSString *NSContextHelpModeDidDeactivateNotification =
|
||||
@"NSContextHelpModeDidDeactivateNotification";
|
||||
|
||||
// NSFont Global Strings
|
||||
NSString *NSAFMAscender = @"Ascender";
|
||||
NSString *NSAFMCapHeight = @"CapHeight";
|
||||
|
|
Loading…
Reference in a new issue