mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:30:48 +00:00
Implemented a load of missing methods and adopted all subclasses to
this changes. (Including copying and coding) This breaks archived cells! git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8264 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
532cc38a15
commit
a10133c5e9
1 changed files with 254 additions and 181 deletions
435
Source/NSCell.m
435
Source/NSCell.m
|
@ -42,14 +42,16 @@
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
#include <AppKit/NSImage.h>
|
#include <AppKit/NSImage.h>
|
||||||
#include <AppKit/NSFont.h>
|
|
||||||
#include <AppKit/NSView.h>
|
#include <AppKit/NSView.h>
|
||||||
#include <AppKit/NSControl.h>
|
#include <AppKit/NSControl.h>
|
||||||
#include <AppKit/NSCell.h>
|
#include <AppKit/NSCell.h>
|
||||||
#include <AppKit/NSCursor.h>
|
#include <AppKit/NSCursor.h>
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
#include <AppKit/NSGraphics.h>
|
#include <AppKit/NSGraphics.h>
|
||||||
|
#include <AppKit/NSFont.h>
|
||||||
#include <AppKit/NSColor.h>
|
#include <AppKit/NSColor.h>
|
||||||
|
#include <AppKit/NSParagraphStyle.h>
|
||||||
|
#include <AppKit/NSMenu.h>
|
||||||
#include <AppKit/PSOperators.h>
|
#include <AppKit/PSOperators.h>
|
||||||
|
|
||||||
static Class colorClass;
|
static Class colorClass;
|
||||||
|
@ -126,19 +128,30 @@ static NSColor *shadowCol;
|
||||||
_cell.type = NSImageCellType;
|
_cell.type = NSImageCellType;
|
||||||
_cell_image = RETAIN(anImage);
|
_cell_image = RETAIN(anImage);
|
||||||
_cell.image_position = NSImageOnly;
|
_cell.image_position = NSImageOnly;
|
||||||
_cell_font = RETAIN([fontClass userFontOfSize: 0]);
|
_typingAttributes = [[NSMutableDictionary alloc]
|
||||||
|
initWithObjectsAndKeys:
|
||||||
|
[NSFont userFontOfSize: 0], NSFontAttributeName,
|
||||||
|
[NSMutableParagraphStyle defaultParagraphStyle],
|
||||||
|
NSParagraphStyleAttributeName,
|
||||||
|
nil];
|
||||||
|
|
||||||
// Implicitly set by allocation:
|
// Implicitly set by allocation:
|
||||||
//
|
//
|
||||||
//_cell.is_disabled = NO;
|
|
||||||
//_cell.state = 0;
|
|
||||||
//_cell.is_highlighted = NO;
|
//_cell.is_highlighted = NO;
|
||||||
|
//_cell.is_disabled = NO;
|
||||||
//_cell.is_editable = NO;
|
//_cell.is_editable = NO;
|
||||||
|
//_cell.is_rich_text = NO;
|
||||||
|
//_cell.imports_graphics = NO;
|
||||||
|
//_cell.shows_first_responder = NO;
|
||||||
|
//_cell.refuses_first_responder = NO;
|
||||||
|
//_cell.sends_action_on_end_editing = NO;
|
||||||
//_cell.is_bordered = NO;
|
//_cell.is_bordered = NO;
|
||||||
//_cell.is_bezeled = NO;
|
//_cell.is_bezeled = NO;
|
||||||
//_cell.is_scrollable = NO;
|
//_cell.is_scrollable = NO;
|
||||||
//_cell.is_selectable = NO;
|
//_cell.is_selectable = NO;
|
||||||
//_cell.is_continuous = NO;
|
//_cell.is_continuous = NO;
|
||||||
//_cell.float_autorange = NO;
|
//_cell.float_autorange = NO;
|
||||||
|
//_cell.state = 0;
|
||||||
//_cell_float_left = 0;
|
//_cell_float_left = 0;
|
||||||
//_cell_float_right = 0;
|
//_cell_float_right = 0;
|
||||||
_action_mask = NSLeftMouseUpMask;
|
_action_mask = NSLeftMouseUpMask;
|
||||||
|
@ -149,10 +162,14 @@ static NSColor *shadowCol;
|
||||||
- (id) initTextCell: (NSString*)aString
|
- (id) initTextCell: (NSString*)aString
|
||||||
{
|
{
|
||||||
_cell.type = NSTextCellType;
|
_cell.type = NSTextCellType;
|
||||||
_cell_font = RETAIN([fontClass userFontOfSize: 0]);
|
_typingAttributes = [[NSMutableDictionary alloc]
|
||||||
|
initWithObjectsAndKeys:
|
||||||
|
[NSFont userFontOfSize: 0], NSFontAttributeName,
|
||||||
|
[NSMutableParagraphStyle defaultParagraphStyle],
|
||||||
|
NSParagraphStyleAttributeName,
|
||||||
|
nil];
|
||||||
_contents = RETAIN(aString);
|
_contents = RETAIN(aString);
|
||||||
// In NSControl's doc they say this is the default
|
|
||||||
_cell.text_align = NSNaturalTextAlignment;
|
|
||||||
// Implicitly set by allocation:
|
// Implicitly set by allocation:
|
||||||
//
|
//
|
||||||
//_cell_image = nil;
|
//_cell_image = nil;
|
||||||
|
@ -178,12 +195,13 @@ static NSColor *shadowCol;
|
||||||
{
|
{
|
||||||
TEST_RELEASE (_contents);
|
TEST_RELEASE (_contents);
|
||||||
TEST_RELEASE (_cell_image);
|
TEST_RELEASE (_cell_image);
|
||||||
TEST_RELEASE (_cell_font);
|
RELEASE (_typingAttributes);
|
||||||
TEST_RELEASE (_represented_object);
|
TEST_RELEASE (_represented_object);
|
||||||
TEST_RELEASE (_objectValue);
|
TEST_RELEASE (_objectValue);
|
||||||
TEST_RELEASE (_formatter);
|
TEST_RELEASE (_formatter);
|
||||||
|
TEST_RELEASE (_menu);
|
||||||
|
|
||||||
NSDeallocateObject (self);
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -325,12 +343,39 @@ static NSColor *shadowCol;
|
||||||
*/
|
*/
|
||||||
- (int) cellAttribute: (NSCellAttribute)aParameter
|
- (int) cellAttribute: (NSCellAttribute)aParameter
|
||||||
{
|
{
|
||||||
|
switch (aParameter)
|
||||||
|
{
|
||||||
|
case NSCellDisabled: return _cell.is_disabled;
|
||||||
|
case NSCellState: return _cell.state;
|
||||||
|
case NSCellEditable: return _cell.is_editable;
|
||||||
|
case NSCellHighlighted: return _cell.is_highlighted;
|
||||||
|
case NSCellIsBordered: return _cell.is_bordered;
|
||||||
|
case NSCellAllowsMixedState: return _cell.allows_mixed_state;
|
||||||
|
|
||||||
|
/*
|
||||||
|
case NSPushInCell: return _cell.;
|
||||||
|
case NSChangeGrayCell: return _cell.;
|
||||||
|
case NSCellLightsByContents: return _cell.;
|
||||||
|
case NSCellLightsByGray: return _cell.;
|
||||||
|
case NSChangeBackgroundCell: return _cell.;
|
||||||
|
case NSCellLightsByBackground: return _cell.;
|
||||||
|
case NSCellChangesContents: return _cell.;
|
||||||
|
case NSCellIsInsetButton: return _cell.;
|
||||||
|
*/
|
||||||
|
case NSCellHasOverlappingImage: return _cell.image_position == NSImageOverlaps;
|
||||||
|
case NSCellHasImageHorizontal: return (_cell.image_position == NSImageRight) ||
|
||||||
|
(_cell.image_position == NSImageLeft);
|
||||||
|
case NSCellHasImageOnLeftOrBottom: return (_cell.image_position == NSImageBelow) ||
|
||||||
|
(_cell.image_position == NSImageLeft);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCellAttribute: (NSCellAttribute)aParameter to: (int)value
|
- (void) setCellAttribute: (NSCellAttribute)aParameter to: (int)value
|
||||||
{
|
{
|
||||||
// TOFO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -338,7 +383,6 @@ static NSColor *shadowCol;
|
||||||
*/
|
*/
|
||||||
- (void) setType: (NSCellType)aType
|
- (void) setType: (NSCellType)aType
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_cell.type == aType)
|
if (_cell.type == aType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -346,7 +390,6 @@ static NSColor *shadowCol;
|
||||||
switch (_cell.type)
|
switch (_cell.type)
|
||||||
{
|
{
|
||||||
case NSTextCellType:
|
case NSTextCellType:
|
||||||
ASSIGN (_cell_font, [fontClass userFontOfSize: 0]);
|
|
||||||
ASSIGN (_contents, @"title");
|
ASSIGN (_contents, @"title");
|
||||||
break;
|
break;
|
||||||
case NSImageCellType:
|
case NSImageCellType:
|
||||||
|
@ -371,7 +414,7 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (void) setEnabled: (BOOL)flag
|
- (void) setEnabled: (BOOL)flag
|
||||||
{
|
{
|
||||||
_cell.is_disabled = !flag;
|
_cell.is_disabled = !flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -438,6 +481,8 @@ static NSColor *shadowCol;
|
||||||
- (void) setAllowsMixedState: (BOOL)flag
|
- (void) setAllowsMixedState: (BOOL)flag
|
||||||
{
|
{
|
||||||
_cell.allows_mixed_state = flag;
|
_cell.allows_mixed_state = flag;
|
||||||
|
if (!flag && _cell.state == NSMixedState)
|
||||||
|
[self setNextState];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) nextState
|
- (int) nextState
|
||||||
|
@ -471,12 +516,13 @@ static NSColor *shadowCol;
|
||||||
*/
|
*/
|
||||||
- (NSTextAlignment) alignment
|
- (NSTextAlignment) alignment
|
||||||
{
|
{
|
||||||
return _cell.text_align;
|
return [[_typingAttributes objectForKey: NSParagraphStyleAttributeName]
|
||||||
|
alignment];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont*) font
|
- (NSFont*) font
|
||||||
{
|
{
|
||||||
return _cell_font;
|
return [_typingAttributes objectForKey: NSFontAttributeName];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isEditable
|
- (BOOL) isEditable
|
||||||
|
@ -496,7 +542,8 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (void) setAlignment: (NSTextAlignment)mode
|
- (void) setAlignment: (NSTextAlignment)mode
|
||||||
{
|
{
|
||||||
_cell.text_align = mode;
|
[[_typingAttributes objectForKey: NSParagraphStyleAttributeName]
|
||||||
|
setAlignment: mode];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setEditable: (BOOL)flag
|
- (void) setEditable: (BOOL)flag
|
||||||
|
@ -511,10 +558,16 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (void) setFont: (NSFont*)fontObject
|
- (void) setFont: (NSFont*)fontObject
|
||||||
{
|
{
|
||||||
NSAssert(fontObject == nil || [fontObject isKindOfClass: fontClass],
|
if (fontObject == nil)
|
||||||
NSInvalidArgumentException);
|
{
|
||||||
|
[_typingAttributes removeObjectForKey: NSFontAttributeName];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSAssert([fontObject isKindOfClass: fontClass], NSInvalidArgumentException);
|
||||||
|
|
||||||
ASSIGN(_cell_font, fontObject);
|
[_typingAttributes setObject: fontObject forKey: NSFontAttributeName];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setSelectable: (BOOL)flag
|
- (void) setSelectable: (BOOL)flag
|
||||||
|
@ -536,60 +589,77 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (void) setWraps: (BOOL)flag
|
- (void) setWraps: (BOOL)flag
|
||||||
{
|
{
|
||||||
_cell.wraps = flag;
|
|
||||||
if (flag)
|
if (flag)
|
||||||
_cell.is_scrollable = NO;
|
{
|
||||||
|
[[_typingAttributes objectForKey: NSParagraphStyleAttributeName]
|
||||||
|
setLineBreakMode: NSLineBreakByWordWrapping];
|
||||||
|
_cell.is_scrollable = NO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[_typingAttributes objectForKey: NSParagraphStyleAttributeName]
|
||||||
|
setLineBreakMode: NSLineBreakByClipping];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) wraps
|
- (BOOL) wraps
|
||||||
{
|
{
|
||||||
return _cell.wraps;
|
return ([[_typingAttributes objectForKey: NSParagraphStyleAttributeName]
|
||||||
|
lineBreakMode] == NSLineBreakByWordWrapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAttributedStringValue: (NSAttributedString*)attribStr
|
- (void) setAttributedStringValue: (NSAttributedString*)attribStr
|
||||||
{
|
{
|
||||||
//TODO
|
[self setStringValue: [attribStr string]];
|
||||||
|
ASSIGN(_typingAttributes, [[attribStr attributesAtIndex: 0 effectiveRange: NULL]
|
||||||
|
mutableCopy]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSAttributedString*) attributedStringValue
|
- (NSAttributedString*) attributedStringValue
|
||||||
{
|
{
|
||||||
//TODO
|
if (_formatter != nil)
|
||||||
return nil;
|
{
|
||||||
|
return [_formatter attributedStringForObjectValue: _objectValue
|
||||||
|
withDefaultAttributes: _typingAttributes];
|
||||||
|
}
|
||||||
|
return AUTORELEASE([[NSAttributedString alloc] initWithString: _contents
|
||||||
|
attributes: _typingAttributes]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAllowsEditingTextAttributes: (BOOL)flag
|
- (void) setAllowsEditingTextAttributes: (BOOL)flag
|
||||||
{
|
{
|
||||||
//TODO
|
_cell.is_rich_text = flag;
|
||||||
|
if (!flag)
|
||||||
|
_cell.imports_graphics = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) allowsEditingTextAttributes
|
- (BOOL) allowsEditingTextAttributes
|
||||||
{
|
{
|
||||||
//TODO
|
return _cell.is_rich_text;
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setImportsGraphics: (BOOL)flag
|
- (void) setImportsGraphics: (BOOL)flag
|
||||||
{
|
{
|
||||||
//TODO
|
_cell.imports_graphics = flag;
|
||||||
|
if (flag)
|
||||||
|
_cell.is_rich_text = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) importsGraphics
|
- (BOOL) importsGraphics
|
||||||
{
|
{
|
||||||
//TODO
|
return _cell.imports_graphics;
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSText*) setUpFieldEditorAttributes: (NSText*)textObject
|
- (NSText*) setUpFieldEditorAttributes: (NSText*)textObject
|
||||||
{
|
{
|
||||||
if (_cell.is_disabled)
|
[textObject setTextColor: [self textColor]];
|
||||||
[textObject setTextColor: dtxtCol];
|
[textObject setFont: [self font]];
|
||||||
else
|
[textObject setAlignment: [self alignment]];
|
||||||
[textObject setTextColor: txtCol];
|
|
||||||
|
|
||||||
[textObject setFont: _cell_font];
|
|
||||||
[textObject setAlignment: _cell.text_align];
|
|
||||||
[textObject setEditable: _cell.is_editable];
|
[textObject setEditable: _cell.is_editable];
|
||||||
[textObject setSelectable: _cell.is_selectable || _cell.is_editable];
|
[textObject setSelectable: _cell.is_selectable || _cell.is_editable];
|
||||||
|
[textObject setRichText: _cell.is_rich_text];
|
||||||
|
[textObject setImportsGraphics: _cell.imports_graphics];
|
||||||
|
|
||||||
return textObject;
|
return textObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,13 +778,20 @@ static NSColor *shadowCol;
|
||||||
- (void) setEntryType: (int)aType
|
- (void) setEntryType: (int)aType
|
||||||
{
|
{
|
||||||
[self setType: NSTextCellType];
|
[self setType: NSTextCellType];
|
||||||
|
// TODO: This should select a suitable formatter
|
||||||
_cell.entry_type = aType;
|
_cell.entry_type = aType;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isEntryAcceptable: (NSString*)aString
|
- (BOOL) isEntryAcceptable: (NSString*)aString
|
||||||
{
|
{
|
||||||
// TODO
|
if (_formatter != nil)
|
||||||
return YES;
|
{
|
||||||
|
return [_formatter isPartialStringValid: aString
|
||||||
|
newEditingString: NULL
|
||||||
|
errorDescription: NULL];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -722,20 +799,18 @@ static NSColor *shadowCol;
|
||||||
*/
|
*/
|
||||||
- (void) setMenu: (NSMenu*)aMenu
|
- (void) setMenu: (NSMenu*)aMenu
|
||||||
{
|
{
|
||||||
//TODO
|
ASSIGN(_menu, aMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMenu*) menu
|
- (NSMenu*) menu
|
||||||
{
|
{
|
||||||
//TODO
|
return _menu;
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMenu*) menuForEvent: (NSEvent*)anEvent
|
- (NSMenu*) menuForEvent: (NSEvent*)anEvent
|
||||||
inRect: (NSRect)cellFrame
|
inRect: (NSRect)cellFrame
|
||||||
ofView: (NSView*)aView
|
ofView: (NSView*)aView
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
return [self menu];
|
return [self menu];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,45 +843,52 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (void) setShowsFirstResponder: (BOOL)flag
|
- (void) setShowsFirstResponder: (BOOL)flag
|
||||||
{
|
{
|
||||||
|
_cell.shows_first_responder = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) showsFirstResponder
|
- (BOOL) showsFirstResponder
|
||||||
{
|
{
|
||||||
return NO;
|
return _cell.shows_first_responder;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setTitleWithMnemonic: (NSString*)aString
|
- (void) setTitleWithMnemonic: (NSString*)aString
|
||||||
{
|
{
|
||||||
// Provided for compatibility only
|
unsigned int location = [aString rangeOfString: @"&"].location;
|
||||||
|
|
||||||
|
[self setStringValue: [aString stringByReplacingString: @"&"
|
||||||
|
withString: @""]];
|
||||||
|
// TODO: We should underline this character
|
||||||
|
[self setMnemonicLocation: location];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) mnemonic
|
- (NSString*) mnemonic
|
||||||
{
|
{
|
||||||
// provided for compatibility only
|
unsigned int location = [self mnemonicLocation];
|
||||||
return @"";
|
|
||||||
|
if ((location == NSNotFound) || location >= [_contents length])
|
||||||
|
return @"";
|
||||||
|
|
||||||
|
return [_contents substringWithRange: NSMakeRange(location, 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMnemonicLocation: (unsigned int)location
|
- (void) setMnemonicLocation: (unsigned int)location
|
||||||
{
|
{
|
||||||
// Provided for compatibility only
|
_mnemonic_location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned int) mnemonicLocation
|
- (unsigned int) mnemonicLocation
|
||||||
{
|
{
|
||||||
// Provided for compatibiliy only
|
return _mnemonic_location;
|
||||||
return NSNotFound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) refusesFirstResponder
|
- (BOOL) refusesFirstResponder
|
||||||
{
|
{
|
||||||
// Approximate compatibility behaviour
|
return _cell.refuses_first_responder;
|
||||||
return _cell.is_disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setRefusesFirstResponder: (BOOL)flag
|
- (void) setRefusesFirstResponder: (BOOL)flag
|
||||||
{
|
{
|
||||||
// Approximate compatibility behaviour
|
_cell.refuses_first_responder = flag;
|
||||||
_cell.is_disabled = flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) performClick: (id)sender
|
- (void) performClick: (id)sender
|
||||||
|
@ -917,8 +999,7 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (int) mouseDownFlags
|
- (int) mouseDownFlags
|
||||||
{
|
{
|
||||||
//FIXME: Should be set on mouse down
|
return _mouse_down_flags;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getPeriodicDelay: (float*)delay interval: (float*)interval
|
- (void) getPeriodicDelay: (float*)delay interval: (float*)interval
|
||||||
|
@ -968,6 +1049,7 @@ static NSColor *shadowCol;
|
||||||
cellFrame.size.width, cellFrame.size.height);
|
cellFrame.size.width, cellFrame.size.height);
|
||||||
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
|
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
|
||||||
|
|
||||||
|
_mouse_down_flags = [theEvent modifierFlags];
|
||||||
if (![self startTrackingAt: point inView: controlView])
|
if (![self startTrackingAt: point inView: controlView])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
|
@ -1051,7 +1133,8 @@ static NSColor *shadowCol;
|
||||||
NSDebugLog(@"NSCell stop tracking\n");
|
NSDebugLog(@"NSCell stop tracking\n");
|
||||||
done = YES;
|
done = YES;
|
||||||
}
|
}
|
||||||
// Did the mouse go up?
|
|
||||||
|
// Did the mouse go up?
|
||||||
if (eventType == NSLeftMouseUp)
|
if (eventType == NSLeftMouseUp)
|
||||||
{
|
{
|
||||||
NSDebugLog(@"NSCell mouse went up\n");
|
NSDebugLog(@"NSCell mouse went up\n");
|
||||||
|
@ -1081,7 +1164,7 @@ static NSColor *shadowCol;
|
||||||
[NSEvent stopPeriodicEvents];
|
[NSEvent stopPeriodicEvents];
|
||||||
|
|
||||||
// Return YES only if the mouse went up within the cell
|
// Return YES only if the mouse went up within the cell
|
||||||
if (mouseWentUp && [controlView mouse: point inRect: cellFrame])
|
if (mouseWentUp && (flag || [controlView mouse: point inRect: cellFrame]))
|
||||||
{
|
{
|
||||||
NSDebugLog(@"NSCell mouse went up in cell\n");
|
NSDebugLog(@"NSCell mouse went up in cell\n");
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -1159,16 +1242,11 @@ static NSColor *shadowCol;
|
||||||
{
|
{
|
||||||
if ((_contents != nil) && ([_contents isEqualToString: @""] == NO))
|
if ((_contents != nil) && ([_contents isEqualToString: @""] == NO))
|
||||||
{
|
{
|
||||||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
s = [self _sizeText: _contents];
|
||||||
_cell_font,
|
|
||||||
NSFontAttributeName,
|
|
||||||
nil];
|
|
||||||
s = [_contents sizeWithAttributes: dict];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s.width = [_cell_font widthOfString: @"A"];
|
s = [self _sizeText: @"A"];
|
||||||
s.height = [_cell_font pointSize] - [_cell_font descender];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1257,78 +1335,6 @@ static NSColor *shadowCol;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this hack without breaking NSTextFieldCell
|
|
||||||
- (NSColor*) textColor
|
|
||||||
{
|
|
||||||
if (_cell.is_disabled)
|
|
||||||
return dtxtCol;
|
|
||||||
else
|
|
||||||
return txtCol;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _drawText: (NSString*) title inFrame: (NSRect) cellFrame
|
|
||||||
{
|
|
||||||
NSColor *textColor;
|
|
||||||
NSDictionary *attributes;
|
|
||||||
NSSize titleSize;
|
|
||||||
|
|
||||||
if (!title)
|
|
||||||
return;
|
|
||||||
|
|
||||||
textColor = [self textColor];
|
|
||||||
|
|
||||||
if (!_cell_font)
|
|
||||||
{
|
|
||||||
[NSException raise: NSInvalidArgumentException
|
|
||||||
format:
|
|
||||||
@"Request to draw a text cell but no font specified!"];
|
|
||||||
}
|
|
||||||
|
|
||||||
attributes = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
||||||
_cell_font, NSFontAttributeName,
|
|
||||||
textColor, NSForegroundColorAttributeName,
|
|
||||||
nil];
|
|
||||||
|
|
||||||
titleSize = [title sizeWithAttributes: attributes];
|
|
||||||
|
|
||||||
// Determine y position of text
|
|
||||||
|
|
||||||
/* Important: text should always be vertically centered without
|
|
||||||
* considering descender [as if descender did not exist].
|
|
||||||
* This is particularly important for single line texts.
|
|
||||||
* Please make sure the output remains always correct.
|
|
||||||
*/
|
|
||||||
cellFrame.origin.y = NSMidY (cellFrame) - titleSize.height/2;
|
|
||||||
cellFrame.size.height = titleSize.height;
|
|
||||||
|
|
||||||
// Determine the x position of text
|
|
||||||
switch (_cell.text_align)
|
|
||||||
{
|
|
||||||
// ignore the justified and natural alignments
|
|
||||||
case NSLeftTextAlignment:
|
|
||||||
case NSJustifiedTextAlignment:
|
|
||||||
case NSNaturalTextAlignment:
|
|
||||||
break;
|
|
||||||
case NSRightTextAlignment:
|
|
||||||
if (titleSize.width < NSWidth (cellFrame))
|
|
||||||
{
|
|
||||||
float shift = NSWidth (cellFrame) - titleSize.width;
|
|
||||||
cellFrame.origin.x += shift;
|
|
||||||
cellFrame.size.width -= shift;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NSCenterTextAlignment:
|
|
||||||
if (titleSize.width < NSWidth (cellFrame))
|
|
||||||
{
|
|
||||||
float shift = (NSWidth (cellFrame) - titleSize.width) / 2;
|
|
||||||
cellFrame.origin.x += shift;
|
|
||||||
cellFrame.size.width -= shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[title drawInRect: cellFrame withAttributes: attributes];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This drawing is minimal and with no background,
|
* This drawing is minimal and with no background,
|
||||||
* to make it easier for subclass to customize drawing.
|
* to make it easier for subclass to customize drawing.
|
||||||
|
@ -1352,6 +1358,11 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
|
|
||||||
|
/* TODO: Enable this when NSDottedFrameRect is implemented.
|
||||||
|
if (_cell.show_first_responder && [[cellFrame window] firstResponder] == cellFrame)
|
||||||
|
NSDottedFrameRect(cellFrame);
|
||||||
|
*/
|
||||||
|
|
||||||
switch (_cell.type)
|
switch (_cell.type)
|
||||||
{
|
{
|
||||||
case NSTextCellType:
|
case NSTextCellType:
|
||||||
|
@ -1381,6 +1392,7 @@ static NSColor *shadowCol;
|
||||||
case NSNullCellType:
|
case NSNullCellType:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// TODO: We don't do any highlighting
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1392,20 +1404,21 @@ static NSColor *shadowCol;
|
||||||
if (NSIsEmptyRect(cellFrame) || ![controlView window])
|
if (NSIsEmptyRect(cellFrame) || ![controlView window])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[controlView lockFocus];
|
|
||||||
|
|
||||||
// draw the border if needed
|
// draw the border if needed
|
||||||
if (_cell.is_bordered)
|
if (_cell.is_bordered)
|
||||||
{
|
{
|
||||||
|
[controlView lockFocus];
|
||||||
[shadowCol set];
|
[shadowCol set];
|
||||||
NSFrameRect(cellFrame);
|
NSFrameRect(cellFrame);
|
||||||
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
else if (_cell.is_bezeled)
|
else if (_cell.is_bezeled)
|
||||||
{
|
{
|
||||||
|
[controlView lockFocus];
|
||||||
NSDrawWhiteBezel(cellFrame, NSZeroRect);
|
NSDrawWhiteBezel(cellFrame, NSZeroRect);
|
||||||
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
|
||||||
[controlView unlockFocus];
|
|
||||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,8 +1454,7 @@ static NSColor *shadowCol;
|
||||||
delegate: (id)anObject
|
delegate: (id)anObject
|
||||||
event: (NSEvent*)theEvent
|
event: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
if (!controlView || !textObject || !_cell_font
|
if (!controlView || !textObject || (_cell.type != NSTextCellType))
|
||||||
|| (_cell.type != NSTextCellType))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[textObject setFrame: [self titleRectForBounds: aRect]];
|
[textObject setFrame: [self titleRectForBounds: aRect]];
|
||||||
|
@ -1487,8 +1499,7 @@ static NSColor *shadowCol;
|
||||||
start: (int)selStart
|
start: (int)selStart
|
||||||
length: (int)selLength
|
length: (int)selLength
|
||||||
{
|
{
|
||||||
if (!controlView || !textObject || !_cell_font
|
if (!controlView || !textObject || (_cell.type != NSTextCellType))
|
||||||
|| (_cell.type != NSTextCellType))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[textObject setFrame: [self titleRectForBounds: aRect]];
|
[textObject setFrame: [self titleRectForBounds: aRect]];
|
||||||
|
@ -1502,13 +1513,12 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
- (BOOL) sendsActionOnEndEditing
|
- (BOOL) sendsActionOnEndEditing
|
||||||
{
|
{
|
||||||
//TODO
|
return _cell.sends_action_on_end_editing;
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setSendsActionOnEndEditing: (BOOL)flag
|
- (void) setSendsActionOnEndEditing: (BOOL)flag
|
||||||
{
|
{
|
||||||
//TODO
|
_cell.sends_action_on_end_editing = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1516,18 +1526,15 @@ static NSColor *shadowCol;
|
||||||
*/
|
*/
|
||||||
- (id) copyWithZone: (NSZone*)zone
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
NSCell *c = [[isa allocWithZone: zone] init];
|
NSCell *c = (NSCell*)NSCopyObject(self, 0, zone);
|
||||||
|
|
||||||
c->_contents = [_contents copyWithZone: zone];
|
c->_contents = [_contents copyWithZone: zone];
|
||||||
ASSIGN (c->_cell_image, _cell_image);
|
c->_typingAttributes = [_typingAttributes mutableCopyWithZone: zone];
|
||||||
ASSIGN (c->_cell_font, _cell_font);
|
c->_objectValue = [_objectValue copyWithZone: zone];
|
||||||
ASSIGN (c->_objectValue, _objectValue);
|
/* Attention! This are now retained */
|
||||||
c->_cell = _cell; // This copies all the flags at once.
|
c->_menu = RETAIN(_menu);
|
||||||
c->_cell_float_left = _cell_float_left;
|
c->_cell_image = RETAIN(_cell_image);
|
||||||
c->_cell_float_right = _cell_float_right;
|
c->_represented_object = RETAIN(_represented_object);
|
||||||
c->_action_mask = _action_mask;
|
|
||||||
/* Attention! This is not retained */
|
|
||||||
c->_represented_object = _represented_object;
|
|
||||||
|
|
||||||
/* Attention! The formatter is retained, *not* copied,
|
/* Attention! The formatter is retained, *not* copied,
|
||||||
as per NSFormatter spec */
|
as per NSFormatter spec */
|
||||||
|
@ -1546,16 +1553,24 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
[aCoder encodeObject: _contents];
|
[aCoder encodeObject: _contents];
|
||||||
[aCoder encodeObject: _cell_image];
|
[aCoder encodeObject: _cell_image];
|
||||||
[aCoder encodeObject: _cell_font];
|
[aCoder encodeObject: _typingAttributes];
|
||||||
[aCoder encodeObject: _objectValue];
|
[aCoder encodeObject: _objectValue];
|
||||||
tmp_int = _cell.state;
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
flag = _cell.is_highlighted;
|
flag = _cell.is_highlighted;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.is_disabled;
|
flag = _cell.is_disabled;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.is_editable;
|
flag = _cell.is_editable;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _cell.is_rich_text;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _cell.imports_graphics;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _cell.shows_first_responder;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _cell.refuses_first_responder;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _cell.sends_action_on_end_editing;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.is_bordered;
|
flag = _cell.is_bordered;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.is_bezeled;
|
flag = _cell.is_bezeled;
|
||||||
|
@ -1568,22 +1583,23 @@ static NSColor *shadowCol;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.float_autorange;
|
flag = _cell.float_autorange;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
flag = _cell.wraps;
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
||||||
flag = _cell.allows_mixed_state;
|
flag = _cell.allows_mixed_state;
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_cell_float_left];
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_cell_float_right];
|
|
||||||
tmp_int = _cell.image_position;
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
tmp_int = _cell.type;
|
tmp_int = _cell.type;
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
tmp_int = _cell.text_align;
|
tmp_int = _cell.image_position;
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
tmp_int = _cell.entry_type;
|
tmp_int = _cell.entry_type;
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
tmp_int = _cell.state;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mnemonic_location];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_cell_float_left];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_cell_float_right];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_mouse_down_flags];
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
||||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_formatter];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_menu];
|
||||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_represented_object];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1591,12 +1607,11 @@ static NSColor *shadowCol;
|
||||||
{
|
{
|
||||||
BOOL flag;
|
BOOL flag;
|
||||||
unsigned int tmp_int;
|
unsigned int tmp_int;
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_font];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_typingAttributes];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_objectValue];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_objectValue];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
_cell.state = tmp_int;
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.is_highlighted = flag;
|
_cell.is_highlighted = flag;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
@ -1604,6 +1619,16 @@ static NSColor *shadowCol;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.is_editable = flag;
|
_cell.is_editable = flag;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
_cell.is_rich_text = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
_cell.imports_graphics = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
_cell.shows_first_responder = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
_cell.refuses_first_responder = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
_cell.sends_action_on_end_editing = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.is_bordered = flag;
|
_cell.is_bordered = flag;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.is_bezeled = flag;
|
_cell.is_bezeled = flag;
|
||||||
|
@ -1616,23 +1641,26 @@ static NSColor *shadowCol;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.float_autorange = flag;
|
_cell.float_autorange = flag;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
_cell.wraps = flag;
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
||||||
_cell.allows_mixed_state = flag;
|
_cell.allows_mixed_state = flag;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
_cell.type = tmp_int;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
_cell.image_position = tmp_int;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
_cell.entry_type = tmp_int;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
||||||
|
_cell.state = tmp_int;
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
|
at: &_mnemonic_location];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
at: &_cell_float_left];
|
at: &_cell_float_left];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
at: &_cell_float_right];
|
at: &_cell_float_right];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
_cell.image_position = tmp_int;
|
at: &_mouse_down_flags];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
_cell.type = tmp_int;
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
_cell.text_align = tmp_int;
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
|
|
||||||
_cell.entry_type = tmp_int;
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_formatter];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_formatter];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_menu];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
|
||||||
|
|
||||||
if (_formatter != nil)
|
if (_formatter != nil)
|
||||||
|
@ -1649,6 +1677,51 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSCell (PrivateMethods)
|
||||||
|
|
||||||
|
// TODO: Remove this hack without breaking NSTextFieldCell
|
||||||
|
- (NSColor*) textColor
|
||||||
|
{
|
||||||
|
if (_cell.is_disabled)
|
||||||
|
return dtxtCol;
|
||||||
|
else
|
||||||
|
return txtCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSize) _sizeText: (NSString*) title
|
||||||
|
{
|
||||||
|
NSSize size;
|
||||||
|
if (title == nil)
|
||||||
|
return NSMakeSize(0,0);
|
||||||
|
|
||||||
|
size = [title sizeWithAttributes: _typingAttributes];
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _drawText: (NSString*) title inFrame: (NSRect) cellFrame
|
||||||
|
{
|
||||||
|
NSSize titleSize;
|
||||||
|
|
||||||
|
if (!title)
|
||||||
|
return;
|
||||||
|
|
||||||
|
titleSize = [self _sizeText: title];
|
||||||
|
|
||||||
|
// Determine y position of text
|
||||||
|
|
||||||
|
/* Important: text should always be vertically centered without
|
||||||
|
* considering descender [as if descender did not exist].
|
||||||
|
* This is particularly important for single line texts.
|
||||||
|
* Please make sure the output remains always correct.
|
||||||
|
*/
|
||||||
|
cellFrame.origin.y = NSMidY (cellFrame) - titleSize.height/2;
|
||||||
|
cellFrame.size.height = titleSize.height;
|
||||||
|
|
||||||
|
[_typingAttributes setObject: [self textColor] forKey: NSForegroundColorAttributeName];
|
||||||
|
[title drawInRect: cellFrame withAttributes: _typingAttributes];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue