* NSView.h added specific values and comments to resize constants enum.

* NSView.m implemented resizeWithOldSuperviewSize (needs work).
	* NSMatrix.m mousedown clarified description comment.
	* NSSavePanel.m integrated source from Daniel B�hringer into premliminary
		implementations provided by Scott Christley.
	* NSSavePanel.h integrated source from Daniel B�hringer into premliminary
		implementations provided by Scott Christley.
	* NSOpenPanel.m integrated source from Daniel B�hringer into premliminary
		implementations provided by Scott Christley.
	* NSOpenPanel.h integrated source from Daniel B�hringer into premliminary
		implementations provided by Scott Christley.
	* NSStringDrawing.h defined NSAttributedString portion of extension.
	* NSAttributedString.h created preliminary implementation of extension.
	* Appkit.h added includes for NSAttributedString and NSStringDrawing.
	* NSPasteboard.h added extern NSRTFDPboardType define.
	* externs.m defined NSRTFDPboardType.
	* NSText.h integrated source from Daniel B�hringer
	* NSTextView.m preliminary implementation from Daniel B�hringer
	* NSTextView.h preliminary implementation from Daniel B�hringer
	* NSSplitView.m in drawRect use NSRectFill()


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2934 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Felipe A. Rodriguez 1998-08-19 09:00:26 +00:00
parent 80825f3b17
commit fd64d9ffb9
18 changed files with 606 additions and 297 deletions

View file

@ -75,6 +75,7 @@
#include <AppKit/NSActionCell.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSAttributedString.h>
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSBox.h>
#include <AppKit/NSBrowser.h>
@ -134,6 +135,7 @@
#include <AppKit/NSSpellProtocol.h>
#include <AppKit/NSSpellServer.h>
#include <AppKit/NSSplitView.h>
#include <AppKit/NSStringDrawing.h>
#include <AppKit/NSText.h>
#include <AppKit/NSTextField.h>
#include <AppKit/NSTextFieldCell.h>

View file

@ -7,6 +7,10 @@
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into Scott Christley's preliminary
implementation by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
@ -42,6 +46,10 @@
BOOL multiple_select;
BOOL choose_dir;
BOOL choose_file;
// integrated from Daniel's source FAR
BOOL canChooseDirectories;
BOOL canChooseFiles;
BOOL allowsMultipleSelection;
}
//
@ -62,6 +70,9 @@
//
// Querying the Chosen Files
//
// Returns an array containing the absolute paths (as NSString
// objects) of the selected files and directories. If multiple
// selections aren't allowed, the array contains a single name.
- (NSArray *)filenames;
//
@ -69,8 +80,8 @@
//
- (int)runModalForTypes:(NSArray *)fileTypes;
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)filename
types:(NSArray *)fileTypes;
file:(NSString *)name
types:(NSArray *)fileTypes;
//
// NSCoding protocol

View file

