Updated PSMTabBarControl (warning fixes)

svn path=/trunk/netsurf/; revision=11560
This commit is contained in:
Sven Weidauer 2011-01-31 08:33:16 +00:00
parent 899c2e3305
commit f98bdddd09
5 changed files with 26 additions and 27 deletions

View File

@ -564,7 +564,7 @@
// add to collection // add to collection
[_cells addObject:cell]; [_cells addObject:cell];
[cell release]; [cell release];
if([_cells count] == [tabView numberOfTabViewItems]) { if([_cells count] == (NSUInteger)[tabView numberOfTabViewItems]) {
[self update]; // don't update unless all are accounted for! [self update]; // don't update unless all are accounted for!
} }
} }
@ -923,7 +923,7 @@
- (void)update:(BOOL)animate { - (void)update:(BOOL)animate {
// make sure all of our tabs are accounted for before updating // make sure all of our tabs are accounted for before updating
if([[self tabView] numberOfTabViewItems] != [_cells count]) { if((NSUInteger)[[self tabView] numberOfTabViewItems] != [_cells count]) {
return; return;
} }
@ -952,7 +952,7 @@
if(animate) { if(animate) {
NSMutableArray *targetFrames = [NSMutableArray arrayWithCapacity:[_cells count]]; NSMutableArray *targetFrames = [NSMutableArray arrayWithCapacity:[_cells count]];
for(NSInteger i = 0; i < [_cells count]; i++) { for(NSUInteger i = 0; i < [_cells count]; i++) {
currentCell = [_cells objectAtIndex:i]; currentCell = [_cells objectAtIndex:i];
//we're going from NSRect -> NSValue -> NSRect -> NSValue here - oh well //we're going from NSRect -> NSValue -> NSRect -> NSValue here - oh well
@ -973,7 +973,7 @@
[[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:NSEventTrackingRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:NSEventTrackingRunLoopMode];
[self _animateCells:_animationTimer]; [self _animateCells:_animationTimer];
} else { } else {
for(NSInteger i = 0; i < [_cells count]; i++) { for(NSUInteger i = 0; i < [_cells count]; i++) {
currentCell = [_cells objectAtIndex:i]; currentCell = [_cells objectAtIndex:i];
[currentCell setFrame:[_controller cellFrameAtIndex:i]]; [currentCell setFrame:[_controller cellFrameAtIndex:i]];
@ -992,11 +992,11 @@
NSAnimation *animation = [[timer userInfo] objectAtIndex:1]; NSAnimation *animation = [[timer userInfo] objectAtIndex:1];
NSArray *targetFrames = [[timer userInfo] objectAtIndex:0]; NSArray *targetFrames = [[timer userInfo] objectAtIndex:0];
PSMTabBarCell *currentCell; PSMTabBarCell *currentCell;
NSInteger cellCount = [_cells count]; NSUInteger cellCount = [_cells count];
if((cellCount > 0) && [animation isAnimating]) { if((cellCount > 0) && [animation isAnimating]) {
//compare our target position with the current position and move towards the target //compare our target position with the current position and move towards the target
for(NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { for(NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) {
currentCell = [_cells objectAtIndex:i]; currentCell = [_cells objectAtIndex:i];
NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue];
CGFloat sizeChange; CGFloat sizeChange;
@ -1032,7 +1032,7 @@
} else { } else {
//put all the cells where they should be in their final position //put all the cells where they should be in their final position
if(cellCount > 0) { if(cellCount > 0) {
for(NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { for(NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) {
PSMTabBarCell *currentCell = [_cells objectAtIndex:i]; PSMTabBarCell *currentCell = [_cells objectAtIndex:i];
NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue];
@ -1064,7 +1064,7 @@
[_animationTimer invalidate]; [_animationTimer invalidate];
[_animationTimer release]; _animationTimer = nil; [_animationTimer release]; _animationTimer = nil;
for(NSInteger i = 0; i < cellCount; i++) { for(NSUInteger i = 0; i < cellCount; i++) {
currentCell = [_cells objectAtIndex:i]; currentCell = [_cells objectAtIndex:i];
//we've hit the cells that are in overflow, stop setting up tracking rects //we've hit the cells that are in overflow, stop setting up tracking rects
@ -1618,7 +1618,7 @@
- (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem { - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem {
// here's a weird one - this message is sent before the "tabViewDidChangeNumberOfTabViewItems" // here's a weird one - this message is sent before the "tabViewDidChangeNumberOfTabViewItems"
// message, thus I can end up updating when there are no cells, if no tabs were (yet) present // message, thus I can end up updating when there are no cells, if no tabs were (yet) present
NSInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem]; NSUInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem];
if([_cells count] > 0 && tabIndex < [_cells count]) { if([_cells count] > 0 && tabIndex < [_cells count]) {
PSMTabBarCell *thisCell = [_cells objectAtIndex:tabIndex]; PSMTabBarCell *thisCell = [_cells objectAtIndex:tabIndex];
@ -1930,7 +1930,7 @@
} }
- (NSInteger)numberOfVisibleTabs { - (NSInteger)numberOfVisibleTabs {
NSInteger i, cellCount = 0; NSUInteger i, cellCount = 0;
PSMTabBarCell *nextCell; PSMTabBarCell *nextCell;
for(i = 0; i < [_cells count]; i++) { for(i = 0; i < [_cells count]; i++) {

View File

@ -27,9 +27,9 @@
- (NSRect)addButtonRect; - (NSRect)addButtonRect;
- (NSMenu *)overflowMenu; - (NSMenu *)overflowMenu;
- (NSRect)cellTrackingRectAtIndex:(NSInteger)index; - (NSRect)cellTrackingRectAtIndex:(NSUInteger)index;
- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index; - (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)index;
- (NSRect)cellFrameAtIndex:(NSInteger)index; - (NSRect)cellFrameAtIndex:(NSUInteger)index;
- (void)setSelectedCell:(PSMTabBarCell *)cell; - (void)setSelectedCell:(PSMTabBarCell *)cell;

View File

@ -78,9 +78,9 @@
@returns The tracking rect of the cell at the requested index. @returns The tracking rect of the cell at the requested index.
*/ */
- (NSRect)cellTrackingRectAtIndex:(NSInteger)index { - (NSRect)cellTrackingRectAtIndex:(NSUInteger)index {
NSRect rect; NSRect rect;
if(index > -1 && index < [_cellTrackingRects count]) { if(index < [_cellTrackingRects count]) {
rect = [[_cellTrackingRects objectAtIndex:index] rectValue]; rect = [[_cellTrackingRects objectAtIndex:index] rectValue];
} else { } else {
NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index); NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index);
@ -97,9 +97,9 @@
@returns The close button tracking rect of the cell at the requested index. @returns The close button tracking rect of the cell at the requested index.
*/ */
- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index { - (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)index {
NSRect rect; NSRect rect;
if(index > -1 && index < [_closeButtonTrackingRects count]) { if(index < [_closeButtonTrackingRects count]) {
rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue]; rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue];
} else { } else {
NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index); NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index);
@ -116,10 +116,10 @@
@returns The frame of the cell at the requested index. @returns The frame of the cell at the requested index.
*/ */
- (NSRect)cellFrameAtIndex:(NSInteger)index { - (NSRect)cellFrameAtIndex:(NSUInteger)index {
NSRect rect; NSRect rect;
if(index > -1 && index < [_cellFrames count]) { if(index < [_cellFrames count]) {
rect = [[_cellFrames objectAtIndex:index] rectValue]; rect = [[_cellFrames objectAtIndex:index] rectValue];
} else { } else {
NSLog(@"cellFrameAtIndex: Invalid index (%ld)", (long)index); NSLog(@"cellFrameAtIndex: Invalid index (%ld)", (long)index);
@ -160,7 +160,7 @@
[cell setTabState:PSMTab_SelectedMask]; [cell setTabState:PSMTab_SelectedMask];
if(![cell isInOverflowMenu]) { if(![cell isInOverflowMenu]) {
NSInteger cellIndex = [cells indexOfObject:cell]; NSUInteger cellIndex = [cells indexOfObject:cell];
if(cellIndex > 0) { if(cellIndex > 0) {
nextCell = [cells objectAtIndex:cellIndex - 1]; nextCell = [cells objectAtIndex:cellIndex - 1];
@ -501,7 +501,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum){
*/ */
- (void)_setupCells:(NSArray *)cells withWidths:(NSArray *)widths { - (void)_setupCells:(NSArray *)cells withWidths:(NSArray *)widths {
NSInteger i, tabState, cellCount = [cells count]; NSUInteger i, tabState, cellCount = [cells count];
NSRect cellRect = [_control genericCellRect]; NSRect cellRect = [_control genericCellRect];
PSMTabBarCell *cell; PSMTabBarCell *cell;
NSTabViewItem *selectedTabViewItem = [[_control tabView] selectedTabViewItem]; NSTabViewItem *selectedTabViewItem = [[_control tabView] selectedTabViewItem];

View File

@ -22,7 +22,7 @@
PSMTabBarControl *_destinationTabBar; PSMTabBarControl *_destinationTabBar;
NSMutableSet *_participatingTabBars; NSMutableSet *_participatingTabBars;
PSMTabBarCell *_draggedCell; PSMTabBarCell *_draggedCell;
NSInteger _draggedCellIndex; // for snap back NSUInteger _draggedCellIndex; // for snap back
BOOL _isDragging; BOOL _isDragging;
// Support for dragging into new windows // Support for dragging into new windows

View File

@ -298,7 +298,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
- (void)performDragOperation { - (void)performDragOperation {
// move cell // move cell
NSInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]]; NSUInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]];
//there is the slight possibility of the targetCell now being set properly, so avoid errors //there is the slight possibility of the targetCell now being set properly, so avoid errors
if(destinationIndex >= [[[self destinationTabBar] cells] count]) { if(destinationIndex >= [[[self destinationTabBar] cells] count]) {
@ -315,7 +315,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[[self sourceTabBar] removeTrackingRect:[[self draggedCell] cellTrackingTag]]; [[self sourceTabBar] removeTrackingRect:[[self draggedCell] cellTrackingTag]];
[[self sourceTabBar] removeTabForCell:[self draggedCell]]; [[self sourceTabBar] removeTabForCell:[self draggedCell]];
NSInteger i, insertIndex; NSUInteger i, insertIndex;
NSArray *cells = [[self destinationTabBar] cells]; NSArray *cells = [[self destinationTabBar] cells];
//find the index of where the dragged cell was just dropped //find the index of where the dragged cell was just dropped
@ -350,9 +350,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
NSTabView *tabView = [[self sourceTabBar] tabView]; NSTabView *tabView = [[self sourceTabBar] tabView];
NSTabViewItem *item = [[self draggedCell] representedObject]; NSTabViewItem *item = [[self draggedCell] representedObject];
BOOL reselect = ([tabView selectedTabViewItem] == item); BOOL reselect = ([tabView selectedTabViewItem] == item);
NSInteger index;
NSArray *cells = [[self sourceTabBar] cells]; NSArray *cells = [[self sourceTabBar] cells];
NSUInteger index;
//find the index of where the dragged cell was just dropped //find the index of where the dragged cell was just dropped
for(index = 0; index < [cells count] && [cells objectAtIndex:index] != [self draggedCell]; index++) { for(index = 0; index < [cells count] && [cells objectAtIndex:index] != [self draggedCell]; index++) {
; ;
@ -767,7 +766,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
} }
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control { - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control {
NSInteger i, numVisibleTabs = [control numberOfVisibleTabs]; NSUInteger i, numVisibleTabs = [control numberOfVisibleTabs];
for(i = 0; i < numVisibleTabs; i++) { for(i = 0; i < numVisibleTabs; i++) {
PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease]; PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease];
[[control cells] insertObject:pc atIndex:(2 * i)]; [[control cells] insertObject:pc atIndex:(2 * i)];