Merge pull request #39 from gnustep/xib_document

Xib document
This commit is contained in:
Fred Kiefer 2020-01-20 20:05:06 +01:00 committed by GitHub
commit 2350210dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 5741 additions and 1802 deletions

1
.gitignore vendored
View file

@ -15,6 +15,7 @@ Source/config.h
Source/Info-gnustep.plist
Tests/gui/*/GNUmakefile
Tools/speech/GSSpeechServer.app
*~
# Created by https://www.gitignore.io/api/xcode
# Edit at https://www.gitignore.io/?templates=xcode

100
ChangeLog
View file

@ -1,7 +1,77 @@
2020-01-19 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSNibOutletConnector.h,
* Headers/AppKit/NSNibControlConnector.h,
* Source/GSXibKeyedUnarchiver.m: Remove references of XIB 5.
* Headers/Additions/GNUstepGUI/GSNibLoading.h: Add one method definition.
* Source/GSXibLoader.m,
* Source/GSXibLoading.m: Move helper classes to the correct file.
2020-01-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXib5KeyedUnarchiver.m: Handle dictionary elements correctly.
* Source/NSKeyValueBinding.m: Transform each element of an array.
2020-01-18 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSArrayController.m: Only filter if there is a filter predicate.
* Source/NSTableView.m: Use destionationValue instead of
sourceValueFor: to get the row numbers and the display values.
* Source/GSThemeDrawing.m: Don't use the datasource of the table
directly to get the values to display.
* Source/NSTabView.m: Mark for redisplay when removing tab item.
* Source/NSKeyValueBinding.m: Add some debugging logs.
2020-01-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSToolbarItem.m (-initWithCoder:): Use decodeSizeForKey:.
* Source/GSBindingHelpers.h,
* Source/NSArrayController.m: Add observable array and use it for arrangeObjects.
* Source/GSXib5KeyedUnarchiver.m: Add generic mechanism to decode
keys that include the class name.
Also add header clip view to subviews of scroller.
2020-01-11 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSRuleEditor.h
* Source/NSRuleEditor.m: Add action and target.
* Source/NSPredicateEditor.m: Add encoding and decoding.
* Source/GSXib5KeyedUnarchiver.m: Decode row templates.
2020-01-10 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSKeyValueBinding.h,
* Source/externs.m: Add some more bindings.
* Source/NSPopUpButton.m,
* Source/NSPopUpButtonCell.m,
* Source/NSTableView.m: Use the new bindings.
2020-01-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXib5KeyedUnarchiver.m,
* Source/GSXibKeyedUnarchiver.m,
* Headers/Additions/GNUstepGUI/GSNibLoading.h,
* Headers/Additions/GNUstepGUI/GSXibElement.h,
* Headers/AppKit/NSCell.h,
* Headers/AppKit/NSWindow.h,
* Source/GSCodingFlags.h,
* Source/GSNibLoading.m,
* Source/GSXib5KeyedUnarchiver.h,
* Source/GSXibElement.m,
* Source/GSXibLoader.m,
* Source/NSButtonCell.m,
* Source/NSCell.m,
* Source/NSMatrix.m,
* Source/NSNibBindingConnector.m,
* Source/NSToolbar.m:
Merge XIB document loading from the old Eggplant branch with lots
of cleanup.
* Headers/Additions/GNUstepGUI/GSXibParser.h,
* Source/GSXibParser.m,
* Source/GNUmakefile: Remove now obsolete class.
2020-01-19 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSNibOutletConnector.h,
* Headers/AppKit/NSNibControlConnector.h,
* Source/NSNibOutletConnector.m,
* Source/NSNibControlConnector.m,
* Source/NSNibConnector.m: Add files missing in last commit from Gregory.
@ -22,24 +92,24 @@
YES makes sense only if `keyDown:` is implemented.
(acceptsFirstMouse:): return YES.
* Source/NSStepperCell.m (cellSize): initial implementation. Retruns
* Source/NSStepperCell.m (cellSize): initial implementation. Returns
minimum size based on up and button sizes.
2020-01-07 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSDatePicker.h,
* Headers/AppKit/NSDatePickerCell.h,
* Source/NSDatePicker.m,
* Source/NSDatePickerCell.m: Small cleanup.
* Headers/AppKit/NSDatePicker.h,
* Headers/AppKit/NSDatePickerCell.h,
* Source/NSDatePicker.m,
* Source/NSDatePickerCell.m: Small cleanup.
* Headers/AppKit/AppKit.h
* Headers/AppKit/NSPredicateEditor.h
* Headers/AppKit/NSPredicateEditorRowTemplate.h
* Headers/AppKit/NSRuleEditor.h
* Source/GNUmakefile
* Source/NSPredicateEditor.m
* Source/NSPredicateEditorRowTemplate.m
* Source/NSRuleEditor.m
* Source/externs.m: Add minimal version of predicate editor copied
* Headers/AppKit/NSPredicateEditor.h
* Headers/AppKit/NSPredicateEditorRowTemplate.h
* Headers/AppKit/NSRuleEditor.h
* Source/GNUmakefile
* Source/NSPredicateEditor.m
* Source/NSPredicateEditorRowTemplate.m
* Source/NSRuleEditor.m
* Source/externs.m: Add minimal version of predicate editor copied
over from mySTEP.
2020-01-06 Fred Kiefer <FredKiefer@gmx.de>

View file

@ -77,9 +77,15 @@ typedef struct _GSWindowTemplateFlags
unsigned int autoPositionMask:6;
unsigned int savePosition:1;
unsigned int style:2;
unsigned int _unused:16; // currently not used, contains Cocoa specific info
unsigned int _unused2:3;
unsigned int isNotShadowed:1;
unsigned int autorecalculatesKeyViewLoop:1;
unsigned int _unused:11; // currently not used, contains Cocoa specific info
#else
unsigned int _unused:16; // currently not used, contains Cocoa specific info
unsigned int _unused:11; // currently not used, contains Cocoa specific info
unsigned int autorecalculatesKeyViewLoop:1;
unsigned int isNotShadowed:1;
unsigned int _unused2:3;
unsigned int style:2;
unsigned int savePosition:1;
unsigned int autoPositionMask:6;
@ -213,6 +219,8 @@ typedef struct _GSWindowTemplateFlags
- (NSString *)className;
- (void) setExtension: (NSString *)ext;
- (NSString *)extension;
- (void) setRealObject: (id)obj;
- (id) realObject;
@end
@interface NSCustomView : NSView <GSNibLoading>

View file

@ -38,7 +38,7 @@
@interface GSXibElement: NSObject
{
NSString *type;
NSDictionary *attributes;
NSMutableDictionary *attributes;
NSString *value;
NSMutableDictionary *elements;
NSMutableArray *values;
@ -54,6 +54,7 @@
- (void) setElement: (GSXibElement*)element forKey: (NSString*)key;
- (void) setValue: (NSString*)text;
- (NSString*) attributeForKey: (NSString*)key;
- (void) setAttribute: (NSString*)attribute forKey: (NSString*)key;
- (GSXibElement*) elementForKey: (NSString*)key;
- (NSDictionary *) attributes;
@end

View file

@ -1,53 +0,0 @@
/* <title>GSXibParser</title>
<abstract>Xib v5 (Cocoa XML) parser</abstract>
Copyright (C) 2014 Free Software Foundation, Inc.
Written by: Gregory Casamento <greg.casamento@gmail.com>
Created: March 2014
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_GSXibParser
#define _GNUstep_H_GSXibParser
#import <Foundation/NSObject.h>
@class NSData;
@class NSXMLParser;
@class NSMutableDictionary;
@class GSXibElement;
@class NSMutableArray;
@interface GSXibParser : NSObject
{
NSMutableDictionary *objects;
GSXibElement *currentElement;
NSMutableArray *stack;
NSXMLParser *theParser;
}
- (id) initWithData: (NSData *)data;
- (NSDictionary *) parse;
@end
#endif

View file

@ -156,6 +156,24 @@ enum {
};
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
enum {
NSBackgroundStyleLight = 0,
NSBackgroundStyleDark = 1,
NSBackgroundStyleRaised = 2,
NSBackgroundStyleLowered = 3
};
typedef NSInteger NSBackgroundStyle;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
enum __NSControlSize {
NSControlSizeRegular,
NSControlSizeSmall,
NSControlSizeMini
};
#endif
@interface NSCell : NSObject <NSCopying, NSCoding>
{
// Attributes
@ -188,7 +206,8 @@ enum {
unsigned allows_undo: 1;
unsigned line_break_mode: 3; // 6 values
// total 20 bits. 4 bits extension, 8 bits left.
// 23 bits for NSCell use, 4 bits for subclass use.
// 5 bits remain unused.
int state: 2; // 3 values but one negative
unsigned mnemonic_location: 8;
unsigned control_tint: 3;
@ -204,6 +223,7 @@ enum {
unsigned in_editing: 1;
// Set if cell uses single line mode.
unsigned uses_single_line_mode:1;
unsigned background_style: 2; // 3 values
} _cell;
NSUInteger _mouse_down_flags;
NSUInteger _action_mask;
@ -455,6 +475,8 @@ enum {
ofView:(NSView *)controlView
untilMouseUp:(BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (NSBackgroundStyle)backgroundStyle;
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle;
- (NSUInteger)hitTestForEvent:(NSEvent *)event
inRect:(NSRect)cellFrame
ofView:(NSView *)controlView;

View file

@ -118,7 +118,9 @@ APPKIT_EXPORT NSString *NSHiddenBinding;
APPKIT_EXPORT NSString *NSSelectedIndexBinding;
APPKIT_EXPORT NSString *NSSelectedObjectBinding;
APPKIT_EXPORT NSString *NSSelectedTagBinding;
APPKIT_EXPORT NSString *NSSelectedValueBinding;
APPKIT_EXPORT NSString *NSSelectionIndexesBinding;
APPKIT_EXPORT NSString *NSSortDescriptorsBinding;
APPKIT_EXPORT NSString *NSTextColorBinding;
APPKIT_EXPORT NSString *NSTitleBinding;
APPKIT_EXPORT NSString *NSToolTipBinding;

View file

@ -58,7 +58,8 @@ extern NSString * const NSRuleEditorPredicateCompoundType;
extern NSString *NSRuleEditorRowsDidChangeNotification;
@interface NSRuleEditor : NSControl {
id _target;
SEL _action;
}
- (void) addRow: (id)sender;

View file

@ -97,25 +97,44 @@ enum {
enum {
NSBorderlessWindowMask = 0,
NSTitledWindowMask = 1,
NSClosableWindowMask = 2,
NSMiniaturizableWindowMask = 4,
NSResizableWindowMask = 8,
NSClosableWindowMask = 1 << 1,
NSMiniaturizableWindowMask = 1 << 2,
NSResizableWindowMask = 1 << 3,
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
NSTexturedBackgroundWindowMask = 256,
NSTexturedBackgroundWindowMask = 1 << 8,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
NSUnscaledWindowMask = 2048,
NSUnifiedTitleAndToolbarWindowMask = 4096,
NSUnscaledWindowMask = 1 << 11,
NSUnifiedTitleAndToolbarWindowMask = 1 << 12,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
NSWindowStyleMaskHUDWindow = 1 << 13,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
NSFullScreenWindowMask = 16384,
NSFullScreenWindowMask = 1 << 14,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
NSFullSizeContentViewWindowMask = 1 << 15,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
NSWindowStyleMaskBorderless = NSBorderlessWindowMask,
NSWindowStyleMaskTitled = NSTitledWindowMask,
NSWindowStyleMaskClosable = NSClosableWindowMask,
NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask,
NSWindowStyleMaskResizable = NSResizableWindowMask,
NSWindowStyleMaskUtilityWindow = 1 << 4,
NSWindowStyleMaskDocModalWindow = 1 << 6,
// Specifies that a panel that does not activate the owning application
NSWindowStyleMaskNonactivatingPanel = 1 << 7,
NSWindowStyleMaskTexturedBackground = NSTexturedBackgroundWindowMask,
NSWindowStyleMaskUnifiedTitleAndToolbar = NSUnifiedTitleAndToolbarWindowMask,
NSWindowStyleMaskFullScreen = NSFullScreenWindowMask,
NSWindowStyleMaskFullSizeContentView = NSFullSizeContentViewWindowMask,
#endif
NSIconWindowMask = 64, /* GNUstep extension - app icon window */
NSMiniWindowMask = 128 /* GNUstep extension - miniwindows */
};
typedef NSUInteger NSWindowStyleMask;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
enum {

View file

@ -317,8 +317,8 @@ GSXibElement.m \
GSXibLoader.m \
GSXibLoading.m \
GSXibKeyedUnarchiver.m \
GSXib5KeyedUnarchiver.m \
GSXibObjectContainer.m \
GSXibParser.m \
GSHelpAttachment.m
# Turn off NSMenuItem warning that NSMenuItem conforms to <NSObject>,
@ -583,7 +583,6 @@ GSXibElement.h \
GSXibLoading.h \
GSXibKeyedUnarchiver.h \
GSXibObjectContainer.h \
GSXibParser.h \
GSHelpAttachment.h
libgnustep-gui_HEADER_FILES = ${GUI_HEADERS}

View file

@ -78,4 +78,10 @@
@interface GSKeyValueAndBinding : GSKeyValueBinding
@end
@interface GSObservableArray : NSArray
{
NSArray *_array;
}
@end
#endif //_GS_BINDING_HELPER_H

389
Source/GSCodingFlags.h Normal file
View file

@ -0,0 +1,389 @@
/*
GSCodingFlags.h
Define flags used in Cocoa for keyed coding.
Copyright (C) 2019 Free Software Foundation, Inc.
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: 12.2019
Original code by: Jonathan Gillaspie <jonathan.gillaspie@testplant.com>,
Frank Le Grand <frank.legrand@testplant.com>
Paul Landers <paul.landers@testplant.com> and
Doug Simons <doug.simons@testplant.com>
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_GSCodingFlags
#define _GNUstep_H_GSCodingFlags
#import "GNUstepGUI/GSNibLoading.h"
typedef struct _GSCellFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int state:1;
unsigned int highlighted:1;
unsigned int disabled:1;
unsigned int editable:1;
NSCellType type:2;
unsigned int vCentered:1;
unsigned int hCentered:1;
unsigned int bordered:1;
unsigned int bezeled:1;
unsigned int selectable:1;
unsigned int scrollable:1;
unsigned int continuous:1;
unsigned int actOnMouseDown:1;
unsigned int isLeaf:1;
unsigned int invalidObjectValue:1;
unsigned int invalidFont:1;
NSLineBreakMode lineBreakMode:3;
unsigned int weakTargetHelperFlag:1;
unsigned int allowsAppearanceEffects:1;
unsigned int singleLineMode:1;
unsigned int actOnMouseDragged:1;
unsigned int isLoaded:1;
unsigned int truncateLastLine:1;
unsigned int dontActOnMouseUp:1;
unsigned int isWhite:1;
unsigned int useUserKeyEquivalent:1;
unsigned int showsFirstResponder:1;
unsigned int focusRingType:2;
#else
unsigned int focusRingType:2;
unsigned int showsFirstResponder:1;
unsigned int useUserKeyEquivalent:1;
unsigned int isWhite:1;
unsigned int dontActOnMouseUp:1;
unsigned int truncateLastLine:1;
unsigned int isLoaded:1;
unsigned int actOnMouseDragged:1;
unsigned int singleLineMode:1;
unsigned int allowsAppearanceEffects:1;
unsigned int weakTargetHelperFlag:1;
NSLineBreakMode lineBreakMode:3;
unsigned int invalidFont:1;
unsigned int invalidObjectValue:1;
unsigned int isLeaf:1;
unsigned int actOnMouseDown:1;
unsigned int continuous:1;
unsigned int scrollable:1;
unsigned int selectable:1;
unsigned int bezeled:1;
unsigned int bordered:1;
unsigned int hCentered:1;
unsigned int vCentered:1;
NSCellType type:2;
unsigned int editable:1;
unsigned int disabled:1;
unsigned int highlighted:1;
unsigned int state:1;
#endif
} GSCellFlags;
typedef union _GSCellFlagsUnion
{
GSCellFlags flags;
uint32_t value;
} GSCellFlagsUnion;
typedef struct _GSCellflags2
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int unused1:1;
unsigned int allowsEditingTextAttributes:1;
unsigned int importsGraphics:1;
unsigned int alignment:3;
unsigned int refusesFirstResponder:1;
unsigned int allowsMixedState:1;
unsigned int unused2:1;
unsigned int sendsActionOnEndEditing:1;
unsigned int unused3:2;
unsigned int controlSize:3;
unsigned int unused4:4;
unsigned int doesNotAllowUndo:1;
unsigned int lineBreakMode:3;
unsigned int unused5:1;
unsigned int controlTint:3;
unsigned int unused6:5;
#else
unsigned int unused6:5;
unsigned int controlTint:3;
unsigned int unused5:1;
unsigned int lineBreakMode:3;
unsigned int doesNotAllowUndo:1;
unsigned int unused4:4;
unsigned int controlSize:3;
unsigned int unused3:2;
unsigned int sendsActionOnEndEditing:1;
unsigned int unused2:1;
unsigned int allowsMixedState:1;
unsigned int refusesFirstResponder:1;
unsigned int alignment:3;
unsigned int importsGraphics:1;
unsigned int allowsEditingTextAttributes:1;
unsigned int unused1:1;
#endif
} GSCellFlags2;
typedef union _GSCellFlags2Union
{
GSCellFlags2 flags;
uint32_t value;
} GSCellFlags2Union;
typedef struct _GSButtonCellFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isPushin:1;
unsigned int changeContents:1;
unsigned int changeBackground:1;
unsigned int changeGray:1;
unsigned int highlightByContents:1;
unsigned int highlightByBackground:1;
unsigned int highlightByGray:1;
unsigned int drawing:1;
unsigned int isBordered:1;
unsigned int imageDoesOverlap:1;
unsigned int isHorizontal:1;
unsigned int isBottomOrLeft:1;
unsigned int isImageAndText:1;
unsigned int isImageSizeDiff:1;
unsigned int hasKeyEquiv:1;
unsigned int lastState:1;
unsigned int isTransparent:1;
unsigned int inset:2; // inset:2
unsigned int doesNotDimImage:1; //doesn't dim:1
unsigned int gradient:3; // gradient:3
unsigned int useButtonImageSource:1;
unsigned int unused2:8; // alt mnemonic loc.
#else
unsigned int unused2:8; // alt mnemonic loc.
unsigned int useButtonImageSource:1;
unsigned int gradient:3; // gradient:3
unsigned int doesNotDimImage:1; // doesn't dim:1
unsigned int inset:2; // inset:2
unsigned int isTransparent:1;
unsigned int lastState:1;
unsigned int hasKeyEquiv:1;
unsigned int isImageSizeDiff:1;
unsigned int isImageAndText:1;
unsigned int isBottomOrLeft:1;
unsigned int isHorizontal:1;
unsigned int imageDoesOverlap:1;
unsigned int isBordered:1;
unsigned int drawing:1;
unsigned int highlightByGray:1;
unsigned int highlightByBackground:1;
unsigned int highlightByContents:1;
unsigned int changeGray:1;
unsigned int changeBackground:1;
unsigned int changeContents:1;
unsigned int isPushin:1;
#endif
} GSButtonCellFlags;
typedef union _GSButtonCellFlagsUnion
{
GSButtonCellFlags flags;
uint32_t value;
} GSButtonCellFlagsUnion;
typedef struct _GSButtonCellFlags2 {
#if GS_WORDS_BIGENDIAN == 1
unsigned int keyEquivalentModifierMask:24;
unsigned int imageScaling:2;
unsigned int bezelStyle2:1;
unsigned int mouseInside:1;
unsigned int showsBorderOnlyWhileMouseInside:1;
unsigned int bezelStyle:3;
#else
unsigned int bezelStyle:3;
unsigned int showsBorderOnlyWhileMouseInside:1;
unsigned int mouseInside:1;
unsigned int bezelStyle2:1;
unsigned int imageScaling:2;
unsigned int keyEquivalentModifierMask:24;
#endif
} GSButtonCellFlags2;
typedef union _GSButtonCellFlags2Union
{
GSButtonCellFlags2 flags;
uint32_t value;
} GSButtonCellFlags2Union;
typedef struct _GSvFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHidden:1;
unsigned int unused1:3;
unsigned int unused2:4;
unsigned int unused3:4;
unsigned int unused4:4;
unsigned int unused5:4;
unsigned int unused6:3;
unsigned int autoresizesSubviews:1;
unsigned int unused7:2;
unsigned int autoresizingMask:6;
#else
unsigned int autoresizingMask:6;
unsigned int unused7:2;
unsigned int autoresizesSubviews:1;
unsigned int unused6:3;
unsigned int unused5:4;
unsigned int unused4:4;
unsigned int unused3:4;
unsigned int unused2:4;
unsigned int unused1:3;
unsigned int isHidden:1;
#endif
} GSvFlags;
typedef union _GSvFlagsUnion
{
GSvFlags flags;
uint32_t value;
} GSvFlagsUnion;
typedef struct _GSTabViewTypeFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int reserved1:1;
unsigned int controlTint:3;
unsigned int controlSize:2;
unsigned int reserved2:18;
unsigned int tabPosition:5;
unsigned int tabViewBorderType:3;
#else
unsigned int tabViewBorderType:3;
unsigned int tabPosition:5;
unsigned int reserved2:18;
unsigned int controlSize:2;
unsigned int controlTint:3;
unsigned int reserved1:1;
#endif
} GSTabViewTypeFlags;
typedef union _GSTabViewTypeFlagsUnion
{
GSTabViewTypeFlags flags;
unsigned int value;
} GSTabViewTypeFlagsUnion;
/*
* Nib compatibility struct. This structure is used to
* pull the attributes out of the nib that we need to fill
* in the flags.
*/
typedef struct _tableViewFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int columnOrdering:1;
unsigned int columnResizing:1;
unsigned int drawsGrid:1;
unsigned int emptySelection:1;
unsigned int multipleSelection:1;
unsigned int columnSelection:1;
unsigned int unknown1:1;
unsigned int columnAutosave:1;
unsigned int alternatingRowBackgroundColors:1;
unsigned int unknown2:3;
unsigned int _unused:20;
#else
unsigned int _unused:20;
unsigned int unknown2:3;
unsigned int alternatingRowBackgroundColors:1;
unsigned int columnAutosave:1;
unsigned int unknown1:1;
unsigned int columnSelection:1;
unsigned int multipleSelection:1;
unsigned int emptySelection:1;
unsigned int drawsGrid:1;
unsigned int columnResizing:1;
unsigned int columnOrdering:1;
#endif
} GSTableViewFlags;
typedef union _GSTableViewFlagsUnion
{
GSTableViewFlags flags;
uint32_t value;
} GSTableViewFlagsUnion;
typedef union _GSWindowTemplateFlagsUnion
{
GSWindowTemplateFlags flags;
uint32_t value;
} GSWindowTemplateFlagsUnion;
typedef struct _GSMatrixFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHighlight:1;
unsigned int isRadio:1;
unsigned int isList:1;
unsigned int allowsEmptySelection:1;
unsigned int autoScroll:1;
unsigned int selectionByRect:1;
unsigned int drawCellBackground:1;
unsigned int drawBackground:1;
unsigned int autosizesCells:1;
unsigned int drawingAncestor:1;
unsigned int tabKeyTraversesCells:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int canSearchIncrementally:1;
unsigned int unused:19;
#else
unsigned int unused:19;
unsigned int canSearchIncrementally:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int tabKeyTraversesCells:1;
unsigned int drawingAncestor:1;
unsigned int autosizesCells:1;
unsigned int drawBackground:1;
unsigned int drawCellBackground:1;
unsigned int selectionByRect:1;
unsigned int autoScroll:1;
unsigned int allowsEmptySelection:1;
unsigned int isList:1;
unsigned int isRadio:1;
unsigned int isHighlight:1;
#endif
} GSMatrixFlags;
typedef union _GSMatrixFlagsUnion
{
GSMatrixFlags flags;
unsigned int value;
} GSMatrixFlagsUnion;
#endif // _GNUstep_H_GSCodingFlags

