Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
RBSplitSubview Class Reference

#include <RBSplitSubview.h>

+ Inheritance diagram for RBSplitSubview:
+ Collaboration diagram for RBSplitSubview:

Instance Methods

(id) - initWithFrame:
 
(RBSplitView *) - splitView
 
(RBSplitView *) - couplingSplitView
 
(RBSplitView *) - outermostSplitView
 
(RBSplitView *) - asSplitView
 
(RBSplitView *) - coupledSplitView
 
(void) - setCoupled:
 
(BOOL) - isCoupled
 
(BOOL) - splitViewIsHorizontal
 
(NSUInteger) - numberOfSubviews
 
(void) - setTag:
 
(NSInteger) - tag
 
(void) - setIdentifier:
 
(NSString *) - identifier
 
(NSUInteger) - position
 
(void) - setPosition:
 
(BOOL) - isCollapsed
 
(RBSSubviewStatus- status
 
(BOOL) - canCollapse
 
(void) - setCanCollapse:
 
(BOOL) - canShrink
 
(BOOL) - canExpand
 
(CGFloat) - minDimension
 
(CGFloat) - maxDimension
 
(void) - setMinDimension:andMaxDimension:
 
(CGFloat) - expand
 
(CGFloat) - collapse
 
(BOOL) - collapseWithAnimation
 
(BOOL) - expandWithAnimation
 
(BOOL) - collapseWithAnimation:withResize:
 
(BOOL) - expandWithAnimation:withResize:
 
(CGFloat) - dimension
 
(void) - setDimension:
 
(CGFloat) - changeDimensionBy:mayCollapse:move:
 
(void) - dealloc [implementation]
 
(BOOL) - isFlipped [implementation]
 
(BOOL) - isOpaque [implementation]
 
(void) - setHidden: [implementation]
 
(BOOL) - acceptsFirstResponder [implementation]
 
(NSString *) - description [implementation]
 
(void) - drawRect: [implementation]
 
(void) - display [implementation]
 
(BOOL) - autoresizesSubviews [implementation]
 
(void) - setAutoresizesSubviews: [implementation]
 
(void) - resizeSubviewsWithOldSize: [implementation]
 
(NSView *) - hitTest: [implementation]
 
(void) - mouseDown: [implementation]
 
(void) - encodeWithCoder: [implementation]
 
(id) - initWithCoder: [implementation]
 
(void) - RB___setHidden: [implementation]
 
(animationData *) - RB___animationData:resize: [implementation]
 
(void) - RB___stepAnimation [implementation]
 
(BOOL) - RB___stopAnimation [implementation]
 
(CGFloat) - RB___visibleDimension [implementation]
 
(CGFloat) - RB___setMinAndMaxTo:savingMin:andMax: [implementation]
 
(CGFloat) - RB___collapse [implementation]
 
(CGFloat) - RB___expandAndSetToMinimum: [implementation]
 
(void) - RB___finishCollapse:withFraction: [implementation]
 
(void) - RB___finishExpand:withFraction: [implementation]
 
(void) - RB___setFrameSize:withFraction: [implementation]
 
(void) - RB___setFrame:withFraction:notify: [implementation]
 
(double) - RB___fraction [implementation]
 
(void) - RB___copyIntoCache: [implementation]
 
(void) - RB___updateFromCache:withTotalDimension: [implementation]
 
(BOOL) - RB___clearResponder [implementation]
 

Class Methods

(BOOL) + animating
 

Protected Attributes

NSString * identifier
 
NSInteger tag
 
CGFloat minDimension
 
CGFloat maxDimension
 
double fraction
 
NSRect previous
 
NSSize savedSize
 
NSUInteger actDivider
 
BOOL canDragWindow
 
BOOL canCollapse
 
BOOL notInLimits
 

Detailed Description

Definition at line 22 of file RBSplitSubview.h.

Method Documentation

◆ acceptsFirstResponder

- (BOOL) acceptsFirstResponder
implementation

Definition at line 16 of file RBSplitSubview.m.

92 {
93 return NO;
94}

References currentAnimation.

◆ animating

+ (BOOL) animating

Definition at line 16 of file RBSplitSubview.m.

21 {
22 return currentAnimation!=NULL;
23}
static animationData * currentAnimation

◆ asSplitView

- (RBSplitView *) asSplitView

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

51 {
52 return nil;
53}
return nil

◆ autoresizesSubviews

- (BOOL) autoresizesSubviews
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

374 {
375 return YES;
376}

◆ canCollapse

- (BOOL) canCollapse

◆ canExpand

- (BOOL) canExpand

Definition at line 16 of file RBSplitSubview.m.

189 {
190 return [self RB___visibleDimension]<maxDimension;
191}

◆ canShrink

- (BOOL) canShrink

Definition at line 16 of file RBSplitSubview.m.

184 {
185 return [self RB___visibleDimension]>([self canCollapse]?0.0:minDimension);
186}

◆ changeDimensionBy:mayCollapse:move:

- (CGFloat) changeDimensionBy: (CGFloat) increment
mayCollapse: (BOOL) mayCollapse
move: (BOOL) move 

Definition at line 16 of file RBSplitSubview.m.

410 :(CGFloat)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move {
411 RBSplitView* sv = [self splitView];
412 if (!sv||(fabs(increment)<1.0)) {
413 return 0.0;
414 }
415 BOOL ishor = [sv isHorizontal];
416 NSRect frame = [self frame];
417 CGFloat olddim = DIM(frame.size);
418 CGFloat newdim = MAX(0.0,olddim+increment);
419 if (newdim<olddim) {
420 if (newdim<minDimension) {
421// Collapse if needed
422 if (mayCollapse&&[self canCollapse]&&(newdim<MAX(1.0,minDimension*(0.5-HYSTERESIS)))) {
423 return [self RB___collapse];
424 }
425 newdim = minDimension;
426 }
427 } else if (newdim>olddim) {
428 if (olddim<1.0) {
429// Expand if needed.
430 if (newdim>(minDimension*(0.5+HYSTERESIS))) {
431 newdim = MAX(newdim,[self RB___expandAndSetToMinimum:YES]);
432 } else {
433 return 0.0;
434 }
435 }
436 if (newdim>maxDimension) {
437 newdim = maxDimension;
438 }
439 }
440 if ((int)newdim!=(int)olddim) {
441// The dimension has changed.
442 increment = newdim-olddim;
443 DIM(frame.size) = newdim;
444 if (move) {
445 DIM(frame.origin) -= increment;
446 }
447// We call super instead of self here to postpone adjusting subviews for nested splitviews.
448// [super setFrameSize:frame.size];
449 [super setFrame:frame];
450 [sv RB___setMustClearFractions];
451 [sv setMustAdjust];
452 }
453 return newdim-olddim;
454}
#define MAX(A, B)
Definition OOMaths.h:114
return self
#define DIM(x)
#define HYSTERESIS
RBSplitView * splitView()

◆ collapse

- (CGFloat) collapse

Definition at line 16 of file RBSplitSubview.m.

237 {
238 return [self RB___collapse];
239}

◆ collapseWithAnimation

- (BOOL) collapseWithAnimation

Definition at line 16 of file RBSplitSubview.m.

243 {
244 return [self collapseWithAnimation:YES withResize:YES];
245}

◆ collapseWithAnimation:withResize:

- (BOOL) collapseWithAnimation: (BOOL) animate
withResize: (BOOL) resize 

Definition at line 16 of file RBSplitSubview.m.

256 :(BOOL)animate withResize:(BOOL)resize {
258 if ([self canCollapse]) {
259 if (animate&&[self RB___animationData:YES resize:resize]) {
260 [self RB___clearResponder];
261 [self RB___stepAnimation];
262 return YES;
263 } else {
264 [self RB___collapse];
265 }
266 }
267 }
268 return NO;
269}
@ RBSSubviewNormal
RBSSubviewStatus status()

◆ coupledSplitView

- (RBSplitView *) coupledSplitView

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

55 {
56 return nil;
57}

◆ couplingSplitView

- (RBSplitView *) couplingSplitView

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

108 {
109 id result = [self superview];
110 if ([result isKindOfClass:[RBSplitView class]]) {
111 return (RBSplitView*)result;
112 }
113 return nil;
114}

◆ dealloc

- (void) dealloc
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

45 {
46 [identifier release];
47 [super dealloc];
48}

◆ description

- (NSString *) description
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

152 {
153 return [identifier length]>0?[NSString stringWithFormat:@"%@(%@)",[super description],identifier]:[super description];
154}

◆ dimension

- (CGFloat) dimension

Definition at line 16 of file RBSplitSubview.m.

309 {
310 CGFloat dim = [self RB___visibleDimension];
311 if (dim<=0.0) {
312 dim = [[self splitView] RB___dimensionWithoutDividers]*fraction;
313 if (dim<minDimension) {
314 dim = minDimension;
315 } else if (dim>maxDimension) {
316 dim = maxDimension;
317 }
318 }
319 return dim;
320}

◆ display

- (void) display
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

362 {
363 RBSplitView* sv = [self splitView];
364 if (sv) {
365 if ([sv mustAdjust]) {
366 [sv display];
367 } else {
368 [super display];
369 }
370 }
371}

◆ drawRect:

- (void) drawRect: (NSRect) rect
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

347 :(NSRect)rect {
348 RBSplitView* sv = [self splitView];
349 NSColor* bg = [sv background];
350 if (bg) {
351 [bg set];
352 NSRectFillUsingOperation(rect,NSCompositeSourceOver);
353 }
354 id del = [sv delegate];
355 if ([del respondsToSelector:@selector(splitView:willDrawSubview:inRect:)]) {
356 [del splitView:sv willDrawSubview:self inRect:rect];
357 }
358}
IBOutlet id delegate
Definition RBSplitView.h:25
NSColor * background
Definition RBSplitView.h:27

◆ encodeWithCoder:

- (void) encodeWithCoder: (NSCoder*) coder
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

