mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Remove notifications.
This commit is contained in:
commit
72cf6ce27c
37 changed files with 3255 additions and 28 deletions
63
ChangeLog
63
ChangeLog
|
@ -1,3 +1,66 @@
|
|||
2020-07-28 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/AppKit.h: Add includes for splitviewcontroller, pagecontroller and tabviewcontroller.
|
||||
* Headers/AppKit/NSPageController.h: Interface for page view controller
|
||||
* Headers/AppKit/NSSplitViewController.h: Interface for splitview controller
|
||||
* Headers/AppKit/NSSplitViewItem.h: Enhancements to splitview item to add logic for controller
|
||||
* Headers/AppKit/NSStoryboardSegue.h: Add methods to handle popovers
|
||||
* Headers/AppKit/NSTabViewController.h: Interface for tabViewController
|
||||
* Headers/AppKit/NSTabViewItem.h: methods to support NSViewController
|
||||
* Headers/AppKit/NSToolbar.h: Minor changes to support tabview controller
|
||||
* Headers/AppKit/NSViewController.h: Additional enum
|
||||
* MISSING: Remove implemented classes from list
|
||||
* Source/GNUmakefile: Add new classes
|
||||
* Source/GSStoryboardTransform.h: Additional methods on proxy
|
||||
* Source/GSStoryboardTransform.m: Additional methods on proxy
|
||||
* Source/GSThemeDrawing.m: minor changes
|
||||
* Source/GSXib5KeyedUnarchiver.m: Handle pagecontroller element, set certain things to true if abesnt
|
||||
* Source/NSPageController.m: Implementation of NSPageController
|
||||
* Source/NSSplitViewController.m: Implementation of NSSplitViewController
|
||||
* Source/NSSplitViewItem.m: Implementation
|
||||
* Source/NSStoryboardSegue.m: New methods for segue
|
||||
* Source/NSTabViewController.m: Implementation of NSTabViewController
|
||||
* Source/NSTabViewItem.m: New methods implementation
|
||||
* Source/NSTabView.m: Add methods to handle NSViewController changes
|
||||
* Source/NSViewController.m: New methods.
|
||||
* Source/NSView.m: Private methods to insert a view
|
||||
* Source/NSViewPrivate.h: Private method to insert view, declaration
|
||||
* Source/NSWindow.m: Minor fixes.
|
||||
|
||||
2020-07-19 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/AppKit.h: Add include files for NSSegue* and other
|
||||
classes.
|
||||
* Headers/AppKit/NSSeguePerforming.h: Protocol for segue performing
|
||||
so that classes that conform can be queried to determine if the
|
||||
segue should be performed in the first place.
|
||||
* Headers/AppKit/NSStoryboard.h: Class which loads the storyboard and
|
||||
loads the individual scenes and controllers.
|
||||
* Headers/AppKit/NSStoryboardSegue.h: This class handles the transition
|
||||
between controllers/scenes.
|
||||
* Headers/AppKit/NSViewController.h: Modifications to handle segues.
|
||||
* Headers/AppKit/NSWindowController.h: Modifications to handle segues.
|
||||
* Headers/AppKit/NSWindow.h: New method to create window controller for
|
||||
view controllers.
|
||||
* MISSING: Remove the classes implemented here from the missing list.
|
||||
* Source/Functions.m: Enhance NSApplicationMain() function to handle the
|
||||
loading of a storyboard.
|
||||
* Source/GNUmakefile: Add the new classes to the build and copy the headers.
|
||||
* Source/GSStoryboardTransform.[hm]: Class to handle the transformation of
|
||||
the storyboard file into "XIB" files for loading. Also handles the intermediate
|
||||
processes of instantiation of the destination controller.
|
||||
* Source/NSStoryboard.m: Implementation of the above described class.
|
||||
* Source/NSStoryboardSegue.m: Implementation of the above described class.
|
||||
* Source/NSViewController.m: Implementation of private methods to handle transitions.
|
||||
* Source/NSWindowController.m: Implementation of private methods to handle transitions.
|
||||
* Source/NSWindow.m: Implementation of method to create window controller for
|
||||
view controllers.
|
||||
|
||||
2020-07-10 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSOutlineView.h: Formalize protocols for
|
||||
NSOutlineViewDelegate and NSOutlineViewDataSource.
|
||||
|
||||
2020-07-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSXib5KeyedUnarchiver.m (alternateName:): Be more careful
|
||||
|
|
|
@ -188,6 +188,7 @@
|
|||
#import <AppKit/NSMediaLibraryBrowserController.h>
|
||||
#import <AppKit/NSMovie.h>
|
||||
#import <AppKit/NSMovieView.h>
|
||||
#import <AppKit/NSPageController.h>
|
||||
#import <AppKit/NSPanGestureRecognizer.h>
|
||||
#import <AppKit/NSNib.h>
|
||||
#import <AppKit/NSNibControlConnector.h>
|
||||
|
@ -228,12 +229,18 @@
|
|||
#import <AppKit/NSStepperTouchBarItem.h>
|
||||
#import <AppKit/NSStepper.h>
|
||||
#import <AppKit/NSStepperCell.h>
|
||||
#import <AppKit/NSStoryboard.h>
|
||||
#import <AppKit/NSStoryboardSegue.h>
|
||||
#import <AppKit/NSSeguePerforming.h>
|
||||
#import <AppKit/NSSwitch.h>
|
||||
#import <AppKit/NSSplitViewController.h>
|
||||
#import <AppKit/NSSplitViewItem.h>
|
||||
#import <AppKit/NSTableColumn.h>
|
||||
#import <AppKit/NSTableHeaderCell.h>
|
||||
#import <AppKit/NSTableHeaderView.h>
|
||||
#import <AppKit/NSTableView.h>
|
||||
#import <AppKit/NSTabView.h>
|
||||
#import <AppKit/NSTabViewController.h>
|
||||
#import <AppKit/NSTabViewItem.h>
|
||||
#import <AppKit/NSTextAlternatives.h>
|
||||
#import <AppKit/NSTextAttachment.h>
|
||||
|
|
|
@ -86,9 +86,9 @@
|
|||
@end /* interface of NSOutlineView */
|
||||
|
||||
/**
|
||||
* Informal protocol NSOutlineViewDataSource
|
||||
* protocol NSOutlineViewDataSource
|
||||
*/
|
||||
@interface NSObject (NSOutlineViewDataSource)
|
||||
@protocol NSOutlineViewDataSource
|
||||
/**
|
||||
* Called to perform drop operation and returns YES if successful,
|
||||
* and NO otherwise.
|
||||
|
@ -197,7 +197,7 @@ APPKIT_EXPORT NSString *NSOutlineViewItemWillCollapseNotification;
|
|||
/*
|
||||
* Methods Implemented by the Delegate
|
||||
*/
|
||||
@interface NSObject (NSOutlineViewDelegate)
|
||||
@protocol NSOutlineViewDelegate
|
||||
// notification methods
|
||||
/**
|
||||
* Called after the column has moved.
|
||||
|
|
101
Headers/AppKit/NSPageController.h
Normal file
101
Headers/AppKit/NSPageController.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* Definition of class NSPageController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 27-07-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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef _NSPageController_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSPageController_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSView, NSArray, NSMutableArray;
|
||||
@protocol NSPageControllerDelegate;
|
||||
|
||||
typedef NSString* NSPageControllerObjectIdentifier;
|
||||
|
||||
enum
|
||||
{
|
||||
NSPageControllerTransitionStyleStackHistory,
|
||||
NSPageControllerTransitionStyleStackBook,
|
||||
NSPageControllerTransitionStyleHorizontalStrip
|
||||
};
|
||||
typedef NSUInteger NSPageControllerTransitionStyle;
|
||||
|
||||
@interface NSPageController : NSViewController
|
||||
{
|
||||
NSPageControllerTransitionStyle _transitionStyle;
|
||||
id _delegate;
|
||||
NSMutableArray *_arrangedObjects;
|
||||
NSInteger _selectedIndex;
|
||||
NSViewController *_selectedViewController;
|
||||
}
|
||||
|
||||
// Set/Get properties
|
||||
- (NSPageControllerTransitionStyle) transitionStyle;
|
||||
- (void) setTransitionStyle: (NSPageControllerTransitionStyle)style;
|
||||
|
||||
- (id) delegate;
|
||||
- (void) setDelegate: (id)delegate;
|
||||
|
||||
- (NSArray *) arrangedObjects;
|
||||
- (void) setArrangedObjects: (NSArray *)array;
|
||||
|
||||
- (NSInteger) selectedIndex;
|
||||
- (void) setSelectedIndex: (NSInteger)index;
|
||||
|
||||
- (NSViewController *) selectedViewController;
|
||||
|
||||
// Handle page transitions
|
||||
- (void) navigateForwardToObject: (id)object;
|
||||
|
||||
- (void) completeTransition;
|
||||
|
||||
- (IBAction) navigateBack: (id)sender;
|
||||
- (IBAction) navigateForward: (id)sender;
|
||||
- (IBAction) takeSelectedIndexFrom: (id)sender; // uses integerValue from sender
|
||||
@end
|
||||
|
||||
@protocol NSPageControllerDelegate
|
||||
- (NSPageControllerObjectIdentifier) pageController: (NSPageController *)pageController identifierForObject: (id)object;
|
||||
- (NSViewController *) pageController: (NSPageController *)pageController viewControllerForIdentifier: (NSPageControllerObjectIdentifier)identifier;
|
||||
- (NSRect) pageController: (NSPageController *)pageController frameForObject: (id)object;
|
||||
- (void) pageController: (NSPageController *)pageController prepareViewController: (NSViewController *)viewController withObject: (id)object;
|
||||
- (void) pageController: (NSPageController *)pageController didTransitionToObject: (id)object;
|
||||
- (void) pageControllerWillStartLiveTransition: (NSPageController *)pageController;
|
||||
- (void) pageControllerDidEndLiveTransition: (NSPageController *)pageController;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSPageController_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
55
Headers/AppKit/NSSeguePerforming.h
Normal file
55
Headers/AppKit/NSSeguePerforming.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Definition of class NSSeguePerforming
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento
|
||||
Date: Mon Jan 20 16:53:17 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 _NSSeguePerforming_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSSeguePerforming_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <AppKit/NSStoryboardSegue.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@protocol NSSeguePerforming
|
||||
- (void)performSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender;
|
||||
|
||||
- (void)prepareForSegue: (NSStoryboardSegue *)segue
|
||||
sender: (id)sender;
|
||||
|
||||
- (BOOL)shouldPerformSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSSeguePerforming_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
78
Headers/AppKit/NSSplitViewController.h
Normal file
78
Headers/AppKit/NSSplitViewController.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* Definition of class NSSplitViewController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Mon 20 Jul 2020 12:55:02 AM EDT
|
||||
|
||||
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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef _NSSplitViewController_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSSplitViewController_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
#import <AppKit/NSUserInterfaceValidation.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSSplitView, NSSplitViewItem, NSArray, NSMutableArray;
|
||||
|
||||
@interface NSSplitViewController : NSViewController
|
||||
{
|
||||
CGFloat _minimumThicknessForInlineSidebars;
|
||||
NSMutableArray *_splitViewItems;
|
||||
}
|
||||
|
||||
// return splitview...
|
||||
- (NSSplitView *) splitView;
|
||||
- (void) setSplitView: (NSSplitView *)splitView;
|
||||
- (NSSplitViewItem *) splitViewItemForViewController: (NSViewController *)vc;
|
||||
- (CGFloat) minimumThicknessForInlineSidebars;
|
||||
- (void) setMinimumThicknessForInlineSidebars: (CGFloat)value;
|
||||
|
||||
// manage splitview items...
|
||||
- (NSArray *) splitViewItems;
|
||||
- (void) setSplitViewItems: (NSArray *)items;
|
||||
- (void) addSplitViewItem: (NSSplitViewItem *)item;
|
||||
- (void) insertSplitViewItem: (NSSplitViewItem *)item atIndex: (NSInteger)index;
|
||||
- (void) removeSplitViewItem: (NSSplitViewItem *)item;
|
||||
|
||||
// instance methods...
|
||||
- (NSRect) splitView: (NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex: (NSInteger)dividerIndex;
|
||||
- (BOOL) splitView: (NSSplitView *)splitView canCollapseSubview: (NSView *)subview;
|
||||
- (NSRect) splitView: (NSSplitView *)splitView effectiveRect: (NSRect)proposedEffectiveRect
|
||||
forDrawnRect: (NSRect)drawnRect ofDividerAtIndex: (NSInteger)dividerIndex;
|
||||
- (BOOL) splitView: (NSSplitView *)splitView shouldCollapseSubview: (NSView *)subview
|
||||
forDoubleClickOnDividerAtIndex: (NSInteger)dividerIndex;
|
||||
- (BOOL) splitView: (NSSplitView *)splitView shouldHideDividerAtIndex: (NSInteger)dividerIndex;
|
||||
- (IBAction)toggleSidebar:(id)sender;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSSplitViewController_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
119
Headers/AppKit/NSSplitViewItem.h
Normal file
119
Headers/AppKit/NSSplitViewItem.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* Interface of class NSSplitViewItem
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Mon 20 Jul 2020 12:56:20 AM EDT
|
||||
|
||||
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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef _NSSplitViewItem_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSSplitViewItem_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
NSSplitViewItemBehaviorDefault,
|
||||
NSSplibViewItemBehaviorSidebar,
|
||||
NSSplitViewItemBehaviorContentList
|
||||
};
|
||||
typedef NSInteger NSSplitViewItemBehavior;
|
||||
|
||||
enum
|
||||
{
|
||||
NSSplitViewItemCollapseBehaviorDefault,
|
||||
NSSplitViewItemCollapseBehaviorPreferResizingSiblingsWithFixedSplitView,
|
||||
NSSplitViewItemCollapseBehaviorPreferResizingSplitViewWithFixedSiblings,
|
||||
NSSplitViewItemCollapseBehaviorUseConstraints
|
||||
};
|
||||
typedef NSInteger NSSplitViewItemCollapseBehavior;
|
||||
|
||||
enum
|
||||
{
|
||||
NSTitlebarSeparatorStyleAutomatic,
|
||||
NSTitlebarSeparatorStyleLine,
|
||||
NSTitlebarSeparatorStyleNone,
|
||||
NSTitlebarSeparatorStyleShadow
|
||||
};
|
||||
typedef NSInteger NSTitlebarSeparatorStyle;
|
||||
|
||||
@class NSViewController;
|
||||
|
||||
@interface NSSplitViewItem : NSObject <NSCoding>
|
||||
{
|
||||
CGFloat _automaticMaximumThickness;
|
||||
CGFloat _preferredThicknessFraction;
|
||||
CGFloat _minimumThickness;
|
||||
CGFloat _maximumThickness;
|
||||
BOOL _springLoaded;
|
||||
BOOL _allowsFullHeightLayout;
|
||||
BOOL _canCollapse;
|
||||
CGFloat /*NSLayoutPriority*/ _holdingPriority;
|
||||
NSSplitViewItemCollapseBehavior _collapseBehavior;
|
||||
NSViewController *_viewController;
|
||||
NSTitlebarSeparatorStyle _titlebarSeparatorStyle;
|
||||
}
|
||||
|
||||
+ (instancetype)contentListWithViewController:(NSViewController *)viewController;
|
||||
+ (instancetype)sidebarWithViewController:(NSViewController *)viewController;
|
||||
+ (instancetype)splitViewItemWithViewController:(NSViewController *)viewController;
|
||||
|
||||
- (CGFloat) automaticMaximumThickness;
|
||||
- (void) setAutomaticMaximumThickness: (CGFloat)f;
|
||||
- (CGFloat) preferredThicknessFraction;
|
||||
- (void) setPreferredThicknessFraction: (CGFloat)f;
|
||||
- (CGFloat) minimumThickness;
|
||||
- (void) setMinimumThickness: (CGFloat)f;
|
||||
- (CGFloat) maximumThickness;
|
||||
- (void) setMaximumThickness: (CGFloat)f;
|
||||
|
||||
- (/* NSLayoutPriority */ CGFloat) holdingPriority;
|
||||
|
||||
- (BOOL) canCollapse;
|
||||
- (NSSplitViewItemCollapseBehavior) collapseBehavior;
|
||||
- (BOOL) isSpringLoaded;
|
||||
- (void) setSpringLoaded: (BOOL)flag;
|
||||
|
||||
- (BOOL) allowsFullHeightLayout;
|
||||
- (void) setAllowsFullHeightLayout: (BOOL)flag;
|
||||
|
||||
- (NSTitlebarSeparatorStyle) titlebarSeparatorStyle;
|
||||
- (void) setTitlebarSeparatorStyle: (NSTitlebarSeparatorStyle)style;
|
||||
|
||||
- (NSViewController *) viewController;
|
||||
- (void) setViewController: (NSViewController *)vc;
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT const CGFloat NSSplitViewItemUnspecifiedDimension;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSSplitViewItem_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
77
Headers/AppKit/NSStoryboard.h
Normal file
77
Headers/AppKit/NSStoryboard.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* Definition of class NSStoryboard
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento
|
||||
Date: Mon Jan 20 15:57:37 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 _NSStoryboard_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSStoryboard_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSString, NSBundle, NSMutableDictionary;
|
||||
|
||||
typedef NSString *NSStoryboardName;
|
||||
typedef NSString *NSStoryboardSceneIdentifier;
|
||||
|
||||
DEFINE_BLOCK_TYPE(NSStoryboardControllerCreator, NSCoder*, id);
|
||||
|
||||
@interface NSStoryboard : NSObject
|
||||
{
|
||||
id _transform;
|
||||
}
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_13, GS_API_LATEST)
|
||||
+ (NSStoryboard *) mainStoryboard;
|
||||
#endif
|
||||
|
||||
+ (instancetype) storyboardWithName: (NSStoryboardName)name
|
||||
bundle: (NSBundle *)bundle;
|
||||
|
||||
- (id) instantiateInitialController;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
|
||||
- (id) instantiateInitialControllerWithCreator: (NSStoryboardControllerCreator)block;
|
||||
#endif
|
||||
|
||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
|
||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
||||
creator: (NSStoryboardControllerCreator)block;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSStoryboard_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
79
Headers/AppKit/NSStoryboardSegue.h
Normal file
79
Headers/AppKit/NSStoryboardSegue.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* Definition of class NSStoryboardSegue
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento
|
||||
Date: Mon Jan 20 15:57: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 _NSStoryboardSegue_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSStoryboardSegue_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#import <AppKit/NSPopover.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef NSString *NSStoryboardSegueIdentifier;
|
||||
|
||||
DEFINE_BLOCK_TYPE_NO_ARGS(GSStoryboardSeguePerformHandler, void);
|
||||
|
||||
@interface NSStoryboardSegue : NSObject
|
||||
{
|
||||
id _sourceController;
|
||||
id _destinationController;
|
||||
NSStoryboardSegueIdentifier _identifier;
|
||||
NSString *_kind;
|
||||
NSString *_relationship;
|
||||
id _popoverAnchorView;
|
||||
NSPopoverBehavior _popoverBehavior;
|
||||
NSRectEdge _preferredEdge;
|
||||
GSStoryboardSeguePerformHandler _handler;
|
||||
}
|
||||
|
||||
- (id) sourceController;
|
||||
- (id) destinationController;
|
||||
- (NSStoryboardSegueIdentifier) identifier;
|
||||
|
||||
+ (instancetype) segueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
source: (id)sourceController
|
||||
destination: (id)destinationController
|
||||
performHandler: (GSStoryboardSeguePerformHandler)performHandler;
|
||||
|
||||
- (instancetype) initWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
source: (id)sourceController
|
||||
destination: (id)destinationController;
|
||||
|
||||
- (void) perform;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSStoryboardSegue_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
101
Headers/AppKit/NSTabViewController.h
Normal file
101
Headers/AppKit/NSTabViewController.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/* Definition of class NSTabViewController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 23-07-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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef _NSTabViewController_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSTabViewController_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <AppKit/NSViewController.h>
|
||||
#import <AppKit/NSToolbar.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSArray, NSTabViewItem, NSTabView, NSMutableArray;
|
||||
|
||||
enum
|
||||
{
|
||||
NSTabViewControllerTabStyleSegmentedControlOnTop,
|
||||
NSTabViewControllerTabStyleSegmentedControlOnBottom,
|
||||
NSTabViewControllerTabStyleToolbar,
|
||||
NSTabViewControllerTabStyleUnspecified
|
||||
};
|
||||
typedef NSUInteger NSTabViewControllerTabStyle;
|
||||
|
||||
@interface NSTabViewController : NSViewController
|
||||
{
|
||||
NSTabViewControllerTabStyle _tabStyle;
|
||||
NSViewControllerTransitionOptions _transitionOptions;
|
||||
BOOL _canPropagateSelectedChildViewControllerTitle;
|
||||
}
|
||||
|
||||
- (NSTabViewControllerTabStyle) tabStyle;
|
||||
- (void) setTabStyle: (NSTabViewControllerTabStyle)ts;
|
||||
|
||||
- (NSTabView *) tabView;
|
||||
- (void) setTabView: (NSTabView *)tv;
|
||||
|
||||
- (NSViewControllerTransitionOptions) transitionOptions;
|
||||
- (void) setTransitionOptions: (NSViewControllerTransitionOptions)options;
|
||||
|
||||
- (BOOL) canPropagateSelectedChildViewControllerTitle;
|
||||
- (void) setCanPropagateSelectedChildViewControllerTitle: (BOOL)flag;
|
||||
|
||||
// Managing tabViewItems...
|
||||
- (NSArray *) tabViewItems;
|
||||
- (void) setTabViewItems: (NSArray *)items;
|
||||
- (NSTabViewItem *) tabViewItemForViewController: (NSViewController *)controller;
|
||||
- (void) addTabViewItem: (NSTabViewItem *)item;
|
||||
- (void) insertTabViewItem: (NSTabViewItem *)item
|
||||
atIndex: (NSInteger)index;
|
||||
- (void) removeTabViewItem: (NSTabViewItem *)item;
|
||||
- (NSInteger) selectedTabViewItemIndex;
|
||||
- (void) setSelectedTabViewItemIndex: (NSInteger)idx;
|
||||
|
||||
// Responding to tabview actions...
|
||||
- (BOOL)tabView:(NSTabView *)tabView
|
||||
shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem;
|
||||
- (void)tabView:(NSTabView *)tabView
|
||||
willSelectTabViewItem:(NSTabViewItem *)tabViewItem;
|
||||
- (void)tabView:(NSTabView *)tabView
|
||||
didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
|
||||
|
||||
// Responding to toolbar actions...
|
||||
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
|
||||
itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
|
||||
willBeInsertedIntoToolbar:(BOOL)flag;
|
||||
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar;
|
||||
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSTabViewController_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
|
@ -41,6 +41,7 @@ typedef enum {
|
|||
@class NSColor;
|
||||
@class NSTabView;
|
||||
@class NSView;
|
||||
@class NSViewController;
|
||||
|
||||
@interface NSTabViewItem : NSObject <NSCoding>
|
||||
{
|
||||
|
@ -53,7 +54,9 @@ typedef enum {
|
|||
NSTabView *_tabview;
|
||||
NSRect _rect; // cached
|
||||
NSString *_toolTip;
|
||||
NSViewController *_viewController;
|
||||
}
|
||||
|
||||
- (id) initWithIdentifier:(id)identifier;
|
||||
|
||||
- (void)setIdentifier:(id)identifier;
|
||||
|
@ -78,6 +81,13 @@ typedef enum {
|
|||
- (void)drawLabel:(BOOL)shouldTruncateLabel
|
||||
inRect:(NSRect)tabRect;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
- (NSViewController *) viewController;
|
||||
- (void) setViewController: (NSViewController *)vc;
|
||||
|
||||
+ (instancetype) tabViewItemWithViewController: (NSViewController *)vc;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
- (NSString *)toolTip;
|
||||
- (void)setToolTip:(NSString *)newToolTip;
|
||||
|
|
|
@ -72,6 +72,8 @@ typedef enum
|
|||
APPKIT_EXPORT NSString *NSToolbarDidRemoveItemNotification;
|
||||
APPKIT_EXPORT NSString *NSToolbarWillAddItemNotification;
|
||||
|
||||
typedef NSString* NSToolbarItemIdentifier;
|
||||
|
||||
@interface NSToolbar : NSObject
|
||||
{
|
||||
NSDictionary *_configurationDictionary;
|
||||
|
|
|
@ -28,12 +28,29 @@ Boston, MA 02110-1301, USA.
|
|||
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSResponder.h>
|
||||
#import <AppKit/NSSeguePerforming.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
|
||||
@class NSArray, NSBundle, NSPointerArray, NSView;
|
||||
@class NSArray, NSBundle, NSPointerArray, NSView, NSMapTable, NSStoryboard;
|
||||
|
||||
@interface NSViewController : NSResponder
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
enum
|
||||
{
|
||||
NSViewControllerTransitionNone = 0x0,
|
||||
NSViewControllerTransitionCrossfade = 0x1,
|
||||
NSViewControllerTransitionSlideUp = 0x10,
|
||||
NSViewControllerTransitionSlideDown = 0x20,
|
||||
NSViewControllerTransitionSlideLeft = 0x40,
|
||||
NSViewControllerTransitionSlideRight = 0x80,
|
||||
NSViewControllerTransitionSlideForward = 0x140,
|
||||
NSViewControllerTransitionSlideBackward = 0x180,
|
||||
NSViewControllerTransitionAllowUserInteraction = 0x1000,
|
||||
};
|
||||
typedef NSUInteger NSViewControllerTransitionOptions;
|
||||
#endif
|
||||
|
||||
@interface NSViewController : NSResponder <NSSeguePerforming>
|
||||
{
|
||||
@private
|
||||
NSString *_nibName;
|
||||
|
@ -45,6 +62,8 @@ Boston, MA 02110-1301, USA.
|
|||
NSPointerArray *_editors;
|
||||
id _autounbinder;
|
||||
NSString *_designNibBundleIdentifier;
|
||||
NSMapTable *_segueMap;
|
||||
NSStoryboard *_storyboard; // a weak reference to the origin storyboard.
|
||||
struct ___vcFlags
|
||||
{
|
||||
unsigned int nib_is_loaded:1;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
@class NSView;
|
||||
@class NSWindowController;
|
||||
@class NSCachedImageRep;
|
||||
@class NSViewController;
|
||||
|
||||
@class GSWindowDecorationView;
|
||||
|
||||
|
@ -336,6 +337,14 @@ PACKAGE_SCOPE
|
|||
* Computing frame and content rectangles
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a window with the view of the specified viewController as it's
|
||||
* content view. The window is resizable, titled, closable, and miniaturizable.
|
||||
*/
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
+ (instancetype) windowWithContentViewController: (NSViewController *)viewController;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the rectangle which would be used for the content view of
|
||||
* a window whose on-screen size and position is specified by aRect
|
||||
|
|
|
@ -29,13 +29,16 @@
|
|||
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSResponder.h>
|
||||
#import <AppKit/NSSeguePerforming.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSArray;
|
||||
@class NSWindow;
|
||||
@class NSDocument;
|
||||
@class NSMapTable;
|
||||
@class NSStoryboard;
|
||||
|
||||
@interface NSWindowController : NSResponder <NSCoding>
|
||||
@interface NSWindowController : NSResponder <NSCoding, NSSeguePerforming>
|
||||
{
|
||||
@private
|
||||
NSWindow *_window;
|
||||
|
@ -45,6 +48,8 @@
|
|||
NSDocument *_document;
|
||||
NSArray *_top_level_objects;
|
||||
id _owner;
|
||||
NSMapTable *_segueMap;
|
||||
NSStoryboard *_storyboard; // a weak reference to the origin storyboard
|
||||
struct ___wcFlags
|
||||
{
|
||||
unsigned int should_close_document:1;
|
||||
|
|
6
MISSING
6
MISSING
|
@ -17,16 +17,10 @@ MISSING HEADERS
|
|||
> NSItemProvider.h
|
||||
> NSMenuToolbarItem.h
|
||||
> NSOpenGLLayer.h
|
||||
> NSPageController.h
|
||||
> NSRuleEditor.h
|
||||
> NSSliderAccessory.h
|
||||
> NSSplitViewController.h
|
||||
> NSSplitViewItem.h
|
||||
> NSStackView.h
|
||||
> NSStatusBarButton.h
|
||||
> NSStoryboard.h
|
||||
> NSStoryboardSegue.h
|
||||
> NSTabViewController.h
|
||||
> NSTableCellView.h
|
||||
> NSTableRowView.h
|
||||
> NSTableViewRowAction.h
|
||||
|
|
|
@ -44,9 +44,18 @@
|
|||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/DPSOperators.h"
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
|
||||
char **NSArgv = NULL;
|
||||
|
||||
@interface NSStoryboard (Private)
|
||||
|
||||
+ (void) _setMainStoryboard: (NSStoryboard *)storyboard;
|
||||
- (void) _instantiateApplicationScene;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* Main initialization routine for the GNUstep GUI Library Apps
|
||||
*/
|
||||
|
@ -85,6 +94,29 @@ NSApplicationMain(int argc, const char **argv)
|
|||
NSLog (_(@"Cannot load the main model file '%@'"), mainModelFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mainModelFile = [infoDict objectForKey: @"NSMainStoryboardFile"];
|
||||
if (mainModelFile != nil && [mainModelFile isEqual: @""] == NO)
|
||||
{
|
||||
NSStoryboard *storyboard = [NSStoryboard storyboardWithName: mainModelFile
|
||||
bundle: [NSBundle mainBundle]];
|
||||
if (storyboard == nil)
|
||||
{
|
||||
NSLog (_(@"Cannot load the main storyboard file '%@'"), mainModelFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSStoryboard _setMainStoryboard: storyboard];
|
||||
[storyboard _instantiateApplicationScene];
|
||||
[storyboard instantiateInitialController];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Storyboard is blank or nil, unable to load.");
|
||||
}
|
||||
}
|
||||
|
||||
RECREATE_AUTORELEASE_POOL(pool);
|
||||
|
||||
|
|
|
@ -165,6 +165,8 @@ NSSharingServicePickerToolbarItem.m \
|
|||
NSSharingServicePickerTouchBarItem.m \
|
||||
NSSliderTouchBarItem.m \
|
||||
NSStepperTouchBarItem.m \
|
||||
NSStoryboard.m \
|
||||
NSStoryboardSegue.m \
|
||||
NSMagnificationGestureRecognizer.m \
|
||||
NSMatrix.m \
|
||||
NSMenu.m \
|
||||
|
@ -186,6 +188,7 @@ NSOpenGLPixelFormat.m \
|
|||
NSOpenGLView.m \
|
||||
NSOpenPanel.m \
|
||||
NSOutlineView.m \
|
||||
NSPageController.m \
|
||||
NSPageLayout.m \
|
||||
NSPanel.m \
|
||||
NSPanGestureRecognizer.m \
|
||||
|
@ -240,12 +243,15 @@ NSSpeechSynthesizer.m \
|
|||
NSStepperTouchBarItem.m \
|
||||
NSSpellChecker.m \
|
||||
NSSplitView.m \
|
||||
NSSplitViewController.m \
|
||||
NSSplitViewItem.m \
|
||||
NSStepper.m \
|
||||
NSStepperCell.m \
|
||||
NSStringDrawing.m \
|
||||
NSStatusBar.m \
|
||||
NSStatusItem.m \
|
||||
NSTabView.m \
|
||||
NSTabViewController.m \
|
||||
NSTabViewItem.m \
|
||||
NSTableColumn.m \
|
||||
NSTableHeaderView.m \
|
||||
|
@ -324,6 +330,7 @@ GSToolTips.m \
|
|||
GSToolbarView.m \
|
||||
GSToolbarCustomizationPalette.m \
|
||||
GSStandardWindowDecorationView.m \
|
||||
GSStoryboardTransform.m \
|
||||
GSWindowDecorationView.m \
|
||||
GSPrinting.m \
|
||||
GSPrintOperation.m \
|
||||
|
@ -464,6 +471,7 @@ NSOpenPanel.h \
|
|||
NSOpenGL.h \
|
||||
NSOpenGLView.h \
|
||||
NSOutlineView.h \
|
||||
NSPageController.h \
|
||||
NSPageLayout.h \
|
||||
NSPanel.h \
|
||||
NSPanGestureRecognizer.h \
|
||||
|
@ -524,14 +532,20 @@ NSSpeechSynthesizer.h \
|
|||
NSSpellChecker.h \
|
||||
NSSpellServer.h \
|
||||
NSSplitView.h \
|
||||
NSSplitViewController.h \
|
||||
NSSplitViewItem.h \
|
||||
NSStepper.h \
|
||||
NSStepperCell.h \
|
||||
NSStepperTouchBarItem.h \
|
||||
NSStoryboard.h \
|
||||
NSStoryboardSegue.h \
|
||||
NSSeguePerforming.h \
|
||||
NSStringDrawing.h \
|
||||
NSStatusBar.h \
|
||||
NSStatusItem.h \
|
||||
NSSwitch.h \
|
||||
NSTabView.h \
|
||||
NSTabViewController.h \
|
||||
NSTabViewItem.h \
|
||||
NSTableColumn.h \
|
||||
NSTableHeaderCell.h \
|
||||
|
|
119
Source/GSStoryboardTransform.h
Normal file
119
Source/GSStoryboardTransform.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* Interface of class GSStoryboardTransform
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Sat 04 Jul 2020 03:48:15 PM EDT
|
||||
|
||||
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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef _GSStoryboardTransform_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _GSStoryboardTransform_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSMutableDictionary;
|
||||
@class NSDictionary;
|
||||
@class NSData;
|
||||
@class NSMapTable;
|
||||
@class NSXMLDocument;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@interface GSStoryboardTransform : NSObject
|
||||
{
|
||||
NSMutableDictionary *_scenesMap;
|
||||
NSMutableDictionary *_controllerMap;
|
||||
NSMutableDictionary *_identifierToSegueMap;
|
||||
NSString *_initialViewControllerId;
|
||||
NSString *_applicationSceneId;
|
||||
}
|
||||
|
||||
- (instancetype) initWithData: (NSData *)data;
|
||||
|
||||
- (NSString *) initialViewControllerId;
|
||||
- (NSString *) applicationSceneId;
|
||||
|
||||
- (NSData *) dataForIdentifier: (NSString *)identifier;
|
||||
- (NSMapTable *) segueMapForIdentifier: (NSString *)identifier;
|
||||
|
||||
- (void) processStoryboard: (NSXMLDocument *)storyboardXml;
|
||||
@end
|
||||
|
||||
// Private classes used when parsing the XIB generated by the transformer...
|
||||
@interface NSStoryboardSeguePerformAction : NSObject <NSCoding, NSCopying>
|
||||
{
|
||||
id _target;
|
||||
SEL _action;
|
||||
id _sender;
|
||||
NSString *_identifier;
|
||||
NSString *_kind;
|
||||
id _popoverAnchorView;
|
||||
NSStoryboardSegue *_storyboardSegue;
|
||||
NSStoryboard *_storyboard;
|
||||
}
|
||||
|
||||
- (id) target;
|
||||
- (void) setTarget: (id)target;
|
||||
|
||||
- (NSString *) selector;
|
||||
- (void) setSelector: (NSString *)s;
|
||||
|
||||
- (SEL) action;
|
||||
- (void) setAction: (SEL)action;
|
||||
|
||||
- (id) sender;
|
||||
- (void) setSender: (id)sender;
|
||||
|
||||
- (NSString *) identifier;
|
||||
- (void) setIdentifier: (NSString *)identifier;
|
||||
|
||||
- (NSString *) kind;
|
||||
- (void) setKind: (NSString *)kind;
|
||||
|
||||
- (void) setPopoverAnchorView: (id)view;
|
||||
- (id) popoverAnchorView;
|
||||
|
||||
- (NSStoryboard *) storyboard;
|
||||
- (void) setStoryboard: (NSStoryboard *)storyboard;
|
||||
|
||||
- (NSStoryboardSegue *) storyboardSegue;
|
||||
- (void) setStoryboardSegue: (NSStoryboardSegue *)ss;
|
||||
|
||||
- (IBAction) doAction: (id)sender;
|
||||
@end
|
||||
|
||||
@interface NSControllerPlaceholder : NSObject <NSCoding, NSCopying>
|
||||
{
|
||||
NSString *_storyboardName;
|
||||
}
|
||||
|
||||
- (NSString *) storyboardName;
|
||||
- (void) setStoryboardName: (NSString *)name;
|
||||
|
||||
- (id) instantiate;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GSStoryboardTransform_h_GNUSTEP_GUI_INCLUDE */
|
888
Source/GSStoryboardTransform.m
Normal file
888
Source/GSStoryboardTransform.m
Normal file
|
@ -0,0 +1,888 @@
|
|||
/* Implementation of class GSStoryboardTransform
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Sat 04 Jul 2020 03:48:15 PM EDT
|
||||
|
||||
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
|
||||
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/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSXMLDocument.h>
|
||||
#import <Foundation/NSXMLNode.h>
|
||||
#import <Foundation/NSXMLElement.h>
|
||||
#import <Foundation/NSUUID.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
#import "AppKit/NSSeguePerforming.h"
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
#import "AppKit/NSStoryboardSegue.h"
|
||||
#import "AppKit/NSNibDeclarations.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
|
||||
#import "GSStoryboardTransform.h"
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
#define APPLICATION @"application"
|
||||
|
||||
@interface NSStoryboardSegue (__private__)
|
||||
- (void) _setDestinationController: (id)controller;
|
||||
- (void) _setSourceController: (id)controller;
|
||||
@end
|
||||
|
||||
@interface NSStoryboardSegue (__StoryboardPrivate__)
|
||||
// Private to this class...
|
||||
- (void) _setKind: (NSString *)k;
|
||||
- (NSString *) _kind;
|
||||
- (void) _setRelationship: (NSString *)r;
|
||||
- (NSString *) _relationship;
|
||||
- (void) _setPopoverAnchorView: (id)view;
|
||||
- (id) _popoverAnchorView;
|
||||
- (void) _setPopoverBehavior: (NSPopoverBehavior)behavior;
|
||||
- (NSPopoverBehavior) _popoverBehavior;
|
||||
- (void) _setPreferredEdge: (NSRectEdge)edge;
|
||||
- (NSRectEdge) _preferredEdge;
|
||||
@end
|
||||
|
||||
// this needs to be set on segues
|
||||
@implementation NSStoryboardSegue (__StoryboardPrivate__)
|
||||
- (void) _setKind: (NSString *)k
|
||||
{
|
||||
ASSIGN(_kind, k);
|
||||
}
|
||||
|
||||
- (NSString *) _kind
|
||||
{
|
||||
return _kind;
|
||||
}
|
||||
|
||||
- (void) _setRelationship: (NSString *)r
|
||||
{
|
||||
ASSIGN(_relationship, r);
|
||||
}
|
||||
|
||||
- (NSString *) _relationship
|
||||
{
|
||||
return _relationship;
|
||||
}
|
||||
|
||||
- (void) _setPopoverAnchorView: (id)view
|
||||
{
|
||||
ASSIGN(_popoverAnchorView, view);
|
||||
}
|
||||
|
||||
- (id) _popoverAnchorView
|
||||
{
|
||||
return _popoverAnchorView;
|
||||
}
|
||||
|
||||
- (void) _setPopoverBehavior: (NSPopoverBehavior)behavior
|
||||
{
|
||||
_popoverBehavior = behavior;
|
||||
}
|
||||
|
||||
- (NSPopoverBehavior) _popoverBehavior
|
||||
{
|
||||
return _popoverBehavior;
|
||||
}
|
||||
|
||||
- (void) _setPreferredEdge: (NSRectEdge)edge
|
||||
{
|
||||
_preferredEdge = edge;
|
||||
}
|
||||
|
||||
- (NSRectEdge) _preferredEdge
|
||||
{
|
||||
return _preferredEdge;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSStoryboardSeguePerformAction
|
||||
- (id) target
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
- (void) setTarget: (id)target
|
||||
{
|
||||
ASSIGN(_target, target);
|
||||
}
|
||||
|
||||
- (SEL) action
|
||||
{
|
||||
return _action;
|
||||
}
|
||||
|
||||
- (void) setAction: (SEL)action
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
- (NSString *) selector
|
||||
{
|
||||
return NSStringFromSelector(_action);
|
||||
}
|
||||
|
||||
- (void) setSelector: (NSString *)s
|
||||
{
|
||||
_action = NSSelectorFromString(s);
|
||||
}
|
||||
|
||||
- (id) sender
|
||||
{
|
||||
return _sender;
|
||||
}
|
||||
|
||||
- (void) setSender: (id)sender
|
||||
{
|
||||
ASSIGN(_sender, sender);
|
||||
}
|
||||
|
||||
- (NSString *) identifier
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
- (void) setIdentifier: (NSString *)identifier
|
||||
{
|
||||
ASSIGN(_identifier, identifier);
|
||||
}
|
||||
|
||||
- (NSString *) kind
|
||||
{
|
||||
return _kind;
|
||||
}
|
||||
|
||||
- (void) setKind: (NSString *)kind
|
||||
{
|
||||
ASSIGN(_kind, kind);
|
||||
}
|
||||
|
||||
- (void) setPopoverAnchorView: (id)view
|
||||
{
|
||||
ASSIGN(_popoverAnchorView, view);
|
||||
}
|
||||
|
||||
- (id) popoverAnchorView
|
||||
{
|
||||
return _popoverAnchorView;
|
||||
}
|
||||
|
||||
- (NSStoryboard *) storyboard
|
||||
{
|
||||
return _storyboard;
|
||||
}
|
||||
|
||||
- (void) setStoryboard: (NSStoryboard *)storyboard
|
||||
{
|
||||
ASSIGN(_storyboard, storyboard);
|
||||
}
|
||||
|
||||
- (NSStoryboardSegue *) storyboardSegue
|
||||
{
|
||||
return _storyboardSegue;
|
||||
}
|
||||
|
||||
- (void) setStoryboardSegue: (NSStoryboardSegue *)ss
|
||||
{
|
||||
ASSIGN(_storyboardSegue, ss);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_storyboard);
|
||||
RELEASE(_kind);
|
||||
RELEASE(_identifier);
|
||||
RELEASE(_popoverAnchorView);
|
||||
RELEASE(_sender);
|
||||
RELEASE(_storyboardSegue);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (IBAction) doAction: (id)sender
|
||||
{
|
||||
BOOL should = YES;
|
||||
|
||||
// If the instance we are testing is a controller, then the value of should is set by this method....
|
||||
// if it is not, as it is possible to initiate a segue from an NSMenuItem, then we don't, but should
|
||||
// remains set to YES so that the logic to replace the destination controller is still called.
|
||||
if ([_sender respondsToSelector: @selector(shouldPerformSegueWithIdentifier:sender:)])
|
||||
{
|
||||
should = [_sender shouldPerformSegueWithIdentifier: _identifier
|
||||
sender: _sender];
|
||||
}
|
||||
|
||||
if (should)
|
||||
{
|
||||
id destCon = [_storyboardSegue destinationController];
|
||||
if ([destCon isKindOfClass: [NSString class]])
|
||||
{
|
||||
// resolve the destination controller
|
||||
destCon = [_storyboard instantiateControllerWithIdentifier: destCon];
|
||||
[_storyboardSegue _setDestinationController: destCon]; // replace with actual controller...
|
||||
}
|
||||
[_storyboardSegue _setSourceController: _sender];
|
||||
|
||||
if (_sender != nil &&
|
||||
[_sender respondsToSelector: @selector(performSegueWithIdentifier:sender:)])
|
||||
{
|
||||
[_sender performSegueWithIdentifier: _identifier
|
||||
sender: _sender];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_storyboardSegue perform];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)z
|
||||
{
|
||||
NSStoryboardSeguePerformAction *pa = [[NSStoryboardSeguePerformAction allocWithZone: z] init];
|
||||
[pa setTarget: _target];
|
||||
[pa setSelector: [self selector]];
|
||||
[pa setSender: _sender];
|
||||
[pa setIdentifier: _identifier];
|
||||
[pa setPopoverAnchorView: _popoverAnchorView];
|
||||
[pa setStoryboardSegue: _storyboardSegue];
|
||||
[pa setStoryboard: _storyboard];
|
||||
return pa;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super init];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSTarget"])
|
||||
{
|
||||
[self setTarget: [coder decodeObjectForKey: @"NSTarget"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSelector"])
|
||||
{
|
||||
[self setSelector: [coder decodeObjectForKey: @"NSSelector"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSender"])
|
||||
{
|
||||
[self setSender: [coder decodeObjectForKey: @"NSSender"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSIdentifier"])
|
||||
{
|
||||
[self setIdentifier: [coder decodeObjectForKey: @"NSIdentifier"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSKind"])
|
||||
{
|
||||
[self setKind: [coder decodeObjectForKey: @"NSKind"]];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSPopoverAnchorView"])
|
||||
{
|
||||
[self setPopoverAnchorView: [coder decodeObjectForKey: @"NSPopoverAnchorView"]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
// this is never encoded directly...
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSControllerPlaceholder
|
||||
|
||||
- (NSString *) storyboardName
|
||||
{
|
||||
return _storyboardName;
|
||||
}
|
||||
|
||||
- (void) setStoryboardName: (NSString *)name
|
||||
{
|
||||
ASSIGNCOPY(_storyboardName, name);
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)z
|
||||
{
|
||||
NSControllerPlaceholder *c = [[NSControllerPlaceholder allocWithZone: z] init];
|
||||
[c setStoryboardName: _storyboardName];
|
||||
return c;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super init];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSStoryboardName"])
|
||||
{
|
||||
[self setStoryboardName: [coder decodeObjectForKey: @"NSStoryboardName"]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
// this is never encoded directly...
|
||||
}
|
||||
|
||||
- (id) instantiate
|
||||
{
|
||||
NSStoryboard *sb = [NSStoryboard storyboardWithName: _storyboardName
|
||||
bundle: [NSBundle mainBundle]];
|
||||
return [sb instantiateInitialController];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GSStoryboardTransform
|
||||
|
||||
- (instancetype) initWithData: (NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData: data
|
||||
options: 0
|
||||
error: NULL];
|
||||
|
||||
_scenesMap = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||
_controllerMap = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||
_identifierToSegueMap = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||
|
||||
[self processStoryboard: xml];
|
||||
RELEASE(xml);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_initialViewControllerId);
|
||||
RELEASE(_applicationSceneId);
|
||||
RELEASE(_scenesMap);
|
||||
RELEASE(_controllerMap);
|
||||
RELEASE(_identifierToSegueMap);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) initialViewControllerId
|
||||
{
|
||||
return _initialViewControllerId;
|
||||
}
|
||||
|
||||
- (NSString *) applicationSceneId
|
||||
{
|
||||
return _applicationSceneId;
|
||||
}
|
||||
|
||||
- (NSMapTable *) segueMapForIdentifier: (NSString *)identifier
|
||||
{
|
||||
return [_identifierToSegueMap objectForKey: identifier];
|
||||
}
|
||||
|
||||
- (NSXMLElement *) createCustomObjectWithId: (NSString *)ident
|
||||
userLabel: (NSString *)userLabel
|
||||
customClass: (NSString *)className
|
||||
{
|
||||
NSXMLElement *customObject =
|
||||
[[NSXMLElement alloc] initWithName: @"customObject"];
|
||||
NSXMLNode *idValue =
|
||||
[NSXMLNode attributeWithName: @"id"
|
||||
stringValue: ident];
|
||||
NSXMLNode *usrLabel =
|
||||
[NSXMLNode attributeWithName: @"userLabel"
|
||||
stringValue: userLabel];
|
||||
NSXMLNode *customCls =
|
||||
[NSXMLNode attributeWithName: @"customClass"
|
||||
stringValue: className];
|
||||
|
||||
[customObject addAttribute: idValue];
|
||||
[customObject addAttribute: usrLabel];
|
||||
[customObject addAttribute: customCls];
|
||||
|
||||
AUTORELEASE(customObject);
|
||||
|
||||
return customObject;
|
||||
}
|
||||
|
||||
- (NSData *) dataForIdentifier: (NSString *)identifier
|
||||
{
|
||||
NSString *sceneId = [_controllerMap objectForKey: identifier];
|
||||
NSXMLDocument *xml = [_scenesMap objectForKey: sceneId];
|
||||
return [xml XMLData];
|
||||
}
|
||||
|
||||
- (void) addStandardObjects: (NSXMLElement *)objects
|
||||
classString: (NSString *) customClassString
|
||||
connections: (NSXMLNode *)appCons
|
||||
firstResponderId: (NSString *)firstResponderId
|
||||
{
|
||||
NSXMLElement *customObject = nil;
|
||||
|
||||
customObject =
|
||||
[self createCustomObjectWithId: @"-3"
|
||||
userLabel: @"Application"
|
||||
customClass: @"NSObject"];
|
||||
[objects insertChild: customObject
|
||||
atIndex: 0];
|
||||
customObject =
|
||||
[self createCustomObjectWithId: firstResponderId
|
||||
userLabel: @"First Responder"
|
||||
customClass: @"FirstResponder"];
|
||||
[objects insertChild: customObject
|
||||
atIndex: 0];
|
||||
customObject =
|
||||
[self createCustomObjectWithId: @"-2"
|
||||
userLabel: @"File's Owner"
|
||||
customClass: customClassString];
|
||||
if (appCons != nil)
|
||||
{
|
||||
[customObject addChild: appCons];
|
||||
}
|
||||
[objects insertChild: customObject
|
||||
atIndex: 0];
|
||||
}
|
||||
|
||||
- (void) processChild: (NSXMLElement *)objects
|
||||
withDoc: (NSXMLElement *)doc
|
||||
withAppNode: (NSXMLNode *)appNode
|
||||
sceneId: (NSString *)sceneId
|
||||
firstResponderId: (NSString *)firstResponderId
|
||||
{
|
||||
NSString *customClassString = nil;
|
||||
NSXMLNode *appCons = nil;
|
||||
|
||||
if (appNode != nil)
|
||||
{
|
||||
NSArray *appConsArr = [appNode nodesForXPath: @"connections" error: NULL];
|
||||
|
||||
appCons = [appConsArr objectAtIndex: 0];
|
||||
if (appCons != nil)
|
||||
{
|
||||
[appCons detach];
|
||||
}
|
||||
|
||||
// Assign application scene...
|
||||
ASSIGN(_applicationSceneId, sceneId);
|
||||
[_controllerMap setObject: _applicationSceneId
|
||||
forKey: APPLICATION];
|
||||
|
||||
// Move all application children to objects...
|
||||
NSArray *appChildren = [appNode children];
|
||||
FOR_IN(NSXMLElement*, ae, appChildren)
|
||||
[ae detach];
|
||||
[objects addChild: ae];
|
||||
END_FOR_IN(appChildren);
|
||||
|
||||
// Remove the appNode
|
||||
[appNode detach];
|
||||
|
||||
// create a customObject entry for NSApplication reference...
|
||||
NSXMLNode *appCustomClass = [(NSXMLElement *)appNode
|
||||
attributeForName: @"customClass"];
|
||||
customClassString = ([appCustomClass stringValue] == nil) ?
|
||||
@"NSApplication" : [appCustomClass stringValue];
|
||||
}
|
||||
|
||||
[self addStandardObjects: objects
|
||||
classString: customClassString
|
||||
connections: appCons
|
||||
firstResponderId: firstResponderId];
|
||||
|
||||
// Add it to the document
|
||||
[objects detach];
|
||||
[doc addChild: objects];
|
||||
}
|
||||
|
||||
- (NSArray *) subclassesOfClass: (Class)clz
|
||||
{
|
||||
NSMutableArray *subclasses = [GSObjCAllSubclassesOfClass(clz) mutableCopy];
|
||||
NSMutableArray *result = [NSMutableArray arrayWithCapacity: [subclasses count]];
|
||||
|
||||
[subclasses insertObject: clz atIndex: 0];
|
||||
FOR_IN(Class, cls, subclasses)
|
||||
{
|
||||
NSString *className = NSStringFromClass(cls);
|
||||
NSString *classNameNoNamespace = [className substringFromIndex: 2];
|
||||
NSString *xmlClassName = [NSString stringWithFormat: @"%@%@",
|
||||
[[classNameNoNamespace substringToIndex: 1] lowercaseString],
|
||||
[classNameNoNamespace substringFromIndex: 1]];
|
||||
NSString *lowerCaseName = [xmlClassName lowercaseString];
|
||||
|
||||
[result addObject: xmlClassName];
|
||||
[result addObject: lowerCaseName];
|
||||
}
|
||||
END_FOR_IN(subclasses);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSArray *) findSubclassesOf: (Class)clz
|
||||
inDocument: (NSXMLDocument *)document
|
||||
{
|
||||
NSArray *result = nil;
|
||||
NSArray *xmlClassNames = [self subclassesOfClass: clz];
|
||||
|
||||
FOR_IN(NSString*, xmlClassName, xmlClassNames)
|
||||
{
|
||||
NSString *xpath = [NSString stringWithFormat: @"//%@",xmlClassName];
|
||||
result = [document nodesForXPath: xpath error: NULL];
|
||||
if ([result count] > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
END_FOR_IN(xmlClassNames);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *) controllerIdWithDocument: (NSXMLDocument *)document
|
||||
{
|
||||
NSString *controllerId = nil;
|
||||
NSArray *windowControllers = [self findSubclassesOf: [NSWindowController class]
|
||||
inDocument: document];
|
||||
NSArray *viewControllers = [self findSubclassesOf: [NSViewController class]
|
||||
inDocument: document];
|
||||
NSArray *controllerPlaceholders = [document nodesForXPath: @"//controllerPlaceholder"
|
||||
error: NULL];
|
||||
|
||||
if ([windowControllers count] > 0)
|
||||
{
|
||||
NSXMLElement *ce = [windowControllers objectAtIndex: 0];
|
||||
NSXMLNode *attr = [ce attributeForName: @"id"];
|
||||
controllerId = [attr stringValue];
|
||||
|
||||
FOR_IN(NSXMLElement*, o, windowControllers)
|
||||
{
|
||||
NSXMLElement *objects = (NSXMLElement *)[o parent];
|
||||
NSArray *windows = [o nodesForXPath: @"//window" error: NULL];
|
||||
FOR_IN(NSXMLNode*, w, windows)
|
||||
{
|
||||
[w detach];
|
||||
[objects addChild: w];
|
||||
}
|
||||
END_FOR_IN(windows);
|
||||
}
|
||||
END_FOR_IN(windowControllers);
|
||||
}
|
||||
|
||||
if ([viewControllers count] > 0)
|
||||
{
|
||||
NSXMLElement *ce = [viewControllers objectAtIndex: 0];
|
||||
NSXMLNode *attr = [ce attributeForName: @"id"];
|
||||
controllerId = [attr stringValue];
|
||||
}
|
||||
|
||||
if ([controllerPlaceholders count] > 0)
|
||||
{
|
||||
NSXMLElement *ce = [controllerPlaceholders objectAtIndex: 0];
|
||||
NSXMLNode *attr = [ce attributeForName: @"id"];
|
||||
controllerId = [attr stringValue];
|
||||
}
|
||||
|
||||
return controllerId;
|
||||
}
|
||||
|
||||
- (void) processStoryboard: (NSXMLDocument *)xml
|
||||
{
|
||||
NSArray *docNodes = [xml nodesForXPath: @"document" error: NULL];
|
||||
|
||||
if ([docNodes count] > 0)
|
||||
{
|
||||
NSXMLElement *docNode = [docNodes objectAtIndex: 0];
|
||||
NSArray *array = [docNode nodesForXPath: @"//scene" error: NULL];
|
||||
NSArray *firstResponderIdNodes = [docNode nodesForXPath: @"//objects/customObject[@sceneMemberID =\"firstResponder\"]/@id"
|
||||
error: NULL];
|
||||
NSString *firstResponderId = @"-1";
|
||||
|
||||
if([firstResponderIdNodes count] > 0)
|
||||
{
|
||||
firstResponderId = [[firstResponderIdNodes objectAtIndex: 0] stringValue];
|
||||
}
|
||||
|
||||
// Set initial view controller...
|
||||
ASSIGN(_initialViewControllerId, [[docNode attributeForName: @"initialViewController"] stringValue]);
|
||||
FOR_IN(NSXMLElement*, e, array)
|
||||
{
|
||||
NSXMLElement *doc = [[NSXMLElement alloc] initWithName: @"document"];
|
||||
NSArray *children = [e children];
|
||||
NSXMLDocument *document = nil;
|
||||
NSString *sceneId = [[e attributeForName: @"sceneID"] stringValue];
|
||||
NSString *controllerId = nil;
|
||||
// Move children...
|
||||
FOR_IN(NSXMLElement*, child, children)
|
||||
{
|
||||
if ([[child name] isEqualToString: @"point"] == YES)
|
||||
continue; // go on if it's a point element, we don't use that in the app...
|
||||
|
||||
NSArray *subnodes = [child nodesForXPath: @"//application" error: NULL];
|
||||
NSXMLNode *appNode = [subnodes objectAtIndex: 0];
|
||||
[self processChild: child
|
||||
withDoc: doc
|
||||
withAppNode: appNode
|
||||
sceneId: sceneId
|
||||
firstResponderId: firstResponderId];
|
||||
|
||||
// fix other custom objects
|
||||
document = [[NSXMLDocument alloc] initWithRootElement: doc];
|
||||
controllerId = [self controllerIdWithDocument: document];
|
||||
controllerId = (controllerId != nil) ? controllerId : APPLICATION;
|
||||
RELEASE(doc);
|
||||
|
||||
// Create document...
|
||||
[_scenesMap setObject: document
|
||||
forKey: sceneId];
|
||||
|
||||
// Map controllerId's to scenes...
|
||||
if (controllerId != nil)
|
||||
{
|
||||
[_controllerMap setObject: sceneId
|
||||
forKey: controllerId];
|
||||
|
||||
[self processSegues: document
|
||||
forControllerId: controllerId];
|
||||
}
|
||||
RELEASE(document);
|
||||
}
|
||||
END_FOR_IN(children);
|
||||
}
|
||||
END_FOR_IN(array);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"No document element found in storyboard file"];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isProcessedDocument: (NSXMLDocument *)xmlIn
|
||||
{
|
||||
NSArray *docArray = [xmlIn nodesForXPath: @"document" error: NULL];
|
||||
if ([docArray count] > 0)
|
||||
{
|
||||
NSXMLElement *docElem = (NSXMLElement *)[docArray objectAtIndex: 0];
|
||||
NSXMLNode *a = [docElem attributeForName: @"processed"];
|
||||
NSString *value = [a stringValue];
|
||||
if (value != nil)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSXMLNode *new_attr = [NSXMLNode attributeWithName: @"processed"
|
||||
stringValue: @"true"];
|
||||
[docElem addAttribute: new_attr];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSXMLElement *) createStoryboardProxyElementWithSelector: (NSString *)selector
|
||||
target: (NSString *)dst
|
||||
segueIdentifier: (NSString *)ident
|
||||
sender: (NSString *)src
|
||||
kind: (NSString *)kind
|
||||
anchorView: (NSString *)anchorView
|
||||
{
|
||||
NSXMLElement *sbproxy = [NSXMLElement elementWithName: @"storyboardSeguePerformAction"];
|
||||
|
||||
NSXMLNode *pselector
|
||||
= [NSXMLNode attributeWithName: @"selector"
|
||||
stringValue: selector];
|
||||
NSXMLNode *ptarget
|
||||
= [NSXMLNode attributeWithName: @"target"
|
||||
stringValue: dst];
|
||||
NSString *pident_value = [[NSUUID UUID] UUIDString];
|
||||
NSXMLNode *pident
|
||||
= [NSXMLNode attributeWithName: @"id"
|
||||
stringValue: pident_value];
|
||||
NSXMLNode *psegueIdent
|
||||
= [NSXMLNode attributeWithName: @"identifier"
|
||||
stringValue: ident];
|
||||
NSXMLNode *psender
|
||||
= [NSXMLNode attributeWithName: @"sender"
|
||||
stringValue: src];
|
||||
NSXMLNode *pkind
|
||||
= [NSXMLNode attributeWithName: @"kind"
|
||||
stringValue: kind];
|
||||
NSXMLNode *panchorview
|
||||
= [NSXMLNode attributeWithName: @"popoverAnchorView"
|
||||
stringValue: anchorView];
|
||||
|
||||
[sbproxy addAttribute: pselector];
|
||||
[sbproxy addAttribute: ptarget];
|
||||
[sbproxy addAttribute: pident];
|
||||
[sbproxy addAttribute: psegueIdent];
|
||||
[sbproxy addAttribute: psender];
|
||||
[sbproxy addAttribute: pkind];
|
||||
[sbproxy addAttribute: panchorview];
|
||||
|
||||
return sbproxy;
|
||||
}
|
||||
|
||||
- (NSMapTable *) processConnections: (NSArray *)connectionsArray
|
||||
withObjects: (NSXMLElement *)objects
|
||||
controllerId: (NSString *)src
|
||||
{
|
||||
NSMapTable *mapTable = [NSMapTable strongToWeakObjectsMapTable];
|
||||
|
||||
FOR_IN (NSXMLElement*, connections, connectionsArray)
|
||||
{
|
||||
NSArray *children = [connections children]; // there should be only one per set.
|
||||
|
||||
FOR_IN (NSXMLElement*, obj, children)
|
||||
if ([[obj name] isEqualToString: @"segue"])
|
||||
{
|
||||
// get the information from the segue.
|
||||
id connections_parent = [[obj parent] parent];
|
||||
id segue_parent = connections; // [obj parent];
|
||||
NSString *connections_parent_name = [connections_parent name];
|
||||
NSXMLNode *attr = [obj attributeForName: @"destination"];
|
||||
NSString *dst = [attr stringValue];
|
||||
attr = [obj attributeForName: @"kind"];
|
||||
NSString *kind = [attr stringValue];
|
||||
attr = [obj attributeForName: @"relationship"];
|
||||
NSString *rel = [attr stringValue];
|
||||
attr = [obj attributeForName: @"id"];
|
||||
NSString *uid = [attr stringValue];
|
||||
attr = [obj attributeForName: @"identifier"];
|
||||
NSString *ident = [attr stringValue];
|
||||
if (ident == nil)
|
||||
{
|
||||
ident = [[NSUUID UUID] UUIDString];
|
||||
}
|
||||
attr = [obj attributeForName: @"popoverAnchorView"];
|
||||
NSString *av = [attr stringValue];
|
||||
attr = [obj attributeForName: @"popoverBehavior"];
|
||||
NSString *pb = [attr stringValue];
|
||||
NSPopoverBehavior behavior = NSPopoverBehaviorApplicationDefined;
|
||||
if ([pb isEqualToString: @"a"])
|
||||
{
|
||||
behavior = NSPopoverBehaviorApplicationDefined;
|
||||
}
|
||||
else if ([pb isEqualToString: @"t"])
|
||||
{
|
||||
behavior = NSPopoverBehaviorTransient;
|
||||
}
|
||||
else if ([pb isEqualToString: @"s"])
|
||||
{
|
||||
behavior = NSPopoverBehaviorSemitransient;
|
||||
}
|
||||
|
||||
attr = [obj attributeForName: @"preferredEdge"];
|
||||
NSString *pe = [attr stringValue];
|
||||
NSRectEdge edge = NSMinXEdge;
|
||||
if ([pe isEqualToString: @"maxY"])
|
||||
{
|
||||
edge = NSMaxYEdge;
|
||||
}
|
||||
else if ([pe isEqualToString: @"minY"])
|
||||
{
|
||||
edge = NSMinYEdge;
|
||||
}
|
||||
else if ([pe isEqualToString: @"maxX"])
|
||||
{
|
||||
edge = NSMaxXEdge;
|
||||
}
|
||||
else if ([pe isEqualToString: @"minX"])
|
||||
{
|
||||
edge = NSMinXEdge;
|
||||
}
|
||||
[obj detach]; // segue can't be in the archive since it doesn't conform to NSCoding
|
||||
|
||||
// Create proxy object to invoke methods on the window controller
|
||||
NSXMLElement *sbproxy = [self createStoryboardProxyElementWithSelector: @"doAction:"
|
||||
target: dst
|
||||
segueIdentifier: ident
|
||||
sender: src
|
||||
kind: kind
|
||||
anchorView: av];
|
||||
|
||||
NSUInteger count = [[objects children] count];
|
||||
[objects insertChild: sbproxy
|
||||
atIndex: count - 1];
|
||||
|
||||
// add action to parent ONLY if it is NOT a controller..
|
||||
if (![[self subclassesOfClass: [NSWindowController class]] containsObject: connections_parent_name] &&
|
||||
![[self subclassesOfClass: [NSViewController class]] containsObject: connections_parent_name])
|
||||
{
|
||||
// Create action...
|
||||
NSXMLElement *action = [NSXMLElement elementWithName: @"action"];
|
||||
NSXMLNode *selector
|
||||
= [NSXMLNode attributeWithName: @"selector"
|
||||
stringValue: @"doAction:"];
|
||||
NSXMLNode *target
|
||||
= [NSXMLNode attributeWithName: @"target"
|
||||
stringValue: [[sbproxy attributeForName: @"id"] stringValue]];
|
||||
NSXMLNode *controller_ident
|
||||
= [NSXMLNode attributeWithName: @"id"
|
||||
stringValue: uid];
|
||||
[action addAttribute: selector];
|
||||
[action addAttribute: target];
|
||||
[action addAttribute: controller_ident];
|
||||
[segue_parent addChild: action];
|
||||
}
|
||||
|
||||
// Create the segue...
|
||||
NSStoryboardSegue *ss = [[NSStoryboardSegue alloc] initWithIdentifier: ident
|
||||
source: src
|
||||
destination: dst];
|
||||
[ss _setKind: kind];
|
||||
[ss _setRelationship: rel];
|
||||
[ss _setPopoverBehavior: behavior];
|
||||
[ss _setPreferredEdge: edge];
|
||||
|
||||
// Add to maptable...
|
||||
[mapTable setObject: ss
|
||||
forKey: ident];
|
||||
|
||||
} // only process segue objects...
|
||||
END_FOR_IN(children);
|
||||
} // iterate over connection objs
|
||||
END_FOR_IN(connectionsArray);
|
||||
|
||||
return mapTable;
|
||||
}
|
||||
|
||||
- (void) processSegues: (NSXMLDocument *)xml
|
||||
forControllerId: (NSString *)identifier
|
||||
{
|
||||
BOOL processed = [self isProcessedDocument: xml];
|
||||
if (!processed)
|
||||
{
|
||||
NSArray *array = [xml nodesForXPath: @"//objects[1]"
|
||||
error: NULL];
|
||||
NSXMLElement *objects = [array objectAtIndex: 0]; // get the "objects" section
|
||||
NSArray *connectionsArray = [xml nodesForXPath: @"//connections"
|
||||
error: NULL];
|
||||
NSMapTable *mapTable = [self processConnections: connectionsArray
|
||||
withObjects: objects
|
||||
controllerId: identifier];
|
||||
[_identifierToSegueMap setObject: mapTable
|
||||
forKey: identifier];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -2459,7 +2459,7 @@ typedef enum {
|
|||
[self drawTabViewBezelRect: aRect
|
||||
tabViewType: type
|
||||
inView: view];
|
||||
|
||||
|
||||
if (type == NSBottomTabsBezelBorder
|
||||
|| type == NSTopTabsBezelBorder)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#import "AppKit/NSToolbarItem.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "GSCodingFlags.h"
|
||||
|
||||
#define DEBUG_XIB5 0
|
||||
|
@ -212,6 +213,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"IBUserDefinedRuntimeAttribute5", @"userDefinedRuntimeAttribute",
|
||||
@"NSURL", @"url",
|
||||
@"NSLayoutConstraint", @"constraint",
|
||||
@"NSPageController", @"pagecontroller", // why is pagecontroller capitalized this way?
|
||||
nil];
|
||||
RETAIN(XmlTagToObjectClassMap);
|
||||
|
||||
|
@ -283,6 +285,8 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"bordered", @"NSIsBordered",
|
||||
@"altersStateOfSelectedItem", @"NSAltersState",
|
||||
@"string", @"NS.relative",
|
||||
@"canPropagateSelectedChildViewControllerTitle",
|
||||
@"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle",
|
||||
nil];
|
||||
RETAIN(XmlKeyMapTable);
|
||||
|
||||
|
@ -395,6 +399,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"decodeFirstAttribute:", @"NSFirstAttribute",
|
||||
@"decodeSecondAttribute:", @"NSSecondAttribute",
|
||||
@"decodeRelation:", @"NSRelation",
|
||||
@"decodeTransitionStyle:", @"NSTransitionStyle",
|
||||
nil];
|
||||
RETAIN(XmlKeyToDecoderSelectorMap);
|
||||
|
||||
|
@ -405,6 +410,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"prefersToBeShown",
|
||||
@"editable",
|
||||
@"enabled",
|
||||
@"canPropagateSelectedChildViewControllerTitle",
|
||||
nil];
|
||||
}
|
||||
}
|
||||
|
@ -2886,6 +2892,31 @@ didStartElement: (NSString*)elementName
|
|||
return num;
|
||||
}
|
||||
|
||||
- (id) decodeTransitionStyle: (GSXibElement *)element
|
||||
{
|
||||
NSNumber *num = [NSNumber numberWithInteger: 0];
|
||||
id obj = [element attributeForKey: @"transitionStyle"];
|
||||
|
||||
if ([obj isEqualToString: @"stackHistory"])
|
||||
{
|
||||
num = [NSNumber numberWithInteger: NSPageControllerTransitionStyleStackHistory];
|
||||
}
|
||||
else if ([obj isEqualToString: @"stackBook"])
|
||||
{
|
||||
num = [NSNumber numberWithInteger: NSPageControllerTransitionStyleStackBook];
|
||||
}
|
||||
else if ([obj isEqualToString: @"horizontalStrip"])
|
||||
{
|
||||
num = [NSNumber numberWithInteger: NSPageControllerTransitionStyleHorizontalStrip];
|
||||
}
|
||||
else // if not specified then assume standard...
|
||||
{
|
||||
num = [NSNumber numberWithInteger: NSPageControllerTransitionStyleStackHistory];
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
- (id) objectForXib: (GSXibElement*)element
|
||||
{
|
||||
id object = [super objectForXib: element];
|
||||
|
|
|
@ -2005,6 +2005,10 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
icon: _icon
|
||||
title: _message_text != nil ? _message_text : _(@"Alert")
|
||||
message: _informative_text != nil ? _informative_text : _(@"No information")];
|
||||
if ([_buttons count] == 0)
|
||||
{
|
||||
[self addButtonWithTitle: @"OK"];
|
||||
}
|
||||
[panel setButtons: _buttons];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,21 +44,23 @@ static NSNotificationCenter *nc = nil;
|
|||
{
|
||||
[self setVersion: 1];
|
||||
activeConstraints = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
// nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(_setupNotifications:)
|
||||
name: NSApplicationDidFinishLaunchingNotification
|
||||
object: nil];
|
||||
// [nc addObserver: self
|
||||
// selector: @selector(_setupNotifications:)
|
||||
// name: NSApplicationDidFinishLaunchingNotification
|
||||
// object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) _setupNotifications: (NSNotification *)n
|
||||
{
|
||||
/*
|
||||
[nc addObserver: self
|
||||
selector: @selector(_handleWindowResize:)
|
||||
name: NSWindowDidResizeNotification
|
||||
object: nil];
|
||||
*/
|
||||
}
|
||||
|
||||
+ (NSString *) _attributeToString: (NSLayoutAttribute)attr
|
||||
|
@ -220,8 +222,8 @@ static NSNotificationCenter *nc = nil;
|
|||
|
||||
+ (void) _activateConstraint: (NSLayoutConstraint *)constraint
|
||||
{
|
||||
[activeConstraints addObject: constraint];
|
||||
activeConstraints = [[activeConstraints sortedArrayUsingSelector: @selector(compare:)] mutableCopy];
|
||||
// [activeConstraints addObject: constraint];
|
||||
// activeConstraints = [[activeConstraints sortedArrayUsingSelector: @selector(compare:)] mutableCopy];
|
||||
}
|
||||
|
||||
+ (void) _removeConstraint: (NSLayoutConstraint *)constraint
|
||||
|
@ -584,6 +586,7 @@ static NSNotificationCenter *nc = nil;
|
|||
|
||||
+ (void) _handleWindowResize: (NSNotification *)notification
|
||||
{
|
||||
/*
|
||||
NSLayoutConstraint *c = nil;
|
||||
NSEnumerator *en = [activeConstraints objectEnumerator];
|
||||
|
||||
|
@ -596,6 +599,7 @@ static NSNotificationCenter *nc = nil;
|
|||
[c _applyConstraint];
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
199
Source/NSPageController.m
Normal file
199
Source/NSPageController.m
Normal file
|
@ -0,0 +1,199 @@
|
|||
/* Implementation of class NSPageController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 27-07-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
|
||||
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/NSArray.h>
|
||||
#import <Foundation/NSKeyValueObserving.h>
|
||||
#import <Foundation/NSArchiver.h>
|
||||
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "AppKit/NSView.h"
|
||||
|
||||
@implementation NSPageController
|
||||
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_transitionStyle = NSPageControllerTransitionStyleStackHistory;
|
||||
_delegate = nil;
|
||||
_arrangedObjects = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
_selectedIndex = 0;
|
||||
_selectedViewController = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_arrangedObjects);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self != nil)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSTransitionStyle"])
|
||||
{
|
||||
_transitionStyle = [coder decodeIntForKey: @"NSTransitionStyle"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder decodeValueOfObjCType: @encode(NSInteger)
|
||||
at: &_transitionStyle];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
[coder encodeInt: _transitionStyle
|
||||
forKey: @"NSTransitionStyle"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeValueOfObjCType: @encode(NSInteger)
|
||||
at: &_transitionStyle];
|
||||
}
|
||||
}
|
||||
|
||||
// Set/Get properties
|
||||
- (NSPageControllerTransitionStyle) transitionStyle
|
||||
{
|
||||
return _transitionStyle;
|
||||
}
|
||||
|
||||
- (void) setTransitionStyle: (NSPageControllerTransitionStyle)style
|
||||
{
|
||||
_transitionStyle = style;
|
||||
}
|
||||
|
||||
- (id<NSPageControllerDelegate>) delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id<NSPageControllerDelegate>)delegate
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (NSArray *) arrangedObjects
|
||||
{
|
||||
return _arrangedObjects;
|
||||
}
|
||||
|
||||
- (void) setArrangedObjects: (NSArray *)array
|
||||
{
|
||||
[_arrangedObjects removeAllObjects];
|
||||
[_arrangedObjects addObjectsFromArray: array];
|
||||
}
|
||||
|
||||
- (NSInteger) selectedIndex
|
||||
{
|
||||
return _selectedIndex;
|
||||
}
|
||||
|
||||
- (void) setSelectedIndex: (NSInteger)index
|
||||
{
|
||||
if ([_delegate respondsToSelector: @selector(pageControllerWillStartLiveTransition:)])
|
||||
{
|
||||
[_delegate pageControllerWillStartLiveTransition: self];
|
||||
}
|
||||
[self willChangeValueForKey: @"selectedIndex"];
|
||||
_selectedIndex = index;
|
||||
_selectedViewController = [_arrangedObjects objectAtIndex: _selectedIndex];
|
||||
[self didChangeValueForKey: @"selectedIndex"];
|
||||
|
||||
// Complete...
|
||||
[self completeTransition];
|
||||
|
||||
// End transition...
|
||||
if ([_delegate respondsToSelector: @selector(pageControllerDidEndLiveTransition:)])
|
||||
{
|
||||
[_delegate pageControllerDidEndLiveTransition: self];
|
||||
}
|
||||
|
||||
// Notify delegate that transition is finished.
|
||||
if ([_delegate respondsToSelector: @selector(pageController:didTransitionToObject:)])
|
||||
{
|
||||
[_delegate pageController: self didTransitionToObject: _selectedViewController];
|
||||
}
|
||||
|
||||
// Resize based on frame...
|
||||
if ([_delegate respondsToSelector: @selector(pageController:frameForObject:)])
|
||||
{
|
||||
NSRect rect = [_delegate pageController: self frameForObject: _selectedViewController];
|
||||
[[_selectedViewController view] setFrame: rect];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSViewController *) selectedViewController
|
||||
{
|
||||
return _selectedViewController;
|
||||
}
|
||||
|
||||
// Handle page transitions
|
||||
- (void) navigateForwardToObject: (id)object
|
||||
{
|
||||
NSInteger index = [_arrangedObjects indexOfObject: object];
|
||||
[self setSelectedIndex: index];
|
||||
}
|
||||
|
||||
- (void) completeTransition
|
||||
{
|
||||
[self setView: [_selectedViewController view]];
|
||||
}
|
||||
|
||||
- (IBAction) navigateBack: (id)sender
|
||||
{
|
||||
NSInteger idx = [self selectedIndex] - 1;
|
||||
[self setSelectedIndex: (idx >= 0) ? idx : 0];
|
||||
}
|
||||
|
||||
- (IBAction) navigateForward: (id)sender
|
||||
{
|
||||
NSInteger idx = [self selectedIndex] + 1;
|
||||
NSInteger lastPage = ([_arrangedObjects count] - 1);
|
||||
[self setSelectedIndex: (idx > lastPage) ? lastPage : idx];
|
||||
}
|
||||
|
||||
- (IBAction) takeSelectedIndexFrom: (id)sender // uses integerValue from sender
|
||||
{
|
||||
if ([sender respondsToSelector: @selector(integerValue)])
|
||||
{
|
||||
NSInteger i = [sender integerValue];
|
||||
[self setSelectedIndex: i];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
208
Source/NSSplitViewController.m
Normal file
208
Source/NSSplitViewController.m
Normal file
|
@ -0,0 +1,208 @@
|
|||
/* Implementation of class NSSplitViewController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Mon 20 Jul 2020 12:55:02 AM EDT
|
||||
|
||||
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
|
||||
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/NSArray.h>
|
||||
#import <Foundation/NSArchiver.h>
|
||||
|
||||
#import "AppKit/NSSplitView.h"
|
||||
#import "AppKit/NSSplitViewController.h"
|
||||
#import "AppKit/NSSplitViewItem.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "NSViewPrivate.h"
|
||||
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
@implementation NSSplitViewController
|
||||
// return splitview...
|
||||
- (NSSplitView *) splitView
|
||||
{
|
||||
return (NSSplitView *)[self view];
|
||||
}
|
||||
|
||||
- (void) setSplitView: (NSSplitView *)splitView
|
||||
{
|
||||
[self setView: splitView];
|
||||
[splitView setDelegate: self];
|
||||
}
|
||||
|
||||
- (NSSplitViewItem *) splitViewItemForViewController: (NSViewController *)vc
|
||||
{
|
||||
FOR_IN (NSSplitViewItem*, svi, _splitViewItems)
|
||||
if ([svi viewController] == vc)
|
||||
{
|
||||
return svi;
|
||||
}
|
||||
END_FOR_IN (_splitViewItems);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGFloat) minimumThicknessForInlineSidebars
|
||||
{
|
||||
return _minimumThicknessForInlineSidebars;
|
||||
}
|
||||
|
||||
- (void) setMinimumThicknessForInlineSidebars: (CGFloat)value
|
||||
{
|
||||
_minimumThicknessForInlineSidebars = value;
|
||||
}
|
||||
|
||||
// manage splitview items...
|
||||
- (NSArray *) splitViewItems
|
||||
{
|
||||
return _splitViewItems;
|
||||
}
|
||||
|
||||
- (void) setSplitViewItems: (NSArray *)items
|
||||
{
|
||||
NSMutableArray *mutableItems = [items mutableCopy];
|
||||
ASSIGN(_splitViewItems, mutableItems);
|
||||
}
|
||||
|
||||
- (void) addSplitViewItem: (NSSplitViewItem *)item
|
||||
{
|
||||
[self insertSplitViewItem: item atIndex: [_splitViewItems count]];
|
||||
}
|
||||
|
||||
- (void) insertSplitViewItem: (NSSplitViewItem *)item atIndex: (NSInteger)index
|
||||
{
|
||||
NSSplitView *sv = [self splitView];
|
||||
NSViewController *vc = [item viewController];
|
||||
|
||||
if (vc != nil)
|
||||
{
|
||||
NSView *v = [vc view];
|
||||
if (v != nil)
|
||||
{
|
||||
[sv _insertSubview: v atIndex: index];
|
||||
}
|
||||
}
|
||||
[_splitViewItems insertObject: item atIndex: index];
|
||||
}
|
||||
|
||||
- (void) removeSplitViewItem: (NSSplitViewItem *)item
|
||||
{
|
||||
NSViewController *vc = [item viewController];
|
||||
if (vc != nil)
|
||||
{
|
||||
NSView *v = [vc view];
|
||||
if (v != nil)
|
||||
{
|
||||
[[self splitView] removeSubview: v];
|
||||
}
|
||||
}
|
||||
[_splitViewItems removeObject: item];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_splitViewItems);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// instance methods...
|
||||
- (NSRect) splitView: (NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex: (NSInteger)dividerIndex
|
||||
{
|
||||
return [splitView frame];
|
||||
}
|
||||
|
||||
- (BOOL) splitView: (NSSplitView *)splitView canCollapseSubview: (NSView *)subview
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSRect) splitView: (NSSplitView *)splitView effectiveRect: (NSRect)proposedEffectiveRect forDrawnRect: (NSRect)drawnRect
|
||||
ofDividerAtIndex: (NSInteger)dividerIndex
|
||||
{
|
||||
return proposedEffectiveRect;
|
||||
}
|
||||
|
||||
- (BOOL) splitView:(NSSplitView *)splitView shouldCollapseSubview: (NSView *)subview forDoubleClickOnDividerAtIndex: (NSInteger)dividerIndex
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) splitView: (NSSplitView *)splitView shouldHideDividerAtIndex: (NSInteger)dividerIndex
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (IBAction)toggleSidebar:(id)sender
|
||||
{
|
||||
NSLog(@"Toggle");
|
||||
}
|
||||
|
||||
// NSCoding
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSSplitView"])
|
||||
{
|
||||
NSSplitView *sv = [coder decodeObjectForKey: @"NSSplitView"];
|
||||
[self setSplitView: sv];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSplitViewItems"])
|
||||
{
|
||||
NSArray *items = [coder decodeObjectForKey: @"NSSplitViewItems"];
|
||||
[_splitViewItems addObjectsFromArray: items];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMinimumThicknessForInlineSidebars"])
|
||||
{
|
||||
_minimumThicknessForInlineSidebars =
|
||||
[coder decodeFloatForKey: @"NSMinimumThicknessForInlineSidebars"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSSplitView *sv = [coder decodeObject];
|
||||
[self setSplitView: sv];
|
||||
NSArray *items = [coder decodeObject];
|
||||
[self setSplitViewItems: items];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_minimumThicknessForInlineSidebars];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder: coder];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
NSSplitView *sv = [coder decodeObjectForKey: @"NSSplitView"];
|
||||
[self setSplitView: sv];
|
||||
NSArray *items = [coder decodeObjectForKey: @"NSSplitViewItems"];
|
||||
[_splitViewItems addObjectsFromArray: items];
|
||||
_minimumThicknessForInlineSidebars =
|
||||
[coder decodeFloatForKey: @"NSMinimumThicknessForInlineSidebars"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeObject: [self splitView]];
|
||||
[coder encodeObject: [self splitViewItems]];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_minimumThicknessForInlineSidebars];
|
||||
}
|
||||
}
|
||||
@end
|
177
Source/NSSplitViewItem.m
Normal file
177
Source/NSSplitViewItem.m
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* Implementation of class NSSplitViewItem
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: Mon 20 Jul 2020 12:56:20 AM EDT
|
||||
|
||||
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
|
||||
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/NSArchiver.h>
|
||||
#import "AppKit/NSSplitViewItem.h"
|
||||
|
||||
@implementation NSSplitViewItem
|
||||
- (instancetype) initWithViewController: (NSViewController *)viewController
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
ASSIGN(_viewController, viewController);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype) contentListWithViewController: (NSViewController *)viewController
|
||||
{
|
||||
return AUTORELEASE([[NSSplitViewItem alloc] initWithViewController: viewController]);
|
||||
}
|
||||
|
||||
+ (instancetype) sidebarWithViewController: (NSViewController *)viewController
|
||||
{
|
||||
return AUTORELEASE([[NSSplitViewItem alloc] initWithViewController: viewController]);
|
||||
}
|
||||
|
||||
+ (instancetype) splitViewItemWithViewController: (NSViewController *)viewController
|
||||
{
|
||||
return AUTORELEASE([[NSSplitViewItem alloc] initWithViewController: viewController]);
|
||||
}
|
||||
|
||||
- (CGFloat) automaticMaximumThickness
|
||||
{
|
||||
return _automaticMaximumThickness;
|
||||
}
|
||||
|
||||
- (void) setAutomaticMaximumThickness: (CGFloat)f
|
||||
{
|
||||
_automaticMaximumThickness = f;
|
||||
}
|
||||
|
||||
- (CGFloat) preferredThicknessFraction
|
||||
{
|
||||
return _preferredThicknessFraction;
|
||||
}
|
||||
|
||||
- (void) setPreferredThicknessFraction: (CGFloat)f
|
||||
{
|
||||
_preferredThicknessFraction = f;
|
||||
}
|
||||
|
||||
- (CGFloat) minimumThickness
|
||||
{
|
||||
return _minimumThickness;
|
||||
}
|
||||
|
||||
- (void) setMinimumThickness: (CGFloat)f
|
||||
{
|
||||
_minimumThickness = f;
|
||||
}
|
||||
|
||||
- (CGFloat) maximumThickness
|
||||
{
|
||||
return _maximumThickness;
|
||||
}
|
||||
|
||||
- (void) setMaximumThickness: (CGFloat)f
|
||||
{
|
||||
_maximumThickness = f;
|
||||
}
|
||||
|
||||
- (/* NSLayoutPriority */ CGFloat) holdingPriority
|
||||
{
|
||||
return _holdingPriority;
|
||||
}
|
||||
|
||||
- (void) setHoldingPriority: (/*NSLayoutPriority*/ CGFloat)hp
|
||||
{
|
||||
_holdingPriority = hp;
|
||||
}
|
||||
|
||||
- (BOOL) canCollapse
|
||||
{
|
||||
return _canCollapse;
|
||||
}
|
||||
|
||||
- (NSSplitViewItemCollapseBehavior) collapseBehavior
|
||||
{
|
||||
return _collapseBehavior;
|
||||
}
|
||||
|
||||
- (BOOL) isSpringLoaded
|
||||
{
|
||||
return _springLoaded;
|
||||
}
|
||||
|
||||
- (void) setSpringLoaded: (BOOL)flag
|
||||
{
|
||||
_springLoaded = flag;
|
||||
}
|
||||
|
||||
- (BOOL) allowsFullHeightLayout
|
||||
{
|
||||
return _allowsFullHeightLayout;
|
||||
}
|
||||
|
||||
- (void) setAllowsFullHeightLayout: (BOOL)flag
|
||||
{
|
||||
_allowsFullHeightLayout = flag;
|
||||
}
|
||||
|
||||
- (NSTitlebarSeparatorStyle) titlebarSeparatorStyle
|
||||
{
|
||||
return _titlebarSeparatorStyle;
|
||||
}
|
||||
|
||||
- (void) setTitlebarSeparatorStyle: (NSTitlebarSeparatorStyle)style
|
||||
{
|
||||
_titlebarSeparatorStyle = style;
|
||||
}
|
||||
|
||||
- (NSViewController *) viewController
|
||||
{
|
||||
return _viewController;
|
||||
}
|
||||
|
||||
- (void) setViewController: (NSViewController *)vc
|
||||
{
|
||||
_viewController = vc;
|
||||
}
|
||||
|
||||
// NSCoding
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super init];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSSplitViewItemViewController"])
|
||||
{
|
||||
_viewController = [coder decodeObjectForKey: @"NSSplitViewItemViewController"];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
[coder encodeObject: _viewController
|
||||
forKey: @"NSSplitViewItemViewController"];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
265
Source/NSStoryboard.m
Normal file
265
Source/NSStoryboard.m
Normal file
|
@ -0,0 +1,265 @@
|
|||
/* Implementation of class NSStoryboard
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento
|
||||
Date: Mon Jan 20 15:57:37 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 <Foundation/NSXMLDocument.h>
|
||||
#import <Foundation/NSXMLElement.h>
|
||||
#import <Foundation/NSXMLNode.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSUUID.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSNibDeclarations.h"
|
||||
|
||||
#import "GNUstepGUI/GSModelLoaderFactory.h"
|
||||
#import "GSStoryboardTransform.h"
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
static NSStoryboard *__mainStoryboard = nil;
|
||||
|
||||
// The storyboard needs to set this information on controllers...
|
||||
@interface NSWindowController (__StoryboardPrivate__)
|
||||
- (void) _setOwner: (id)owner;
|
||||
- (void) _setTopLevelObjects: (NSArray *)array;
|
||||
- (void) _setSegueMap: (NSMapTable *)map;
|
||||
- (void) _setStoryboard: (NSStoryboard *)storyboard;
|
||||
@end
|
||||
|
||||
@interface NSViewController (__StoryboardPrivate__)
|
||||
- (void) _setTopLevelObjects: (NSArray *)array;
|
||||
- (void) _setSegueMap: (NSMapTable *)map;
|
||||
- (void) _setStoryboard: (NSStoryboard *)storyboard;
|
||||
@end
|
||||
|
||||
@implementation NSWindowController (__StoryboardPrivate__)
|
||||
- (void) _setOwner: (id)owner
|
||||
{
|
||||
_owner = owner; // weak
|
||||
}
|
||||
|
||||
- (void) _setTopLevelObjects: (NSArray *)array
|
||||
{
|
||||
_top_level_objects = array;
|
||||
}
|
||||
|
||||
- (void) _setSegueMap: (NSMapTable *)map
|
||||
{
|
||||
ASSIGN(_segueMap, map);
|
||||
}
|
||||
|
||||
- (void) _setStoryboard: (NSStoryboard *)storyboard
|
||||
{
|
||||
_storyboard = storyboard;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSViewController (__StoryboardPrivate__)
|
||||
- (void) _setTopLevelObjects: (NSArray *)array
|
||||
{
|
||||
_topLevelObjects = array;
|
||||
}
|
||||
|
||||
- (void) _setSegueMap: (NSMapTable *)map
|
||||
{
|
||||
ASSIGN(_segueMap, map);
|
||||
}
|
||||
|
||||
- (void) _setStoryboard: (NSStoryboard *)storyboard
|
||||
{
|
||||
_storyboard = storyboard;
|
||||
}
|
||||
@end
|
||||
// end private methods...
|
||||
|
||||
@implementation NSStoryboard
|
||||
|
||||
// Private instance methods...
|
||||
- (id) initWithName: (NSStoryboardName)name
|
||||
bundle: (NSBundle *)bundle
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSString *path = [bundle pathForResource: name
|
||||
ofType: @"storyboard"];
|
||||
NSData *data = [NSData dataWithContentsOfFile: path];
|
||||
_transform = [[GSStoryboardTransform alloc] initWithData: data];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Class methods...
|
||||
+ (void) _setMainStoryboard: (NSStoryboard *)storyboard // private, only called from NSApplicationMain()
|
||||
{
|
||||
if (__mainStoryboard == nil)
|
||||
{
|
||||
ASSIGN(__mainStoryboard, storyboard);
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSStoryboard *) mainStoryboard
|
||||
{
|
||||
return __mainStoryboard;
|
||||
}
|
||||
|
||||
+ (instancetype) storyboardWithName: (NSStoryboardName)name
|
||||
bundle: (NSBundle *)bundle
|
||||
{
|
||||
return AUTORELEASE([[NSStoryboard alloc] initWithName: name
|
||||
bundle: bundle]);
|
||||
}
|
||||
|
||||
// Instance methods...
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_transform);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) _instantiateApplicationScene
|
||||
{
|
||||
[self instantiateControllerWithIdentifier: @"application"];
|
||||
}
|
||||
|
||||
- (id) instantiateInitialController
|
||||
{
|
||||
return [self instantiateInitialControllerWithCreator: nil];
|
||||
}
|
||||
|
||||
- (id) instantiateInitialControllerWithCreator: (NSStoryboardControllerCreator)block
|
||||
{
|
||||
return [self instantiateControllerWithIdentifier: [_transform initialViewControllerId]
|
||||
creator: block];
|
||||
}
|
||||
|
||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
||||
{
|
||||
return [self instantiateControllerWithIdentifier: identifier
|
||||
creator: nil];
|
||||
}
|
||||
|
||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
||||
creator: (NSStoryboardControllerCreator)block
|
||||
{
|
||||
id result = nil;
|
||||
NSMutableArray *topLevelObjects = [NSMutableArray arrayWithCapacity: 5];
|
||||
NSDictionary *table = [NSDictionary dictionaryWithObjectsAndKeys: topLevelObjects,
|
||||
NSNibTopLevelObjects,
|
||||
NSApp,
|
||||
NSNibOwner,
|
||||
nil];
|
||||
GSModelLoader *loader = [GSModelLoaderFactory modelLoaderForFileType: @"xib"];
|
||||
BOOL success = [loader loadModelData: [_transform dataForIdentifier: identifier]
|
||||
externalNameTable: table
|
||||
withZone: [self zone]];
|
||||
|
||||
if (success)
|
||||
{
|
||||
NSMutableArray *seguesToPerform = [NSMutableArray array];
|
||||
NSMapTable *segueMap = [_transform segueMapForIdentifier: identifier];
|
||||
NSWindowController *wc = nil;
|
||||
NSViewController *vc = nil;
|
||||
NSWindow *w = nil;
|
||||
|
||||
FOR_IN(id, o, topLevelObjects)
|
||||
if ([o isKindOfClass: [NSWindowController class]])
|
||||
{
|
||||
wc = (NSWindowController *)o;
|
||||
[wc _setSegueMap: segueMap];
|
||||
[wc _setTopLevelObjects: topLevelObjects];
|
||||
[wc _setStoryboard: self];
|
||||
[wc _setOwner: NSApp];
|
||||
result = o;
|
||||
}
|
||||
else if ([o isKindOfClass: [NSViewController class]])
|
||||
{
|
||||
vc = (NSViewController *)o;
|
||||
[vc _setSegueMap: segueMap];
|
||||
[vc _setTopLevelObjects: topLevelObjects];
|
||||
[vc _setStoryboard: self];
|
||||
result = o;
|
||||
}
|
||||
else if ([o isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
w = (NSWindow *)o;
|
||||
}
|
||||
else if ([o isKindOfClass: [NSControllerPlaceholder class]])
|
||||
{
|
||||
NSControllerPlaceholder *ph = (NSControllerPlaceholder *)o;
|
||||
result = [ph instantiate];
|
||||
}
|
||||
END_FOR_IN(topLevelObjects);
|
||||
|
||||
// Process action proxies after so we know we have the windowController...
|
||||
FOR_IN(id, o, topLevelObjects)
|
||||
if ([o isKindOfClass: [NSStoryboardSeguePerformAction class]])
|
||||
{
|
||||
NSStoryboardSeguePerformAction *ssa = (NSStoryboardSeguePerformAction *)o;
|
||||
NSMapTable *mapTable = [_transform segueMapForIdentifier: identifier];
|
||||
NSStoryboardSegue *ss = [mapTable objectForKey: [ssa identifier]];
|
||||
|
||||
[ssa setSender: result]; // resolve controller here...
|
||||
[ssa setStoryboardSegue: ss];
|
||||
[ssa setStoryboard: self];
|
||||
if ([[ssa kind] isEqualToString: @"relationship"]) // if it is a relationship, perform immediately
|
||||
{
|
||||
[seguesToPerform addObject: ssa];
|
||||
}
|
||||
}
|
||||
END_FOR_IN(topLevelObjects);
|
||||
|
||||
// Depending on which kind of controller we have, do the correct thing....
|
||||
if (w != nil && wc != nil)
|
||||
{
|
||||
[wc setWindow: w];
|
||||
}
|
||||
|
||||
// perform segues after all is initialized.
|
||||
FOR_IN(NSStoryboardSeguePerformAction*, ssa, seguesToPerform)
|
||||
[ssa doAction: result]; // this will, as far as I know, only happen with window controllers, to set content.
|
||||
END_FOR_IN(seguesToPerform);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Couldn't load controller scene identifier = %@", identifier];
|
||||
}
|
||||
|
||||
// Execute the block if it's set...
|
||||
if (block != nil)
|
||||
{
|
||||
CALL_BLOCK(block, self);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@end
|
197
Source/NSStoryboardSegue.m
Normal file
197
Source/NSStoryboardSegue.m
Normal file
|
@ -0,0 +1,197 @@
|
|||
/* Implementation of class NSStoryboardSegue
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento
|
||||
Date: Mon Jan 20 15:57: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 <Foundation/NSString.h>
|
||||
#import <Foundation/NSGeometry.h>
|
||||
|
||||
#import "AppKit/NSStoryboardSegue.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
#import "AppKit/NSSplitViewController.h"
|
||||
#import "AppKit/NSSplitViewItem.h"
|
||||
#import "AppKit/NSSplitView.h"
|
||||
#import "AppKit/NSTabViewController.h"
|
||||
#import "AppKit/NSTabViewItem.h"
|
||||
#import "AppKit/NSTabView.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSPopover.h"
|
||||
|
||||
@implementation NSStoryboardSegue
|
||||
|
||||
- (id) sourceController
|
||||
{
|
||||
return _sourceController;
|
||||
}
|
||||
|
||||
- (id) destinationController
|
||||
{
|
||||
return _destinationController;
|
||||
}
|
||||
|
||||
- (NSStoryboardSegueIdentifier)identifier
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
- (void) _setHandler: (GSStoryboardSeguePerformHandler)handler
|
||||
{
|
||||
ASSIGN(_handler, handler);
|
||||
}
|
||||
|
||||
- (void) _setDestinationController: (id)controller
|
||||
{
|
||||
_destinationController = controller;
|
||||
}
|
||||
|
||||
- (void) _setSourceController: (id)controller
|
||||
{
|
||||
_sourceController = controller;
|
||||
}
|
||||
|
||||
+ (instancetype) segueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
source: (id)sourceController
|
||||
destination: (id)destinationController
|
||||
performHandler: (GSStoryboardSeguePerformHandler)performHandler
|
||||
{
|
||||
NSStoryboardSegue *segue = [[NSStoryboardSegue alloc] initWithIdentifier: identifier
|
||||
source: sourceController
|
||||
destination: destinationController];
|
||||
AUTORELEASE(segue);
|
||||
[segue _setHandler: performHandler];
|
||||
|
||||
return segue;
|
||||
}
|
||||
|
||||
- (instancetype) initWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
source: (id)sourceController
|
||||
destination: (id)destinationController
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
ASSIGN(_sourceController, sourceController);
|
||||
ASSIGN(_destinationController, destinationController);
|
||||
ASSIGN(_identifier, identifier);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_sourceController);
|
||||
RELEASE(_destinationController);
|
||||
RELEASE(_identifier);
|
||||
RELEASE(_kind);
|
||||
RELEASE(_relationship);
|
||||
RELEASE(_handler);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) perform
|
||||
{
|
||||
// Perform segue based on it's kind...
|
||||
if ([_kind isEqualToString: @"relationship"])
|
||||
{
|
||||
if ([_relationship isEqualToString: @"window.shadowedContentViewController"])
|
||||
{
|
||||
NSWindow *w = [_sourceController window];
|
||||
NSView *v = [_destinationController view];
|
||||
[w setContentView: v];
|
||||
[w setTitle: [_destinationController title]];
|
||||
[_sourceController showWindow: self];
|
||||
}
|
||||
else if ([_relationship isEqualToString: @"splitItems"])
|
||||
{
|
||||
NSView *v = [_destinationController view];
|
||||
NSSplitViewController *svc = (NSSplitViewController *)_sourceController;
|
||||
[[svc splitView] addSubview: v];
|
||||
NSUInteger idx = [[[svc splitView] subviews] count] - 1;
|
||||
NSSplitViewItem *item = [[svc splitViewItems] objectAtIndex: idx];
|
||||
[item setViewController: _destinationController];
|
||||
}
|
||||
else if ([_relationship isEqualToString: @"tabItems"])
|
||||
{
|
||||
NSTabViewController *tvc = (NSTabViewController *)_sourceController;
|
||||
NSTabViewItem *item = [NSTabViewItem tabViewItemWithViewController: _destinationController];
|
||||
[tvc addTabViewItem: item];
|
||||
}
|
||||
}
|
||||
else if ([_kind isEqualToString: @"modal"])
|
||||
{
|
||||
NSWindow *w = nil;
|
||||
if ([_destinationController isKindOfClass: [NSWindowController class]])
|
||||
{
|
||||
w = [_destinationController window];
|
||||
}
|
||||
else
|
||||
{
|
||||
w = [NSWindow windowWithContentViewController: _destinationController];
|
||||
[w setTitle: [_destinationController title]];
|
||||
}
|
||||
RETAIN(w);
|
||||
[w center];
|
||||
[NSApp runModalForWindow: w];
|
||||
}
|
||||
else if ([_kind isEqualToString: @"show"])
|
||||
{
|
||||
if ([_destinationController isKindOfClass: [NSWindowController class]])
|
||||
{
|
||||
[_destinationController showWindow: _sourceController];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWindow *w = [NSWindow windowWithContentViewController: _destinationController];
|
||||
[w setTitle: [_destinationController title]];
|
||||
[w center];
|
||||
[w orderFrontRegardless];
|
||||
RETAIN(w);
|
||||
}
|
||||
}
|
||||
else if ([_kind isEqualToString: @"popover"])
|
||||
{
|
||||
NSPopover *po = [[NSPopover alloc] init];
|
||||
NSRect rect = [_popoverAnchorView frame];
|
||||
|
||||
[po setBehavior: _popoverBehavior];
|
||||
[po setContentViewController: _destinationController];
|
||||
[po showRelativeToRect: rect
|
||||
ofView: _popoverAnchorView
|
||||
preferredEdge: _preferredEdge];
|
||||
}
|
||||
else if ([_kind isEqualToString: @"sheet"])
|
||||
{
|
||||
}
|
||||
else if ([_kind isEqualToString: @"custom"])
|
||||
{
|
||||
}
|
||||
|
||||
if (_handler != nil)
|
||||
{
|
||||
CALL_BLOCK_NO_ARGS(_handler);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -111,10 +111,15 @@
|
|||
{
|
||||
if (tabViewItem == nil)
|
||||
return;
|
||||
|
||||
if (_items == nil)
|
||||
{
|
||||
ASSIGN(_items, [NSMutableArray array]);
|
||||
}
|
||||
|
||||
[tabViewItem _setTabView: self];
|
||||
[_items insertObject: tabViewItem atIndex: index];
|
||||
|
||||
|
||||
// If this is the first inserted then select it...
|
||||
if ([_items count] == 1)
|
||||
[self selectTabViewItem: tabViewItem];
|
||||
|
@ -564,7 +569,6 @@
|
|||
{
|
||||
ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]);
|
||||
[_items makeObjectsPerformSelector: @selector(_setTabView:) withObject: self];
|
||||
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"])
|
||||
{
|
||||
|
|
229
Source/NSTabViewController.m
Normal file
229
Source/NSTabViewController.m
Normal file
|
@ -0,0 +1,229 @@
|
|||
/* Implementation of class NSTabViewController
|
||||
Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 23-07-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
|
||||
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/NSArray.h>
|
||||
|
||||
#import "AppKit/NSTabViewController.h"
|
||||
#import "AppKit/NSTabViewItem.h"
|
||||
#import "AppKit/NSTabView.h"
|
||||
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
@implementation NSTabViewController
|
||||
- (NSTabViewControllerTabStyle) tabStyle
|
||||
{
|
||||
return _tabStyle;
|
||||
}
|
||||
|
||||
- (void) setTabStyle: (NSTabViewControllerTabStyle)ts
|
||||
{
|
||||
_tabStyle = ts;
|
||||
}
|
||||
|
||||
- (NSTabView *) tabView
|
||||
{
|
||||
return (NSTabView *)[self view];
|
||||
}
|
||||
|
||||
- (void) setTabView: (NSTabView *)tv
|
||||
{
|
||||
[self setView: tv];
|
||||
[tv setDelegate: self];
|
||||
}
|
||||
|
||||
- (NSViewControllerTransitionOptions) transitionOptions
|
||||
{
|
||||
return _transitionOptions;
|
||||
}
|
||||
|
||||
- (void) setTransitionOptions: (NSViewControllerTransitionOptions)options
|
||||
{
|
||||
_transitionOptions = options;
|
||||
}
|
||||
|
||||
- (BOOL) canPropagateSelectedChildViewControllerTitle
|
||||
{
|
||||
return _canPropagateSelectedChildViewControllerTitle;
|
||||
}
|
||||
|
||||
- (void) setCanPropagateSelectedChildViewControllerTitle: (BOOL)flag
|
||||
{
|
||||
_canPropagateSelectedChildViewControllerTitle = flag;
|
||||
}
|
||||
|
||||
// Managing tabViewItems...
|
||||
- (NSArray *) tabViewItems
|
||||
{
|
||||
return [[self tabView] tabViewItems];
|
||||
}
|
||||
|
||||
- (void) setTabViewItems: (NSArray *)items
|
||||
{
|
||||
FOR_IN(NSTabViewItem*, item, items)
|
||||
[[self tabView] addTabViewItem: item];
|
||||
END_FOR_IN(items);
|
||||
}
|
||||
|
||||
- (NSTabViewItem *) tabViewItemForViewController: (NSViewController *)controller
|
||||
{
|
||||
NSArray *tabViewItems = [[self tabView] tabViewItems];
|
||||
FOR_IN(NSTabViewItem*, tvi, tabViewItems)
|
||||
if ([tvi viewController] == controller)
|
||||
{
|
||||
return tvi;
|
||||
}
|
||||
END_FOR_IN(tabViewItems);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) addTabViewItem: (NSTabViewItem *)item
|
||||
{
|
||||
[[self tabView] addTabViewItem: item];
|
||||
}
|
||||
|
||||
- (void) insertTabViewItem: (NSTabViewItem *)item
|
||||
atIndex: (NSInteger)index
|
||||
{
|
||||
[[self tabView] insertTabViewItem: item atIndex: index];
|
||||
}
|
||||
|
||||
- (void) removeTabViewItem: (NSTabViewItem *)item
|
||||
{
|
||||
[[self tabView] removeTabViewItem: item];
|
||||
}
|
||||
|
||||
- (NSInteger) selectedTabViewItemIndex
|
||||
{
|
||||
return [[self tabView] indexOfTabViewItem: [[self tabView] selectedTabViewItem]];
|
||||
}
|
||||
|
||||
- (void) setSelectedTabViewItemIndex: (NSInteger)idx
|
||||
{
|
||||
[[self tabView] selectTabViewItemAtIndex: idx];
|
||||
if (_canPropagateSelectedChildViewControllerTitle)
|
||||
{
|
||||
NSString *title = [[[self tabView] tabViewItems] objectAtIndex: idx];
|
||||
if (title != nil)
|
||||
{
|
||||
[self setTitle: title];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Responding to tabview actions...
|
||||
- (BOOL)tabView:(NSTabView *)tabView
|
||||
shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)tabView:(NSTabView *)tabView
|
||||
willSelectTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
- (void)tabView:(NSTabView *)tabView
|
||||
didSelectTabViewItem:(NSTabViewItem *)tabViewItem
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
// Responding to toolbar actions...
|
||||
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
|
||||
itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
|
||||
willBeInsertedIntoToolbar:(BOOL)flag
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
|
||||
{
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
|
||||
{
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
// NSCoding
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSTabView"])
|
||||
{
|
||||
NSTabView *tv = [coder decodeObjectForKey: @"NSTabView"];
|
||||
[self setTabView: tv];
|
||||
|
||||
// Currently we only support the tabs being on the top or the bottom.
|
||||
// The rendering code doesn't support anything outside of these two
|
||||
// cases. Here we force the use of the top case, when it is outside
|
||||
// of either of the cases we handle... this is temporary. FIXME
|
||||
if ([tv tabViewType] != NSTopTabsBezelBorder &&
|
||||
[tv tabViewType] != NSBottomTabsBezelBorder)
|
||||
{
|
||||
[tv setTabViewType: NSTopTabsBezelBorder];
|
||||
}
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle"])
|
||||
{
|
||||
BOOL flag = [coder decodeBoolForKey: @"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle"];
|
||||
[self setCanPropagateSelectedChildViewControllerTitle: flag];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL flag;
|
||||
[self setTabView: [coder decodeObject]]; // get tabview...
|
||||
[coder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &flag];
|
||||
[self setCanPropagateSelectedChildViewControllerTitle: flag];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
[super encodeWithCoder: coder];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
NSTabView *tv = [self tabView];
|
||||
[coder encodeObject: tv forKey: @"NSTabView"];
|
||||
[coder encodeBool: [self canPropagateSelectedChildViewControllerTitle]
|
||||
forKey: @"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle"];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL flag = [self canPropagateSelectedChildViewControllerTitle];
|
||||
[coder encodeObject: [self tabView]]; // get tabview...
|
||||
[coder encodeValueOfObjCType: @encode(BOOL)
|
||||
at: &flag];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
#import "AppKit/NSTabView.h"
|
||||
#import "AppKit/NSTabViewItem.h"
|
||||
#import "AppKit/PSOperators.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
|
||||
@implementation NSTabViewItem
|
||||
|
||||
|
@ -72,6 +73,33 @@
|
|||
NSStringFromClass([self class]), _label, _ident];
|
||||
}
|
||||
|
||||
- (NSViewController *) viewController
|
||||
{
|
||||
return _viewController;
|
||||
}
|
||||
|
||||
- (void) setViewController: (NSViewController *)vc
|
||||
{
|
||||
_viewController = vc; // weak
|
||||
[self setView: [vc view]];
|
||||
}
|
||||
|
||||
+ (instancetype) tabViewItemWithViewController: (NSViewController *)vc
|
||||
{
|
||||
NSTabViewItem *item = AUTORELEASE([[NSTabViewItem alloc] init]);
|
||||
if ([vc title] == nil || [[vc title] isEqualToString: @""])
|
||||
{
|
||||
NSString *className = [vc className];
|
||||
[item setLabel: className];
|
||||
}
|
||||
else
|
||||
{
|
||||
[item setLabel: [vc title]];
|
||||
}
|
||||
[item setViewController: vc];
|
||||
return item;
|
||||
}
|
||||
|
||||
// Set identifier.
|
||||
|
||||
- (void) setIdentifier: (id)identifier
|
||||
|
|
|
@ -205,7 +205,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
* Private methods.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The [-_invalidateCoordinates] method marks the coordinate mapping
|
||||
* matrices (matrixFromWindow and _matrixToWindow) and the cached visible
|
||||
|
@ -5132,6 +5131,28 @@ static NSView* findByTag(NSView *view, NSInteger aTag, NSUInteger *level)
|
|||
|
||||
@end
|
||||
|
||||
@implementation NSView (__NSViewPrivateMethods__)
|
||||
|
||||
/*
|
||||
* This method inserts a view at a given place in the view hierarchy.
|
||||
*/
|
||||
- (void) _insertSubview: (NSView *)sv atIndex: (NSUInteger)idx
|
||||
{
|
||||
[sv _viewWillMoveToWindow: _window];
|
||||
[sv _viewWillMoveToSuperview: self];
|
||||
[sv setNextResponder: self];
|
||||
[_sub_views insertObject: sv atIndex: idx];
|
||||
_rFlags.has_subviews = 1;
|
||||
[sv resetCursorRects];
|
||||
[sv setNeedsDisplay: YES];
|
||||
[sv _viewDidMoveToWindow];
|
||||
[sv viewDidMoveToSuperview];
|
||||
[self didAddSubview: sv];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSView(KeyViewLoop)
|
||||
|
||||
static NSComparisonResult
|
||||
|
|
|
@ -29,11 +29,15 @@
|
|||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
|
||||
#import "AppKit/NSStoryboardSegue.h"
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
|
||||
@implementation NSViewController
|
||||
|
||||
|
@ -46,7 +50,7 @@
|
|||
|
||||
ASSIGN(_nibName, nibNameOrNil);
|
||||
ASSIGN(_nibBundle, nibBundleOrNil);
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -63,7 +67,8 @@
|
|||
DESTROY(_autounbinder);
|
||||
DESTROY(_designNibBundleIdentifier);
|
||||
DESTROY(view);
|
||||
|
||||
DESTROY(_segueMap);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -79,6 +84,11 @@
|
|||
|
||||
- (void)setTitle:(NSString *)title
|
||||
{
|
||||
NSWindow *w = [[self view] window];
|
||||
if (w != nil)
|
||||
{
|
||||
[w setTitle: title]; // sync title with window...
|
||||
}
|
||||
ASSIGN(_title, title);
|
||||
}
|
||||
|
||||
|
@ -151,6 +161,7 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
_segueMap = RETAIN([NSMapTable strongToWeakObjectsMapTable]);
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
NSView *aView = [aDecoder decodeObjectForKey: @"NSView"];
|
||||
|
@ -179,6 +190,29 @@
|
|||
[aCoder encodeObject: [self view]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NSSeguePerforming methods...
|
||||
- (void)performSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender
|
||||
{
|
||||
NSStoryboardSegue *segue = [_segueMap objectForKey: identifier];
|
||||
[self prepareForSegue: segue
|
||||
sender: sender];
|
||||
[segue perform];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue: (NSStoryboardSegue *)segue
|
||||
sender: (id)sender
|
||||
{
|
||||
// do nothing in base class method...
|
||||
}
|
||||
|
||||
- (BOOL)shouldPerformSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSViewController (NSEditorRegistration)
|
||||
|
@ -227,5 +261,5 @@
|
|||
// Loop over all elements of _editors
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -34,4 +34,8 @@
|
|||
- (void) _recursiveSetUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView;
|
||||
@end
|
||||
|
||||
@interface NSView (__NSViewPrivateMethods__)
|
||||
- (void) _insertSubview: (NSView *)sv atIndex: (NSUInteger)idx;
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSViewPrivate
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
#import "AppKit/NSTextField.h"
|
||||
#import "AppKit/NSTextFieldCell.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
#import "AppKit/PSOperators.h"
|
||||
|
@ -723,6 +724,26 @@ static NSNotificationCenter *nc = nil;
|
|||
}
|
||||
}
|
||||
|
||||
+ (instancetype) windowWithContentViewController: (NSViewController *)viewController
|
||||
{
|
||||
NSView *view = [viewController view];
|
||||
NSRect frame = [view frame];
|
||||
NSString *title = [viewController title];
|
||||
NSUInteger style = NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask;
|
||||
NSWindow *window = [[self alloc] initWithContentRect: frame
|
||||
styleMask: style
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: NO];
|
||||
[window setTitle: title];
|
||||
[window setContentView: view];
|
||||
[view setNeedsDisplay: YES];
|
||||
AUTORELEASE(window);
|
||||
return window;
|
||||
}
|
||||
|
||||
+ (void) removeFrameUsingName: (NSString*)name
|
||||
{
|
||||
if (name != nil)
|
||||
|
|
|
@ -33,11 +33,16 @@
|
|||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSNibLoading.h"
|
||||
#import "AppKit/NSPanel.h"
|
||||
#import "AppKit/NSWindowController.h"
|
||||
#import "AppKit/NSStoryboardSegue.h"
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
#import "AppKit/NSViewController.h"
|
||||
|
||||
#import "NSDocumentFrameworkPrivate.h"
|
||||
|
||||
@implementation NSWindowController
|
||||
|
@ -137,6 +142,7 @@
|
|||
RELEASE(_window_nib_path);
|
||||
RELEASE(_window_frame_autosave_name);
|
||||
RELEASE(_top_level_objects);
|
||||
RELEASE(_segueMap);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -319,7 +325,7 @@
|
|||
return _window;
|
||||
}
|
||||
|
||||
/** Sets the window that this controller managers to aWindow. The old
|
||||
/** Sets the window that this controller manages to aWindow. The old
|
||||
window is released. */
|
||||
- (void) setWindow: (NSWindow *)aWindow
|
||||
{
|
||||
|
@ -527,6 +533,7 @@
|
|||
if (!self)
|
||||
return nil;
|
||||
|
||||
_segueMap = nil;
|
||||
ASSIGN(_window_frame_autosave_name, @"");
|
||||
_wcFlags.should_cascade = YES;
|
||||
//_wcFlags.should_close_document = NO;
|
||||
|
@ -550,4 +557,26 @@
|
|||
[super encodeWithCoder: coder];
|
||||
}
|
||||
|
||||
// NSSeguePerforming methods...
|
||||
- (void)performSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender
|
||||
{
|
||||
NSStoryboardSegue *segue = [_segueMap objectForKey: identifier];
|
||||
[self prepareForSegue: segue
|
||||
sender: sender];
|
||||
[segue perform];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue: (NSStoryboardSegue *)segue
|
||||
sender: (id)sender
|
||||
{
|
||||
// do nothing in base class method...
|
||||
}
|
||||
|
||||
- (BOOL)shouldPerformSegueWithIdentifier: (NSStoryboardSegueIdentifier)identifier
|
||||
sender: (id)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue