Update gitignore

This commit is contained in:
Gregory John Casamento 2020-01-25 13:19:33 -05:00
commit 2f50bad42f
83 changed files with 9772 additions and 3737 deletions

3
.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
@ -54,4 +55,4 @@ DerivedData/
### Xcode Patch ###
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.gitignore.io/api/xcode
# End of https://www.gitignore.io/api/xcode

224
ChangeLog
View file

@ -1,3 +1,227 @@
2020-01-23 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXib5KeyedUnarchiver.m: Remove NSWindowTemplate5.
* Source/GSXibLoader.m: Clean up code.
* Headers/Additions/GNUstepGUI/GSXibKeyedUnarchiver.h,
* Source/GSXibKeyedUnarchiver.m: Provide method to load both sorts
of XIB files.
* Source/NSArrayController.m: Add horrible hack to get KVB on
array controller to work.
2020-01-22 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXib5KeyedUnarchiver.m,
* Headers/Additions/GNUstepGUI/GSNibLoading.h,
* Source/GSXibLoading.m: Move toolbar ivar from NSWindowTemplate5
to NSWindowTemplate.
2020-01-22 Fred Kiefer <FredKiefer@gmx.de>
* TextConverters/RTF/rtfScanner.m: Add RTFansicpg.
* TextConverters/RTF/rtfGrammar.y: Handle encoding and code pages.
* TextConverters/RTF/rtfGrammar.tab.h,
* TextConverters/RTF/rtfGrammar.tab.m: Regenerated.
* TextConverters/RTF/RTFConsumerFunctions.h,
* TextConverters/RTF/RTFConsumer.m: Add code to handle encoding.
2020-01-20 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSAppearance.h,
* Source/NSPDFInfo.m,
* Source/NSWorkspace.m: Fix compiler warnings.
2020-01-19 Fred Kiefer <FredKiefer@gmx.de>
* 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.
2020-01-10 Sergii Stoian <stoyan255@gmail.com>
* Images/common_StepperDown.tiff,
* Images/common_StepperDownHighlighted.tiff,
* Images/common_StepperUp.tiff,
* Images/common_StepperUpHighlighted.tiff: new images with arrows
similar to scroll view buttons'.
* Source/GSThemeDrawing.m (stepperUpButtonRectWithFrame:),
(stepperDownButtonRectWithFrame:): center buttons horizontally; simplify
and cleanup.
* Source/NSStepper.m (acceptsFirstResponder): return NO. Returning
YES makes sense only if `keyDown:` is implemented.
(acceptsFirstMouse:): return YES.
* 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/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
over from mySTEP.
2020-01-06 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSDatePickerCell.h,
* Headers/AppKit/NSDatePicker.h,
* Source/NSDatePickerCell.m,
* Source/NSDatePicker.m: Add minimal version of date picker copied
over from mySTEP.
2019-12-29 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBundleAdditions.m (-pathForNibResource:): Report type
not filename while iterating.
2019-12-18 Sergii Stoian <stoyan255@gmail.com>
* Source/NSBrowser.m (frameOfColumn:): shift up column only for browser
with separated columns layout.
(tile): fix column height calculation; moved sanity check of column
height closer to calculation; removed code that duplicates code below.
2019-12-17 Sergii Stoian <stoyan255@gmail.com>
* Source/NSScrollView.m (tile): tweak location and height of vertical
scroller if header or corner view available.
* Source/GSThemeDrawing.m: (drawTableCornerView:withClip:): do not draw
black rectangle because -drawDarkButton:withClip: draws all necessary
elements.
* Source/GSThemeDrawing.m (drawScrollViewRect:inView:): further cleanup
of method implementation. Removed all tweaks of scroller length - all
required calculations must be done in NSScrollView's -tile method. Simplified
caluclations of X and Y positions of scroller.
2019-12-17 Sergii Stoian <stoyan255@gmail.com>
* Source/GSThemeDrawing.m (drawScrollViewRect:inView:): fixed scroller
border positionning and length - do not overlap border if any.
Use [self sizeForBorderType: borderType] to determine border width.
2019-12-12 Sergii Stoian <stoyan255@gmail.com>
* Source/NSFont.m (smallSystemFontSize): return 10 as default value.
Update documention comment regarding default values for NSMiniFontSize
ans NSSmallFontSize.
2019-12-11 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m
(initialize): use MiniWindowTile image for miniwindow tile.
(drawRect:): adjusted position of title cell to fit tile image.
(setTitle:): disable drawing of title cell background;
use NSMiniControlSize font size for miniwindow title cell.
* Source/NSFont.m (systemFontSizeForControlSize:): increased default font
size for NSMiniControlSize.
2019-12-11 Sergii Stoian <stoyan255@gmail.com>
* Source/GSHorizontalTypesetter.m: removed extra imports left from
last 2 commits.
2019-12-10 Sergii Stoian <stoyan255@gmail.com>
* Headers/Additions/GNUstepGUI/GSLayoutManager.h,
* Source/GSLayoutManager.m: new method -typingAttributes returns default
typing attributes of NSTextView.
* Source/NSLayoutManager.m: override GSLayoutManager's -typingAttributes
- primitive method - provides access to _typingAttributes ivar.
* Source/GSHorizontalTypesetter.m: use new GSLayoutManager's
-typingAttributes method to get paragraph style and font of new empty text
container. Normally `curLayoutManager` is a NSLayoutManager object so,
actually, we get NSLayoutManager's _typingAttributes.
* Source/GSHorizontalTypesetter.m: (_addExtraLineFragment) get paragraph
style and font from NSLayoutManager's typing attributes. Fixes insertion
point height for empty text objects (NSTextView, NSTexField etc.).
2019-12-09 Sergii Stoian <stoyan255@gmail.com>
* Source/NSStringDrawing.m: fixed incorrect string drawing (shortened, misplaced)

View file

@ -168,6 +168,7 @@ If characters have been edited, lengthChange has the text length delta.
forStartingGlyphAtIndex: (NSUInteger)glyph
characterIndex: (NSUInteger)index;
- (NSDictionary *) typingAttributes;
@end

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;
@ -137,6 +143,7 @@ typedef struct _GSWindowTemplateFlags
GSWindowTemplateFlags _flags;
NSString *_autosaveName;
Class _baseWindowClass;
NSToolbar *_toolbar;
}
- (id) initWithWindow: (NSWindow *)window
className: (NSString *)windowClass
@ -213,6 +220,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

@ -43,6 +43,9 @@
NSMutableDictionary *decoded;
}
+ (BOOL) checkXib5: (NSData *)data;
+ (NSKeyedUnarchiver *) unarchiverForReadingWithData: (NSData *)data;
- (void) _initCommon;
- (id) decodeObjectForXib: (GSXibElement*)element
forClassName: (NSString*)classname

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

@ -48,6 +48,7 @@
#import <AppKit/NSAccessibilityConstants.h>
#import <AppKit/NSActionCell.h>
#import <AppKit/NSAnimationContext.h>
#import <AppKit/NSAppearance.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSAttributedString.h>
#import <AppKit/NSBitmapImageRep.h>
@ -71,6 +72,7 @@
#import <AppKit/NSControl.h>
#import <AppKit/NSCursor.h>
#import <AppKit/NSCustomImageRep.h>
#import <AppKit/NSDataAsset.h>
#import <AppKit/NSDataLink.h>
#import <AppKit/NSDataLinkManager.h>
#import <AppKit/NSDataLinkPanel.h>
@ -147,6 +149,8 @@
#import <AppKit/NSClickGestureRecognizer.h>
#import <AppKit/NSColorPickerTouchBarItem.h>
#import <AppKit/NSCustomTouchBarItem.h>
#import <AppKit/NSDatePicker.h>
#import <AppKit/NSDatePickerCell.h>
#import <AppKit/NSDockTile.h>
#import <AppKit/NSDocument.h>
#import <AppKit/NSDocumentController.h>
@ -172,6 +176,8 @@
#import <AppKit/NSMovieView.h>
#import <AppKit/NSPanGestureRecognizer.h>
#import <AppKit/NSNib.h>
#import <AppKit/NSNibControlConnector.h>
#import <AppKit/NSNibOutletConnector.h>
#import <AppKit/NSNibDeclarations.h>
#import <AppKit/NSObjectController.h>
#import <AppKit/NSOpenGL.h>
@ -179,9 +185,12 @@
#import <AppKit/NSOutlineView.h>
#import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSPickerTouchBarItem.h>
#import <AppKit/NSPredicateEditor.h>
#import <AppKit/NSPredicateEditorRowTemplate.h>
#import <AppKit/NSProgressIndicator.h>
#import <AppKit/NSPopoverTouchBarItem.h>
#import <AppKit/NSPressGestureRecognizer.h>
#import <AppKit/NSRuleEditor.h>
#import <AppKit/NSRulerMarker.h>
#import <AppKit/NSRulerView.h>
#import <AppKit/NSRotationGestureRecognizer.h>
@ -212,6 +221,8 @@
#import <AppKit/NSTextStorage.h>
#import <AppKit/NSTextTable.h>
#import <AppKit/NSTextView.h>
#import <AppKit/NSTouch.h>
#import <AppKit/NSTouchBar.h>
#import <AppKit/NSTouchBarItem.h>
#import <AppKit/NSTokenField.h>
#import <AppKit/NSTokenFieldCell.h>

View file

@ -0,0 +1,84 @@
/* Definition of class NSAppearance
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Jan 15 07:03:39 EST 2020
This file is part of the GNUstep 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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSAppearance_h_GNUSTEP_GUI_INCLUDE
#define _NSAppearance_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#import <Foundation/NSBundle.h>
#import <AppKit/AppKitDefines.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
typedef NSString* NSAppearanceName;
@interface NSAppearance : NSObject <NSCoding>
{
NSString *_name;
BOOL _allowsVibrancy;
NSAppearanceName _currentAppearance;
}
// Creating an appearance...
+ (instancetype) appearanceNamed: (NSString *)name;
- (instancetype) initWithAppearanceNamed: (NSString *)name bundle: (NSBundle *)bundle;
// Getting the appearance name
- (NSString *) name;
// Determining the most appropriate appearance
- (NSAppearanceName) bestMatchFromAppearancesWithNames: (NSArray *)appearances;
// Getting and setting the appearance
+ (void) setCurrentAppearance: (NSAppearance *)appearance;
+ (NSAppearance *) currentAppearance;
// Managing vibrancy
- (BOOL) allowsVibrancy;
@end
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameAqua;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameDarkAqua;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameVibrantLight;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameVibrantDark;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameAccessibilityHighContrastAqua;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameAccessibilityHighContrastDarkAqua;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameAccessibilityHighContrastVibrantLight;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameAccessibilityHighContrastVibrantDark;
APPKIT_EXPORT NSAppearanceName const NSAppearanceNameLightContent;
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSAppearance_h_GNUSTEP_GUI_INCLUDE */

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

@ -0,0 +1,68 @@
/* Definition of class NSDataAsset
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Fri Jan 17 10:25:34 EST 2020
This file is part of the GNUstep 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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSDataAsset_h_GNUSTEP_GUI_INCLUDE
#define _NSDataAsset_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSData, NSBundle, NSString;
typedef NSString* NSDataAssetName;
@interface NSDataAsset : NSObject <NSCopying>
{
NSDataAssetName _name;
NSBundle *_bundle;
NSData *_data;
NSString *_typeIdentifier;
}
// Initializing the Data Asset
- (instancetype) initWithName: (NSDataAssetName)name;
- (instancetype) initWithName: (NSDataAssetName)name bundle: (NSBundle *)bundle;
// Accessing data...
- (NSData *) data;
// Getting data asset information
- (NSDataAssetName) name;
- (NSString *) typeIdentifier;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSDataAsset_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,82 @@
/* -*-objc-*-
NSDatePicker.h
The date picker class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
Copyright (c) 2005 DSITRI.
Author: Fabian Spillner
Date: 22. October 2007
Author: Fabian Spillner <fabian.spillner@gmail.com>
Date: 7. November 2007 - aligned with 10.5
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_NSDatePicker
#define _GNUstep_H_NSDatePicker
#import <AppKit/NSControl.h>
#import <AppKit/NSDatePickerCell.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
@interface NSDatePicker : NSControl
- (NSColor *) backgroundColor;
- (NSCalendar *) calendar;
- (NSDatePickerElementFlags) datePickerElements;
- (NSDatePickerMode) datePickerMode;
- (NSDatePickerStyle) datePickerStyle;
- (NSDate *) dateValue;
- (id) delegate;
- (BOOL) drawsBackground;
- (BOOL) isBezeled;
- (BOOL) isBordered;
- (NSLocale *) locale;
- (NSDate *) maxDate;
- (NSDate *) minDate;
- (void) setBackgroundColor:(NSColor *) color;
- (void) setBezeled:(BOOL) flag;
- (void) setBordered:(BOOL) flag;
- (void) setCalendar:(NSCalendar *) calendar;
- (void) setDatePickerElements:(NSDatePickerElementFlags) flags;
- (void) setDatePickerMode:(NSDatePickerMode) mode;
- (void) setDatePickerStyle:(NSDatePickerStyle) style;
- (void) setDateValue:(NSDate *) date;
- (void) setDelegate:(id) obj; /* DOESNT EXIST IN API */
- (void) setDrawsBackground:(BOOL) flag;
- (void) setLocale:(NSLocale *) locale;
- (void) setMaxDate:(NSDate *) date;
- (void) setMinDate:(NSDate *) date;
- (void) setTextColor:(NSColor *) color;
- (void) setTimeInterval:(NSTimeInterval) interval;
- (void) setTimeZone:(NSTimeZone *) zone;
- (NSColor *) textColor;
- (NSTimeInterval) timeInterval;
- (NSTimeZone *) timeZone;
@end
#endif
#endif /* _GNUstep_H_NSDatePicker */

View file

@ -0,0 +1,120 @@
/* -*-objc-*-
NSDatePickerCell.h
The date picker cell class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
Author: Fabian Spillner
Date: 22. October 2007
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_NSDatePickerCell
#define _GNUstep_H_NSDatePickerCell
#import <AppKit/NSActionCell.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
enum {
NSTextFieldAndStepperDatePickerStyle = 0,
NSClockAndCalendarDatePickerStyle = 1,
NSTextFieldDatePickerStyle = 2
};
typedef NSUInteger NSDatePickerStyle;
enum {
NSSingleDateMode = 0,
NSRangeDateMode = 1
};
typedef NSUInteger NSDatePickerMode;
enum {
NSHourMinuteDatePickerElementFlag = 0x000c,
NSHourMinuteSecondDatePickerElementFlag = 0x000e,
NSTimeZoneDatePickerElementFlag = 0x0010,
NSYearMonthDatePickerElementFlag = 0x00c0,
NSYearMonthDayDatePickerElementFlag = 0x00e0,
NSEraDatePickerElementFlag = 0x0100,
};
typedef NSUInteger NSDatePickerElementFlags;
@class NSColor, NSDate, NSCalendar, NSLocale, NSTimeZone;
@interface NSDatePickerCell : NSActionCell
{
NSColor *_backgroundColor;
NSColor *_textColor;
NSDate *_maxDate;
NSDate *_minDate;
id _delegate;
NSTimeInterval _timeInterval;
// FIXME: pack into a bitfield?
NSDatePickerElementFlags _datePickerElements;
NSDatePickerMode _datePickerMode;
NSDatePickerStyle _datePickerStyle;
BOOL _drawsBackground;
}
- (NSColor *) backgroundColor;
- (NSCalendar *) calendar;
- (NSDatePickerElementFlags) datePickerElements;
- (NSDatePickerMode) datePickerMode;
- (NSDatePickerStyle) datePickerStyle;
- (NSDate *) dateValue;
- (id) delegate;
- (BOOL) drawsBackground;
- (NSLocale *) locale;
- (NSDate *) maxDate;
- (NSDate *) minDate;
- (void) setBackgroundColor:(NSColor *) color;
- (void) setCalendar:(NSCalendar *) calendar;
- (void) setDatePickerElements:(NSDatePickerElementFlags) flags;
- (void) setDatePickerMode:(NSDatePickerMode) mode;
- (void) setDatePickerStyle:(NSDatePickerStyle) style;
- (void) setDateValue:(NSDate *) date;
- (void) setDelegate:(id) obj;
- (void) setDrawsBackground:(BOOL) flag;
- (void) setLocale:(NSLocale *) locale;
- (void) setMaxDate:(NSDate *) date;
- (void) setMinDate:(NSDate *) date;
- (void) setTextColor:(NSColor *) color;
- (void) setTimeInterval:(NSTimeInterval) interval;
- (void) setTimeZone:(NSTimeZone *) zone;
- (NSColor *) textColor;
- (NSTimeInterval) timeInterval;
- (NSTimeZone *) timeZone;
@end
@interface NSObject (NSDataPickerCellDelegate)
- (void)datePickerCell:(NSDatePickerCell *) aDatePickerCell
validateProposedDateValue:(NSDate **) proposedDateValue
timeInterval:(NSTimeInterval *) proposedTimeInterval;
@end
#endif
#endif /* _GNUstep_H_NSDatePickerCell */

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

@ -50,13 +50,8 @@
- (void) setSource: (id)anObject;
@end
@interface NSNibControlConnector : NSNibConnector
- (void) establishConnection;
@end
@interface NSNibOutletConnector : NSNibConnector
- (void) establishConnection;
@end
#import <AppKit/NSNibControlConnector.h>
#import <AppKit/NSNibOutletConnector.h>
#endif

View file

@ -0,0 +1,37 @@
/*
NSNibControlConnector.h
Copyright (C) 1999 Free Software Foundation, Inc.
Author: Richard Frith-Macdonald <richard@branstorm.co.uk>
Date: 1999
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU 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_NSNibControlConnector
#define _GNUstep_H_NSNibControlConnector
#import <AppKit/NSNibConnector.h>
@interface NSNibControlConnector : NSNibConnector
- (void) establishConnection;
@end
#endif

View file

@ -0,0 +1,37 @@
/*
NSNibOutletConnector.h
Copyright (C) 1999 Free Software Foundation, Inc.
Author: Richard Frith-Macdonald <richard@branstorm.co.uk>
Date: 1999
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU 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_NSNibOutletConnector
#define _GNUstep_H_NSNibOutletConnector
#import <AppKit/NSNibConnector.h>
@interface NSNibOutletConnector : NSNibConnector
- (void) establishConnection;
@end
#endif

View file

@ -0,0 +1,48 @@
/* -*-objc-*-
NSPredicateEditor.h
The predicate editor class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Fabian Spillner on 03.12.07.
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_NSPredicateEditor
#define _GNUstep_H_NSPredicateEditor
#import <AppKit/NSRuleEditor.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
@class NSArray;
@interface NSPredicateEditor : NSRuleEditor {
NSArray *_rowTemplates;
}
- (NSArray *) rowTemplates;
- (void) setRowTemplates: (NSArray *)templates;
@end
#endif
#endif /* _GNUstep_H_NSPredicateEditor */

View file

@ -0,0 +1,88 @@
/* -*-objc-*-
NSPredicateEditorRowTemplate.h
The template rows for the predicate editor
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Fabian Spillner on 03.12.07.
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_NSPredicateEditorRowTemplate
#define _GNUstep_H_NSPredicateEditorRowTemplate
#import <Foundation/Foundation.h>
@class NSPredicate, NSEntityDescription;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
/* CoreData Framework */
enum {
NSUndefinedAttributeType = 0,
NSInteger16AttributeType = 100,
NSInteger32AttributeType = 200,
NSInteger64AttributeType = 300,
NSDecimalAttributeType = 400,
NSDoubleAttributeType = 500,
NSFloatAttributeType = 600,
NSStringAttributeType = 700,
NSBooleanAttributeType = 800,
NSDateAttributeType = 900,
NSBinaryDataAttributeType = 1000
};
typedef NSUInteger NSAttributeType;
@interface NSPredicateEditorRowTemplate : NSObject {
}
+ (NSArray *) templatesWithAttributeKeyPaths: (NSArray *)paths
inEntityDescription: (NSEntityDescription *)entityDesc;
- (NSArray *) compoundTypes;
- (NSArray *) displayableSubpredicatesOfPredicate: (NSPredicate *)pred;
- (id) initWithCompoundTypes: (NSArray *)types;
- (id) initWithLeftExpressions: (NSArray *)leftExprs
rightExpressionAttributeType: (NSAttributeType)attrType
modifier: (NSComparisonPredicateModifier)modif
operators: (NSArray *)ops
options: (NSUInteger)opts;
- (id) initWithLeftExpressions: (NSArray *)leftExprs
rightExpressions: (NSArray *)rightExprs
modifier: (NSComparisonPredicateModifier)modif
operators: (NSArray *)ops
options: (NSUInteger)opts;
- (NSArray *) leftExpressions;
- (double) matchForPredicate: (NSPredicate *)pred;
- (NSComparisonPredicateModifier) modifier;
- (NSArray *) operators;
- (NSUInteger) options;
- (NSPredicate *) predicateWithSubpredicates: (NSArray *)subpred;
- (NSAttributeType) rightExpressionAttributeType;
- (NSArray *) rightExpressions;
- (void) setPredicate: (NSPredicate *)pred;
- (NSArray *) templateViews;
@end
#endif
#endif /* _GNUstep_H_NSPredicateEditorRowTemplate */

View file

@ -0,0 +1,141 @@
/* -*-objc-*-
NSRuleEditor.h
The rule editor class
Copyright (C) 2020 Free Software Foundation, Inc.
Created by Fabian Spillner on 03.12.07.
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_NSRuleEditor
#define _GNUstep_H_NSRuleEditor
#import <AppKit/NSControl.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
enum {
NSRuleEditorNestingModeSingle,
NSRuleEditorNestingModeList,
NSRuleEditorNestingModeCompound,
NSRuleEditorNestingModeSimple
};
typedef NSUInteger NSRuleEditorNestingMode;
enum {
NSRuleEditorRowTypeSimple,
NSRuleEditorRowTypeCompound
};
typedef NSUInteger NSRuleEditorRowType;
extern NSString * const NSRuleEditorPredicateLeftExpression;
extern NSString * const NSRuleEditorPredicateRightExpression;
extern NSString * const NSRuleEditorPredicateComparisonModifier;
extern NSString * const NSRuleEditorPredicateOptions;
extern NSString * const NSRuleEditorPredicateOperatorType;
extern NSString * const NSRuleEditorPredicateCustomSelector;
extern NSString * const NSRuleEditorPredicateCompoundType;
extern NSString *NSRuleEditorRowsDidChangeNotification;
@interface NSRuleEditor : NSControl {
id _target;
SEL _action;
}
- (void) addRow: (id)sender;
- (BOOL) canRemoveAllRows;
- (NSArray *) criteriaForRow: (NSInteger)index;
- (NSString *) criteriaKeyPath;
- (id) delegate;
- (NSArray *) displayValuesForRow: (NSInteger)index;
- (NSString *) displayValuesKeyPath;
- (NSDictionary *) formattingDictionary;
- (NSString *) formattingStringsFilename;
- (void) insertRowAtIndex: (NSInteger)index
withType: (NSRuleEditorRowType)type
asSubrowOfRow: (NSInteger)row
animate: (BOOL)flag;
- (BOOL) isEditable;
- (NSRuleEditorNestingMode) nestingMode;
- (NSInteger) numberOfRows;
- (NSInteger) parentRowForRow: (NSInteger)row;
- (NSPredicate *) predicate;
- (NSPredicate *) predicateForRow: (NSInteger)row;
- (void) reloadCriteria;
- (void) reloadPredicate;
- (void) removeRowAtIndex: (NSInteger)index;
- (void) removeRowsAtIndexes: (NSIndexSet *)rowIds includeSubrows: (BOOL)flag;
- (Class) rowClass;
- (NSInteger) rowForDisplayValue: (id)value;
- (CGFloat) rowHeight;
- (NSRuleEditorRowType) rowTypeForRow: (NSInteger)row;
- (NSString *) rowTypeKeyPath;
- (NSIndexSet *) selectedRowIndexes;
- (void) selectRowIndexes: (NSIndexSet *)ids
byExtendingSelection: (BOOL)flag;
- (void) setCanRemoveAllRows: (BOOL)flag;
- (void) setCriteria: (NSArray *)crits
andDisplayValues: (NSArray *)vals
forRowAtIndex: (NSInteger)index;
- (void) setCriteriaKeyPath: (NSString *)path;
- (void) setDelegate: (id)delegate;
- (void) setDisplayValuesKeyPath: (NSString *)path;
- (void) setEditable: (BOOL)flag;
- (void) setFormattingDictionary: (NSDictionary *)dict;
- (void) setFormattingStringsFilename: (NSString *)filename;
- (void) setNestingMode: (NSRuleEditorNestingMode)flag;
- (void) setRowClass: (Class)rowClass;
- (void) setRowHeight: (CGFloat)height;
- (void) setRowTypeKeyPath: (NSString *)path;
- (void) setSubrowsKeyPath: (NSString *)path;
- (NSIndexSet *) subrowIndexesForRow: (NSInteger)row;
- (NSString *) subrowsKeyPath;
@end
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
@protocol NSRuleEditorDelegate
- (id) ruleEditor: (NSRuleEditor *)editor
child: (NSInteger)idx
forCriterion: (id)crit
withRowType: (NSRuleEditorRowType) type;
- (id) ruleEditor: (NSRuleEditor *)editor
displayValueForCriterion: (id)crit
inRow: (NSInteger)row;
- (NSInteger) ruleEditor: (NSRuleEditor *)editor
numberOfChildrenForCriterion: (id)crit
withRowType: (NSRuleEditorRowType)type;
- (NSDictionary *) ruleEditor: (NSRuleEditor *)editor
predicatePartsForCriterion: (id)crit
withDisplayValue: (id)val
inRow: (NSInteger)row;
- (void) ruleEditorRowsDidChange: (NSNotification *)notif;
@end
#endif
#endif /* _GNUstep_H_NSRuleEditor */

47
Headers/AppKit/NSTouch.h Normal file
View file

@ -0,0 +1,47 @@
/* Definition of class NSTouch
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory Casamento
Date: Mon Jan 20 10:43:31 EST 2020
This file is part of the GNUstep 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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTouch_h_GNUSTEP_GUI_INCLUDE
#define _NSTouch_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@interface NSTouch : NSObject
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTouch_h_GNUSTEP_GUI_INCLUDE */

View file

@ -0,0 +1,47 @@
/* Definition of class NSTouchBar
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory Casamento
Date: Mon Jan 20 10:35:18 EST 2020
This file is part of the GNUstep 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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSTouchBar_h_GNUSTEP_GUI_INCLUDE
#define _NSTouchBar_h_GNUSTEP_GUI_INCLUDE
#import <Foundation/NSObject.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@interface NSTouchBar : NSObject
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSTouchBar_h_GNUSTEP_GUI_INCLUDE */

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 {

Binary file not shown.

Binary file not shown.

13
MISSING
View file

@ -7,16 +7,12 @@ MISSING HEADERS
> NSAccessibilityElement.h
> NSAccessibilityProtocols.h
> NSAlignmentFeedbackFilter.h
> NSAppearance.h
> NSCollectionViewCompositionalLayout.h
> NSCollectionViewFlowLayout.h
> NSCollectionViewGridLayout.h
> NSCollectionViewLayout.h
> NSCollectionViewTransitionLayout.h
> NSColorSampler.h
> NSDataAsset.h
> NSDatePicker.h
> NSDatePickerCell.h
> NSDictionaryController.h
> NSDiffableDataSource.h
> NSDraggingItem.h
@ -43,8 +39,6 @@ MISSING HEADERS
> NSPathControl.h
> NSPathControlItem.h
> NSPersistentDocument.h
> NSPredicateEditor.h
> NSPredicateEditorRowTemplate.h
> NSPressureConfiguration.h
> NSQuickDrawView.h
> NSRuleEditor.h
@ -80,7 +74,6 @@ MISSING HEADERS
> NSWindowRestoration.h
> NSWindowTab.h
> NSWindowTabGroup.h
Total: 86
Completed
---
@ -90,7 +83,10 @@ Completed
> NSPDFPanel.h
> NSPICTImageRep.h
> NSDockTile.h
Total: 6
> NSAppearance.h
> NSDataAsset.h
> NSTouch.h
> NSTouchBar.h
Mac Specific
---
@ -117,4 +113,3 @@ Mac Specific
> NSWindowScripting.h
> NSHapticFeedback.h
> NSAppleScriptExtensions.h
Total: 23

View file

@ -50,6 +50,7 @@ NSAffineTransform.m \
NSAlert.m \
NSAnimation.m \
NSAnimationContext.m \
NSAppearance.m \
NSApplication.m \
NSArrayController.m \
NSAttributedString.m \
@ -89,9 +90,12 @@ NSController.m \
NSCursor.m \
NSCustomImageRep.m \
NSCustomTouchBarItem.m \
NSDataAsset.m \
NSDataLink.m \
NSDataLinkManager.m \
NSDataLinkPanel.m \
NSDatePicker.m \
NSDatePickerCell.m \
NSDockTile.m \
NSDocument.m \
NSDocumentController.m \
@ -117,6 +121,8 @@ NSSharingServicePickerTouchBarItem.m \
NSSliderTouchBarItem.m \
NSSpeechRecognizer.m \
NSStepperTouchBarItem.m \
NSTouch.m \
NSTouchBar.m \
NSTouchBarItem.m \
NSGestureRecognizer.m \
NSGradient.m \
@ -146,7 +152,6 @@ NSSharingServicePickerTouchBarItem.m \
NSSliderTouchBarItem.m \
NSSpeechRecognizer.m \
NSStepperTouchBarItem.m \
NSTouchBarItem.m \
NSMagnificationGestureRecognizer.m \
NSMatrix.m \
NSMenu.m \
@ -157,6 +162,8 @@ NSMovie.m \
NSMovieView.m \
NSNib.m \
NSNibConnector.m \
NSNibControlConnector.m \
NSNibOutletConnector.m \
NSNibBindingConnector.m \
NSNibAXAttributeConnector.m \
NSNibAXRelationshipConnector.m \
@ -171,7 +178,6 @@ NSPanel.m \
NSPanGestureRecognizer.m \
NSPickerTouchBarItem.m \
NSPopoverTouchBarItem.m \
NSPressGestureRecognizer.m \
NSParagraphStyle.m \
NSPasteboardItem.m \
NSPDFInfo.m \
@ -181,6 +187,9 @@ NSPICTImageRep.m \
NSPopover.m \
NSPopUpButton.m \
NSPopUpButtonCell.m \
NSPredicateEditor.m \
NSPredicateEditorRowTemplate.m \
NSPressGestureRecognizer.m \
NSPrinter.m \
NSPrintInfo.m \
NSPrintOperation.m \
@ -188,6 +197,7 @@ NSPrintPanel.m \
NSProgressIndicator.m \
NSResponder.m \
NSRotationGestureRecognizer.m \
NSRuleEditor.m \
NSRulerMarker.m \
NSRulerView.m \
NSRunningApplication.m \
@ -240,7 +250,6 @@ NSTextView_actions.m \
NSToolbar.m \
NSToolbarItem.m \
NSToolbarItemGroup.m \
NSTouchBarItem.m \
NSTokenField.m \
NSTokenFieldCell.m \
NSTrackingArea.m \
@ -309,8 +318,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>,
@ -339,6 +348,7 @@ NSAffineTransform.h \
NSAlert.h \
NSAnimation.h \
NSAnimationContext.h \
NSAppearance.h \
NSApplication.h \
NSArrayController.h \
NSBezierPath.h \
@ -371,9 +381,12 @@ NSController.h \
NSCursor.h \
NSCustomImageRep.h \
NSCustomTouchBarItem.h \
NSDataAsset.h \
NSDataLink.h \
NSDataLinkManager.h \
NSDataLinkPanel.h \
NSDatePicker.h \
NSDatePickerCell.h \
NSDockTile.h \
NSDocument.h \
NSDocumentController.h \
@ -435,6 +448,8 @@ NSPopoverTouchBarItem.h \
NSPopover.h \
NSPopUpButton.h \
NSPopUpButtonCell.h \
NSPredicateEditor.h \
NSPredicateEditorRowTemplate.h \
NSPressGestureRecognizer.h \
NSPrintInfo.h \
NSPrintOperation.h \
@ -443,6 +458,7 @@ NSPrinter.h \
NSProgressIndicator.h \
NSResponder.h \
NSRotationGestureRecognizer.h \
NSRuleEditor.h \
NSRulerMarker.h \
NSRulerView.h \
NSRunningApplication.h \
@ -493,6 +509,8 @@ NSTextView.h \
NSToolbar.h \
NSToolbarItem.h \
NSToolbarItemGroup.h \
NSTouch.h \
NSTouchBar.h \
NSTouchBarItem.h \
NSTokenField.h \
NSTokenFieldCell.h \
@ -512,6 +530,8 @@ NSColorPicking.h \
NSDragging.h \
NSGraphics.h \
NSNibConnector.h \
NSNibControlConnector.h \
NSNibOutletConnector.h \
NSNibDeclarations.h \
NSNibLoading.h \
NSNib.h \
@ -567,7 +587,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

@ -534,9 +534,10 @@ For bigger values the width gets ignored.
}
else
{
// FIXME These should come from the typing attributes
curParagraphStyle = [NSParagraphStyle defaultParagraphStyle];
curFont = [NSFont userFontOfSize: 0];
NSDictionary *typingAttributes = [curLayoutManager typingAttributes];
curParagraphStyle = [typingAttributes
objectForKey: NSParagraphStyleAttributeName];
curFont = [typingAttributes objectForKey: NSFontAttributeName];
}
line_height = [curFont defaultLineHeightForFont];

View file