545 :(NSCoder*)coder {
546 NSRect frame;
547 BOOL coll = [self isCollapsed];
548 if (coll) {
549// We can't encode a collapsed subview as-is, so we correct the frame size first and add WAYOUT
550// to the origin to signal it was collapsed.
551 NSRect newf = frame = [self frame];
552 newf.origin.x += WAYOUT;
553 [super setFrameOrigin:newf.origin];
554 newf.size = savedSize;
555 [super setFrameSize:newf.size];
556 }
557 [super encodeWithCoder:coder];
558 if (coll) {
559 [super setFrame:frame];
560 }
561 if ([coder allowsKeyedCoding]) {
562 [coder encodeObject:identifier forKey:@"identifier"];
563 [coder encodeInteger:tag forKey:@"tag"];
564 [coder encodeDouble:minDimension forKey:@"minDimension"];
565 [coder encodeDouble:maxDimension forKey:@"maxDimension"];
566 [coder encodeDouble:fraction forKey:@"fraction"];
567 [coder encodeBool:canCollapse forKey:@"canCollapse"];
568 } else {
569 [coder encodeObject:identifier];
570 [coder encodeValueOfObjCType:@encode(typeof(tag)) at:&tag];
571 [coder encodeValueOfObjCType:@encode(typeof(minDimension)) at:&minDimension];
572 [coder encodeValueOfObjCType:@encode(typeof(maxDimension)) at:&maxDimension];
573 [coder encodeValueOfObjCType:@encode(typeof(fraction)) at:&fraction];
574 [coder encodeValueOfObjCType:@encode(typeof(canCollapse)) at:&canCollapse];
575 }
576}
#define WAYOUT

◆ expand

- (CGFloat) expand

Definition at line 16 of file RBSplitSubview.m.

228 {
229 return [self RB___expandAndSetToMinimum:NO];
230}

◆ expandWithAnimation

- (BOOL) expandWithAnimation

Definition at line 16 of file RBSplitSubview.m.

249 {
250 return [self expandWithAnimation:YES withResize:YES];
251}

◆ expandWithAnimation:withResize:

- (BOOL) expandWithAnimation: (BOOL) animate
withResize: (BOOL) resize 

Definition at line 16 of file RBSplitSubview.m.

271 :(BOOL)animate withResize:(BOOL)resize {
273 if (animate&&[self RB___animationData:YES resize:resize]) {
274 [self RB___stepAnimation];
275 return YES;
276 } else {
277 [self RB___expandAndSetToMinimum:NO];
278 }
279 }
280 return NO;
281}
@ RBSSubviewCollapsed

◆ hitTest:

- (NSView *) hitTest: (NSPoint) aPoint
implementation

Definition at line 16 of file RBSplitSubview.m.

463 :(NSPoint)aPoint {
464 if ([self mouse:aPoint inRect:[self frame]]) {
465 RBSplitView* sv = [self splitView];
466 id delegate = [sv delegate];
467 if ([delegate respondsToSelector:@selector(splitView:dividerForPoint:inSubview:)]) {
468 actDivider = [delegate splitView:sv dividerForPoint:aPoint inSubview:self];
469 if ((actDivider+1)<[sv RB___numberOfSubviews]) {
470 return self;
471 }
472 }
473 actDivider = NSNotFound;
474 NSView* result = [super hitTest:aPoint];
475 canDragWindow = ![[result opaqueAncestor] isDescendantOf:[[result window] contentView]];
476 return result;
477 }
478 return nil;
479}
NSUInteger actDivider

◆ identifier

- (NSString *) identifier

◆ initWithCoder:

- (id) initWithCoder: (NSCoder*) coder
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

578 :(NSCoder*)coder {
579 if ((self = [super initWithCoder:coder])) {
580 fraction = 0.0;
581 canCollapse = NO;
582 notInLimits = NO;
583 minDimension = 1.0;
585 identifier = @"";
586 actDivider = NSNotFound;
587 canDragWindow = NO;
588 previous = [self frame];
589 savedSize = previous.size;
590 if (previous.origin.x>=WAYOUT) {
591// The subview was collapsed when encoded, so we correct the origin and collapse it.
592 BOOL ishor = [self splitViewIsHorizontal];
593 previous.origin.x -= WAYOUT;
594 DIM(previous.size) = 0.0;
595 [self setFrameOrigin:previous.origin];
596 [self setFrameSize:previous.size];
597 }
598 previous = NSZeroRect;
599 if ([coder allowsKeyedCoding]) {
600 [self setIdentifier:[coder decodeObjectForKey:@"identifier"]];
601 tag = [coder decodeIntegerForKey:@"tag"];
602 minDimension = [coder decodeDoubleForKey:@"minDimension"];
603 maxDimension = [coder decodeDoubleForKey:@"maxDimension"];
604 fraction = [coder decodeDoubleForKey:@"fraction"];
605 canCollapse = [coder decodeBoolForKey:@"canCollapse"];
606 } else {
607 [self setIdentifier:[coder decodeObject]];
608 [coder decodeValueOfObjCType:@encode(typeof(tag)) at:&tag];
609 [coder decodeValueOfObjCType:@encode(typeof(minDimension)) at:&minDimension];
610 [coder decodeValueOfObjCType:@encode(typeof(maxDimension)) at:&maxDimension];
611 [coder decodeValueOfObjCType:@encode(typeof(fraction)) at:&fraction];
612 [coder decodeValueOfObjCType:@encode(typeof(canCollapse)) at:&canCollapse];
613 }
614 }
615 return self;
616}
NSString * identifier

◆ initWithFrame:

- (id) initWithFrame: (NSRect) frame

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

27 :(NSRect)frame {
28 self = [super initWithFrame:frame];
29 if (self) {
30 fraction = 0.0;
31 canCollapse = NO;
32 notInLimits = NO;
33 minDimension = 1.0;
35 identifier = @"";
36 previous = NSZeroRect;
37 savedSize = frame.size;
38 actDivider = NSNotFound;
39 canDragWindow = NO;
40 }
41 return self;
42}

◆ isCollapsed

- (BOOL) isCollapsed

Definition at line 16 of file RBSplitSubview.m.

179 {
180 return [self RB___visibleDimension]<=0.0;
181}

◆ isCoupled

- (BOOL) isCoupled

Definition at line 16 of file RBSplitSubview.m.

64 {
65 return NO;
66}

◆ isFlipped

- (BOOL) isFlipped
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

69 {
70 return NO;
71}

◆ isOpaque

- (BOOL) isOpaque
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

74 {
75 return [[self couplingSplitView] isOpaque];
76}

◆ maxDimension

- (CGFloat) maxDimension

◆ minDimension

- (CGFloat) minDimension

◆ mouseDown:

- (void) mouseDown: (NSEvent*) theEvent
implementation

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

483 :(NSEvent*)theEvent {
484 NSWindow* window = [self window];
485 NSPoint where = [theEvent locationInWindow];
486 if (actDivider<NSNotFound) {
487 // Cache divider# here for the loop
488 NSUInteger thediv = actDivider;
489// The mouse down was inside an alternate drag view; actDivider was just set in hitTest.
490 RBSplitView* sv = [self splitView];
491 NSPoint point = [sv convertPoint:where fromView:nil];
492 [[RBSplitView cursor:RBSVDragCursor] push];
493 NSPoint base = NSZeroPoint;
494// Record the current divider coordinate.
495 CGFloat divc = [sv RB___dividerOrigin:thediv];
496 BOOL ishor = [sv isHorizontal];
497 [sv RB___setDragging:YES];
498// Loop while the button is down.
499 while ((theEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask|NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES])&&([theEvent type]!=NSLeftMouseUp)) {
500// Set up a local autorelease pool for the loop to prevent buildup of temporary objects.
501 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
502 NSDisableScreenUpdates();
503// This does the actual movement.
504 [sv RB___trackMouseEvent:theEvent from:point withBase:base inDivider:thediv];
505 if ([sv mustAdjust]) {
506// If something changed, we clear fractions and redisplay.
508 [sv display];
509 }
510// Change the drag point by the actual amount moved.
511 CGFloat newc = [sv RB___dividerOrigin:thediv];
512 DIM(point) += newc-divc;
513 divc = newc;
514 NSEnableScreenUpdates();
515 [pool drain];
516 }
517 [sv RB___setDragging:NO];
518 [NSCursor pop];
519 actDivider = NSNotFound;
520 return;
521 }
522 if (canDragWindow&&[window isMovableByWindowBackground]&&![[self couplingSplitView] background]) {
523// If we get here, it's a textured (metal) window, the mouse has gone down on an non-opaque portion
524// of the subview, and our RBSplitView has a transparent background. RBSplitView returns NO to
525// mouseDownCanMoveWindow, but the window should move here - after all, the window background
526// is visible right here! So we fake it and move the window as intended. Mwahahaha!
527 where = [window convertBaseToScreen:where];
528 NSPoint origin = [window frame].origin;
529// Now we loop handling mouse events until we get a mouse up event.
530 while ((theEvent = [NSApp nextEventMatchingMask:NSLeftMouseDownMask|NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES])&&([theEvent type]!=NSLeftMouseUp)) {
531// Set up a local autorelease pool for the loop to prevent buildup of temporary objects.
532 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
533 NSPoint now = [window convertBaseToScreen:[theEvent locationInWindow]];
534 origin.x += now.x-where.x;
535 origin.y += now.y-where.y;
536// Move the window by the mouse displacement since the last event.
537 [window setFrameOrigin:origin];
538 where = now;
539 [pool drain];
540 }
541 }
542}
float y
float x
RBSplitView * couplingSplitView()
void RB___trackMouseEvent:from:withBase:inDivider:(NSEvent *theEvent,[from] NSPoint where,[withBase] NSPoint base,[inDivider] NSUInteger indx)
CGFloat RB___dividerOrigin:(NSUInteger indx)
void RB___setDragging:(BOOL flag)
NSCursor * cursor:(RBSVCursorType type)
Definition RBSplitView.m:33
void RB___setMustClearFractions()
BOOL isHorizontal
Definition RBSplitView.h:33
voidpf uLong int origin
Definition ioapi.h:140

