From f98bdddd09609b7a42b849279c7c83624090ab4e Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 31 Jan 2011 08:33:16 +0000 Subject: Updated PSMTabBarControl (warning fixes) svn path=/trunk/netsurf/; revision=11560 --- cocoa/PSMTabBarControl/PSMTabBarControl.m | 20 ++++++++++---------- cocoa/PSMTabBarControl/PSMTabBarController.h | 6 +++--- cocoa/PSMTabBarControl/PSMTabBarController.m | 16 ++++++++-------- cocoa/PSMTabBarControl/PSMTabDragAssistant.h | 2 +- cocoa/PSMTabBarControl/PSMTabDragAssistant.m | 9 ++++----- 5 files changed, 26 insertions(+), 27 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PSMTabBarControl/PSMTabBarControl.m b/cocoa/PSMTabBarControl/PSMTabBarControl.m index 865180417..3a7e0c6d4 100644 --- a/cocoa/PSMTabBarControl/PSMTabBarControl.m +++ b/cocoa/PSMTabBarControl/PSMTabBarControl.m @@ -564,7 +564,7 @@ // add to collection [_cells addObject:cell]; [cell release]; - if([_cells count] == [tabView numberOfTabViewItems]) { + if([_cells count] == (NSUInteger)[tabView numberOfTabViewItems]) { [self update]; // don't update unless all are accounted for! } } @@ -923,7 +923,7 @@ - (void)update:(BOOL)animate { // 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; } @@ -952,7 +952,7 @@ if(animate) { 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]; //we're going from NSRect -> NSValue -> NSRect -> NSValue here - oh well @@ -973,7 +973,7 @@ [[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:NSEventTrackingRunLoopMode]; [self _animateCells:_animationTimer]; } else { - for(NSInteger i = 0; i < [_cells count]; i++) { + for(NSUInteger i = 0; i < [_cells count]; i++) { currentCell = [_cells objectAtIndex:i]; [currentCell setFrame:[_controller cellFrameAtIndex:i]]; @@ -992,11 +992,11 @@ NSAnimation *animation = [[timer userInfo] objectAtIndex:1]; NSArray *targetFrames = [[timer userInfo] objectAtIndex:0]; PSMTabBarCell *currentCell; - NSInteger cellCount = [_cells count]; + NSUInteger cellCount = [_cells count]; if((cellCount > 0) && [animation isAnimating]) { //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]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; CGFloat sizeChange; @@ -1032,7 +1032,7 @@ } else { //put all the cells where they should be in their final position 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]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; @@ -1064,7 +1064,7 @@ [_animationTimer invalidate]; [_animationTimer release]; _animationTimer = nil; - for(NSInteger i = 0; i < cellCount; i++) { + for(NSUInteger i = 0; i < cellCount; i++) { currentCell = [_cells objectAtIndex:i]; //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 { // 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 - NSInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem]; + NSUInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem]; if([_cells count] > 0 && tabIndex < [_cells count]) { PSMTabBarCell *thisCell = [_cells objectAtIndex:tabIndex]; @@ -1930,7 +1930,7 @@ } - (NSInteger)numberOfVisibleTabs { - NSInteger i, cellCount = 0; + NSUInteger i, cellCount = 0; PSMTabBarCell *nextCell; for(i = 0; i < [_cells count]; i++) { diff --git a/cocoa/PSMTabBarControl/PSMTabBarController.h b/cocoa/PSMTabBarControl/PSMTabBarController.h index 447011f44..a73a04f1f 100644 --- a/cocoa/PSMTabBarControl/PSMTabBarController.h +++ b/cocoa/PSMTabBarControl/PSMTabBarController.h @@ -27,9 +27,9 @@ - (NSRect)addButtonRect; - (NSMenu *)overflowMenu; -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index; -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index; -- (NSRect)cellFrameAtIndex:(NSInteger)index; +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)index; +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)index; +- (NSRect)cellFrameAtIndex:(NSUInteger)index; - (void)setSelectedCell:(PSMTabBarCell *)cell; diff --git a/cocoa/PSMTabBarControl/PSMTabBarController.m b/cocoa/PSMTabBarControl/PSMTabBarController.m index 7d9820e61..68e1bc498 100644 --- a/cocoa/PSMTabBarControl/PSMTabBarController.m +++ b/cocoa/PSMTabBarControl/PSMTabBarController.m @@ -78,9 +78,9 @@ @returns The tracking rect of the cell at the requested index. */ -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index { +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)index { NSRect rect; - if(index > -1 && index < [_cellTrackingRects count]) { + if(index < [_cellTrackingRects count]) { rect = [[_cellTrackingRects objectAtIndex:index] rectValue]; } else { NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index); @@ -97,9 +97,9 @@ @returns The close button tracking rect of the cell at the requested index. */ -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index { +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)index { NSRect rect; - if(index > -1 && index < [_closeButtonTrackingRects count]) { + if(index < [_closeButtonTrackingRects count]) { rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue]; } else { NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index); @@ -116,10 +116,10 @@ @returns The frame of the cell at the requested index. */ -- (NSRect)cellFrameAtIndex:(NSInteger)index { +- (NSRect)cellFrameAtIndex:(NSUInteger)index { NSRect rect; - if(index > -1 && index < [_cellFrames count]) { + if(index < [_cellFrames count]) { rect = [[_cellFrames objectAtIndex:index] rectValue]; } else { NSLog(@"cellFrameAtIndex: Invalid index (%ld)", (long)index); @@ -160,7 +160,7 @@ [cell setTabState:PSMTab_SelectedMask]; if(![cell isInOverflowMenu]) { - NSInteger cellIndex = [cells indexOfObject:cell]; + NSUInteger cellIndex = [cells indexOfObject:cell]; if(cellIndex > 0) { nextCell = [cells objectAtIndex:cellIndex - 1]; @@ -501,7 +501,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum){ */ - (void)_setupCells:(NSArray *)cells withWidths:(NSArray *)widths { - NSInteger i, tabState, cellCount = [cells count]; + NSUInteger i, tabState, cellCount = [cells count]; NSRect cellRect = [_control genericCellRect]; PSMTabBarCell *cell; NSTabViewItem *selectedTabViewItem = [[_control tabView] selectedTabViewItem]; diff --git a/cocoa/PSMTabBarControl/PSMTabDragAssistant.h b/cocoa/PSMTabBarControl/PSMTabDragAssistant.h index 30965f943..2632e11a0 100644 --- a/cocoa/PSMTabBarControl/PSMTabDragAssistant.h +++ b/cocoa/PSMTabBarControl/PSMTabDragAssistant.h @@ -22,7 +22,7 @@ PSMTabBarControl *_destinationTabBar; NSMutableSet *_participatingTabBars; PSMTabBarCell *_draggedCell; - NSInteger _draggedCellIndex; // for snap back + NSUInteger _draggedCellIndex; // for snap back BOOL _isDragging; // Support for dragging into new windows diff --git a/cocoa/PSMTabBarControl/PSMTabDragAssistant.m b/cocoa/PSMTabBarControl/PSMTabDragAssistant.m index 82a063afa..4542e8d02 100644 --- a/cocoa/PSMTabBarControl/PSMTabDragAssistant.m +++ b/cocoa/PSMTabBarControl/PSMTabDragAssistant.m @@ -298,7 +298,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; - (void)performDragOperation { // 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 if(destinationIndex >= [[[self destinationTabBar] cells] count]) { @@ -315,7 +315,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; [[self sourceTabBar] removeTrackingRect:[[self draggedCell] cellTrackingTag]]; [[self sourceTabBar] removeTabForCell:[self draggedCell]]; - NSInteger i, insertIndex; + NSUInteger i, insertIndex; NSArray *cells = [[self destinationTabBar] cells]; //find the index of where the dragged cell was just dropped @@ -350,9 +350,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSTabView *tabView = [[self sourceTabBar] tabView]; NSTabViewItem *item = [[self draggedCell] representedObject]; BOOL reselect = ([tabView selectedTabViewItem] == item); - NSInteger index; NSArray *cells = [[self sourceTabBar] cells]; - + NSUInteger index; //find the index of where the dragged cell was just dropped for(index = 0; index < [cells count] && [cells objectAtIndex:index] != [self draggedCell]; index++) { ; @@ -767,7 +766,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; } - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control { - NSInteger i, numVisibleTabs = [control numberOfVisibleTabs]; + NSUInteger i, numVisibleTabs = [control numberOfVisibleTabs]; for(i = 0; i < numVisibleTabs; i++) { PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease]; [[control cells] insertObject:pc atIndex:(2 * i)]; -- cgit v1.2.3