@ -34,6 +34,7 @@
#import "AppKit/NSAttributedString.h"
#import "AppKit/NSTextStorage.h"
#import "AppKit/NSTextContainer.h"
#import "AppKit/NSTextView.h"
/* just for NSAttachmentCharacter */
#import "AppKit/NSTextAttachment.h"
@ -3280,7 +3281,13 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
else if (attributeTag == NSGlyphAttributeBidiLevel)
g->bidilevel = anInt;
}
}
}
- (NSDictionary *) typingAttributes
{
return [NSTextView defaultTypingAttributes];
}
/*
* NSCoding protocol

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"];
@ -409,6 +424,11 @@ static BOOL _isInInterfaceBuilder = NO;
_windowStyle |= NSTitledWindowMask;
}
if ([coder containsValueForKey: @"NSToolbar"])
{
_toolbar = [coder decodeObjectForKey: @"NSToolbar"];
}
_baseWindowClass = [NSWindow class];
}
else
@ -440,6 +460,7 @@ static BOOL _isInInterfaceBuilder = NO;
[aCoder encodeRect: rect forKey: @"NSWindowRect"];
[aCoder encodeObject: _title forKey: @"NSWindowTitle"];
[aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"];
[aCoder encodeObject: _toolbar forKey: @"NSToolbar"];
}
}
@ -485,6 +506,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];
@ -497,6 +520,10 @@ static BOOL _isInInterfaceBuilder = NO;
// FIXME: No idea what is going on here
[_realObject setToolbar: (NSToolbar*)_viewClass];
}
if (_toolbar)
{
[_realObject setToolbar: _toolbar];
}
[_realObject setContentMinSize: _minSize];
[_realObject setContentMaxSize: _maxSize];
@ -1001,9 +1028,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)
@ -722,22 +724,20 @@
- (NSRect) stepperUpButtonRectWithFrame: (NSRect)frame
{
NSSize size = [[NSImage imageNamed: @"common_StepperUp"] size];
NSRect upRect;
NSRect upRect = {{NSMinX(frame), NSMinY(frame)}, {size.width, size.height}};
upRect.size = size;
upRect.origin.x = NSMaxX(frame) - size.width;
upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1;
upRect.origin.x += ((int)frame.size.width / 2) - ((int)size.width / 2);
upRect.origin.y += ((int)frame.size.height / 2);
return upRect;
}
- (NSRect) stepperDownButtonRectWithFrame: (NSRect)frame
{
NSSize size = [[NSImage imageNamed: @"common_StepperDown"] size];
NSRect downRect;
NSRect downRect = {{NSMinX(frame), NSMinY(frame)}, {size.width, size.height}};
downRect.size = size;
downRect.origin.x = NSMaxX(frame) - size.width;
downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - size.height + 1;
downRect.origin.x += ((int)frame.size.width / 2) - ((int)size.width / 2);
downRect.origin.y += ((int)frame.size.height / 2) - size.height;
return downRect;
}
@ -1446,8 +1446,6 @@ static NSImage *spinningImages[MaxCount];
if (tiles == nil)
{
[[NSColor blackColor] set];
NSRectFill(divide);
rect = [self drawDarkButton: rect withClip: aRect];
[[NSColor controlShadowColor] set];
NSRectFill(rect);
@ -2646,6 +2644,7 @@ typedef enum {
NSScroller *vertScroller = [scrollView verticalScroller];
NSScroller *horizScroller = [scrollView horizontalScroller];
CGFloat scrollerWidth = [NSScroller scrollerWidth];
NSRect scrollerFrame;
[color set];
@ -2653,43 +2652,39 @@ typedef enum {
{
NSInterfaceStyle style;
CGFloat xpos;
CGFloat scrollerHeight = bounds.size.height;
scrollerFrame = [vertScroller frame];
style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil);
if (style == NSMacintoshInterfaceStyle
|| style == NSWindows95InterfaceStyle)
{
xpos = [vertScroller frame].origin.x - 1.0;
xpos = scrollerFrame.origin.x - 1.0;
}
else
{
xpos = [vertScroller frame].origin.x + scrollerWidth;
xpos = scrollerFrame.origin.x + scrollerWidth;
}
NSRectFill(NSMakeRect(xpos, [vertScroller frame].origin.y - 1.0,
1.0, scrollerHeight + 1.0));
NSRectFill(NSMakeRect(xpos, scrollerFrame.origin.y,
1.0, scrollerFrame.size.height));
}
if ([scrollView hasHorizontalScroller])
{
CGFloat ypos;
CGFloat scrollerY = [horizScroller frame].origin.y;
CGFloat scrollerLength = bounds.size.width;
if ([scrollView hasVerticalScroller])
{
scrollerLength -= [NSScroller scrollerWidth];
}
scrollerFrame = [horizScroller frame];
if ([scrollView isFlipped])
{
ypos = scrollerY - 1.0;
ypos = scrollerFrame.origin.y - 1.0;
}
else
{
ypos = scrollerY + scrollerWidth + 1.0;
ypos = scrollerFrame.origin.y + scrollerWidth + 1.0;
}
NSRectFill(NSMakeRect([horizScroller frame].origin.x - 1.0, ypos,
scrollerLength + 1.0, 1.0));
NSRectFill(NSMakeRect([horizScroller frame].origin.x, ypos,
scrollerFrame.size.width, 1.0));
}
}
}
@ -3112,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];
@ -3129,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 */
@ -3177,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
@ -31,175 +34,211 @@
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSXMLDocument.h>
#import "GNUstepGUI/GSXibKeyedUnarchiver.h"
#import "GNUstepGUI/GSXibElement.h"
#import "GNUstepGUI/GSNibLoading.h"
#import "GSXib5KeyedUnarchiver.h"
@implementation GSXibKeyedUnarchiver
+ (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
}
+ (NSKeyedUnarchiver *) unarchiverForReadingWithData: (NSData *)data
{
NSKeyedUnarchiver *unarchiver = nil;
if ([self checkXib5: data])
{
unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data];
}
else
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
}
return AUTORELEASE(unarchiver);
}
- (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 +274,7 @@
theParser = [[NSXMLParser alloc] initWithData: theData];
[theParser setDelegate: self];
NS_DURING
{
// Parse the XML data
@ -249,7 +288,7 @@
NS_ENDHANDLER
DESTROY(theParser);
#endif
#endif
return self;
}
@ -405,7 +444,7 @@ didStartElement: (NSString*)elementName
// pop
currentElement = last;
if (r != o)
{
[delegate unarchiver: self
@ -443,7 +482,7 @@ didStartElement: (NSString*)elementName
// Balance the retain above
RELEASE(o);
if (objID != nil)
{
NSDebugLLog(@"XIB", @"decoded object %@ for id %@", o, objID);
@ -454,7 +493,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 +547,7 @@ didStartElement: (NSString*)elementName
}
// Balance the retain above
RELEASE(o);
if (objID != nil)
{
NSDebugLLog(@"XIB", @"decoded object %@ for id %@", o, objID);
@ -547,14 +586,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 +605,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"int" isEqualToString: elementName])
@ -574,7 +614,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"double" isEqualToString: elementName])
@ -583,7 +623,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"bool" isEqualToString: elementName])
@ -592,7 +632,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"integer" isEqualToString: elementName])
@ -602,7 +642,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"real" isEqualToString: elementName])
@ -612,7 +652,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"boolean" isEqualToString: elementName])
@ -622,37 +662,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 +732,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"bytes" isEqualToString: elementName])
@ -702,7 +742,7 @@ didStartElement: (NSString*)elementName
if (objID != nil)
[decoded setObject: new forKey: objID];
return new;
}
else if ([@"array" isEqualToString: elementName])
@ -732,7 +772,7 @@ didStartElement: (NSString*)elementName
}
else
{
NSLog(@"Unknown element type %@", elementName);
//NSLog(@"Unknown element type %@", elementName);
}
return nil;
@ -970,7 +1010,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,19 +35,13 @@
#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"
@interface NSApplication (NibCompatibility)
@ -58,16 +52,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 +63,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,40 +80,19 @@
return 4.0;
}
- (void) awake: (NSArray *)rootObjects
inContainer: (id)objects
- (void) awake: (NSArray *)rootObjects
withContext: (NSDictionary *)context
{
NSEnumerator *en;
id obj;
NSMutableArray *topLevelObjects = [context objectForKey: NSNibTopLevelObjects];
id owner = [context objectForKey: NSNibOwner];
id first = nil;
id app = nil;
NSCustomObject *object;
NSString *className;
NSEnumerator *en;
id obj;
NSUInteger index = 0;
// Get the file's owner and NSApplication object references...
object = (NSCustomObject*)[rootObjects objectAtIndex: 1];
if ([[object className] isEqualToString: @"FirstResponder"])
if ([rootObjects count] == 0)
{
first = [object realObject];
}
else
{
NSLog(@"%s:first responder missing\n", __PRETTY_FUNCTION__);
}
object = (NSCustomObject*)[rootObjects objectAtIndex: 2];
className = [object className];
if ([className isEqualToString: @"NSApplication"] ||
[NSClassFromString(className) isSubclassOfClass:[NSApplication class]])
{
app = [object realObject];
}
else
{
NSLog(@"%s:NSApplication missing '%@'\n", __PRETTY_FUNCTION__, className);
NSWarnMLog(@"No root objects in XIB!");
return;
}
// Use the owner as first root object
@ -952,13 +101,15 @@
en = [rootObjects objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
index++;
if ([obj respondsToSelector: @selector(nibInstantiate)])
{
obj = [obj nibInstantiate];
}
// IGNORE file's owner, first responder and NSApplication instances...
if ((obj != nil) && (obj != owner) && (obj != first) && (obj != app))
if ((obj != nil) && (index > 3))
{
[topLevelObjects addObject: obj];
// All top level objects must be released by the caller to avoid
@ -974,9 +125,16 @@
[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];
}
@ -987,13 +145,13 @@
withZone: (NSZone *)zone;
{
BOOL loaded = NO;
NSKeyedUnarchiver *unarchiver = nil;
NS_DURING
{
if (data != nil)
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
NSKeyedUnarchiver *unarchiver = [GSXibKeyedUnarchiver unarchiverForReadingWithData: data];
if (unarchiver != nil)
{
NSArray *rootObjects;
@ -1004,28 +162,14 @@
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
@ -1036,7 +180,6 @@
NS_HANDLER
{
NSLog(@"Exception occurred while loading model: %@",[localException reason]);
// TEST_RELEASE(unarchiver);
}
NS_ENDHANDLER

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

110
Source/NSAppearance.m Normal file
View file

@ -0,0 +1,110 @@
/* Implementation of class NSAppearance
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Wed Jan 15 07:03:39 EST 2020
This file is part of the GNUstep 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <AppKit/NSAppearance.h>
#import <Foundation/NSArchiver.h>
NSAppearance *__currentAppearance = nil;
@implementation NSAppearance
// Creating an appearance...
+ (instancetype) appearanceNamed: (NSString *)name
{
return [[NSAppearance alloc] initWithAppearanceNamed: name bundle: nil];
}
- (instancetype) initWithAppearanceNamed: (NSString *)name bundle: (NSBundle *)bundle
{
self = [super init];
if (self)
{
ASSIGNCOPY(_name, name);
_allowsVibrancy = NO;
}
return self;
}
- (instancetype) initWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
}
else
{
ASSIGN(_name, [coder decodeObject]);
[coder decodeValueOfObjCType: @encode(BOOL) at: &_allowsVibrancy];
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
}
else
{
[coder encodeObject: _name];
[coder encodeValueOfObjCType: @encode(BOOL) at: &_allowsVibrancy];
}
}
- (void) dealloc
{
RELEASE(_name);
[super dealloc];
}
// Getting the appearance name
- (NSString *) name
{
return _name;
}
// Determining the most appropriate appearance
- (NSAppearanceName) bestMatchFromAppearancesWithNames: (NSArray *)appearances
{
return nil;
}
// Getting and setting the appearance
+ (void) setCurrentAppearance: (NSAppearance *)appearance
{
ASSIGN(__currentAppearance, appearance);
}
+ (NSAppearance *) currentAppearance
{
return __currentAppearance;
}
// Managing vibrancy
- (BOOL) allowsVibrancy
{
return _allowsVibrancy;
}
@end

View file

@ -2,7 +2,7 @@
<abstract>Controller class for arrays</abstract>
Copyright <copy>(C) 2006 Free Software Foundation, Inc.</copy>
Copyright <copy>(C) 2006, 2020 Free Software Foundation, Inc.</copy>
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: June 2006
@ -41,6 +41,105 @@
#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]])
{
// FIXME: Using the correct memory management here
// Leads to an issue inside of KVO. For now we leak the
// object until this gets fixed.
//return AUTORELEASE([[GSObservableArray alloc]
return ([[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
@ -57,7 +156,6 @@
{
if ((self = [super initWithContent: content]) != nil)
{
[self rearrangeObjects];
[self setSelectsInsertedObjects: YES];
}
@ -92,8 +190,7 @@
}
else
{
// FIXME: Should check whether _arranged_objects is mutable
ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObject: obj]);
DESTROY(_arranged_objects);
}
if ([self selectsInsertedObjects])
{
@ -112,8 +209,7 @@
}
else
{
// FIXME: Should check whether _arranged_objects is mutable
ASSIGN(_arranged_objects, [_arranged_objects arrayByAddingObjectsFromArray: obj]);
DESTROY(_arranged_objects);
}
if ([self selectsInsertedObjects])
{
@ -133,8 +229,7 @@
}
else
{
// FIXME
//[_arranged_objects removeObject: obj];
DESTROY(_arranged_objects);
}
[self didChangeValueForKey: NSContentBinding];
}
@ -150,8 +245,7 @@
}
else
{
// FIXME
//[_arranged_objects removeObjectsInArray: obj];
DESTROY(_arranged_objects);
}
[self didChangeValueForKey: NSContentBinding];
}
@ -290,7 +384,7 @@
- (NSArray*) selectedObjects
{
// We make the selection work on the arranged objects
return [_arranged_objects objectsAtIndexes: _selection_indexes];
return [[self arrangedObjects] objectsAtIndexes: _selection_indexes];
}
- (NSUInteger) selectionIndex
@ -365,20 +459,31 @@
- (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];
}
- (id) arrangedObjects
{
if (_arranged_objects == nil)
{
[self rearrangeObjects];
}
return _arranged_objects;
}
- (void) rearrangeObjects
{
[self willChangeValueForKey: @"arrangedObjects"];
ASSIGN(_arranged_objects, [self arrangeObjects: _content]);
DESTROY(_arranged_objects);
_arranged_objects = [[GSObservableArray alloc]
initWithArray: [self arrangeObjects: _content]];
[self didChangeValueForKey: @"arrangedObjects"];
}

View file

@ -1974,10 +1974,10 @@ static BOOL browserUseBezels;
else
rect.origin.y = scrollerWidth + bezelBorderSize.width;
}
else
{
rect.origin.y += bezelBorderSize.width;
}
else if (!_separatesColumns)
{
rect.origin.y += bezelBorderSize.width;
}
}
else
{
@ -2105,11 +2105,16 @@ static BOOL browserUseBezels;
else
{
_scrollerRect = NSZeroRect;
_columnSize.height -= 2 * bezelBorderSize.width;
if (!_separatesColumns)
_columnSize.height -= 2 * bezelBorderSize.width;
}
if (_columnSize.height < 0)
_columnSize.height = 0;
num = _lastVisibleColumn - _firstVisibleColumn + 1;
// Column count
if (_minColumnWidth > 0)
{
CGFloat colWidth = _minColumnWidth + scrollerWidth;
@ -2130,6 +2135,7 @@ static BOOL browserUseBezels;
if (_maxVisibleColumns > 0 && columnCount > _maxVisibleColumns)
columnCount = _maxVisibleColumns;
// Create extra columns
if (columnCount != num)
{
if (num > 0)
@ -2149,7 +2155,7 @@ static BOOL browserUseBezels;
_lastVisibleColumn = _firstVisibleColumn + columnCount - 1;
}
// Columns
// Column width
if (_separatesColumns)
frameWidth = _frame.size.width - ((columnCount - 1) * browserColumnSeparation);
else
@ -2158,9 +2164,6 @@ static BOOL browserUseBezels;
_columnSize.width = (int)(frameWidth / (CGFloat)columnCount);
if (_columnSize.height < 0)
_columnSize.height = 0;
for (i = _firstVisibleColumn; i <= _lastVisibleColumn; i++)
{
NSBrowserColumn *bc;
@ -2178,11 +2181,6 @@ static BOOL browserUseBezels;
return;
}
{
NSBorderType bt = _separatesColumns ? NSBezelBorder : NSNoBorder;
[sc setBorderType: bt];
}
[sc setBorderType: [self _resolvedBorderType]];
[sc setFrame: [self frameOfColumn: i]];
matrix = [bc columnMatrix];

View file

@ -110,7 +110,7 @@
enumerator = [types objectEnumerator];
while ((type = [enumerator nextObject]))
{
NSDebugLLog(@"NIB", @"Checking type %@", fileName);
NSDebugLLog(@"NIB", @"Checking type %@", type);
NSString *path = [self pathForResource: fileName
ofType: type];
if (path != nil)

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)
{

85
Source/NSDataAsset.m Normal file
View file

@ -0,0 +1,85 @@
/* Implementation of class NSDataAsset
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Fri Jan 17 10:25:34 EST 2020
This file is part of the GNUstep 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSBundle.h>
#import <Foundation/NSString.h>
#import <Foundation/NSData.h>
#import <AppKit/NSDataAsset.h>
@implementation NSDataAsset
// Initializing the Data Asset
- (instancetype) initWithName: (NSDataAssetName)name
{
return [self initWithName: name bundle: nil];
}
- (instancetype) initWithName: (NSDataAssetName)name bundle: (NSBundle *)bundle
{
self = [super init];
if (self != nil)
{
ASSIGNCOPY(_name, name);
ASSIGN(_bundle, bundle);
_data = nil;
_typeIdentifier = nil;
}
return self;
}
- (void) dealloc
{
RELEASE(_name);
RELEASE(_bundle);
RELEASE(_data);
RELEASE(_typeIdentifier);
[super dealloc];
}
- (id) copyWithZone: (NSZone *)zone
{
NSDataAsset *copy = [[NSDataAsset allocWithZone: zone] initWithName: _name bundle: _bundle];
ASSIGNCOPY(copy->_data, _data);
ASSIGNCOPY(copy->_typeIdentifier, _typeIdentifier);
return copy;
}
// Accessing data...
- (NSData *) data
{
return _data;
}
// Getting data asset information
- (NSDataAssetName) name
{
return _name;
}
- (NSString *) typeIdentifier
{
return _typeIdentifier;
}
@end

220
Source/NSDatePicker.m Normal file
View file

@ -0,0 +1,220 @@
/** <title>NSDatePicker</title>
<abstract>The date picker class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Nikolaus Schaller <hns@computer.org>
Date: April 2006
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
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/NSString.h>
#import "AppKit/NSDatePickerCell.h"
#import "AppKit/NSDatePicker.h"
static id usedCellClass = nil;
@implementation NSDatePicker
+ (void) initialize
{
if (self == [NSDatePicker class])
{
[self setVersion: 1];
[self setCellClass: [NSDatePickerCell class]];
}
}
+ (Class) cellClass
{
return usedCellClass;
}
+ (void) setCellClass: (Class)cellClass
{
usedCellClass = cellClass;
}
- (NSColor *) backgroundColor
{
return [_cell backgroundColor];
}
- (NSCalendar *) calendar
{
return [_cell calendar];
}
- (NSDatePickerElementFlags) datePickerElements
{
return [_cell datePickerElements];
}
- (NSDatePickerMode) datePickerMode
{
return [_cell datePickerMode];
}
- (NSDatePickerStyle) datePickerStyle
{
return [_cell datePickerStyle];
}
- (NSDate *) dateValue
{
return [_cell dateValue];
}
- (id) delegate
{
return [_cell delegate];
}
- (BOOL) drawsBackground
{
return [_cell drawsBackground];
}
- (BOOL) isBezeled
{
return [_cell isBezeled];
}
- (BOOL) isBordered
{
return [_cell isBordered];
}
- (NSLocale *) locale
{
return [_cell locale];
}
- (NSDate *) maxDate
{
return [_cell maxDate];
}
- (NSDate *) minDate
{
return [_cell minDate];
}
- (void) setBackgroundColor: (NSColor *)color
{
[_cell setBackgroundColor: color];
}
- (void) setBezeled: (BOOL)flag
{
[_cell setBezeled: flag];
}
- (void) setBordered: (BOOL)flag
{
[_cell setBordered: flag];
}
- (void) setCalendar: (NSCalendar *)calendar
{
[_cell setCalendar: calendar];
}
- (void) setDatePickerElements: (NSDatePickerElementFlags)flags
{
[_cell setDatePickerElements: flags];
}
- (void) setDatePickerMode: (NSDatePickerMode)mode
{
[_cell setDatePickerMode: mode];
}
- (void) setDatePickerStyle: (NSDatePickerStyle)style
{
[_cell setDatePickerStyle: style];
}
- (void) setDateValue: (NSDate *)date
{
[_cell setDateValue: date];
}
- (void) setDelegate: (id)obj
{
[_cell setDelegate: obj];
}
- (void) setDrawsBackground: (BOOL)flag
{
[_cell setDrawsBackground: flag];
}
- (void) setLocale: (NSLocale *)locale
{
[_cell setLocale: locale];
}
- (void) setMaxDate: (NSDate *)date
{
[_cell setMaxDate: date];
}
- (void) setMinDate: (NSDate *)date
{
[_cell setMinDate: date];
}
- (void) setTextColor: (NSColor *)color
{
[_cell setTextColor: color];
}
- (void) setTimeInterval: (NSTimeInterval)interval
{
[_cell setTimeInterval: interval];
}
- (void) setTimeZone: (NSTimeZone *)zone
{
[_cell setTimeZone: zone];
}
- (NSColor *) textColor
{
return [_cell textColor];
}
- (NSTimeInterval) timeInterval
{
return [_cell timeInterval];
}
- (NSTimeZone *) timeZone
{
return [_cell timeZone];
}
@end

225
Source/NSDatePickerCell.m Normal file
View file

@ -0,0 +1,225 @@
/** <title>NSDatePickerCell</title>
<abstract>The date picker cell class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Nikolaus Schaller <hns@computer.org>
Date: April 2006
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
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/NSString.h>
#import <Foundation/NSDateFormatter.h>
#import "AppKit/NSDatePickerCell.h"
#import "AppKit/NSColor.h"
@implementation NSDatePickerCell
- (id) initTextCell: (NSString*)aString
{
if ((self = [super initTextCell: aString]))
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[self setFormatter: formatter];
RELEASE(formatter);
}
return self;
}
- (NSColor *) backgroundColor
{
return _backgroundColor;
}
- (void) setBackgroundColor: (NSColor *)color
{
ASSIGN(_backgroundColor, color);
}
- (NSCalendar *) calendar
{
return [[self formatter] calendar];
}
- (void) setCalendar: (NSCalendar *)calendar
{
[[self formatter] setCalendar: calendar];
}
- (NSDatePickerElementFlags) datePickerElements
{
return _datePickerElements;
}
- (void) setDatePickerElements: (NSDatePickerElementFlags)flags
{
_datePickerElements = flags;
}
- (NSDatePickerMode) datePickerMode
{
return _datePickerMode;
}
- (void) setDatePickerMode: (NSDatePickerMode)mode
{
_datePickerMode = mode;
}
- (NSDatePickerStyle) datePickerStyle
{
return _datePickerStyle;
}
- (void) setDatePickerStyle: (NSDatePickerStyle)style
{
_datePickerStyle = style;
}
- (NSDate *) dateValue
{
return (NSDate *)[self objectValue];
}
- (void) setDateValue: (NSDate *)date
{
[self setObjectValue: date];
}
- (id) delegate
{
return _delegate;
}
- (void) setDelegate: (id)obj
{
_delegate = obj;
}
- (BOOL) drawsBackground
{
return _drawsBackground;
}
- (void) setDrawsBackground: (BOOL)flag
{
_drawsBackground = flag;
}
- (NSLocale *) locale
{
return [[self formatter] locale];
}
- (void) setLocale: (NSLocale *)locale
{
[[self formatter] setLocale: locale];
}
- (NSDate *) maxDate
{
return _maxDate;
}
- (void) setMaxDate: (NSDate *)date
{
ASSIGN(_maxDate, date);
}
- (NSDate *) minDate
{
return _minDate;
}
- (void) setMinDate: (NSDate *)date
{
ASSIGN(_minDate, date);
}
- (NSColor *) textColor
{
return _textColor;
}
- (void) setTextColor: (NSColor *)color
{
ASSIGN(_textColor, color);
}
- (NSTimeInterval) timeInterval
{
return _timeInterval;
}
- (void) setTimeInterval: (NSTimeInterval)interval
{
_timeInterval = interval;
}
- (NSTimeZone *) timeZone
{
return [[self formatter] timeZone];
}
- (void) setTimeZone: (NSTimeZone *)zone
{
[[self formatter] setTimeZone: zone];
}
- (void) encodeWithCoder: (NSCoder *)aCoder
{
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeDouble: [self timeInterval] forKey: @"NSTimeInterval"];
[aCoder encodeInt: [self datePickerElements] forKey: @"NSDatePickerElements"];
[aCoder encodeInt: [self datePickerStyle] forKey: @"NSDatePickerType"];
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
}
else
{
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
if ((self = [super initWithCoder: aDecoder]))
{
if ([aDecoder allowsKeyedCoding])
{
[self setTimeInterval: [aDecoder decodeDoubleForKey: @"NSTimeInterval"]];
[self setDatePickerElements: [aDecoder decodeIntForKey: @"NSDatePickerElements"]];
[self setDatePickerStyle: [aDecoder decodeIntForKey: @"NSDatePickerType"]];
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]];
}
else
{
}
}
return self;
}
@end

View file

@ -166,10 +166,10 @@ keyForFont(NSString *name, const CGFloat *matrix,
<item>NSFontSize 12 (System Font Size)</item>
<item>NSLabelFontSize (none)</item>
<item>NSMenuFontSize (none)</item>
<item>NSMiniFontSize 6</item>
<item>NSMiniFontSize 8</item>
<item>NSMessageFontSize (none)</item>
<item>NSPaletteFontSize (none)</item>
<item>NSSmallFontSize 9</item>
<item>NSSmallFontSize 10</item>
<item>NSTitleBarFontSize (none)</item>
<item>NSToolTipsFontSize (none)</item>
<item>NSUserFixedPitchFontSize (none)</item>
@ -656,7 +656,7 @@ static void setNSFont(NSString *key, NSFont *font)
if (fontSize == 0)
{
fontSize = 9;
fontSize = 10;
}
return fontSize;
@ -684,7 +684,7 @@ static void setNSFont(NSString *key, NSFont *font)
if (fontSize == 0)
{
fontSize = 6;
fontSize = 8;
}
return fontSize;

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

@ -3017,6 +3017,11 @@ no_soft_invalidation:
}
}
- (NSDictionary *) typingAttributes
{
return _typingAttributes;
}
@end

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

@ -1,7 +1,7 @@
/*
/*
<title>NSNibConnector</title>
<abstract>Implementation of NSNibConnector and subclasses</abstract>
<abstract>Implementation of NSNibConnector</abstract>
Copyright (C) 1999, 2015 Free Software Foundation, Inc.
@ -9,7 +9,7 @@
Date: 1999
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: August 2015
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -24,16 +24,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.
*/
*/
#import "config.h"
#import <Foundation/NSCoder.h>
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
#import "AppKit/NSControl.h"
#import "AppKit/NSNibConnector.h"
@implementation NSNibConnector
@ -93,7 +90,7 @@
ASSIGN(_src, [aDecoder decodeObjectForKey: @"NSSource"]);
}
if ([aDecoder containsValueForKey: @"NSLabel"])
{
{
ASSIGN(_tag, [aDecoder decodeObjectForKey: @"NSLabel"]);
}
}
@ -172,66 +169,11 @@
- (NSString *)description
{
NSString *desc = [NSString stringWithFormat: @"<%@ src=%@ dst=%@ label=%@>",
[super description],
[self source],
[self destination],
[self label]];
return desc;
return [NSString stringWithFormat: @"<%@ src=%@ dst=%@ label=%@>",
[super description],
[self source],
[self destination],
[self label]];
}
@end
@implementation NSNibControlConnector
- (void) establishConnection
{
SEL sel = NSSelectorFromString(_tag);
[_src setTarget: _dst];
[_src setAction: sel];
}
@end
@implementation NSNibOutletConnector
- (void) establishConnection
{
NS_DURING
{
if (_src != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[_tag substringToIndex: 1] uppercaseString],
[_tag substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [_src respondsToSelector: sel])
{
[_src performSelector: sel withObject: _dst];
}
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 = [_tag cString];
Class class = object_getClass(_src);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(_src, ivar, _dst);
}
}
}
}
NS_HANDLER
{
NSLog(@"Error while establishing connection %@: %@", self, [localException reason]);
}
NS_ENDHANDLER;
}
@end

View file

@ -0,0 +1,45 @@
/*
<title>NSNibControlConnector</title>
<abstract>Implementation of NSNibControlConnector</abstract>
Copyright (C) 1999, 2015 Free Software Foundation, Inc.
Author: Richard Frith-Macdonald <richard@branstorm.co.uk>
Date: 1999
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: August 2015
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 "AppKit/NSControl.h"
#import "AppKit/NSNibControlConnector.h"
@implementation NSNibControlConnector
- (void) establishConnection
{
SEL sel = NSSelectorFromString(_tag);
[_src setTarget: _dst];
[_src setAction: sel];
}
@end

View file

@ -0,0 +1,81 @@
/*
<title>NSNibOutletConnector</title>
<abstract>Implementation of NSNibOutletConnector</abstract>
Copyright (C) 1999, 2015 Free Software Foundation, Inc.
Author: Richard Frith-Macdonald <richard@branstorm.co.uk>
Date: 1999
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: August 2015
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/NSException.h>
#import <Foundation/NSString.h>
#import "AppKit/NSNibOutletConnector.h"
@implementation NSNibOutletConnector
- (void) establishConnection
{
NS_DURING
{
if (_src != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[_tag substringToIndex: 1] uppercaseString],
[_tag substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [_src respondsToSelector: sel])
{
[_src performSelector: sel withObject: _dst];
}
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 = [_tag cString];
Class class = object_getClass(_src);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(_src, ivar, _dst);
}
}
}
}
NS_HANDLER
{
NSLog(@"Error while establishing connection %@: %@", self, [localException reason]);
}
NS_ENDHANDLER;
}
@end

View file

@ -22,9 +22,10 @@
Boston, MA 02110 USA.
*/
#import <AppKit/NSPDFInfo.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSURL.h>
#import <AppKit/NSPDFInfo.h>
@implementation NSPDFInfo

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

@ -0,0 +1,84 @@
/** <title>NSPredicateEditor</title>
<abstract>The predicate editor class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
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 "AppKit/NSPredicateEditor.h"
@implementation NSPredicateEditor
- (void) dealloc
{
RELEASE(_rowTemplates);
[super dealloc];
}
- (NSArray *) rowTemplates
{
return _rowTemplates;
}
- (void) setRowTemplates: (NSArray *)templates
{
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

@ -0,0 +1,121 @@
/** <title>NSPredicateEditorRowTemplate</title>
<abstract>The template rows for the predicate editor</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
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 "AppKit/NSPredicateEditorRowTemplate.h"
@implementation NSPredicateEditorRowTemplate
+ (NSArray *) templatesWithAttributeKeyPaths: (NSArray *)paths
inEntityDescription: (NSEntityDescription *)entityDesc
{
return nil;
}
- (NSArray *) compoundTypes
{
return nil;
}
- (NSArray *) displayableSubpredicatesOfPredicate: (NSPredicate *)pred
{
return nil;
}
- (id) initWithCompoundTypes: (NSArray *)types
{
return self;
}
- (id) initWithLeftExpressions: (NSArray *)leftExprs
rightExpressionAttributeType: (NSAttributeType)attrType
modifier: (NSComparisonPredicateModifier)modif
operators: (NSArray *)ops
options: (NSUInteger)opts;
{
return self;
}
- (id) initWithLeftExpressions: (NSArray *)leftExprs
rightExpressions: (NSArray *)rightExprs
modifier: (NSComparisonPredicateModifier)modif
operators: (NSArray *)ops
options: (NSUInteger)opts;
{
return self;
}
- (NSArray *) leftExpressions
{
return nil;
}
- (double) matchForPredicate: (NSPredicate *)pred
{
return 0.0;
}
- (NSComparisonPredicateModifier) modifier
{
return NSDirectPredicateModifier;
}
- (NSArray *) operators
{
return nil;
}
- (NSUInteger) options
{
return 0;
}
- (NSPredicate *) predicateWithSubpredicates: (NSArray *)subpred
{
return nil;
}
- (NSAttributeType) rightExpressionAttributeType
{
return 0;
}
- (NSArray *) rightExpressions
{
return nil;
}
- (void) setPredicate: (NSPredicate *)pred
{
}
- (NSArray *) templateViews
{
return nil;
}
@end

253
Source/NSRuleEditor.m Normal file
View file

@ -0,0 +1,253 @@
/** <title>NSRuleEditor</title>
<abstract>The rule editor class</abstract>
Copyright (C) 2020 Free Software Foundation, Inc.
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: January 2020
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 "AppKit/NSRuleEditor.h"
@implementation NSRuleEditor
- (void) addRow: (id)sender
{
}
- (BOOL) canRemoveAllRows
{
return YES;
}
- (NSArray *) criteriaForRow: (NSInteger)index
{
return nil;
}
- (NSString *) criteriaKeyPath
{
return nil;
}
- (id) delegate
{
return nil;
}
- (NSArray *) displayValuesForRow: (NSInteger)index
{
return nil;
}
- (NSString *) displayValuesKeyPath
{
return nil;
}
- (NSDictionary *) formattingDictionary
{
return nil;
}
- (NSString *) formattingStringsFilename
{
return nil;
}
- (void) insertRowAtIndex: (NSInteger)index
withType: (NSRuleEditorRowType)type
asSubrowOfRow: (NSInteger)row
animate: (BOOL)flag
{
}
- (BOOL) isEditable
{
return YES;
}
- (NSRuleEditorNestingMode) nestingMode
{
return NSRuleEditorNestingModeSingle;
}
- (NSInteger) numberOfRows
{
return 0;
}
- (NSInteger) parentRowForRow: (NSInteger)row
{
return 0;
}
- (NSPredicate *) predicate
{
return nil;
}
- (NSPredicate *) predicateForRow: (NSInteger)row
{
return nil;
}
- (void) reloadCriteria
{
}
- (void) reloadPredicate
{
}
- (void) removeRowAtIndex: (NSInteger)index
{
}
- (void) removeRowsAtIndexes: (NSIndexSet *)rowIds includeSubrows: (BOOL)flag
{
}
- (Class) rowClass
{
return nil;
}
- (NSInteger) rowForDisplayValue: (id)value
{
return 0;
}
- (CGFloat) rowHeight
{
return 0.0;
}
- (NSRuleEditorRowType) rowTypeForRow: (NSInteger)row
{
return NSRuleEditorRowTypeSimple;
}
- (NSString *) rowTypeKeyPath
{
return nil;
}
- (NSIndexSet *) selectedRowIndexes
{
return nil;
}
- (void) selectRowIndexes: (NSIndexSet *)ids
byExtendingSelection: (BOOL)flag
{
}
- (void) setCanRemoveAllRows: (BOOL)flag
{
}
- (void) setCriteria: (NSArray *)crits
andDisplayValues: (NSArray *)vals
forRowAtIndex: (NSInteger)index
{
}
- (void) setCriteriaKeyPath: (NSString *)path
{
}
- (void) setDelegate: (id)delegate
{
}
- (void) setDisplayValuesKeyPath: (NSString *)path
{
}
- (void) setEditable: (BOOL)flag
{
}
- (void) setFormattingDictionary: (NSDictionary *)dict
{
}
- (void) setFormattingStringsFilename: (NSString *)filename
{
}
- (void) setNestingMode: (NSRuleEditorNestingMode)flag
{
}
- (void) setRowClass: (Class)rowClass
{
}
- (void) setRowHeight: (CGFloat)height
{
}
- (void) setRowTypeKeyPath: (NSString *)path
{
}
- (void) setSubrowsKeyPath: (NSString *)path
{
}
- (NSIndexSet *) subrowIndexesForRow: (NSInteger)row
{
return nil;
}
- (NSString *) subrowsKeyPath
{
return nil;
}
- (void) viewDidMoveToWindow
{
}
- (void) setAction: (SEL)action
{
_action = action;
}
- (SEL) action
{
return _action;
}
- (void) setTarget: (id)target
{
_target = target;
}
- (id) target
{
return _target;
}
@end

View file

@ -1213,10 +1213,15 @@ GSOppositeEdge(NSRectEdge edge)
/** Vertically expand the scroller by 1pt on each end */
if (overlapBorders)
{
{
vertScrollerRect.origin.y -= 1;
vertScrollerRect.size.height += 2;
}
else if (_hasHeaderView || _hasCornerView)
{
vertScrollerRect.origin.y -= 1;
vertScrollerRect.size.height += 1;
}
[_vertScroller setFrame: vertScrollerRect];

View file

@ -85,6 +85,17 @@ id _nsstepperCellClass = nil;
return YES;
}
- (BOOL)acceptsFirstResponder
{
// FIXME: change to `YES` after `keyDown:` implementation.
return NO;
}
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
{
return YES;
}
- (void) keyDown: (NSEvent*)theEvent
{
// FIXME

View file

@ -346,6 +346,24 @@
return mouseWentUp;
}
- (NSSize) cellSize
{
NSRect upRect = [[GSTheme theme]
stepperUpButtonRectWithFrame: [_control_view bounds]];
NSRect downRect = [[GSTheme theme]
stepperDownButtonRectWithFrame: [_control_view bounds]];
NSSize size;
if (upRect.size.width > downRect.size.width)
size.width = upRect.size.width;
else
size.width = downRect.size.width;
size.height = upRect.size.height + downRect.size.height;
return size;
}
//
// NSCoding protocol
//

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"])

30
Source/NSTouch.m Normal file
View file

@ -0,0 +1,30 @@
/* Implementation of class NSTouch
Copyright (C) 2019 Free Software Foundation, Inc.
By: Gregory Casamento
Date: Mon Jan 20 10:43:31 EST 2020
This file is part of the GNUstep 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <AppKit/NSTouch.h>
@implementation NSTouch
@end

30
Source/NSTouchBar.m Normal file
View file

@ -0,0 +1,30 @@
/* Implementation of class NSTouchBar
Copyright (C) 2019 Free Software Foundation, Inc.
By: Gregory Casamento
Date: Mon Jan 20 10:35:18 EST 2020
This file is part of the GNUstep 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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <AppKit/NSTouchBar.h>
@implementation NSTouchBar
@end

View file

@ -481,7 +481,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
iconSize = GSGetIconSize();
tileImage = [[GSCurrentServer() iconTileImage] copy];
tileImage = [[NSImage imageNamed:@"common_MiniWindowTile"] copy];
[tileImage setScalesWhenResized: YES];
[tileImage setSize: iconSize];
@ -514,8 +514,8 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
iconSize.width - ((iconSize.width / 8) * 2),
iconSize.height - ((iconSize.height / 8) * 2))
inView: self];
[titleCell drawWithFrame: NSMakeRect(1, iconSize.height - 12,
iconSize.width - 2, 11)
[titleCell drawWithFrame: NSMakeRect(3, iconSize.height - 13,
iconSize.width - 6, 10)
inView: self];
}
@ -600,15 +600,17 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{
if (titleCell == nil)
{
CGFloat fontSize;
titleCell = [[NSTextFieldCell alloc] initTextCell: aString];
[titleCell setSelectable: NO];
[titleCell setEditable: NO];
[titleCell setBordered: NO];
[titleCell setAlignment: NSCenterTextAlignment];
[titleCell setDrawsBackground: YES];
[titleCell setBackgroundColor: [NSColor blackColor]];
[titleCell setDrawsBackground: NO];
[titleCell setTextColor: [NSColor whiteColor]];
[titleCell setFont: [NSFont systemFontOfSize: 8]];
fontSize = [NSFont systemFontSizeForControlSize: NSMiniControlSize];
[titleCell setFont: [NSFont systemFontOfSize: fontSize]];
}
else
{

View file

@ -1308,7 +1308,6 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
non-standard f_basetype field, which provides the name of the
underlying file system type.
*/
uid_t uid;
BOOL isRootFS;
BOOL hasOwnership;
@ -1323,7 +1322,6 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
if (statfs([fullPath fileSystemRepresentation], &m))
return NO;
#endif
uid = geteuid();
*writableFlag = 1;
#if defined(HAVE_STRUCT_STATVFS_F_FLAG)
@ -1342,9 +1340,11 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
hasOwnership = NO;
#if (defined(USING_STATFS) && defined(HAVE_STRUCT_STATFS_F_OWNER)) || (defined(USING_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_OWNER))
uid_t uid = geteuid();
if (uid == 0 || uid == m.f_owner)
hasOwnership = YES;
#elif (defined(USING_STATVFS) && !defined(USING_STATFS) && defined (HAVE_STATFS) && defined(HAVE_STRUCT_STATFS_F_OWNER))
uid_t uid = geteuid();
// FreeBSD only?
struct statfs m2;
statfs([fullPath fileSystemRepresentation], &m2);

View file

@ -31,6 +31,7 @@
#import <Foundation/NSString.h>
#import "AppKit/NSApplication.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSAppearance.h"
// Global strings
NSString *NSModalPanelRunLoopMode = @"NSModalPanelRunLoopMode";
@ -760,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";
@ -785,6 +788,30 @@ NSString *NSImageNameFontPanel = @"NSFontPanel";
NSString *NSImageNameColorPanel = @"NSColorPanel";
NSString *NSImageNameCaution = @"NSCaution";
// NSRuleEditor
NSString *const NSRuleEditorPredicateLeftExpression = @"NSRuleEditorPredicateLeftExpression";
NSString *const NSRuleEditorPredicateRightExpression = @"NSRuleEditorPredicateRightExpression";
NSString *const NSRuleEditorPredicateComparisonModifier = @"NSRuleEditorPredicateComparisonModifier";
NSString *const NSRuleEditorPredicateOptions = @"NSRuleEditorPredicateOptions";
NSString *const NSRuleEditorPredicateOperatorType = @"NSRuleEditorPredicateOperatorType";
NSString *const NSRuleEditorPredicateCustomSelector = @"NSRuleEditorPredicateCustomSelector";
NSString *const NSRuleEditorPredicateCompoundType = @"NSRuleEditorPredicateCompoundType";
NSString *NSRuleEditorRowsDidChangeNotification = @"NSRuleEditorRowsDidChangeNotification";
// NSAppearance
const NSAppearanceName NSAppearanceNameAqua = @"NSAppearanceNameAqua";
const NSAppearanceName NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
const NSAppearanceName NSAppearanceNameVibrantLight = @"NSAppearanceNameVibrantLight";
const NSAppearanceName NSAppearanceNameVibrantDark = @"NSAppearanceNameVibrantDark";
const NSAppearanceName NSAppearanceNameAccessibilityHighContrastAqua = @"NSAppearanceNameAccessibilityHighContrastAqua";
const NSAppearanceName NSAppearanceNameAccessibilityHighContrastDarkAqua = @"NSAppearanceNameAccessibilityHighContrastDarkAqua";
const NSAppearanceName NSAppearanceNameAccessibilityHighContrastVibrantLight =
@"NSAppearanceNameAccessibilityHighContrastVibrantLight";
const NSAppearanceName NSAppearanceNameAccessibilityHighContrastVibrantDark =
@"NSAppearanceNameAccessibilityHighContrastVibrantDark";
const NSAppearanceName NSAppearanceNameLightContent = @"NSAppearanceNameLightContent";
extern void __objc_gui_force_linking (void);
void
@ -793,5 +820,3 @@ __objc_gui_force_linking (void)
extern void __objc_gui_linking (void);
__objc_gui_linking ();
}

