mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Remove MacVim plugin related code
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
//
|
||||
// CTGradient.h
|
||||
//
|
||||
// Created by Chad Weider on 2/14/07.
|
||||
// Writtin by Chad Weider.
|
||||
//
|
||||
// Released into public domain on 4/10/08.
|
||||
//
|
||||
// Version: 1.8
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
typedef struct _CTGradientElement
|
||||
{
|
||||
float red, green, blue, alpha;
|
||||
float position;
|
||||
|
||||
struct _CTGradientElement *nextElement;
|
||||
} CTGradientElement;
|
||||
|
||||
typedef enum _CTBlendingMode
|
||||
{
|
||||
CTLinearBlendingMode,
|
||||
CTChromaticBlendingMode,
|
||||
CTInverseChromaticBlendingMode
|
||||
} CTGradientBlendingMode;
|
||||
|
||||
|
||||
@interface CTGradient : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
CTGradientElement* elementList;
|
||||
CTGradientBlendingMode blendingMode;
|
||||
|
||||
CGFunctionRef gradientFunction;
|
||||
}
|
||||
|
||||
+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end;
|
||||
|
||||
+ (id)aquaSelectedGradient;
|
||||
+ (id)aquaNormalGradient;
|
||||
+ (id)aquaPressedGradient;
|
||||
|
||||
+ (id)unifiedSelectedGradient;
|
||||
+ (id)unifiedNormalGradient;
|
||||
+ (id)unifiedPressedGradient;
|
||||
+ (id)unifiedDarkGradient;
|
||||
|
||||
+ (id)sourceListSelectedGradient;
|
||||
+ (id)sourceListUnselectedGradient;
|
||||
|
||||
+ (id)rainbowGradient;
|
||||
+ (id)hydrogenSpectrumGradient;
|
||||
|
||||
- (CTGradient *)gradientWithAlphaComponent:(float)alpha;
|
||||
|
||||
- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1]
|
||||
- (CTGradient *)removeColorStopAtIndex:(unsigned)index;
|
||||
- (CTGradient *)removeColorStopAtPosition:(float)position;
|
||||
|
||||
- (CTGradientBlendingMode)blendingMode;
|
||||
- (NSColor *)colorStopAtIndex:(unsigned)index;
|
||||
- (NSColor *)colorAtPosition:(float)position;
|
||||
|
||||
|
||||
- (void)drawSwatchInRect:(NSRect)rect;
|
||||
- (void)fillRect:(NSRect)rect angle:(float)angle; //fills rect with axial gradient
|
||||
// angle in degrees
|
||||
- (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient
|
||||
// gradient from center outwards
|
||||
- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle;
|
||||
- (void)radialFillBezierPath:(NSBezierPath *)path;
|
||||
|
||||
@end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,10 +35,6 @@
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
|
||||
FSEventStreamRef fsEventStream;
|
||||
#endif
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
NSMenuItem *plugInMenuItem;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (MMAppController *)sharedInstance;
|
||||
@@ -51,12 +47,6 @@
|
||||
- (NSArray *)filterOpenFiles:(NSArray *)filenames;
|
||||
- (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args;
|
||||
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (void)addItemToPlugInMenu:(NSMenuItem *)item;
|
||||
- (void)removeItemFromPlugInMenu:(NSMenuItem *)item;
|
||||
#endif
|
||||
|
||||
- (IBAction)newWindow:(id)sender;
|
||||
- (IBAction)newWindowAndActivate:(id)sender;
|
||||
- (IBAction)fileOpen:(id)sender;
|
||||
|
||||
@@ -42,11 +42,6 @@
|
||||
#import "MMVimController.h"
|
||||
#import "MMWindowController.h"
|
||||
#import "Miscellaneous.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
#import "MMPlugInManager.h"
|
||||
#endif
|
||||
|
||||
#import <unistd.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
|
||||
@@ -142,11 +137,6 @@ typedef struct
|
||||
toCommandLine:(NSArray **)cmdline;
|
||||
- (NSString *)workingDirectoryForArguments:(NSDictionary *)args;
|
||||
- (NSScreen *)screenContainingPoint:(NSPoint)pt;
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (void)removePlugInMenu;
|
||||
- (void)addPlugInMenuToMenu:(NSMenu *)mainMenu;
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
||||
@@ -216,9 +206,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
@"", MMLoginShellCommandKey,
|
||||
@"", MMLoginShellArgumentKey,
|
||||
[NSNumber numberWithBool:YES], MMDialogsTrackPwdKey,
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[NSNumber numberWithBool:YES], MMShowLeftPlugInContainerKey,
|
||||
#endif
|
||||
[NSNumber numberWithInt:3], MMOpenLayoutKey,
|
||||
[NSNumber numberWithBool:NO], MMVerticalSplitKey,
|
||||
[NSNumber numberWithInt:0], MMPreloadCacheSizeKey,
|
||||
@@ -253,17 +240,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
pidArguments = [NSMutableDictionary new];
|
||||
inputQueues = [NSMutableDictionary new];
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
NSString *plugInTitle = NSLocalizedString(@"Plug-In",
|
||||
@"Plug-In menu title");
|
||||
plugInMenuItem = [[NSMenuItem alloc] initWithTitle:plugInTitle
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
NSMenu *submenu = [[NSMenu alloc] initWithTitle:plugInTitle];
|
||||
[plugInMenuItem setSubmenu:submenu];
|
||||
[submenu release];
|
||||
#endif
|
||||
|
||||
// NOTE: Do not use the default connection since the Logitech Control
|
||||
// Center (LCC) input manager steals and this would cause MacVim to
|
||||
// never open any windows. (This is a bug in LCC but since they are
|
||||
@@ -298,9 +274,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
[openSelectionString release]; openSelectionString = nil;
|
||||
[recentFilesMenuItem release]; recentFilesMenuItem = nil;
|
||||
[defaultMainMenu release]; defaultMainMenu = nil;
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[plugInMenuItem release]; plugInMenuItem = nil;
|
||||
#endif
|
||||
[appMenuItemTemplate release]; appMenuItemTemplate = nil;
|
||||
|
||||
[super dealloc];
|
||||
@@ -399,9 +372,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
[NSApp setServicesProvider:self];
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[[MMPlugInManager sharedManager] loadAllPlugIns];
|
||||
#endif
|
||||
|
||||
if ([self maxPreloadCacheSize] > 0) {
|
||||
[self scheduleVimControllerPreloadAfterDelay:2];
|
||||
@@ -633,10 +603,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
[self stopWatchingVimDir];
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[[MMPlugInManager sharedManager] unloadAllPlugIns];
|
||||
#endif
|
||||
|
||||
#if MM_HANDLE_XCODE_MOD_EVENT
|
||||
[[NSAppleEventManager sharedAppleEventManager]
|
||||
removeEventHandlerForEventClass:'KAHL'
|
||||
@@ -889,12 +855,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
}
|
||||
}
|
||||
[NSApp setWindowsMenu:windowsMenu];
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
// Move plugin menu from old to new main menu.
|
||||
[self removePlugInMenu];
|
||||
[self addPlugInMenuToMenu:mainMenu];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSArray *)filterOpenFiles:(NSArray *)filenames
|
||||
@@ -1052,24 +1012,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
return openOk;
|
||||
}
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (void)addItemToPlugInMenu:(NSMenuItem *)item
|
||||
{
|
||||
NSMenu *menu = [plugInMenuItem submenu];
|
||||
[menu addItem:item];
|
||||
if ([menu numberOfItems] == 1)
|
||||
[self addPlugInMenuToMenu:[NSApp mainMenu]];
|
||||
}
|
||||
|
||||
- (void)removeItemFromPlugInMenu:(NSMenuItem *)item
|
||||
{
|
||||
NSMenu *menu = [plugInMenuItem submenu];
|
||||
[menu removeItem:item];
|
||||
if ([menu numberOfItems] == 0)
|
||||
[self removePlugInMenu];
|
||||
}
|
||||
#endif
|
||||
|
||||
- (IBAction)newWindow:(id)sender
|
||||
{
|
||||
ASLogDebug(@"Open new window");
|
||||
@@ -1810,29 +1752,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
return dict;
|
||||
}
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (void)removePlugInMenu
|
||||
{
|
||||
if ([plugInMenuItem menu])
|
||||
[[plugInMenuItem menu] removeItem:plugInMenuItem];
|
||||
}
|
||||
|
||||
- (void)addPlugInMenuToMenu:(NSMenu *)mainMenu
|
||||
{
|
||||
NSMenu *windowsMenu = [mainMenu findWindowsMenu];
|
||||
|
||||
if ([[plugInMenuItem submenu] numberOfItems] > 0) {
|
||||
int idx = windowsMenu ? [mainMenu indexOfItemWithSubmenu:windowsMenu]
|
||||
: -1;
|
||||
if (idx > 0) {
|
||||
[mainMenu insertItem:plugInMenuItem atIndex:idx];
|
||||
} else {
|
||||
[mainMenu addItem:plugInMenuItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)scheduleVimControllerPreloadAfterDelay:(NSTimeInterval)delay
|
||||
{
|
||||
[self performSelector:@selector(preloadVimController:)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "MMVimController.h"
|
||||
|
||||
|
||||
@interface MMPlugInManager : NSObject {
|
||||
|
||||
NSMutableArray *plugInClasses;
|
||||
}
|
||||
|
||||
- (NSArray *)plugInClasses;
|
||||
|
||||
// Find and load any plugins
|
||||
- (void)loadAllPlugIns;
|
||||
|
||||
// release instances of loaded plugins
|
||||
- (void)unloadAllPlugIns;
|
||||
|
||||
// Return singleton instance of MMPluginManager
|
||||
+ (MMPlugInManager *)sharedManager;
|
||||
|
||||
@end
|
||||
@@ -1,151 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MMPlugInManager
|
||||
*
|
||||
* This class is responsible for finding MacVim plugins at startup, loading
|
||||
* them, and keeping track of them.
|
||||
*
|
||||
* Author: Matt Tolton
|
||||
*/
|
||||
|
||||
#import "MacVim.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
|
||||
#import "MMPlugInManager.h"
|
||||
#import "PlugInInterface.h"
|
||||
#import "PlugInImpl.h"
|
||||
|
||||
@implementation MMPlugInManager
|
||||
|
||||
static NSString *ext = @"mmplugin";
|
||||
|
||||
static NSString *appSupportSubpath = @"Application Support/MacVim/PlugIns";
|
||||
|
||||
static MMPlugInManager *plugInManager = nil;
|
||||
|
||||
+ (MMPlugInManager*)sharedManager
|
||||
{
|
||||
if (!plugInManager)
|
||||
plugInManager = [[MMPlugInManager alloc] init];
|
||||
|
||||
return plugInManager;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]) == nil) return nil;
|
||||
plugInClasses = [[NSMutableArray alloc] init];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
ASLogDebug(@"");
|
||||
|
||||
[plugInClasses release]; plugInClasses = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *)plugInClasses;
|
||||
{
|
||||
return plugInClasses;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)allBundles
|
||||
{
|
||||
NSArray *librarySearchPaths;
|
||||
NSEnumerator *searchPathEnum;
|
||||
NSString *currPath;
|
||||
NSMutableArray *bundleSearchPaths = [NSMutableArray array];
|
||||
NSMutableArray *allBundles = [NSMutableArray array];
|
||||
|
||||
librarySearchPaths = NSSearchPathForDirectoriesInDomains(
|
||||
NSLibraryDirectory, NSAllDomainsMask - NSSystemDomainMask, YES);
|
||||
|
||||
searchPathEnum = [librarySearchPaths objectEnumerator];
|
||||
while(currPath = [searchPathEnum nextObject]) {
|
||||
[bundleSearchPaths addObject:
|
||||
[currPath stringByAppendingPathComponent:appSupportSubpath]];
|
||||
}
|
||||
|
||||
[bundleSearchPaths addObject:
|
||||
[[NSBundle mainBundle] builtInPlugInsPath]];
|
||||
|
||||
searchPathEnum = [bundleSearchPaths objectEnumerator];
|
||||
while(currPath = [searchPathEnum nextObject]) {
|
||||
NSDirectoryEnumerator *bundleEnum;
|
||||
NSString *currBundlePath;
|
||||
bundleEnum = [[NSFileManager defaultManager]
|
||||
enumeratorAtPath:currPath];
|
||||
if(bundleEnum) {
|
||||
while(currBundlePath = [bundleEnum nextObject]) {
|
||||
if([[currBundlePath pathExtension] isEqualToString:ext]) {
|
||||
[allBundles addObject:[currPath
|
||||
stringByAppendingPathComponent:currBundlePath]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allBundles;
|
||||
}
|
||||
|
||||
- (BOOL)plugInClassIsValid:(Class)class
|
||||
{
|
||||
return [class conformsToProtocol:@protocol(PlugInProtocol)];
|
||||
}
|
||||
|
||||
- (void)loadAllPlugIns
|
||||
{
|
||||
NSMutableArray *bundlePaths;
|
||||
NSEnumerator *pathEnum;
|
||||
NSString *currPath;
|
||||
NSBundle *currBundle;
|
||||
Class currPrincipalClass;
|
||||
|
||||
bundlePaths = [NSMutableArray array];
|
||||
|
||||
[bundlePaths addObjectsFromArray:[self allBundles]];
|
||||
|
||||
pathEnum = [bundlePaths objectEnumerator];
|
||||
while(currPath = [pathEnum nextObject]) {
|
||||
currBundle = [NSBundle bundleWithPath:currPath];
|
||||
if(currBundle) {
|
||||
currPrincipalClass = [currBundle principalClass];
|
||||
if(currPrincipalClass && [self plugInClassIsValid:currPrincipalClass]) {
|
||||
if ([currPrincipalClass initializePlugIn:
|
||||
[MMPlugInAppMediator sharedAppMediator]]) {
|
||||
ASLogInfo(@"Plug-in initialized: %@", currPath);
|
||||
[plugInClasses addObject:currPrincipalClass];
|
||||
} else {
|
||||
ASLogErr(@"Plug-in failed to initialize: %@", currPath);
|
||||
}
|
||||
} else {
|
||||
ASLogErr(@"Plug-in did not conform to protocol: %@", currPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unloadAllPlugIns
|
||||
{
|
||||
int i, count = [plugInClasses count];
|
||||
for (i = 0; i < count; i++)
|
||||
[[plugInClasses objectAtIndex:i] terminatePlugIn];
|
||||
|
||||
[plugInClasses removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#import "MacVim.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
#import "PlugInImpl.h"
|
||||
#endif
|
||||
|
||||
|
||||
@class MMWindowController;
|
||||
|
||||
@@ -36,9 +32,6 @@
|
||||
int pid;
|
||||
NSString *serverName;
|
||||
NSDictionary *vimState;
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
MMPlugInInstanceMediator *instanceMediator;
|
||||
#endif
|
||||
BOOL isPreloading;
|
||||
NSDate *creationDate;
|
||||
}
|
||||
@@ -70,7 +63,4 @@
|
||||
- (id)evaluateVimExpressionCocoa:(NSString *)expr
|
||||
errorString:(NSString **)errstr;
|
||||
- (void)processInputQueue:(NSArray *)queue;
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (MMPlugInInstanceMediator *)instanceMediator;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
#import "MMWindowController.h"
|
||||
#import "Miscellaneous.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
#import "MMPlugInManager.h"
|
||||
#endif
|
||||
|
||||
static NSString *MMDefaultToolbarImageName = @"Attention";
|
||||
static int MMAlertTextFieldHeight = 22;
|
||||
@@ -150,11 +147,6 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
|
||||
[mainMenu addItem:appMenuItem];
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
instanceMediator = [[MMPlugInInstanceMediator alloc]
|
||||
initWithVimController:self];
|
||||
#endif
|
||||
|
||||
isInitialized = YES;
|
||||
|
||||
return self;
|
||||
@@ -166,10 +158,6 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
|
||||
isInitialized = NO;
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[instanceMediator release]; instanceMediator = nil;
|
||||
#endif
|
||||
|
||||
[serverName release]; serverName = nil;
|
||||
[backendProxy release]; backendProxy = nil;
|
||||
|
||||
@@ -195,13 +183,6 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
return windowController;
|
||||
}
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
- (MMPlugInInstanceMediator *)instanceMediator
|
||||
{
|
||||
return instanceMediator;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSDictionary *)vimState
|
||||
{
|
||||
return vimState;
|
||||
|
||||
@@ -12,13 +12,6 @@
|
||||
#import <asl.h>
|
||||
|
||||
|
||||
//
|
||||
// Uncomment to enable support for MacVim plugins (not to be confused with Vim
|
||||
// plugins!).
|
||||
//
|
||||
//#define MM_ENABLE_PLUGINS
|
||||
|
||||
|
||||
// Taken from /usr/include/AvailabilityMacros.h
|
||||
#ifndef MAC_OS_X_VERSION_10_4
|
||||
# define MAC_OS_X_VERSION_10_4 1040
|
||||
|
||||
@@ -73,13 +73,6 @@
|
||||
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */ = {isa = PBXBuildFile; fileRef = B59228A511F7572F00E7F584 /* MacVim.sdef */; };
|
||||
BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */; };
|
||||
BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2E0DAAD74400F08A5C /* RBSplitView.m */; };
|
||||
BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BD943D520DA3050B00A02D9B /* PlugInImpl.m */; };
|
||||
BD9DF0A00DB2BA020025C97C /* PlugInView.nib in Resources */ = {isa = PBXBuildFile; fileRef = BD9DF09F0DB2BA020025C97C /* PlugInView.nib */; };
|
||||
BD9DF0B00DB41E780025C97C /* PlugInGUI.m in Sources */ = {isa = PBXBuildFile; fileRef = BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */; };
|
||||
BD9DF0FB0DB48C860025C97C /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = BD9DF0FA0DB48C860025C97C /* CTGradient.m */; };
|
||||
BDA8B1120D9F8A8500B3511A /* MMPlugInManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -226,21 +219,6 @@
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* MacVim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacVim.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B59228A511F7572F00E7F584 /* MacVim.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = MacVim.sdef; sourceTree = "<group>"; };
|
||||
BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitSubview.h; sourceTree = "<group>"; };
|
||||
BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitSubview.m; sourceTree = "<group>"; };
|
||||
BD476E2D0DAAD74400F08A5C /* RBSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitView.h; sourceTree = "<group>"; };
|
||||
BD476E2E0DAAD74400F08A5C /* RBSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitView.m; sourceTree = "<group>"; };
|
||||
BD476E2F0DAAD74400F08A5C /* RBSplitViewPrivateDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitViewPrivateDefines.h; sourceTree = "<group>"; };
|
||||
BD943D310DA2EA2500A02D9B /* PlugInInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInInterface.h; sourceTree = "<group>"; };
|
||||
BD943D510DA3050B00A02D9B /* PlugInImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInImpl.h; sourceTree = "<group>"; };
|
||||
BD943D520DA3050B00A02D9B /* PlugInImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlugInImpl.m; sourceTree = "<group>"; };
|
||||
BD9DF09F0DB2BA020025C97C /* PlugInView.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = PlugInView.nib; sourceTree = "<group>"; };
|
||||
BD9DF0AE0DB41E780025C97C /* PlugInGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInGUI.h; sourceTree = "<group>"; };
|
||||
BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlugInGUI.m; sourceTree = "<group>"; };
|
||||
BD9DF0F90DB48C860025C97C /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTGradient.h; sourceTree = "<group>"; };
|
||||
BD9DF0FA0DB48C860025C97C /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTGradient.m; sourceTree = "<group>"; };
|
||||
BDA8B1100D9F8A8500B3511A /* MMPlugInManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMPlugInManager.h; sourceTree = "<group>"; };
|
||||
BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMPlugInManager.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -275,13 +253,6 @@
|
||||
1D145C7E0E5227CE00691AA0 /* MMTextViewHelper.m */,
|
||||
1D8059220E118663001699D1 /* Miscellaneous.h */,
|
||||
1D80591D0E1185EA001699D1 /* Miscellaneous.m */,
|
||||
BD9DF0F90DB48C860025C97C /* CTGradient.h */,
|
||||
BD9DF0FA0DB48C860025C97C /* CTGradient.m */,
|
||||
BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */,
|
||||
BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */,
|
||||
BD476E2D0DAAD74400F08A5C /* RBSplitView.h */,
|
||||
BD476E2E0DAAD74400F08A5C /* RBSplitView.m */,
|
||||
BD476E2F0DAAD74400F08A5C /* RBSplitViewPrivateDefines.h */,
|
||||
0395A8310D71ED7800881434 /* DBPrefsWindowController.h */,
|
||||
0395A8320D71ED7800881434 /* DBPrefsWindowController.m */,
|
||||
1DE3F8E80D50F84600052B9E /* MMPreferenceController.h */,
|
||||
@@ -312,13 +283,6 @@
|
||||
1D1474960C56703C0038FA2B /* MacVim.m */,
|
||||
32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
BDA8B1100D9F8A8500B3511A /* MMPlugInManager.h */,
|
||||
BDA8B1110D9F8A8500B3511A /* MMPlugInManager.m */,
|
||||
BD943D310DA2EA2500A02D9B /* PlugInInterface.h */,
|
||||
BD943D510DA3050B00A02D9B /* PlugInImpl.h */,
|
||||
BD943D520DA3050B00A02D9B /* PlugInImpl.m */,
|
||||
BD9DF0AE0DB41E780025C97C /* PlugInGUI.h */,
|
||||
BD9DF0AF0DB41E780025C97C /* PlugInGUI.m */,
|
||||
);
|
||||
name = "MacVim Source";
|
||||
sourceTree = "<group>";
|
||||
@@ -435,7 +399,6 @@
|
||||
1D8BEA73104992290069B072 /* FindAndReplace.nib */,
|
||||
0395A8A90D72D88B00881434 /* General.png */,
|
||||
1D22374A0E45DF4800E6FFFF /* Advanced.png */,
|
||||
BD9DF09F0DB2BA020025C97C /* PlugInView.nib */,
|
||||
1DD3D51D0D82D4C9006E4320 /* ibeam.png */,
|
||||
1D0F11480D58C77800D5DA09 /* Font */,
|
||||
1DE9726C0C48050600F96A9F /* Toolbar */,
|
||||
@@ -547,7 +510,6 @@
|
||||
1DE3F8E70D50F80500052B9E /* Preferences.nib in Resources */,
|
||||
0395A8AA0D72D88B00881434 /* General.png in Resources */,
|
||||
1DD3D51E0D82D4C9006E4320 /* ibeam.png in Resources */,
|
||||
BD9DF0A00DB2BA020025C97C /* PlugInView.nib in Resources */,
|
||||
1D22374B0E45DF4800E6FFFF /* Advanced.png in Resources */,
|
||||
1DCD00BF0E50B2B700460166 /* Attention.png in Resources */,
|
||||
1DCD00C00E50B2B700460166 /* Copy.png in Resources */,
|
||||
@@ -618,12 +580,6 @@
|
||||
1DE3F8EB0D50F84600052B9E /* MMPreferenceController.m in Sources */,
|
||||
0395A8330D71ED7800881434 /* DBPrefsWindowController.m in Sources */,
|
||||
1D80591F0E1185EA001699D1 /* Miscellaneous.m in Sources */,
|
||||
BDA8B1120D9F8A8500B3511A /* MMPlugInManager.m in Sources */,
|
||||
BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */,
|
||||
BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */,
|
||||
BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */,
|
||||
BD9DF0B00DB41E780025C97C /* PlugInGUI.m in Sources */,
|
||||
BD9DF0FB0DB48C860025C97C /* CTGradient.m in Sources */,
|
||||
1D145C7F0E5227CE00691AA0 /* MMTextViewHelper.m in Sources */,
|
||||
1D60088B0E96A0B2003763F0 /* MMFindReplaceController.m in Sources */,
|
||||
1DE63FFB0E71820F00959BDB /* MMCoreTextView.m in Sources */,
|
||||
|
||||
@@ -45,9 +45,6 @@ extern NSString *MMCurrentPreferencePaneKey;
|
||||
extern NSString *MMLoginShellCommandKey;
|
||||
extern NSString *MMLoginShellArgumentKey;
|
||||
extern NSString *MMDialogsTrackPwdKey;
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
extern NSString *MMShowLeftPlugInContainerKey;
|
||||
#endif
|
||||
extern NSString *MMOpenLayoutKey;
|
||||
extern NSString *MMVerticalSplitKey;
|
||||
extern NSString *MMPreloadCacheSizeKey;
|
||||
|
||||
@@ -37,9 +37,6 @@ NSString *MMCurrentPreferencePaneKey = @"MMCurrentPreferencePane";
|
||||
NSString *MMLoginShellCommandKey = @"MMLoginShellCommand";
|
||||
NSString *MMLoginShellArgumentKey = @"MMLoginShellArgument";
|
||||
NSString *MMDialogsTrackPwdKey = @"MMDialogsTrackPwd";
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
NSString *MMShowLeftPlugInContainerKey = @"MMShowLeftPlugInContainer";
|
||||
#endif
|
||||
NSString *MMOpenLayoutKey = @"MMOpenLayout";
|
||||
NSString *MMVerticalSplitKey = @"MMVerticalSplit";
|
||||
NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize";
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "RBSplitView.h"
|
||||
|
||||
|
||||
@class MMPlugInView;
|
||||
@class MMPlugInViewContainer;
|
||||
@class MMPlugInViewController;
|
||||
|
||||
@interface MMPlugInViewHeader : NSView {
|
||||
IBOutlet MMPlugInViewController *controller;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface MMPlugInView : RBSplitSubview {
|
||||
IBOutlet MMPlugInViewController *controller;
|
||||
}
|
||||
|
||||
- (MMPlugInViewController *)controller;
|
||||
|
||||
@end
|
||||
|
||||
@interface MMPlugInViewController : NSObject {
|
||||
IBOutlet RBSplitSubview *plugInSubview;
|
||||
IBOutlet MMPlugInViewHeader *headerView;
|
||||
IBOutlet NSView *contentView;
|
||||
IBOutlet NSTextField *titleField;
|
||||
}
|
||||
|
||||
- (id)initWithView:(NSView *)view title:(NSString *)title;
|
||||
- (void)moveToContainer:(MMPlugInViewContainer *)container;
|
||||
- (RBSplitSubview *)plugInSubview;
|
||||
- (MMPlugInViewContainer *)container;
|
||||
|
||||
// called when the dropView on the container holding this plugin view was
|
||||
// changed, and this was the current dropView or it is the new dropView
|
||||
- (void)dropViewChanged;
|
||||
@end
|
||||
|
||||
@interface MMPlugInViewContainer : RBSplitView {
|
||||
RBSplitSubview *fillerView;
|
||||
|
||||
// only used during drag and drop
|
||||
MMPlugInView *dropView;
|
||||
}
|
||||
|
||||
- (MMPlugInView *)dropView;
|
||||
@end
|
||||
@@ -1,334 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MMPlugInViewHeader
|
||||
*
|
||||
* Essentially just a title bar for a plugin view. Handles drawing the
|
||||
* drag-and-drop line where a new plugin view will be inserted.
|
||||
*
|
||||
* MMPlugInView
|
||||
*
|
||||
* This contains a single view added by a plugin.
|
||||
*
|
||||
* MMPlugInViewContainer
|
||||
*
|
||||
* This contains multiple MMPlugInViews. It handles the drag and drop aspects
|
||||
* of the views, as well.
|
||||
*
|
||||
* Author: Matt Tolton
|
||||
*/
|
||||
#import "MacVim.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
|
||||
#import "PlugInGUI.h"
|
||||
#import "CTGradient.h"
|
||||
|
||||
NSString *MMPlugInViewPboardType = @"MMPlugInViewPboardType";
|
||||
|
||||
@implementation MMPlugInViewHeader
|
||||
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
// Make image from view
|
||||
NSView *view = self;
|
||||
[view lockFocus];
|
||||
NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc]
|
||||
initWithFocusedViewRect: [view bounds]] autorelease];
|
||||
[view unlockFocus];
|
||||
|
||||
NSImage *image = [[[NSImage alloc] initWithSize: [view bounds].size]
|
||||
autorelease];
|
||||
[image addRepresentation:bitmap];
|
||||
|
||||
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
||||
|
||||
[pboard declareTypes:[NSArray arrayWithObject:MMPlugInViewPboardType]
|
||||
owner:self];
|
||||
|
||||
NSPoint pt = [view convertPoint:[view bounds].origin
|
||||
toView:[controller plugInSubview]];
|
||||
[[controller plugInSubview] dragImage:image
|
||||
at:pt
|
||||
offset:NSMakeSize(0, 0)
|
||||
event:theEvent
|
||||
pasteboard:pboard
|
||||
source:controller
|
||||
slideBack:YES];
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
{
|
||||
NSColor *startColor;
|
||||
startColor = [NSColor colorWithCalibratedRed:.600
|
||||
green:.600
|
||||
blue:.600
|
||||
alpha:1.0];
|
||||
|
||||
NSColor *endColor = [NSColor colorWithCalibratedRed:.800
|
||||
green:.800
|
||||
blue:.800
|
||||
alpha:1.0];
|
||||
|
||||
CTGradient *grad = [CTGradient gradientWithBeginningColor:startColor
|
||||
endingColor:endColor];
|
||||
[grad fillRect:[self bounds] angle:90];
|
||||
|
||||
MMPlugInView *dropView = [[controller container] dropView];
|
||||
|
||||
if (dropView == [controller plugInSubview]) {
|
||||
NSRect insertionRect = NSMakeRect(0,[self bounds].size.height - 2,
|
||||
[self bounds].size.width, 2);
|
||||
[[NSColor redColor] set];
|
||||
NSRectFill(insertionRect);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSRect)dragRect
|
||||
{
|
||||
return NSMakeRect(0, [self bounds].size.height - 6, [self bounds].size.width, 6);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MMPlugInView
|
||||
|
||||
- (MMPlugInViewController *)controller
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MMPlugInViewController
|
||||
|
||||
- (id)initWithView:(NSView *)view title:(NSString *)title
|
||||
{
|
||||
if ((self = [super init]) == nil) return nil;
|
||||
|
||||
if (![NSBundle loadNibNamed:@"PlugInView" owner:self])
|
||||
ASLogErr(@"Error loading PlugIn nib");
|
||||
|
||||
[titleField setStringValue:title];
|
||||
|
||||
[plugInSubview setMinDimension:50
|
||||
andMaxDimension:0.0];
|
||||
|
||||
[view setFrame:[contentView bounds]];
|
||||
[contentView addSubview:view];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (RBSplitSubview *)plugInSubview
|
||||
{
|
||||
return plugInSubview;
|
||||
}
|
||||
|
||||
- (void)moveToContainer:(MMPlugInViewContainer *)container
|
||||
{
|
||||
if ([plugInSubview splitView]) {
|
||||
[plugInSubview removeFromSuperview];
|
||||
}
|
||||
[container addSubview:plugInSubview];
|
||||
}
|
||||
|
||||
- (void)moveToContainer:(MMPlugInViewContainer *)container before:(MMPlugInView *)lowerView
|
||||
{
|
||||
if ([plugInSubview splitView]) {
|
||||
[plugInSubview removeFromSuperview];
|
||||
}
|
||||
[container addSubview:plugInSubview positioned:NSWindowBelow relativeTo:lowerView];
|
||||
}
|
||||
|
||||
- (MMPlugInViewHeader *)headerView
|
||||
{
|
||||
return headerView;
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
|
||||
{
|
||||
if (isLocal)
|
||||
return NSDragOperationPrivate;
|
||||
else
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (void)dropViewChanged {
|
||||
[headerView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (MMPlugInViewContainer *)container {
|
||||
return (MMPlugInViewContainer *)[plugInSubview splitView];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MMPlugInViewContainer
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame]) == nil) return nil;
|
||||
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:MMPlugInViewPboardType, nil]];
|
||||
|
||||
[self setVertical:NO];
|
||||
[self setDelegate:self];
|
||||
|
||||
fillerView = [[RBSplitSubview alloc] initWithFrame:NSMakeRect(0,0,0,0)];
|
||||
[fillerView setHidden:YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
ASLogDebug(@"");
|
||||
|
||||
[fillerView release]; fillerView = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (unsigned int)splitView:(RBSplitView*)sender dividerForPoint:(NSPoint)point
|
||||
inSubview:(RBSplitSubview*)subview
|
||||
{
|
||||
MMPlugInViewController *controller = [(MMPlugInView *)subview controller];
|
||||
MMPlugInViewHeader *header = [controller headerView];
|
||||
|
||||
if ([header mouse:[header convertPoint:point fromView:sender]
|
||||
inRect:[header dragRect]])
|
||||
return [subview position] - 1;
|
||||
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
- (NSRect)splitView:(RBSplitView*)sender cursorRect:(NSRect)rect
|
||||
forDivider:(unsigned int)theDivider
|
||||
{
|
||||
|
||||
if (theDivider != 0) return NSZeroRect;
|
||||
|
||||
int i;
|
||||
for (i = 1;; i++) {
|
||||
MMPlugInView *view = (MMPlugInView *)[sender subviewAtPosition:i];
|
||||
if (!view) break;
|
||||
|
||||
MMPlugInViewHeader *header = [[view controller] headerView];
|
||||
NSRect rect = [header dragRect];
|
||||
rect = [sender convertRect:rect fromView:header];
|
||||
[sender addCursorRect:rect
|
||||
cursor:[RBSplitView cursor:RBSVHorizontalCursor]];
|
||||
|
||||
}
|
||||
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (void)clearDragInfo
|
||||
{
|
||||
if (dropView) {
|
||||
MMPlugInView *save = dropView;
|
||||
dropView = nil;
|
||||
[[save controller] dropViewChanged];
|
||||
}
|
||||
}
|
||||
|
||||
// point should be in the window's coordinate system
|
||||
- (void)updateDragInfo:(id<NSDraggingInfo>)info
|
||||
{
|
||||
|
||||
[self clearDragInfo];
|
||||
|
||||
if (!([info draggingSourceOperationMask] & NSDragOperationPrivate)) return;
|
||||
|
||||
if (![[info draggingSource] isKindOfClass:[MMPlugInViewController class]]) return;
|
||||
|
||||
// for now has to be THIS container. in the future, it will be ok for any
|
||||
// container associated with the same vim instance
|
||||
if ([[info draggingSource] container] != self) return;
|
||||
|
||||
// XXX for now we just use the view that the mouse is currently over, and
|
||||
// always insert "above" that view. In the future, we might want to try to
|
||||
// find the divider that the mouse is closest to and have the dropView be
|
||||
// the view below that divider.
|
||||
|
||||
NSPoint point = [info draggingLocation];
|
||||
|
||||
int i;
|
||||
for (i = 0;; i++) {
|
||||
MMPlugInView *subview = (MMPlugInView *)[self subviewAtPosition:i];
|
||||
if (!subview) break;
|
||||
|
||||
if ([subview mouse:[subview convertPoint:point fromView:nil]
|
||||
inRect:[subview bounds]]) {
|
||||
dropView = subview;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ([[info draggingSource] plugInSubview] == dropView)
|
||||
dropView = nil;
|
||||
|
||||
if (dropView) [[dropView controller] dropViewChanged];
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
[self updateDragInfo:sender];
|
||||
|
||||
if (dropView != nil)
|
||||
return NSDragOperationPrivate;
|
||||
else
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
[self updateDragInfo:sender];
|
||||
|
||||
if (dropView != nil)
|
||||
return NSDragOperationPrivate;
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
[self updateDragInfo:sender];
|
||||
return dropView != nil;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
MMPlugInViewController *source = [sender draggingSource];
|
||||
[source moveToContainer:self before:dropView];
|
||||
[self clearDragInfo];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
[self clearDragInfo];
|
||||
}
|
||||
|
||||
|
||||
- (MMPlugInView *)dropView {
|
||||
return dropView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PlugInInterface.h"
|
||||
|
||||
@interface MMPlugInAppMediator : NSObject <PlugInAppMediator> {
|
||||
NSMenu *plugInMenu;
|
||||
}
|
||||
|
||||
+ (MMPlugInAppMediator *)sharedAppMediator;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@class MMVimController;
|
||||
|
||||
// One of these per vim controller object. It manages all of the plugin
|
||||
// instances for a given controller.
|
||||
@interface MMPlugInInstanceMediator : NSObject <PlugInInstanceMediator> {
|
||||
// NB: this is a weak reference to the vim controller
|
||||
MMVimController *vimController;
|
||||
NSMutableArray *instances;
|
||||
NSDrawer *drawer;
|
||||
NSMutableArray *plugInViews ;
|
||||
}
|
||||
|
||||
- (id)initWithVimController:(MMVimController *)controller;
|
||||
|
||||
@end
|
||||
@@ -1,237 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MMPlugInInstanceMediator
|
||||
*
|
||||
* Implementation of the PlugInInstanceMediator protocol. One of these is
|
||||
* created per vim instance. It manages all of the plugin instances for that
|
||||
* vim instance.
|
||||
*
|
||||
* MMPlugInAppMediator
|
||||
*
|
||||
* Implementation of the PlugInAppMediator protocol. Singleton class.
|
||||
*
|
||||
* Author: Matt Tolton
|
||||
*/
|
||||
|
||||
#import "Miscellaneous.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
|
||||
static int MMPlugInArchMajorVersion = 1;
|
||||
static int MMPlugInArchMinorVersion = 0;
|
||||
|
||||
#import "PlugInImpl.h"
|
||||
#import "PlugInGUI.h"
|
||||
#import "MMPlugInManager.h"
|
||||
#import "RBSplitView.h"
|
||||
#import "MMAppController.h"
|
||||
#import "MMVimController.h"
|
||||
|
||||
|
||||
@implementation MMPlugInInstanceMediator
|
||||
|
||||
- (void)setupDrawer
|
||||
{
|
||||
// XXX The drawer does not work in full screen mode. Eventually, the
|
||||
// drawer will go away so I'm ignoring this issue for now.
|
||||
drawer = [[NSDrawer alloc] initWithContentSize:NSMakeSize(200,100)
|
||||
preferredEdge:NSMinXEdge];
|
||||
|
||||
|
||||
NSSize contentSize = [drawer contentSize];
|
||||
|
||||
// XXX memory management for this
|
||||
MMPlugInViewContainer *containerView = [[MMPlugInViewContainer alloc]
|
||||
initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];
|
||||
|
||||
[drawer setContentView:containerView];
|
||||
|
||||
[containerView release];
|
||||
|
||||
[drawer setParentWindow:[[vimController windowController] window]];
|
||||
}
|
||||
|
||||
- (void)toggleDrawer
|
||||
{
|
||||
[drawer toggle:nil];
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setBool:[drawer state] == NSDrawerOpenState
|
||||
|| [drawer state] == NSDrawerOpeningState
|
||||
forKey:MMShowLeftPlugInContainerKey];
|
||||
}
|
||||
|
||||
- (void)initializeInstances
|
||||
{
|
||||
NSArray *plugInClasses = [[MMPlugInManager sharedManager] plugInClasses];
|
||||
int i, count = [plugInClasses count];
|
||||
for (i = 0; i < count; i++) {
|
||||
Class plugInClass = [plugInClasses objectAtIndex:i];
|
||||
if ([plugInClass instancesRespondToSelector:
|
||||
@selector(initWithMediator:)]) {
|
||||
id instance = [[[plugInClass alloc] initWithMediator:self] autorelease];
|
||||
[instances addObject:instance];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithVimController:(MMVimController *)controller
|
||||
{
|
||||
if ((self = [super init]) == nil) return nil;
|
||||
vimController = controller;
|
||||
instances = [[NSMutableArray alloc] init];
|
||||
plugInViews = [[NSMutableArray alloc] init];
|
||||
|
||||
[self setupDrawer];
|
||||
[self initializeInstances];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
ASLogDebug(@"");
|
||||
|
||||
[plugInViews release]; plugInViews = nil;
|
||||
[instances release]; instances = nil;
|
||||
[drawer release]; drawer = nil;
|
||||
vimController = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)evaluateVimExpression:(NSString *)vimExpression
|
||||
{
|
||||
NSString *errstr = nil;
|
||||
id res = [vimController evaluateVimExpressionCocoa:vimExpression
|
||||
errorString:&errstr];
|
||||
if (!res) {
|
||||
// Setting format to %@ instead of just passing errstr avoids warning.
|
||||
[NSException raise:@"VimEvaluationException" format:@"%@", errstr];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
- (void)addVimInput:(NSString *)input
|
||||
{
|
||||
[vimController addVimInput:input];
|
||||
}
|
||||
|
||||
- (void)addPlugInView:(NSView *)view withTitle:(NSString *)title
|
||||
{
|
||||
// Do this here so that the drawer is never opened automatically when there
|
||||
// are no plugin views.
|
||||
if ([[NSUserDefaults standardUserDefaults]
|
||||
boolForKey:MMShowLeftPlugInContainerKey] && [plugInViews count] == 0)
|
||||
[drawer open];
|
||||
|
||||
MMPlugInViewController *newView =
|
||||
[[MMPlugInViewController alloc] initWithView:view title:title];
|
||||
|
||||
[plugInViews addObject:newView];
|
||||
|
||||
[newView moveToContainer:(MMPlugInViewContainer *)[drawer contentView]];
|
||||
|
||||
[newView release];
|
||||
}
|
||||
|
||||
- (void)openFiles:(NSArray *)filenames
|
||||
{
|
||||
[vimController dropFiles:filenames forceOpen:YES];
|
||||
}
|
||||
|
||||
- (id)instanceWithClass:(Class)class
|
||||
{
|
||||
int i, count = [instances count];
|
||||
for (i = 0; i < count; i++) {
|
||||
id instance = [instances objectAtIndex:i];
|
||||
if ([instance isKindOfClass:class])
|
||||
return instance;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MMPlugInAppMediator
|
||||
|
||||
MMPlugInAppMediator *sharedAppMediator = nil;
|
||||
|
||||
+ (MMPlugInAppMediator *)sharedAppMediator
|
||||
{
|
||||
if (sharedAppMediator == nil)
|
||||
sharedAppMediator = [[MMPlugInAppMediator alloc] init];
|
||||
|
||||
return sharedAppMediator;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]) == nil) return nil;
|
||||
|
||||
NSString *title = NSLocalizedString(@"Toggle Left Drawer",
|
||||
@"Toggle Left Drawer menu title");
|
||||
NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title
|
||||
action:@selector(toggleLeftDrawer:)
|
||||
keyEquivalent:@""] autorelease];
|
||||
[item setTarget:self];
|
||||
[self addPlugInMenuItem:item];
|
||||
[self addPlugInMenuItem:[NSMenuItem separatorItem]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)toggleLeftDrawer:(id)sender
|
||||
{
|
||||
MMVimController *c = [[MMAppController sharedInstance] keyVimController];
|
||||
|
||||
[[c instanceMediator] toggleDrawer];
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
return [[MMAppController sharedInstance] keyVimController] != nil;
|
||||
}
|
||||
|
||||
- (void)addPlugInMenuItem:(NSMenuItem *)menuItem
|
||||
{
|
||||
NSAssert(menuItem, @"menuItem cannot be nil");
|
||||
[[MMAppController sharedInstance] addItemToPlugInMenu:menuItem];
|
||||
}
|
||||
|
||||
// It is a little bit ugly having to pass the class in here. An alternative
|
||||
// would be to have a 1:1 relationship between app mediators and plugins, so
|
||||
// that we'd know exactly which plugin class to look for.
|
||||
- (id)keyPlugInInstanceWithClass:(Class)class
|
||||
{
|
||||
MMVimController *keyVimController = [[NSApp delegate] keyVimController];
|
||||
|
||||
if (keyVimController)
|
||||
return [[keyVimController instanceMediator] instanceWithClass:class];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (int)majorVersion
|
||||
{
|
||||
return MMPlugInArchMajorVersion;
|
||||
}
|
||||
|
||||
- (int)minorVersion
|
||||
{
|
||||
return MMPlugInArchMinorVersion;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 ft=objc:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* MacVim GUI port by Bjorn Winckler
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
* See README.txt for an overview of the Vim source code.
|
||||
*/
|
||||
|
||||
// This header file should include everything that a plug-in will need so that
|
||||
// it is all we need to distribute for plug-in developers.
|
||||
|
||||
/*
|
||||
* PlugInAppMediator
|
||||
*
|
||||
* The interface that the plugin may use to interact with the MacVim
|
||||
* application.
|
||||
*
|
||||
* PlugInInstanceMediator
|
||||
*
|
||||
* The interface that a plugin may use to interact with a specific vim instance
|
||||
* within MacVim.
|
||||
*
|
||||
* PlugInProtocol
|
||||
*
|
||||
* The protocol which the principal class of the plugin must conform to.
|
||||
*
|
||||
* Author: Matt Tolton
|
||||
*
|
||||
*/
|
||||
|
||||
@protocol PlugInAppMediator
|
||||
|
||||
- (void)addPlugInMenuItem:(NSMenuItem *)menuItem;
|
||||
|
||||
// Returns the plugin instance of the specified class associated with the key vim window.
|
||||
// If a vim window is not the key window, returns nil.
|
||||
// If there are no instances with the specified class, returns nil.
|
||||
- (id)keyPlugInInstanceWithClass:(Class)class;
|
||||
|
||||
// Plugin architecture version. Major versions indicate API incompatibilities.
|
||||
// Minor versions may include additions, but nothing that should break current
|
||||
// plugins.
|
||||
- (int)majorVersion;
|
||||
- (int)minorVersion;
|
||||
|
||||
@end
|
||||
|
||||
@protocol PlugInInstanceMediator
|
||||
|
||||
// vim values are converted into NSNumber, NSString, NSArray, and NSDictionary
|
||||
- (id)evaluateVimExpression:(NSString *)vimExpression;
|
||||
- (void)addVimInput:(NSString *)input;
|
||||
- (void)openFiles:(NSArray *)fileNames;
|
||||
- (void)addPlugInView:(NSView *)view withTitle:(NSString *)title;
|
||||
|
||||
@end
|
||||
|
||||
@protocol PlugInProtocol
|
||||
// The mediator should not be retained. It will exist until terminatePlugIn is
|
||||
// called.
|
||||
+ (BOOL)initializePlugIn:(id<PlugInAppMediator>)mediator;
|
||||
+ (void)terminatePlugIn;
|
||||
@end
|
||||
|
||||
@interface NSObject (PlugInProtocol)
|
||||
// The mediator should not be retained. It will exist until it releases this
|
||||
// plugin instance, and is not valid after that.
|
||||
- (id)initWithMediator:(id<PlugInInstanceMediator>)mediator;
|
||||
@end
|
||||
|
||||
Generated
-98
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBClasses</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>MMPlugInView</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>controller</key>
|
||||
<string>MMPlugInViewController</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>RBSplitSubview</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>MMPlugInViewController</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>contentView</key>
|
||||
<string>NSView</string>
|
||||
<key>headerView</key>
|
||||
<string>MMPlugInViewHeader</string>
|
||||
<key>plugInSubview</key>
|
||||
<string>RBSplitSubview</string>
|
||||
<key>titleField</key>
|
||||
<string>NSTextField</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>RBSplitView</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>delegate</key>
|
||||
<string>id</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>RBSplitSubview</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>RBSplitSubview</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSView</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>FirstResponder</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ACTIONS</key>
|
||||
<dict>
|
||||
<key>didAdjustSubviews</key>
|
||||
<string>RBSplitView</string>
|
||||
<key>willAdjustSubviews</key>
|
||||
<string>RBSplitView</string>
|
||||
</dict>
|
||||
<key>CLASS</key>
|
||||
<string>NSObject</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>MMPlugInViewHeader</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>controller</key>
|
||||
<string>MMPlugInViewController</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSView</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>IBVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Generated
-20
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBFramework Version</key>
|
||||
<string>629</string>
|
||||
<key>IBLastKnownRelativeProjectPath</key>
|
||||
<string>../MacVim.xcodeproj</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>6</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>9D34</string>
|
||||
<key>targetFramework</key>
|
||||
<string>IBCocoaFramework</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -1,146 +0,0 @@
|
||||
//
|
||||
// RBSplitSubview.h version 1.1.4
|
||||
// RBSplitView
|
||||
//
|
||||
// Created by Rainer Brockerhoff on 19/11/2004.
|
||||
// Copyright 2004-2006 Rainer Brockerhoff.
|
||||
// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class RBSplitView;
|
||||
|
||||
// These values are used to inquire about the status of a subview.
|
||||
typedef enum {
|
||||
RBSSubviewExpanding=-2,
|
||||
RBSSubviewCollapsing=-1,
|
||||
RBSSubviewNormal=0,
|
||||
RBSSubviewCollapsed=1
|
||||
} RBSSubviewStatus;
|
||||
|
||||
@interface RBSplitSubview : NSView {
|
||||
// Subclasses normally should use setter methods instead of changing instance variables by assignment.
|
||||
// Most getter methods simply return the corresponding instance variable, so with some care, subclasses
|
||||
// could reference them directly.
|
||||
NSString* identifier; // An identifier string for the subview, default is @"".
|
||||
int tag; // A tag integer for the subview, default is 0.
|
||||
float minDimension; // The minimum dimension. Must be 1.0 or any larger integer.
|
||||
float maxDimension; // The maximum dimension. Must be at least equal to the minDimension.
|
||||
// Set to a large number if there's no maximum.
|
||||
double fraction; // A fractional part of the dimension, used for proportional resizing.
|
||||
// Normally varies between -0.999... and 0.999...
|
||||
// When collapsed, holds the proportion of the RBSplitView's dimension
|
||||
// the view was occupying before collapsing.
|
||||
NSRect previous; // Holds the frame rect for the last delegate notification.
|
||||
NSSize savedSize; // This holds the size the subview had before it was resized beyond
|
||||
// its minimum or maximum limits. Valid if notInLimits is YES.
|
||||
unsigned int actDivider; // This is set temporarily while an alternate drag view is being dragged.
|
||||
BOOL canDragWindow; // This is set temporarily during a mouseDown on a non-opaque subview.
|
||||
BOOL canCollapse; // YES if the subview can be collapsed.
|
||||
BOOL notInLimits; // YES if the subview's dimensions are outside the set limits.
|
||||
}
|
||||
|
||||
// This class method returns YES if some RBSplitSubview is being animated.
|
||||
+ (BOOL)animating;
|
||||
|
||||
// This is the designated initializer for creating extra subviews programmatically.
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
|
||||
// Returns the immediately containing RBSplitView, or nil if there is none.
|
||||
// couplingSplitView returns nil if we're a non-coupled RBSplitView.
|
||||
// outermostSplitView returns the outermost RBSplitView.
|
||||
- (RBSplitView*)splitView;
|
||||
- (RBSplitView*)couplingSplitView;
|
||||
- (RBSplitView*)outermostSplitView;
|
||||
|
||||
// Returns self if we're a RBSplitView, nil otherwise. Convenient for testing or calling methods.
|
||||
// coupledSplitView returns nil if we're a non-coupled RBSplitView.
|
||||
- (RBSplitView*)asSplitView;
|
||||
- (RBSplitView*)coupledSplitView;
|
||||
|
||||
// Sets and gets the coupling between the view and its containing RBSplitView (if any). Coupled
|
||||
// RBSplitViews take some parameters, such as divider images, from the containing view. The default
|
||||
// for RBSplitView is YES. However, calling setCoupled: on a RBSplitSubview will have no effect,
|
||||
// and isCoupled will always return false.
|
||||
- (void)setCoupled:(BOOL)flag;
|
||||
- (BOOL)isCoupled;
|
||||
|
||||
// Returns YES if the containing RBSplitView is horizontal.
|
||||
- (BOOL)splitViewIsHorizontal;
|
||||
|
||||
// Returns the number of subviews. Just a convenience method.
|
||||
- (unsigned)numberOfSubviews;
|
||||
|
||||
// Sets and gets the tag.
|
||||
- (void)setTag:(int)theTag;
|
||||
- (int)tag;
|
||||
|
||||
// Sets and gets the identifier string. Will never be nil.
|
||||
- (void)setIdentifier:(NSString*)aString;
|
||||
- (NSString*)identifier;
|
||||
|
||||
// Position means the subview's position within the RBSplitView - counts from zero left to right
|
||||
// or top to bottom. Setting it will move the subview to another position without changing its size,
|
||||
// status or attributes. Set position to 0 to move it to the start, or to some large number to move it
|
||||
// to the end of the RBSplitView.
|
||||
- (unsigned)position;
|
||||
- (void)setPosition:(unsigned)newPosition;
|
||||
|
||||
// Returns YES if the subview is collapsed. Collapsed subviews are squashed down to zero but never
|
||||
// made smaller than the minimum dimension as far as their own subviews are concerned. If the
|
||||
// subview is being animated this will return NO.
|
||||
- (BOOL)isCollapsed;
|
||||
|
||||
// This will return the current status of the subview. Negative values mean the subview is
|
||||
// being animated.
|
||||
- (RBSSubviewStatus)status;
|
||||
|
||||
// Sets and gets the ability to collapse the subview. However, this can be overridden by the delegate.
|
||||
- (BOOL)canCollapse;
|
||||
- (void)setCanCollapse:(BOOL)flag;
|
||||
|
||||
// Tests whether the subview can shrink or expand further.
|
||||
- (BOOL)canShrink;
|
||||
- (BOOL)canExpand;
|
||||
|
||||
// Sets and gets the minimum and maximum dimensions. They're set at the same time to make sure values
|
||||
// are consistent. Despite being floats, they'll always have integer values. The minimum value for the
|
||||
// minimum is 1.0. Pass 0.0 for the maximum to set it to some huge number.
|
||||
- (float)minDimension;
|
||||
- (float)maxDimension;
|
||||
- (void)setMinDimension:(float)newMinDimension andMaxDimension:(float)newMaxDimension;
|
||||
|
||||
// Call this to expand a subview programmatically. It will return the subview's dimension after
|
||||
// expansion.
|
||||
- (float)expand;
|
||||
|
||||
// Call this to collapse a subview programmatically. It will return the negative
|
||||
// of the subview's dimension _before_ collapsing, or 0.0 if the subview can't be collapsed.
|
||||
- (float)collapse;
|
||||
|
||||
// These calls collapse and expand subviews with animation. They return YES if animation
|
||||
// startup was successful.
|
||||
- (BOOL)collapseWithAnimation;
|
||||
- (BOOL)expandWithAnimation;
|
||||
|
||||
// These methods collapse and expand subviews with animation, depending on the parameters.
|
||||
// They return YES if animation startup was successful. If resize is NO, the subview is
|
||||
// collapsed/expanded without resizing it during animation.
|
||||
- (BOOL)collapseWithAnimation:(BOOL)animate withResize:(BOOL)resize;
|
||||
- (BOOL)expandWithAnimation:(BOOL)animate withResize:(BOOL)resize;
|
||||
|
||||
// Returns the current dimension of the subview.
|
||||
- (float)dimension;
|
||||
|
||||
// Sets the current dimension of the subview, subject to the current maximum and minimum.
|
||||
// If the subview is collapsed, this has no immediate effect.
|
||||
- (void)setDimension:(float)value;
|
||||
|
||||
// This method is used internally when a divider is dragged. It tries to change the subview's dimension
|
||||
// and returns the actual change, collapsing or expanding whenever possible. You usually won't need
|
||||
// to call this directly.
|
||||
- (float)changeDimensionBy:(float)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,929 +0,0 @@
|
||||
//
|
||||
// RBSplitSubview.m version 1.1.4
|
||||
// RBSplitView
|
||||
//
|
||||
// Created by Rainer Brockerhoff on 19/11/2004.
|
||||
// Copyright 2004-2006 Rainer Brockerhoff.
|
||||
// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License.
|
||||
//
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
|
||||
#import "RBSplitView.h"
|
||||
#import "RBSplitViewPrivateDefines.h"
|
||||
|
||||
// This variable points to the animation data structure while an animation is in
|
||||
// progress; if there's none, it will be NULL. Animating may be very CPU-intensive so
|
||||
// we allow only one animation to take place at a time.
|
||||
static animationData* currentAnimation = NULL;
|
||||
|
||||
@implementation RBSplitSubview
|
||||
|
||||
// This class method returns YES if an animation is in progress.
|
||||
+ (BOOL)animating {
|
||||
return currentAnimation!=NULL;
|
||||
}
|
||||
|
||||
// This is the designated initializer for RBSplitSubview. It sets some reasonable defaults. However, you
|
||||
// can't rely on anything working until you insert it into a RBSplitView.
|
||||
- (id)initWithFrame:(NSRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
fraction = 0.0;
|
||||
canCollapse = NO;
|
||||
notInLimits = NO;
|
||||
minDimension = 1.0;
|
||||
maxDimension = WAYOUT;
|
||||
identifier = @"";
|
||||
previous = NSZeroRect;
|
||||
savedSize = frame.size;
|
||||
actDivider = NSNotFound;
|
||||
canDragWindow = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Just releases our stuff when going away.
|
||||
- (void)dealloc {
|
||||
[identifier release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// These return nil since we're not a RBSplitView (they're overridden there).
|
||||
- (RBSplitView*)asSplitView {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (RBSplitView*)coupledSplitView {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Sets and gets the coupling between a RBSplitView and its containing RBSplitView (if any).
|
||||
// For convenience, these methods are also implemented here.
|
||||
- (void)setCoupled:(BOOL)flag {
|
||||
}
|
||||
|
||||
- (BOOL)isCoupled {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// RBSplitSubviews are never flipped, unless they're RBSplitViews.
|
||||
- (BOOL)isFlipped {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We copy the opacity of the owning split view.
|
||||
- (BOOL)isOpaque {
|
||||
return [[self couplingSplitView] isOpaque];
|
||||
}
|
||||
|
||||
// A hidden RBSplitSubview is not redrawn and is not considered for drawing dividers.
|
||||
// This won't work before 10.3, though.
|
||||
- (void)setHidden:(BOOL)flag {
|
||||
if ([self isHidden]!=flag) {
|
||||
RBSplitView* sv = [self splitView];
|
||||
[self RB___setHidden:flag];
|
||||
if (flag) {
|
||||
[sv adjustSubviews];
|
||||
} else {
|
||||
[sv adjustSubviewsExcepting:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RBSplitSubviews can't be in the responder chain.
|
||||
- (BOOL)acceptsFirstResponder {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Mousing down should move the window only for a completely transparent background. This might have
|
||||
// unintended side effects in metal windows, so for those you might want to use a background color
|
||||
// with a very low alpha (0.01 for instance).
|
||||
// This is commented out as I'm still experimenting with it.
|
||||
/*- (BOOL)mouseDownCanMoveWindow {
|
||||
RBSplitView* sv = [self asSplitView];
|
||||
if (!sv) {
|
||||
sv = [self couplingSplitView];
|
||||
}
|
||||
return [sv background]==nil;
|
||||
return YES;
|
||||
}*/
|
||||
|
||||
// This returns the owning splitview. It's guaranteed to return a RBSplitView or nil.
|
||||
// You should avoid having "orphan" RBSplitSubviews, or at least manipulating
|
||||
// them while they're not inserted in a RBSplitView.
|
||||
- (RBSplitView*)splitView {
|
||||
id result = [self superview];
|
||||
if ([result isKindOfClass:[RBSplitView class]]) {
|
||||
return (RBSplitView*)result;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// This also returns the owning splitview. It's overridden for nested RBSplitViews.
|
||||
- (RBSplitView*)couplingSplitView {
|
||||
id result = [self superview];
|
||||
if ([result isKindOfClass:[RBSplitView class]]) {
|
||||
return (RBSplitView*)result;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// This returns the outermost directly containing RBSplitView, or nil.
|
||||
- (RBSplitView*)outermostSplitView {
|
||||
id result = nil;
|
||||
id sv = self;
|
||||
while ((sv = [sv superview])&&[sv isKindOfClass:[RBSplitView class]]) {
|
||||
result = sv;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// This convenience method returns YES if the containing RBSplitView is horizontal.
|
||||
- (BOOL)splitViewIsHorizontal {
|
||||
return [[self splitView] isHorizontal];
|
||||
}
|
||||
|
||||
// You can use either tags (ints) or identifiers (NSStrings) to identify individual subviews.
|
||||
// We take care not to have nil identifiers.
|
||||
- (void)setTag:(int)theTag {
|
||||
tag = theTag;
|
||||
}
|
||||
|
||||
- (int)tag {
|
||||
return tag;
|
||||
}
|
||||
|
||||
- (void)setIdentifier:(NSString*)aString {
|
||||
[identifier autorelease];
|
||||
identifier = aString?[aString retain]:@"";
|
||||
}
|
||||
|
||||
- (NSString*)identifier {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
// If we have an identifier, this will make debugging a little easier by appending it to the
|
||||
// default description.
|
||||
- (NSString*)description {
|
||||
return [identifier length]>0?[NSString stringWithFormat:@"%@(%@)",[super description],identifier]:[super description];
|
||||
}
|
||||
|
||||
// This pair of methods allows you to get and change the position of a subview (within the split view);
|
||||
// this counts from zero from the left or top of the split view.
|
||||
- (unsigned)position {
|
||||
RBSplitView* sv = [self splitView];
|
||||
return sv?[[sv subviews] indexOfObjectIdenticalTo:self]:0;
|
||||
}
|
||||
|
||||
- (void)setPosition:(unsigned)newPosition {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv) {
|
||||
[self retain];
|
||||
[self removeFromSuperviewWithoutNeedingDisplay];
|
||||
NSArray* subviews = [sv subviews];
|
||||
if (newPosition>=[subviews count]) {
|
||||
[sv addSubview:self positioned:NSWindowAbove relativeTo:nil];
|
||||
} else {
|
||||
[sv addSubview:self positioned:NSWindowBelow relativeTo:[subviews objectAtIndex:newPosition]];
|
||||
}
|
||||
[self release];
|
||||
}
|
||||
}
|
||||
|
||||
// Tests whether the subview is collapsed.
|
||||
- (BOOL)isCollapsed {
|
||||
return [self RB___visibleDimension]<=0.0;
|
||||
}
|
||||
|
||||
// Tests whether the subview can shrink further.
|
||||
- (BOOL)canShrink {
|
||||
return [self RB___visibleDimension]>([self canCollapse]?0.0:minDimension);
|
||||
}
|
||||
|
||||
// Tests whether the subview can expand further.
|
||||
- (BOOL)canExpand {
|
||||
return [self RB___visibleDimension]<maxDimension;
|
||||
}
|
||||
|
||||
// Returns the subview's status.
|
||||
- (RBSSubviewStatus)status {
|
||||
animationData* anim = [self RB___animationData:NO resize:NO];
|
||||
if (anim) {
|
||||
return anim->collapsing?RBSSubviewCollapsing:RBSSubviewExpanding;
|
||||
}
|
||||
return [self RB___visibleDimension]<=0.0?RBSSubviewCollapsed:RBSSubviewNormal;
|
||||
}
|
||||
|
||||
// Tests whether the subview can be collapsed. The local instance variable will be overridden by the
|
||||
// delegate method if it's implemented.
|
||||
- (BOOL)canCollapse {
|
||||
BOOL result = canCollapse;
|
||||
RBSplitView* sv = [self splitView];
|
||||
if ([sv RB___numberOfSubviews]<2) {
|
||||
return NO;
|
||||
}
|
||||
id delegate = [sv delegate];
|
||||
if ([delegate respondsToSelector:@selector(splitView:canCollapse:)]) {
|
||||
result = [delegate splitView:sv canCollapse:self];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// This sets the subview's "canCollapse" flag. Ignored if the delegate's splitView:canCollapse:
|
||||
// method is implemented.
|
||||
- (void)setCanCollapse:(BOOL)flag {
|
||||
canCollapse = flag;
|
||||
}
|
||||
|
||||
// This expands a collapsed subview and calls the delegate's splitView:didExpand: method, if it exists.
|
||||
// This is not called internally by other methods; call this to expand a subview programmatically.
|
||||
// As a convenience to other methods, it returns the subview's dimension after expanding (this may be
|
||||
// off by 1 pixel due to rounding) or 0.0 if it couldn't be expanded.
|
||||
// The delegate should not change the subview's frame.
|
||||
- (float)expand {
|
||||
return [self RB___expandAndSetToMinimum:NO];
|
||||
}
|
||||
|
||||
// This collapses an expanded subview and calls the delegate's splitView:didCollapse: method, if it exists.
|
||||
// This is not called internally by other methods; call this to expand a subview programmatically.
|
||||
// As a convenience to other methods, it returns the negative of the subview's dimension before
|
||||
// collapsing (or 0.0 if it couldn't be collapsed).
|
||||
// The delegate should not change the subview's frame.
|
||||
- (float)collapse {
|
||||
return [self RB___collapse];
|
||||
}
|
||||
|
||||
// This tries to collapse the subview with animation, and collapses it instantly if some other
|
||||
// subview is animating. Returns YES if animation was started successfully.
|
||||
- (BOOL)collapseWithAnimation {
|
||||
return [self collapseWithAnimation:YES withResize:YES];
|
||||
}
|
||||
|
||||
// This tries to expand the subview with animation, and expands it instantly if some other
|
||||
// subview is animating. Returns YES if animation was started successfully.
|
||||
- (BOOL)expandWithAnimation {
|
||||
return [self expandWithAnimation:YES withResize:YES];
|
||||
}
|
||||
|
||||
// These methods collapse and expand subviews with animation, depending on the parameters.
|
||||
// They return YES if animation startup was successful. If resize is NO, the subview is
|
||||
// collapsed/expanded without resizing it during animation.
|
||||
- (BOOL)collapseWithAnimation:(BOOL)animate withResize:(BOOL)resize {
|
||||
if ([self status]==RBSSubviewNormal) {
|
||||
if ([self canCollapse]) {
|
||||
if (animate&&[self RB___animationData:YES resize:resize]) {
|
||||
[self RB___clearResponder];
|
||||
[self RB___stepAnimation];
|
||||
return YES;
|
||||
} else {
|
||||
[self RB___collapse];
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)expandWithAnimation:(BOOL)animate withResize:(BOOL)resize {
|
||||
if ([self status]==RBSSubviewCollapsed) {
|
||||
if (animate&&[self RB___animationData:YES resize:resize]) {
|
||||
[self RB___stepAnimation];
|
||||
return YES;
|
||||
} else {
|
||||
[self RB___expandAndSetToMinimum:NO];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
// These 3 methods get and set the view's minimum and maximum dimensions.
|
||||
// The minimum dimension ought to be an integer at least equal to 1.0 but we make sure.
|
||||
// The maximum dimension ought to be an integer at least equal to the minimum. As a convenience,
|
||||
// pass in zero to set it to some huge number.
|
||||
- (float)minDimension {
|
||||
return minDimension;
|
||||
}
|
||||
|
||||
- (float)maxDimension {
|
||||
return maxDimension;
|
||||
}
|
||||
|
||||
- (void)setMinDimension:(float)newMinDimension andMaxDimension:(float)newMaxDimension {
|
||||
minDimension = MAX(1.0,floorf(newMinDimension));
|
||||
if (newMaxDimension<1.0) {
|
||||
newMaxDimension = WAYOUT;
|
||||
}
|
||||
maxDimension = MAX(minDimension,floorf(newMaxDimension));
|
||||
float dim = [self dimension];
|
||||
if ((dim<minDimension)||(dim>maxDimension)) {
|
||||
[[self splitView] setMustAdjust];
|
||||
}
|
||||
}
|
||||
|
||||
// This returns the subview's dimension. If it's collapsed, it returns the dimension it would have
|
||||
// after expanding.
|
||||
- (float)dimension {
|
||||
float dim = [self RB___visibleDimension];
|
||||
if (dim<=0.0) {
|
||||
dim = [[self splitView] RB___dimensionWithoutDividers]*fraction;
|
||||
if (dim<minDimension) {
|
||||
dim = minDimension;
|
||||
} else if (dim>maxDimension) {
|
||||
dim = maxDimension;
|
||||
}
|
||||
}
|
||||
return dim;
|
||||
}
|
||||
|
||||
// Sets the current dimension of the subview, subject to the current maximum and minimum.
|
||||
// If the subview is collapsed, this will have an effect only after reexpanding.
|
||||
- (void)setDimension:(float)value {
|
||||
RBSplitView* sv = [self splitView];
|
||||
NSSize size = [self frame].size;
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
if (DIM(size)>0.0) {
|
||||
// We're not collapsed, set the size and adjust other subviews.
|
||||
DIM(size) = value;
|
||||
[self setFrameSize:size];
|
||||
[sv adjustSubviewsExcepting:self];
|
||||
} else {
|
||||
// We're collapsed, adjust the fraction so that we'll have the (approximately) correct
|
||||
// dimension after expanding.
|
||||
fraction = value/[sv RB___dimensionWithoutDividers];
|
||||
}
|
||||
}
|
||||
|
||||
// This just draws the background of a subview, then tells the delegate, if any.
|
||||
// The delegate would usually draw a frame inside the subview.
|
||||
- (void)drawRect:(NSRect)rect {
|
||||
RBSplitView* sv = [self splitView];
|
||||
NSColor* bg = [sv background];
|
||||
if (bg) {
|
||||
[bg set];
|
||||
NSRectFillUsingOperation(rect,NSCompositeSourceOver);
|
||||
}
|
||||
id del = [sv delegate];
|
||||
if ([del respondsToSelector:@selector(splitView:willDrawSubview:inRect:)]) {
|
||||
[del splitView:sv willDrawSubview:self inRect:rect];
|
||||
}
|
||||
}
|
||||
|
||||
// We check if the RBSplitView must be adjusted before redisplaying programmatically.
|
||||
// if so, we adjust and display the whole RBSplitView.
|
||||
- (void)display {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv) {
|
||||
if ([sv mustAdjust]) {
|
||||
[sv display];
|
||||
} else {
|
||||
[super display];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RBSplitSubviews will always resize their own subviews.
|
||||
- (BOOL)autoresizesSubviews {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// This is method is called automatically when the subview is resized; don't call it yourself.
|
||||
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv) {
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
NSRect frame = [self frame];
|
||||
float dim = DIM(frame.size);
|
||||
float other = OTHER(frame.size);
|
||||
// We resize subviews only when we're inside the subview's limits and the containing splitview's limits.
|
||||
animationData* anim = [self RB___animationData:NO resize:NO];
|
||||
if ((dim>=(anim&&!anim->resizing?anim->dimension:minDimension))&&(dim<=maxDimension)&&(other>=[sv minDimension])&&(other<=[sv maxDimension])) {
|
||||
if (notInLimits) {
|
||||
// The subviews can be resized, so we restore the saved size.
|
||||
oldBoundsSize = savedSize;
|
||||
}
|
||||
// We save the size every time the subview's subviews are resized within the limits.
|
||||
notInLimits = NO;
|
||||
savedSize = frame.size;
|
||||
[super resizeSubviewsWithOldSize:oldBoundsSize];
|
||||
} else {
|
||||
notInLimits = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This method is used internally when a divider is dragged. It tries to change the subview's dimension
|
||||
// and returns the actual change, collapsing or expanding whenever possible. You usually won't need
|
||||
// to call this directly.
|
||||
- (float)changeDimensionBy:(float)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (!sv||(fabsf(increment)<1.0)) {
|
||||
return 0.0;
|
||||
}
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
NSRect frame = [self frame];
|
||||
float olddim = DIM(frame.size);
|
||||
float newdim = MAX(0.0,olddim+increment);
|
||||
if (newdim<olddim) {
|
||||
if (newdim<minDimension) {
|
||||
// Collapse if needed
|
||||
if (mayCollapse&&[self canCollapse]&&(newdim<MAX(1.0,minDimension*(0.5-HYSTERESIS)))) {
|
||||
return [self RB___collapse];
|
||||
}
|
||||
newdim = minDimension;
|
||||
}
|
||||
} else if (newdim>olddim) {
|
||||
if (olddim<1.0) {
|
||||
// Expand if needed.
|
||||
if (newdim>(minDimension*(0.5+HYSTERESIS))) {
|
||||
newdim = MAX(newdim,[self RB___expandAndSetToMinimum:YES]);
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
if (newdim>maxDimension) {
|
||||
newdim = maxDimension;
|
||||
}
|
||||
}
|
||||
if ((int)newdim!=(int)olddim) {
|
||||
// The dimension has changed.
|
||||
increment = newdim-olddim;
|
||||
DIM(frame.size) = newdim;
|
||||
if (move) {
|
||||
DIM(frame.origin) -= increment;
|
||||
}
|
||||
// We call super instead of self here to postpone adjusting subviews for nested splitviews.
|
||||
// [super setFrameSize:frame.size];
|
||||
[super setFrame:frame];
|
||||
[sv RB___setMustClearFractions];
|
||||
[sv setMustAdjust];
|
||||
}
|
||||
return newdim-olddim;
|
||||
}
|
||||
|
||||
// This convenience method returns the number of subviews (surprise!)
|
||||
- (unsigned)numberOfSubviews {
|
||||
return [[self subviews] count];
|
||||
}
|
||||
|
||||
// We return the deepest subview that's hit by aPoint. We also check with the delegate if aPoint is
|
||||
// within an alternate drag view.
|
||||
- (NSView*)hitTest:(NSPoint)aPoint {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if ([self mouse:aPoint inRect:[self frame]]) {
|
||||
id delegate = [sv delegate];
|
||||
if ([delegate respondsToSelector:@selector(splitView:dividerForPoint:inSubview:)]) {
|
||||
actDivider = [delegate splitView:sv dividerForPoint:aPoint inSubview:self];
|
||||
if ((int)actDivider<(int)([sv RB___numberOfSubviews]-1)) {
|
||||
return self;
|
||||
}
|
||||
}
|
||||
actDivider = NSNotFound;
|
||||
NSView* result = [super hitTest:aPoint];
|
||||
canDragWindow = ![result isOpaque];
|
||||
return result;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// This method handles clicking and dragging in an empty portion of the subview, or in an alternate
|
||||
// drag view as designated by the delegate.
|
||||
- (void)mouseDown:(NSEvent*)theEvent {
|
||||
NSWindow* window = [self window];
|
||||
NSPoint where = [theEvent locationInWindow];
|
||||
if (actDivider<NSNotFound) {
|
||||
// The mouse down was inside an alternate drag view; actDivider was just set in hitTest.
|
||||
RBSplitView* sv = [self splitView];
|
||||
NSPoint point = [sv convertPoint:where fromView:nil];
|
||||
[[RBSplitView cursor:RBSVDragCursor] push];
|
||||
NSPoint base = NSZeroPoint;
|
||||
// Record the current divider coordinate.
|
||||
float divc = [sv RB___dividerOrigin:actDivider];
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
[sv RB___setDragging:YES];
|
||||
// Loop while the button is down.
|
||||
while ((theEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask|NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES])&&([theEvent type]!=NSLeftMouseUp)) {
|
||||
// Set up a local autorelease pool for the loop to prevent buildup of temporary objects.
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSDisableScreenUpdates();
|
||||
// This does the actual movement.
|
||||
[sv RB___trackMouseEvent:theEvent from:point withBase:base inDivider:actDivider];
|
||||
if ([sv mustAdjust]) {
|
||||
// If something changed, we clear fractions and redisplay.
|
||||
[sv RB___setMustClearFractions];
|
||||
[sv display];
|
||||
}
|
||||
// Change the drag point by the actual amount moved.
|
||||
float newc = [sv RB___dividerOrigin:actDivider];
|
||||
DIM(point) += newc-divc;
|
||||
divc = newc;
|
||||
NSEnableScreenUpdates();
|
||||
[pool release];
|
||||
}
|
||||
[sv RB___setDragging:NO];
|
||||
[NSCursor pop];
|
||||
actDivider = NSNotFound;
|
||||
return;
|
||||
}
|
||||
if (canDragWindow&&[window isMovableByWindowBackground]&&![[self couplingSplitView] background]) {
|
||||
// If we get here, it's a textured (metal) window, the mouse has gone down on an non-opaque portion
|
||||
// of the subview, and our RBSplitView has a transparent background. RBSplitView returns NO to
|
||||
// mouseDownCanMoveWindow, but the window should move here - after all, the window background
|
||||
// is visible right here! So we fake it and move the window as intended. Mwahahaha!
|
||||
where = [window convertBaseToScreen:where];
|
||||
NSPoint origin = [window frame].origin;
|
||||
// Now we loop handling mouse events until we get a mouse up event.
|
||||
while ((theEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask|NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES])&&([theEvent type]!=NSLeftMouseUp)) {
|
||||
// Set up a local autorelease pool for the loop to prevent buildup of temporary objects.
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSPoint now = [window convertBaseToScreen:[theEvent locationInWindow]];
|
||||
origin.x += now.x-where.x;
|
||||
origin.y += now.y-where.y;
|
||||
// Move the window by the mouse displacement since the last event.
|
||||
[window setFrameOrigin:origin];
|
||||
where = now;
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// These two methods encode and decode subviews.
|
||||
- (void)encodeWithCoder:(NSCoder*)coder {
|
||||
NSRect frame;
|
||||
BOOL coll = [self isCollapsed];
|
||||
if (coll) {
|
||||
// We can't encode a collapsed subview as-is, so we correct the frame size first and add WAYOUT
|
||||
// to the origin to signal it was collapsed.
|
||||
NSRect newf = frame = [self frame];
|
||||
newf.origin.x += WAYOUT;
|
||||
[super setFrameOrigin:newf.origin];
|
||||
newf.size = savedSize;
|
||||
[super setFrameSize:newf.size];
|
||||
}
|
||||
[super encodeWithCoder:coder];
|
||||
if (coll) {
|
||||
[super setFrame:frame];
|
||||
}
|
||||
if ([coder allowsKeyedCoding]) {
|
||||
[coder encodeObject:identifier forKey:@"identifier"];
|
||||
[coder encodeInt:tag forKey:@"tag"];
|
||||
[coder encodeFloat:minDimension forKey:@"minDimension"];
|
||||
[coder encodeFloat:maxDimension forKey:@"maxDimension"];
|
||||
[coder encodeDouble:fraction forKey:@"fraction"];
|
||||
[coder encodeBool:canCollapse forKey:@"canCollapse"];
|
||||
} else {
|
||||
[coder encodeObject:identifier];
|
||||
[coder encodeValueOfObjCType:@encode(typeof(tag)) at:&tag];
|
||||
[coder encodeValueOfObjCType:@encode(typeof(minDimension)) at:&minDimension];
|
||||
[coder encodeValueOfObjCType:@encode(typeof(maxDimension)) at:&maxDimension];
|
||||
[coder encodeValueOfObjCType:@encode(typeof(fraction)) at:&fraction];
|
||||
[coder encodeValueOfObjCType:@encode(typeof(canCollapse)) at:&canCollapse];
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder*)coder {
|
||||
if ((self = [super initWithCoder:coder])) {
|
||||
fraction = 0.0;
|
||||
canCollapse = NO;
|
||||
notInLimits = NO;
|
||||
minDimension = 1.0;
|
||||
maxDimension = WAYOUT;
|
||||
identifier = @"";
|
||||
actDivider = NSNotFound;
|
||||
canDragWindow = NO;
|
||||
previous = [self frame];
|
||||
savedSize = previous.size;
|
||||
if (previous.origin.x>=WAYOUT) {
|
||||
// The subview was collapsed when encoded, so we correct the origin and collapse it.
|
||||
BOOL ishor = [self splitViewIsHorizontal];
|
||||
previous.origin.x -= WAYOUT;
|
||||
DIM(previous.size) = 0.0;
|
||||
[self setFrameOrigin:previous.origin];
|
||||
[self setFrameSize:previous.size];
|
||||
}
|
||||
previous = NSZeroRect;
|
||||
if ([coder allowsKeyedCoding]) {
|
||||
[self setIdentifier:[coder decodeObjectForKey:@"identifier"]];
|
||||
tag = [coder decodeIntForKey:@"tag"];
|
||||
minDimension = [coder decodeFloatForKey:@"minDimension"];
|
||||
maxDimension = [coder decodeFloatForKey:@"maxDimension"];
|
||||
fraction = [coder decodeDoubleForKey:@"fraction"];
|
||||
canCollapse = [coder decodeBoolForKey:@"canCollapse"];
|
||||
} else {
|
||||
[self setIdentifier:[coder decodeObject]];
|
||||
[coder decodeValueOfObjCType:@encode(typeof(tag)) at:&tag];
|
||||
[coder decodeValueOfObjCType:@encode(typeof(minDimension)) at:&minDimension];
|
||||
[coder decodeValueOfObjCType:@encode(typeof(maxDimension)) at:&maxDimension];
|
||||
[coder decodeValueOfObjCType:@encode(typeof(fraction)) at:&fraction];
|
||||
[coder decodeValueOfObjCType:@encode(typeof(canCollapse)) at:&canCollapse];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RBSplitSubview (RB___SubviewAdditions)
|
||||
|
||||
// This hides/shows the subview without calling adjustSubview.
|
||||
- (void)RB___setHidden:(BOOL)flag {
|
||||
[super setHidden:flag];
|
||||
}
|
||||
|
||||
// This internal method returns the current animationData. It will always return nil if
|
||||
// the receiver isn't the current owner and some other subview is already being animated.
|
||||
// Otherwise, if the parameter is YES, a new animation will be started (or the current
|
||||
// one will be restarted).
|
||||
- (animationData*)RB___animationData:(BOOL)start resize:(BOOL)resize {
|
||||
if (currentAnimation&&(currentAnimation->owner!=self)) {
|
||||
// There already is an animation in progress on some other subview.
|
||||
return nil;
|
||||
}
|
||||
if (start) {
|
||||
// We want to start (or restart) an animation.
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv) {
|
||||
float dim = [self dimension];
|
||||
// First assume the default time, then ask the delegate.
|
||||
NSTimeInterval total = dim*(0.2/150.0);
|
||||
id delegate = [sv delegate];
|
||||
if ([delegate respondsToSelector:@selector(splitView:willAnimateSubview:withDimension:)]) {
|
||||
total = [delegate splitView:sv willAnimateSubview:self withDimension:dim];
|
||||
}
|
||||
// No use animating anything shorter than the frametime.
|
||||
if (total>FRAMETIME) {
|
||||
if (!currentAnimation) {
|
||||
currentAnimation = (animationData*)malloc(sizeof(animationData));
|
||||
}
|
||||
if (currentAnimation) {
|
||||
currentAnimation->owner = self;
|
||||
currentAnimation->stepsDone = 0;
|
||||
currentAnimation->elapsedTime = 0.0;
|
||||
currentAnimation->dimension = dim;
|
||||
currentAnimation->collapsing = ![self isCollapsed];
|
||||
currentAnimation->totalTime = total;
|
||||
currentAnimation->finishTime = [NSDate timeIntervalSinceReferenceDate]+total;
|
||||
currentAnimation->resizing = resize;
|
||||
[sv RB___setDragging:YES];
|
||||
}
|
||||
} else if (currentAnimation) {
|
||||
free(currentAnimation);
|
||||
currentAnimation = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentAnimation;
|
||||
}
|
||||
|
||||
// This internal method steps the animation to the next frame.
|
||||
- (void)RB___stepAnimation {
|
||||
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
|
||||
animationData* anim = [self RB___animationData:NO resize:NO];
|
||||
if (anim) {
|
||||
RBSplitView* sv = [self splitView];
|
||||
NSTimeInterval remain = anim->finishTime-now;
|
||||
NSRect frame = [self frame];
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
// Continuing animation only makes sense if we still have at least FRAMETIME available.
|
||||
if (remain>=FRAMETIME) {
|
||||
float dim = DIM(frame.size);
|
||||
float avg = anim->elapsedTime;
|
||||
// We try to keep a record of how long it takes, on the average, to resize and adjust
|
||||
// one animation frame.
|
||||
if (anim->stepsDone) {
|
||||
avg /= anim->stepsDone;
|
||||
}
|
||||
NSTimeInterval delay = MIN(0.0,FRAMETIME-avg);
|
||||
// We adjust the new dimension proportionally to how much of the designated time has passed.
|
||||
dim = floorf(anim->dimension*(remain-avg)/anim->totalTime);
|
||||
if (dim>4.0) {
|
||||
if (!anim->collapsing) {
|
||||
dim = anim->dimension-dim;
|
||||
}
|
||||
DIM(frame.size) = dim;
|
||||
[self RB___setFrame:frame withFraction:0.0 notify:NO];
|
||||
[sv adjustSubviews];
|
||||
[self display];
|
||||
anim->elapsedTime += [NSDate timeIntervalSinceReferenceDate]-now;
|
||||
++anim->stepsDone;
|
||||
// Schedule a timer to do the next animation step.
|
||||
[self performSelector:@selector(RB___stepAnimation) withObject:nil afterDelay:delay inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode,NSModalPanelRunLoopMode,
|
||||
NSEventTrackingRunLoopMode,nil]];
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We're finished, either collapse or expand entirely now.
|
||||
if (anim->collapsing) {
|
||||
DIM(frame.size) = 0.0;
|
||||
[self RB___finishCollapse:frame withFraction:anim->dimension/[sv RB___dimensionWithoutDividers]];
|
||||
} else {
|
||||
float savemin,savemax;
|
||||
float dim = [self RB___setMinAndMaxTo:anim->dimension savingMin:&savemin andMax:&savemax];
|
||||
DIM(frame.size) = dim;
|
||||
[self RB___finishExpand:frame withFraction:0.0];
|
||||
minDimension = savemin;
|
||||
maxDimension = savemax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This internal method stops the animation, if the receiver is being animated. It will
|
||||
// return YES if the animation was stopped.
|
||||
- (BOOL)RB___stopAnimation {
|
||||
if (currentAnimation&&(currentAnimation->owner==self)) {
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(RB___stepAnimation) object:nil];
|
||||
free(currentAnimation);
|
||||
currentAnimation = NULL;
|
||||
[[self splitView] RB___setDragging:NO];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This internal method returns the actual visible dimension of the subview. Differs from -dimension in
|
||||
// that it returns 0.0 if the subview is collapsed.
|
||||
- (float)RB___visibleDimension {
|
||||
BOOL ishor = [self splitViewIsHorizontal];
|
||||
NSRect frame = [self frame];
|
||||
return MAX(0.0,DIM(frame.size));
|
||||
}
|
||||
|
||||
// This pair of internal methods is used only inside -[RBSplitView adjustSubviews] to copy subview data
|
||||
// from and to that method's internal cache.
|
||||
- (void)RB___copyIntoCache:(subviewCache*)cache {
|
||||
cache->sub = self;
|
||||
cache->rect = [self frame];
|
||||
cache->size = [self RB___visibleDimension];
|
||||
cache->fraction = fraction;
|
||||
cache->constrain = NO;
|
||||
}
|
||||
|
||||
- (void)RB___updateFromCache:(subviewCache*)cache withTotalDimension:(float)value {
|
||||
float dim = [self RB___visibleDimension];
|
||||
if (cache->size>=1.0) {
|
||||
// New state is not collapsed.
|
||||
if (dim>=1.0) {
|
||||
// Old state was not collapsed, so we just change the frame.
|
||||
[self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
|
||||
} else {
|
||||
// Old state was collapsed, so we expand it.
|
||||
[self RB___finishExpand:cache->rect withFraction:cache->fraction];
|
||||
}
|
||||
} else {
|
||||
// New state is collapsed.
|
||||
if (dim>=1.0) {
|
||||
// Old state was not collapsed, so we clear first responder and change the frame.
|
||||
[self RB___clearResponder];
|
||||
[self RB___finishCollapse:cache->rect withFraction:dim/value];
|
||||
} else {
|
||||
// It was collapsed already, but the frame may have changed, so we set it.
|
||||
[self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This internal method sets minimum and maximum values to the same value, saves the old values,
|
||||
// and returns the new value (which will be limited to the old values).
|
||||
- (float)RB___setMinAndMaxTo:(float)value savingMin:(float*)oldmin andMax:(float*)oldmax {
|
||||
*oldmin = [self minDimension];
|
||||
*oldmax = [self maxDimension];
|
||||
if (value<*oldmin) {
|
||||
value = *oldmin;
|
||||
}
|
||||
if (value>*oldmax) {
|
||||
value = *oldmax;
|
||||
}
|
||||
minDimension = maxDimension = value;
|
||||
return value;
|
||||
}
|
||||
|
||||
// This internal method tries to clear the first responder, if the current responder is a descendant of
|
||||
// the receiving subview. If so, it will set first responder to nil, redisplay the former responder and
|
||||
// return YES. Returns NO otherwise.
|
||||
- (BOOL)RB___clearResponder {
|
||||
NSWindow* window = [self window];
|
||||
if (window) {
|
||||
NSView* responder = (NSView*)[window firstResponder];
|
||||
if (responder&&[responder respondsToSelector:@selector(isDescendantOf:)]) {
|
||||
if ([responder isDescendantOf:self]) {
|
||||
if ([window makeFirstResponder:nil]) {
|
||||
[responder display];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This internal method collapses a subview.
|
||||
// It returns the negative of the size of the subview before collapsing, or 0.0 if it wasn't collapsed.
|
||||
- (float)RB___collapse {
|
||||
float result = 0.0;
|
||||
if (![self isCollapsed]) {
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv&&[self canCollapse]) {
|
||||
[self RB___clearResponder];
|
||||
NSRect frame = [self frame];
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
result = DIM(frame.size);
|
||||
// For collapsed views, fraction will contain the fraction of the dimension previously occupied
|
||||
DIM(frame.size) = 0.0;
|
||||
[self RB___finishCollapse:frame withFraction:result/[sv RB___dimensionWithoutDividers]];
|
||||
}
|
||||
}
|
||||
return -result;
|
||||
}
|
||||
|
||||
// This internal method finishes the collapse of a subview, stopping the animation if
|
||||
// there is one, and calling the delegate method if there is one.
|
||||
- (void)RB___finishCollapse:(NSRect)rect withFraction:(double)value {
|
||||
RBSplitView* sv = [self splitView];
|
||||
BOOL finish = [self RB___stopAnimation];
|
||||
[self RB___setFrame:rect withFraction:value notify:YES];
|
||||
[sv RB___setMustClearFractions];
|
||||
if (finish) {
|
||||
[self display];
|
||||
}
|
||||
id delegate = [sv delegate];
|
||||
if ([delegate respondsToSelector:@selector(splitView:didCollapse:)]) {
|
||||
[delegate splitView:sv didCollapse:self];
|
||||
}
|
||||
}
|
||||
|
||||
// This internal method expands a subview. setToMinimum will usually be YES during a divider drag.
|
||||
// It returns the size of the subview after expanding, or 0.0 if it wasn't expanded.
|
||||
- (float)RB___expandAndSetToMinimum:(BOOL)setToMinimum {
|
||||
float result = 0.0;
|
||||
RBSplitView* sv = [self splitView];
|
||||
if (sv&&[self isCollapsed]) {
|
||||
NSRect frame = [super frame];
|
||||
double frac = fraction;
|
||||
BOOL ishor = [sv isHorizontal];
|
||||
if (setToMinimum) {
|
||||
result = DIM(frame.size) = minDimension;
|
||||
} else {
|
||||
result = [sv RB___dimensionWithoutDividers]*frac;
|
||||
// We need to apply a compensation factor for proportional resizing in adjustSubviews.
|
||||
float newdim = floorf((frac>=1.0)?result:result/(1.0-frac));
|
||||
DIM(frame.size) = newdim;
|
||||
result = floorf(result);
|
||||
}
|
||||
[self RB___finishExpand:frame withFraction:0.0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// This internal method finishes the the expansion of a subview, stopping the animation if
|
||||
// there is one, and calling the delegate method if there is one.
|
||||
- (void)RB___finishExpand:(NSRect)rect withFraction:(double)value {
|
||||
RBSplitView* sv = [self splitView];
|
||||
BOOL finish = [self RB___stopAnimation];
|
||||
[self RB___setFrame:rect withFraction:value notify:YES];
|
||||
[sv RB___setMustClearFractions];
|
||||
if (finish) {
|
||||
[self display];
|
||||
}
|
||||
id delegate = [sv delegate];
|
||||
if ([delegate respondsToSelector:@selector(splitView:didExpand:)]) {
|
||||
[delegate splitView:sv didExpand:self];
|
||||
}
|
||||
}
|
||||
|
||||
// These internal methods set the subview's frame or size, and also store a fraction value
|
||||
// which is used to ensure repeatability when the whole split view is resized.
|
||||
- (void)RB___setFrame:(NSRect)rect withFraction:(double)value notify:(BOOL)notify {
|
||||
RBSplitView* sv = [self splitView];
|
||||
id delegate = nil;
|
||||
if (notify) {
|
||||
delegate = [sv delegate];
|
||||
// If the delegate method isn't implemented, we ignore the delegate altogether.
|
||||
if ([delegate respondsToSelector:@selector(splitView:changedFrameOfSubview:from:to:)]) {
|
||||
// If the rects are equal, the delegate isn't called.
|
||||
if (NSEqualRects(previous,rect)) {
|
||||
delegate = nil;
|
||||
}
|
||||
} else {
|
||||
delegate = nil;
|
||||
}
|
||||
}
|
||||
[sv setMustAdjust];
|
||||
[self setFrame:rect];
|
||||
fraction = value;
|
||||
[delegate splitView:sv changedFrameOfSubview:self from:previous to:rect];
|
||||
previous = delegate?rect:NSZeroRect;
|
||||
}
|
||||
|
||||
- (void)RB___setFrameSize:(NSSize)size withFraction:(double)value {
|
||||
[[self splitView] setMustAdjust];
|
||||
[self setFrameSize:size];
|
||||
fraction = value;
|
||||
}
|
||||
|
||||
// This internal method gets the fraction value.
|
||||
- (double)RB___fraction {
|
||||
return fraction;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // MM_ENABLE_PLUGINS
|
||||
@@ -1,225 +0,0 @@
|
||||
//
|
||||
// RBSplitView.h version 1.1.4
|
||||
// RBSplitView
|
||||
//
|
||||
// Created by Rainer Brockerhoff on 24/09/2004.
|
||||
// Copyright 2004-2006 Rainer Brockerhoff.
|
||||
// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License.
|
||||
//
|
||||
|
||||
#import "RBSplitSubview.h"
|
||||
|
||||
// These values are used to handle the various cursor types.
|
||||
typedef enum {
|
||||
RBSVHorizontalCursor=0, // appears over horizontal dividers
|
||||
RBSVVerticalCursor, // appears over vertical dividers
|
||||
RBSV2WayCursor, // appears over two-way thumbs
|
||||
RBSVDragCursor, // appears while dragging
|
||||
RBSVCursorTypeCount
|
||||
} RBSVCursorType;
|
||||
|
||||
@interface RBSplitView : RBSplitSubview {
|
||||
// Subclasses normally should use setter methods instead of changing instance variables by assignment.
|
||||
// Most getter methods simply return the corresponding instance variable, so with some care, subclasses
|
||||
// could reference them directly.
|
||||
IBOutlet id delegate; // The delegate (may be nil).
|
||||
NSString* autosaveName; // This name is used for storing subview proportions in user defaults.
|
||||
NSColor* background; // The color used to paint the view's background (may be nil).
|
||||
NSImage* divider; // The image used for the divider "dimple".
|
||||
NSRect* dividers; // A C array of NSRects, one for each divider.
|
||||
float dividerThickness; // Actual divider width; should be an integer and at least 1.0.
|
||||
BOOL mustAdjust; // Set internally if the subviews need to be adjusted.
|
||||
BOOL mustClearFractions; // Set internally if fractions should be cleared before adjusting.
|
||||
BOOL isHorizontal; // The divider's orientation; default is vertical.
|
||||
BOOL canSaveState; // Set internally to allow saving subview state.
|
||||
BOOL isCoupled; // If YES, take some parameters from the containing RBSplitView, if any.
|
||||
BOOL isAdjusting; // Set internally while the subviews are being adjusted.
|
||||
BOOL isDragging; // Set internally while in a drag loop.
|
||||
BOOL isInScrollView; // Set internally if directly contained in an NSScrollView.
|
||||
}
|
||||
|
||||
// These class methods get and set the cursor used for each type.
|
||||
// Pass in nil to reset to the default cursor for that type.
|
||||
+ (NSCursor*)cursor:(RBSVCursorType)type;
|
||||
+ (void)setCursor:(RBSVCursorType)type toCursor:(NSCursor*)cursor;
|
||||
|
||||
// This class method clears the saved state for a given autosave name from the defaults.
|
||||
+ (void)removeStateUsingName:(NSString*)name;
|
||||
|
||||
// This class method returns the actual key used to store autosave data in the defaults.
|
||||
+ (NSString*)defaultsKeyForName:(NSString*)name isHorizontal:(BOOL)orientation;
|
||||
|
||||
// Sets and gets the autosaveName; this will be the key used to store the subviews' proportions
|
||||
// in the user defaults. Default is @"", which doesn't save anything. Set flag to YES to set
|
||||
// unique names for nested subviews. You are responsible for avoiding duplicates.
|
||||
- (void)setAutosaveName:(NSString*)aString recursively:(BOOL)flag;
|
||||
- (NSString*)autosaveName;
|
||||
|
||||
// Saves the current state of the subviews if there's a valid autosave name set. If the argument
|
||||
// is YES, it's then also called recursively for nested RBSplitViews. Returns YES if successful.
|
||||
- (BOOL)saveState:(BOOL)recurse;
|
||||
|
||||
// Restores the saved state of the subviews if there's a valid autosave name set. If the argument
|
||||
// is YES, it's first called recursively for nested RBSplitViews. Returns YES if successful.
|
||||
// You need to call adjustSubviews after calling this.
|
||||
- (BOOL)restoreState:(BOOL)recurse;
|
||||
|
||||
// Returns a string encoding the current state of all direct subviews. Does not check for nesting.
|
||||
- (NSString*)stringWithSavedState;
|
||||
|
||||
// Readjusts all direct subviews according to the encoded string parameter. The number of subviews
|
||||
// must match. Returns YES if successful. Does not check for nesting.
|
||||
- (BOOL)setStateFromString:(NSString*)aString;
|
||||
|
||||
// Returns an array with complete state information for the receiver and all subviews, taking
|
||||
// nesting into account. Don't store this array in a file, as its format might change in the
|
||||
// future; this is for taking a state snapshot and later restoring it with setStatesFromArray.
|
||||
- (NSArray*)arrayWithStates;
|
||||
|
||||
// Restores the state of the receiver and all subviews. The array must have been produced by a
|
||||
// previous call to arrayWithStates. Returns YES if successful. This will fail if you have
|
||||
// added or removed subviews in the meantime!
|
||||
// You need to call adjustSubviews after calling this.
|
||||
- (BOOL)setStatesFromArray:(NSArray*)array;
|
||||
|
||||
// This is the designated initializer for creating RBSplitViews programmatically.
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
|
||||
// This convenience initializer adds any number of subviews and adjusts them proportionally.
|
||||
- (id)initWithFrame:(NSRect)frame andSubviews:(unsigned)count;
|
||||
|
||||
// Sets and gets the delegate. (Delegates aren't retained.) See further down for delegate methods.
|
||||
- (void)setDelegate:(id)anObject;
|
||||
- (id)delegate;
|
||||
|
||||
// Returns a subview which has a certain identifier string, or nil if there's none
|
||||
- (RBSplitSubview*)subviewWithIdentifier:(NSString*)anIdentifier;
|
||||
|
||||
// Returns the subview at a certain position. Returns nil if the position is invalid.
|
||||
- (RBSplitSubview*)subviewAtPosition:(unsigned)position;
|
||||
|
||||
// Adds a subview at a certain position.
|
||||
- (void)addSubview:(NSView*)aView atPosition:(unsigned)position;
|
||||
|
||||
// Sets and gets the divider thickness, which should be a positive integer or zero.
|
||||
// Setting the divider image also resets this automatically, so you would call this
|
||||
// only if you want the divider to be larger or smaller than the image. Zero means that
|
||||
// the image dimensions will be used.
|
||||
- (void)setDividerThickness:(float)thickness;
|
||||
- (float)dividerThickness;
|
||||
|
||||
// Sets and gets the divider image. The default image can also be set in Interface Builder, so usually
|
||||
// there's no need to call this. Passing in nil means that the default divider thickness will be zero,
|
||||
// and no mouse events will be processed, so that the dividers can be moved only programmatically.
|
||||
- (void)setDivider:(NSImage*)image;
|
||||
- (NSImage*)divider;
|
||||
|
||||
// Sets and gets the view background. The default is nil, meaning no background is
|
||||
// drawn and the view and its subviews are considered transparent.
|
||||
- (void)setBackground:(NSColor*)color;
|
||||
- (NSColor*)background;
|
||||
|
||||
// Sets and gets the orientation. This uses the same convention as NSSplitView: vertical means the
|
||||
// dividers are vertical, but the subviews are in a horizontal row. Sort of counter-intuitive, yes.
|
||||
- (void)setVertical:(BOOL)flag;
|
||||
- (BOOL)isVertical;
|
||||
- (BOOL)isHorizontal;
|
||||
|
||||
// Call this to force adjusting the subviews before display. Called automatically if anything
|
||||
// relevant is changed.
|
||||
- (void)setMustAdjust;
|
||||
|
||||
// Returns YES if there's a pending adjustment.
|
||||
- (BOOL)mustAdjust;
|
||||
|
||||
// Returns YES if we're in a dragging loop.
|
||||
- (BOOL)isDragging;
|
||||
|
||||
// Returns YES if the view is directly contained in an NSScrollView.
|
||||
- (BOOL)isInScrollView;
|
||||
|
||||
// Call this to recalculate all subview dimensions. Normally this is done automatically whenever
|
||||
// something relevant is changed, so you rarely will need to call this explicitly.
|
||||
- (void)adjustSubviews;
|
||||
|
||||
// This method should be called only from within the splitView:wasResizedFrom:to: delegate method
|
||||
// to keep some specific subview the same size.
|
||||
- (void)adjustSubviewsExcepting:(RBSplitSubview*)excepting;
|
||||
|
||||
// This method draws dividers. You should never call it directly but you can override it when
|
||||
// subclassing, if you need custom dividers.
|
||||
- (void)drawDivider:(NSImage*)anImage inRect:(NSRect)rect betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing;
|
||||
|
||||
@end
|
||||
|
||||
// The following methods are optionally implemented by the delegate.
|
||||
|
||||
@interface NSObject(RBSplitViewDelegate)
|
||||
|
||||
// The delegate can override a subview's ability to collapse by implementing this method.
|
||||
// Return YES to allow collapsing. If this is implemented, the subviews' built-in
|
||||
// 'collapsed' flags are ignored.
|
||||
- (BOOL)splitView:(RBSplitView*)sender canCollapse:(RBSplitSubview*)subview;
|
||||
|
||||
// The delegate can alter the divider's appearance by implementing this method.
|
||||
// Before calling this, the divider is filled with the background, and afterwards
|
||||
// the divider image is drawn into the returned rect. If imageRect is empty, no
|
||||
// divider image will be drawn, because there are nested RBSplitViews. Return
|
||||
// NSZeroRect to suppress the divider image. Return imageRect to use the default
|
||||
// location for the image, or change its origin to place the image elsewhere.
|
||||
// You could also draw the divider yourself at this point and return NSZeroRect.
|
||||
- (NSRect)splitView:(RBSplitView*)sender willDrawDividerInRect:(NSRect)dividerRect betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing withProposedRect:(NSRect)imageRect;
|
||||
|
||||
// These methods are called after a subview is completely collapsed or expanded. adjustSubviews may or may not
|
||||
// have been called, however.
|
||||
- (void)splitView:(RBSplitView*)sender didCollapse:(RBSplitSubview*)subview;
|
||||
- (void)splitView:(RBSplitView*)sender didExpand:(RBSplitSubview*)subview;
|
||||
|
||||
// These methods are called just before and after adjusting subviews.
|
||||
- (void)willAdjustSubviews:(RBSplitView*)sender;
|
||||
- (void)didAdjustSubviews:(RBSplitView*)sender;
|
||||
|
||||
// This method will be called after a RBSplitView is resized with setFrameSize: but before
|
||||
// adjustSubviews is called on it.
|
||||
- (void)splitView:(RBSplitView*)sender wasResizedFrom:(float)oldDimension to:(float)newDimension;
|
||||
|
||||
// This method will be called when a divider is double-clicked and both leading and trailing
|
||||
// subviews can be collapsed. Return either of the parameters to collapse that subview, or nil
|
||||
// to collapse neither. If not implemented, the smaller subview will be collapsed.
|
||||
- (RBSplitSubview*)splitView:(RBSplitView*)sender collapseLeading:(RBSplitSubview*)leading orTrailing:(RBSplitSubview*)trailing;
|
||||
|
||||
// This method will be called when a cursor rect is being set (inside resetCursorRects). The
|
||||
// proposed rect is passed in. Return the actual rect, or NSZeroRect to suppress cursor setting
|
||||
// for this divider. This won't be called for two-axis thumbs, however. The rects are in
|
||||
// sender's local coordinates.
|
||||
- (NSRect)splitView:(RBSplitView*)sender cursorRect:(NSRect)rect forDivider:(unsigned int)divider;
|
||||
|
||||
// This method will be called whenever a mouse-down event is received in a divider. Return YES to have
|
||||
// the event handled by the split view, NO if you wish to ignore it or handle it in the delegate.
|
||||
- (BOOL)splitView:(RBSplitView*)sender shouldHandleEvent:(NSEvent*)theEvent inDivider:(unsigned int)divider betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing;
|
||||
|
||||
// This method will be called just before a subview will be collapsed or expanded with animation.
|
||||
// Return the approximate time the animation should take, or 0.0 to disallow animation.
|
||||
// If not implemented, it will use the default of 0.2 seconds per 150 pixels.
|
||||
- (NSTimeInterval)splitView:(RBSplitView*)sender willAnimateSubview:(RBSplitSubview*)subview withDimension:(float)dimension;
|
||||
|
||||
// This method will be called whenever a subview's frame is changed, usually from inside adjustSubviews' final loop.
|
||||
// You'd normally use this to move some auxiliary view to keep it aligned with the subview.
|
||||
- (void)splitView:(RBSplitView*)sender changedFrameOfSubview:(RBSplitSubview*)subview from:(NSRect)fromRect to:(NSRect)toRect;
|
||||
|
||||
// This method is called whenever the event handlers want to check if some point within the RBSplitSubview
|
||||
// should act as an alternate drag view. Usually, the delegate will check the point (which is in sender's
|
||||
// local coordinates) against the frame of one or several auxiliary views, and return a valid divider number.
|
||||
// Returning NSNotFound means the point is not valid.
|
||||
- (unsigned int)splitView:(RBSplitView*)sender dividerForPoint:(NSPoint)point inSubview:(RBSplitSubview*)subview;
|
||||
|
||||
// This method is called continuously while a divider is dragged, just before the leading subview is resized.
|
||||
// Return NO to resize the trailing view by the same amount, YES to resize the containing window by the same amount.
|
||||
- (BOOL)splitView:(RBSplitView*)sender shouldResizeWindowForDivider:(unsigned int)divider betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing willGrow:(BOOL)grow;
|
||||
|
||||
// This method is called by each subview's drawRect: method, just after filling it with the background color but
|
||||
// before the contained subviews are drawn. Usually you would use this to draw a frame inside the subview.
|
||||
- (void)splitView:(RBSplitView*)sender willDrawSubview:(RBSplitSubview*)subview inRect:(NSRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,98 +0,0 @@
|
||||
//
|
||||
// RBSplitViewPrivateDefines.h version 1.1.4
|
||||
// RBSplitView
|
||||
//
|
||||
// Created by Rainer Brockerhoff on 19/11/2004.
|
||||
// Copyright 2004-2006 Rainer Brockerhoff.
|
||||
// Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License.
|
||||
//
|
||||
|
||||
// These defines are used only locally; no sense exporting them in the main header file where they might
|
||||
// conflict with something...
|
||||
|
||||
// This is the hysteresis value for collapsing/expanding subviews with the mouse. 0.05 (5%) works well.
|
||||
#define HYSTERESIS (0.05)
|
||||
|
||||
// This selects the main horizontal or vertical coordinate according to the split view's orientation.
|
||||
// It can be used as an lvalue, too. You need to have BOOL ishor declared to use it.
|
||||
#define DIM(x) (((float*)&(x))[ishor])
|
||||
|
||||
// This selects the other coordinate.
|
||||
#define OTHER(x) (((float*)&(x))[!ishor])
|
||||
|
||||
// This value for the view offsets is guaranteed to be out of view for quite some time and is used
|
||||
// to mark the view as collapsed.
|
||||
#define WAYOUT (1000000.0)
|
||||
|
||||
// This is the default framerate for collapse/expand animation.
|
||||
#define FRAMETIME (1.0/60.0)
|
||||
|
||||
// This struct is used internally for speeding up adjustSubviews.
|
||||
typedef struct subviewCache {
|
||||
NSRect rect; // the subview's frame
|
||||
double fraction; // fractional extra
|
||||
RBSplitSubview* sub; // points at the subview
|
||||
float size; // current dimension (integer)
|
||||
BOOL constrain; // set if constrained
|
||||
} subviewCache;
|
||||
|
||||
// This struct is used internally for doing collapse/expand animation.
|
||||
typedef struct animationData {
|
||||
RBSplitSubview* owner; // the subview being animated
|
||||
float dimension; // the subview's starting or ending dimension
|
||||
int stepsDone; // counts already done animation steps
|
||||
NSTimeInterval elapsedTime; // time already spent in resizing and adjusting subviews
|
||||
NSTimeInterval finishTime; // the animation should be finished at this time
|
||||
NSTimeInterval totalTime; // total time the animation should take
|
||||
BOOL collapsing; // YES if we're collapsing, NO if we're expanding
|
||||
BOOL resizing; // YES if we're resizing, NO if we're frozen
|
||||
} animationData;
|
||||
|
||||
// The following methods are for internal use, and you should never call or override them.
|
||||
// They'll probably vary wildy from version to version, too.
|
||||
|
||||
@interface RBSplitSubview (RB___SubviewAdditions)
|
||||
|
||||
- (void)RB___setHidden:(BOOL)flag;
|
||||
- (animationData*)RB___animationData:(BOOL)start resize:(BOOL)resize;
|
||||
- (void)RB___stepAnimation;
|
||||
- (BOOL)RB___stopAnimation;
|
||||
- (float)RB___visibleDimension;
|
||||
- (float)RB___setMinAndMaxTo:(float)value savingMin:(float*)oldmin andMax:(float*)oldmax;
|
||||
- (float)RB___collapse;
|
||||
- (float)RB___expandAndSetToMinimum:(BOOL)setToMinimum;
|
||||
- (void)RB___finishCollapse:(NSRect)rect withFraction:(double)value;
|
||||
- (void)RB___finishExpand:(NSRect)rect withFraction:(double)value;
|
||||
- (void)RB___setFrameSize:(NSSize)size withFraction:(double)value;
|
||||
- (void)RB___setFrame:(NSRect)rect withFraction:(double)value notify:(BOOL)notify;
|
||||
- (double)RB___fraction;
|
||||
- (void)RB___copyIntoCache:(subviewCache*)cache;
|
||||
- (void)RB___updateFromCache:(subviewCache*)cache withTotalDimension:(float)value;
|
||||
- (BOOL)RB___clearResponder;
|
||||
|
||||
@end
|
||||
|
||||
@interface RBSplitView (RB___ViewAdditions)
|
||||
|
||||
- (void)RB___adjustOutermostIfNeeded;
|
||||
- (void)RB___setDragging:(BOOL)flag;
|
||||
- (float)RB___dividerOrigin:(int)indx;
|
||||
- (NSArray*)RB___subviews;
|
||||
- (unsigned int)RB___numberOfSubviews;
|
||||
- (void)RB___adjustSubviewsExcepting:(RBSplitSubview*)excepting;
|
||||
- (float)RB___dimensionWithoutDividers;
|
||||
- (float)RB___dividerThickness;
|
||||
- (NSRect)RB___dividerRect:(unsigned)indx relativeToView:(RBSplitView*)view;
|
||||
- (void)RB___setMustClearFractions;
|
||||
- (BOOL)RB___shouldResizeWindowForDivider:(unsigned int)indx betweenView:(RBSplitSubview*)leading andView:(RBSplitSubview*)trailing willGrow:(BOOL)grow;
|
||||
- (void)RB___tryToExpandLeading:(RBSplitSubview*)leading divider:(unsigned int)indx trailing:(RBSplitSubview*)trailing delta:(float)delta;
|
||||
- (void)RB___tryToShortenLeading:(RBSplitSubview*)leading divider:(unsigned int)indx trailing:(RBSplitSubview*)trailing delta:(float)delta always:(BOOL)always;
|
||||
- (void)RB___tryToExpandTrailing:(RBSplitSubview*)trailing leading:(RBSplitSubview*)leading delta:(float)delta;
|
||||
- (void)RB___tryToShortenTrailing:(RBSplitSubview*)trailing divider:(unsigned int)indx leading:(RBSplitSubview*)leading delta:(float)delta always:(BOOL)always;
|
||||
- (void)RB___trackMouseEvent:(NSEvent*)theEvent from:(NSPoint)where withBase:(NSPoint)base inDivider:(unsigned)indx;
|
||||
- (void)RB___addCursorRectsTo:(RBSplitView*)masterView forDividerRect:(NSRect)rect thickness:(float)delta;
|
||||
- (unsigned)RB___dividerHitBy:(NSPoint)point relativeToView:(RBSplitView*)view thickness:(float)delta;
|
||||
- (void)RB___drawDividersIn:(RBSplitView*)masterView forDividerRect:(NSRect)rect thickness:(float)delta;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user