Change name of window menu items
[MacVim.git] / src / MacVim / RBSplitSubview.h
blobd05823052674ead703157daece1d28ce41cd6175
1 //
2 // RBSplitSubview.h version 1.1.4
3 // RBSplitView
4 //
5 // Created by Rainer Brockerhoff on 19/11/2004.
6 // Copyright 2004-2006 Rainer Brockerhoff.
7 // Some Rights Reserved under the Creative Commons Attribution License, version 2.5, and/or the MIT License.
8 //
10 #import <Cocoa/Cocoa.h>
12 @class RBSplitView;
14 // These values are used to inquire about the status of a subview.
15 typedef enum {
16 RBSSubviewExpanding=-2,
17 RBSSubviewCollapsing=-1,
18 RBSSubviewNormal=0,
19 RBSSubviewCollapsed=1
20 } RBSSubviewStatus;
22 @interface RBSplitSubview : NSView {
23 // Subclasses normally should use setter methods instead of changing instance variables by assignment.
24 // Most getter methods simply return the corresponding instance variable, so with some care, subclasses
25 // could reference them directly.
26 NSString* identifier; // An identifier string for the subview, default is @"".
27 int tag; // A tag integer for the subview, default is 0.
28 float minDimension; // The minimum dimension. Must be 1.0 or any larger integer.
29 float maxDimension; // The maximum dimension. Must be at least equal to the minDimension.
30 // Set to a large number if there's no maximum.
31 double fraction; // A fractional part of the dimension, used for proportional resizing.
32 // Normally varies between -0.999... and 0.999...
33 // When collapsed, holds the proportion of the RBSplitView's dimension
34 // the view was occupying before collapsing.
35 NSRect previous; // Holds the frame rect for the last delegate notification.
36 NSSize savedSize; // This holds the size the subview had before it was resized beyond
37 // its minimum or maximum limits. Valid if notInLimits is YES.
38 unsigned int actDivider; // This is set temporarily while an alternate drag view is being dragged.
39 BOOL canDragWindow; // This is set temporarily during a mouseDown on a non-opaque subview.
40 BOOL canCollapse; // YES if the subview can be collapsed.
41 BOOL notInLimits; // YES if the subview's dimensions are outside the set limits.
44 // This class method returns YES if some RBSplitSubview is being animated.
45 + (BOOL)animating;
47 // This is the designated initializer for creating extra subviews programmatically.
48 - (id)initWithFrame:(NSRect)frame;
50 // Returns the immediately containing RBSplitView, or nil if there is none.
51 // couplingSplitView returns nil if we're a non-coupled RBSplitView.
52 // outermostSplitView returns the outermost RBSplitView.
53 - (RBSplitView*)splitView;
54 - (RBSplitView*)couplingSplitView;
55 - (RBSplitView*)outermostSplitView;
57 // Returns self if we're a RBSplitView, nil otherwise. Convenient for testing or calling methods.
58 // coupledSplitView returns nil if we're a non-coupled RBSplitView.
59 - (RBSplitView*)asSplitView;
60 - (RBSplitView*)coupledSplitView;
62 // Sets and gets the coupling between the view and its containing RBSplitView (if any). Coupled
63 // RBSplitViews take some parameters, such as divider images, from the containing view. The default
64 // for RBSplitView is YES. However, calling setCoupled: on a RBSplitSubview will have no effect,
65 // and isCoupled will always return false.
66 - (void)setCoupled:(BOOL)flag;
67 - (BOOL)isCoupled;
69 // Returns YES if the containing RBSplitView is horizontal.
70 - (BOOL)splitViewIsHorizontal;
72 // Returns the number of subviews. Just a convenience method.
73 - (unsigned)numberOfSubviews;
75 // Sets and gets the tag.
76 - (void)setTag:(int)theTag;
77 - (int)tag;
79 // Sets and gets the identifier string. Will never be nil.
80 - (void)setIdentifier:(NSString*)aString;
81 - (NSString*)identifier;
83 // Position means the subview's position within the RBSplitView - counts from zero left to right
84 // or top to bottom. Setting it will move the subview to another position without changing its size,
85 // status or attributes. Set position to 0 to move it to the start, or to some large number to move it
86 // to the end of the RBSplitView.
87 - (unsigned)position;
88 - (void)setPosition:(unsigned)newPosition;
90 // Returns YES if the subview is collapsed. Collapsed subviews are squashed down to zero but never
91 // made smaller than the minimum dimension as far as their own subviews are concerned. If the
92 // subview is being animated this will return NO.
93 - (BOOL)isCollapsed;
95 // This will return the current status of the subview. Negative values mean the subview is
96 // being animated.
97 - (RBSSubviewStatus)status;
99 // Sets and gets the ability to collapse the subview. However, this can be overridden by the delegate.
100 - (BOOL)canCollapse;
101 - (void)setCanCollapse:(BOOL)flag;
103 // Tests whether the subview can shrink or expand further.
104 - (BOOL)canShrink;
105 - (BOOL)canExpand;
107 // Sets and gets the minimum and maximum dimensions. They're set at the same time to make sure values
108 // are consistent. Despite being floats, they'll always have integer values. The minimum value for the
109 // minimum is 1.0. Pass 0.0 for the maximum to set it to some huge number.
110 - (float)minDimension;
111 - (float)maxDimension;
112 - (void)setMinDimension:(float)newMinDimension andMaxDimension:(float)newMaxDimension;
114 // Call this to expand a subview programmatically. It will return the subview's dimension after
115 // expansion.
116 - (float)expand;
118 // Call this to collapse a subview programmatically. It will return the negative
119 // of the subview's dimension _before_ collapsing, or 0.0 if the subview can't be collapsed.
120 - (float)collapse;
122 // These calls collapse and expand subviews with animation. They return YES if animation
123 // startup was successful.
124 - (BOOL)collapseWithAnimation;
125 - (BOOL)expandWithAnimation;
127 // These methods collapse and expand subviews with animation, depending on the parameters.
128 // They return YES if animation startup was successful. If resize is NO, the subview is
129 // collapsed/expanded without resizing it during animation.
130 - (BOOL)collapseWithAnimation:(BOOL)animate withResize:(BOOL)resize;
131 - (BOOL)expandWithAnimation:(BOOL)animate withResize:(BOOL)resize;
133 // Returns the current dimension of the subview.
134 - (float)dimension;
136 // Sets the current dimension of the subview, subject to the current maximum and minimum.
137 // If the subview is collapsed, this has no immediate effect.
138 - (void)setDimension:(float)value;
140 // This method is used internally when a divider is dragged. It tries to change the subview's dimension
141 // and returns the actual change, collapsing or expanding whenever possible. You usually won't need
142 // to call this directly.
143 - (float)changeDimensionBy:(float)increment mayCollapse:(BOOL)mayCollapse move:(BOOL)move;
145 @end