View file

@ -288,6 +288,7 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
instruction: (NSString*)instruction;
- (void) appendImage: (NSString*) string;
- (void) reset;
- (void) setEncoding: (NSStringEncoding)anEncoding;
@end
@implementation RTFConsumer
@ -545,6 +546,11 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
RELEASE(attr);
}
- (void) setEncoding: (NSStringEncoding)anEncoding
{
encoding = anEncoding;
}
- (RTFAttribute*) attr
{
return [attrs lastObject];
@ -571,7 +577,6 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
CREATE_AUTORELEASE_POOL(pool);
RTFscannerCtxt scanner;
StringContext stringCtxt;
char buffer[5];
// We read in the first few characters to find out which
// encoding we have
@ -580,26 +585,6 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
// Too short to be an RTF
return nil;
}
[rtfData getBytes: buffer range: NSMakeRange(7, 3)];
if (strncmp(buffer, "mac", 3) == 0)
{
encoding = NSMacOSRomanStringEncoding;
}
else if (strncmp(buffer, "pc", 2) == 0)
{
// FIXME: Code page 437 kCFStringEncodingDOSLatinUS
encoding = NSISOLatin1StringEncoding;
}
else if (strncmp(buffer, "pca", 3) == 0)
{
// FIXME: Code page 850 kCFStringEncodingDOSLatin1
encoding = NSISOLatin1StringEncoding;
}
else
{
encoding = NSISOLatin1StringEncoding;
}
// Reset this RFTConsumer, as it might already have been used!
_class = class;
@ -1403,3 +1388,42 @@ void GSRTFaddField (void *ctxt, int start, const char *inst)
[(RTFDConsumer *)ctxt appendField: start instruction: fieldInstruction];
DESTROY(fieldInstruction);
}
void GSRTFencoding(void *ctxt, int encoding)
{
switch (encoding)
{
case 1:
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
break;
case 2:
[(RTFDConsumer *)ctxt setEncoding: NSMacOSRomanStringEncoding];
break;
case 3:
// FIXME: Code page 437 kCFStringEncodingDOSLatinUS
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
break;
case 4:
// FIXME: Code page 850 kCFStringEncodingDOSLatin1
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
break;
case 1250:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1250StringEncoding];
break;
case 1251:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1251StringEncoding];
break;
case 1252:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1252StringEncoding];
break;
case 1253:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1253StringEncoding];
break;
case 1254:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1254StringEncoding];
break;
default:
NSLog(@"Setting unknown encoding %d", encoding);
break;
}
}