View file

@ -52,6 +52,7 @@
#import "GNUstepGUI/GSNibLoading.h"
#import "AppKit/NSApplication.h"
#import "AppKit/NSFontManager.h"
#import "AppKit/NSImage.h"
#import "AppKit/NSMenuItem.h"
#import "AppKit/NSMenuView.h"
@ -326,10 +327,12 @@ static BOOL _isInInterfaceBuilder = NO;
_flags.isDeferred = deferred;
_flags.isOneShot = oneShot;
_flags.isVisible = visible;
_flags.isNotShadowed = ![window hasShadow];
_flags.wantsToBeColor = wantsToBeColor;
_flags.dynamicDepthLimit = [window hasDynamicDepthLimit];
_flags.autoPositionMask = autoPositionMask;
_flags.savePosition = YES; // not yet implemented.
_flags.autorecalculatesKeyViewLoop = [window autorecalculatesKeyViewLoop];
}
}
return self;
@ -343,14 +346,26 @@ static BOOL _isInInterfaceBuilder = NO;
{
ASSIGN(_viewClass, [coder decodeObjectForKey: @"NSViewClass"]);
}
else
{
ASSIGN(_viewClass, @"NSView");
}
if ([coder containsValueForKey: @"NSWindowClass"])
{
ASSIGN(_windowClass, [coder decodeObjectForKey: @"NSWindowClass"]);
}
else
{
ASSIGN(_windowClass, @"NSWindow");
}
if ([coder containsValueForKey: @"NSWindowStyleMask"])
{
_windowStyle = [coder decodeIntForKey: @"NSWindowStyleMask"];
}
else
{
_windowStyle = 0;
}
if ([coder containsValueForKey: @"NSWindowBacking"])
{
_backingStoreType = [coder decodeIntForKey: @"NSWindowBacking"];
@ -485,6 +500,8 @@ static BOOL _isInInterfaceBuilder = NO;
// [_realObject setAutoPosition: _flags.autoPosition];
[_realObject setDynamicDepthLimit: _flags.dynamicDepthLimit];
// [_realObject setFrameAutosaveName: _autosaveName]; // done after setting the min/max sizes
[_realObject setHasShadow: !_flags.isNotShadowed];
[_realObject setAutorecalculatesKeyViewLoop: _flags.autorecalculatesKeyViewLoop];
// reset attributes...
[_realObject setContentView: _view];
@ -1001,9 +1018,14 @@ static BOOL _isInInterfaceBuilder = NO;
if (GSObjCIsKindOf(aClass, [NSApplication class]) ||
[_className isEqual: @"NSApplication"])
{
{
_object = RETAIN([aClass sharedApplication]);
}
}
else if ((GSObjCIsKindOf(aClass, [NSFontManager class])) ||
([_className isEqual: @"NSFontManager"]))
{
_object = RETAIN([aClass sharedFontManager]);
}
else
{
_object = [[aClass allocWithZone: NSDefaultMallocZone()] init];

View file

@ -72,6 +72,8 @@
- (void) _willDisplayCell: (NSCell*)cell
forTableColumn: (NSTableColumn *)tb
row: (NSInteger)index;
- (id)_objectValueForTableColumn: (NSTableColumn *)tb
row: (NSInteger)index;
@end
@interface NSCell (Private)
@ -3105,7 +3107,6 @@ typedef enum {
NSInteger numberOfColumns = [tableView numberOfColumns];
// NSIndexSet *selectedRows = [tableView selectedRowIndexes];
// NSColor *backgroundColor = [tableView backgroundColor];
id dataSource = [tableView dataSource];
CGFloat *columnOrigins = [tableView _columnOrigins];
NSInteger editedRow = [tableView editedRow];
NSInteger editedColumn = [tableView editedColumn];
@ -3122,11 +3123,6 @@ typedef enum {
NSColor *selectedTextColor = [self colorNamed: @"highlightedTableRowTextColor"
state: GSThemeNormalState];
if (dataSource == nil)
{
return;
}
/* Using columnAtPoint: here would make it called twice per row per drawn
rect - so we avoid it and do it natively */
@ -3170,9 +3166,8 @@ typedef enum {
}
else
{
[cell setObjectValue: [dataSource tableView: tableView
objectValueForTableColumn: tb
row: rowIndex]];
[cell setObjectValue: [tableView _objectValueForTableColumn: tb
row: rowIndex]];
}
drawingRect = [tableView frameOfCellAtColumn: i
row: rowIndex];

View file

@ -0,0 +1,47 @@
/** <title>GSXib5KeyedUnarchiver.h</title>
<abstract>The XIB 5 keyed unarchiver</abstract>
Copyright (C) 2016,2017 Free Software Foundation, Inc.
Author: Marcian Lytwyn <gnustep@advcsi.com>
Date: 12/28/16
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import "GNUstepGUI/GSXibKeyedUnarchiver.h"
@class GSXibElement;
@interface GSXib5KeyedUnarchiver : GSXibKeyedUnarchiver
{
GSXibElement *_IBObjectContainer;
GSXibElement *_connectionRecords;
GSXibElement *_objectRecords;
GSXibElement *_orderedObjects;
GSXibElement *_flattenedProperties;
GSXibElement *_runtimeAttributes;
NSMutableDictionary *_orderedObjectsDict;
NSArray *_resources;
}
- (NSRange) decodeRangeForKey: (NSString*)key;
@end

File diff suppressed because it is too large Load diff

View file

@ -38,7 +38,7 @@
andAttributes: (NSDictionary*)attribs
{
ASSIGN(type, typeName);
ASSIGN(attributes, attribs);
attributes = [attribs mutableCopy];
elements = [[NSMutableDictionary alloc] init];
values = [[NSMutableArray alloc] init];
@ -95,6 +95,11 @@
return [attributes objectForKey: key];
}
- (void) setAttribute: (NSString*)attribute forKey: (NSString*)key
{
[attributes setObject: attribute forKey: key];
}
- (GSXibElement*) elementForKey: (NSString*)key
{
return [elements objectForKey: key];

View file

@ -1,29 +1,32 @@
/** <title>GSXibKeyedUnarchiver.m</title>
<abstract>
These are templates for use with OSX XIB 5 files. These classes are the
templates and other things which are needed for reading XIB 5 files.
These are templates for use with OSX XIB files. These classes are the
templates and other things which are needed for reading XIB files.
</abstract>
Copyright (C) 2005, 2017 Free Software Foundation, Inc.
Copyright (C) 2010, 2012, 2017 Free Software Foundation, Inc.
File created by Marcian Lytwyn on 12/30/16 from original code by:
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2010
Author: Gregory John Casamento
Date: 2003, 2005
Date: 2012
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
@ -39,167 +42,160 @@
- (NSData *) _preProcessXib: (NSData *)data
{
NSData *result = nil;
NSData *result = data;
#if GNUSTEP_BASE_HAVE_LIBXML
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data
options:0
error:NULL];
result = data;
if (document == nil)
{
NSLog(@"%s:DOCUMENT IS NIL: %@\n", __PRETTY_FUNCTION__, document);
}
else
{
// Test to see if this is an Xcode 5 XIB...
NSArray *documentNodes = [document nodesForXPath:@"/document"
error:NULL];
if ([documentNodes count] > 0)
{
NSLog(@"Unsupported... This is an XCode 5 XIB file.");
return nil;
}
NSArray *customClassNodes = [document nodesForXPath:@"//dictionary[@key=\"flattenedProperties\"]/"
@"string[contains(@key,\"CustomClassName\")]"
error:NULL];
NSMutableDictionary *customClassDict = [NSMutableDictionary dictionary];
if (customClassNodes)
{
NSDebugLLog(@"PREXIB", @"%s:customClassNodes: %@\n", __PRETTY_FUNCTION__, customClassNodes);
// Replace the NSXMLNodes with a dictionary...
NSInteger index = 0;
for (index = 0; index < [customClassNodes count]; ++index)
{
id node = [customClassNodes objectAtIndex:index];
if ([node isMemberOfClass:[NSXMLElement class]])
{
NSString *key = [[node attributeForName:@"key"] stringValue];
if ([key rangeOfString:@"CustomClassName"].location != NSNotFound)
{
[customClassDict setObject:[node stringValue] forKey:key];
}
}
}
}
else
{
NSArray *customClassNodes = [document nodesForXPath:@"//dictionary[@key=\"flattenedProperties\"]/"
@"string[contains(@key,\"CustomClassName\")]"
error:NULL];
NSMutableDictionary *customClassDict = [NSMutableDictionary dictionary];
if (customClassNodes)
{
NSDebugLLog(@"PREXIB", @"%s:customClassNodes: %@\n", __PRETTY_FUNCTION__, customClassNodes);
// Replace the NSXMLNodes with a dictionary...
NSInteger index = 0;
for (index = 0; index < [customClassNodes count]; ++index)
{
id node = [customClassNodes objectAtIndex:index];
if ([node isMemberOfClass:[NSXMLElement class]])
{
NSString *key = [[node attributeForName:@"key"] stringValue];
if ([key rangeOfString:@"CustomClassName"].location != NSNotFound)
{
[customClassDict setObject:[node stringValue] forKey:key];
}
}
}
}
else
{
NSArray *flatProps = [document nodesForXPath:@"//object[@key=\"flattenedProperties\"]" error:NULL];
if ([flatProps count] == 1)
{
NSInteger index = 0;
NSArray *xmlKeys = [[flatProps objectAtIndex:0] nodesForXPath:@"//object[@key=\"flattenedProperties\"]/object[@key=\"dict.sortedKeys\"]/*" error:NULL];
NSArray *xmlObjs = [[flatProps objectAtIndex:0] nodesForXPath:@"//object[@key=\"flattenedProperties\"]/object[@key=\"dict.values\"]/*" error:NULL];
if ([xmlKeys count] != [xmlObjs count])
{
NSLog(@"%s:keys to objs count mismatch - keys: %d objs: %d\n", __PRETTY_FUNCTION__,
(int)[xmlKeys count], (int)[xmlObjs count]);
}
else
{
for (index = 0; index < [xmlKeys count]; ++index)
{
id key = [[xmlKeys objectAtIndex:index] stringValue];
if ([key rangeOfString:@"CustomClassName"].location != NSNotFound)
{
// NSString *obj = [[xmlObjs objectAtIndex:index] stringValue];
[customClassDict setObject:[[xmlObjs objectAtIndex:index] stringValue] forKey:key];
}
}
}
}
}
NSDebugLLog(@"PREXIB", @"%s:customClassDict: %@\n", __PRETTY_FUNCTION__, customClassDict);
if ([customClassDict count] > 0)
{
NSArray *objectRecords = nil;
NSEnumerator *en = [[customClassDict allKeys] objectEnumerator];
NSString *key = nil;
while ((key = [en nextObject]) != nil)
{
NSString *keyValue = [key stringByReplacingOccurrencesOfString:@".CustomClassName" withString:@""];
NSString *className = [customClassDict objectForKey: key];
NSString *objectRecordXpath = nil;
objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/"
@"int[@key=\"objectID\"][text()=\"%@\"]/../reference",
keyValue];
objectRecords = [document nodesForXPath: objectRecordXpath error: NULL];
if (objectRecords == nil)
{
// If that didn't work then it could be a 4.6+ XIB...
objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/"
@"string[@key=\"id\"][text()=\"%@\"]/../reference",
keyValue];
objectRecords = [document nodesForXPath: objectRecordXpath error: NULL];
}
NSString *refId = nil;
if ([objectRecords count] > 0)
{
id record = nil;
NSEnumerator *oen = [objectRecords objectEnumerator];
while ((record = [oen nextObject]) != nil)
{
if ([record isMemberOfClass:[NSXMLElement class]])
{
if([[[record attributeForName:@"key"] stringValue] isEqualToString:@"object"])
{
NSArray *classNodes = nil;
id classNode = nil;
NSString *refXpath = nil;
refId = [[record attributeForName:@"ref"] stringValue];
refXpath = [NSString stringWithFormat:@"//object[@id=\"%@\"]",refId];
classNodes = [document nodesForXPath:refXpath
error:NULL];
if([classNodes count] > 0)
{
id classAttr = nil;
Class cls = NSClassFromString(className);
classNode = [classNodes objectAtIndex:0];
classAttr = [classNode attributeForName:@"class"];
[classAttr setStringValue:className];
if (cls != nil)
{
if ([cls respondsToSelector:@selector(cellClass)])
{
NSArray *cellNodes = nil;
id cellNode = nil;
id cellClass = [cls cellClass];
NSString *cellXpath = [NSString stringWithFormat:@"//object[@id=\"%@\"]/object[@key=\"NSCell\"]",refId];
cellNodes = [document nodesForXPath:cellXpath
error:NULL];
if ([cellNodes count] > 0)
{
NSString *cellClassString = NSStringFromClass(cellClass);
id cellAttr = nil;
cellNode = [cellNodes objectAtIndex:0];
cellAttr = [cellNode attributeForName:@"class"];
[cellAttr setStringValue:cellClassString];
}
}
}
}
}
}
}
}
}
}
result = [document XMLData];
RELEASE(document);
}
{
NSArray *flatProps = [document nodesForXPath:@"//object[@key=\"flattenedProperties\"]" error:NULL];
if ([flatProps count] == 1)
{
NSInteger index = 0;
NSArray *xmlKeys = [[flatProps objectAtIndex:0] nodesForXPath:
@"//object[@key=\"flattenedProperties\"]/object[@key=\"dict.sortedKeys\"]/*" error:NULL];
NSArray *xmlObjs = [[flatProps objectAtIndex:0] nodesForXPath:
@"//object[@key=\"flattenedProperties\"]/object[@key=\"dict.values\"]/*" error:NULL];
if ([xmlKeys count] != [xmlObjs count])
{
NSLog(@"%s:keys to objs count mismatch - keys: %d objs: %d\n", __PRETTY_FUNCTION__,
(int)[xmlKeys count], (int)[xmlObjs count]);
}
else
{
for (index = 0; index < [xmlKeys count]; ++index)
{
id key = [[xmlKeys objectAtIndex:index] stringValue];
if ([key rangeOfString:@"CustomClassName"].location != NSNotFound)
{
// NSString *obj = [[xmlObjs objectAtIndex:index] stringValue];
[customClassDict setObject:[[xmlObjs objectAtIndex:index] stringValue] forKey:key];
}
}
}
}
}
NSDebugLLog(@"PREXIB", @"%s:customClassDict: %@\n", __PRETTY_FUNCTION__, customClassDict);
if ([customClassDict count] > 0)
{
NSArray *objectRecords = nil;
NSEnumerator *en = [[customClassDict allKeys] objectEnumerator];
NSString *key = nil;
while ((key = [en nextObject]) != nil)
{
NSString *keyValue = [key stringByReplacingOccurrencesOfString:@".CustomClassName" withString:@""];
NSString *className = [customClassDict objectForKey: key];
NSString *objectRecordXpath = nil;
objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/"
@"int[@key=\"objectID\"][text()=\"%@\"]/../reference",
keyValue];
objectRecords = [document nodesForXPath: objectRecordXpath error: NULL];
if (objectRecords == nil)
{
// If that didn't work then it could be a 4.6+ XIB...
objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/"
@"string[@key=\"id\"][text()=\"%@\"]/../reference",
keyValue];
objectRecords = [document nodesForXPath: objectRecordXpath error: NULL];
}
NSString *refId = nil;
if ([objectRecords count] > 0)
{
id record = nil;
NSEnumerator *oen = [objectRecords objectEnumerator];
while ((record = [oen nextObject]) != nil)
{
if ([record isMemberOfClass:[NSXMLElement class]])
{
if([[[record attributeForName:@"key"] stringValue] isEqualToString:@"object"])
{
NSArray *classNodes = nil;
id classNode = nil;
NSString *refXpath = nil;
refId = [[record attributeForName:@"ref"] stringValue];
refXpath = [NSString stringWithFormat:@"//object[@id=\"%@\"]",refId];
classNodes = [document nodesForXPath:refXpath
error:NULL];
if([classNodes count] > 0)
{
id classAttr = nil;
Class cls = NSClassFromString(className);
classNode = [classNodes objectAtIndex:0];
classAttr = [classNode attributeForName:@"class"];
[classAttr setStringValue:className];
if (cls != nil)
{
if ([cls respondsToSelector:@selector(cellClass)])
{
NSArray *cellNodes = nil;
id cellNode = nil;
id cellClass = [cls cellClass];
NSString *cellXpath = [NSString stringWithFormat:
@"//object[@id=\"%@\"]/object[@key=\"NSCell\"]",refId];
cellNodes = [document nodesForXPath:cellXpath
error:NULL];
if ([cellNodes count] > 0)
{
NSString *cellClassString = NSStringFromClass(cellClass);
id cellAttr = nil;
cellNode = [cellNodes objectAtIndex:0];
cellAttr = [cellNode attributeForName:@"class"];
[cellAttr setStringValue:cellClassString];
}
}
}
}
}
}
}
}
}
}
result = [document XMLData];
RELEASE(document);
}
#endif
return result;
@ -235,7 +231,7 @@
theParser = [[NSXMLParser alloc] initWithData: theData];
[theParser setDelegate: self];
NS_DURING
{
// Parse the XML data
@ -249,7 +245,7 @@
NS_ENDHANDLER
DESTROY(theParser);
#endif
#endif
return self;
}
@ -405,7 +401,7 @@ didStartElement: (NSString*)elementName
// pop
currentElement = last;
if (r != o)
{
[delegate unarchiver: self
@ -443,7 +439,7 @@ didStartElement: (NSString*)elementName
// Balance the retain above
RELEASE(o);
if (objID != nil)
{
NSDebugLLog(@"XIB", @"decoded object %@ for id %@", o, objID);
@ -454,7 +450,7 @@ didStartElement: (NSString*)elementName
/*
This method is a copy of decodeObjectForXib:forClassName:withKey:
The only difference being in the way we decode the object and the
The only difference being in the way we decode the object and the
missing context switch.
*/
- (id) decodeDictionaryForXib: (GSXibElement*)element
@ -508,7 +504,7 @@ didStartElement: (NSString*)elementName
}
// Balance the retain above
RELEASE(o);
if (objID != nil)
{
NSDebugLLog(@"XIB", @"decoded object %@ for id %@", o, objID);
@ -547,14 +543,15 @@ didStartElement: (NSString*)elementName
}
else if ([@"string" isEqualToString: elementName])
{
NSString *type = [element attributeForKey: @"type"];
id new = [element value];
if ([type isEqualToString: @"base64-UTF8"])
// Handle newer format as well
if ([[element attributeForKey: @"type"] isEqualToString: @"base64-UTF8"] ||
[[element attributeForKey: @"base64-UTF8"] boolValue])
{
NSData *d = [[NSData alloc] initWithBase64EncodedString: new
options: 0];
new = AUTORELEASE([[NSString alloc] initWithData: d
options: NSDataBase64DecodingIgnoreUnknownCharacters];
new = AUTORELEASE([[NSString alloc] initWithData: d
encoding: NSUTF8StringEncoding]);
RELEASE(d);
}
@ -565,7 +562,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"int" isEqualToString: elementName])
@ -574,7 +571,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"double" isEqualToString: elementName])
@ -583,7 +580,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"bool" isEqualToString: elementName])
@ -592,7 +589,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"integer" isEqualToString: elementName])
@ -602,7 +599,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"real" isEqualToString: elementName])
@ -612,7 +609,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"boolean" isEqualToString: elementName])
@ -622,37 +619,37 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"point" isEqualToString: elementName])
{
NSPoint point = [self decodePointForKey: [element attributeForKey: @"key"]];
id new = [NSValue valueWithPoint: point];
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"size" isEqualToString: elementName])
{
NSSize size = [self decodeSizeForKey: [element attributeForKey: @"key"]];
id new = [NSValue valueWithSize: size];
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"rect" isEqualToString: elementName])
{
NSRect rect = [self decodeRectForKey: [element attributeForKey: @"key"]];
id new = [NSValue valueWithRect: rect];
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"reference" isEqualToString: elementName])
@ -692,7 +689,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"bytes" isEqualToString: elementName])
@ -702,7 +699,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"array" isEqualToString: elementName])
@ -732,7 +729,7 @@ didStartElement: (NSString*)elementName
}
else
{
NSLog(@"Unknown element type %@", elementName);
//NSLog(@"Unknown element type %@", elementName);
}
return nil;
@ -970,7 +967,8 @@ didStartElement: (NSString*)elementName
if (o != nil)
{
if ([o isKindOfClass: [NSNumber class]] == YES)
if (([o isKindOfClass: [NSNumber class]] == YES) ||
([o isKindOfClass: [NSString class]] == YES))
{
long long l = [o longLongValue];

View file

@ -35,20 +35,16 @@
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSXMLParser.h>
#import <Foundation/NSXMLDocument.h>
#import <Foundation/NSXMLElement.h>
#import "AppKit/NSApplication.h"
#import "AppKit/NSMenu.h"
#import "AppKit/NSNib.h"
#import "AppKit/NSNibLoading.h"
#import "GNUstepGUI/GSModelLoaderFactory.h"
#import "GNUstepGUI/GSNibLoading.h"
#import "GNUstepGUI/GSXibLoading.h"
#import "GNUstepGUI/GSXibParser.h"
#import "GNUstepGUI/GSXibObjectContainer.h"
#import "GNUstepGUI/GSXibElement.h"
#import "GNUstepGUI/GSXibKeyedUnarchiver.h"
#import "GSXib5KeyedUnarchiver.h"
@interface NSApplication (NibCompatibility)
- (void) _setMainMenu: (NSMenu*)aMenu;
@ -58,16 +54,6 @@
- (BOOL) _isMainMenu;
@end
@interface NSCustomObject (NibCompatibility)
- (id) realObject;
- (void) setRealObject: (id)obj;
- (NSString *)className;
@end
@interface NSNibConnector (NibCompatibility)
- (id) nibInstantiate;
@end
@implementation NSMenu (XibCompatibility)
- (BOOL) _isMainMenu
@ -79,820 +65,6 @@
@end
@implementation FirstResponder
+ (id) allocWithZone: (NSZone*)zone
{
return nil;
}
@end
@implementation IBClassDescriptionSource
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"majorKey"])
{
ASSIGN(majorKey, [coder decodeObjectForKey: @"majorKey"]);
}
if ([coder containsValueForKey: @"minorKey"])
{
ASSIGN(minorKey, [coder decodeObjectForKey: @"minorKey"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(majorKey);
DESTROY(minorKey);
[super dealloc];
}
@end
@implementation IBPartialClassDescription
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"className"])
{
ASSIGN(className, [coder decodeObjectForKey: @"className"]);
}
if ([coder containsValueForKey: @"superclassName"])
{
ASSIGN(superclassName, [coder decodeObjectForKey: @"superclassName"]);
}
if ([coder containsValueForKey: @"actions"])
{
ASSIGN(actions, [coder decodeObjectForKey: @"actions"]);
}
if ([coder containsValueForKey: @"outlets"])
{
ASSIGN(outlets, [coder decodeObjectForKey: @"outlets"]);
}
if ([coder containsValueForKey: @"sourceIdentifier"])
{
ASSIGN(sourceIdentifier, [coder decodeObjectForKey: @"sourceIdentifier"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(className);
DESTROY(superclassName);
DESTROY(actions);
DESTROY(outlets);
DESTROY(sourceIdentifier);
[super dealloc];
}
@end
@implementation IBClassDescriber
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"referencedPartialClassDescriptions"])
{
ASSIGN(referencedPartialClassDescriptions, [coder decodeObjectForKey: @"referencedPartialClassDescriptions"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(referencedPartialClassDescriptions);
[super dealloc];
}
@end
@implementation IBConnection
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"label"])
{
ASSIGN(label, [coder decodeObjectForKey: @"label"]);
}
if ([coder containsValueForKey: @"source"])
{
ASSIGN(source, [coder decodeObjectForKey: @"source"]);
}
if ([coder containsValueForKey: @"destination"])
{
ASSIGN(destination, [coder decodeObjectForKey: @"destination"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
// FIXME
}
- (void) dealloc
{
DESTROY(label);
DESTROY(source);
DESTROY(destination);
[super dealloc];
}
- (NSString*) label
{
return label;
}
- (id) source
{
return source;
}
- (id) destination
{
return destination;
}
- (NSNibConnector*) nibConnector
{
NSString *tag = [self label];
NSRange colonRange = [tag rangeOfString: @":"];
NSUInteger location = colonRange.location;
NSNibConnector *result = nil;
if (location == NSNotFound)
{
result = [[NSNibOutletConnector alloc] init];
}
else
{
result = [[NSNibControlConnector alloc] init];
}
[result setDestination: [self destination]];
[result setSource: [self source]];
[result setLabel: [self label]];
return result;
}
- (id) nibInstantiate
{
if ([source respondsToSelector: @selector(nibInstantiate)])
{
ASSIGN(source, [source nibInstantiate]);
}
if ([destination respondsToSelector: @selector(nibInstantiate)])
{
ASSIGN(destination, [destination nibInstantiate]);
}
return self;
}
- (void) establishConnection
{
}
@end
@implementation IBActionConnection
- (void) establishConnection
{
SEL sel = NSSelectorFromString(label);
[destination setTarget: source];
[destination setAction: sel];
}
@end
@implementation IBOutletConnection
- (void) establishConnection
{
NS_DURING
{
if (source != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[label substringToIndex: 1] uppercaseString],
[label substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [source respondsToSelector: sel])
{
[source performSelector: sel withObject: destination];
}
else
{
/*
* We cannot use the KVC mechanism here, as this would always retain _dst
* and it could also affect _setXXX methods and _XXX ivars that aren't
* affected by the Cocoa code.
*/
const char *name = [label cString];
Class class = object_getClass(source);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(source, ivar, destination);
}
}
}
}
NS_HANDLER
{
NSLog(@"Error while establishing connection %@: %@",self,[localException reason]);
}
NS_ENDHANDLER;
}
@end
@implementation IBBindingConnection
- (void) dealloc
{
DESTROY(connector);
[super dealloc];
}
- (id) initWithCoder: (NSCoder*)coder
{
self = [super initWithCoder: coder];
if (self == nil)
return nil;
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connector"])
{
ASSIGN(connector, [coder decodeObjectForKey: @"connector"]);
}
}
return self;
}
- (id) nibInstantiate
{
[connector nibInstantiate];
return [super nibInstantiate];
}
- (void) establishConnection
{
[connector establishConnection];
}
@end
@implementation IBConnectionRecord
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connection"])
{
ASSIGN(connection, [coder decodeObjectForKey: @"connection"]);
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without a connection ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
// Load the connection ID....
if ([coder containsValueForKey: @"connectionID"])
{
// PRE-4.6 XIBs....
connectionID = [coder decodeIntForKey: @"connectionID"];
}
else if ([coder containsValueForKey: @"id"])
{
// 4.6+ XIBs....
NSString *string = [coder decodeObjectForKey: @"id"];
if (string && [string isKindOfClass:[NSString class]] && [string length])
{
connectionID = [string intValue];
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:class: %@ - connection ID is missing or zero!",
__PRETTY_FUNCTION__, NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without a connection ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(connection);
[super dealloc];
}
- (IBConnection*) connection
{
return connection;
}
- (id) nibInstantiate
{
ASSIGN(connection, [connection nibInstantiate]);
return self;
}
- (void) establishConnection
{
[connection establishConnection];
}
@end
@implementation IBToolTipAttribute
- (NSString*) toolTip
{
return toolTip;
}
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"name"])
{
ASSIGN(name, [coder decodeObjectForKey: @"name"]);
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"toolTip"])
{
ASSIGN(toolTip, [coder decodeObjectForKey: @"toolTip"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(name);
DESTROY(object);
DESTROY(toolTip);
[super dealloc];
}
@end
@implementation IBInitialTabViewItemAttribute
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"name"])
{
ASSIGN(name, [coder decodeObjectForKey: @"name"]);
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"initialTabViewItem"])
{
ASSIGN(initialTabViewItem, [coder decodeObjectForKey: @"initialTabViewItem"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(name);
DESTROY(object);
DESTROY(initialTabViewItem);
[super dealloc];
}
@end
@implementation IBObjectRecord
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"objectID"])
{
// PRE-4.6 XIBs....
objectID = [coder decodeObjectForKey: @"objectID"];
}
else if ([coder containsValueForKey: @"id"])
{
// 4.6+ XIBs....
objectID = [coder decodeObjectForKey: @"id"];
}
else
{
// Cannot process without object ID...
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without an object ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"children"])
{
ASSIGN(children, [coder decodeObjectForKey: @"children"]);
}
if ([coder containsValueForKey: @"parent"])
{
ASSIGN(parent, [coder decodeObjectForKey: @"parent"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(object);
DESTROY(children);
DESTROY(parent);
[super dealloc];
}
- (id) object
{
return object;
}
- (id) parent
{
return parent;
}
- (id) objectID
{
return objectID;
}
- (NSString *) description
{
return [NSString stringWithFormat: @"<%@, %@, %@, %p>",
[self className],
object,
parent,
objectID];
}
@end
@implementation IBMutableOrderedSet
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"orderedObjects"])
{
ASSIGN(orderedObjects, [coder decodeObjectForKey: @"orderedObjects"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(orderedObjects);
[super dealloc];
}
- (NSArray*)orderedObjects
{
return orderedObjects;
}
- (id) objectWithObjectID: (id)objID
{
NSEnumerator *en;
IBObjectRecord *obj;
en = [orderedObjects objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
if ([[obj objectID] isEqual:objID])
{
return [obj object];
}
}
return nil;
}
@end
@implementation IBObjectContainer
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"sourceID"])
{
ASSIGN(sourceID, [coder decodeObjectForKey: @"sourceID"]);
}
if ([coder containsValueForKey: @"maxID"])
{
maxID = [coder decodeIntForKey: @"maxID"];
}
if ([coder containsValueForKey: @"flattenedProperties"])
{
ASSIGN(flattenedProperties, [coder decodeObjectForKey: @"flattenedProperties"]);
}
if ([coder containsValueForKey: @"objectRecords"])
{
ASSIGN(objectRecords, [coder decodeObjectForKey: @"objectRecords"]);
}
if ([coder containsValueForKey: @"connectionRecords"])
{
ASSIGN(connectionRecords, [coder decodeObjectForKey: @"connectionRecords"]);
}
// We could load more data here, but we currently don't need it.
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
// FIXME
}
- (void) dealloc
{
DESTROY(connectionRecords);
DESTROY(objectRecords);
DESTROY(flattenedProperties);
DESTROY(unlocalizedProperties);
DESTROY(activeLocalization);
DESTROY(localizations);
DESTROY(sourceID);
[super dealloc];
}
- (NSEnumerator*) connectionRecordEnumerator
{
return [connectionRecords objectEnumerator];
}
- (NSEnumerator*) objectRecordEnumerator
{
return [[objectRecords orderedObjects] objectEnumerator];
}
- (NSDictionary*) propertiesForObjectID: (id)objectID
{
NSEnumerator *en;
NSString *idString;
NSString *key;
NSMutableDictionary *properties;
int idLength;
idString = [NSString stringWithFormat: @"%@.", objectID];
idLength = [idString length];
properties = [[NSMutableDictionary alloc] init];
en = [flattenedProperties keyEnumerator];
while ((key = [en nextObject]) != nil)
{
if ([key hasPrefix: idString])
{
id value = [flattenedProperties objectForKey: key];
[properties setObject: value forKey: [key substringFromIndex: idLength]];
}
}
return AUTORELEASE(properties);
}
/*
Returns a dictionary of the custom class names keyed on the objectIDs.
*/
- (NSDictionary*) customClassNames
{
NSMutableDictionary *properties;
int i;
properties = [[NSMutableDictionary alloc] init];
// We have special objects at -3, -2, -1 and 0
for (i = -3; i < maxID; i++)
{
NSString *idString;
id value;
idString = [NSString stringWithFormat: @"%d.CustomClassName", i];
value = [flattenedProperties objectForKey: idString];
if (value)
{
NSString *key;
key = [NSString stringWithFormat: @"%d", i];
[properties setObject: value forKey: key];
}
}
return properties;
}
- (id) nibInstantiate
{
NSEnumerator *en;
id obj;
// iterate over connections, instantiate, and then establish them.
en = [connectionRecords objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
[obj nibInstantiate];
[obj establishConnection];
}
// awaken all objects.
en = [[objectRecords orderedObjects] objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
id realObj;
NSDictionary *properties;
id value;
realObj = [obj object];
if ([realObj respondsToSelector: @selector(nibInstantiate)])
{
realObj = [realObj nibInstantiate];
}
properties = [self propertiesForObjectID: [obj objectID]];
NSDebugLLog(@"XIB", @"object %ld props %@", (long)[obj objectID], properties);
//value = [properties objectForKey: @"windowTemplate.maxSize"];
//value = [properties objectForKey: @"CustomClassName"];
// Activate windows
value = [properties objectForKey: @"NSWindowTemplate.visibleAtLaunch"];
if (value != nil)
{
if ([value boolValue] == YES)
{
if ([realObj isKindOfClass: [NSWindow class]])
{
// bring visible windows to front...
[(NSWindow *)realObj orderFront: self];
}
}
}
// Tool tips
value = [properties objectForKey: @"IBAttributePlaceholdersKey"];
if (value != nil)
{
NSDictionary *infodict = (NSDictionary*)value;
// Process tooltips...
IBToolTipAttribute *tooltip = [infodict objectForKey: @"ToolTip"];
if (tooltip && [realObj respondsToSelector: @selector(setToolTip:)])
{
[realObj setToolTip: [tooltip toolTip]];
}
// Process XIB runtime attributes...
if ([infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"])
{
IBUserDefinedRuntimeAttributesPlaceholder *placeholder =
[infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"];
NSArray *attributes = [placeholder runtimeAttributes];
NSEnumerator *objectIter = [attributes objectEnumerator];
IBUserDefinedRuntimeAttribute *attribute;
while ((attribute = [objectIter nextObject]) != nil)
{
[realObj setValue: [attribute value] forKeyPath: [attribute keyPath]];
}
}
}
if ([realObj respondsToSelector: @selector(awakeFromNib)])
{
[realObj awakeFromNib];
}
}
return self;
}
@end
@interface GSXibLoader: GSModelLoader
{
}
@ -910,8 +82,7 @@
return 4.0;
}
- (void) awake: (NSArray *)rootObjects
inContainer: (id)objects
- (void) awake: (NSArray *)rootObjects
withContext: (NSDictionary *)context
{
NSEnumerator *en;
@ -923,6 +94,12 @@
NSCustomObject *object;
NSString *className;
if ([rootObjects count] == 0)
{
NSWarnMLog(@"No root objects in XIB!");
return;
}
// Get the file's owner and NSApplication object references...
object = (NSCustomObject*)[rootObjects objectAtIndex: 1];
if ([[object className] isEqualToString: @"FirstResponder"])
@ -974,14 +151,47 @@
[NSApp _setMainMenu: obj];
}
}
}
- (void) awake: (NSArray *)rootObjects
inContainer: (id)objects
withContext: (NSDictionary *)context
{
[self awake: rootObjects withContext: context];
// Load connections and awaken objects
if ([objects respondsToSelector:@selector(nibInstantiate)])
if ([objects respondsToSelector: @selector(nibInstantiate)])
{
[objects nibInstantiate];
}
}
- (BOOL) checkXib5: (NSData *)data
{
#if GNUSTEP_BASE_HAVE_LIBXML
// Ensure we have a XIB 5 version...first see if we can parse the XML...
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData: data
options: 0
error: NULL];
if (document == nil)
{
return NO;
}
else
{
// Test to see if this is an Xcode 5 XIB...
NSArray *documentNodes = [document nodesForXPath: @"/document" error: NULL];
// Need at LEAST ONE document node...we should find something a bit more
// specific to check here...
return [documentNodes count] != 0;
}
#else
// We now default to checking XIB 5 versions
return YES;
#endif
}
- (BOOL) loadModelData: (NSData *)data
externalNameTable: (NSDictionary *)context
withZone: (NSZone *)zone;
@ -993,7 +203,15 @@
{
if (data != nil)
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
if ([self checkXib5: data])
{
unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data];
}
else
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
}
if (unarchiver != nil)
{
NSArray *rootObjects;
@ -1004,28 +222,15 @@
rootObjects = [unarchiver decodeObjectForKey: @"IBDocument.RootObjects"];
objects = [unarchiver decodeObjectForKey: @"IBDocument.Objects"];
NSDebugLLog(@"XIB", @"rootObjects %@", rootObjects);
[self awake: rootObjects
inContainer: objects
[self awake: rootObjects
inContainer: objects
withContext: context];
loaded = YES;
RELEASE(unarchiver);
}
else
{
GSXibParser *parser = [[GSXibParser alloc] initWithData: data];
NSDictionary *result = [parser parse];
if (result != nil)
{
NSArray *rootObjects = [result objectForKey: @"IBDocument.RootObjects"];
GSXibObjectContainer *objects = [result objectForKey: @"IBDocument.Objects"];
[self awake: rootObjects
inContainer: objects
withContext: context];
}
else
{
NSLog(@"Could not instantiate Xib unarchiver/Unable to parse Xib.");
}
NSLog(@"Could not instantiate Xib unarchiver/Unable to parse Xib.");
}
}
else

