* Headers/AppKit/AppKit.h: added NSHelpManager.h.

* Headers/AppKit/NSHelpManager.h: declaration for new method -pathForHelpResource:
  * Source/NSHelpManager.m: implemented -pathForHelpResource: in the NSBundle 
  category. -pathForHelpResource: looks for help files giving the priority
  to localized resources. 
  -showHelp: looks for rtfd files too.
  * Source/GSHelpManagerPanel.m: various fixes to avoid a crash when quitting
  and to resize correctly the NSTextView.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23164 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Sersale 2006-07-15 11:42:02 +00:00
parent b718aee750
commit 30dc6bf85a
5 changed files with 177 additions and 76 deletions

View file

@ -28,6 +28,7 @@
#include "AppKit/NSApplication.h"
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSTextView.h"
#include "AppKit/NSTextContainer.h"
#include "AppKit/NSScrollView.h"
#include "AppKit/NSClipView.h"
#include "AppKit/NSColor.h"
@ -46,68 +47,69 @@ static GSHelpManagerPanel* _GSsharedGSHelpPanel;
return _GSsharedGSHelpPanel;
}
/* This window should not be destroyed... So we don't allow it to! */
- (id) retain
- (id)init
{
return self;
}
- (void) release
{
}
- (id) autorelease
{
return self;
}
- (id) init
{
NSScrollView *scrollView;
NSRect scrollViewRect = {{0, 0}, {470, 150}};
NSRect winRect = {{100, 100}, {470, 150}};
unsigned int style = NSTitledWindowMask | NSClosableWindowMask
| NSMiniaturizableWindowMask | NSResizableWindowMask;
unsigned int style = NSTitledWindowMask | NSClosableWindowMask
| NSMiniaturizableWindowMask | NSResizableWindowMask;
self = [super initWithContentRect: winRect
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
[self initWithContentRect: winRect
styleMask: style
backing: NSBackingStoreRetained
defer: NO];
[self setFloatingPanel: YES];
[self setRepresentedFilename: @"Help"];
[self setTitle: @"Help"];
[self setDocumentEdited: NO];
if (self) {
NSRect scrollViewRect = {{0, 0}, {470, 150}};
NSRect r;
NSScrollView *scrollView;
scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES];
[scrollView setAutoresizingMask: NSViewHeightSizable];
textView = [[NSTextView alloc] initWithFrame:
[[scrollView contentView] frame]];
[textView setEditable: NO];
[textView setRichText: YES];
[textView setSelectable: YES];
// off white
[textView setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.85
alpha: 1.0]];
[scrollView setDocumentView: textView];
[[self contentView] addSubview: scrollView];
RELEASE(scrollView);
[self setReleasedWhenClosed: NO];
[self setFloatingPanel: YES];
// [self setTitle: NSLocalizedString(@"Help", @"")];
[self setTitle: @"Help"];
scrollView = [[NSScrollView alloc] initWithFrame: scrollViewRect];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES];
[scrollView setAutoresizingMask: NSViewHeightSizable];
r = [[scrollView contentView] frame];
textView = [[NSTextView alloc] initWithFrame: r];
[textView setRichText: YES];
[textView setEditable: NO];
[textView setSelectable: NO];
[textView setHorizontallyResizable: NO];
[textView setVerticallyResizable: YES];
[textView setMinSize: NSMakeSize (0, 0)];
[textView setMaxSize: NSMakeSize (1E7, 1E7)];
[textView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
[[textView textContainer] setContainerSize: NSMakeSize(r.size.width, 1e7)];
[[textView textContainer] setWidthTracksTextView: YES];
[textView setUsesRuler: NO];
// [textView setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.85 alpha: 1.0]];
[scrollView setDocumentView: textView];
RELEASE(textView);
[[self contentView] addSubview: scrollView];
RELEASE(scrollView);
}
return self;
}
- (void) setHelpText: (NSAttributedString*) helpText
- (void)setHelpText:(NSAttributedString *)helpText
{
// FIXME: The attributed text should be set, but there is
// no public method for this.
[textView setText: [helpText string]];
[[textView textStorage] setAttributedString: helpText];
}
- (void) close
{
[NSApp stopModal];
if ([self isVisible])
{
[NSApp stopModal];
}
[super close];
}
@end