capp_lint

This commit is contained in:
Antoine Mercadal
2010-10-13 13:41:35 +02:00
parent 8fc465b63a
commit 560c971aeb
+40 -39
View File
@@ -48,7 +48,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
CPNumber selectedIndex;
CPTabViewType type;
id delegate;
unsigned delegateSelectors;
}
@@ -59,61 +59,61 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
if (self)
{
items = [CPArray array];
tabs = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 0, HEIGHT_OF_SEGMENTED_CONTROL)];
[tabs setHitTests:NO];
box = [[CPBox alloc] initWithFrame:CGRectMake(0, HEIGHT_OF_SEGMENTED_CONTROL / 2, CGRectGetWidth(aFrame),
CGRectGetHeight(aFrame) - HEIGHT_OF_SEGMENTED_CONTROL)];
selectedIndex = CPNotFound;
[self setTabViewType:CPTopTabsBezelBorder];
[self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.95 alpha:1.0]];
[self addSubview:box];
[self addSubview:tabs];
}
return self;
}
/*!
Override CPView message to allow to set the autoresizing mask
/*!
Override CPView message to allow to set the autoresizing mask
of the tabview and it's subview
@param unsigned aMask the autoresizing mask
*/
- (void)setAutoresizingMask:(unsigned)aMask
{
[box setAutoresizingMask:aMask];
[super setAutoresizingMask:aMask];
}
/*!
/*!
Override the CPView method in order
to allow to reposition the segmented control
@param aFrame the new frame
*/
- (void)setFrame:(CGRect)aFrame
{
[super setFrame:aFrame];
[self _repositionTabs];
}
/*!
/*!
Override the CPView method in order
to allow to reposition the segmented control
@param someBounds the new bounds
*/
- (void)setBounds:(CGRect)someBounds
{
[super setBounds:someBounds];
[self _repositionTabs];
}
@@ -136,7 +136,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
- (void)insertTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(unsigned)anIndex
{
[items insertObject:aTabViewItem atIndex:anIndex];
[self _updateItems];
[self _repositionTabs];
@@ -160,7 +160,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
[self _updateItems];
[self _repositionTabs];
if (delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
[delegate tabViewDidChangeNumberOfTabViewItems:self];
}
@@ -221,7 +221,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
if ([items count] === 0)
return; // throw?
[self selectTabViewItemAtIndex:0];
}
@@ -233,7 +233,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
if ([items count] === 0)
return; // throw?
[self selectTabViewItemAtIndex:[items count] - 1];
}
@@ -245,12 +245,13 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
if (selectedIndex === CPNotFound)
return;
var nextIndex = selectedIndex + 1;
if (nextIndex === [items count])
return; // does nothing. According to spec at (http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTabView/selectNextTabViewItem:)
// does nothing. According to spec at (http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTabView/selectNextTabViewItem:)
return;
[self selectTabViewItemAtIndex:nextIndex];
}
@@ -262,12 +263,12 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
if (selectedIndex === CPNotFound)
return;
var previousIndex = selectedIndex - 1;
if (previousIndex < 0)
return; // does nothing. See above.
[self selectTabViewItemAtIndex:previousIndex];
}
@@ -290,18 +291,18 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
if (anIndex === selectedIndex)
return;
var aTabViewItem = [self tabViewItemAtIndex:anIndex];
if ((delegateSelectors & CPTabViewShouldSelectTabViewItemSelector) && ![delegate tabView:self shouldSelectTabViewItem:aTabViewItem])
return;
if (delegateSelectors & CPTabViewWillSelectTabViewItemSelector)
[delegate tabView:self willSelectTabViewItem:aTabViewItem];
[tabs selectSegmentWithTag:anIndex];
[self _setSelectedIndex:anIndex];
if (delegateSelectors & CPTabViewDidSelectTabViewItemSelector)
[delegate tabView:self didSelectTabViewItem:aTabViewItem];
}
@@ -323,17 +324,17 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
if (type === aTabViewType)
return;
if ((type === CPTopTabsBezelBorder || type === CPBottomTabsBezelBorder)
&& (aTabViewType !== CPTopTabsBezelBorder && aTabViewType !== CPBottomTabsBezelBorder))
[tabs removeFromSuperview];
if ((type === CPNoTabsBezelBorder || type === CPNoTabsLineBorder || type === CPNoTabsNoBorder)
&& (aTabViewType !== CPNoTabsBezelBorder && aTabViewType !== CPNoTabsBezelBorder && aTabViewType !== CPNoTabsNoBorder))
[self addSubview:tabs];
type = aTabViewType;
switch (type)
{
case CPTopTabsBezelBorder:
@@ -400,7 +401,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
- (void)mouseDown:(CPEvent)anEvent
{
var segmentIndex = [tabs testSegment:[tabs convertPoint:[anEvent locationInWindow] fromView:nil]];
if (segmentIndex != CPNotFound)
{
[self selectTabViewItemAtIndex:segmentIndex];
@@ -412,7 +413,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
{
var horizontalCenterOfSelf = CGRectGetWidth([self bounds]) / 2,
verticalCenterOfTabs = CGRectGetHeight([tabs bounds]) / 2;
if (type === CPBottomTabsBezelBorder)
[tabs setCenter:CGPointMake(horizontalCenterOfSelf, CGRectGetHeight([self bounds]) - verticalCenterOfTabs)];
else
@@ -422,7 +423,7 @@ var HEIGHT_OF_SEGMENTED_CONTROL = 24;
- (void)_setSelectedIndex:(CPNumber)index
{
selectedIndex = index;
[box setContentView:[[items objectAtIndex:selectedIndex] view]];
}
@@ -475,7 +476,7 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:items forKey:CPTabViewItemsKey];;
[aCoder encodeObject:[self selectedTabViewItem] forKey:CPTabViewSelectedItemKey];