@ -48,6 +48,16 @@ enum {
@interface NSPanel : NSWindow <NSCoding>
{
// Attributes
BOOL _becomesKeyOnlyIfNeeded;
BOOL _isFloatingPanel;
BOOL _worksWhenModal;
id file_name;
id directory;
id panel_title;
id accessory_view;
id required_type;
id panel_prompt;
id file_package;
}
//

View file

@ -48,6 +48,7 @@ extern NSString *NSRulerPboardType;
extern NSString *NSPostScriptPboardType;
extern NSString *NSTabularTextPboardType;
extern NSString *NSRTFPboardType;
extern NSString *NSRTFDPboardType;
extern NSString *NSTIFFPboardType;
extern NSString *NSDataLinkPboardType;
extern NSString *NSGeneralPboardType;

View file

@ -1,20 +1,24 @@
/*
/*
NSSavePanel.h
Standard save panel for saving files
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into Scott Christley's preliminary
implementation by Felipe A. Rodriguez <far@ix.netcom.com>
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
@ -24,13 +28,16 @@
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_NSSavePanel
#define _GNUstep_H_NSSavePanel
#include <Foundation/NSCoder.h>
#include <Foundation/NSSet.h>
#include <AppKit/NSPanel.h>
#include <AppKit/NSBrowser.h>
@class NSString;
@class NSView;
@ -41,94 +48,136 @@ enum {
NSFileHandlingPanelBrowser,
NSFileHandlingPanelCancelButton,
NSFileHandlingPanelOKButton,
NSFileHandlingPanelForm,
NSFileHandlingPanelHomeButton,
NSFileHandlingPanelDiskButton,
NSFileHandlingPanelDiskEjectButton
NSFileHandlingPanelForm,
NSFileHandlingPanelHomeButton,
NSFileHandlingPanelDiskButton,
NSFileHandlingPanelDiskEjectButton
};
@interface NSSavePanel : NSPanel <NSCoding>
{
// Attributes
NSView *accessory_view;
NSString *panel_title;
NSString *panel_prompt;
NSString *directory;
NSString *file_name;
NSString *required_type;
BOOL file_package;
// id delegate;
NSBrowser *browser; // from Daniel's source
id form;
id homeButton;
id okButton;
id mountButton,unmountButton;
id separator;
id titleField;
NSString *lastValidPath;
NSArray *requiredTypes;
NSSet *typeTable;
// Reserved for back-end use
void *be_save_reserved;
// Attributes
id panelImage; // from Scott's source
id panelTitleField;
id panelPromptField;
id panelBrowser;
id panelFileNameField;
NSString *_directory;
NSString *_fileName;
NSString *_requiredType;
BOOL _filePackage;
BOOL _delegateRespondsToCompare;
BOOL _delegateRespondsToShow;
BOOL _delegateRespondsToValid;
// to do finish integration, eliminate excess FAR
NSView *_accessoryView; // integrated by Felipe
BOOL treatsFilePackagesAsDirectories;
// Reserved for back-end use
void *be_save_reserved;
}
//
// Creating an NSSavePanel
// Creating an NSSavePanel
//
+ (NSSavePanel *)savePanel;
+ (NSSavePanel *)savePanel; // Returns an instance of NSSavePanel,
// creating one if necessary.
//
// Customizing the NSSavePanel
// Customizing the NSSavePanel
//
- (void)setDefaults;
- (void)setAccessoryView:(NSView *)aView;
- (NSView *)accessoryView;
// Sets the title of the NSSavePanel to title. By default,
// ªSaveº is the title string. If you adapt the NSSavePanel
// for other uses, its title should reflect the user action
// that brings it to the screen.
- (void)setTitle:(NSString *)title;
- (NSString *)title;
- (void)setPrompt:(NSString *)prompt;
// Returns the prompt of the Save panel field that holds
// the current pathname or file name. By default this
// prompt is ªName:º. *Note - currently no prompt is shown.
- (NSString *)prompt;
//
// Setting Directory and File Type
// Setting Directory and File Type
//
- (NSString *)requiredFileType;
// Sets the current path name in the Save panel's browser.
// The path argument must be an absolute path name.
- (void)setDirectory:(NSString *)path;
// Specifies the type, a file name extension to be appended to
// any selected files that don't already have that extension;
// The argument type should not include the period that begins
// the extension. Invoke this method each time the Save panel
// is used for another file type within the application.
- (void)setRequiredFileType:(NSString *)type;
// Sets the NSSavePanel's behavior for displaying file packages
// (for example, MyApp.app) to the user. If flag is YES, the
// user is shown files and subdirectories within a file
// package. If NO, the NSSavePanel shows each file package as
// a file, thereby giving no indication that it is a directory.
- (void)setTreatsFilePackagesAsDirectories:(BOOL)flag;
- (BOOL)treatsFilePackagesAsDirectories;
// Validates and possibly reloads the browser columns visible
// in the Save panel by causing the delegate method
// panel:shouldShowFilename: to be invoked. One situation in
// which this method would find use is whey you want the
// browser show only files with certain extensions based on the
// selection made in an accessory-view pop-up list. When the
// user changes the selection, you would invoke this method to
// revalidate the visible columns.
- (void)validateVisibleColumns;
//
// Running the NSSavePanel
// Running the NSSavePanel
//
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)filename;
// Initializes the panel to the directory specified by path
// and, optionally, the file specified by filename, then
// displays it and begins its modal event loop; path and
// filename can be empty strings, but cannot be nil. The
// method invokes Application's runModalForWindow: method with
// self as the argument. Returns NSOKButton (if the user
// clicks the OK button) or NSCancelButton (if the user clicks
// the Cancel button). Do not invoke filename or directory
// within a modal loop because the information that these
// methods fetch is updated only upon return.
- (int)runModalForDirectory:(NSString *)path file:(NSString *)filename;
- (int)runModal;
//
// Reading Save Information
// Reading Save Information
//
// Returns the absolute pathname of the directory currently
// shown in the panel. Do not invoke this method within a
// modal session (runModal or runModalForDirectory:file:)
// because the directory information is only updated just
// before the modal session ends.
- (NSString *)directory;
- (NSString *)filename;
//
// Target and Action Methods
// Target and Action Methods
//
- (void)ok:(id)sender;
- (void)cancel:(id)sender;
- (void)ok:(id)sender; // target/action of panel's OK button.
- (void)cancel:(id)sender; // target/action of panel's cancel button
//
// Responding to User Input
// Responding to User Input
//
- (void)selectText:(id)sender;
//
// Setting the Delegate
//
- (void)setDelegate:(id)anObject;
//
// Methods Implemented by the Delegate
//
- (NSComparisonResult)panel:(id)sender
compareFilename:(NSString *)filename1
with:(NSString *)filename2
caseSensitive:(BOOL)caseSensitive;
- (BOOL)panel:(id)sender
shouldShowFilename:(NSString *)filename;
- (BOOL)panel:(id)sender
isValidFilename:(NSString*)filename;
//
// NSCoding protocol
//
@ -137,4 +186,26 @@ enum {
@end
//
// Methods Implemented by the Delegate
//
@interface NSObject(NSSavePanelDelegate)
// The NSSavePanel sends this message just before the end of a
// modal session for each file name displayed or selected
// (including file names in multiple selections). The delegate
// determines whether it wants the file identified by filename;
// it returns YES if the file name is valid, or NO if the
// NSSavePanel should stay in its modal loop and wait for the
// user to type in or select a different file name or names. If
// the delegate refuses a file name in a multiple selection,
// none of the file names in the selection are accepted.
- (BOOL)panel:(id)sender isValidFilename:(NSString*)filename;
- (NSComparisonResult)panel:(id)sender
compareFilename:(NSString *)filename1
with:(NSString *)filename2
caseSensitive:(BOOL)caseSensitive;
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
@end
#endif // _GNUstep_H_NSSavePanel

View file

@ -30,6 +30,7 @@
#define _GNUstep_H_NSStringDrawing
#include <Foundation/NSString.h>
#include <AppKit/NSAttributedString.h>
#include <Foundation/NSGeometry.h>
#include <gnustep/base/preface.h>
@ -65,12 +66,10 @@ enum
@end
#ifdef OS_4_2
@interface NSAttributedString(NSStringDrawing)
- (NSSize)size;
@end
#endif /* OS_4_2 */
#endif /* _GNUstep_H_NSStringDrawing */

View file

@ -9,6 +9,8 @@
Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: July 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
This file is part of the GNUstep GUI Library.
@ -34,6 +36,7 @@
#include <AppKit/NSView.h>
#include <AppKit/NSSpellProtocol.h>
#include <Foundation/NSRange.h>
#include <AppKit/NSAttributedString.h>
@class NSString;
@class NSData;
@ -50,40 +53,78 @@ typedef enum _NSTextAlignment {
} NSTextAlignment;
enum {
NSIllegalTextMovement = 0,
NSIllegalTextMovement = 0,
NSReturnTextMovement = 0x10,
NSTabTextMovement = 0x11,
NSBacktabTextMovement = 0x12,
NSLeftTextMovement = 0x13,
NSTabTextMovement = 0x11,
NSBacktabTextMovement = 0x12,
NSLeftTextMovement = 0x13,
NSRightTextMovement = 0x14,
NSUpTextMovement = 0x15,
NSDownTextMovement = 0x16
NSUpTextMovement = 0x15,
NSDownTextMovement = 0x16
};
// these definitions should migrate to NSTextView when implemented
typedef enum _NSSelectionGranularity
{ NSSelectByCharacter = 0,
NSSelectByWord = 1,
NSSelectByParagraph = 2,
} NSSelectionGranularity;
#if GNUSTEP
typedef enum _NSSelectionAffinity
{ NSSelectionAffinityUpstream = 0,
NSSelectionAffinityDownstream = 1,
} NSSelectionAffinity;
#endif
@interface NSText : NSView <NSChangeSpelling,NSIgnoreMisspelledWords,NSCoding>
{
// Attributes
id delegate;
NSString *text_contents;
unsigned int alignment;
BOOL is_editable;
BOOL is_rich_text;
BOOL is_selectable;
BOOL imports_graphics;
BOOL uses_font_panel;
BOOL is_horizontally_resizable;
BOOL is_vertically_resizable;
BOOL is_ruler_visible;
BOOL is_field_editor;
BOOL draws_background;
NSColor *background_color;
NSColor *text_color;
NSFont *default_font;
NSRange selected_range;
// Reserved for back-end use
void *be_text_reserved;
{
id delegate;
NSString *text_contents;
unsigned int alignment;
BOOL is_editable;
BOOL is_rich_text;
BOOL is_selectable;
BOOL imports_graphics;
BOOL uses_font_panel;
BOOL is_horizontally_resizable;
BOOL is_vertically_resizable;
BOOL is_ruler_visible;
BOOL is_field_editor;
BOOL draws_background;
NSColor *background_color;
NSColor *text_color;
NSFont *default_font;
NSRange selected_range;
void *be_text_reserved; // Reserved for back-end use
NSSize minSize, maxSize;
NSDictionary *typingAttributes;
// content
NSMutableString *plainContent;
NSMutableAttributedString *rtfContent;
// internal stuff
// contains private _GNULineLayoutInfo objects
NSMutableArray *lineLayoutInformation;
int spellCheckerDocumentTag;
NSCharacterSet *selectionWordGranularitySet;
NSCharacterSet *selectionParagraphGranularitySet;
NSCharacterSet *inWordSet, *outsideWordSet; // linewrapping by word
}
//
// GNU utility methods
//
// return value is guaranteed to be a
// NSAttributedString even if data is only NSString
+ (NSAttributedString*) attributedStringForData:(NSString*) aData;
+ (NSData*) dataForAttributedString:(NSAttributedString*) aString;
//
// Getting and Setting Contents
//
@ -97,6 +138,10 @@ enum {
- (void)setText:(NSString *)string
range:(NSRange)range;
- (NSString *)text;
- (NSString *)string;
- (void)setString:(NSString *)string; // old fashioned
- (unsigned) textLength; // GNU extension
//
// Managing Global Characteristics
@ -121,11 +166,9 @@ enum {
- (void)changeFont:(id)sender;
- (NSFont *)font;
- (void)setBackgroundColor:(NSColor *)color;
- (void)setColor:(NSColor *)color
ofRange:(NSRange)range;
- (void)setColor:(NSColor *)color ofRange:(NSRange)range;
- (void)setFont:(NSFont *)obj;
- (void)setFont:(NSFont *)font
ofRange:(NSRange)range;
- (void)setFont:(NSFont *)font ofRange:(NSRange)range;
- (void)setTextColor:(NSColor *)color;
- (void)setUsesFontPanel:(BOOL)flag;
- (NSColor *)textColor;
@ -191,8 +234,7 @@ enum {
// Reading and Writing RTFD Files
//
- (BOOL)readRTFDFromFile:(NSString *)path;
- (BOOL)writeRTFDToFile:(NSString *)path
atomically:(BOOL)flag;
- (BOOL)writeRTFDToFile:(NSString *)path atomically:(BOOL)flag;
//
// Managing the Field Editor

View file

@ -3,8 +3,10 @@
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: January 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into GNUstep
by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
@ -29,6 +31,17 @@
#include <AppKit/NSText.h>
@interface NSTextView : NSText
{
}
- (void)insertText:(NSString *)insertString;
- (NSArray *)acceptableDragTypes;
- (void)updateDragTypeRegistration;
- (NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange
granularity:(NSSelectionGranularity)granularity;
@end
#endif /* _GNUstep_H_NSTextView */

View file

@ -7,9 +7,10 @@
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Heavily changed and extended by Ovidiu Predescu <ovidiu@net-community.com>.
Date: 1997
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library.
@ -49,21 +50,22 @@
typedef int NSTrackingRectTag;
typedef enum _NSBorderType {
NSNoBorder,
NSLineBorder,
NSBezelBorder,
NSGrooveBorder
typedef enum _NSBorderType { // constants representing the
NSNoBorder, // four types of borders that
NSLineBorder, // can appear around an NSView
NSBezelBorder,
NSGrooveBorder
} NSBorderType;
enum {
NSViewNotSizable,
NSViewMinXMargin,
NSViewWidthSizable,
NSViewMaxXMargin,
NSViewMinYMargin,
NSViewHeightSizable,
NSViewMaxYMargin
// autoresize constants which NSView uses in
// determining the parts of a view which are
enum { // resized when the view's superview is resized
NSViewNotSizable = 0, // view does not resize with its superview
NSViewMinXMargin = 1, // left margin between views can stretch
NSViewWidthSizable = 2, // view's width can stretch
NSViewMaxXMargin = 4, // right margin between views can stretch
NSViewMinYMargin = 8, // top margin between views can stretch
NSViewHeightSizable = 16, // view's height can stretch
NSViewMaxYMargin = 32 // bottom margin between views can stretch
};
@interface NSView : NSResponder <NSCoding>

View file

@ -256,6 +256,8 @@ static id NSApp;
- (int)runModalForWindow:(NSWindow *)theWindow
{
[theWindow display];
[theWindow makeKeyAndOrderFront: self];
return 0;
}

View file

@ -9,6 +9,8 @@
Date: March 1997
A completely rewritten version of the original source by Pascal Forget and
Scott Christley.
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library.
@ -1154,13 +1156,12 @@ static MPoint anchor = {0, 0};
ASSIGN(lastEvent, theEvent);
[[self window] captureMouse: self]; // grab the mouse
[self lockFocus];
// selection consists of two stages, the first stage loops
// until the mouse goes up while the second stage completes
while (!done) // the process by sending actions and displaying the cell
{ // as it should appear after the selection process
BOOL shouldProceedEvent = NO;
[self lockFocus]; // selection involves two steps, first
// a loop that continues until the left
while (!done) // mouse goes up; then a series of
{ // steps which send actions and display
BOOL shouldProceedEvent = NO; // the cell as it should appear after
// the selection process is complete
insideBounds = [self _getRow:&row
column:&column
forPoint:lastLocation

View file

@ -7,7 +7,11 @@
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into Scott Christley's preliminary
implementation by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -32,7 +36,11 @@
#include <Foundation/NSArray.h>
#include <AppKit/NSOpenPanel.h>
static NSOpenPanel *MB_THE_OPEN_PANEL = nil;
// toDo: - canChooseFiles unimplemented
// - allowsMultipleSelection untested
// - setCanChooseDirectories untested
static NSOpenPanel *gnustep_gui_open_panel = nil;
@implementation NSOpenPanel
@ -41,11 +49,8 @@ static NSOpenPanel *MB_THE_OPEN_PANEL = nil;
//
+ (void)initialize
{
if (self == [NSOpenPanel class])
{
// Initial version
[self setVersion:1];
}
if (self == [NSOpenPanel class])
[self setVersion:1]; // Initial version
}
//
@ -53,115 +58,99 @@ static NSOpenPanel *MB_THE_OPEN_PANEL = nil;
//
+ (NSOpenPanel *)openPanel
{
if (!MB_THE_OPEN_PANEL)
MB_THE_OPEN_PANEL = [[NSOpenPanel alloc] init];
return MB_THE_OPEN_PANEL;
if (!gnustep_gui_open_panel)
{
// PanelLoader *pl = [PanelLoader panelLoader];
// gnustep_gui_open_panel = [pl loadPanel: @"NSOpenPanel"];
gnustep_gui_open_panel = [[NSOpenPanel alloc] init];
}
return gnustep_gui_open_panel;
}
//
// Instance methods
//
//
// Initialization
//
- (void)setDefaults
{
[super setDefaults];
panel_title = @"Open File";
multiple_select = NO;
choose_dir = NO;
choose_file = YES;
}
- init
{
[super init];
[self setDefaults];
return self;
{
self = [super init];
[self setTitle:@"Open"];
[self setCanChooseFiles:YES];
multiple_select = NO;
return self;
}
//
// Filtering Files
//
- (BOOL)allowsMultipleSelection
{
return multiple_select;
}
- (BOOL)canChooseDirectories
{
return choose_dir;
}
- (BOOL)canChooseFiles
{
return choose_file;
}
- (void)setAllowsMultipleSelection:(BOOL)flag
{
multiple_select = flag;
{
allowsMultipleSelection=flag;
[browser setAllowsMultipleSelection:flag];
}
- (void)setCanChooseDirectories:(BOOL)flag
{
choose_dir = flag;
}
- (void)setCanChooseFiles:(BOOL)flag;
{
choose_file = flag;
}
-(BOOL) allowsMultipleSelection { return allowsMultipleSelection; }
-(void) setCanChooseDirectories:(BOOL)flag { canChooseDirectories = flag; }
-(BOOL) canChooseDirectories { return canChooseDirectories; }
-(void) setCanChooseFiles:(BOOL)flag { canChooseFiles = flag; }
-(BOOL) canChooseFiles { return canChooseFiles; }
-(NSString*) filename { return [browser path]; }
//
// Querying the Chosen Files
//
- (NSArray *)filenames
{
return the_filenames;
}
{
if(!allowsMultipleSelection)
return [NSArray arrayWithObject:[self filename]];
else
{
NSArray *cells=[browser selectedCells];
NSEnumerator *cellEnum;
id currCell;
NSMutableArray *ret = [NSMutableArray array];
NSString *dir=[self directory];
- (NSString *)filename
{
if ([the_filenames count] > 0)
return [the_filenames objectAtIndex:0];
else
return nil;
for(cellEnum=[cells objectEnumerator];currCell=[cellEnum nextObject];)
{
[ret addObject:[NSString
stringWithFormat:@"%@/%@",dir,[currCell stringValue]]];
}
return ret;
}
}
//
// Running the NSOpenPanel
//
- (int)runModalForTypes:(NSArray *)fileTypes
{
return 0;
{
return [self runModalForDirectory:[self directory]
file: nil
types: fileTypes];
}
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)filename
{
NSArray *t = [NSArray arrayWithObject:@"*"];
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)name
types:(NSArray *)fileTypes
{
if(requiredTypes)
[requiredTypes autorelease];
requiredTypes = [fileTypes retain];
if (path) directory = path;
if (filename) file_name = filename;
return [self runModalForTypes:t];
}
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)filename
types:(NSArray *)fileTypes
{
if (path) directory = path;
if (filename) file_name = filename;
return [self runModalForTypes:fileTypes];
return [self runModalForDirectory:path file:name];
}
//
// Target and Action Methods
//
- (void)ok:(id)sender
- (void)ok_ORIGINAL_NOT_USED:(id)sender // excess? fix me FAR
{
char *sp, files[4096], *p;
NSMutableString *m;

View file

@ -60,26 +60,32 @@
//
- (BOOL)becomesKeyOnlyIfNeeded
{
return NO;
return _becomesKeyOnlyIfNeeded;
}
- (BOOL)isFloatingPanel
{
return NO;
return _isFloatingPanel;
}
- (void)setBecomesKeyOnlyIfNeeded:(BOOL)flag
{}
{
_becomesKeyOnlyIfNeeded = flag;
}
- (void)setFloatingPanel:(BOOL)flag
{}
{
_isFloatingPanel = flag;
}
- (void)setWorksWhenModal:(BOOL)flag
{}
{
_worksWhenModal = flag;
}
- (BOOL)worksWhenModal
{
return NO;
return _worksWhenModal;
}
//

View file

@ -7,7 +7,11 @@
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into Scott Christley's preliminary
implementation by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -29,14 +33,27 @@
#include <gnustep/gui/config.h>
#include <string.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSString.h>
#include <Foundation/NSCoder.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSSavePanel.h>
#include <AppKit/NSOpenPanel.h>
#include <AppKit/NSBrowserCell.h>
// toDo:
// - interactive directory creation in SavePanel
// - accessory view support
// - parse ".hidden" files; array of suffixes of directories treated as single
// files
//
// Class variables
//
static NSSavePanel *MB_THE_SAVE_PANEL = nil;
static NSSavePanel *gnustep_gui_save_panel = nil;
@implementation NSSavePanel
@ -46,20 +63,22 @@ static NSSavePanel *MB_THE_SAVE_PANEL = nil;
+ (void)initialize
{
if (self == [NSSavePanel class])
{
// Initial version
[self setVersion:1];
}
[self setVersion:1]; // Initial version
}
//
// Creating an NSSavePanel
//
+ (NSSavePanel *)savePanel
{
if (!MB_THE_SAVE_PANEL)
MB_THE_SAVE_PANEL = [[NSSavePanel alloc] init];
return MB_THE_SAVE_PANEL;
{
if(!gnustep_gui_save_panel)
{
// PanelLoader *pl = [PanelLoader panelLoader];
// gnustep_gui_save_panel = (NSSavePanel *)[pl loadPanel: @"NSSavePanel"];
gnustep_gui_save_panel = [[NSSavePanel alloc] init];
}
return gnustep_gui_save_panel;
}
//
@ -70,21 +89,21 @@ static NSSavePanel *MB_THE_SAVE_PANEL = nil;
//
- (void)setDefaults
{
directory = @"\\";
file_name = @"";
accessory_view = nil;
panel_title = @"Save File";
panel_prompt = @"";
required_type = nil;
file_package = YES;
directory = @"\\";
file_name = @"";
_accessoryView = nil;
panel_title = @"Save File";
panel_prompt = @"";
required_type = nil;
treatsFilePackagesAsDirectories = YES;
}
- init
{
[super init];
[self setDefaults];
return self;
[super init];
[self setDefaults];
return self;
}
//
@ -92,143 +111,188 @@ static NSSavePanel *MB_THE_SAVE_PANEL = nil;
//
- (void)setAccessoryView:(NSView *)aView
{
accessory_view = aView;
_accessoryView = aView;
}
- (NSView *)accessoryView
{
return accessory_view;
return _accessoryView;
}
-(void) validateVisibleColumns
{
}
- (void)setTitle:(NSString *)title
{
panel_title = title;
{
[titleField setStringValue:title];
}
- (NSString *)title
{
return panel_title;
{
return [titleField stringValue];
}
- (void)setPrompt:(NSString *)prompt
{
panel_prompt = prompt;
{ // does currently not work since i went with NSTextField instead of NSForm
[[form cell] setTitle:prompt];
}
- (NSString *)prompt
{
return panel_prompt;
{
return [[form cell] title];
}
//
// Setting Directory and File Type
//
- (NSString *)requiredFileType
{
return required_type;
{
if(!requiredTypes || ![requiredTypes count])
return nil;
return [requiredTypes objectAtIndex:0];
}
- (void)setDirectory:(NSString *)path
{
directory = path;
{
NSString *standardizedPath=[path stringByStandardizingPath];
if(standardizedPath)
{
[browser setPath:standardizedPath];
if(lastValidPath)
[lastValidPath autorelease];
lastValidPath=[path retain];
}
}
- (void)setRequiredFileType:(NSString *)type
{
required_type = type;
{
if(requiredTypes)
[requiredTypes autorelease];
requiredTypes=[[NSArray arrayWithObject:type] retain];
}
- (void)setTreatsFilePackagesAsDirectories:(BOOL)flag
{
file_package = flag;
{
treatsFilePackagesAsDirectories=flag;
}
- (BOOL)treatsFilePackagesAsDirectories
{
return file_package;
{
return treatsFilePackagesAsDirectories;
}
//
// Running the NSSavePanel
//
- (int)runModalForDirectory:(NSString *)path
file:(NSString *)filename
{
if (path)
directory = path;
if (filename)
file_name = filename;
- (int)runModalForDirectory:(NSString *)path file:(NSString *)name
{
int ret;
return [self runModal];
[browser loadColumnZero];
[self setDirectory:path];
[browser setPath:[NSString stringWithFormat:@"%@/%@",
[self directory], name]];
[form setStringValue:name];
[self selectText:self]; // or should it be browser?
if([self class] == [NSOpenPanel class])
[okButton setEnabled:
([browser selectedCell] && [self canChooseDirectories]) ||
[[browser selectedCell] isLeaf]];
[self makeKeyAndOrderFront:self];
ret = [[NSApplication sharedApplication] runModalForWindow:self];
// replace warning
if([self class] == [NSSavePanel class] &&
[[browser selectedCell] isLeaf] && ret == NSOKButton)
{
if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?",
@"Replace",@"Cancel",nil,[form stringValue],
[self directory]) == NSAlertAlternateReturn)
return NSCancelButton;
}
return ret;
}
- (int)runModal
{
return 0;
{
return [self runModalForDirectory:[self directory] file:@""];
}
//
// Reading Save Information
//
- (NSString *)directory
{
return directory;
{
NSString *path;
if([[browser selectedCell] isLeaf]) // remove file component of path
path=[[browser path] stringByDeletingLastPathComponent];
else
path=[browser path];
if(![path length])
return lastValidPath;
else
return path;
}
- (NSString *)filename
{
return file_name;
{
NSString *ret = [NSString stringWithFormat:@"%@/%@",[self directory],
[form stringValue]];
// if path does not exist ask the user to
// create each missing directory
if([[self requiredFileType] length] && ![ret hasSuffix:[NSString
stringWithFormat:@".%@",[self requiredFileType]]])
ret = [NSString stringWithFormat:@"%@.%@",ret,[self requiredFileType]];
return [ret stringByExpandingTildeInPath];
}
//
// Target and Action Methods
//
- (void)ok:(id)sender
{
char *sp, files[4096];
{ // iterate through selection if a multiple selection
if(![self panel:self isValidFilename:[self filename]])
return;
strcpy(files, [file_name cString]);
sp = strrchr(files, '\\');
if (sp != NULL)
{
sp++;
*sp = '\0';
directory = [NSString stringWithCString:files];
}
[[NSApplication sharedApplication] stopModalWithCode:NSOKButton];
[self orderOut:self];
}
- (void)cancel:(id)sender
{
{
[[NSApplication sharedApplication] stopModalWithCode:NSCancelButton];
[self orderOut:self];
}
//
// Responding to User Input
//
- (void)selectText:(id)sender
{}
//
// Setting the Delegate
//
- (void)setDelegate:(id)anObject
{
delegate = anObject;
{
[form selectText:sender];
}
//
// Methods Implemented by the Delegate
//
- (NSComparisonResult)panel:(id)sender
compareFilename:(NSString *)filename1
with:(NSString *)filename2
caseSensitive:(BOOL)caseSensitive
compareFilename:(NSString *)filename1
with:(NSString *)filename2
caseSensitive:(BOOL)caseSensitive
{
if ([delegate respondsToSelector:
@selector(panel:compareFilename:with:caseSensitive:)])
return [delegate panel:sender compareFilename:filename1
with:filename2 caseSensitive:caseSensitive];
return NSOrderedSame;
if ([delegate respondsToSelector:
@selector(panel:compareFilename:with:caseSensitive:)])
return [delegate panel:sender
compareFilename:filename1
with:filename2
caseSensitive:caseSensitive];
return NSOrderedSame;
}
- (BOOL)panel:(id)sender
@ -239,12 +303,13 @@ shouldShowFilename:(NSString *)filename
return NO;
}
- (BOOL)panel:(id)sender
isValidFilename:(NSString*)filename
{
if ([delegate respondsToSelector:@selector(panel:isValidFilename:)])
return [delegate panel:sender isValidFilename:filename];
return NO;
- (BOOL)panel:(id)sender isValidFilename:(NSString*)filename
{
if([self delegate] && [[self delegate]
respondsToSelector:@selector(panel:isValidFilename:)])
return [[self delegate] panel:sender isValidFilename:filename];
return YES;
}
//
@ -252,7 +317,7 @@ isValidFilename:(NSString*)filename
//
- (void)encodeWithCoder:aCoder
{
[aCoder encodeObject: accessory_view];
[aCoder encodeObject: _accessoryView];
[aCoder encodeObject: panel_title];
[aCoder encodeObject: panel_prompt];
[aCoder encodeObject: directory];
@ -268,7 +333,7 @@ isValidFilename:(NSString*)filename
- initWithCoder:aDecoder
{
accessory_view = [aDecoder decodeObject];
_accessoryView = [aDecoder decodeObject];
panel_title = [aDecoder decodeObject];
panel_prompt = [aDecoder decodeObject];
directory = [aDecoder decodeObject];

View file

@ -26,12 +26,14 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <gnustep/gui/config.h>
#import <Foundation/Foundation.h>
#import <Foundation/NSRunLoop.h>
#import <AppKit/AppKit.h>
#include <string.h>
#include <math.h>
/* Backend protocol - methods that must be implemented by the backend to
complete the class */
@protocol NSSplitViewBackend
@ -421,7 +423,8 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
if([self isOpaque])
{
[[self backgroundColor] set];
[self _fillRect: [self bounds]];
NSRectFill(r);
// [self _fillRect: [self bounds]];
}
/* draw the dimples */

View file

@ -3,9 +3,9 @@
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: January 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -23,7 +23,75 @@
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import <AppKit/NSTextView.h>
#include <AppKit/NSTextView.h>
#include <AppKit/NSPasteboard.h>
@implementation NSTextView
-(void) insertText:(NSString *)insertString
{ // update previous line in case a word
// moved up on becoming shorter
unsigned lineIndex = MAX(0, [self lineLayoutIndexForCharacterIndex:
[self selectedRange].location - 1]);
//if(![delegate textDid...]) return; // also send notifications
if([self isRichText])
{
[self replaceRange:[self selectedRange]
withAttributedString:[[[NSAttributedString alloc]
initWithString:insertString attributes:[self typingAttributes]]
autorelease]];
[self rebuildRichLineLayoutInformationStartingAtLine:lineIndex];
}
else
{
[self replaceRange:[self selectedRange] withString:insertString];
[self rebuildPlainLineLayoutInformationStartingAtLine:lineIndex];
} // move the cursor
[self setSelectedRange:NSMakeRange([self selectedRange].location +
[insertString length],0)];
// [self displayRect:NSUnionRect([[lineLayoutInformation
// objectAtIndex:lineIndex] lineRect],
// [[lineLayoutInformation lastObject]lineRect])];
}
- (NSArray*)acceptableDragTypes
{
NSMutableArray *ret = [NSMutableArray arrayWithObjects:NSStringPboardType,
NSColorPboardType, nil];
if([self isRichText])
[ret addObject:NSRTFPboardType];
if([self importsGraphics])
[ret addObject:NSRTFDPboardType];
return ret;
}
- (void)updateDragTypeRegistration
{
[self registerForDraggedTypes:[self acceptableDragTypes]];
}
- (NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange
granularity:(NSSelectionGranularity)granularity
{
switch(granularity)
{
case NSSelectByCharacter:
return proposedCharRange;
case NSSelectByWord:
{ //selectionWordGranularitySet
}
break;
case NSSelectByParagraph:
{ //selectionParagraphGranularitySet
}
break;
}
return proposedCharRange;
}
@end

View file

@ -7,10 +7,11 @@
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Heavily changed and extended by Ovidiu Predescu <ovidiu@net-community.com>.
Date: 1997
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -161,6 +162,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
needs_display = YES;
post_frame_changes = NO;
autoresize_subviews = YES;
autoresizingMask = NSViewNotSizable;
return self;
}
@ -710,7 +712,28 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
}
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
{}
{ // preliminary implementation FIX ME
if(autoresizingMask == NSViewNotSizable) // view is not resizable
return;
if(autoresizingMask & NSViewWidthSizable) // width resizable?
{
frame.size.width = [super_view frame].size.width;
}
else // width is not resizable, so check
{ // if left margin can be stretched
if(autoresizingMask & NSViewMinXMargin)
frame.origin.x += [super_view frame].size.width - oldSize.width;
}
if(autoresizingMask & NSViewHeightSizable) // height resizable?
{
frame.size.height = [super_view frame].size.height;
}
else // height is not resizable so check
{ // if right margin can be stretched
if(autoresizingMask & NSViewMinYMargin)
frame.origin.y += [super_view frame].size.height - oldSize.height;
}
}
- (void)allocateGState
{}

View file

@ -173,6 +173,7 @@ NSString *NSRulerPboardType = @"NSRulerPboardType";
NSString *NSPostScriptPboardType = @"NSPostScriptPboardType";
NSString *NSTabularTextPboardType = @"NSTabularTextPboardType";
NSString *NSRTFPboardType = @"NSRTFPboardType";
NSString *NSRTFDPboardType = @"NSRTFDPboardType";
NSString *NSTIFFPboardType = @"NSTIFFPboardType";
NSString *NSDataLinkPboardType = @"NSDataLinkPboardType";
NSString *NSGeneralPboardType = @"NSGeneralPboardType";