mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge pull request #3212 from daboe01/tooltip-tableview-fix
New: toolTips for CPTableView and CPOutlineView
This commit is contained in:
@@ -1512,6 +1512,21 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return [super frameOfDataViewAtColumn:aColumn row:aRow];
|
||||
}
|
||||
|
||||
- (void)_applyToolTipToDataView:(CPView)aDataView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
if (_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_)
|
||||
{
|
||||
var item = [self itemAtRow:aRow],
|
||||
tooltip = [self _sendDelegateToolTipForView:aDataView rect:[aDataView frame] tableColumn:aTableColumn item:item mouseLocation:CGPointMakeZero()];
|
||||
|
||||
[aDataView setToolTip:tooltip];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super _applyToolTipToDataView:aDataView forTableColumn:aTableColumn row:aRow];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Retargets the drop item for the outlineview.
|
||||
|
||||
@@ -2118,6 +2133,17 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
/*** CPTableViewDelegate methods ***/
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (CPString)_sendDelegateToolTipForView:(id)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn item:(id)anItem mouseLocation:(CGPoint)aPoint
|
||||
{
|
||||
if (!(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_))
|
||||
return nil;
|
||||
|
||||
return [_outlineViewDelegate outlineView:self toolTipForView:aView rect:aRect tableColumn:aTableColumn item:anItem mouseLocation:aPoint];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(CPInteger)theRow
|
||||
{
|
||||
return SHOULD_SELECT_ITEM(self, [self itemAtRow:theRow]);
|
||||
|
||||
+11
-1
@@ -3616,10 +3616,21 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
[self _setEditingState:NO forView:dataView];
|
||||
|
||||
[self _sendDelegateWillDisplayView:dataView forTableColumn:tableColumn row:row];
|
||||
[self _applyToolTipToDataView:dataView forTableColumn:tableColumn row:row];
|
||||
|
||||
return dataView;
|
||||
}
|
||||
|
||||
- (void)_applyToolTipToDataView:(CPView)aDataView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
var tooltip = nil;
|
||||
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_toolTipForView_rect_tableColumn_row_mouseLocation_)
|
||||
tooltip = [self _sendDelegateToolTipForView:aDataView rect:[aDataView frame] tableColumn:aTableColumn row:aRow mouseLocation:CGPointMakeZero()];
|
||||
|
||||
[aDataView setToolTip:tooltip];
|
||||
}
|
||||
|
||||
- (void)_setObjectValueForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow forView:(CPView)aDataView
|
||||
{
|
||||
[self _setObjectValueForTableColumn:aTableColumn row:aRow forView:aDataView useCache:!_invalidateObjectValuesCache];
|
||||
@@ -5969,7 +5980,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Not yet implemented
|
||||
*/
|
||||
- (CPString)_sendDelegateToolTipForView:(id)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex mouseLocation:(CGPoint)aPoint
|
||||
{
|
||||
|
||||
@@ -308,4 +308,17 @@ var rowHeights = [ ];
|
||||
return anItem.customHeight;
|
||||
}
|
||||
|
||||
- (CPString)outlineView:(CPOutlineView)anOutlineView toolTipForView:(CPView)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn item:(id)anItem mouseLocation:(CGPoint)aPoint
|
||||
{
|
||||
if (anItem === nil)
|
||||
return nil;
|
||||
|
||||
var title = [anItem title],
|
||||
childCount = [[anItem children] count],
|
||||
childString = childCount === 1 ? @"1 child" : childCount + @" children";
|
||||
|
||||
// Dynamischer Tooltip basierend auf dem 'Menu' Objekt
|
||||
return [CPString stringWithFormat:@"Outline Node: %@\nContains: %@", title, childString];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -64,6 +64,9 @@ var AppControllerInstance = nil;
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
[[tableView tableColumns][0] setDataView:dataView];
|
||||
|
||||
// Set the delegate so we can test the new toolTip feature
|
||||
[tableView setDelegate:self];
|
||||
|
||||
rows = [
|
||||
[CPDictionary dictionaryWithJSObject:{ id:1, filename: "Jack.png", size:1327, uploading:NO, progress:0 }],
|
||||
@@ -88,6 +91,27 @@ var AppControllerInstance = nil;
|
||||
return !uploading;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Tool tip test
|
||||
// --------------------------------------------------------------------------------------
|
||||
- (CPString)tableView:(CPTableView)aTableView toolTipForView:(CPView)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex mouseLocation:(CGPoint)aPoint
|
||||
{
|
||||
// Make sure the row exists
|
||||
if (aRowIndex < 0 || aRowIndex >= [rows count])
|
||||
return nil;
|
||||
|
||||
var info = [rows objectAtIndex:aRowIndex],
|
||||
filename = [info valueForKey:@"filename"],
|
||||
isUploading = [info valueForKey:@"uploading"],
|
||||
progress = [info valueForKey:@"progress"];
|
||||
|
||||
// Provide a dynamic tooltip based on the state of the data in the row
|
||||
if (isUploading)
|
||||
return [CPString stringWithFormat:@"Uploading '%@' (%d%% complete)", filename, progress];
|
||||
|
||||
return [CPString stringWithFormat:@"File: %@\nStatus: Idle", filename];
|
||||
}
|
||||
|
||||
- (@action)start:(id)sender
|
||||
{
|
||||
// Note we use setUploading:YES instead of uploading = YES.
|
||||
|
||||
Reference in New Issue
Block a user