View file

@ -1,6 +1,42 @@
/* <title>GSXibLoading</title>
<abstract>Xib (Cocoa XML) loading helper classes</abstract>
Copyright (C) 2010, 2011 Free Software Foundation, Inc.
Written by: Fred Kiefer <FredKiefer@gmx.de>
Created: March 2010
Author: Gregory John Casamento
Date: 2010, 2012
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02110 USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSKeyedArchiver.h>
#import "GNUstepGUI/GSXibElement.h"
#import "AppKit/NSControl.h"
#import "AppKit/NSNibLoading.h"
#import "AppKit/NSWindow.h"
#import "GNUstepGUI/GSNibLoading.h"
#import "GNUstepGUI/GSXibLoading.h"
@interface IBAccessibilityAttribute : NSObject <NSCoding>
@ -158,3 +194,831 @@
return self;
}
@end
@implementation FirstResponder
+ (id) allocWithZone: (NSZone*)zone
{
return nil;
}
@end
@implementation IBClassDescriptionSource
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"majorKey"])
{
ASSIGN(majorKey, [coder decodeObjectForKey: @"majorKey"]);
}
if ([coder containsValueForKey: @"minorKey"])
{
ASSIGN(minorKey, [coder decodeObjectForKey: @"minorKey"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(majorKey);
DESTROY(minorKey);
[super dealloc];
}
@end
@implementation IBPartialClassDescription
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"className"])
{
ASSIGN(className, [coder decodeObjectForKey: @"className"]);
}
if ([coder containsValueForKey: @"superclassName"])
{
ASSIGN(superclassName, [coder decodeObjectForKey: @"superclassName"]);
}
if ([coder containsValueForKey: @"actions"])
{
ASSIGN(actions, [coder decodeObjectForKey: @"actions"]);
}
if ([coder containsValueForKey: @"outlets"])
{
ASSIGN(outlets, [coder decodeObjectForKey: @"outlets"]);
}
if ([coder containsValueForKey: @"sourceIdentifier"])
{
ASSIGN(sourceIdentifier, [coder decodeObjectForKey: @"sourceIdentifier"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(className);
DESTROY(superclassName);
DESTROY(actions);
DESTROY(outlets);
DESTROY(sourceIdentifier);
[super dealloc];
}
@end
@implementation IBClassDescriber
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"referencedPartialClassDescriptions"])
{
ASSIGN(referencedPartialClassDescriptions, [coder decodeObjectForKey: @"referencedPartialClassDescriptions"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(referencedPartialClassDescriptions);
[super dealloc];
}
@end
@implementation IBConnection
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"label"])
{
ASSIGN(label, [coder decodeObjectForKey: @"label"]);
}
if ([coder containsValueForKey: @"source"])
{
ASSIGN(source, [coder decodeObjectForKey: @"source"]);
}
if ([coder containsValueForKey: @"destination"])
{
ASSIGN(destination, [coder decodeObjectForKey: @"destination"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
// FIXME
}
- (void) dealloc
{
DESTROY(label);
DESTROY(source);
DESTROY(destination);
[super dealloc];
}
- (NSString*) label
{
return label;
}
- (id) source
{
return source;
}
- (id) destination
{
return destination;
}
- (NSNibConnector*) nibConnector
{
NSString *tag = [self label];
NSRange colonRange = [tag rangeOfString: @":"];
NSUInteger location = colonRange.location;
NSNibConnector *result = nil;
if (location == NSNotFound)
{
result = [[NSNibOutletConnector alloc] init];
}
else
{
result = [[NSNibControlConnector alloc] init];
}
[result setDestination: [self destination]];
[result setSource: [self source]];
[result setLabel: [self label]];
return result;
}
- (NSString*) description
{
return [NSString stringWithFormat: @"%@ - label: %@, source: %@, destination: %@",
[super description], label, NSStringFromClass([source class]),
NSStringFromClass([destination class])];
}
- (id) nibInstantiate
{
if ([source respondsToSelector: @selector(nibInstantiate)])
{
ASSIGN(source, [source nibInstantiate]);
}
if ([destination respondsToSelector: @selector(nibInstantiate)])
{
ASSIGN(destination, [destination nibInstantiate]);
}
return self;
}
- (void) establishConnection
{
}
@end
@implementation IBActionConnection
- (void) establishConnection
{
SEL sel = NSSelectorFromString(label);
[destination setTarget: source];
[destination setAction: sel];
}
@end
@implementation IBOutletConnection
- (void) establishConnection
{
NS_DURING
{
if (source != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[label substringToIndex: 1] uppercaseString],
[label substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [source respondsToSelector: sel])
{
[source performSelector: sel withObject: destination];
}
else
{
/*
* We cannot use the KVC mechanism here, as this would always retain _dst
* and it could also affect _setXXX methods and _XXX ivars that aren't
* affected by the Cocoa code.
*/
const char *name = [label cString];
Class class = object_getClass(source);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(source, ivar, destination);
}
else
{
NSWarnMLog(@"class '%@' has no instance var named: %@", NSStringFromClass(class), label);
}
}
}
}
NS_HANDLER
{
NSLog(@"Error while establishing connection %@: %@",self,[localException reason]);
}
NS_ENDHANDLER;
}
@end
@implementation IBBindingConnection
- (void) dealloc
{
DESTROY(connector);
[super dealloc];
}
- (id) initWithCoder: (NSCoder*)coder
{
self = [super initWithCoder: coder];
if (self == nil)
return nil;
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connector"])
{
ASSIGN(connector, [coder decodeObjectForKey: @"connector"]);
}
}
return self;
}
- (void) establishConnection
{
[connector establishConnection];
}
@end
@implementation IBConnectionRecord
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connection"])
{
ASSIGN(connection, [coder decodeObjectForKey: @"connection"]);
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without a connection ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
// Load the connection ID....
if ([coder containsValueForKey: @"connectionID"])
{
// PRE-4.6 XIBs....
connectionID = [coder decodeIntForKey: @"connectionID"];
}
else if ([coder containsValueForKey: @"id"])
{
// 4.6+ XIBs....
NSString *string = [coder decodeObjectForKey: @"id"];
if (string && [string isKindOfClass:[NSString class]] && [string length])
{
connectionID = [string intValue];
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:class: %@ - connection ID is missing or zero!",
__PRETTY_FUNCTION__, NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
}
else
{
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without a connection ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(connection);
[super dealloc];
}
- (IBConnection*) connection
{
return connection;
}
- (id) nibInstantiate
{
ASSIGN(connection, [connection nibInstantiate]);
return self;
}
- (void) establishConnection
{
[connection establishConnection];
}
@end
@implementation IBToolTipAttribute
- (NSString*) toolTip
{
return toolTip;
}
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"name"])
{
ASSIGN(name, [coder decodeObjectForKey: @"name"]);
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"toolTip"])
{
ASSIGN(toolTip, [coder decodeObjectForKey: @"toolTip"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(name);
DESTROY(object);
DESTROY(toolTip);
[super dealloc];
}
@end
@implementation IBInitialTabViewItemAttribute
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"name"])
{
ASSIGN(name, [coder decodeObjectForKey: @"name"]);
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"initialTabViewItem"])
{
ASSIGN(initialTabViewItem, [coder decodeObjectForKey: @"initialTabViewItem"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(name);
DESTROY(object);
DESTROY(initialTabViewItem);
[super dealloc];
}
@end
@implementation IBObjectRecord
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"objectID"])
{
// PRE-4.6 XIBs....
objectID = [coder decodeObjectForKey: @"objectID"];
}
else if ([coder containsValueForKey: @"id"])
{
// 4.6+ XIBs....
objectID = [coder decodeObjectForKey: @"id"];
}
else
{
// Cannot process without object ID...
NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ without an object ID",
__PRETTY_FUNCTION__,
NSStringFromClass([self class])];
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
}
if ([coder containsValueForKey: @"children"])
{
ASSIGN(children, [coder decodeObjectForKey: @"children"]);
}
if ([coder containsValueForKey: @"parent"])
{
ASSIGN(parent, [coder decodeObjectForKey: @"parent"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(object);
DESTROY(children);
DESTROY(parent);
[super dealloc];
}
- (id) object
{
return object;
}
- (id) parent
{
return parent;
}
- (id) objectID
{
return objectID;
}
- (NSString *) description
{
return [NSString stringWithFormat: @"<%@, %@, %@, %p>",
[self className],
object,
parent,
objectID];
}
@end
@implementation IBMutableOrderedSet
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"orderedObjects"])
{
ASSIGN(orderedObjects, [coder decodeObjectForKey: @"orderedObjects"]);
}
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) dealloc
{
DESTROY(orderedObjects);
[super dealloc];
}
- (NSArray*) orderedObjects
{
return orderedObjects;
}
- (id) objectWithObjectID: (id)objID
{
NSEnumerator *en;
IBObjectRecord *obj;
en = [orderedObjects objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
if ([[obj objectID] isEqual:objID])
{
return [obj object];
}
}
return nil;
}
@end
@implementation IBObjectContainer
- (id) initWithCoder: (NSCoder*)coder
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"sourceID"])
{
ASSIGN(sourceID, [coder decodeObjectForKey: @"sourceID"]);
}
if ([coder containsValueForKey: @"maxID"])
{
maxID = [coder decodeIntForKey: @"maxID"];
}
if ([coder containsValueForKey: @"flattenedProperties"])
{
ASSIGN(flattenedProperties, [coder decodeObjectForKey: @"flattenedProperties"]);
}
if ([coder containsValueForKey: @"objectRecords"])
{
ASSIGN(objectRecords, [coder decodeObjectForKey: @"objectRecords"]);
}
if ([coder containsValueForKey: @"connectionRecords"])
{
ASSIGN(connectionRecords, [coder decodeObjectForKey: @"connectionRecords"]);
}
// We could load more data here, but we currently don't need it.
}
else
{
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
return self;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
// FIXME
}
- (void) dealloc
{
DESTROY(connectionRecords);
DESTROY(objectRecords);
DESTROY(flattenedProperties);
DESTROY(unlocalizedProperties);
DESTROY(activeLocalization);
DESTROY(localizations);
DESTROY(sourceID);
[super dealloc];
}
- (NSString*) description
{
return [NSString stringWithFormat:
@"%@ - sourceID: %@: maxID: %@: objectRecords: %@: flattenedProperties: %@: connectionRecords: %@: ",
[super description], sourceID, maxID, objectRecords,
flattenedProperties, connectionRecords];
}
- (NSEnumerator*) connectionRecordEnumerator
{
return [connectionRecords objectEnumerator];
}
- (NSEnumerator*) objectRecordEnumerator
{
return [[objectRecords orderedObjects] objectEnumerator];
}
- (NSDictionary*) propertiesForObjectID: (id)objectID
{
NSEnumerator *en;
NSString *idString;
NSString *key;
NSMutableDictionary *properties;
int idLength;
idString = [NSString stringWithFormat: @"%@.", objectID];
idLength = [idString length];
properties = [[NSMutableDictionary alloc] init];
en = [flattenedProperties keyEnumerator];
while ((key = [en nextObject]) != nil)
{
if ([key hasPrefix: idString])
{
id value = [flattenedProperties objectForKey: key];
[properties setObject: value forKey: [key substringFromIndex: idLength]];
}
}
return AUTORELEASE(properties);
}
/*
Returns a dictionary of the custom class names keyed on the objectIDs.
*/
- (NSDictionary*) customClassNames
{
NSMutableDictionary *properties;
int i;
properties = [[NSMutableDictionary alloc] init];
// We have special objects at -3, -2, -1 and 0
for (i = -3; i < maxID; i++)
{
NSString *idString;
id value;
idString = [NSString stringWithFormat: @"%d.CustomClassName", i];
value = [flattenedProperties objectForKey: idString];
if (value)
{
NSString *key;
key = [NSString stringWithFormat: @"%d", i];
[properties setObject: value forKey: key];
}
}
return properties;
}
- (id) nibInstantiate
{
NSEnumerator *en;
id obj;
// iterate over connections, instantiate, and then establish them.
en = [connectionRecords objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
[obj nibInstantiate];
[obj establishConnection];
}
// awaken all objects.
en = [[objectRecords orderedObjects] objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
id realObj;
NSDictionary *properties;
id value;
realObj = [obj object];
if ([realObj respondsToSelector: @selector(nibInstantiate)])
{
realObj = [realObj nibInstantiate];
}
properties = [self propertiesForObjectID: [obj objectID]];
NSDebugLLog(@"XIB", @"object %@ props %@", [obj objectID], properties);
//value = [properties objectForKey: @"windowTemplate.maxSize"];
//value = [properties objectForKey: @"CustomClassName"];
// Activate windows
value = [properties objectForKey: @"NSWindowTemplate.visibleAtLaunch"];
if (value != nil)
{
if ([value boolValue] == YES)
{
if ([realObj isKindOfClass: [NSWindow class]])
{
// bring visible windows to front...
[(NSWindow *)realObj orderFront: self];
}
}
}
// Tool tips
value = [properties objectForKey: @"IBAttributePlaceholdersKey"];
if (value != nil)
{
NSDictionary *infodict = (NSDictionary*)value;
// Process tooltips...
IBToolTipAttribute *tooltip = [infodict objectForKey: @"ToolTip"];
if (tooltip && [realObj respondsToSelector: @selector(setToolTip:)])
{
[realObj setToolTip: [tooltip toolTip]];
}
// Process XIB runtime attributes...
if ([infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"])
{
IBUserDefinedRuntimeAttributesPlaceholder *placeholder =
[infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"];
NSArray *attributes = [placeholder runtimeAttributes];
NSEnumerator *objectIter = [attributes objectEnumerator];
IBUserDefinedRuntimeAttribute *attribute;
while ((attribute = [objectIter nextObject]) != nil)
{
[realObj setValue: [attribute value] forKeyPath: [attribute keyPath]];
}
}
}
if ([realObj respondsToSelector: @selector(awakeFromNib)])
{
[realObj awakeFromNib];
}
}
return self;
}
@end

View file

@ -1,211 +0,0 @@
/* <title>GSXibParser</title>
<abstract>Xib v5 (Cocoa XML) parser</abstract>
Copyright (C) 2014 Free Software Foundation, Inc.
Written by: Gregory Casamento <greg.casamento@gmail.com>
Created: March 2014
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02110 USA.
*/
#import <Foundation/NSData.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSXMLParser.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSException.h>
#import "GNUstepGUI/GSXibParser.h"
#import "GNUstepGUI/GSXibElement.h"
// XIB Object...
@interface XIBObject : NSObject
{
NSMutableArray *connections;
}
- (id) initWithXibElement: (GSXibElement *)element;
- (id) instantiateObject;
@end
@implementation XIBObject
- (id) initWithXibElement: (GSXibElement *)element
{
if ((self = [super init]) != nil)
{
connections = [[NSMutableArray alloc] initWithCapacity: 10];
}
return self;
}
- (void) dealloc
{
[connections release];
[super dealloc];
}
- (id) instantiateObject
{
return nil;
}
- (NSArray *) connections
{
return connections;
}
@end
@interface XIBAction : XIBObject
- (void) setSelector: (NSString *)selectorName;
- (NSString *) selector;
- (void) setTarget: (NSString *)targetId;
- (NSString *) target;
@end
@interface XIBOutlet : XIBObject
- (void) setProperty: (NSString *)propertyName;
- (NSString *) property;
- (void) setDestination: (NSString *)destinationId;
- (NSString *) destination;
@end
@interface XIBCustomObject
- (void) setUserLabel: (NSString *)label;
- (NSString *) userLabel;
- (void) setCustomClass: (NSString *)className;
- (NSString *) customClass;
@end
@implementation GSXibParser
- (id) initWithData: (NSData *)data
{
if ((self = [super init]) != nil)
{
theParser = [[NSXMLParser alloc] initWithData: data];
[theParser setDelegate: self];
objects = [[NSMutableDictionary alloc] initWithCapacity: 100];
stack = [[NSMutableArray alloc] initWithCapacity: 100];
currentElement = nil;
}
return self;
}
- (NSDictionary *) parse
{
NS_DURING
{
[theParser parse];
}
NS_HANDLER
{
NSLog(@"%@",[localException reason]);
}
NS_ENDHANDLER;
return objects;
}
- (NSMutableDictionary *) instantiateObjects
{
return nil;
}
- (NSString *)classNameFromType: (NSString *)typeName
{
NSString *className = [@"XIB" stringByAppendingString: [typeName capitalizedString]];
return className;
}
- (id) instantiateObjectForElement: (GSXibElement *)element
{
NSString *className = [self classNameFromType: [element type]];
id obj = nil;
if (className != nil)
{
Class cls = NSClassFromString(className);
if (cls != nil)
{
obj = [[cls alloc] initWithXibElement:element];
}
}
return obj;
}
- (void) parser: (NSXMLParser*)parser
foundCharacters: (NSString*)string
{
[currentElement setValue: string];
}
- (void) parser: (NSXMLParser*)parser
didStartElement: (NSString*)elementName
namespaceURI: (NSString*)namespaceURI
qualifiedName: (NSString*)qualifiedName
attributes: (NSDictionary*)attributeDict
{
GSXibElement *element = [[GSXibElement alloc] initWithType: elementName
andAttributes: attributeDict];
NSString *key = [attributeDict objectForKey: @"id"];
// FIXME: We should use proper memory management here
AUTORELEASE(element);
if ([@"document" isEqualToString: elementName])
{
currentElement = element;
}
else
{
if (key != nil)
{
// id obj = [self instantiateObjectForElement: element];
[currentElement setElement: element forKey: key];
}
else
{
// For Arrays
[currentElement addElement: element];
}
currentElement = element;
}
[stack addObject: currentElement];
}
- (void) parser: (NSXMLParser*)parser
didEndElement: (NSString*)elementName
namespaceURI: (NSString*)namespaceURI
qualifiedName: (NSString*)qName
{
if (![@"document" isEqualToString: elementName])
{
currentElement = [stack lastObject];
[stack removeLastObject];
}
else
{
objects = [self instantiateObjects];
}
}
@end

View file

@ -41,6 +41,101 @@
#import "GSBindingHelpers.h"
#import "GSFastEnumeration.h"
@implementation GSObservableArray
- (id) initWithArray: (NSArray *)array
{
self = [super init];
if (self)
{
ASSIGN(_array, array);
}
return self;
}
- (void) dealloc
{
RELEASE(_array);
[super dealloc];
}
- (NSUInteger) count
{
return [_array count];
}
- (NSUInteger) indexOfObject: (id)anObject
{
return [_array indexOfObject: anObject];
}
- (id) objectAtIndex: (NSUInteger)index
{
return [_array objectAtIndex: index];
}
- (NSArray *) objectsAtIndexes: (NSIndexSet *)indexes
{
NSArray *result = [_array objectsAtIndexes: indexes];
return AUTORELEASE([[GSObservableArray alloc]
initWithArray: result]);
}
- (id) valueForKey: (NSString*)key
{
id result = [_array valueForKey: key];
if ([result isKindOfClass: [NSArray class]])
{
return AUTORELEASE([[GSObservableArray alloc]
initWithArray: result]);
}
return result;
}
- (NSArray*) arrayByAddingObject: (id)anObject
{
NSArray * result = [_array arrayByAddingObject: anObject];
return AUTORELEASE([[GSObservableArray alloc]
initWithArray: result]);
}
- (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray
{
NSArray * result = [_array arrayByAddingObjectsFromArray: anotherArray];
return AUTORELEASE([[GSObservableArray alloc]
initWithArray: result]);
}
- (void) addObserver: (NSObject*)anObserver
forKeyPath: (NSString*)aPath
options: (NSKeyValueObservingOptions)options
context: (void*)aContext
{
NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [self count])];
[self addObserver: anObserver
toObjectsAtIndexes: indexes
forKeyPath: aPath
options: options
context: aContext];
}
- (void) removeObserver: (NSObject*)anObserver forKeyPath: (NSString*)aPath
{
NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [self count])];
[self removeObserver: anObserver
fromObjectsAtIndexes: indexes
forKeyPath: aPath];
}
@end
@implementation NSArrayController
+ (void) initialize
@ -365,8 +460,13 @@
- (NSArray*) arrangeObjects: (NSArray*)obj
{
NSArray *temp = [obj filteredArrayUsingPredicate: _filter_predicate];
NSArray *temp = obj;
if (_filter_predicate != nil)
{
temp = [obj filteredArrayUsingPredicate: _filter_predicate];
}
return [temp sortedArrayUsingDescriptors: _sort_descriptors];
}
@ -378,7 +478,8 @@
- (void) rearrangeObjects
{
[self willChangeValueForKey: @"arrangedObjects"];
ASSIGN(_arranged_objects, [self arrangeObjects: _content]);
_arranged_objects = [[GSObservableArray alloc]
initWithArray: [self arrangeObjects: _content]];
[self didChangeValueForKey: @"arrangedObjects"];
}