◆ numberOfSubviews

- (NSUInteger) numberOfSubviews

Definition at line 16 of file RBSplitSubview.m.

457 {
458 return [[self subviews] count];
459}

◆ outermostSplitView

- (RBSplitView *) outermostSplitView

Definition at line 16 of file RBSplitSubview.m.

117 {
118 id result = nil;
119 id sv = self;
120 while ((sv = [sv superview])&&[sv isKindOfClass:[RBSplitView class]]) {
121 result = sv;
122 }
123 return result;
124}

◆ position

- (NSUInteger) position

Definition at line 16 of file RBSplitSubview.m.

158 {
159 RBSplitView* sv = [self splitView];
160 return sv?[[sv subviews] indexOfObjectIdenticalTo:self]:0;
161}

◆ RB___animationData:resize:

- (animationData *) RB___animationData: (BOOL) start
resize: (BOOL) resize 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

631 :(BOOL)start resize:(BOOL)resize {
632 if (currentAnimation&&(currentAnimation->owner!=self)) {
633// There already is an animation in progress on some other subview.
634 return nil;
635 }
636 if (start) {
637// We want to start (or restart) an animation.
638 RBSplitView* sv = [self splitView];
639 if (sv) {
640 CGFloat dim = [self dimension];
641// First assume the default time, then ask the delegate.
642 NSTimeInterval total = dim*(0.2/150.0);
643 id delegate = [sv delegate];
644 if ([delegate respondsToSelector:@selector(splitView:willAnimateSubview:withDimension:)]) {
645 total = [delegate splitView:sv willAnimateSubview:self withDimension:dim];
646 }
647// No use animating anything shorter than the frametime.
648 if (total>FRAMETIME) {
649 if (!currentAnimation) {
650 currentAnimation = (animationData*)malloc(sizeof(animationData));
651 }
652 if (currentAnimation) {
653 currentAnimation->owner = self;
657 currentAnimation->collapsing = ![self isCollapsed];
659 currentAnimation->finishTime = [NSDate timeIntervalSinceReferenceDate]+total;
660 currentAnimation->resizing = resize;
661 [sv RB___setDragging:YES];
662 }
663 } else if (currentAnimation) {
664 free(currentAnimation);
665 currentAnimation = NULL;
666 }
667 }
668 }
669 return currentAnimation;
670}
#define FRAMETIME

◆ RB___clearResponder

- (BOOL) RB___clearResponder
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

796 {
797 NSWindow* window = [self window];
798 if (window) {
799 NSView* responder = (NSView*)[window firstResponder];
800 if (responder&&[responder respondsToSelector:@selector(isDescendantOf:)]) {
801 if ([responder isDescendantOf:self]) {
802 if ([window makeFirstResponder:nil]) {
803 [responder display];
804 return YES;
805 }
806 }
807 }
808 }
809 return NO;
810}

◆ RB___collapse

- (CGFloat) RB___collapse
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

814 {
815 CGFloat result = 0.0;
816 if (![self isCollapsed]) {
817 RBSplitView* sv = [self splitView];
818 if (sv&&[self canCollapse]) {
819 [self RB___clearResponder];
820 NSRect frame = [self frame];
821 BOOL ishor = [sv isHorizontal];
822 result = DIM(frame.size);
823// For collapsed views, fraction will contain the fraction of the dimension previously occupied
824 DIM(frame.size) = 0.0;
825 [self RB___finishCollapse:frame withFraction:result/[sv RB___dimensionWithoutDividers]];
826 }
827 }
828 return -result;
829}
CGFloat RB___dimensionWithoutDividers()

◆ RB___copyIntoCache:

- (void) RB___copyIntoCache: (subviewCache*) cache
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

746 :(subviewCache*)cache {
747 cache->sub = self;
748 cache->rect = [self frame];
749 cache->size = [self RB___visibleDimension];
750 cache->fraction = fraction;
751 cache->constrain = NO;
752}

◆ RB___expandAndSetToMinimum:

- (CGFloat) RB___expandAndSetToMinimum: (BOOL) setToMinimum
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

849 :(BOOL)setToMinimum {
850 CGFloat result = 0.0;
851 RBSplitView* sv = [self splitView];
852 if (sv&&[self isCollapsed]) {
853 NSRect frame = [super frame];
854 double frac = fraction;
855 BOOL ishor = [sv isHorizontal];
856 if (setToMinimum) {
857 result = DIM(frame.size) = minDimension;
858 } else {
859 result = [sv RB___dimensionWithoutDividers]*frac;
860// We need to apply a compensation factor for proportional resizing in adjustSubviews.
861 CGFloat newdim = floor((frac>=1.0)?result:result/(1.0-frac));
862 DIM(frame.size) = newdim;
863 result = floor(result);
864 }
865 [self RB___finishExpand:frame withFraction:0.0];
866 }
867 return result;
868}

◆ RB___finishCollapse:withFraction:

- (void) RB___finishCollapse: (NSRect) rect
withFraction: (double) value 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

833 :(NSRect)rect withFraction:(double)value {
834 RBSplitView* sv = [self splitView];
835 BOOL finish = [self RB___stopAnimation];
836 [self RB___setFrame:rect withFraction:value notify:YES];
837 [sv RB___setMustClearFractions];
838 if (finish) {
839 [self display];
840 }
841 id delegate = [sv delegate];
842 if ([delegate respondsToSelector:@selector(splitView:didCollapse:)]) {
843 [delegate splitView:sv didCollapse:self];
844 }
845}

◆ RB___finishExpand:withFraction:

- (void) RB___finishExpand: (NSRect) rect
withFraction: (double) value 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

872 :(NSRect)rect withFraction:(double)value {
873 RBSplitView* sv = [self splitView];
874 BOOL finish = [self RB___stopAnimation];
875 [self RB___setFrame:rect withFraction:value notify:YES];
876 [sv RB___setMustClearFractions];
877 if (finish) {
878 [self display];
879 }
880 id delegate = [sv delegate];
881 if ([delegate respondsToSelector:@selector(splitView:didExpand:)]) {
882 [delegate splitView:sv didExpand:self];
883 }
884}

◆ RB___fraction

- (double) RB___fraction
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

917 {
918 return fraction;
919}

◆ RB___setFrame:withFraction:notify:

- (void) RB___setFrame: (NSRect) rect
withFraction: (double) value
notify: (BOOL) notify 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

888 :(NSRect)rect withFraction:(double)value notify:(BOOL)notify {
889 RBSplitView* sv = [self splitView];
890 id delegate = nil;
891 if (notify) {
892 delegate = [sv delegate];
893// If the delegate method isn't implemented, we ignore the delegate altogether.
894 if ([delegate respondsToSelector:@selector(splitView:changedFrameOfSubview:from:to:)]) {
895// If the rects are equal, the delegate isn't called.
896 if (NSEqualRects(previous,rect)) {
897 delegate = nil;
898 }
899 } else {
900 delegate = nil;
901 }
902 }
903 [sv setMustAdjust];
904 [self setFrame:rect];
905 fraction = value;
906 [delegate splitView:sv changedFrameOfSubview:self from:previous to:rect];
907 previous = delegate?rect:NSZeroRect;
908}

◆ RB___setFrameSize:withFraction:

- (void) RB___setFrameSize: (NSSize) size
withFraction: (double) value 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

910 :(NSSize)size withFraction:(double)value {
911 [[self splitView] setMustAdjust];
912 [self setFrameSize:size];
913 fraction = value;
914}
voidpf void uLong size
Definition ioapi.h:134

◆ RB___setHidden:

- (void) RB___setHidden: (BOOL) flag
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

623 :(BOOL)flag {
624 [super setHidden:flag];
625}

◆ RB___setMinAndMaxTo:savingMin:andMax:

- (CGFloat) RB___setMinAndMaxTo: (CGFloat) value
savingMin: (CGFloat*) oldmin
andMax: (CGFloat*) oldmax 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

780 :(CGFloat)value savingMin:(CGFloat*)oldmin andMax:(CGFloat*)oldmax {
781 *oldmin = [self minDimension];
782 *oldmax = [self maxDimension];
783 if (value<*oldmin) {
784 value = *oldmin;
785 }
786 if (value>*oldmax) {
787 value = *oldmax;
788 }
789 minDimension = maxDimension = value;
790 return value;
791}

◆ RB___stepAnimation

- (void) RB___stepAnimation
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

673 {
674 NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
675 animationData* anim = [self RB___animationData:NO resize:NO];
676 if (anim) {
677 RBSplitView* sv = [self splitView];
678 NSTimeInterval remain = anim->finishTime-now;
679 NSRect frame = [self frame];
680 BOOL ishor = [sv isHorizontal];
681// Continuing animation only makes sense if we still have at least FRAMETIME available.
682 if (remain>=FRAMETIME) {
683 CGFloat avg = anim->elapsedTime;
684// We try to keep a record of how long it takes, on the average, to resize and adjust
685// one animation frame.
686 if (anim->stepsDone) {
687 avg /= anim->stepsDone;
688 }
689 NSTimeInterval delay = MIN(0.0,FRAMETIME-avg);
690// We adjust the new dimension proportionally to how much of the designated time has passed.
691 CGFloat dim = floor(anim->dimension*(remain-avg)/anim->totalTime);
692 if (dim>4.0) {
693 if (!anim->collapsing) {
694 dim = anim->dimension-dim;
695 }
696 DIM(frame.size) = dim;
697 [self RB___setFrame:frame withFraction:0.0 notify:NO];
698 [sv adjustSubviews];
699 [self display];
700 anim->elapsedTime += [NSDate timeIntervalSinceReferenceDate]-now;
701 ++anim->stepsDone;
702// Schedule a timer to do the next animation step.
703 [self performSelector:@selector(RB___stepAnimation) withObject:nil afterDelay:delay inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode,NSModalPanelRunLoopMode,
704 NSEventTrackingRunLoopMode,nil]];
705 return;
706 }
707 }
708// We're finished, either collapse or expand entirely now.
709 if (anim->collapsing) {
710 DIM(frame.size) = 0.0;
711 [self RB___finishCollapse:frame withFraction:anim->dimension/[sv RB___dimensionWithoutDividers]];
712 } else {
713 CGFloat savemin,savemax;
714 CGFloat dim = [self RB___setMinAndMaxTo:anim->dimension savingMin:&savemin andMax:&savemax];
715 DIM(frame.size) = dim;
716 [self RB___finishExpand:frame withFraction:0.0];
717 minDimension = savemin;
718 maxDimension = savemax;
719 }
720 }
721}
#define MIN(A, B)
Definition OOMaths.h:111
void adjustSubviews()

