Added MacOS 10.4 methods for NSDocument, NSDocumentController,

NSPrintOperation, NSResponder and NSCell.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24378 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-01-17 12:09:41 +00:00
parent bc34ad5f62
commit 34b0abf4d0
25 changed files with 1902 additions and 521 deletions

View file

@ -1,3 +1,50 @@
2007-01-17 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSResponder.h: Add MacOS 10.4 methods.
* Source/NSResponder.m: Implement new MacOS 10.4 methods.
* Headers/AppKit/NSDocumentFrameworkPrivate.h: Remove.
* Source/NSDocumentFrameworkPrivate.h: Add.
* Source/GNUmakefile: Don't install NSDocumentFrameworkPrivate.h.
* Headers/AppKit/NSDocument.h: Add MacOS 10.4 methods and
additional ivars. Rename ivars to adopt to coding standards.
* Source/NSDocument.m: Implement new MacOS 10.4 methods adopted
to changes of ivar names.
* Headers/AppKit/NSDocument.h: Add MacOS 10.4 methods and
additional ivars. Rename ivars to adopt to coding standards.
* Source/NSDocument.m: Adopt include of NSDocumentFrameworkPrivate.h.
Implement new MacOS 10.4 methods and adopt to changes of ivar names.
* Headers/AppKit/NSDocumentController.h: Add MacOS 10.4 methods and
additional ivars. Rename ivars to adopt to coding standards. Fix includes.
* Source/NSDocumentController.m: Adopt include of NSDocumentFrameworkPrivate.h.
Implement new MacOS 10.4 methods and adopt to changes of ivar names.
* Headers/AppKit/NSWindowController.h: Rename ivars to adopt to coding standards.
* Source/NSWindowController.m: Adopt include of NSDocumentFrameworkPrivate.h.
Adopt to changes of ivar names.
* Headers/AppKit/NSPrintOperation.h: Add MacOS 10.4 methods and
additional ivars. Rename ivars to adopt to coding standards.
* Source/NSPrintOperation.m: Implement new MacOS 10.4 methods and
adopt to changes of ivar names.
* Source/GSPrintOperation.m,
* Source/GSEPSPrintOperation.m,
* Printing/GSLPR/GSLPRPrintOperation.m,
* Printing/GSCUPS/GSCUPSPrintOperation.m: Adopt to changes in super class.
* Headers/AppKit/NSCell.h: Add MacOS 10.4 methods and
additional ivars. Store the state in two bits only. Rename ivar to
adopt to coding standards. Move mnemonic_location into flags.
* Source/NSCell.m: Implement new MacOS 10.3 and 10.4 methods and
adopt to changes of ivar names. Add encoding and decoding of new
ivars and improve keyed coding and decoding.
* Headers/AppKit/NSColor.h: Adopt values of NSControlTint
enumerator to Cocoa values.
* Headers/AppKit/NSParagraphstyle.h: Add protection against double inclusion.
* Source/GSServicemanager.m,
* Source/NSAttributedString.m,
* Source/NSView.m,
* Source/NSApplication.m: Correct includes to avoid compiler warnings.
2007-01-14 Stefan Bidigaray 2007-01-14 Stefan Bidigaray
* Source/NSWindow.m: * Source/NSWindow.m:

View file

@ -36,8 +36,12 @@
// For tint // For tint
#include <AppKit/NSColor.h> #include <AppKit/NSColor.h>
// for NSWritingDirection
#include <AppKit/NSParagraphStyle.h>
// For text alignment // For text alignment
#include <AppKit/NSText.h> #include <AppKit/NSText.h>
// for NSFocusRingType
#include <AppKit/NSView.h>
@class NSString; @class NSString;
@class NSMutableDictionary; @class NSMutableDictionary;
@ -58,9 +62,9 @@ enum {
NSPositiveIntType, NSPositiveIntType,
NSFloatType, NSFloatType,
NSPositiveFloatType, NSPositiveFloatType,
NSDateType,
NSDoubleType, NSDoubleType,
NSPositiveDoubleType NSPositiveDoubleType,
NSDateType
}; };
typedef enum { typedef enum {
@ -121,7 +125,7 @@ enum {
NSString *_contents; NSString *_contents;
NSImage *_cell_image; NSImage *_cell_image;
NSFont *_font; NSFont *_font;
id _objectValue; id _object_value;
struct GSCellFlagsType { struct GSCellFlagsType {
// total 32 bits. 0 bits left. // total 32 bits. 0 bits left.
unsigned contents_is_attributed_string: 1; unsigned contents_is_attributed_string: 1;
@ -144,30 +148,40 @@ enum {
unsigned type: 2; // 3 values unsigned type: 2; // 3 values
unsigned image_position: 3; // 7 values unsigned image_position: 3; // 7 values
unsigned entry_type: 4; // 8 values unsigned entry_type: 4; // 8 values
unsigned allows_undo: 1;
unsigned line_break_mode: 3; // 6 values
// total 19 bits. 4 bits extension, 9 bits left.
int state: 2; // 3 values but one negative
unsigned mnemonic_location: 8;
unsigned control_tint: 3;
unsigned control_size: 2;
unsigned focus_ring_type: 2; // 3 values
unsigned base_writing_direction: 2; // 3 values
// 4 bits reserved for subclass use // 4 bits reserved for subclass use
unsigned subclass_bool_one: 1; unsigned subclass_bool_one: 1;
unsigned subclass_bool_two: 1; unsigned subclass_bool_two: 1;
unsigned subclass_bool_three: 1; unsigned subclass_bool_three: 1;
unsigned subclass_bool_four: 1; unsigned subclass_bool_four: 1;
/* This is not in the bitfield now (for simpler macosx compatibility)
but who knows in the future */
int state; // 3 values but one negative
} _cell; } _cell;
unsigned char _mnemonic_location;
unsigned int _mouse_down_flags; unsigned int _mouse_down_flags;
unsigned int _action_mask; unsigned int _action_mask;
NSFormatter *_formatter; NSFormatter *_formatter;
NSMenu *_menu; NSMenu *_menu;
id _represented_object; id _represented_object;
void *_reserved1;
} }
// //
// Class methods // Class methods
// //
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
+ (NSFocusRingType)defaultFocusRingType;
#endif
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
+ (NSMenu *)defaultMenu; + (NSMenu *)defaultMenu;
#endif #endif
+ (BOOL) prefersTrackingUntilMouseUp; + (BOOL)prefersTrackingUntilMouseUp;
// //
// Initializing an NSCell // Initializing an NSCell
@ -217,6 +231,10 @@ enum {
- (BOOL)isOpaque; - (BOOL)isOpaque;
- (void)setBezeled:(BOOL)flag; - (void)setBezeled:(BOOL)flag;
- (void)setBordered:(BOOL)flag; - (void)setBordered:(BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (NSFocusRingType)focusRingType;
- (void)setFocusRingType:(NSFocusRingType)type;
#endif
// //
// Setting the NSCell's State // Setting the NSCell's State
@ -254,6 +272,14 @@ enum {
- (void)setTitle:(NSString *)aString; - (void)setTitle:(NSString *)aString;
- (NSString *)title; - (NSString *)title;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (NSWritingDirection)baseWritingDirection;
- (void)setBaseWritingDirection:(NSWritingDirection)direction;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSLineBreakMode)lineBreakMode;
- (void)setLineBreakMode:(NSLineBreakMode)mode;
#endif
// //
// Target and Action // Target and Action
@ -437,6 +463,10 @@ enum {
- (BOOL)sendsActionOnEndEditing; - (BOOL)sendsActionOnEndEditing;
- (void)setSendsActionOnEndEditing:(BOOL)flag; - (void)setSendsActionOnEndEditing:(BOOL)flag;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)allowsUndo;
- (void)setAllowsUndo:(BOOL)flag;
#endif
@end @end

View file

@ -41,9 +41,9 @@
typedef enum _NSControlTint { typedef enum _NSControlTint {
NSDefaultControlTint, NSDefaultControlTint,
NSClearControlTint,
NSBlueControlTint, NSBlueControlTint,
NSGraphiteControlTint NSGraphiteControlTint = 6,
NSClearControlTint
} NSControlTint; } NSControlTint;
typedef enum _NSControlSize { typedef enum _NSControlSize {

View file

@ -7,6 +7,9 @@
Author: Carl Lindberg <Carl.Lindberg@hbo.com> Author: Carl Lindberg <Carl.Lindberg@hbo.com>
Date: 1999 Date: 1999
Modifications: Fred Kiefer <fredkiefer@gmx.de>
Date: Dec 2006
Added MacOS 10.4 methods.
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -41,6 +44,9 @@
@class NSArray; @class NSArray;
@class NSMutableArray; @class NSMutableArray;
@class NSData; @class NSData;
@class NSDate;
@class NSDictionary;
@class NSError;
@class NSFileManager; @class NSFileManager;
@class NSURL; @class NSURL;
@class NSUndoManager; @class NSUndoManager;
@ -50,7 +56,9 @@
@class NSView; @class NSView;
@class NSSavePanel; @class NSSavePanel;
@class NSMenuItem; @class NSMenuItem;
@class NSPageLayout;
@class NSPrintInfo; @class NSPrintInfo;
@class NSPrintOperation;
@class NSPopUpButton; @class NSPopUpButton;
@class NSFileWrapper; @class NSFileWrapper;
@class NSDocumentController; @class NSDocumentController;
@ -60,49 +68,87 @@
typedef enum _NSDocumentChangeType { typedef enum _NSDocumentChangeType {
NSChangeDone = 0, NSChangeDone = 0,
NSChangeUndone = 1, NSChangeUndone = 1,
NSChangeCleared = 2 NSChangeCleared = 2,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
NSChangeReadOtherContents = 3,
NSChangeAutosaved = 4
#endif
} NSDocumentChangeType; } NSDocumentChangeType;
typedef enum _NSSaveOperationType { typedef enum _NSSaveOperationType {
NSSaveOperation = 0, NSSaveOperation = 0,
NSSaveAsOperation = 1, NSSaveAsOperation = 1,
NSSaveToOperation = 2 NSSaveToOperation = 2,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
NSAutosaveOperation = 3
#endif
} NSSaveOperationType; } NSSaveOperationType;
@interface NSDocument : NSObject @interface NSDocument : NSObject
{ {
@private @private
NSWindow *_window; // Outlet for the single window case NSWindow *_window; // Outlet for the single window case
NSMutableArray *_windowControllers; // WindowControllers for this document NSMutableArray *_window_controllers; // WindowControllers for this document
NSString *_fileName; // Save location NSURL *_file_url; // Save location as URL
NSString *_fileType; // file/document type NSString *_file_name; // Save location
NSPrintInfo *_printInfo; // print info record NSString *_file_type; // file/document type
long _changeCount; // number of time the document has been changed NSDate *_file_modification_date;// file modification date
NSView *savePanelAccessory; // outlet for the accessory save-panel view NSString *_last_component_file_name; // file name last component
NSPopUpButton *spaButton; // outlet for "the File Format:" button in the save panel. NSURL *_autosaved_file_url; // Autosave location as URL
int _documentIndex; // Untitled index NSPrintInfo *_print_info; // print info record
NSUndoManager *_undoManager; // Undo manager for this document NSView *_save_panel_accessory; // outlet for the accessory save-panel view
NSString *_saveType; // the currently selected extension. NSPopUpButton *_spa_button; // outlet for "the File Format:" button in the save panel.
NSString *_save_type; // the currently selected extension.
NSUndoManager *_undo_manager; // Undo manager for this document
long _change_count; // number of time the document has been changed
long _autosave_change_count; // number of time the document has been changed since the last autosave
int _document_index; // Untitled index
struct __docFlags { struct __docFlags {
unsigned int inClose:1; unsigned int in_close:1;
unsigned int hasUndoManager:1; unsigned int has_undo_manager:1;
unsigned int RESERVED:30; unsigned int RESERVED:30;
} _docFlags; } _doc_flags;
void *_reserved1; void *_reserved1;
} }
+ (NSArray *)readableTypes;
+ (NSArray *)writableTypes;
+ (BOOL)isNativeType:(NSString *)type;
/*" Initialization "*/ /*" Initialization "*/
- (id)init; - (id)init;
- (id)initWithContentsOfFile:(NSString *)fileName ofType:(NSString *)fileType; - (id)initWithContentsOfFile:(NSString *)fileName ofType:(NSString *)fileType;
- (id)initWithContentsOfURL:(NSURL *)url ofType:(NSString *)fileType; - (id)initWithContentsOfURL:(NSURL *)url ofType:(NSString *)fileType;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (id)initForURL:(NSURL *)forUrl
withContentsOfURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)error;
- (id)initWithContentsOfURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)error;
- (id)initWithType:(NSString *)type
error:(NSError **)error;
#endif
/*" Window management "*/ /*" Window management "*/
- (NSArray *)windowControllers; - (NSArray *)windowControllers;
- (void)addWindowController:(NSWindowController *)windowController; - (void)addWindowController:(NSWindowController *)windowController;
#if OS_API_VERSION(GS_API_MACOSX, MAC_OS_X_VERSION_10_4)
- (BOOL)shouldCloseWindowController:(NSWindowController *)windowController; - (BOOL)shouldCloseWindowController:(NSWindowController *)windowController;
#endif
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void)shouldCloseWindowController:(NSWindowController *)windowController
delegate:(id)delegate
shouldCloseSelector:(SEL)callback
contextInfo:(void *)contextInfo;
#endif
- (void)showWindows; - (void)showWindows;
- (void)removeWindowController:(NSWindowController *)windowController; - (void)removeWindowController:(NSWindowController *)windowController;
- (void)setWindow:(NSWindow *)aWindow; - (void)setWindow:(NSWindow *)aWindow;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSWindow *)windowForSheet;
#endif
/*" Window controller creation "*/ /*" Window controller creation "*/
- (void)makeWindowControllers; // Manual creation - (void)makeWindowControllers; // Manual creation
@ -125,16 +171,28 @@ typedef enum _NSSaveOperationType {
/*" Closing "*/ /*" Closing "*/
- (void)close; - (void)close;
#if OS_API_VERSION(GS_API_MACOSX, MAC_OS_X_VERSION_10_4)
- (BOOL)canCloseDocument; - (BOOL)canCloseDocument;
#endif
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void)canCloseDocumentWithDelegate:(id)delegate
shouldCloseSelector:(SEL)shouldCloseSelector
contextInfo:(void *)contextInfo;
#endif
/*" Type and location "*/ /*" Type and location "*/
- (NSString *)fileName; - (NSString *)fileName;
- (void)setFileName:(NSString *)fileName; - (void)setFileName:(NSString *)fileName;
- (NSString *)fileType; - (NSString *)fileType;
- (void)setFileType:(NSString *)type; - (void)setFileType:(NSString *)type;
+ (NSArray *)readableTypes; #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
+ (NSArray *)writableTypes; - (NSURL *)fileURL;
+ (BOOL)isNativeType:(NSString *)type; - (void)setFileURL:(NSURL *)url;
- (NSDate *)fileModificationDate;
- (void)setFileModificationDate: (NSDate *)date;
- (NSString *)lastComponentOfFileName;
- (void)setLastComponentOfFileName:(NSString *)str;
#endif
/*" Read/Write/Revert "*/ /*" Read/Write/Revert "*/
@ -152,11 +210,43 @@ typedef enum _NSSaveOperationType {
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type; - (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)type;
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type; - (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type;
- (BOOL)revertToSavedFromURL:(NSURL *)url ofType:(NSString *)type; - (BOOL)revertToSavedFromURL:(NSURL *)url ofType:(NSString *)type;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSData *)dataOfType:(NSString *)type
error:(NSError **)error;
- (NSFileWrapper *)fileWrapperOfType:(NSString *)type
error:(NSError **)error;
- (BOOL)readFromData:(NSData *)data
ofType:(NSString *)type
error:(NSError **)error;
- (BOOL)readFromFileWrapper:(NSFileWrapper *)wrapper
ofType:(NSString *)type
error:(NSError **)error;
- (BOOL)readFromURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)error;
- (BOOL)revertToContentsOfURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)error;
- (BOOL)writeSafelyToURL:(NSURL *)url
ofType:(NSString *)type
forSaveOperation:(NSSaveOperationType)op
error:(NSError **)error;
- (BOOL)writeToURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)error;
- (BOOL)writeToURL:(NSURL *)url
ofType:(NSString *)type
forSaveOperation:(NSSaveOperationType)op
originalContentsURL:(NSURL *)orig
error:(NSError **)error;
#endif
/*" Save panel "*/ /*" Save panel "*/
- (BOOL)shouldRunSavePanelWithAccessoryView; - (BOOL)shouldRunSavePanelWithAccessoryView;
#if OS_API_VERSION(GS_API_MACOSX, MAC_OS_X_VERSION_10_4)
- (NSString *)fileNameFromRunningSavePanelForSaveOperation:(NSSaveOperationType)saveOperation; - (NSString *)fileNameFromRunningSavePanelForSaveOperation:(NSSaveOperationType)saveOperation;
- (int)runModalSavePanel:(NSSavePanel *)savePanel withAccessoryView:(NSView *)accessoryView; - (int)runModalSavePanel:(NSSavePanel *)savePanel withAccessoryView:(NSView *)accessoryView;
#endif
- (NSString *)fileTypeFromLastRunSavePanel; - (NSString *)fileTypeFromLastRunSavePanel;
- (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath - (NSDictionary *)fileAttributesToWriteToFile: (NSString *)fullDocumentPath
ofType: (NSString *)docType ofType: (NSString *)docType
@ -168,6 +258,15 @@ typedef enum _NSSaveOperationType {
- (BOOL)writeWithBackupToFile:(NSString *)fileName - (BOOL)writeWithBackupToFile:(NSString *)fileName
ofType:(NSString *)fileType ofType:(NSString *)fileType
saveOperation:(NSSaveOperationType)saveOp; saveOperation:(NSSaveOperationType)saveOp;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSArray *)writableTypesForSaveOperation:(NSSaveOperationType)op;
- (NSDictionary *)fileAttributesToWriteToURL:(NSURL *)url
ofType:(NSString *)type
forSaveOperation:(NSSaveOperationType)op
originalContentsURL:(NSURL *)original
error:(NSError **)error;
- (BOOL)fileNameExtensionWasHiddenInLastRunSavePanel;
#endif
/*" Printing "*/ /*" Printing "*/
- (NSPrintInfo *)printInfo; - (NSPrintInfo *)printInfo;
@ -177,6 +276,24 @@ typedef enum _NSSaveOperationType {
- (int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo; - (int)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)printInfo;
- (IBAction)printDocument:(id)sender; - (IBAction)printDocument:(id)sender;
- (void)printShowingPrintPanel:(BOOL)flag; - (void)printShowingPrintPanel:(BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)preparePageLayout:(NSPageLayout *)pageLayout;
- (void)runModalPageLayoutWithPrintInfo:(NSPrintInfo *)info
delegate:(id)delegate
didRunSelector:(SEL)sel
contextInfo:(void *)context;
- (void)printDocumentWithSettings:(NSDictionary *)settings
showPrintPanel:(BOOL)flag
delegate:(id)delegate
didPrintSelector:(SEL)sel
contextInfo:(void *)context;
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)settings
error:(NSError **)error;
- (void)runModalPrintOperation:(NSPrintOperation *)op
delegate:(id)delegate
didRunSelector:(SEL)sel
contextInfo:(void *)context;
#endif
/*" IB Actions "*/ /*" IB Actions "*/
- (IBAction)saveDocument:(id)sender; - (IBAction)saveDocument:(id)sender;
@ -195,13 +312,6 @@ typedef enum _NSSaveOperationType {
- (void)setHasUndoManager:(BOOL)flag; - (void)setHasUndoManager:(BOOL)flag;
/* NEW delegate operations*/ /* NEW delegate operations*/
- (void)shouldCloseWindowController:(NSWindowController *)windowController
delegate:(id)delegate
shouldCloseSelector:(SEL)callback
contextInfo:(void *)contextInfo;
- (void)canCloseDocumentWithDelegate:(id)delegate
shouldCloseSelector:(SEL)shouldCloseSelector
contextInfo:(void *)contextInfo;
- (void)saveToFile:(NSString *)fileName - (void)saveToFile:(NSString *)fileName
saveOperation:(NSSaveOperationType)saveOperation saveOperation:(NSSaveOperationType)saveOperation
delegate:(id)delegate delegate:(id)delegate
@ -216,6 +326,36 @@ typedef enum _NSSaveOperationType {
didSaveSelector:(SEL)didSaveSelector didSaveSelector:(SEL)didSaveSelector
contextInfo:(void *)contextInfo; contextInfo:(void *)contextInfo;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)saveToURL:(NSURL *)url
ofType:(NSString *)type
forSaveOperation:(NSSaveOperationType)op
error:(NSError **)error;
- (BOOL)saveToURL:(NSURL *)url
ofType:(NSString *)type
forSaveOperation:(NSSaveOperationType)op
delegate:(id)delegate
didSaveSelector:(SEL)didSaveSelector
contextInfo:(void *)contextInfo;
/* Autosaving */
- (NSURL *)autosavedContentsFileURL;
- (void)setAutosavedContentsFileURL:(NSURL *)url;
- (void)autosaveDocumentWithDelegate:(id)delegate
didAutosaveSelector:(SEL)didAutosaveSelector
contextInfo:(void *)context;
- (NSString *)autosavingFileType;
- (BOOL)hasUnautosavedChanges;
- (BOOL)presentError:(NSError *)error;
- (void)presentError:(NSError *)error
modalForWindow:(NSWindow *)window
delegate:(id)delegate
didPresentSelector:(SEL)sel
contextInfo:(void *)context;
- (NSError *)willPresentError:(NSError *)error;
#endif
@end @end
#endif // _GNUstep_H_NSDocument #endif // _GNUstep_H_NSDocument

View file

@ -32,27 +32,33 @@
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
#include <Foundation/Foundation.h> #include <Foundation/NSObject.h>
#include <AppKit/NSNibDeclarations.h> #include <AppKit/NSNibDeclarations.h>
#include <AppKit/NSUserInterfaceValidation.h> #include <AppKit/NSUserInterfaceValidation.h>
@class NSArray, NSMutableArray; @class NSArray;
@class NSError;
@class NSMutableArray;
@class NSURL; @class NSURL;
@class NSMenuItem, NSOpenPanel, NSWindow; @class NSString;
@class NSDocument; @class NSDocument;
@class NSMenuItem;
@class NSOpenPanel;
@class NSWindow;
@interface NSDocumentController : NSObject @interface NSDocumentController : NSObject
{ {
@private @private
NSMutableArray *_documents; NSMutableArray *_documents;
NSMutableArray *_recentDocuments; NSMutableArray *_recent_documents;
struct __controllerFlags {
unsigned int shouldCreateUI:1;
unsigned int RESERVED:31;
} _controllerFlags;
NSArray *_types; // from info.plist with key NSTypes NSArray *_types; // from info.plist with key NSTypes
NSTimeInterval _autosavingDelay;
struct __controller_flags {
unsigned int should_create_ui:1;
unsigned int RESERVED:31;
} _controller_flags;
void *_reserved1; void *_reserved1;
void *_reserved2;
} }
+ (id)sharedDocumentController; + (id)sharedDocumentController;
@ -67,6 +73,32 @@
- (id)makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type; - (id)makeDocumentWithContentsOfURL:(NSURL *)url ofType:(NSString *)type;
- (id)openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display; - (id)openDocumentWithContentsOfURL:(NSURL *)url display:(BOOL)display;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (id)makeDocumentForURL:(NSURL *)url
withContentsOfURL:(NSURL *)contents
ofType:(NSString *)type
error:(NSError **)err;
- (id)makeDocumentWithContentsOfURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)err;
- (id)makeUntitledDocumentOfType:(NSString *)type
error:(NSError **)err;
- (id)openDocumentWithContentsOfURL:(NSURL *) url
display:(BOOL) flag
error:(NSError **) err;
- (id)openUntitledDocumentAndDisplay:(BOOL)flag
error:(NSError **)err;
- (BOOL)reopenDocumentForURL:(NSURL *)url
withContentsOfURL:(NSURL *)contents
error:(NSError **)err;
- (BOOL)presentError:(NSError *)err;
- (void)presentError:(NSError *)err
modalForWindow:(NSWindow *)win
delegate:(id)delegate
didPresentSelector:(SEL)sel
contextInfo:(void *)context;
- (NSError *)willPresentError:(NSError *)err;
#endif
/*" With or without UI "*/ /*" With or without UI "*/
- (BOOL)shouldCreateUI; - (BOOL)shouldCreateUI;
@ -107,6 +139,9 @@
- (NSString *)currentDirectory; - (NSString *)currentDirectory;
- (id)documentForWindow:(NSWindow *)window; - (id)documentForWindow:(NSWindow *)window;
- (id)documentForFileName:(NSString *)fileName; - (id)documentForFileName:(NSString *)fileName;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (id)documentForURL:(NSURL *)url;
#endif
/*" Menu validation "*/ /*" Menu validation "*/
@ -118,10 +153,20 @@
- (NSString *)typeFromFileExtension:(NSString *)fileExtension; - (NSString *)typeFromFileExtension:(NSString *)fileExtension;
- (NSArray *)fileExtensionsFromType:(NSString *)type; - (NSArray *)fileExtensionsFromType:(NSString *)type;
- (Class)documentClassForType:(NSString *)type; - (Class)documentClassForType:(NSString *)type;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSString *)defaultType;
- (NSArray *)documentClassNames;
- (NSString *)typeForContentsOfURL:(NSURL *)url error:(NSError **)err;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
/* Autosaving */
- (NSTimeInterval)autosavingDelay;
- (void)setAutosavingDelay:(NSTimeInterval)autosavingDelay;
#endif
@end @end
#endif // GS_API_MACOSX #endif // GS_API_MACOSX
#endif // _GNUstep_H_NSDocumentController #endif // _GNUstep_H_NSDocumentController

View file

@ -1,5 +1,4 @@
/* /*
#import <GNUstepBase/GSVersionMacros.h>
NSParagraphStyle.h NSParagraphStyle.h
NSParagraphStyle and NSMutableParagraphStyle hold paragraph style NSParagraphStyle and NSMutableParagraphStyle hold paragraph style
@ -7,7 +6,7 @@
Copyright (C) 1996,1999 Free Software Foundation, Inc. Copyright (C) 1996,1999 Free Software Foundation, Inc.
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de> Author: Daniel Böhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998 Date: August 1998
Update: Richard Frith-Macdonald <richard@brainstorm.co.uk> March 1999 Update: Richard Frith-Macdonald <richard@brainstorm.co.uk> March 1999
@ -29,6 +28,9 @@
51 Franklin Street, Fifth Floor, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#ifndef _GNUstep_H_NSParagraphStyle
#define _GNUstep_H_NSParagraphStyle
#import <GNUstepBase/GSVersionMacros.h>
#include <AppKit/NSText.h> #include <AppKit/NSText.h>
@ -135,7 +137,7 @@ typedef enum _NSWritingDirection {
- (float) maximumLineHeight; - (float) maximumLineHeight;
- (NSLineBreakMode) lineBreakMode; - (NSLineBreakMode) lineBreakMode;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
/* /*
* Returns the writing direction of "language", which is an ISO 639 * Returns the writing direction of "language", which is an ISO 639
* two- or three letter code, e.g. "en", or an ISO language-region * two- or three letter code, e.g. "en", or an ISO language-region
@ -165,7 +167,9 @@ typedef enum _NSWritingDirection {
- (void) setTabStops: (NSArray*)array; - (void) setTabStops: (NSArray*)array;
- (void) setParagraphStyle: (NSParagraphStyle*)obj; - (void) setParagraphStyle: (NSParagraphStyle*)obj;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (void) setBaseWritingDirection: (NSWritingDirection)direction; - (void) setBaseWritingDirection: (NSWritingDirection)direction;
#endif #endif
@end @end
#endif // _GNUstep_H_NSParagraphStyle

View file

@ -61,17 +61,22 @@ typedef enum _NSPrintingPageOrder {
@interface NSPrintOperation : NSObject @interface NSPrintOperation : NSObject
{ {
// Attributes // Attributes
NSPrintInfo *_printInfo; NSPrintInfo *_print_info;
NSView *_view; NSView *_view;
NSRect _rect; NSRect _rect;
NSMutableData *_data; NSMutableData *_data;
NSString *_path; NSString *_path;
NSGraphicsContext *_context; NSGraphicsContext *_context;
NSPrintPanel *_printPanel; NSPrintPanel *_print_panel;
NSView *_accessoryView; NSView *_accessory_view;
NSPrintingPageOrder _pageOrder; NSString *_job_style_hint;
BOOL _showPanels; NSPrintingPageOrder _page_order;
//BOOL _pathSet; removed, just test _path for nil struct __Flags {
unsigned int show_print_panel:1;
unsigned int show_progress_panel:1;
unsigned int can_spawn_separate_thread:1;
unsigned int RESERVED:29;
} _flags;
int _currentPage; int _currentPage;
} }
@ -137,6 +142,12 @@ typedef enum _NSPrintingPageOrder {
- (BOOL)showPanels; - (BOOL)showPanels;
- (void)setPrintPanel:(NSPrintPanel *)panel; - (void)setPrintPanel:(NSPrintPanel *)panel;
- (void)setShowPanels:(BOOL)flag; - (void)setShowPanels:(BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)showsPrintPanel;
- (void)setShowsPrintPanel:(BOOL)flag;
- (BOOL)showsProgressPanel;
- (void)setShowsProgressPanel:(BOOL)flag;
#endif
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (NSView *)accessoryView; - (NSView *)accessoryView;
@ -164,10 +175,16 @@ typedef enum _NSPrintingPageOrder {
- (BOOL)deliverResult; - (BOOL)deliverResult;
- (BOOL)runOperation; - (BOOL)runOperation;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void)runOperationModalForWindow: (NSWindow *)docWindow - (void)runOperationModalForWindow:(NSWindow *)docWindow
delegate: (id)delegate delegate:(id)delegate
didRunSelector: (SEL)didRunSelector didRunSelector:(SEL)didRunSelector
contextInfo:(void *)contextInfo; contextInfo:(void *)contextInfo;
- (BOOL)canSpawnSeparateThread;
- (void)setCanSpawnSeparateThread:(BOOL)flag;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (NSString *) jobStyleHint;
- (void)setJobStyleHint:(NSString *)hint;
#endif #endif
// //

View file

@ -36,10 +36,13 @@
#include <AppKit/AppKitDefines.h> #include <AppKit/AppKitDefines.h>
@class NSCoder; @class NSCoder;
@class NSError;
@class NSString; @class NSString;
@class NSEvent; @class NSEvent;
@class NSMenu; @class NSMenu;
@class NSUndoManager; @class NSUndoManager;
@class NSWindow;
@interface NSResponder : NSObject <NSCoding> @interface NSResponder : NSObject <NSCoding>
{ {
@ -128,7 +131,9 @@
- (void) rightMouseDown: (NSEvent*)theEvent; - (void) rightMouseDown: (NSEvent*)theEvent;
- (void) rightMouseDragged: (NSEvent*)theEvent; - (void) rightMouseDragged: (NSEvent*)theEvent;
- (void) rightMouseUp: (NSEvent*)theEvent; - (void) rightMouseUp: (NSEvent*)theEvent;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (void) scrollWheel: (NSEvent *)theEvent; - (void) scrollWheel: (NSEvent *)theEvent;
#endif
/* /*
* Services menu support * Services menu support
@ -175,6 +180,17 @@
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent; - (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL)presentError:(NSError *)error;
- (void)presentError:(NSError *)error
modalForWindow:(NSWindow *)window
delegate:(id)delegate
didPresentSelector:(SEL)sel
contextInfo:(void *)context;
- (NSError *)willPresentError:(NSError *)error;
#endif
@end @end
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
@ -231,6 +247,7 @@
- (void) selectParagraph: (id)sender; - (void) selectParagraph: (id)sender;
- (void) selectToMark: (id)sender; - (void) selectToMark: (id)sender;
- (void) selectWord: (id)sender; - (void) selectWord: (id)sender;
- (void) setMark: (id)sender;
- (void) showContextHelp: (id)sender; - (void) showContextHelp: (id)sender;
- (void) swapWithMark: (id)sender; - (void) swapWithMark: (id)sender;
- (void) transpose: (id)sender; - (void) transpose: (id)sender;
@ -238,11 +255,22 @@
- (void) uppercaseWord: (id)sender; - (void) uppercaseWord: (id)sender;
- (void) yank: (id)sender; - (void) yank: (id)sender;
// New in MacOSX 10.3 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void) cancelOperation: (id)sender; - (void) cancelOperation: (id)sender;
- (void) deleteBackwardByDecomposingPreviousCharacter: (id)sender; - (void) deleteBackwardByDecomposingPreviousCharacter: (id)sender;
- (void) moveLeftAndModifySelection: (id)sender; - (void) moveLeftAndModifySelection: (id)sender;
- (void) moveRightAndModifySelection: (id)sender; - (void) moveRightAndModifySelection: (id)sender;
- (void) moveWordLeft: (id)sender;
- (void) moveWordLeftAndModifySelection: (id)sender;
- (void) moveWordRight: (id)sender;
- (void) moveWordRightAndModifySelection: (id)sender;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (void) insertContainerBreak: (id)sender;
- (void) insertLineBreak: (id)sender;
- (void) tabletPoint:(NSEvent *)event;
- (void) tabletProximity:(NSEvent *)event;
#endif
@end @end
#endif #endif

View file

@ -38,17 +38,17 @@
{ {
@private @private
NSWindow *_window; NSWindow *_window;
NSString *_windowNibName; NSString *_window_nib_name;
NSString *_windowNibPath; NSString *_window_nib_path;
NSString *_windowFrameAutosaveName; NSString *_window_frame_autosave_name;
NSDocument *_document; NSDocument *_document;
NSArray *_topLevelObjects; NSArray *_top_level_objects;
id _owner; id _owner;
struct ___wcFlags struct ___wcFlags
{ {
unsigned int shouldCloseDocument:1; unsigned int should_close_document:1;
unsigned int shouldCascade:1; unsigned int should_cascade:1;
unsigned int nibIsLoaded:1; unsigned int nib_is_loaded:1;
unsigned int RESERVED:29; unsigned int RESERVED:29;
} _wcFlags; } _wcFlags;
void *_reserved1; void *_reserved1;

View file

@ -97,9 +97,9 @@
//NSMutableArray *args; //NSMutableArray *args;
NSDebugMLLog(@"GSPrinting", @""); NSDebugMLLog(@"GSPrinting", @"");
name = [[_printInfo printer] name]; name = [[[self printInfo] printer] name];
status = [NSString stringWithFormat: @"Spooling to printer %@.", name]; status = [NSString stringWithFormat: @"Spooling to printer %@.", name];
[_printPanel _setStatusStringValue: status]; [[self printPanel] _setStatusStringValue: status];
cupsPrintFile( [name UTF8String], cupsPrintFile( [name UTF8String],
[_path UTF8String], [_path UTF8String],
@ -107,7 +107,7 @@
0, NULL ); 0, NULL );
//dict = [_printInfo dictionary]; //dict = [[self printInfo] dictionary];
//args = [NSMutableArray array]; //args = [NSMutableArray array];
//copies = [[dict objectForKey: NSPrintCopies] intValue]; //copies = [[dict objectForKey: NSPrintCopies] intValue];
//if (copies > 1) //if (copies > 1)
@ -141,7 +141,7 @@
} }
NSDebugMLLog(@"GSPrinting", @"Creating context."); NSDebugMLLog(@"GSPrinting", @"Creating context.");
info = [_printInfo dictionary]; info = [[self printInfo] dictionary];
output = [info objectForKey: NSPrintSavePath]; output = [info objectForKey: NSPrintSavePath];
if (output) if (output)

View file

@ -102,11 +102,11 @@
NSMutableArray *args; NSMutableArray *args;
NSDebugMLLog(@"GSPrinting", @""); NSDebugMLLog(@"GSPrinting", @"");
name = [[_printInfo printer] name]; name = [[[self printInfo] printer] name];
status = [NSString stringWithFormat: @"Spooling to printer %@.", name]; status = [NSString stringWithFormat: @"Spooling to printer %@.", name];
[_printPanel _setStatusStringValue: status]; [[self printPanel] _setStatusStringValue: status];
dict = [_printInfo dictionary]; dict = [[self printInfo] dictionary];
args = [NSMutableArray array]; args = [NSMutableArray array];
copies = [[dict objectForKey: NSPrintCopies] intValue]; copies = [[dict objectForKey: NSPrintCopies] intValue];
if (copies > 1) if (copies > 1)
@ -140,7 +140,7 @@
} }
NSDebugMLLog(@"GSPrinting", @"Creating context."); NSDebugMLLog(@"GSPrinting", @"Creating context.");
info = [_printInfo dictionary]; info = [[self printInfo] dictionary];
output = [info objectForKey: NSPrintSavePath]; output = [info objectForKey: NSPrintSavePath];
if (output) if (output)

View file

@ -347,7 +347,6 @@ NSWindow+Toolbar.h \
NSWorkspace.h \ NSWorkspace.h \
NSAttributedString.h \ NSAttributedString.h \
NSColorPicking.h \ NSColorPicking.h \
NSDocumentFrameworkPrivate.h \
NSDragging.h \ NSDragging.h \
NSGraphics.h \ NSGraphics.h \
NSNibConnector.h \ NSNibConnector.h \

View file

@ -98,8 +98,8 @@
{ {
/* Save this for the view to look at. Seems like there should /* Save this for the view to look at. Seems like there should
be a better way to pass it to beginDocument */ be a better way to pass it to beginDocument */
[[_printInfo dictionary] setObject: [NSValue valueWithRect: _rect] [[[self printInfo] dictionary] setObject: [NSValue valueWithRect: _rect]
forKey: @"NSPrintSheetBounds"]; forKey: @"NSPrintSheetBounds"];
[_view beginDocument]; [_view beginDocument];
@ -136,7 +136,7 @@
if (_context) if (_context)
return _context; return _context;
info = [_printInfo dictionary]; info = [[self printInfo] dictionary];
[info setObject: _path [info setObject: _path
forKey: @"NSOutputFile"]; forKey: @"NSOutputFile"];

View file

@ -88,7 +88,7 @@
toData: [NSMutableData data] toData: [NSMutableData data]
printInfo: aPrintInfo]; printInfo: aPrintInfo];
_showPanels = YES; [self setShowPanels: YES];
return self; return self;
} }
@ -116,7 +116,7 @@
NSString *job; NSString *job;
success = YES; success = YES;
job = [_printInfo jobDisposition]; job = [[self printInfo] jobDisposition];
if ([job isEqual: NSPrintPreviewJob]) if ([job isEqual: NSPrintPreviewJob])
{ {
/* Check to see if there is a GNUstep app that can preview PS files. /* Check to see if there is a GNUstep app that can preview PS files.
@ -126,7 +126,7 @@
NSTask *task; NSTask *task;
NSString *preview; NSString *preview;
NSWorkspace *ws = [NSWorkspace sharedWorkspace]; NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[_printPanel _setStatusStringValue: @"Opening in previewer..."]; [[self printPanel] _setStatusStringValue: @"Opening in previewer..."];
preview = [ws getBestAppInRole: @"Viewer" preview = [ws getBestAppInRole: @"Viewer"
forExtension: @"ps"]; forExtension: @"ps"];

View file

@ -43,6 +43,7 @@
#include <Foundation/NSPathUtilities.h> #include <Foundation/NSPathUtilities.h>
#include <Foundation/NSUserDefaults.h> #include <Foundation/NSUserDefaults.h>
#include <Foundation/NSSerialization.h> #include <Foundation/NSSerialization.h>
#include <Foundation/NSPort.h>
#include <Foundation/NSPortNameServer.h> #include <Foundation/NSPortNameServer.h>
#include <Foundation/NSTask.h> #include <Foundation/NSTask.h>
#include <Foundation/NSObjCRuntime.h> #include <Foundation/NSObjCRuntime.h>

View file

@ -33,18 +33,24 @@
#include <stdio.h> #include <stdio.h>
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSSet.h> #include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSDictionary.h> #include <Foundation/NSDictionary.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSObject.h> #include <Foundation/NSObject.h>
#include <Foundation/NSRunLoop.h> #include <Foundation/NSPathUtilities.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSTimer.h>
#include <Foundation/NSProcessInfo.h> #include <Foundation/NSProcessInfo.h>
#include <Foundation/NSFileManager.h> #include <Foundation/NSRunLoop.h>
#include <Foundation/NSSet.h>
#include <Foundation/NSString.h>
#include <Foundation/NSTimer.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSUserDefaults.h> #include <Foundation/NSUserDefaults.h>
#include <Foundation/NSBundle.h> #include <Foundation/NSValue.h>
#ifndef LIB_FOUNDATION_LIBRARY #ifndef LIB_FOUNDATION_LIBRARY
# include <Foundation/NSConnection.h> # include <Foundation/NSConnection.h>
@ -52,20 +58,20 @@
#include "AppKit/AppKitExceptions.h" #include "AppKit/AppKitExceptions.h"
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSCell.h"
#include "AppKit/NSCursor.h"
#include "AppKit/NSDocumentController.h" #include "AppKit/NSDocumentController.h"
#include "AppKit/NSPasteboard.h"
#include "AppKit/NSFontManager.h"
#include "AppKit/NSPanel.h"
#include "AppKit/NSEvent.h" #include "AppKit/NSEvent.h"
#include "AppKit/NSFontManager.h"
#include "AppKit/NSImage.h" #include "AppKit/NSImage.h"
#include "AppKit/NSMenu.h" #include "AppKit/NSMenu.h"
#include "AppKit/NSMenuItem.h" #include "AppKit/NSMenuItem.h"
#include "AppKit/NSMenuItemCell.h"
#include "AppKit/NSMenuView.h"
#include "AppKit/NSCursor.h"
#include "AppKit/NSWorkspace.h"
#include "AppKit/NSNibLoading.h" #include "AppKit/NSNibLoading.h"
#include "AppKit/NSPageLayout.h" #include "AppKit/NSPageLayout.h"
#include "AppKit/NSPanel.h"
#include "AppKit/NSPasteboard.h"
#include "AppKit/NSWorkspace.h"
#include "AppKit/NSScreen.h"
#include "AppKit/PSOperators.h" #include "AppKit/PSOperators.h"
#include "GNUstepGUI/GSDisplayServer.h" #include "GNUstepGUI/GSDisplayServer.h"

View file

@ -28,10 +28,16 @@
*/ */
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSString.h>
#include <Foundation/NSRange.h>
#include <Foundation/NSBundle.h> #include <Foundation/NSBundle.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSException.h>
#include <Foundation/NSFileManager.h> #include <Foundation/NSFileManager.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSRange.h>
#include <Foundation/NSString.h>
#include <Foundation/NSValue.h>
#include "AppKit/NSAttributedString.h" #include "AppKit/NSAttributedString.h"
#include "AppKit/NSDocumentController.h" #include "AppKit/NSDocumentController.h"
#include "AppKit/NSParagraphStyle.h" #include "AppKit/NSParagraphStyle.h"

View file

@ -99,7 +99,7 @@ static NSColor *shadowCol;
{ {
if (self == [NSCell class]) if (self == [NSCell class])
{ {
[self setVersion: 1]; [self setVersion: 2];
colorClass = [NSColor class]; colorClass = [NSColor class];
cellClass = [NSCell class]; cellClass = [NSCell class];
fontClass = [NSFont class]; fontClass = [NSFont class];
@ -117,11 +117,16 @@ static NSColor *shadowCol;
} }
} }
+ (NSMenu*)defaultMenu + (NSMenu*) defaultMenu
{ {
return nil; return nil;
} }
+ (NSFocusRingType) defaultFocusRingType
{
return NSFocusRingTypeDefault;
}
/**<p>This class method returns NO. This method should be overrided by /**<p>This class method returns NO. This method should be overrided by
subclasses.</p> subclasses.</p>
*/ */
@ -170,6 +175,7 @@ static NSColor *shadowCol;
//_cell.state = 0; //_cell.state = 0;
_action_mask = NSLeftMouseUpMask; _action_mask = NSLeftMouseUpMask;
_menu = [isa defaultMenu]; _menu = [isa defaultMenu];
[self setFocusRingType: [isa defaultFocusRingType]];
return self; return self;
} }
@ -199,6 +205,7 @@ static NSColor *shadowCol;
//_cell.is_selectable = NO; //_cell.is_selectable = NO;
_action_mask = NSLeftMouseUpMask; _action_mask = NSLeftMouseUpMask;
_menu = [isa defaultMenu]; _menu = [isa defaultMenu];
[self setFocusRingType: [isa defaultFocusRingType]];
return self; return self;
} }
@ -209,7 +216,7 @@ static NSColor *shadowCol;
TEST_RELEASE (_cell_image); TEST_RELEASE (_cell_image);
TEST_RELEASE (_font); TEST_RELEASE (_font);
TEST_RELEASE (_represented_object); TEST_RELEASE (_represented_object);
TEST_RELEASE (_objectValue); TEST_RELEASE (_object_value);
TEST_RELEASE (_formatter); TEST_RELEASE (_formatter);
TEST_RELEASE (_menu); TEST_RELEASE (_menu);
@ -223,7 +230,7 @@ static NSColor *shadowCol;
{ {
if (_cell.has_valid_object_value) if (_cell.has_valid_object_value)
{ {
return _objectValue; return _object_value;
} }
else else
{ {
@ -242,9 +249,9 @@ static NSColor *shadowCol;
- (double) doubleValue - (double) doubleValue
{ {
if ((_cell.has_valid_object_value == YES) && if ((_cell.has_valid_object_value == YES) &&
([_objectValue respondsToSelector: @selector(doubleValue)])) ([_object_value respondsToSelector: @selector(doubleValue)]))
{ {
return [_objectValue doubleValue]; return [_object_value doubleValue];
} }
else else
{ {
@ -258,9 +265,9 @@ static NSColor *shadowCol;
- (float) floatValue - (float) floatValue
{ {
if ((_cell.has_valid_object_value == YES) && if ((_cell.has_valid_object_value == YES) &&
([_objectValue respondsToSelector: @selector(floatValue)])) ([_object_value respondsToSelector: @selector(floatValue)]))
{ {
return [_objectValue floatValue]; return [_object_value floatValue];
} }
else else
{ {
@ -274,9 +281,9 @@ static NSColor *shadowCol;
- (int) intValue - (int) intValue
{ {
if ((_cell.has_valid_object_value == YES) && if ((_cell.has_valid_object_value == YES) &&
([_objectValue respondsToSelector: @selector(intValue)])) ([_object_value respondsToSelector: @selector(intValue)]))
{ {
return [_objectValue intValue]; return [_object_value intValue];
} }
else else
{ {
@ -291,7 +298,7 @@ static NSColor *shadowCol;
{ {
if (_cell.contents_is_attributed_string == NO) if (_cell.contents_is_attributed_string == NO)
{ {
// If we have a formatter this is also the string of the _objectValue // If we have a formatter this is also the string of the _object_value
return _contents; return _contents;
} }
else else
@ -304,7 +311,7 @@ static NSColor *shadowCol;
{ {
id newContents; id newContents;
ASSIGN (_objectValue, object); ASSIGN (_object_value, object);
if (_formatter == nil) if (_formatter == nil)
{ {
@ -322,14 +329,14 @@ static NSColor *shadowCol;
} }
else else
{ {
newContents = [_objectValue description]; newContents = [_object_value description];
_cell.contents_is_attributed_string = NO; _cell.contents_is_attributed_string = NO;
_cell.has_valid_object_value = YES; _cell.has_valid_object_value = YES;
} }
} }
else else
{ {
newContents = [_formatter stringForObjectValue: _objectValue]; newContents = [_formatter stringForObjectValue: _object_value];
_cell.contents_is_attributed_string = NO; _cell.contents_is_attributed_string = NO;
if (newContents != nil) if (newContents != nil)
{ {
@ -414,7 +421,7 @@ static NSColor *shadowCol;
if (_formatter == nil) if (_formatter == nil)
{ {
ASSIGN (_contents, string); ASSIGN (_contents, string);
ASSIGN (_objectValue, string); ASSIGN (_object_value, string);
_cell.has_valid_object_value = YES; _cell.has_valid_object_value = YES;
} }
else else
@ -708,6 +715,16 @@ static NSColor *shadowCol;
_cell.is_bezeled = NO; _cell.is_bezeled = NO;
} }
- (NSFocusRingType) focusRingType
{
return _cell.focus_ring_type;
}
- (void) setFocusRingType: (NSFocusRingType)type
{
_cell.focus_ring_type = type;
}
/**<p>Sets the NSCell's state. Please use always symbolic constants when /**<p>Sets the NSCell's state. Please use always symbolic constants when
calling this method. The integer values could be changed in the this calling this method. The integer values could be changed in the this
implementation. (Currently they match the Cocoa values but they are implementation. (Currently they match the Cocoa values but they are
@ -896,6 +913,11 @@ static NSColor *shadowCol;
if (flag) if (flag)
{ {
_cell.is_scrollable = NO; _cell.is_scrollable = NO;
[self setLineBreakMode: NSLineBreakByWordWrapping];
}
else
{
[self setLineBreakMode: NSLineBreakByClipping];
} }
} }
@ -935,7 +957,7 @@ static NSColor *shadowCol;
NSAttributedString *attrStr; NSAttributedString *attrStr;
attributes = [self _nonAutoreleasedTypingAttributes]; attributes = [self _nonAutoreleasedTypingAttributes];
attrStr = [_formatter attributedStringForObjectValue: _objectValue attrStr = [_formatter attributedStringForObjectValue: _object_value
withDefaultAttributes: attributes]; withDefaultAttributes: attributes];
RELEASE(attributes); RELEASE(attributes);
if (attrStr != nil) if (attrStr != nil)
@ -1022,6 +1044,26 @@ static NSColor *shadowCol;
[self setStringValue: aString]; [self setStringValue: aString];
} }
- (NSLineBreakMode) lineBreakMode
{
return _cell.line_break_mode;
}
- (void) setLineBreakMode: (NSLineBreakMode)mode
{
_cell.line_break_mode = mode;
}
- (NSWritingDirection) baseWritingDirection
{
return _cell.base_writing_direction;
}
- (void) setBaseWritingDirection: (NSWritingDirection)direction
{
_cell.base_writing_direction = direction;
}
/**<p>Implemented by subclasses to return the action method. /**<p>Implemented by subclasses to return the action method.
The NSCell implementaiton returns NULL.</p> The NSCell implementaiton returns NULL.</p>
<p>See Also: -setAction: -setTarget: -target</p> <p>See Also: -setAction: -setTarget: -target</p>
@ -1247,7 +1289,7 @@ static NSColor *shadowCol;
} }
/* /*
* respond to keyboard * Should this cell respond to keyboard input?
*/ */
- (BOOL) acceptsFirstResponder - (BOOL) acceptsFirstResponder
{ {
@ -1287,23 +1329,19 @@ static NSColor *shadowCol;
- (void) setMnemonicLocation: (unsigned int)location - (void) setMnemonicLocation: (unsigned int)location
{ {
_mnemonic_location = location; _cell.mnemonic_location = location;
} }
- (unsigned int) mnemonicLocation - (unsigned int) mnemonicLocation
{ {
return _mnemonic_location; return _cell.mnemonic_location;
} }
/* Apple Compatibility method - do not use - please test whether the
cell is enabled or disabled instead. */
- (BOOL) refusesFirstResponder - (BOOL) refusesFirstResponder
{ {
return _cell.refuses_first_responder; return _cell.refuses_first_responder;
} }
/* Apple Compatibility method - do not use - please disable the cell
instead. */
- (void) setRefusesFirstResponder: (BOOL)flag - (void) setRefusesFirstResponder: (BOOL)flag
{ {
_cell.refuses_first_responder = flag; _cell.refuses_first_responder = flag;
@ -1845,24 +1883,22 @@ static NSColor *shadowCol;
- (void) setControlSize: (NSControlSize)controlSize - (void) setControlSize: (NSControlSize)controlSize
{ {
// FIXME _cell.control_size = controlSize;
} }
- (NSControlSize) controlSize - (NSControlSize) controlSize
{ {
// FIXME return _cell.control_size;
return NSRegularControlSize;
} }
- (void) setControlTint: (NSControlTint)controlTint - (void) setControlTint: (NSControlTint)controlTint
{ {
// FIXME _cell.control_tint = controlTint;
} }
- (NSControlTint) controlTint - (NSControlTint) controlTint
{ {
// FIXME return _cell.control_tint;
return NSDefaultControlTint;
} }
/**<p>This method is used by subclasses to specified the control view. /**<p>This method is used by subclasses to specified the control view.
@ -1947,7 +1983,10 @@ static NSColor *shadowCol;
} }
if (_cell.shows_first_responder) if (_cell.shows_first_responder)
NSDottedFrameRect(cellFrame); {
// FIXME: Should depend on _cell.focus_ring_type
NSDottedFrameRect(cellFrame);
}
// NB: We don't do any highlighting to make it easier for subclasses // NB: We don't do any highlighting to make it easier for subclasses
// to reuse this code while doing their own custom highlighting and // to reuse this code while doing their own custom highlighting and
@ -2082,7 +2121,7 @@ static NSColor *shadowCol;
{ {
NSString *contents; NSString *contents;
contents = [_formatter editingStringForObjectValue: _objectValue]; contents = [_formatter editingStringForObjectValue: _object_value];
if (contents == nil) if (contents == nil)
{ {
contents = _contents; contents = _contents;
@ -2126,7 +2165,7 @@ static NSColor *shadowCol;
[clipView removeFromSuperview]; [clipView removeFromSuperview];
} }
/** <p> TODO.This method does nothing if a the <var>controlView</var> is nil, /** <p> This method does nothing if the <var>controlView</var> is nil,
if text object does not exist or if the cell's type is not <ref type="type" if text object does not exist or if the cell's type is not <ref type="type"
id="NSCellType">NSTextCellType</ref> </p> id="NSCellType">NSTextCellType</ref> </p>
*/ */
@ -2148,7 +2187,7 @@ static NSColor *shadowCol;
{ {
NSString *contents; NSString *contents;
contents = [_formatter editingStringForObjectValue: _objectValue]; contents = [_formatter editingStringForObjectValue: _object_value];
if (contents == nil) if (contents == nil)
{ {
contents = _contents; contents = _contents;
@ -2185,6 +2224,16 @@ static NSColor *shadowCol;
_cell.sends_action_on_end_editing = flag; _cell.sends_action_on_end_editing = flag;
} }
- (BOOL) allowsUndo
{
return _cell.allows_undo;
}
- (void) setAllowsUndo: (BOOL)flag
{
_cell.allows_undo = flag;
}
/* /*
* Copying * Copying
*/ */
@ -2198,7 +2247,7 @@ static NSColor *shadowCol;
pointers to the objects are copied. We need to RETAIN them all pointers to the objects are copied. We need to RETAIN them all
though. */ though. */
TEST_RETAIN (_font); TEST_RETAIN (_font);
TEST_RETAIN (_objectValue); TEST_RETAIN (_object_value);
TEST_RETAIN (_menu); TEST_RETAIN (_menu);
TEST_RETAIN (_cell_image); TEST_RETAIN (_cell_image);
TEST_RETAIN (_formatter); TEST_RETAIN (_formatter);
@ -2218,40 +2267,55 @@ static NSColor *shadowCol;
unsigned int cFlags2 = 0; unsigned int cFlags2 = 0;
// encode contents // encode contents
[aCoder encodeObject: _contents forKey: @"NSContents"]; [aCoder encodeObject: [self objectValue] forKey: @"NSContents"];
// flags // flags
cFlags |= [self focusRingType];
cFlags |= [self showsFirstResponder] ? 0x4 : 0;
cFlags |= (_action_mask & NSLeftMouseUpMask) ? 0 : 0x20;
cFlags |= [self wraps] ? 0x40 : 0; cFlags |= [self wraps] ? 0x40 : 0;
cFlags |= (_action_mask & NSLeftMouseDraggedMask) ? 0x100 : 0;
cFlags |= ([self lineBreakMode] << 12);
cFlags |= (_action_mask & NSLeftMouseDownMask) ? 0x40000 : 0;
cFlags |= [self isContinuous] ? 0x80000 : 0;
cFlags |= [self isScrollable] ? 0x100000 : 0; cFlags |= [self isScrollable] ? 0x100000 : 0;
cFlags |= [self isSelectable] ? 0x200001 : 0; cFlags |= [self isSelectable] ? 0x200000 : 0;
cFlags |= [self isBezeled] ? 0x400000 : 0; cFlags |= [self isBezeled] ? 0x400000 : 0;
cFlags |= [self isBordered] ? 0x800000 : 0; cFlags |= [self isBordered] ? 0x800000 : 0;
cFlags |= ([self type] == NSTextCellType) ? 0x4000000 : 0; cFlags |= ([self type] << 26);
cFlags |= [self isContinuous] ? 0x40000 : 0;
cFlags |= [self isEditable] ? 0x10000000 : 0; cFlags |= [self isEditable] ? 0x10000000 : 0;
cFlags |= ([self isEnabled] == NO) ? 0x20000000 : 0; cFlags |= ([self isEnabled] == NO) ? 0x20000000 : 0;
cFlags |= ([self state] == NSOnState) ? 0x80000000 : 0;
cFlags |= [self isHighlighted] ? 0x40000000 : 0; cFlags |= [self isHighlighted] ? 0x40000000 : 0;
cFlags |= ([self state] == NSOnState) ? 0x80000000 : 0;
[aCoder encodeInt: cFlags forKey: @"NSCellFlags"]; [aCoder encodeInt: cFlags forKey: @"NSCellFlags"];
// flags part 2 // flags part 2
cFlags2 |= ([self controlTint] << 5);
cFlags2 |= ([self controlSize] << 17);
cFlags2 |= [self sendsActionOnEndEditing] ? 0x400000 : 0; cFlags2 |= [self sendsActionOnEndEditing] ? 0x400000 : 0;
cFlags2 |= [self allowsMixedState] ? 0x1000000 : 0; cFlags2 |= [self allowsMixedState] ? 0x1000000 : 0;
cFlags2 |= [self refusesFirstResponder] ? 0x2000000 : 0; cFlags2 |= [self refusesFirstResponder] ? 0x2000000 : 0;
cFlags2 |= ([self alignment] == NSRightTextAlignment) ? 0x4000000 : 0; cFlags2 |= ([self alignment] << 26);
cFlags2 |= ([self alignment] == NSCenterTextAlignment) ? 0x8000000 : 0;
cFlags2 |= ([self alignment] == NSJustifiedTextAlignment) ? 0xC000000 : 0;
cFlags2 |= ([self alignment] == NSNaturalTextAlignment) ? 0x10000000 : 0;
cFlags2 |= [self importsGraphics] ? 0x20000000 : 0; cFlags2 |= [self importsGraphics] ? 0x20000000 : 0;
cFlags2 |= [self allowsEditingTextAttributes] ? 0x40000000 : 0; cFlags2 |= [self allowsEditingTextAttributes] ? 0x40000000 : 0;
[aCoder encodeInt: cFlags2 forKey: @"NSCellFlags2"]; [aCoder encodeInt: cFlags2 forKey: @"NSCellFlags2"];
// font and formatter. if (_cell.type == NSTextCellType)
[aCoder encodeObject: [self font] forKey: @"NSSupport"]; {
// font and formatter.
if ([self formatter]) if ([self font])
{ {
[aCoder encodeObject: [self formatter] forKey: @"NSFormatter"]; [aCoder encodeObject: [self font] forKey: @"NSSupport"];
}
if ([self formatter])
{
[aCoder encodeObject: [self formatter] forKey: @"NSFormatter"];
}
}
else if ([self image])
{
[aCoder encodeObject: [self image] forKey: @"NSSupport"];
} }
} }
else else
@ -2262,7 +2326,7 @@ static NSColor *shadowCol;
[aCoder encodeObject: _contents]; [aCoder encodeObject: _contents];
[aCoder encodeObject: _cell_image]; [aCoder encodeObject: _cell_image];
[aCoder encodeObject: _font]; [aCoder encodeObject: _font];
[aCoder encodeObject: _objectValue]; [aCoder encodeObject: _object_value];
flag = _cell.contents_is_attributed_string; flag = _cell.contents_is_attributed_string;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.is_highlighted; flag = _cell.is_highlighted;
@ -2297,7 +2361,7 @@ static NSColor *shadowCol;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.allows_mixed_state; flag = _cell.allows_mixed_state;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.wraps; flag = [self wraps];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
tmp_int = _cell.text_align; tmp_int = _cell.text_align;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
@ -2307,14 +2371,29 @@ static NSColor *shadowCol;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.entry_type; tmp_int = _cell.entry_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
// FIXME: State may be -1, why do we encode it as unsigned?
tmp_int = _cell.state; tmp_int = _cell.state;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location]; tmp_int = _cell.mnemonic_location;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask]; [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter]; [aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu]; [aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object]; [aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
tmp_int = _cell.allows_undo;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.line_break_mode;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.control_tint;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.control_size;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.focus_ring_type;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
tmp_int = _cell.base_writing_direction;
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
} }
} }
@ -2336,66 +2415,67 @@ static NSColor *shadowCol;
else else
{ {
self = [self init]; self = [self init];
[self setObjectValue: contents];
} }
if ([aDecoder containsValueForKey: @"NSCellFlags"]) if ([aDecoder containsValueForKey: @"NSCellFlags"])
{ {
unsigned long cFlags; unsigned long cFlags;
unsigned long mask = 0;
cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"]; cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"];
[self setFocusRingType: (cFlags & 0x3)];
[self setShowsFirstResponder: ((cFlags & 0x4) == 0x4)];
// This bit flag is the other way around!
if ((cFlags & 0x20) != 0x20)
mask |= NSLeftMouseUpMask;
// This bit flag is the other way around! // This bit flag is the other way around!
[self setWraps: ((cFlags & 0x40) != 0x40)]; [self setWraps: ((cFlags & 0x40) != 0x40)];
if ((cFlags & 0x100) == 0x100)
mask |= NSLeftMouseDraggedMask;
[self setLineBreakMode: ((cFlags & 0x7000) >> 12)];
if ((cFlags & 0x40000) == 0x40000)
mask |= NSLeftMouseDownMask;
if ((cFlags & 0x80000) == 0x80000)
mask |= NSPeriodicMask;
[self sendActionOn: mask];
[self setScrollable: ((cFlags & 0x100000) == 0x100000)]; [self setScrollable: ((cFlags & 0x100000) == 0x100000)];
// Strange that this is not a simple bit flag [self setSelectable: ((cFlags & 0x200000) == 0x200000)];
[self setSelectable: ((cFlags & 0x200001) == 0x200001)];
[self setBezeled: ((cFlags & 0x400000) == 0x400000)]; [self setBezeled: ((cFlags & 0x400000) == 0x400000)];
[self setBordered: ((cFlags & 0x800000) == 0x800000)]; [self setBordered: ((cFlags & 0x800000) == 0x800000)];
if ((cFlags & 0x4000000) == 0x4000000) [self setType: ((cFlags & 0xC000000) >> 26)];
{
[self setType: NSTextCellType];
}
[self setContinuous: ((cFlags & 0x40000) == 0x40000)];
[self setEditable: ((cFlags & 0x10000000) == 0x10000000)]; [self setEditable: ((cFlags & 0x10000000) == 0x10000000)];
// This bit flag is the other way around! // This bit flag is the other way around!
[self setEnabled: ((cFlags & 0x20000000) != 0x20000000)]; [self setEnabled: ((cFlags & 0x20000000) != 0x20000000)];
[self setHighlighted: ((cFlags & 0x40000000) == 0x40000000)]; [self setHighlighted: ((cFlags & 0x40000000) == 0x40000000)];
[self setState: ((cFlags & 0x80000000) == 0x80000000)?NSOnState:NSOffState]; [self setState: ((cFlags & 0x80000000) == 0x80000000) ? NSOnState : NSOffState];
} }
if ([aDecoder containsValueForKey: @"NSCellFlags2"]) if ([aDecoder containsValueForKey: @"NSCellFlags2"])
{ {
int cFlags2; int cFlags2;
cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"]; cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"];
[self setControlTint: ((cFlags2 & 0xE0) >> 5)];
[self setControlSize: ((cFlags2 & 0xE0000) >> 17)];
[self setSendsActionOnEndEditing: (cFlags2 & 0x400000)]; [self setSendsActionOnEndEditing: (cFlags2 & 0x400000)];
[self setAllowsMixedState: ((cFlags2 & 0x1000000) == 0x1000000)]; [self setAllowsMixedState: ((cFlags2 & 0x1000000) == 0x1000000)];
[self setRefusesFirstResponder: ((cFlags2 & 0x2000000) == 0x2000000)]; [self setRefusesFirstResponder: ((cFlags2 & 0x2000000) == 0x2000000)];
if ((cFlags2 & 0x4000000) == 0x4000000) [self setAlignment: ((cFlags2 & 0x1C000000) >> 26)];
{
[self setAlignment: NSRightTextAlignment];
}
if ((cFlags2 & 0x8000000) == 0x8000000)
{
[self setAlignment: NSCenterTextAlignment];
}
if ((cFlags2 & 0xC000000) == 0xC000000)
{
[self setAlignment: NSJustifiedTextAlignment];
}
if ((cFlags2 & 0x10000000) == 0x10000000)
{
[self setAlignment: NSNaturalTextAlignment];
}
[self setImportsGraphics: ((cFlags2 & 0x20000000) == 0x20000000)]; [self setImportsGraphics: ((cFlags2 & 0x20000000) == 0x20000000)];
[self setAllowsEditingTextAttributes: ((cFlags2 & 0x40000000) == 0x40000000)]; [self setAllowsEditingTextAttributes: ((cFlags2 & 0x40000000) == 0x40000000)];
} }
if ([aDecoder containsValueForKey: @"NSSupport"]) if ([aDecoder containsValueForKey: @"NSSupport"])
{ {
NSFont *support = [aDecoder decodeObjectForKey: @"NSSupport"]; id support = [aDecoder decodeObjectForKey: @"NSSupport"];
[self setFont: support]; if ([support isKindOfClass: [NSFont class]])
{
[self setFont: support];
}
else if ([support isKindOfClass: [NSImage class]])
{
[self setImage: support];
}
} }
if ([aDecoder containsValueForKey: @"NSFormatter"]) if ([aDecoder containsValueForKey: @"NSFormatter"])
{ {
@ -2409,11 +2489,12 @@ static NSColor *shadowCol;
BOOL flag; BOOL flag;
unsigned int tmp_int; unsigned int tmp_int;
id formatter, menu; id formatter, menu;
int version = [aDecoder versionForClassName: @"NSCell"];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_font]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_font];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_objectValue]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_object_value];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.contents_is_attributed_string = flag; _cell.contents_is_attributed_string = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
@ -2457,8 +2538,8 @@ static NSColor *shadowCol;
_cell.entry_type = tmp_int; _cell.entry_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.state = tmp_int; _cell.state = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
at: &_mnemonic_location]; _cell.mnemonic_location = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) [aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_mouse_down_flags]; at: &_mouse_down_flags];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask]; [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
@ -2472,7 +2553,7 @@ static NSColor *shadowCol;
{ {
NSString *contents; NSString *contents;
contents = [_formatter stringForObjectValue: _objectValue]; contents = [_formatter stringForObjectValue: _object_value];
if (contents != nil) if (contents != nil)
{ {
_cell.has_valid_object_value = YES; _cell.has_valid_object_value = YES;
@ -2480,6 +2561,22 @@ static NSColor *shadowCol;
_cell.contents_is_attributed_string = NO; _cell.contents_is_attributed_string = NO;
} }
} }
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.allows_undo = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.line_break_mode = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.control_tint = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.control_size = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.focus_ring_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.base_writing_direction = tmp_int;
}
} }
return self; return self;
} }
@ -2507,21 +2604,12 @@ static NSColor *shadowCol;
NSMutableParagraphStyle *paragraphStyle; NSMutableParagraphStyle *paragraphStyle;
color = [self textColor]; color = [self textColor];
/* Note: there are only 6 possible paragraph styles for cells. /* Note: There are only a few possible paragraph styles for cells.
TODO: Create them once at the beginning, and reuse them for the whole TODO: Cache them and reuse them for the whole app lifetime. */
app lifetime. */
paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: [self lineBreakMode]];
if (_cell.wraps) [paragraphStyle setBaseWritingDirection: [self baseWritingDirection]];
{ [paragraphStyle setAlignment: [self alignment]];
[paragraphStyle setLineBreakMode: NSLineBreakByWordWrapping];
}
else
{
[paragraphStyle setLineBreakMode: NSLineBreakByClipping];
}
[paragraphStyle setAlignment: _cell.text_align];
attr = [[NSDictionary alloc] initWithObjectsAndKeys: attr = [[NSDictionary alloc] initWithObjectsAndKeys:
_font, NSFontAttributeName, _font, NSFontAttributeName,

File diff suppressed because it is too large Load diff

View file

@ -27,16 +27,22 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <Foundation/NSArray.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSString.h>
#include <Foundation/NSURL.h>
#include <Foundation/NSUserDefaults.h>
#include "AppKit/NSDocumentController.h" #include "AppKit/NSDocumentController.h"
#include "AppKit/NSOpenPanel.h" #include "AppKit/NSOpenPanel.h"
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSMenuItem.h" #include "AppKit/NSMenuItem.h"
#include "AppKit/NSWorkspace.h" #include "AppKit/NSWorkspace.h"
#include "AppKit/NSDocumentFrameworkPrivate.h" #include "NSDocumentFrameworkPrivate.h"
#include "GSGuiPrivate.h" #include "GSGuiPrivate.h"
#include <Foundation/NSUserDefaults.h>
static NSString *NSTypesKey = @"NSTypes"; static NSString *NSTypesKey = @"NSTypes";
static NSString *NSNameKey = @"NSName"; static NSString *NSNameKey = @"NSName";
static NSString *NSRoleKey = @"NSRole"; static NSString *NSRoleKey = @"NSRole";
@ -165,22 +171,22 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
_documents = [[NSMutableArray alloc] init]; _documents = [[NSMutableArray alloc] init];
/* Get list of recent documents */ /* Get list of recent documents */
_recentDocuments = [[NSUserDefaults standardUserDefaults] _recent_documents = [[NSUserDefaults standardUserDefaults]
objectForKey: NSRecentDocuments]; objectForKey: NSRecentDocuments];
if (_recentDocuments) if (_recent_documents)
{ {
int i, count; int i, count;
_recentDocuments = [_recentDocuments mutableCopy]; _recent_documents = [_recent_documents mutableCopy];
count = [_recentDocuments count]; count = [_recent_documents count];
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
NSURL *url; NSURL *url;
url = [NSURL URLWithString: [_recentDocuments objectAtIndex: i]]; url = [NSURL URLWithString: [_recent_documents objectAtIndex: i]];
[_recentDocuments replaceObjectAtIndex: i withObject: url]; [_recent_documents replaceObjectAtIndex: i withObject: url];
} }
} }
else else
_recentDocuments = RETAIN([NSMutableArray array]); _recent_documents = RETAIN([NSMutableArray array]);
[self setShouldCreateUI:YES]; [self setShouldCreateUI:YES];
[[[NSWorkspace sharedWorkspace] notificationCenter] [[[NSWorkspace sharedWorkspace] notificationCenter]
@ -198,19 +204,47 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
{ {
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver: self]; [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver: self];
RELEASE (_documents); RELEASE (_documents);
RELEASE (_recentDocuments); RELEASE (_recent_documents);
RELEASE (_types); RELEASE (_types);
[super dealloc]; [super dealloc];
} }
/*
* Private helper method to check, if the method given via the selector sel
* has been overridden in the current subclass.
*/
- (BOOL)_hasOverridden: (SEL)sel
{
// The actual signature is not important as we wont call the methods.
IMP meth1;
IMP meth2;
meth1 = [self methodForSelector: sel];
meth2 = [[NSDocument class] instanceMethodForSelector: sel];
return (meth1 != meth2);
}
#define OVERRIDDEN(sel) [self _hasOverridden: @selector(sel)]
- (BOOL) shouldCreateUI - (BOOL) shouldCreateUI
{ {
return _controllerFlags.shouldCreateUI; return _controller_flags.should_create_ui;
} }
- (void) setShouldCreateUI: (BOOL)flag - (void) setShouldCreateUI: (BOOL)flag
{ {
_controllerFlags.shouldCreateUI = flag; _controller_flags.should_create_ui = flag;
}
- (NSTimeInterval) autosavingDelay
{
return _autosavingDelay;
}
- (void) setAutosavingDelay: (NSTimeInterval)autosavingDelay
{
_autosavingDelay = autosavingDelay;
} }
- (id) makeUntitledDocumentOfType: (NSString *)type - (id) makeUntitledDocumentOfType: (NSString *)type
@ -238,14 +272,69 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
ofType: type]); ofType: type]);
} }
- _defaultType - (id)makeDocumentForURL:(NSURL *)url
withContentsOfURL:(NSURL *)contents
ofType:(NSString *)type
error:(NSError **)err
{
Class documentClass = [self documentClassForType: type];
return AUTORELEASE([[documentClass alloc] initForURL: url
withContentsOfURL: contents
ofType: type
error: err]);
}
- (id)makeDocumentWithContentsOfURL:(NSURL *)url
ofType:(NSString *)type
error:(NSError **)err
{
Class documentClass = [self documentClassForType: type];
return AUTORELEASE([[documentClass alloc] initWithContentsOfURL: url
ofType: type
error: err]);
}
- (id)makeUntitledDocumentOfType:(NSString *)type
error:(NSError **)err
{
Class documentClass = [self documentClassForType: type];
return AUTORELEASE([[documentClass alloc] initWithType: type
error: err]);
}
- (BOOL)presentError:(NSError *)error
{
error = [self willPresentError: error];
return [NSApp presentError: error];
}
- (void)presentError:(NSError *)error
modalForWindow:(NSWindow *)window
delegate:(id)delegate
didPresentSelector:(SEL)sel
contextInfo:(void *)context
{
error = [self willPresentError: error];
[NSApp presentError: error
modalForWindow: window
delegate: delegate
didPresentSelector: sel
contextInfo: context];
}
- (NSError *) willPresentError: (NSError *)error
{
return error;
}
- (NSString*) defaultType
{ {
if ([_types count] == 0) if ([_types count] == 0)
{ {
return nil; // raise exception? return nil; // raise exception?
} }
return [(NSDictionary*)[_types objectAtIndex:0] objectForKey:NSNameKey]; return [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: NSNameKey];
} }
- (void) addDocument: (NSDocument *)document - (void) addDocument: (NSDocument *)document
@ -268,13 +357,10 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
} }
[self addDocument: document]; [self addDocument: document];
if ([self shouldCreateUI]) if (display && [self shouldCreateUI])
{ {
[document makeWindowControllers]; [document makeWindowControllers];
if (display) [document showWindows];
{
[document showWindows];
}
} }
return document; return document;
@ -294,13 +380,16 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
{ {
NSString *type = [self typeFromFileExtension: [fileName pathExtension]]; NSString *type = [self typeFromFileExtension: [fileName pathExtension]];
if ((document = [self makeDocumentWithContentsOfFile: fileName document = [self makeDocumentWithContentsOfFile: fileName ofType: type];
ofType: type]))
if (document == nil)
{ {
[self addDocument: document]; return nil;
} }
if ([self shouldCreateUI]) [self addDocument: document];
if (display && [self shouldCreateUI])
{ {
[document makeWindowControllers]; [document makeWindowControllers];
} }
@ -324,11 +413,11 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
*/ */
- (id) openDocumentWithContentsOfURL: (NSURL *)url display: (BOOL)display - (id) openDocumentWithContentsOfURL: (NSURL *)url display: (BOOL)display
{ {
// Should we only do this if [url isFileURL] is YES? NSDocument *document = [self documentForURL: url];
NSDocument *document = [self documentForFileName: [url path]];
if (document == nil) if (document == nil)
{ {
// Should we only do this if [url isFileURL] is YES?
NSString *type = [self typeFromFileExtension: NSString *type = [self typeFromFileExtension:
[[url path] pathExtension]]; [[url path] pathExtension]];
@ -341,7 +430,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
[self addDocument: document]; [self addDocument: document];
if ([self shouldCreateUI]) if (display && [self shouldCreateUI])
{ {
[document makeWindowControllers]; [document makeWindowControllers];
} }
@ -358,6 +447,94 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
return document; return document;
} }
- (id)openUntitledDocumentAndDisplay:(BOOL)display
error:(NSError **)err
{
NSString *type;
type = [self defaultType];
if (OVERRIDDEN(openUntitledDocumentOfType:display:))
{
return [self openUntitledDocumentOfType: type display: display];
}
else
{
NSDocument *document = [self makeUntitledDocumentOfType: type
error: err];
if (document == nil)
{
return nil;
}
[self addDocument: document];
if (display && [self shouldCreateUI])
{
[document makeWindowControllers];
[document showWindows];
}
return document;
}
}
- (id) openDocumentWithContentsOfURL: (NSURL *)url
display: (BOOL)display
error: (NSError **)err
{
if (OVERRIDDEN(openDocumentWithContentsOfFile:display:))
{
NSString *fileName;
fileName = [url path];
return [self openDocumentWithContentsOfFile: fileName display: display];
}
else
{
NSDocument *document = [self documentForURL: url];
if (document == nil)
{
// Should we only do this if [url isFileURL] is YES?
NSString *type = [self typeFromFileExtension:
[[url path] pathExtension]];
document = [self makeDocumentWithContentsOfURL: url ofType: type error: err];
if (document == nil)
{
return nil;
}
[self addDocument: document];
if (display && [self shouldCreateUI])
{
[document makeWindowControllers];
}
}
// remember this document as opened
[self noteNewRecentDocumentURL: url];
if (display && [self shouldCreateUI])
{
[document showWindows];
}
return document;
}
}
- (BOOL) reopenDocumentForURL: (NSURL *)url
withContentsOfURL: (NSURL *)contents
error: (NSError **)err
{
// FIXME
return NO;
}
- (NSOpenPanel *) _setupOpenPanel - (NSOpenPanel *) _setupOpenPanel
{ {
NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSOpenPanel *openPanel = [NSOpenPanel openPanel];
@ -455,7 +632,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
- (IBAction) newDocument: (id)sender - (IBAction) newDocument: (id)sender
{ {
[self openUntitledDocumentOfType: [self _defaultType] display: YES]; [self openUntitledDocumentOfType: [self defaultType] display: YES];
} }
@ -564,7 +741,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
- (BOOL) applicationOpenUntitledFile: (NSApplication *)sender - (BOOL) applicationOpenUntitledFile: (NSApplication *)sender
{ {
return [self openUntitledDocumentOfType: [self _defaultType] return [self openUntitledDocumentOfType: [self defaultType]
display: YES] ? YES : NO; display: YES] ? YES : NO;
} }
@ -691,6 +868,33 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
return nil; return nil;
} }
- (id)documentForURL: (NSURL *)url
{
if (OVERRIDDEN(documentForFileName:))
{
NSString *fileName;
fileName = [url path];
return [self documentForFileName: fileName];
}
else
{
int i, count = [_documents count];
for (i = 0; i < count; i++)
{
NSDocument *document = [_documents objectAtIndex: i];
if ([[document fileURL] isEqual: url])
{
return document;
}
}
return nil;
}
}
- (BOOL) validateMenuItem: (NSMenuItem *)anItem - (BOOL) validateMenuItem: (NSMenuItem *)anItem
{ {
if ([anItem action] == @selector(saveAllDocuments:)) if ([anItem action] == @selector(saveAllDocuments:))
@ -733,6 +937,15 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
return nil; return nil;
} }
- (NSString *) typeForContentsOfURL: (NSURL *)url error: (NSError **)err
{
// FIXME
NSString *extension;
extension = [[url path] pathExtension];
return [self typeFromFileExtension: extension];
}
- (NSArray *) fileExtensionsFromType: (NSString *)type - (NSArray *) fileExtensionsFromType: (NSString *)type
{ {
NSDictionary *typeInfo = TYPE_INFO(type); NSDictionary *typeInfo = TYPE_INFO(type);
@ -751,11 +964,29 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
return className? NSClassFromString(className) : Nil; return className? NSClassFromString(className) : Nil;
} }
- (NSArray *)documentClassNames
{
int i, count = [_types count];
NSMutableArray *classNames;
classNames = [[NSMutableArray alloc] initWithCapacity: count];
for (i = 0; i < count; i++)
{
NSDictionary *typeInfo = [_types objectAtIndex: i];
[classNames addObject: [typeInfo objectForKey: NSDocumentClassKey]];
}
return AUTORELEASE(classNames);
}
- (IBAction) clearRecentDocuments: (id)sender - (IBAction) clearRecentDocuments: (id)sender
{ {
[_recentDocuments removeAllObjects]; [_recent_documents removeAllObjects];
[[NSUserDefaults standardUserDefaults] [[NSUserDefaults standardUserDefaults]
setObject: _recentDocuments forKey: NSRecentDocuments]; setObject: _recent_documents forKey: NSRecentDocuments];
} }
// The number of remembered recent documents // The number of remembered recent documents
@ -772,22 +1003,22 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
- (void) noteNewRecentDocumentURL: (NSURL *)anURL - (void) noteNewRecentDocumentURL: (NSURL *)anURL
{ {
unsigned index = [_recentDocuments indexOfObject: anURL]; unsigned index = [_recent_documents indexOfObject: anURL];
NSMutableArray *a; NSMutableArray *a;
if (index != NSNotFound) if (index != NSNotFound)
{ {
// Always keep the current object at the end of the list // Always keep the current object at the end of the list
[_recentDocuments removeObjectAtIndex: index]; [_recent_documents removeObjectAtIndex: index];
} }
else if ([_recentDocuments count] > MAX_DOCS) else if ([_recent_documents count] > MAX_DOCS)
{ {
[_recentDocuments removeObjectAtIndex: 0]; [_recent_documents removeObjectAtIndex: 0];
} }
[_recentDocuments addObject: anURL]; [_recent_documents addObject: anURL];
a = [_recentDocuments mutableCopy]; a = [_recent_documents mutableCopy];
index = [a count]; index = [a count];
while (index-- > 0) while (index-- > 0)
{ {
@ -801,7 +1032,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
- (NSArray *) recentDocumentURLs - (NSArray *) recentDocumentURLs
{ {
return _recentDocuments; return _recent_documents;
} }
@end @end

View file

@ -28,9 +28,8 @@
*/ */
#ifndef _GNUstep_H_NSDocumentFramworkPrivate #ifndef _GNUstep_H_NSDocumentFramworkPrivate
#define _GNUstep_H_NSDocumentFramworkPrivate #define _GNUstep_H_NSDocumentFramworkPrivate
#import <GNUstepBase/GSVersionMacros.h>
#include "NSDocumentController.h" #include <AppKit/NSDocumentController.h>
@interface NSDocumentController (Private) @interface NSDocumentController (Private)
- (NSArray *)_editorAndViewerTypesForClass:(Class)documentClass; - (NSArray *)_editorAndViewerTypesForClass:(Class)documentClass;
@ -42,7 +41,7 @@
@end @end
#include "NSDocument.h" #include <AppKit/NSDocument.h>
@interface NSDocument (Private) @interface NSDocument (Private)
- (void)_removeWindowController:(NSWindowController *)controller; - (void)_removeWindowController:(NSWindowController *)controller;
@ -50,7 +49,7 @@
@end @end
#include "NSWindowController.h" #include <AppKit/NSWindowController.h>
@interface NSWindowController (Private) @interface NSWindowController (Private)
- (void)_windowDidLoad; - (void)_windowDidLoad;

View file

@ -290,13 +290,14 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
- (void) dealloc - (void) dealloc
{ {
RELEASE(_printInfo); RELEASE(_print_info);
RELEASE(_view); RELEASE(_view);
RELEASE(_data); RELEASE(_data);
TEST_RELEASE(_context); TEST_RELEASE(_context);
TEST_RELEASE(_printPanel); TEST_RELEASE(_print_panel);
TEST_RELEASE(_accessoryView); TEST_RELEASE(_accessory_view);
TEST_RELEASE(_path); TEST_RELEASE(_path);
TEST_RELEASE(_job_style_hint);
[super dealloc]; [super dealloc];
} }
@ -324,17 +325,17 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (NSPrintPanel *)printPanel - (NSPrintPanel *)printPanel
{ {
if (_printPanel == nil) if (_print_panel == nil)
ASSIGN(_printPanel, [NSPrintPanel printPanel]); ASSIGN(_print_panel, [NSPrintPanel printPanel]);
return _printPanel; return _print_panel;
} }
/** Returns YES if the reciever display an NSPrintPanel and other information /** Returns YES if the reciever display an NSPrintPanel and other information
when running a print operation. */ when running a print operation. */
- (BOOL)showPanels - (BOOL)showPanels
{ {
return _showPanels; return [self showsPrintPanel] && [self showsProgressPanel];
} }
/** Sets the NSPrintPanel used by the receiver obtaining and displaying /** Sets the NSPrintPanel used by the receiver obtaining and displaying
@ -342,7 +343,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (void)setPrintPanel:(NSPrintPanel *)panel - (void)setPrintPanel:(NSPrintPanel *)panel
{ {
ASSIGN(_printPanel, panel); ASSIGN(_print_panel, panel);
} }
/** Use this to set whether a print panel is displayed during a printing /** Use this to set whether a print panel is displayed during a printing
@ -352,15 +353,37 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (void)setShowPanels:(BOOL)flag - (void)setShowPanels:(BOOL)flag
{ {
_showPanels = flag; [self setShowsPrintPanel: flag];
[self setShowsProgressPanel: flag];
} }
- (BOOL)showsPrintPanel
{
return _flags.show_print_panel;
}
- (void)setShowsPrintPanel:(BOOL)flag
{
_flags.show_print_panel = flag;
}
- (BOOL)showsProgressPanel
{
return _flags.show_progress_panel;
}
- (void)setShowsProgressPanel:(BOOL)flag
{
_flags.show_progress_panel = flag;
}
/** Returns the accessory view used by the NSPrintPanel associated with /** Returns the accessory view used by the NSPrintPanel associated with
the receiver. the receiver.
*/ */
- (NSView *)accessoryView - (NSView *)accessoryView
{ {
return _accessoryView; return _accessory_view;
} }
/** Set the accessory view used by the NSPrintPanel associated with the /** Set the accessory view used by the NSPrintPanel associated with the
@ -368,7 +391,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (void)setAccessoryView:(NSView *)aView - (void)setAccessoryView:(NSView *)aView
{ {
ASSIGN(_accessoryView, aView); ASSIGN(_accessory_view, aView);
} }
// //
@ -413,14 +436,14 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (NSPrintingPageOrder)pageOrder - (NSPrintingPageOrder)pageOrder
{ {
return _pageOrder; return _page_order;
} }
/** Set the page order used when printing. /** Set the page order used when printing.
*/ */
- (void)setPageOrder:(NSPrintingPageOrder)order - (void)setPageOrder:(NSPrintingPageOrder)order
{ {
_pageOrder = order; _page_order = order;
} }
// //
@ -455,12 +478,12 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
{ {
BOOL result; BOOL result;
if (_showPanels) if ([self showsPrintPanel])
{ {
NSPrintPanel *panel = [self printPanel]; NSPrintPanel *panel = [self printPanel];
int button; int button;
[panel setAccessoryView: _accessoryView]; [panel setAccessoryView: _accessory_view];
[self _setupPrintInfo]; [self _setupPrintInfo];
[panel updateFromPrintInfo]; [panel updateFromPrintInfo];
button = [panel runModal]; button = [panel runModal];
@ -495,7 +518,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
NSPrintPanel *panel = [self printPanel]; NSPrintPanel *panel = [self printPanel];
/* Save the selector so we can use it later */ /* Save the selector so we can use it later */
dict = [_printInfo dictionary]; dict = [_print_info dictionary];
[dict setObject: [NSValue value: &didRunSelector withObjCType: @encode(SEL)] [dict setObject: [NSValue value: &didRunSelector withObjCType: @encode(SEL)]
forKey: @"GSModalRunSelector"]; forKey: @"GSModalRunSelector"];
[dict setObject: delegate [dict setObject: delegate
@ -504,10 +527,10 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
/* Assume we want to show the panel regardless of the value /* Assume we want to show the panel regardless of the value
of _showPanels of _showPanels
*/ */
[panel setAccessoryView: _accessoryView]; [panel setAccessoryView: _accessory_view];
[self _setupPrintInfo]; [self _setupPrintInfo];
[panel updateFromPrintInfo]; [panel updateFromPrintInfo];
[panel beginSheetWithPrintInfo: _printInfo [panel beginSheetWithPrintInfo: _print_info
modalForWindow: docWindow modalForWindow: docWindow
delegate: delegate delegate: delegate
didEndSelector: didEndSelector:
@ -516,6 +539,26 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
[panel setAccessoryView: nil]; [panel setAccessoryView: nil];
} }
- (BOOL)canSpawnSeparateThread
{
return _flags.can_spawn_separate_thread;
}
- (void)setCanSpawnSeparateThread:(BOOL)flag
{
_flags.can_spawn_separate_thread = flag;
}
- (NSString *) jobStyleHint
{
return _job_style_hint;
}
- (void)setJobStyleHint:(NSString *)hint
{
ASSIGN(_job_style_hint, hint);
}
// //
// Getting the NSPrintInfo Object // Getting the NSPrintInfo Object
// //
@ -523,7 +566,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
*/ */
- (NSPrintInfo *)printInfo - (NSPrintInfo *)printInfo
{ {
return _printInfo; return _print_info;
} }
/** Set the NSPrintInfo object associated with the receiver. /** Set the NSPrintInfo object associated with the receiver.
@ -533,7 +576,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
if (aPrintInfo == nil) if (aPrintInfo == nil)
aPrintInfo = [NSPrintInfo sharedPrintInfo]; aPrintInfo = [NSPrintInfo sharedPrintInfo];
ASSIGNCOPY(_printInfo, aPrintInfo); ASSIGNCOPY(_print_info, aPrintInfo);
} }
// //
@ -565,8 +608,9 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
ASSIGN(_view, aView); ASSIGN(_view, aView);
_rect = rect; _rect = rect;
ASSIGN(_data, data); ASSIGN(_data, data);
_pageOrder = NSUnknownPageOrder; _page_order = NSUnknownPageOrder;
_showPanels = NO; [self setShowsPrintPanel: NO];
[self setShowsProgressPanel: NO];
[self setPrintInfo: aPrintInfo]; [self setPrintInfo: aPrintInfo];
_path = nil; _path = nil;
_currentPage = 0; _currentPage = 0;
@ -593,13 +637,13 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
return NO; return NO;
result = NO; result = NO;
if (_pageOrder == NSUnknownPageOrder) if (_page_order == NSUnknownPageOrder)
{ {
if ([[[_printInfo dictionary] objectForKey: NSPrintReversePageOrder] if ([[[_print_info dictionary] objectForKey: NSPrintReversePageOrder]
boolValue] == YES) boolValue] == YES)
_pageOrder = NSDescendingPageOrder; _page_order = NSDescendingPageOrder;
else else
_pageOrder = NSAscendingPageOrder; _page_order = NSAscendingPageOrder;
} }
[NSGraphicsContext setCurrentContext: _context]; [NSGraphicsContext setCurrentContext: _context];
@ -626,7 +670,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
{ {
BOOL knowsPageRange; BOOL knowsPageRange;
NSRange viewPageRange; NSRange viewPageRange;
NSMutableDictionary *dict = [_printInfo dictionary]; NSMutableDictionary *dict = [_print_info dictionary];
knowsPageRange = [_view knowsPageRange: &viewPageRange]; knowsPageRange = [_view knowsPageRange: &viewPageRange];
if (knowsPageRange == YES) if (knowsPageRange == YES)
@ -656,7 +700,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
success = [self deliverResult]; success = [self deliverResult];
} }
[self cleanUpOperation]; [self cleanUpOperation];
dict = [_printInfo dictionary]; dict = [_print_info dictionary];
didRunSelector = [[dict objectForKey: @"GSModalRunSelector"] pointerValue]; didRunSelector = [[dict objectForKey: @"GSModalRunSelector"] pointerValue];
delegate = [dict objectForKey: @"GSModalRunDelegate"]; delegate = [dict objectForKey: @"GSModalRunDelegate"];
didRun = (void (*)(id, SEL, BOOL, id))[delegate methodForSelector: didRun = (void (*)(id, SEL, BOOL, id))[delegate methodForSelector:
@ -693,10 +737,10 @@ scaleRect(NSRect rect, double scale)
- (void) _printPaginateWithInfo: (page_info_t *)info knowsRange: (BOOL)knowsRange - (void) _printPaginateWithInfo: (page_info_t *)info knowsRange: (BOOL)knowsRange
{ {
NSMutableDictionary *dict; NSMutableDictionary *dict;
dict = [_printInfo dictionary]; dict = [_print_info dictionary];
info->paperSize = [_printInfo paperSize]; info->paperSize = [_print_info paperSize];
info->orient = [_printInfo orientation]; info->orient = [_print_info orientation];
info->printScale = [[dict objectForKey: NSPrintScalingFactor] doubleValue]; info->printScale = [[dict objectForKey: NSPrintScalingFactor] doubleValue];
info->nup = [[dict objectForKey: NSPrintPagesPerSheet] intValue]; info->nup = [[dict objectForKey: NSPrintPagesPerSheet] intValue];
info->nupScale = 1; info->nupScale = 1;
@ -709,12 +753,12 @@ scaleRect(NSRect rect, double scale)
/* Subtract the margins from the paper size to get print boundary */ /* Subtract the margins from the paper size to get print boundary */
info->paperBounds.size = info->paperSize; info->paperBounds.size = info->paperSize;
info->paperBounds.origin.x = [_printInfo leftMargin]; info->paperBounds.origin.x = [_print_info leftMargin];
info->paperBounds.origin.y = [_printInfo bottomMargin]; info->paperBounds.origin.y = [_print_info bottomMargin];
info->paperBounds.size.width -= info->paperBounds.size.width -=
([_printInfo rightMargin]+[_printInfo leftMargin]); ([_print_info rightMargin]+[_print_info leftMargin]);
info->paperBounds.size.height -= info->paperBounds.size.height -=
([_printInfo topMargin]+[_printInfo bottomMargin]); ([_print_info topMargin]+[_print_info bottomMargin]);
info->sheetBounds = info->paperBounds; info->sheetBounds = info->paperBounds;
if (info->orient == NSLandscapeOrientation) if (info->orient == NSLandscapeOrientation)
@ -739,10 +783,10 @@ scaleRect(NSRect rect, double scale)
if (knowsRange == NO) if (knowsRange == NO)
{ {
/* Now calculate page fitting to get page scale */ /* Now calculate page fitting to get page scale */
if ([_printInfo horizontalPagination] == NSFitPagination) if ([_print_info horizontalPagination] == NSFitPagination)
info->pageScale = info->paperBounds.size.width info->pageScale = info->paperBounds.size.width
/ NSWidth(info->scaledBounds); / NSWidth(info->scaledBounds);
if ([_printInfo verticalPagination] == NSFitPagination) if ([_print_info verticalPagination] == NSFitPagination)
info->pageScale = MIN(info->pageScale, info->pageScale = MIN(info->pageScale,
NSHeight(info->paperBounds)/NSHeight(info->scaledBounds)); NSHeight(info->paperBounds)/NSHeight(info->scaledBounds));
/* Scale bounds by pageScale */ /* Scale bounds by pageScale */
@ -751,9 +795,9 @@ scaleRect(NSRect rect, double scale)
/* Now find out how many pages */ /* Now find out how many pages */
info->xpages = ceil(NSWidth(info->scaledBounds)/NSWidth(info->paperBounds)); info->xpages = ceil(NSWidth(info->scaledBounds)/NSWidth(info->paperBounds));
info->ypages = ceil(NSHeight(info->scaledBounds)/NSHeight(info->paperBounds)); info->ypages = ceil(NSHeight(info->scaledBounds)/NSHeight(info->paperBounds));
if ([_printInfo horizontalPagination] == NSClipPagination) if ([_print_info horizontalPagination] == NSClipPagination)
info->xpages = 1; info->xpages = 1;
if ([_printInfo verticalPagination] == NSClipPagination) if ([_print_info verticalPagination] == NSClipPagination)
info->ypages = 1; info->ypages = 1;
} }
@ -869,7 +913,7 @@ scaleRect(NSRect rect, double scale)
NSMutableDictionary *dict; NSMutableDictionary *dict;
page_info_t info; page_info_t info;
dict = [_printInfo dictionary]; dict = [_print_info dictionary];
/* Setup pagination */ /* Setup pagination */
allPages = [[dict objectForKey: NSPrintAllPages] boolValue]; allPages = [[dict objectForKey: NSPrintAllPages] boolValue];
@ -917,7 +961,7 @@ scaleRect(NSRect rect, double scale)
_currentPage = info.first; _currentPage = info.first;
dir = 1; dir = 1;
if (_pageOrder == NSDescendingPageOrder) if (_page_order == NSDescendingPageOrder)
{ {
_currentPage = info.last; _currentPage = info.last;
dir = -1; dir = -1;
@ -975,12 +1019,12 @@ scaleRect(NSRect rect, double scale)
/* Check if adjust pages forced part of the bounds onto /* Check if adjust pages forced part of the bounds onto
another page */ another page */
if (NSMaxX(pageRect) < NSMaxX(_rect) if (NSMaxX(pageRect) < NSMaxX(_rect)
&& [_printInfo horizontalPagination] != NSClipPagination) && [_print_info horizontalPagination] != NSClipPagination)
{ {
info.xpages++; info.xpages++;
} }
if (NSMaxY(pageRect) < NSMaxY(_rect) if (NSMaxY(pageRect) < NSMaxY(_rect)
&& [_printInfo verticalPagination] != NSClipPagination) && [_print_info verticalPagination] != NSClipPagination)
{ {
info.ypages++; info.ypages++;
} }

View file

@ -437,4 +437,48 @@
return NO; return NO;
} }
- (BOOL)presentError:(NSError *)error
{
error = [self willPresentError: error];
if (_next_responder)
{
return [_next_responder presentError: error];
}
else
{
return [NSApp presentError: error];
}
}
- (void)presentError:(NSError *)error
modalForWindow:(NSWindow *)window
delegate:(id)delegate
didPresentSelector:(SEL)sel
contextInfo:(void *)context
{
error = [self willPresentError: error];
if (_next_responder)
{
[_next_responder presentError: error
modalForWindow: window
delegate: delegate
didPresentSelector: sel
contextInfo: context];
}
else
{
[NSApp presentError: error
modalForWindow: window
delegate: delegate
didPresentSelector: sel
contextInfo: context];
}
}
- (NSError *) willPresentError: (NSError *)error
{
return error;
}
@end @end

View file

@ -36,6 +36,7 @@
#include <float.h> #include <float.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSCalendarDate.h> #include <Foundation/NSCalendarDate.h>
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
#include <Foundation/NSKeyedArchiver.h> #include <Foundation/NSKeyedArchiver.h>

View file

@ -24,10 +24,15 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/ */
#include "AppKit/NSWindowController.h" #include <Foundation/NSBundle.h>
#include "AppKit/NSPanel.h" #include <Foundation/NSException.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSString.h>
#include "AppKit/NSNibLoading.h" #include "AppKit/NSNibLoading.h"
#include "AppKit/NSDocumentFrameworkPrivate.h" #include "AppKit/NSPanel.h"
#include "AppKit/NSWindowController.h"
#include "NSDocumentFrameworkPrivate.h"
@implementation NSWindowController @implementation NSWindowController
@ -51,7 +56,7 @@
} }
self = [self initWithWindow: nil]; self = [self initWithWindow: nil];
ASSIGN(_windowNibName, windowNibName); ASSIGN(_window_nib_name, windowNibName);
_owner = owner; _owner = owner;
return self; return self;
} }
@ -72,7 +77,7 @@
} }
self = [self initWithWindow: nil]; self = [self initWithWindow: nil];
ASSIGN(_windowNibPath, windowNibPath); ASSIGN(_window_nib_path, windowNibPath);
_owner = owner; _owner = owner;
return self; return self;
} }
@ -81,9 +86,9 @@
{ {
self = [super init]; self = [super init];
_windowFrameAutosaveName = @""; _window_frame_autosave_name = @"";
_wcFlags.shouldCascade = YES; _wcFlags.should_cascade = YES;
_wcFlags.shouldCloseDocument = NO; _wcFlags.should_close_document = NO;
[self setWindow: window]; [self setWindow: window];
if (_window != nil) if (_window != nil)
@ -103,40 +108,40 @@
- (void) dealloc - (void) dealloc
{ {
[self setWindow: nil]; [self setWindow: nil];
RELEASE (_windowNibName); RELEASE(_window_nib_name);
RELEASE (_windowNibPath); RELEASE(_window_nib_path);
RELEASE (_windowFrameAutosaveName); RELEASE(_window_frame_autosave_name);
RELEASE (_topLevelObjects); RELEASE(_top_level_objects);
[super dealloc]; [super dealloc];
} }
- (NSString *) windowNibName - (NSString *) windowNibName
{ {
if ((_windowNibName == nil) && (_windowNibPath != nil)) if ((_window_nib_name == nil) && (_window_nib_path != nil))
{ {
return [[_windowNibPath lastPathComponent] return [[_window_nib_path lastPathComponent]
stringByDeletingPathExtension]; stringByDeletingPathExtension];
} }
return _windowNibName; return _window_nib_name;
} }
- (NSString *)windowNibPath - (NSString *)windowNibPath
{ {
if ((_windowNibName != nil) && (_windowNibPath == nil)) if ((_window_nib_name != nil) && (_window_nib_path == nil))
{ {
NSString *path; NSString *path;
path = [[NSBundle bundleForClass: [_owner class]] path = [[NSBundle bundleForClass: [_owner class]]
pathForNibResource: _windowNibName]; pathForNibResource: _window_nib_name];
if (path == nil) if (path == nil)
path = [[NSBundle mainBundle] path = [[NSBundle mainBundle]
pathForNibResource: _windowNibName]; pathForNibResource: _window_nib_name];
return path; return path;
} }
return _windowNibPath; return _window_nib_path;
} }
- (id) owner - (id) owner
@ -187,7 +192,7 @@
- (void) setWindowFrameAutosaveName:(NSString *)name - (void) setWindowFrameAutosaveName:(NSString *)name
{ {
ASSIGN(_windowFrameAutosaveName, name); ASSIGN(_window_frame_autosave_name, name);
if ([self isWindowLoaded]) if ([self isWindowLoaded])
{ {
@ -197,27 +202,27 @@
- (NSString *) windowFrameAutosaveName - (NSString *) windowFrameAutosaveName
{ {
return _windowFrameAutosaveName; return _window_frame_autosave_name;
} }
- (void) setShouldCloseDocument: (BOOL)flag - (void) setShouldCloseDocument: (BOOL)flag
{ {
_wcFlags.shouldCloseDocument = flag; _wcFlags.should_close_document = flag;
} }
- (BOOL) shouldCloseDocument - (BOOL) shouldCloseDocument
{ {
return _wcFlags.shouldCloseDocument; return _wcFlags.should_close_document;
} }
- (void) setShouldCascadeWindows: (BOOL)flag - (void) setShouldCascadeWindows: (BOOL)flag
{ {
_wcFlags.shouldCascade = flag; _wcFlags.should_cascade = flag;
} }
- (BOOL) shouldCascadeWindows - (BOOL) shouldCascadeWindows
{ {
return _wcFlags.shouldCascade; return _wcFlags.should_cascade;
} }
- (void) close - (void) close
@ -375,7 +380,7 @@
- (BOOL) isWindowLoaded - (BOOL) isWindowLoaded
{ {
return _wcFlags.nibIsLoaded; return _wcFlags.nib_is_loaded;
} }
- (void) windowDidLoad - (void) windowDidLoad
@ -388,15 +393,15 @@
- (void) _windowDidLoad - (void) _windowDidLoad
{ {
_wcFlags.nibIsLoaded = YES; _wcFlags.nib_is_loaded = YES;
[self synchronizeWindowTitleWithDocumentName]; [self synchronizeWindowTitleWithDocumentName];
/* Make sure window sizes itself right */ /* Make sure window sizes itself right */
if ([_windowFrameAutosaveName length] > 0) if ([_window_frame_autosave_name length] > 0)
{ {
[_window setFrameUsingName: _windowFrameAutosaveName]; [_window setFrameUsingName: _window_frame_autosave_name];
[_window setFrameAutosaveName: _windowFrameAutosaveName]; [_window setFrameAutosaveName: _window_frame_autosave_name];
} }
if ([self shouldCascadeWindows]) if ([self shouldCascadeWindows])
@ -431,7 +436,7 @@
externalNameTable: table externalNameTable: table
withZone: [_owner zone]]) withZone: [_owner zone]])
{ {
_wcFlags.nibIsLoaded = YES; _wcFlags.nib_is_loaded = YES;
if (_window == nil && _document != nil && _owner == _document) if (_window == nil && _document != nil && _owner == _document)
{ {
@ -440,10 +445,10 @@
} }
else else
{ {
if (_windowNibName != nil) if (_window_nib_name != nil)
{ {
NSLog (@"%@: could not load nib named %@.nib", NSLog (@"%@: could not load nib named %@.nib",
[self class], _windowNibName); [self class], _window_nib_name);
} }
} }
} }