View file

@ -56,56 +56,10 @@
#import "GNUstepGUI/GSTheme.h"
#import "GNUstepGUI/GSNibLoading.h"
#import "GSGuiPrivate.h"
#import "GSCodingFlags.h"
#include <math.h>
typedef struct _GSButtonCellFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isPushin:1;
unsigned int changeContents:1;
unsigned int changeBackground:1;
unsigned int changeGray:1;
unsigned int highlightByContents:1;
unsigned int highlightByBackground:1;
unsigned int highlightByGray:1;
unsigned int drawing:1;
unsigned int isBordered:1;
unsigned int imageDoesOverlap:1;
unsigned int isHorizontal:1;
unsigned int isBottomOrLeft:1;
unsigned int isImageAndText:1;
unsigned int isImageSizeDiff:1;
unsigned int hasKeyEquiv:1;
unsigned int lastState:1;
unsigned int isTransparent:1;
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int useButtonImageSource:1;
unsigned int unused2:8; // alt mnemonic loc.
#else
unsigned int unused2:8; // alt mnemonic loc.
unsigned int useButtonImageSource:1;
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int isTransparent:1;
unsigned int lastState:1;
unsigned int hasKeyEquiv:1;
unsigned int isImageSizeDiff:1;
unsigned int isImageAndText:1;
unsigned int isBottomOrLeft:1;
unsigned int isHorizontal:1;
unsigned int imageDoesOverlap:1;
unsigned int isBordered:1;
unsigned int drawing:1;
unsigned int highlightByGray:1;
unsigned int highlightByBackground:1;
unsigned int highlightByContents:1;
unsigned int changeGray:1;
unsigned int changeBackground:1;
unsigned int changeContents:1;
unsigned int isPushin:1;
#endif
} GSButtonCellFlags;
@interface NSCell (Private)
- (NSSize) _scaleImageWithSize: (NSSize)imageSize
toFitInSize: (NSSize)canvasSize
@ -1674,8 +1628,10 @@ typedef struct _GSButtonCellFlags
buttonCellFlags.changeGray = [self cellAttribute: NSChangeGrayCell];
// set these to zero...
buttonCellFlags.unused1 = 0; // 32;
buttonCellFlags.unused2 = 0; // 255;
buttonCellFlags.inset = 0;
buttonCellFlags.doesNotDimImage = 0;
buttonCellFlags.gradient = 0;
buttonCellFlags.unused2 = 0;
buttonCellFlags.lastState = 0;
buttonCellFlags.isImageSizeDiff = 0;
buttonCellFlags.drawing = 0;

View file

@ -2,7 +2,7 @@
<abstract>The abstract cell class</abstract>
Copyright (C) 1996-2012 Free Software Foundation, Inc.
Copyright (C) 1996-2012,2019 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
@ -27,11 +27,13 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <math.h>
#import "config.h"
#import <Foundation/NSCoder.h>
#import <Foundation/NSDebug.h>
@ -134,7 +136,7 @@ static NSColor *dtxtCol;
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>
*/
+ (BOOL) prefersTrackingUntilMouseUp
@ -150,8 +152,8 @@ static NSColor *dtxtCol;
return [self initTextCell: @""];
}
/**<p>Initializes and returns a new NSCell with a NSImage <var>anImage</var>.
This method sets the image position to <ref type="type"
/**<p>Initializes and returns a new NSCell with a NSImage <var>anImage</var>.
This method sets the image position to <ref type="type"
id="NSCellImagePosition">NSImageOnly</ref> and the cell's type to
<ref type="type" id="NSCellType">NSImageCellType</ref>.</p>
<p>See Also: -initTextCell: </p>
@ -187,7 +189,7 @@ static NSColor *dtxtCol;
return self;
}
/**<p>Initializes and returns a new NSCell with a NSString aString.
/**<p>Initializes and returns a new NSCell with a NSString aString.
This method sets the cell's type to <ref type="type" id="NSCellType">
NSTextCellType</ref>.</p>
<p>See Also: -initImageCell: </p>
@ -339,19 +341,19 @@ static NSColor *dtxtCol;
}
}
- (void) setObjectValue: (id)object
- (void) setObjectValue: (id)object
{
id newContents;
ASSIGN (_object_value, object);
if (_formatter == nil)
if (_formatter == nil)
{
if (object == nil || [object isKindOfClass: [NSString class]] == YES)
{
newContents = object;
_cell.contents_is_attributed_string = NO;
_cell.has_valid_object_value = YES;
// If we are in single line mode, trim the new line characters
if(_cell.uses_single_line_mode == YES)
{
@ -380,7 +382,7 @@ static NSColor *dtxtCol;
}
else if ([_object_value respondsToSelector: @selector(stringValue)])
{
// If the thing that was assigned is not a string, but
// If the thing that was assigned is not a string, but
// responds to stringValue then get that.
newContents = [_object_value stringValue];
_cell.contents_is_attributed_string = NO;
@ -412,7 +414,7 @@ static NSColor *dtxtCol;
/**<p>Sets the NSCell's value to aDouble.</p>
*<p>See Also: -doubleValue</p>
*<p>See Also: -doubleValue</p>
*/
- (void) setDoubleValue: (double)aDouble
{
@ -425,16 +427,16 @@ static NSColor *dtxtCol;
}
/**
*<p>Sets the NSCell's value to a aFloat. This used for example in
*<p>Sets the NSCell's value to a aFloat. This used for example in
NSSliderCell</p>
*<p>See Also: -floatValue</p>
*<p>See Also: -floatValue</p>
*/
- (void) setFloatValue: (float)aFloat
{
NSNumber *number;
// NB: GNUstep can set a float value for an image cell.
// NSSliderCell is an example of it!
// NB: GNUstep can set a float value for an image cell.
// NSSliderCell is an example of it!
number = [NSNumber numberWithFloat: aFloat];
[self setObjectValue: number];
@ -443,13 +445,13 @@ static NSColor *dtxtCol;
/**
*<p>Sets the NSCell's value to anInt.</p>
*<p>See Also: -intValue</p>
*<p>See Also: -intValue</p>
*/
- (void) setIntValue: (int)anInt
{
NSNumber *number;
// NB: GNUstep can set an int value for an image cell.
// NB: GNUstep can set an int value for an image cell.
number = [NSNumber numberWithInt: anInt];
[self setObjectValue: number];
@ -457,21 +459,21 @@ static NSColor *dtxtCol;
/**
*<p>Sets the NSCell's value to anInt.</p>
*<p>See Also: -integerValue</p>
*<p>See Also: -integerValue</p>
*/
- (void) setIntegerValue: (NSInteger)anInt
{
NSNumber *number;
// NB: GNUstep can set an int value for an image cell.
// NB: GNUstep can set an int value for an image cell.
number = [NSNumber numberWithInteger: anInt];
[self setObjectValue: number];
}
/**<p>Sets the cell's value to a NSString.
/**<p>Sets the cell's value to a NSString.
The NSCell's type is set to NSTextCellType if needed</p>
<p>See Also: -stringValue</p>
<p>See Also: -stringValue</p>
*/
- (void) setStringValue: (NSString*)aString
{
@ -479,7 +481,7 @@ static NSColor *dtxtCol;
nil. */
if (aString == nil)
{
NSDebugMLLog (@"MacOSXCompatibility",
NSDebugMLLog (@"MacOSXCompatibility",
@"Attempt to use nil as string value");
}
@ -495,9 +497,9 @@ static NSColor *dtxtCol;
else
{
id newObjectValue;
if ([_formatter getObjectValue: &newObjectValue
forString: aString
if ([_formatter getObjectValue: &newObjectValue
forString: aString
errorDescription: NULL])
{
[self setObjectValue: newObjectValue];
@ -524,30 +526,30 @@ static NSColor *dtxtCol;
case NSCellEditable: return _cell.is_editable;
case NSCellHighlighted: return _cell.is_highlighted;
case NSCellIsBordered: return _cell.is_bordered;
case NSCellAllowsMixedState: return _cell.allows_mixed_state;
case NSCellAllowsMixedState: return _cell.allows_mixed_state;
/*
case NSPushInCell: return 0;
case NSChangeGrayCell: return 0;
case NSCellLightsByContents: return 0;
case NSCellLightsByGray: return 0;
case NSChangeBackgroundCell: return 0;
case NSCellLightsByBackground: return 0;
case NSCellChangesContents: return 0;
case NSCellIsInsetButton: return 0;
case NSPushInCell: return 0;
case NSChangeGrayCell: return 0;
case NSCellLightsByContents: return 0;
case NSCellLightsByGray: return 0;
case NSChangeBackgroundCell: return 0;
case NSCellLightsByBackground: return 0;
case NSCellChangesContents: return 0;
case NSCellIsInsetButton: return 0;
*/
case NSCellHasOverlappingImage:
case NSCellHasOverlappingImage:
{
return _cell.image_position == NSImageOverlaps;
}
case NSCellHasImageHorizontal:
case NSCellHasImageHorizontal:
{
return (_cell.image_position == NSImageRight)
return (_cell.image_position == NSImageRight)
|| (_cell.image_position == NSImageLeft);
}
case NSCellHasImageOnLeftOrBottom:
case NSCellHasImageOnLeftOrBottom:
{
return (_cell.image_position == NSImageBelow)
return (_cell.image_position == NSImageBelow)
|| (_cell.image_position == NSImageLeft);
}
default:
@ -556,7 +558,7 @@ static NSColor *dtxtCol;
break;
}
}
return 0;
}
@ -689,7 +691,7 @@ static NSColor *dtxtCol;
{
return;
}
_cell.type = aType;
switch (_cell.type)
{
@ -711,15 +713,15 @@ static NSColor *dtxtCol;
}
/**<p>Returns the cell's type. Returns NSNullCellType if the
cell's type flag is set to NSImageCellType and if the cell's image
is nil. See <ref type="type" id="NSCellType">NSCellType</ref> for more
cell's type flag is set to NSImageCellType and if the cell's image
is nil. See <ref type="type" id="NSCellType">NSCellType</ref> for more
information.</p><p>See Also -setType:</p>
*/
- (NSCellType) type
{
if (_cell.type == NSImageCellType && _cell_image == nil)
return NSNullCellType;
return _cell.type;
}
@ -737,7 +739,7 @@ static NSColor *dtxtCol;
*/
- (void) setEnabled: (BOOL)flag
{
_cell.is_disabled = !flag;
_cell.is_disabled = !flag;
}
/**<p>Returns whether the NSCell has a bezeled border. By default a NSCell
@ -748,7 +750,7 @@ static NSColor *dtxtCol;
return _cell.is_bezeled;
}
/**<p>Returns whether the NSCell has a border. By default a NSCell has
/**<p>Returns whether the NSCell has a border. By default a NSCell has
border</p><p>See Also: -setBordered: -setBezeled: -isBezeled</p>
*/
- (BOOL) isBordered
@ -763,7 +765,7 @@ static NSColor *dtxtCol;
return NO;
}
/**<p>Sets whether the cell has a bezeled border.
/**<p>Sets whether the cell has a bezeled border.
If this method is called, the bordered flag is turn off.
By default a NSCell has no bezeled border</p>
<p>See Also: -isBezeled -setBordered: -isBordered</p>
@ -774,7 +776,7 @@ static NSColor *dtxtCol;
_cell.is_bordered = NO;
}
/**<p>Sets whether the cell has a border. If this method is called,
/**<p>Sets whether the cell has a border. If this method is called,
the bezeled flag is turn off. By default a NSCell has no border</p>
<p>See Also: -isBordered -setBezeled: -isBezeled</p>
*/
@ -815,7 +817,7 @@ static NSColor *dtxtCol;
{
_cell.state = NSOffState;
}
else
else
{
_cell.state = NSMixedState;
}
@ -875,9 +877,9 @@ static NSColor *dtxtCol;
[self setState: [self nextState]];
}
/**<p>Returns the alignment of the text used in the NSCell. See
/**<p>Returns the alignment of the text used in the NSCell. See
<ref type="type" id="NSTextAlignment">NSTextAlignment</ref> for more
informations. By default the text alignment is <ref type="type"
informations. By default the text alignment is <ref type="type"
id="NSTextAlignment">NSJustifiedTextAlignment</ref></p>
<p>See Also: -setAlignment:</p>
*/
@ -902,7 +904,7 @@ static NSColor *dtxtCol;
return _cell.is_editable;
}
/**<p>Returns whether the cell is selectable. This method returns YES if
/**<p>Returns whether the cell is selectable. This method returns YES if
the cell is selectable or editable. NO otherwise</p>
<p>See Also: -setSelectable: -isEditable -setEditable: </p>
*/
@ -919,7 +921,7 @@ static NSColor *dtxtCol;
return _cell.is_scrollable;
}
/**<p>Sets the alignment of the text. See <ref type="type"
/**<p>Sets the alignment of the text. See <ref type="type"
id="NSTextAlignment">NSTextAlignment</ref>.</p><p>See Also: -alignment </p>
*/
- (void) setAlignment: (NSTextAlignment)mode
@ -936,7 +938,7 @@ static NSColor *dtxtCol;
/*
* The cell_editable flag is also checked to see if the cell is
* selectable so turning edit on also turns selectability on (until
* edit is turned off again).
* edit is turned off again).
*/
_cell.is_editable = flag;
}
@ -1005,9 +1007,9 @@ static NSColor *dtxtCol;
if (_formatter != nil)
{
id newObjectValue;
if ([_formatter getObjectValue: &newObjectValue
forString: [attribStr string]
if ([_formatter getObjectValue: &newObjectValue
forString: [attribStr string]
errorDescription: NULL] == YES)
{
[self setObjectValue: newObjectValue];
@ -1034,7 +1036,7 @@ static NSColor *dtxtCol;
NSAttributedString *attrStr;
attributes = [self _nonAutoreleasedTypingAttributes];
attrStr = [_formatter attributedStringForObjectValue: _object_value
attrStr = [_formatter attributedStringForObjectValue: _object_value
withDefaultAttributes: attributes];
RELEASE(attributes);
if (attrStr != nil)
@ -1129,7 +1131,7 @@ static NSColor *dtxtCol;
return NULL;
}
/** <p>Implemented by subclasses to set the action method.
/** <p>Implemented by subclasses to set the action method.
The NSCell implementation raises a NSInternalInconsistencyException</p>
<p>See Also: -action -setTarget: -target</p>
*/
@ -1149,7 +1151,7 @@ static NSColor *dtxtCol;
format: @"attempt to set a target in an NSCell"];
}
/**<p>Implemented by subclass to return the target object.
/**<p>Implemented by subclass to return the target object.
The NSCell implementation returns nil</p>
<p>See Also: -setTarget: -setAction: -action</p>
*/
@ -1177,7 +1179,7 @@ static NSColor *dtxtCol;
{
_action_mask |= NSPeriodicMask;
}
else
else
{
_action_mask &= ~NSPeriodicMask;
}
@ -1194,7 +1196,7 @@ static NSColor *dtxtCol;
return previousMask;
}
/**<p>Returns the NSCell's image if the NSCell's type is <ref type="type"
/**<p>Returns the NSCell's image if the NSCell's type is <ref type="type"
id="NSCellType">NSImageCellType</ref>,
returns nil otherwise.</p>
<p>See Also: -setImage: -setType: -type</p>
@ -1209,24 +1211,24 @@ static NSColor *dtxtCol;
return nil;
}
/**<p>Sets the NSCell's image to anImage. This method sets the cell's type
/**<p>Sets the NSCell's image to anImage. This method sets the cell's type
to NSImageCellType if needed. Raises an NSInvalidArgumentException if
the anImage is not an NSImage (sub)class. The new image is retained and the
old one is released</p><p>See Also: -image</p>
*/
- (void) setImage: (NSImage*)anImage
{
if (anImage)
if (anImage)
{
NSAssert ([anImage isKindOfClass: imageClass],
NSInvalidArgumentException);
}
if (_cell.type != NSImageCellType)
{
[self setType: NSImageCellType];
}
ASSIGN (_cell_image, anImage);
}
@ -1240,7 +1242,7 @@ static NSColor *dtxtCol;
format: @"attempt to set a tag in an NSCell"];
}
/**<p>Implemented by subclasses to Return the tag.
/**<p>Implemented by subclasses to Return the tag.
The NSCell implementation returns -1 </p><p>See Also: -setTag:</p>
*/
- (NSInteger) tag
@ -1268,7 +1270,7 @@ static NSColor *dtxtCol;
[format appendString: @"#"];
}
}
else
else
{
while (leftDigits--)
{
@ -1287,7 +1289,7 @@ static NSColor *dtxtCol;
RELEASE(formatter);
}
- (void) setFormatter: (NSFormatter*)newFormatter
- (void) setFormatter: (NSFormatter*)newFormatter
{
ASSIGN(_formatter, newFormatter);
}
@ -1318,12 +1320,12 @@ static NSColor *dtxtCol;
if ((_formatter != nil) && ![aString isEqualToString: @""])
{
id newObjectValue;
return [_formatter getObjectValue: &newObjectValue
forString: aString
return [_formatter getObjectValue: &newObjectValue
forString: aString
errorDescription: NULL];
}
else
else
{
return YES;
}
@ -1332,7 +1334,7 @@ static NSColor *dtxtCol;
/*
* Menu
*/
- (void) setMenu: (NSMenu*)aMenu
- (void) setMenu: (NSMenu*)aMenu
{
ASSIGN (_menu, aMenu);
}
@ -1342,8 +1344,8 @@ static NSColor *dtxtCol;
return _menu;
}
- (NSMenu*) menuForEvent: (NSEvent*)anEvent
inRect: (NSRect)cellFrame
- (NSMenu*) menuForEvent: (NSEvent*)anEvent
inRect: (NSRect)cellFrame
ofView: (NSView*)aView
{
return [self menu];
@ -1381,7 +1383,7 @@ static NSColor *dtxtCol;
return _cell.is_disabled == NO && _cell.refuses_first_responder == NO;
}
- (void) setShowsFirstResponder: (BOOL)flag
- (void) setShowsFirstResponder: (BOOL)flag
{
_cell.shows_first_responder = flag;
}
@ -1398,10 +1400,9 @@ static NSColor *dtxtCol;
if (r.length > 0)
{
NSUInteger location = r.location;
[self setTitle: [[aString substringToIndex: location]
stringByAppendingString:
[self setTitle: [[aString substringToIndex: location]
stringByAppendingString:
[aString substringFromIndex: NSMaxRange(r)]]];
// TODO: We should underline this character
[self setMnemonicLocation: location];
@ -1419,7 +1420,7 @@ static NSColor *dtxtCol;
return [c substringWithRange: NSMakeRange (location, 1)];
}
- (void) setMnemonicLocation: (NSUInteger)location
- (void) setMnemonicLocation: (NSUInteger)location
{
_cell.mnemonic_location = location;
}
@ -1448,7 +1449,7 @@ static NSColor *dtxtCol;
{
NSView *cv = [self controlView];
if (cv != nil)
if (cv != nil)
[self performClickWithFrame: [cv bounds] inView: cv];
}
@ -1493,17 +1494,17 @@ static NSColor *dtxtCol;
[self setNextState];
if ((controlView != nil) && [controlView canDraw])
{
{
NSWindow *cvWin = [controlView window];
NSDate *limit = [NSDate dateWithTimeIntervalSinceNow: 0.1];
[controlView lockFocus];
[self highlight: YES withFrame: cellFrame inView: controlView];
[cvWin flushWindow];
// Wait approx 1/10 seconds
[[NSRunLoop currentRunLoop] runUntilDate: limit];
[self highlight: NO withFrame: cellFrame inView: controlView];
[cvWin flushWindow];
[controlView unlockFocus];
@ -1577,11 +1578,21 @@ static NSColor *dtxtCol;
ASSIGN (_represented_object, anObject);
}
/**<p>Returns the mouse flags. This flags are usally sets in
- (NSBackgroundStyle)backgroundStyle
{
return(_cell.background_style);
}
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
{
_cell.background_style = backgroundStyle;
}
/**<p>Returns the mouse flags. This flags are usally sets in
the -trackMouse:inRect:ofView:untilMouseUp: method</p>
*/
- (NSInteger) mouseDownFlags
{
{
return _mouse_down_flags;
}
@ -1728,7 +1739,7 @@ static NSColor *dtxtCol;
NSWindow *w = [controlView window];
/*
* Too many periodic events in succession -
* Too many periodic events in succession -
* update the mouse location and reset the counter.
*/
location = [w mouseLocationOutsideOfEventStream];
@ -1767,7 +1778,7 @@ static NSColor *dtxtCol;
{
[self _sendActionFrom: controlView];
}
theEvent = [theApp nextEventMatchingMask: event_mask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
@ -1817,7 +1828,7 @@ static NSColor *dtxtCol;
{
if (_cell.type == NSImageCellType)
{
if ((_cell_image != nil) &&
if ((_cell_image != nil) &&
NSMouseInRect([controlView convertPoint: [event locationInWindow]
fromView: nil],
[self imageRectForBounds: [controlView bounds]],
@ -1884,7 +1895,7 @@ static NSColor *dtxtCol;
}
}
/**<p>Implemented by subclasses to returns the key equivalent.
/**<p>Implemented by subclasses to returns the key equivalent.
The NSCell implementation returns an empty NSString. </p>
*/
- (NSString*) keyEquivalent
@ -1901,11 +1912,11 @@ static NSColor *dtxtCol;
}
/**Returns the minimun size needed to display the NSCell.
This size is calculate by adding :
This size is calculate by adding :
<list>
<item> the borders (plain or bezeled) size</item>
<item> the spacing between the border and inside the cell</item>
<item> the TODO ... if the cell is type of NSTextCellType
<item> the TODO ... if the cell is type of NSTextCellType
or the image size if the cell has a NSImageCellType type.</item>
</list>
<p>This method returns NSZeroSize if the cell has a NSNullCellType type
@ -1924,10 +1935,10 @@ static NSColor *dtxtCol;
aType = NSBezelBorder;
else
aType = NSNoBorder;
borderSize = [[GSTheme theme] sizeForBorderType: aType];
// Add spacing between border and inside
// Add spacing between border and inside
if (_cell.is_bordered || _cell.is_bezeled)
{
borderSize.height += 1;
@ -1974,7 +1985,7 @@ static NSColor *dtxtCol;
// Add in border size
s.width += 2 * borderSize.width;
s.height += 2 * borderSize.height;
return s;
}
@ -2005,7 +2016,7 @@ static NSColor *dtxtCol;
aType = NSBezelBorder;
else
aType = NSNoBorder;
borderSize = [[GSTheme theme] sizeForBorderType: aType];
return NSInsetRect(theRect, borderSize.width, borderSize.height);
}
@ -2017,8 +2028,8 @@ static NSColor *dtxtCol;
if (_cell.type == NSImageCellType)
{
NSRect frame = [self drawingRectForBounds: theRect];
// Add spacing between border and inside
// Add spacing between border and inside
if (_cell.is_bordered || _cell.is_bezeled)
{
frame.origin.x += 3;
@ -2041,8 +2052,8 @@ static NSColor *dtxtCol;
if (_cell.type == NSTextCellType)
{
NSRect frame = [self drawingRectForBounds: theRect];
// Add spacing between border and inside
// Add spacing between border and inside
if (_cell.is_bordered || _cell.is_bezeled)
{
frame.origin.x += 3;
@ -2115,7 +2126,7 @@ static NSColor *dtxtCol;
NSPoint position;
NSRect drawingRect = [self imageRectForBounds: cellFrame];
NSRect rect;
size = [_cell_image size];
position.x = MAX(NSMidX(drawingRect) - (size.width/2.),0.);
position.y = MAX(NSMidY(drawingRect) - (size.height/2.),0.);
@ -2195,8 +2206,8 @@ static NSColor *dtxtCol;
/*
* NB: This has a visible effect only if subclasses override
* drawWithFrame:inView: to draw something special when the
* cell is highlighted.
* NSCell simply draws border+text/image and makes no highlighting,
* cell is highlighted.
* NSCell simply draws border+text/image and makes no highlighting,
* for easier subclassing.
*/
if ([self isOpaque] == NO)
@ -2332,7 +2343,7 @@ static NSColor *dtxtCol;
_cell.in_editing = YES;
}
/**<p>Ends any text editing. This method sets the text object's delegate
/**<p>Ends any text editing. This method sets the text object's delegate
to nil, and remove the NSClipView and the text object used for editing</p>
<p>See Also: -editWithFrame:inView:editor:delegate:event:</p>
*/
@ -2343,7 +2354,7 @@ static NSColor *dtxtCol;
_cell.in_editing = NO;
[textObject setString: @""];
[textObject setDelegate: nil];
clipView = (NSClipView*)[textObject superview];
if ([clipView isKindOfClass: [NSClipView class]])
{
@ -2403,7 +2414,7 @@ static NSColor *dtxtCol;
range: NSMakeRange(selStart, selLength)];
}
- (BOOL) sendsActionOnEndEditing
- (BOOL) sendsActionOnEndEditing
{
return _cell.sends_action_on_end_editing;
}
@ -2467,7 +2478,7 @@ static NSColor *dtxtCol;
cFlags |= (_action_mask & NSLeftMouseDraggedMask) ? 0x100 : 0;
cFlags |= (_action_mask & NSLeftMouseDownMask) ? 0x40000 : 0;
cFlags |= [self isContinuous] ? 0x80000 : 0;
cFlags |= [self isScrollable] ? 0x100000 : 0;
cFlags |= [self isScrollable] ? 0x100000 : 0;
cFlags |= [self isSelectable] ? 0x200000 : 0;
cFlags |= [self isBezeled] ? 0x400000 : 0;
cFlags |= [self isBordered] ? 0x800000 : 0;
@ -2477,9 +2488,10 @@ static NSColor *dtxtCol;
cFlags |= [self isHighlighted] ? 0x40000000 : 0;
cFlags |= ([self state] == NSOnState) ? 0x80000000 : 0;
[aCoder encodeInt: cFlags forKey: @"NSCellFlags"];
// flags part 2
cFlags2 |= ([self usesSingleLineMode] ? 0x40 : 0);
cFlags2 |= (([self allowsUndo] == NO) ? 0x1000 : 0);
cFlags2 |= ([self controlTint] << 5);
cFlags2 |= ([self lineBreakMode] << 9);
cFlags2 |= ([self controlSize] << 17);
@ -2490,7 +2502,7 @@ static NSColor *dtxtCol;
cFlags2 |= [self importsGraphics] ? 0x20000000 : 0;
cFlags2 |= [self allowsEditingTextAttributes] ? 0x40000000 : 0;
[aCoder encodeInt: cFlags2 forKey: @"NSCellFlags2"];
if (_cell.type == NSTextCellType)
{
// font and formatter.
@ -2498,7 +2510,7 @@ static NSColor *dtxtCol;
{
[aCoder encodeObject: [self font] forKey: @"NSSupport"];
}
if ([self formatter])
{
[aCoder encodeObject: [self formatter] forKey: @"NSFormatter"];
@ -2513,7 +2525,7 @@ static NSColor *dtxtCol;
{
BOOL flag;
unsigned int tmp_int;
[aCoder encodeObject: _contents];
[aCoder encodeObject: _cell_image];
[aCoder encodeObject: _font];
@ -2610,13 +2622,13 @@ static NSColor *dtxtCol;
self = [self init];
[self setObjectValue: contents];
}
if ([aDecoder containsValueForKey: @"NSCellFlags"])
{
unsigned long cFlags;
NSUInteger mask = 0;
cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"];
[self setFocusRingType: (cFlags & 0x3)];
[self setShowsFirstResponder: ((cFlags & 0x4) == 0x4)];
// This bit flag is the other way around!
@ -2645,7 +2657,7 @@ static NSColor *dtxtCol;
if ([aDecoder containsValueForKey: @"NSCellFlags2"])
{
int cFlags2;
cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"];
[self setUsesSingleLineMode: (cFlags2 & 0x40)];
[self setControlTint: ((cFlags2 & 0xE0) >> 5)];
@ -2674,7 +2686,7 @@ static NSColor *dtxtCol;
if ([aDecoder containsValueForKey: @"NSFormatter"])
{
NSFormatter *formatter = [aDecoder decodeObjectForKey: @"NSFormatter"];
[self setFormatter: formatter];
}
}
@ -2736,7 +2748,7 @@ static NSColor *dtxtCol;
_cell.state = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.mnemonic_location = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(NSUInteger)
[aDecoder decodeValueOfObjCType: @encode(NSUInteger)
at: &_mouse_down_flags];
[aDecoder decodeValueOfObjCType: @encode(NSUInteger) at: &_action_mask];
if (version < 3)
@ -2830,7 +2842,7 @@ static NSColor *dtxtCol;
}
_action_mask = mask;
}
_action_mask |= NSLeftMouseUpMask;
_action_mask |= NSLeftMouseUpMask;
[aDecoder decodeValueOfObjCType: @encode(id) at: &formatter];
[self setFormatter: formatter];
[aDecoder decodeValueOfObjCType: @encode(id) at: &menu];
@ -2871,7 +2883,7 @@ static NSColor *dtxtCol;
wraps attribute. */
[self setWraps: wraps];
}
if (version >= 4)
{
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
@ -2913,13 +2925,13 @@ static NSColor *dtxtCol;
if (_cell.is_disabled)
return dtxtCol;
else
return txtCol;
return txtCol;
}
/* This method is an exception and returns a non-autoreleased
dictionary, so that calling methods can deallocate it immediately
using release. Otherwise if many cells are drawn/their size
computed, we pile up hundreds or thousands of these objects before they
computed, we pile up hundreds or thousands of these objects before they
are deallocated at the end of the run loop. */
- (NSDictionary*) _nonAutoreleasedTypingAttributes
{
@ -2928,14 +2940,14 @@ static NSColor *dtxtCol;
NSMutableParagraphStyle *paragraphStyle;
color = [self textColor];
/* Note: There are only a few possible paragraph styles for cells.
/* Note: There are only a few possible paragraph styles for cells.
TODO: Cache them and reuse them for the whole app lifetime. */
paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: [self lineBreakMode]];
[paragraphStyle setBaseWritingDirection: [self baseWritingDirection]];
[paragraphStyle setAlignment: [self alignment]];
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
_font, NSFontAttributeName,
color, NSForegroundColorAttributeName,
paragraphStyle, NSParagraphStyleAttributeName,
@ -2966,7 +2978,7 @@ static NSColor *dtxtCol;
- (NSAttributedString*) _drawAttributedString
{
if (!_cell.is_disabled)
{
{
return [self attributedStringValue];
}
else
@ -2974,23 +2986,62 @@ static NSColor *dtxtCol;
NSAttributedString *attrStr = [self attributedStringValue];
NSDictionary *attribs;
NSMutableDictionary *newAttribs;
attribs = [attrStr attributesAtIndex: 0
attribs = [attrStr attributesAtIndex: 0
effectiveRange: NULL];
newAttribs = [NSMutableDictionary dictionaryWithDictionary: attribs];
[newAttribs setObject: [NSColor disabledControlTextColor]
forKey: NSForegroundColorAttributeName];
return AUTORELEASE([[NSAttributedString alloc]
initWithString: [attrStr string]
attributes: newAttribs]);
}
}
- (BOOL) _shouldShortenStringForRect: (NSRect)titleRect size: (NSSize)titleSize length: (NSUInteger)length
{
NSLineBreakMode mode = [self lineBreakMode];
return ((titleSize.width > titleRect.size.width) && (length > 4) &&
(mode == NSLineBreakByTruncatingHead ||
mode == NSLineBreakByTruncatingTail ||
mode == NSLineBreakByTruncatingMiddle));
}
- (NSAttributedString*) _resizeAttributedString: (NSAttributedString*)attrstring forRect: (NSRect)titleRect
{
// Redo string based on selected truncation mask...
NSMutableAttributedString *mutableString = AUTORELEASE([attrstring mutableCopy]);
NSString *ellipsis = @"...";
NSLineBreakMode mode = [self lineBreakMode];
// This code shortens the string one character at a time.
// To speed it up we start off proportional:
CGFloat width = [mutableString size].width;
int cut = MAX(floor([mutableString length] * (width - titleRect.size.width) / width), 4);
do
{
NSRange replaceRange;
if (mode == NSLineBreakByTruncatingHead)
replaceRange = NSMakeRange(0, cut);
else if (mode == NSLineBreakByTruncatingTail)
replaceRange = NSMakeRange([mutableString length] - cut, cut);
else
replaceRange = NSMakeRange(([mutableString length] / 2) - (cut / 2), cut);
[mutableString replaceCharactersInRange: replaceRange withString: ellipsis];
cut = 4;
} while ([mutableString length] > 4 && [mutableString size].width > titleRect.size.width);
// Return the modified attributed string...
return mutableString;
}
/**
* Private internal method to display an attributed string.
*/
- (void) _drawAttributedText: (NSAttributedString*)aString
- (void) _drawAttributedText: (NSAttributedString*)aString
inFrame: (NSRect)aRect
{
NSSize titleSize;
@ -2999,13 +3050,18 @@ static NSColor *dtxtCol;
return;
titleSize = [aString size];
if ([self _shouldShortenStringForRect: aRect size: titleSize length: [aString length]])
{
aString = [self _resizeAttributedString: aString forRect: aRect];
titleSize = [aString size];
}
/** Important: text should always be vertically centered without
* considering descender [as if descender did not exist].
* This is particularly important for single line texts.
* Please make sure the output remains always correct.
*/
aRect.origin.y = NSMidY (aRect) - titleSize.height/2;
aRect.origin.y = NSMidY (aRect) - titleSize.height/2;
aRect.size.height = titleSize.height;
[aString drawInRect: aRect];
@ -3021,13 +3077,19 @@ static NSColor *dtxtCol;
attributes = [self _nonAutoreleasedTypingAttributes];
titleSize = [aString sizeWithAttributes: attributes];
if ([self _shouldShortenStringForRect: cellFrame size: titleSize length: [aString length]])
{
NSAttributedString *attrstring = AUTORELEASE([[NSAttributedString alloc] initWithString: aString
attributes: attributes]);
return [self _drawAttributedText: attrstring inFrame: cellFrame];
}
/** Important: text should always be vertically centered without
* considering descender [as if descender did not exist].
* This is particularly important for single line texts.
* Please make sure the output remains always correct.
*/
cellFrame.origin.y = NSMidY (cellFrame) - titleSize.height/2;
cellFrame.origin.y = NSMidY (cellFrame) - titleSize.height/2;
cellFrame.size.height = titleSize.height;
[aString drawInRect: cellFrame withAttributes: attributes];
@ -3035,7 +3097,7 @@ static NSColor *dtxtCol;
}
// Private helper method overridden in subclasses
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
inView: (NSView*)controlView
{
NSBorderType aType;
@ -3071,7 +3133,7 @@ static NSColor *dtxtCol;
case NSFocusRingTypeNone:
default:
break;
}
}
}
}
@ -3117,7 +3179,7 @@ static NSColor *dtxtCol;
{
if (_formatter != nil)
{
NSString *contents;
NSString *contents;
contents = [_formatter editingStringForObjectValue: _object_value];
if (contents == nil)
@ -3145,7 +3207,7 @@ static NSColor *dtxtCol;
}
else
{
NSString *contents;
NSString *contents;
if (nil == _contents)
{
@ -3198,7 +3260,7 @@ scaleProportionally(NSSize imageSize, NSSize canvasSize, BOOL scaleUpOrDown)
/* Get the smaller ratio and scale the image size by it. */
ratio = MIN(canvasSize.width / imageSize.width,
canvasSize.height / imageSize.height);
/* Only scale down, unless scaleUpOrDown is YES */
if (ratio < 1.0 || scaleUpOrDown)
{

View file

@ -29,6 +29,7 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSException.h>
@ -43,6 +44,7 @@
#import "AppKit/NSKeyValueBinding.h"
#import "GSBindingHelpers.h"
#import "GSFastEnumeration.h"
@implementation NSObject (NSKeyValueBindingCreation)
@ -345,7 +347,10 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
- (void) setValueFor: (NSString *)binding
{
[src setValue: [self destinationValue] forKey: binding];
id value = [self destinationValue];
NSDebugLLog(@"NSBinding", @"setValueFor: binding %@, source %@ value %@", binding, src, value);
[src setValue: value forKey: binding];
}
- (void) reverseSetValue: (id)value
@ -355,6 +360,7 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
keyPath = [info objectForKey: NSObservedKeyPathKey];
dest = [info objectForKey: NSObservedObjectKey];
NSDebugLLog(@"NSBinding", @"reverseSetValue: keyPath %@, dest %@ value %@", keyPath, dest, value);
[dest setValue: value forKeyPath: keyPath];
}
@ -377,6 +383,7 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
options = [info objectForKey: NSOptionsKey];
newValue = [change objectForKey: NSKeyValueChangeNewKey];
newValue = [self transformValue: newValue withOptions: options];
NSDebugLLog(@"NSBinding", @"observeValueForKeyPath: binding %@, keyPath %@, source %@ value %@", binding, keyPath, src, newValue);
[src setValue: newValue forKey: binding];
}
}
@ -444,7 +451,21 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
if (valueTransformer != nil)
{
value = [valueTransformer transformedValue: value];
if ([value isKindOfClass: [NSArray class]])
{
NSArray *oldValue = (NSArray *)value;
NSMutableArray *newValue = [[NSMutableArray alloc] initWithCapacity: [oldValue count]];
id<NSFastEnumeration> enumerator = oldValue;
FOR_IN (id, obj, enumerator)
[newValue addObject: [valueTransformer transformedValue: obj]];
END_FOR_IN(enumerator)
value = AUTORELEASE(newValue);
}
else
{
value = [valueTransformer transformedValue: value];
}
}
return value;
@ -477,6 +498,12 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
return value;
}
- (NSString*) description
{
return [NSString stringWithFormat:
@"GSKeyValueBinding src (%@) info %@", src, info];
}
@end
@implementation GSKeyValueOrBinding : GSKeyValueBinding

View file

@ -76,6 +76,7 @@
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSMatrix.h"
#import "AppKit/NSWindow.h"
#import "GSCodingFlags.h"
#include <math.h>
@ -129,40 +130,6 @@ typedef struct {
NSInteger height;
} MRect;
typedef struct _GSMatrixFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHighlight:1;
unsigned int isRadio:1;
unsigned int isList:1;
unsigned int allowsEmptySelection:1;
unsigned int autoScroll:1;
unsigned int selectionByRect:1;
unsigned int drawCellBackground:1;
unsigned int drawBackground:1;
unsigned int autosizesCells:1;
unsigned int drawingAncestor:1;
unsigned int tabKeyTraversesCells:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int canSearchIncrementally:1;
unsigned int unused:19;
#else
unsigned int unused:19;
unsigned int canSearchIncrementally:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int tabKeyTraversesCells:1;
unsigned int drawingAncestor:1;
unsigned int autosizesCells:1;
unsigned int drawBackground:1;
unsigned int drawCellBackground:1;
unsigned int selectionByRect:1;
unsigned int autoScroll:1;
unsigned int allowsEmptySelection:1;
unsigned int isList:1;
unsigned int isRadio:1;
unsigned int isHighlight:1;
#endif
} GSMatrixFlags;
static inline MPoint MakePoint (NSInteger x, NSInteger y)
{
MPoint point = { x, y };

View file

@ -145,10 +145,15 @@
if ([aDecoder allowsKeyedCoding])
{
if ([aDecoder decodeIntForKey: @"NSNibBindingConnectorVersion"] != 2)
if ([aDecoder containsValueForKey: @"NSNibBindingConnectorVersion"])
{
RELEASE(self);
return nil;
int version = [aDecoder decodeIntForKey: @"NSNibBindingConnectorVersion"];
if (version != 2)
{
NSLog(@"Unexpected NSNibBindingConnectorVersion %d", version);
RELEASE(self);
return nil;
}
}
if ([aDecoder containsValueForKey: @"NSBinding"])
{

View file

@ -67,6 +67,7 @@ Class _nspopupbuttonCellClass = 0;
[self exposeBinding: NSSelectedIndexBinding];
[self exposeBinding: NSSelectedObjectBinding];
[self exposeBinding: NSSelectedTagBinding];
[self exposeBinding: NSSelectedValueBinding];
[self exposeBinding: NSContentValuesBinding];
}
}
@ -571,8 +572,13 @@ this to return nil to indicate that we have no context menu.
}
else if ([aKey isEqual: NSSelectedObjectBinding])
{
// FIXME: This looks wrong to me
[self selectItemWithTag: [anObject intValue]];
}
else if ([aKey isEqual: NSSelectedValueBinding])
{
[self selectItemWithTitle: anObject];
}
else if ([aKey isEqual: NSContentValuesBinding])
{
[self removeAllItems];
@ -596,8 +602,13 @@ this to return nil to indicate that we have no context menu.
}
else if ([aKey isEqual: NSSelectedObjectBinding])
{
// FIXME
return [NSNumber numberWithInt: [self selectedTag]];
}
else if ([aKey isEqual: NSSelectedValueBinding])
{
return [self titleOfSelectedItem];
}
else if ([aKey isEqual: NSContentValuesBinding])
{
return [self itemTitles];

View file

@ -1385,22 +1385,20 @@ static NSImage *_pbc_image[5];
if (_control_view)
{
GSKeyValueBinding *theBinding;
NSString *bindings[] = {NSSelectedIndexBinding, NSSelectedTagBinding,
NSSelectedObjectBinding, NSSelectedValueBinding};
int i;
theBinding = [GSKeyValueBinding getBinding: NSSelectedIndexBinding
forObject: _control_view];
if (theBinding != nil)
[theBinding reverseSetValueFor: NSSelectedIndexBinding];
for (i = 0; i < 4; i++)
{
NSString *binding = bindings[i];
GSKeyValueBinding *theBinding;
theBinding = [GSKeyValueBinding getBinding: NSSelectedTagBinding
forObject: _control_view];
if (theBinding != nil)
[theBinding reverseSetValueFor: NSSelectedTagBinding];
theBinding = [GSKeyValueBinding getBinding: NSSelectedObjectBinding
forObject: _control_view];
if (theBinding != nil)
[theBinding reverseSetValueFor: NSSelectedObjectBinding];
theBinding = [GSKeyValueBinding getBinding: binding
forObject: _control_view];
if (theBinding != nil)
[theBinding reverseSetValueFor: binding];
}
}
[NSApp sendAction: [self action] to: [self target] from: _control_view];

View file

@ -47,4 +47,38 @@
ASSIGN(_rowTemplates, templates);
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _rowTemplates forKey: @"NSRowTemplates"];
}
else
{
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if (nil == self)
{
return nil;
}
if ([aDecoder allowsKeyedCoding])
{
NSArray *rowTemplates = [aDecoder decodeObjectForKey: @"NSRowTemplates"];
[self setRowTemplates: rowTemplates];
}
else
{
}
return self;
}
@end

View file

@ -230,4 +230,24 @@
{
}
- (void) setAction: (SEL)action
{
_action = action;
}
- (SEL) action
{
return _action;
}
- (void) setTarget: (id)target
{
_target = target;
}
- (id) target
{
return _target;
}
@end

View file

@ -160,6 +160,9 @@
{
[_delegate tabViewDidChangeNumberOfTabViewItems: self];
}
/* TODO (Optimize) - just mark the tabs rect as needing redisplay */
[self setNeedsDisplay: YES];
}
- (NSInteger) indexOfTabViewItem: (NSTabViewItem*)tabViewItem

View file

@ -2000,6 +2000,7 @@ static void computeNewSelection
// FIXME
[self exposeBinding: NSContentBinding];
[self exposeBinding: NSSelectionIndexesBinding];
[self exposeBinding: NSSortDescriptorsBinding];
}
}
@ -2783,7 +2784,7 @@ byExtendingSelection: (BOOL)flag
if ([indexes lastIndex] >= _numberOfColumns)
{
[NSException raise: NSInvalidArgumentException
format: @"Column index out of table in selectColumn"];
format: @"Column index out of table in selectColumn"];
}
/* This check is not fully correct, as both sets may contain just
@ -2792,7 +2793,7 @@ byExtendingSelection: (BOOL)flag
[_selectedColumns count] + [indexes count] > 1)
{
[NSException raise: NSInternalInconsistencyException
format: @"Can not set multiple selection in table view when multiple selection is disabled"];
format: @"Can not set multiple selection in table view when multiple selection is disabled"];
}
col = [indexes firstIndex];
@ -2866,7 +2867,7 @@ byExtendingSelection: (BOOL)flag
if ([indexes lastIndex] >= _numberOfRows)
{
[NSException raise: NSInvalidArgumentException
format: @"Row index out of table in selectRow"];
format: @"Row index out of table in selectRow"];
}
/* This check is not fully correct, as both sets may contain just
@ -6670,7 +6671,7 @@ For a more detailed explanation, -setSortDescriptors:. */
forObject: tb];
if (theBinding != nil)
{
return [(NSArray *)[theBinding sourceValueFor: NSValueBinding]
return [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
}
else if ([_dataSource respondsToSelector:
@ -6712,7 +6713,7 @@ For a more detailed explanation, -setSortDescriptors:. */
forObject: self];
if (theBinding != nil)
{
return [(NSArray *)[theBinding sourceValueFor: NSContentBinding] count];
return [(NSArray *)[theBinding destinationValue] count];
}
else if ([_dataSource respondsToSelector:
@selector(numberOfRowsInTableView:)])
@ -6931,7 +6932,7 @@ For a more detailed explanation, -setSortDescriptors:. */
{
// Reload data
[self reloadData];
NSLog(@"Setting TV content to %@", anObject);
NSDebugLLog(@"NSBinding", @"Setting table view content to %@", anObject);
}
else if ([aKey isEqual: NSSelectionIndexesBinding])
{

File diff suppressed because it is too large Load diff

View file

@ -1690,9 +1690,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
if ([aCoder containsValueForKey: @"NSToolbarItemLabel"])
[self setLabel: [aCoder decodeObjectForKey:@"NSToolbarItemLabel"]];
if ([aCoder containsValueForKey: @"NSToolbarItemMinSize"])
[self setMinSize: NSSizeFromString([aCoder decodeObjectForKey:@"NSToolbarItemMinSize"])];
[self setMinSize: [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"]];
if ([aCoder containsValueForKey: @"NSToolbarItemMaxSize"])
[self setMaxSize: NSSizeFromString([aCoder decodeObjectForKey:@"NSToolbarItemMaxSize"])];
[self setMaxSize: [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"]];
if ([aCoder containsValueForKey: @"NSToolbarItemAutovalidates"])
[self setAutovalidates: [aCoder decodeBoolForKey:@"NSToolbarItemAutovalidates"]];
if ([aCoder containsValueForKey: @"NSToolbarItemVisibilityPriority"])

View file

@ -761,7 +761,9 @@ NSString *NSHiddenBinding = @"hidden";
NSString *NSSelectedIndexBinding = @"selectedIndex";
NSString *NSSelectedObjectBinding = @"selectedObject";
NSString *NSSelectedTagBinding = @"selectedTag";
NSString *NSSelectedValueBinding = @"selectedValue";
NSString *NSSelectionIndexesBinding = @"selectionIndexes";
NSString *NSSortDescriptorsBinding = @"sortDescriptors";
NSString *NSTextColorBinding = @"textColor";
NSString *NSTitleBinding = @"title";
NSString *NSToolTipBinding = @"toolTip";