◆ RB___stopAnimation

- (BOOL) RB___stopAnimation
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

725 {
727 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(RB___stepAnimation) object:nil];
728 free(currentAnimation);
729 currentAnimation = NULL;
730 [[self splitView] RB___setDragging:NO];
731 return YES;
732 }
733 return NO;
734}

◆ RB___updateFromCache:withTotalDimension:

- (void) RB___updateFromCache: (subviewCache*) cache
withTotalDimension: (CGFloat) value 
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

754 :(subviewCache*)cache withTotalDimension:(CGFloat)value {
755 CGFloat dim = [self RB___visibleDimension];
756 if (cache->size>=1.0) {
757// New state is not collapsed.
758 if (dim>=1.0) {
759// Old state was not collapsed, so we just change the frame.
760 [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
761 } else {
762// Old state was collapsed, so we expand it.
763 [self RB___finishExpand:cache->rect withFraction:cache->fraction];
764 }
765 } else {
766// New state is collapsed.
767 if (dim>=1.0) {
768// Old state was not collapsed, so we clear first responder and change the frame.
769 [self RB___clearResponder];
770 [self RB___finishCollapse:cache->rect withFraction:dim/value];
771 } else {
772// It was collapsed already, but the frame may have changed, so we set it.
773 [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
774 }
775 }
776}

◆ RB___visibleDimension

- (CGFloat) RB___visibleDimension
implementation

Provided by category RBSplitSubview(RB___SubviewAdditions).

Definition at line 16 of file RBSplitSubview.m.

738 {
739 BOOL ishor = [self splitViewIsHorizontal];
740 NSRect frame = [self frame];
741 return MAX(0.0,DIM(frame.size));
742}

◆ resizeSubviewsWithOldSize:

- (void) resizeSubviewsWithOldSize: (NSSize) oldBoundsSize
implementation

Definition at line 16 of file RBSplitSubview.m.

383 :(NSSize)oldBoundsSize {
384 RBSplitView* sv = [self splitView];
385 if (sv) {
386 BOOL ishor = [sv isHorizontal];
387 NSRect frame = [self frame];
388 CGFloat dim = DIM(frame.size);
389 CGFloat other = OTHER(frame.size);
390// We resize subviews only when we're inside the subview's limits and the containing splitview's limits.
391 animationData* anim = [self RB___animationData:NO resize:NO];
392 if ((dim>=(anim&&!anim->resizing?anim->dimension:minDimension))&&(dim<=maxDimension)&&(other>=[sv minDimension])&&(other<=[sv maxDimension])) {
393 if (notInLimits) {
394// The subviews can be resized, so we restore the saved size.
395 oldBoundsSize = savedSize;
396 }
397// We save the size every time the subview's subviews are resized within the limits.
398 notInLimits = NO;
399 savedSize = frame.size;
400 [super resizeSubviewsWithOldSize:oldBoundsSize];
401 } else {
402 notInLimits = YES;
403 }
404 }
405}
#define OTHER(x)

◆ setAutoresizesSubviews:

- (void) setAutoresizesSubviews: (BOOL) flag
implementation

Definition at line 16 of file RBSplitSubview.m.

379 :(BOOL)flag {
380}

◆ setCanCollapse:

- (void) setCanCollapse: (BOOL) flag

Definition at line 16 of file RBSplitSubview.m.

219 :(BOOL)flag {
220 canCollapse = flag;
221}

◆ setCoupled:

- (void) setCoupled: (BOOL) flag

Reimplemented in RBSplitView.

Definition at line 16 of file RBSplitSubview.m.

61 :(BOOL)flag {
62}

◆ setDimension:

- (void) setDimension: (CGFloat) value

Definition at line 16 of file RBSplitSubview.m.

324 :(CGFloat)value {
325 if (value<minDimension) {
326 value = minDimension;
327 } else if (value>maxDimension) {
328 value = maxDimension;
329 }
330 RBSplitView* sv = [self splitView];
331 NSSize size = [self frame].size;
332 BOOL ishor = [sv isHorizontal];
333 if (DIM(size)>0.0) {
334// We're not collapsed, set the size and adjust other subviews.
335 DIM(size) = value;
336 [self setFrameSize:size];
337 [sv adjustSubviewsExcepting:self];
338 } else {
339// We're collapsed, adjust the fraction so that we'll have the (approximately) correct
340// dimension after expanding.
342 }
343}
void adjustSubviewsExcepting:(RBSplitSubview *excepting)

◆ setHidden:

- (void) setHidden: (BOOL) flag
implementation

Definition at line 16 of file RBSplitSubview.m.

79 :(BOOL)flag {
80 if ([self isHidden]!=flag) {
81 RBSplitView* sv = [self splitView];
82 [self RB___setHidden:flag];
83 if (flag) {
84 [sv adjustSubviews];
85 } else {
87 }
88 }
89}

◆ setIdentifier:

- (void) setIdentifier: (NSString*) aString

Definition at line 16 of file RBSplitSubview.m.

141 :(NSString*)aString {
142 [identifier autorelease];
143 identifier = aString?[aString retain]:@"";
144}

◆ setMinDimension:andMaxDimension:

- (void) setMinDimension: (CGFloat) newMinDimension
andMaxDimension: (CGFloat) newMaxDimension 

Definition at line 16 of file RBSplitSubview.m.

295 :(CGFloat)newMinDimension andMaxDimension:(CGFloat)newMaxDimension {
296 minDimension = MAX(1.0,floor(newMinDimension));
297 if (newMaxDimension<1.0) {
298 newMaxDimension = WAYOUT;
299 }
300 maxDimension = MAX(minDimension,floor(newMaxDimension));
301 CGFloat dim = [self dimension];
302 if ((dim<minDimension)||(dim>maxDimension)) {
303 [[self splitView] setMustAdjust];
304 }
305}

◆ setPosition:

- (void) setPosition: (NSUInteger) newPosition

Definition at line 16 of file RBSplitSubview.m.

163 :(NSUInteger)newPosition {
164 RBSplitView* sv = [self splitView];
165 if (sv) {
166 [self retain];
167 [self removeFromSuperviewWithoutNeedingDisplay];
168 NSArray* subviews = [sv subviews];
169 if (newPosition>=[subviews count]) {
170 [sv addSubview:self positioned:NSWindowAbove relativeTo:nil];
171 } else {
172 [sv addSubview:self positioned:NSWindowBelow relativeTo:[subviews objectAtIndex:newPosition]];
173 }
174 [self release];
175 }
176}
unsigned count
void addSubview:positioned:relativeTo:(NSView *aView, [positioned] NSWindowOrderingMode place, [relativeTo] NSView *otherView)

◆ setTag:

- (void) setTag: (NSInteger) theTag

Definition at line 16 of file RBSplitSubview.m.

133 :(NSInteger)theTag {
134 tag = theTag;
135}

◆ splitView

- (RBSplitView *) splitView

Definition at line 16 of file RBSplitSubview.m.

99 {
100 id result = [self superview];
101 if ([result isKindOfClass:[RBSplitView class]]) {
102 return (RBSplitView*)result;
103 }
104 return nil;
105}

◆ splitViewIsHorizontal

- (BOOL) splitViewIsHorizontal

Definition at line 16 of file RBSplitSubview.m.

127 {
128 return [[self splitView] isHorizontal];
129}

◆ status

- (RBSSubviewStatus) status

Definition at line 16 of file RBSplitSubview.m.

194 {
195 animationData* anim = [self RB___animationData:NO resize:NO];
196 if (anim) {
198 }
199 return [self RB___visibleDimension]<=0.0?RBSSubviewCollapsed:RBSSubviewNormal;
200}
@ RBSSubviewCollapsing
@ RBSSubviewExpanding

◆ tag

- (NSInteger) tag

Member Data Documentation

◆ actDivider

- (NSUInteger) actDivider
protected

Definition at line 38 of file RBSplitSubview.h.

◆ canCollapse

- (BOOL) canCollapse
protected

Definition at line 40 of file RBSplitSubview.h.

◆ canDragWindow

- (BOOL) canDragWindow
protected

Definition at line 39 of file RBSplitSubview.h.

◆ fraction

- (double) fraction
protected

Definition at line 31 of file RBSplitSubview.h.

◆ identifier

- (NSString *) identifier
protected

Definition at line 26 of file RBSplitSubview.h.

◆ maxDimension

- (CGFloat) maxDimension
protected

Definition at line 29 of file RBSplitSubview.h.

◆ minDimension

- (CGFloat) minDimension
protected

Definition at line 28 of file RBSplitSubview.h.

◆ notInLimits

- (BOOL) notInLimits
protected

Definition at line 41 of file RBSplitSubview.h.

◆ previous

- (NSRect) previous
protected

Definition at line 35 of file RBSplitSubview.h.

◆ savedSize

- (NSSize) savedSize
protected

Definition at line 36 of file RBSplitSubview.h.

◆ tag

- (NSInteger) tag
protected

Definition at line 27 of file RBSplitSubview.h.


The documentation for this class was generated from the following files: