ãXcodeãã©ã°ã€ã³ã®äœæãã®å ¬éã«èå³ããããããXcodeã®ç°¡åãªã¿ã€ã ãã©ãã«ãŒãäœæããããšã«ããŸããã ç§ãçµéšããããã»ã¹ã¯ããã®èšäºã®æ¬è³ªã§ãã ãã®äžã§ãä»ã®ãã©ã°ã€ã³ãããéããããå¹ççã«æžãã®ã«åœ¹ç«ã€ããã€ãã®ãã©ã°ã€ã³ãåæããŸãã
ã€ã³ã¿ãŒãã§ã€ã¹ãåãããã©ã°ã€ã³ã®äž»ãªã¢ã€ãã¢ã¯ãXI UIã«çµ±åãããå¯èœãªéããã€ãã£ãã«èŠããããšã§ãã ããããXcodeãŠã£ã³ããŠãèŠããšããã«ããã©ã®ãªããžã§ã¯ããã©ãã«ãããã©ã®ããã«å¿ èŠãªãªããžã§ã¯ãã«çµ±åã§ããããç解ããæ¹æ³ã¯ïŒããšããçåãããã«çããŸãã Xcodeã«ããŒãããã©ã®ãªããžã§ã¯ããã©ãã«ããããäŒããç°¡åãªãã©ã°ã€ã³ãäœæããŸãã
æåã®ãã©ã°ã€ã³
ãŸãã ãã©ã°ã€ã³ã®ãã³ãã¬ãŒããã€ã³ã¹ããŒã«ããŠããã©ã°ã€ã³ãäœæããŸãã 次ã«ããã¹ãŠãç°¡åã§ããXcodeã®æ§æãç解ããã«ã¯ããã®ãªããžã§ã¯ãããã°ã«åºåããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããã°ããã¡ã€ã«ã«æžã蟌ããããã€ã¢ãã°ã§è¡šç€ºããŠæ¯åéããããšãã§ããŸãã ããããã®æ å ±ãXcodeã³ã³ãœãŒã«ã«çŽæ¥åºåããã®ã¯ã©ãã»ã©äŸ¿å©ã§ããããïŒ ãŸããäœãã2çªç®ã®ãã©ã°ã€ã³ã§ãã®åé¡ã解決ããŸãããããã«ã€ããŠã¯å°ãåŸã§è©³ãã説æããŸãã ãããŸã§ã®éããã°ãããªããžã§ã¯ãã®å ŽæãåŠçããªãããã«ããªããžã§ã¯ãã®åœ±ä»ãé åãå«ãXcodeãŠã£ã³ããŠã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ããããããã¹ãŠãã¡ã€ã«ã«ä¿åããŸãã
æåã®ãã©ã°ã€ã³ã¯ããã¹ãŠã®ãNSViewããééããããããè²ä»ãããŠãçŸåšã®ãŠã£ã³ããŠã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ã1ã€ã®ã¡ãœããã®ã¿ã§æ§æãããŸãã ç°¡åã«èãããŸãããå®éã«ã¯1ã€ã®å°ããªãã¥ã¢ã³ã¹ããããŸããäžéšã®XView 'NSView'ãªããžã§ã¯ãã¯1ã€ã® 'ContentView'以å€ã®ãã®ãæã€ããšãã§ãããç¬èªã®ã³ã³ãã³ããã¥ãŒãè¿œå ã§ããŸããã ããããããã¯éèŠã§ã¯ãããŸããããã®ãããªãªããžã§ã¯ããç¡èŠããŠãããããæãäžããŸãã
ã¡ãœããããã¹ã
ãããŠãã¡ãœããåŒã³åºãïŒ
- (void)viewSnap:(NSView *)view { static int i = 0; // text field NSTextField *name = [[NSTextField alloc] initWithFrame:view.bounds]; name.backgroundColor = [NSColor colorWithDeviceRed:rand()%255/255.f green:rand()%255/255.f blue:rand()%255/255.f alpha:0.3]; name.textColor = [NSColor blackColor]; NSString *string = view.className?:NSStringFromClass(view.class); name.stringValue = string?:@"unknown"; if (![view respondsToSelector:@selector(contentView)]) {// text field? [view addSubview:name]; // NSImage *captureImage = [[NSImage alloc] initWithData:[[NSApp keyWindow].contentView dataWithPDFInsideRect:[[NSApp keyWindow].contentView bounds]]]; [[captureImage TIFFRepresentation] writeToFile:[NSString stringWithFormat:@"%@%d.png", self.dirPath, i++] atomically:YES]; [name removeFromSuperview]; } for (NSView *v in view.subviews) { if ([v respondsToSelector:@selector(contentView)]) { NSView *vv = [v performSelector:@selector(contentView) withObject:nil]; [self viewSnap:vv]; } else { [self viewSnap:v]; } } }
ãããŠãã¡ãœããåŒã³åºãïŒ
- (void)doMenuAction { NSWindow * window = [NSApp keyWindow]; srand(time(NULL)); [self viewSnap:window.contentView]; }
ãã®åŸãåçãä¿åãããã©ã«ããéããŠæ¥œããããšãã§ããŸãã ãNSViewãã®ãµã€ãºã«å¿ããŠãããã¹ãã®ãµã€ãºãè©ŠããŠã¿ã䟡å€ããããŸãã
çµæã¯æ¬¡ã®ãšããã§ãã
ãããŠãããçŸãã圢ã§ãæåã§åŠçããåŸã®çµæã¯æ¬¡ã®ãšããã§ãã
ããã€ãã®åç
ããã«2çªç®ã®ãã©ã°ã€ã³ã«ç§»åããŸãã Xcodeã³ã³ãœãŒã«ã®ãã©ã°ã€ã³ããæ å ±ãåºåããŸãã
2çªç®ã®ãã©ã°ã€ã³
æåã®ãã©ã°ã€ã³ãããXcodeã®ã³ã³ãœãŒã«ããIDEConsoleTextViewãã¯ã©ã¹ã§ããããšãåŠã³ãŸããã ããããããã¯ã©ã®ãããªã¯ã©ã¹ã§ãã©ã®ã¡ãœããããããŸããïŒ èª¿ã¹ãã«ã¯ãããã€ãã®æ¹æ³ããããŸãã
1.ãŠã£ã³ããŠã§ã³ã³ãœãŒã«ãèŠã€ãããã®ã¡ãœããããã¹ãŠãã¡ã€ã«ã«è¡šç€ºãããã©ã°ã€ã³ãäœæããŸã
2. class-dumpã䜿çšããŠããã©ã€ããŒããã¬ãŒã ã¯ãŒã¯ãããã¹ãŠã®ããããŒãååŸããããã§ãã®ã¯ã©ã¹ãèŠã€ããããšããŸãã
3. XVimãããžã§ã¯ãããŒãžã«ç§»åãããã¹ãŠã®ãã©ã€ããŒããªãŒããŒãããã«é£ããŠè¡ããŸãã
ã©ã®æ¹åã«è¡ããã¯çµ¶å¯Ÿã«é¢ä¿ãããŸãããäž»ãªããšã¯ãã³ã³ãœãŒã«ã 'NSTextView'ã®ãµãã¯ã©ã¹ã§ããã次ã®ã¡ãœãããå«ãŸããŠããããšãèŠã€ããããšã§ãïŒ insertTextïŒã insertNewLine:ã ããã§ããŠã£ã³ããŠå ã§ã³ã³ãœãŒã«ãèŠã€ããŠãããã«å¿ èŠãªæ å ±ã®è¡ãæžãçããããšãã§ããŸããã
次ã«ããã°ã¢ãŒããæ åœãããã¿ã³ãè¿œå ããä»ã®ãã©ã°ã€ã³ããæ å ±ãååŸããå¿ èŠããããŸãã
æåã®ãã©ã°ã€ã³ã®åŸãã³ã³ãœãŒã«ã®é£ã«ã³ã³ãããŒã«ãå«ããDVTScopeBarViewããããããšãããããŸãã ããã«ãã¿ã³ã眮ããŸãã ãDVTScopeBarViewãããããŒãèŠãŠãã¯ã©ã¹ã«addViewOnRightïŒã¡ãœãããå«ãŸããŠããããšã確èªããŸãã éåžžã«è¯ãã®ã§ãä»ã®èŠçŽ ã®äœçœ®ãæ°ã«ããã«ããã¿ã³ãããŒã«è¿œå ã§ããŸãã
IDEConsoleTextViewããã³DVTScopeBarViewãæ€çŽ¢ããŸã
- (IDEConsoleTextView *)consoleViewInMainView:(NSView *)mainView { for (NSView *childView in mainView.subviews) { if ([childView isKindOfClass:NSClassFromString(@"IDEConsoleTextView")]) { return (IDEConsoleTextView *)childView; } else { NSView *v = [self consoleViewInMainView:childView]; if ([v isKindOfClass:NSClassFromString(@"IDEConsoleTextView")]) { return (IDEConsoleTextView *)v; } } } return nil; } - (DVTScopeBarView *)scopeBarViewInView:(NSView *)view { for (NSView *childView in view.subviews) { if ([childView isKindOfClass:NSClassFromString(@"DVTScopeBarView")]) { return (DVTScopeBarView *)childView; } else { NSView *v = [self scopeBarViewInView:childView]; if ([v isKindOfClass:NSClassFromString(@"DVTScopeBarView")]) { return (DVTScopeBarView *)v; } } } return nil; } - (void)someMethod { NSWindow *window = [NSApp keyWindow]; NSView *contentView = window.contentView; IDEConsoleTextView *console = [self consoleViewInMainView:contentView];// DVTScopeBarView *scopeBar = nil; NSView *parent = console.superview; while (!scopeBar) { if (!parent) break; scopeBar = [self scopeBarViewInView:parent]; parent = parent.superview; } //... }
ããã§ãããŒã«ãã¿ã³ãè¿œå ããããŠã£ã³ããŠã«ã³ã³ãœãŒã«ãèŠã€ãããŸããã ã©ããããããä»ã®ãã©ã°ã€ã³ããæ å ±ãååŸããŠè¡šç€ºããããšãæ®ã£ãŠããŸãã æãç°¡åãªãªãã·ã§ã³ïŒãNSNotificationCenterãã䜿çšããŸãã ãã©ã°ã€ã³ã¯Xcodeç°å¢ã«ããŒããããããããéç¥ããã£ããã§ããããããã©ã°ã€ã³éã§ãã©ã°ã€ã³ãéä¿¡ããã³ãã£ããã§ããŸãã å¿ èŠãªéç¥ããµãã¹ã¯ã©ã€ãããã³ã³ãœãŒã«ã«ãã°ã衚瀺ããããæ瀺ããŸãã ãããè¡ãã«ã¯ãã¯ã©ã€ã¢ã³ããã¡ã€ã«ïŒä»ã®ãã©ã°ã€ã³ã䜿çšãããã¡ã€ã«ïŒã«é¢æ°ãäœæããå¿ èŠãªéç¥ãéä¿¡ããŠãã©ã°ã€ã³ã§ãã£ããããŸãã
ãã°æ©èœãšã³ã³ãœãŒã«è¡šç€º
ã芧ã®ãšããããã°ã¯çµ¶å¯Ÿã«ä»»æã®ãã©ã³ãã§è¡šç€ºã§ããŸãã
void PluginLogWithName(NSString *pluginName, NSString *format, ...) { NSString *name = @""; if (pluginName.length) { name = pluginName; } va_list argumentList; va_start(argumentList, format); NSString *string = [NSString stringWithFormat:@"%@ Plugin Console %@: ", [NSDate date], name]; NSString* msg = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@%@",string, format] arguments:argumentList]; NSMutableAttributedString *logString = [[NSMutableAttributedString alloc] initWithString:msg attributes:nil]; [logString setAttributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Helvetica-Bold" size:15.f] forKey:NSFontAttributeName] range:NSMakeRange(0, string.length)]; [[NSNotificationCenter defaultCenter] postNotificationName:PluginLoggerShouldLogNotification object:logString]; va_end(argumentList); } - (void)addLog:(NSNotification *)notification {// for (NSWindow *window in [NSApp windows]) {// NSView *contentView = window.contentView; IDEConsoleTextView *console = [self consoleViewInMainView:contentView];// console.logMode = 1;// [console insertText:notification.object];// [console insertNewline:@""];// } }
ã芧ã®ãšããããã°ã¯çµ¶å¯Ÿã«ä»»æã®ãã©ã³ãã§è¡šç€ºã§ããŸãã
ããã§ã2çªç®ã®ãã©ã°ã€ã³ã®æºåãã§ããŸããã å®å šãªãœãŒã¹ã¯ããã«ãããŸã ã ãã©ã°ã€ã³ã¯æ¬¡ã®ããã«ãªããŸãã
3çªç®ã®ãã©ã°ã€ã³
ããããã©ã°ã€ã³ãè¿ãã«ãããããããžã®ã¢ã¯ã»ã¹ãXcodeã®å·Šããã«ã®ã»ã¯ã·ã§ã³ãšåãã§ããã°ããã§ããã...
ãã©ã°ã€ã³ãXcodeãŠã£ã³ããŠã«çµ±åããããšãèããã«èª°ã§ãç¬èªã®ãã©ã°ã€ã³ãè¿œå ã§ããããã«ãç¬èªã®ããã«ãXcodeã«è¿œå ããŸãããã
ããã§ã¯ã以åã®äž¡æ¹ã®ãã©ã°ã€ã³ã圹ç«ã¡ãŸãã å°ãªããšã圌ãã¯ç§ã«ãšã£ãŠéå®ããŸããã ãã°ãå¿é ããããç¡éã®ã¯ã©ãã·ã¥ãèŠã€ããããããããç解ããããç¡éã®ããããŒãã¡ã€ã«ãæãäžãããããå¿ èŠã¯ãããŸããã çµæã«ã€ããŠã話ããŸãã
ãNSToolbarããŠã£ã³ããŠããããããã«ãã¿ã³ãè¿œå ããŸãã æãé£ããã®ã¯ãããŒã«ããŒã«èŠçŽ ãçŽæ¥è¿œå ããã¡ãœããããªãããšã§ãã ãã¡ãããç§ãã¡ããåå®çŸ©ããã代ç人ã¯ã§ããŸããã èŠçŽ ãè¿œå ããããã®ããŒã«ããŒãæã€å¯äžã®ã¡ãœããïŒ insertItemWithItemIdentifierïŒatIndexïŒããèŠçŽ èªäœãããªã²ãŒããçæããŸãã å¯äžã®æ¹æ³ã¯ã代ç人ã誰ã§ãããã確èªããããšã§ãã ãã¶ãããã«ããã€ãã®ã¢ãããŒãããããŸããïŒ ãã°ã«ããªã²ãŒãã¯ã©ã¹ã衚瀺ãããIDEToolbarDelegateãã¯ã©ã¹ãååŸããŸãã ããŠãä»åºŠã¯class-dumpã§åãåã£ãããŸãã¯XVimããååŸãããã©ã€ããŒãããããŒã«ç§»åããŠãããã§ãã®ã¯ã©ã¹ãæ¢ããŸãã ãã®ã¯ã©ã¹ã«ã¯ãé¢å¿ã®ããããããã£ã§ããtoolbarItemProvidersãšallowedItemIdentifiersãããã«è¡šç€ºãããŸãã ãããããããªã²ãŒãã«ã¯ãèŠçŽ ãæäŸããã ãã®ãªããžã§ã¯ãã®èŸæžãå«ãŸããŠããŸãã ãã°ã«toolbarItemProvidersã®çŸåšã®å 容ã衚瀺ãããšã次ã®ãããªèŸæžã衚瀺ãããŸãã
{ "some_id":<IDEToolbarItemProxy class>, "some_other_id":<IDEToolbarItemProxy class>, }
ããŠããã1ã€ã®æãããããããŸã-ããã¯ã¯ã©ã¹ 'IDEToolbarItemProxy'ã§ãã ãŸããããããŒã®ã€ã³ã¿ãŒãã§ã€ã¹ã調ã¹ãŠãèå¥åïŒãNSToolbarãã®èŠçŽ ã®èå¥åã§ããå¯èœæ§ãé«ãïŒã§åæåããã providerClassããããã£ãããããšã確èªããŸãã ãããã providerClassãšã¯äœã§ãã©ã®ããã«å®è£ ããã®ã§ããããïŒ ç¹å®ã®ã¯ã©ã¹ã«å«ãŸããå 容ãç解ããã«ã¯ã2ã€ã®æ¹æ³ããããŸãã
1.ãããã®ã¯ã©ã¹ãšãã®ã¡ãœããããèŸæžtoolbarItemProvidersã®ãã¹ãŠã®ãããã€ããŒãã掟çãããŸãã
2.空ã®ã¯ã©ã¹ãäœæããèŸæžã«è¿œå ããXcodeã®ã¯ã©ãã·ã¥ããã£ããããŠãã©ã®ã¡ãœãããæ¬ èœããŠããããç¥ãããŸãã
ç§ã¯2çªç®ã®æ¹æ³ãæ¡çšããŸããããæåã®æ¹æ³ã¯ããæ£ããããã§ãã ãããããã®ãã©ã°ã€ã³ãæžãããšãããªãããã®çç±ã§ãã®èãã¯æãã€ããŸããã§ããã
ãããã£ãŠãã¯ã©ã¹ãäœæããããªã²ãŒãã«è¿œå ããŸãã
ã³ãŒã
IDEToolbarDelegate *delegate = (IDEToolbarDelegate *)window.toolbar.delegate;// if ([delegate isKindOfClass:NSClassFromString(@"IDEToolbarDelegate")]) { IDEToolbarItemProxy * proxy = [[NSClassFromString(@"IDEToolbarItemProxy") alloc] initWithItemIdentifier:PluginButtonIdentifier];// proxy.providerClass = [PluginButtonProvider class];// ( ) NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary:delegate.toolbarItemProviders];// [d setObject:proxy forKey:proxy.toolbarItemIdentifier];// delegate.toolbarItemProviders = d;// NSMutableArray *ar = [NSMutableArray arrayWithArray:delegate.allowedItemIdentifiers];// [ar addObject:proxy.toolbarItemIdentifier]; delegate.allowedItemIdentifiers = ar; [window.toolbar insertItemWithItemIdentifier:PluginButtonIdentifier atIndex:window.toolbar.items.count];// }
ãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããXcodeãåèµ·åããŠãããã«ã¯ã©ãã·ã¥ããã£ããããŸãã ãã°ãèŠãŠãã¯ã©ã¹ã«+ïŒidïŒitemForItemIdentifierïŒïŒidïŒarg1 forToolbarInWindowïŒïŒidïŒarg2ã¡ãœãããå¿ èŠã§ããããšãç解ããŸãã ãã®ã¡ãœããã¯ããããã³ã«ãIDEToolbarItemProviderãã§èª¬æãããŠããŸãã ãã©ã°ã€ã³ãã¢ã³ã€ã³ã¹ããŒã«ããXcodeãå®è¡ããŠãã®ã¡ââãœãããè¿œå ããŸãã ã¡ãœããã®ååãããå ¥åã§èå¥åãšãŠã£ã³ããŠãååŸããåºåã§ãªããžã§ã¯ããååŸããå¿ èŠãããããšã¯æããã§ãã Nåç®ã®ã¯ã©ãã·ã¥ãšXcodeã®åèµ·åã«ããè©Šè¡é¯èª€ã«ãããã®ãããªæäœã«ããããããã¯ã©ã¹ãDVTViewControllerToolbarItemãã®ãªããžã§ã¯ãã§ããããšãããããŸãã ãããŠãããã¯ã¯ã©ã¹ãDVTGenericButtonViewControllerãã§é çªã«åæåãããŸãã ãªããžã§ã¯ããDVTGenericButtonViewControllerãèªäœã«ã¯ã次ã®åæåããããŸãã
XcodeããŒãžã§ã³6ããåïŒ initWithButtonïŒactionBlockïŒitemIdentifierïŒwindowïŒ
ããŒãžã§ã³6以éïŒ initWithButtonïŒactionBlockïŒsetupTeardownBlockïŒitemIdentifierïŒwindowïŒ
ã¡ãœããã®ååããããã¿ã³ãæŒããããšãã«åŒã³åºããããããã¯ãèå¥åãããã³ãŠã£ã³ããŠãå¿ èŠã§ããããšã¯æããã§ãã
ã·ã³ãã«ãªãã¿ã³ãäœæããå¿ èŠãªã³ã³ãããŒã©ãŒãåæåããŸãã
ã³ãŒããããã
DVTGenericButtonViewController *bvc = [(DVTGenericButtonViewController*)[NSClassFromString(@"DVTGenericButtonViewController") alloc] initWithButton:button actionBlock:^(NSButton *sender){} setupTeardownBlock:nil itemIdentifier:PluginButtonIdentifier window:arg2]; DVTViewControllerToolbarItem *c = [ NSClassFromString(@"DVTViewControllerToolbarItem") toolbarItemWithViewController:bvc];
ãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããXcodeãåèµ·åããŸãã ããã§ãã¿ã³ãXcodeã«è¿œå ãããŸããã ãã¿ã³ã®ãã³ãã©ãŒãèšè¿°ããããšã¯æ®ã£ãŠããŸãã ãã¿ã³ãã¯ãªãã¯ãããšãéããŠããªãå Žåã¯å³åŽã®ããã«ãéãããªããžã§ã¯ãããã®ããã«ã«è¿œå ãããŸãã å³åŽã®ããã«ãéããæåã®ãã©ã°ã€ã³ãèµ·åããŸãã çµæã確èªãããšãããã«ããDVTSplitViewããªããžã§ã¯ãã§ããããšãæããã«ãªããŸãã ããã«ãå³åŽã®ããã«ãé衚瀺ã«ãªã£ãŠããå Žåã¯ãããã°ã©ã ã§ãã®ããã«ãéãæ¹æ³ã決å®ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããã¹ãŠã®ãNSToolbarItemãããŠã£ã³ããŠã®ããŒã«ããŒãããã°ã«åºåããŸãã å¿ èŠãªãªããžã§ã¯ããæåŸã§ããããšãç¥ã£ãŠããŸãïŒãã¿ã³ããŸã è¿œå ãããŠããªãå ŽåïŒã å¿ èŠãªãNSToolbarItemããååŸãããããå¶åŸ¡ãããŠãŒã¶ãŒã確èªããŸããã€ãŸãããtargetãããããã£ã確èªããŸãã ãNSToolbarItemãã®ã¿ãŒã²ããã¯ãã¯ã©ã¹ã_IDEWorkspacePartsVisibilityToolbarViewControllerãã®ãªããžã§ã¯ãã§ãã å°æ¥çã«ãŠã£ã³ããŠã§å¿ èŠãªãNSToolbarItemããèŠã€ããããã«ã®ã¿å¿ èŠãªã®ã§ããã®ã€ã³ã¿ãŒãã§ã€ã¹ãèŠãå¿ èŠã¯ãããŸããïŒçªç¶ãããã¯å¥ã®çš®é¡ã«é 眮ããããã誰ããç§ãã¡ã«èŠçŽ ãè¿œå ããŸãïŒã ãã¹ãŠã®æºåãæŽã£ãã®ã§ãå³åŽã®ããã«ã衚瀺ãããŠã£ã³ããŠã§ãããèŠã€ããŠãªããžã§ã¯ããè¿œå ã§ããŸãã
ãã¿ã³åŠç
NSWindow *window = arg2; NSToolbarItem *item = nil; for (NSToolbarItem *it in [[window toolbar] items]) {// if ([it.target isMemberOfClass:NSClassFromString(@"_IDEWorkspacePartsVisibilityToolbarViewController")]) { item = it; break; } } NSSegmentedControl *control = (NSSegmentedControl *)item.view;// if ([sender state] == NSOnState) {// if (![control isSelectedForSegment:2]) {// [control setSelected:YES forSegment:2];// [item.target performSelector:item.action withObject:control];// } DVTSplitView *splitView = [PluginButtonProvider splitViewForWindow:window];// PanelView *myView = [[PluginPanel sharedPlugin] myViewForWindow:window];/// myView.frame = splitView.bounds;// [myView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; for (NSView *sub in splitView.subviews) {// [sub setHidden:YES]; } [splitView addSubview:myView];// } else { DVTSplitView *splitView = [PluginButtonProvider splitViewForWindow:window];// PanelView *myView = [[PluginPanel sharedPlugin] myViewForWindow:window];/// [myView removeFromSuperview];// for (NSView *sub in splitView.subviews) {// [sub setHidden:NO]; } }
ç§ãã¡ã®ãªããžã§ã¯ãã¯ãNSViewããªããžã§ã¯ãã§ãããããã«ã¯ãDVTChooserViewããšéåžžã®ãNSViewããå«ãŸããããã«ãã©ã°ã€ã³ã®ã³ã³ãã³ããè¿œå ãããŸãã ãªããDVTChooserViewããªã®ã§ããïŒ ããã«ãå¯èœãªéãXcodeãŠã£ã³ããŠã«åããããã ãããè¡ãã«ã¯ãæåã®ãã©ã°ã€ã³ãèµ·åããå·ŠåŽã®ããã«ãèŠãŠããDVTChooserViewããå¿ èŠãªãã®ã§ããããšãããããŸãã ãDVTChooserViewãã«ã¯ããã¿ã³ãšãã¿ã³ããªã³/ãªãã«ãªã£ããšããå€æã§ããé©åãªããªã²ãŒããåãããNSMatrixããå«ãŸããŠããŸãã ãŸãããã®ãªããžã§ã¯ãã¯ãDVTChoiceããªããžã§ã¯ããå ¥åãšããŠåãåããæäœããŸãã ãDVTChoiceãã«ã¯ã¢ã€ã³ã³ã眲åãããã³ãã®ãªããžã§ã¯ããåŠçãããªããžã§ã¯ããå«ãŸããŠããããšãèãããšãããã¯æã䟿å©ã§ãã
ãªããžã§ã¯ããšè¿œå èŠçŽ
// DVTChooserView _chooserView = [[NSClassFromString(@"DVTChooserView") alloc] initWithFrame:NSZeroRect]; _chooserView.allowsEmptySelection = NO; _chooserView.allowsMultipleSelection = NO; _chooserView.delegate = self; // - (void)chooserView:(DVTChooserView *)view userWillSelectChoices:(NSArray *)choices { DVTChoice *choice = [choices lastObject];// self.contentView = [[choice representedObject] view];// } // DVTChoice DVTChoice *plugin = note.object;// if (plugin) { NSWindow *window = [[note userInfo] objectForKey:PluginPanelWindowNotificationKey];// PanelView *panel = [self myViewForWindow:window];// [panel.chooserView.mutableChoices addObject:plugin];// DVTChooserView if (!panel.contentView) { panel.contentView = [[[[panel.chooserView mutableChoices] lastObject] representedObject] view];// , } }
以äžã§ãã 3çªç®ã®ãã©ã°ã€ã³ã®æãèå³æ·±ãå Žæã調ã¹ãŸããã ãã¹ãŠã®ãœãŒã¹ã¯ãã¡ãã§ãã
ãã©ã°ã€ã³ãããã«ã«è¿œå ããŸã
Xcodeã«ããã«å šäœãè¿œå ããŸããã ããã§ã¯ãäœããåããŸãããã
Xcodeã®è€éããç解ããå¿ èŠããªããªã£ããããããã3è¡ã®ã³ãŒãã§ãã©ã°ã€ã³ãããã«ã«è¿œå ã§ããŸãã
3ã€ã®éæ³ã®ç·
NSImage *image = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"plugin_icon"]];// // , . 1- TPViewController *c = [[TPViewController alloc] initWithNibName:@"TPView" bundle:[NSBundle bundleForClass:self.class]]; // DVTChoice . 2- DVTChoice *choice = [[NSClassFromString(@"DVTChoice") alloc] initWithTitle:@"Time" toolTip:@"Time management plugin" image:image representedObject:c]; // , . 3- PluginPanelAddPlugin(choice, [[note userInfo] objectForKey:PluginPanelWindowNotificationKey]);
ããã§ãXcodeãŠã£ã³ããŠã«ç¬èªã®ããã«ã衚瀺ããããã©ã°ã€ã³ãè¿œå ã§ããŸãã ããã§ããã©ã°ã€ã³ã®äžéšã1ãæã«é 眮ã§ããŸãã
æåŸã«-ããã«ã®äœ¿çšäŸ-Xcodeã®ã·ã³ãã«ãªã¿ã€ã ãã©ãã«ãŒã
ã¿ã€ã ãã©ã°ã€ã³