View file

@ -152,5 +152,8 @@ void GSRTFNeXTHelpMarker(void *ctxt, int num, const char *markername);
void GSRTFaddField (void *ctxt, int start, const char *inst);
/* set encoding */
void GSRTFencoding(void *ctxt, int encoding);
#endif

View file

@ -1,19 +1,20 @@
/* A Bison parser, made by GNU Bison 2.7. */
/* A Bison parser, made by GNU Bison 3.5. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -26,13 +27,16 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
#ifndef YY_GSRTF_RTFGRAMMAR_TAB_H_INCLUDED
# define YY_GSRTF_RTFGRAMMAR_TAB_H_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@ -40,153 +44,140 @@
extern int GSRTFdebug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
RTFtext = 258,
RTFstart = 259,
RTFansi = 260,
RTFmac = 261,
RTFpc = 262,
RTFpca = 263,
RTFignore = 264,
RTFinfo = 265,
RTFstylesheet = 266,
RTFfootnote = 267,
RTFheader = 268,
RTFfooter = 269,
RTFpict = 270,
RTFplain = 271,
RTFparagraph = 272,
RTFdefaultParagraph = 273,
RTFrow = 274,
RTFcell = 275,
RTFtabulator = 276,
RTFemdash = 277,
RTFendash = 278,
RTFemspace = 279,
RTFenspace = 280,
RTFbullet = 281,
RTFfield = 282,
RTFfldinst = 283,
RTFfldalt = 284,
RTFfldrslt = 285,
RTFflddirty = 286,
RTFfldedit = 287,
RTFfldlock = 288,
RTFfldpriv = 289,
RTFfttruetype = 290,
RTFlquote = 291,
RTFrquote = 292,
RTFldblquote = 293,
RTFrdblquote = 294,
RTFred = 295,
RTFgreen = 296,
RTFblue = 297,
RTFcolorbg = 298,
RTFcolorfg = 299,
RTFunderlinecolor = 300,
RTFcolortable = 301,
RTFfont = 302,
RTFfontSize = 303,
RTFNeXTGraphic = 304,
RTFNeXTGraphicWidth = 305,
RTFNeXTGraphicHeight = 306,
RTFNeXTHelpLink = 307,
RTFNeXTHelpMarker = 308,
RTFNeXTfilename = 309,
RTFNeXTmarkername = 310,
RTFNeXTlinkFilename = 311,
RTFNeXTlinkMarkername = 312,
RTFpaperWidth = 313,
RTFpaperHeight = 314,
RTFmarginLeft = 315,
RTFmarginRight = 316,
RTFmarginTop = 317,
RTFmarginButtom = 318,
RTFfirstLineIndent = 319,
RTFleftIndent = 320,
RTFrightIndent = 321,
RTFalignCenter = 322,
RTFalignJustified = 323,
RTFalignLeft = 324,
RTFalignRight = 325,
RTFlineSpace = 326,
RTFspaceAbove = 327,
RTFstyle = 328,
RTFbold = 329,
RTFitalic = 330,
RTFunderline = 331,
RTFunderlineDot = 332,
RTFunderlineDash = 333,
RTFunderlineDashDot = 334,
RTFunderlineDashDotDot = 335,
RTFunderlineDouble = 336,
RTFunderlineStop = 337,
RTFunderlineThick = 338,
RTFunderlineThickDot = 339,
RTFunderlineThickDash = 340,
RTFunderlineThickDashDot = 341,
RTFunderlineThickDashDotDot = 342,
RTFunderlineWord = 343,
RTFstrikethrough = 344,
RTFstrikethroughDouble = 345,
RTFunichar = 346,
RTFsubscript = 347,
RTFsuperscript = 348,
RTFtabstop = 349,
RTFfcharset = 350,
RTFfprq = 351,
RTFcpg = 352,
RTFOtherStatement = 353,
RTFfontListStart = 354,
RTFfamilyNil = 355,
RTFfamilyRoman = 356,
RTFfamilySwiss = 357,
RTFfamilyModern = 358,
RTFfamilyScript = 359,
RTFfamilyDecor = 360,
RTFfamilyTech = 361,
RTFfamilyBiDi = 362
};
enum yytokentype
{
RTFtext = 258,
RTFstart = 259,
RTFansi = 260,
RTFmac = 261,
RTFpc = 262,
RTFpca = 263,
RTFignore = 264,
RTFinfo = 265,
RTFstylesheet = 266,
RTFfootnote = 267,
RTFheader = 268,
RTFfooter = 269,
RTFpict = 270,
RTFplain = 271,
RTFparagraph = 272,
RTFdefaultParagraph = 273,
RTFrow = 274,
RTFcell = 275,
RTFtabulator = 276,
RTFemdash = 277,
RTFendash = 278,
RTFemspace = 279,
RTFenspace = 280,
RTFbullet = 281,
RTFfield = 282,
RTFfldinst = 283,
RTFfldalt = 284,
RTFfldrslt = 285,
RTFflddirty = 286,
RTFfldedit = 287,
RTFfldlock = 288,
RTFfldpriv = 289,
RTFfttruetype = 290,
RTFlquote = 291,
RTFrquote = 292,
RTFldblquote = 293,
RTFrdblquote = 294,
RTFred = 295,
RTFgreen = 296,
RTFblue = 297,
RTFcolorbg = 298,
RTFcolorfg = 299,
RTFunderlinecolor = 300,
RTFcolortable = 301,
RTFfont = 302,
RTFfontSize = 303,
RTFNeXTGraphic = 304,
RTFNeXTGraphicWidth = 305,
RTFNeXTGraphicHeight = 306,
RTFNeXTHelpLink = 307,
RTFNeXTHelpMarker = 308,
RTFNeXTfilename = 309,
RTFNeXTmarkername = 310,
RTFNeXTlinkFilename = 311,
RTFNeXTlinkMarkername = 312,
RTFpaperWidth = 313,
RTFpaperHeight = 314,
RTFmarginLeft = 315,
RTFmarginRight = 316,
RTFmarginTop = 317,
RTFmarginButtom = 318,
RTFfirstLineIndent = 319,
RTFleftIndent = 320,
RTFrightIndent = 321,
RTFalignCenter = 322,
RTFalignJustified = 323,
RTFalignLeft = 324,
RTFalignRight = 325,
RTFlineSpace = 326,
RTFspaceAbove = 327,
RTFstyle = 328,
RTFbold = 329,
RTFitalic = 330,
RTFunderline = 331,
RTFunderlineDot = 332,
RTFunderlineDash = 333,
RTFunderlineDashDot = 334,
RTFunderlineDashDotDot = 335,
RTFunderlineDouble = 336,
RTFunderlineStop = 337,
RTFunderlineThick = 338,
RTFunderlineThickDot = 339,
RTFunderlineThickDash = 340,
RTFunderlineThickDashDot = 341,
RTFunderlineThickDashDotDot = 342,
RTFunderlineWord = 343,
RTFstrikethrough = 344,
RTFstrikethroughDouble = 345,
RTFunichar = 346,
RTFsubscript = 347,
RTFsuperscript = 348,
RTFtabstop = 349,
RTFfcharset = 350,
RTFfprq = 351,
RTFcpg = 352,
RTFansicpg = 353,
RTFOtherStatement = 354,
RTFfontListStart = 355,
RTFfamilyNil = 356,
RTFfamilyRoman = 357,
RTFfamilySwiss = 358,
RTFfamilyModern = 359,
RTFfamilyScript = 360,
RTFfamilyDecor = 361,
RTFfamilyTech = 362,
RTFfamilyBiDi = 363
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
union YYSTYPE
{
/* Line 2058 of yacc.c */
#line 85 "rtfGrammar.y"
#line 82 "rtfGrammar.y"
int number;
const char *text;
RTFcmd cmd;
#line 172 "rtfGrammar.tab.h"
/* Line 2058 of yacc.c */
#line 171 "rtfGrammar.tab.h"
} YYSTYPE;
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int GSRTFparse (void *YYPARSE_PARAM);
#else
int GSRTFparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int GSRTFparse (void *ctxt, void *lctxt);
#else
int GSRTFparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_GSRTF_RTFGRAMMAR_TAB_H_INCLUDED */

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@
*/
/* we request for a reentrant parser */
%pure_parser
%define api.pure
%{
@ -60,10 +60,6 @@
/* this context is passed to the interface functions */
typedef void *GSRTFctxt;
// Two parameters are not supported by some bison versions. The declaration of
// yyparse in the .c file must be corrected to be able to compile it.
/*#define YYPARSE_PARAM ctxt, void *lctxt*/
#define YYLEX_PARAM lctxt
/*#undef YYLSP_NEEDED*/
#define CTXT ctxt
@ -81,6 +77,7 @@ int fieldStart = 0;
%parse-param {void *ctxt}
%parse-param {void *lctxt}
%lex-param {void *lctxt}
%union {
int number;
@ -184,6 +181,7 @@ int fieldStart = 0;
%token <cmd> RTFfcharset
%token <cmd> RTFfprq
%token <cmd> RTFcpg
%token <cmd> RTFansicpg
%token <cmd> RTFOtherStatement
%token RTFfontListStart
@ -209,11 +207,11 @@ int fieldStart = 0;
rtfFile: '{' { GSRTFstart(CTXT); } RTFstart rtfIngredients { GSRTFstop(CTXT); } '}'
;
/* FIXME: This should change the used encoding */
rtfCharset: RTFansi { $$ = 1; }
| RTFmac { $$ = 2; }
| RTFpc { $$ = 3; }
| RTFpca { $$ = 4; }
rtfCharset: RTFansi { GSRTFencoding(CTXT, 1); }
| RTFmac { GSRTFencoding(CTXT, 2); }
| RTFpc { GSRTFencoding(CTXT, $$ = 3); }
| RTFpca { GSRTFencoding(CTXT, 4); }
| rtfCharset RTFansicpg { GSRTFencoding(CTXT, $2.parameter); }
;
rtfIngredients: /* empty */

View file

@ -163,6 +163,7 @@ LexKeyword RTFcommands[] =
{"NeXTHelpLink",token(RTFNeXTHelpLink)},
{"NeXTHelpMarker",token(RTFNeXTHelpMarker)},
{"ansi", token(RTFansi)},
{"ansicpg", token(RTFansicpg)},
{"b", token(RTFbold)},
{"blue", token(RTFblue)},
{"bullet", token(RTFbullet)},