mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 16:00:41 +00:00
Better helper methods for cell string drawing. Implement MacOSX 10.4
methods on NSForm and NSFormCell. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25421 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eef9e991e9
commit
561e8d0985
8 changed files with 320 additions and 220 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2007-08-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSCell.h: Export more private drawing methods.
|
||||||
|
* Source/NSCell.m (-_drawAttributedString): New helper method to
|
||||||
|
get the attributed string which should be drawn.
|
||||||
|
* Source/NSCell.m (-drawInteriorWithFrame:inView:): Use this method.
|
||||||
|
* Source/NSSecureTextFieldCell.m: Implement -_drawAttributedString
|
||||||
|
instead of -drawInteriorWithFrame:.
|
||||||
|
* Headers/AppKit/NSFormCell.h,
|
||||||
|
* Headers/AppKit/NSForm.h: Add MacOSX 10.4 methods.
|
||||||
|
* Source/NSForm.m: Implement these methods.
|
||||||
|
* Source/NSFormCell.m: Implement these methods. Rewrote drawing
|
||||||
|
code. Remove the color change notification handling.
|
||||||
|
|
||||||
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSApplication.m (-_windowWillClose:): Don't call
|
* Source/NSApplication.m (-_windowWillClose:): Don't call
|
||||||
|
@ -7,7 +21,7 @@
|
||||||
|
|
||||||
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSCell.m (#initialize): Increase version number.
|
* Source/NSCell.m (+initialize): Increase version number.
|
||||||
* Source/NSCell.m (-initWithCoder:): Correct values for the
|
* Source/NSCell.m (-initWithCoder:): Correct values for the
|
||||||
decoded action mask, as they changed on 2007-08-03.
|
decoded action mask, as they changed on 2007-08-03.
|
||||||
Fixes bug #20884.
|
Fixes bug #20884.
|
||||||
|
|
|
@ -484,6 +484,11 @@ enum {
|
||||||
- (void) _drawAttributedText: (NSAttributedString*)aString
|
- (void) _drawAttributedText: (NSAttributedString*)aString
|
||||||
inFrame: (NSRect)aRect;
|
inFrame: (NSRect)aRect;
|
||||||
- (BOOL) _sendsActionOn:(int)eventTypeMask;
|
- (BOOL) _sendsActionOn:(int)eventTypeMask;
|
||||||
|
- (NSAttributedString*) _drawAttributedString;
|
||||||
|
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView*)controlView;
|
||||||
|
- (void) _drawFocusRingWithFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView*)controlView;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -64,6 +64,10 @@
|
||||||
- (void)setTextFont:(NSFont*)fontObject;
|
- (void)setTextFont:(NSFont*)fontObject;
|
||||||
- (void)setTitleAlignment:(NSTextAlignment)aMode;
|
- (void)setTitleAlignment:(NSTextAlignment)aMode;
|
||||||
- (void)setTitleFont:(NSFont*)fontObject;
|
- (void)setTitleFont:(NSFont*)fontObject;
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||||
|
- (void) setTitleBaseWritingDirection: (NSWritingDirection)direction;
|
||||||
|
- (void) setTextBaseWritingDirection: (NSWritingDirection)direction;
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getting a Cell
|
// Getting a Cell
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
// YES if the titleWidth is automatically computed
|
// YES if the titleWidth is automatically computed
|
||||||
#define _formcell_auto_title_width _cell.subclass_bool_one
|
#define _formcell_auto_title_width _cell.subclass_bool_one
|
||||||
NSCell* _titleCell;
|
NSCell* _titleCell;
|
||||||
|
#define _formcell_placeholder_is_attributed_string _cell.subclass_bool_two
|
||||||
|
id _placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -67,7 +69,15 @@
|
||||||
- (void)setAttributedTitle:(NSAttributedString *)anAttributedString;
|
- (void)setAttributedTitle:(NSAttributedString *)anAttributedString;
|
||||||
- (void)setTitleWithMnemonic:(NSString *)titleWithAmpersand;
|
- (void)setTitleWithMnemonic:(NSString *)titleWithAmpersand;
|
||||||
#endif
|
#endif
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||||
|
- (NSAttributedString*)placeholderAttributedString;
|
||||||
|
- (NSString*)placeholderString;
|
||||||
|
- (void)setPlaceholderAttributedString:(NSAttributedString*)string;
|
||||||
|
- (void)setPlaceholderString:(NSString*)string;
|
||||||
|
|
||||||
|
- (NSWritingDirection)titleBaseWritingDirection;
|
||||||
|
- (void)setTitleBaseWritingDirection:(NSWritingDirection)writingDirection;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
131
Source/NSCell.m
131
Source/NSCell.m
|
@ -1943,33 +1943,8 @@ static NSColor *shadowCol;
|
||||||
switch (_cell.type)
|
switch (_cell.type)
|
||||||
{
|
{
|
||||||
case NSTextCellType:
|
case NSTextCellType:
|
||||||
{
|
[self _drawAttributedText: [self _drawAttributedString]
|
||||||
if (!_cell.is_disabled)
|
|
||||||
{
|
|
||||||
[self _drawAttributedText: [self attributedStringValue]
|
|
||||||
inFrame: cellFrame];
|
inFrame: cellFrame];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NSAttributedString *attrStr = [self attributedStringValue];
|
|
||||||
NSDictionary *attribs;
|
|
||||||
NSMutableDictionary *newAttribs;
|
|
||||||
|
|
||||||
attribs = [attrStr attributesAtIndex: 0
|
|
||||||
effectiveRange: NULL];
|
|
||||||
newAttribs = [NSMutableDictionary
|
|
||||||
dictionaryWithDictionary: attribs];
|
|
||||||
[newAttribs setObject: [NSColor disabledControlTextColor]
|
|
||||||
forKey: NSForegroundColorAttributeName];
|
|
||||||
|
|
||||||
attrStr = [[NSAttributedString alloc]
|
|
||||||
initWithString: [attrStr string]
|
|
||||||
attributes: newAttribs];
|
|
||||||
[self _drawAttributedText: attrStr
|
|
||||||
inFrame: cellFrame];
|
|
||||||
RELEASE(attrStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageCellType:
|
case NSImageCellType:
|
||||||
|
@ -2001,44 +1976,6 @@ static NSColor *shadowCol;
|
||||||
// prettyfying
|
// prettyfying
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helper method overridden in subclasses
|
|
||||||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
|
||||||
{
|
|
||||||
if (_cell.is_bordered)
|
|
||||||
{
|
|
||||||
[shadowCol set];
|
|
||||||
NSFrameRect(cellFrame);
|
|
||||||
}
|
|
||||||
else if (_cell.is_bezeled)
|
|
||||||
{
|
|
||||||
[[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private helper method
|
|
||||||
- (void) _drawFocusRingWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
|
||||||
{
|
|
||||||
if (_cell.shows_first_responder
|
|
||||||
&& [[controlView window] firstResponder] == controlView)
|
|
||||||
{
|
|
||||||
switch (_cell.focus_ring_type)
|
|
||||||
{
|
|
||||||
case NSFocusRingTypeDefault:
|
|
||||||
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds:
|
|
||||||
cellFrame]
|
|
||||||
view: controlView];
|
|
||||||
break;
|
|
||||||
case NSFocusRingTypeExterior:
|
|
||||||
[[GSTheme theme] drawFocusFrame: cellFrame
|
|
||||||
view: controlView];
|
|
||||||
break;
|
|
||||||
case NSFocusRingTypeNone:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**<p>Draws the cell in <var>controlView</var></p>
|
/**<p>Draws the cell in <var>controlView</var></p>
|
||||||
*/
|
*/
|
||||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
|
@ -2802,6 +2739,33 @@ static NSColor *shadowCol;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private internal method, returns an attributed string to display.
|
||||||
|
*/
|
||||||
|
- (NSAttributedString*) _drawAttributedString
|
||||||
|
{
|
||||||
|
if (!_cell.is_disabled)
|
||||||
|
{
|
||||||
|
return [self attributedStringValue];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSAttributedString *attrStr = [self attributedStringValue];
|
||||||
|
NSDictionary *attribs;
|
||||||
|
NSMutableDictionary *newAttribs;
|
||||||
|
|
||||||
|
attribs = [attrStr attributesAtIndex: 0
|
||||||
|
effectiveRange: NULL];
|
||||||
|
newAttribs = [NSMutableDictionary dictionaryWithDictionary: attribs];
|
||||||
|
[newAttribs setObject: [NSColor disabledControlTextColor]
|
||||||
|
forKey: NSForegroundColorAttributeName];
|
||||||
|
|
||||||
|
return AUTORELEASE([[NSAttributedString alloc]
|
||||||
|
initWithString: [attrStr string]
|
||||||
|
attributes: newAttribs]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private internal method to display an attributed string.
|
* Private internal method to display an attributed string.
|
||||||
*/
|
*/
|
||||||
|
@ -2849,6 +2813,45 @@ static NSColor *shadowCol;
|
||||||
RELEASE (attributes);
|
RELEASE (attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Private helper method overridden in subclasses
|
||||||
|
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView*)controlView
|
||||||
|
{
|
||||||
|
if (_cell.is_bordered)
|
||||||
|
{
|
||||||
|
[shadowCol set];
|
||||||
|
NSFrameRect(cellFrame);
|
||||||
|
}
|
||||||
|
else if (_cell.is_bezeled)
|
||||||
|
{
|
||||||
|
[[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Private helper method
|
||||||
|
- (void) _drawFocusRingWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
|
{
|
||||||
|
if (_cell.shows_first_responder
|
||||||
|
&& [[controlView window] firstResponder] == controlView)
|
||||||
|
{
|
||||||
|
switch (_cell.focus_ring_type)
|
||||||
|
{
|
||||||
|
case NSFocusRingTypeDefault:
|
||||||
|
[[GSTheme theme] drawFocusFrame: [self drawingRectForBounds:
|
||||||
|
cellFrame]
|
||||||
|
view: controlView];
|
||||||
|
break;
|
||||||
|
case NSFocusRingTypeExterior:
|
||||||
|
[[GSTheme theme] drawFocusFrame: cellFrame
|
||||||
|
view: controlView];
|
||||||
|
break;
|
||||||
|
case NSFocusRingTypeNone:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) _sendsActionOn:(int)eventTypeMask
|
- (BOOL) _sendsActionOn:(int)eventTypeMask
|
||||||
{
|
{
|
||||||
return (_action_mask & eventTypeMask);
|
return (_action_mask & eventTypeMask);
|
||||||
|
|
|
@ -196,6 +196,16 @@ static Class defaultCellClass = nil;
|
||||||
[self setCellSize: size];
|
[self setCellSize: size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**<p>Sets the size of the frame to aSize</p>
|
||||||
|
<p>See Also: [NSView-setFrameSize:]</p>
|
||||||
|
*/
|
||||||
|
- (void) setFrameSize: (NSSize)aSize
|
||||||
|
{
|
||||||
|
[super setFrameSize: aSize];
|
||||||
|
// Set the width of the entries independent of autosizesCells
|
||||||
|
_cellSize.width = _bounds.size.width;
|
||||||
|
}
|
||||||
|
|
||||||
/** <p>Sets the spacing between all entries to spacing. By default
|
/** <p>Sets the spacing between all entries to spacing. By default
|
||||||
the spacing is 4.</p><p>See Also: [NSMatrix-setIntercellSpacing:]</p>
|
the spacing is 4.</p><p>See Also: [NSMatrix-setIntercellSpacing:]</p>
|
||||||
*/
|
*/
|
||||||
|
@ -268,6 +278,34 @@ static Class defaultCellClass = nil;
|
||||||
[[self cellAtRow: i column: 0] setFont: fontObject];
|
[[self cellAtRow: i column: 0] setFont: fontObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** <p>Sets the title writing direction to direction for all entries</p>
|
||||||
|
<p>See Also: [NSFormCell-setTitleBaseWritingDirection:] -setTextBaseWritingDirection:</p>
|
||||||
|
*/
|
||||||
|
- (void) setTitleBaseWritingDirection: (NSWritingDirection)direction
|
||||||
|
{
|
||||||
|
int i, count = [self numberOfRows];
|
||||||
|
|
||||||
|
/* Set the writing direction attribute to the cell prototype */
|
||||||
|
[[self prototype] setTitleBaseWritingDirection: direction];
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
[[self cellAtRow: i column: 0] setTitleBaseWritingDirection: direction];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** <p>Sets the contents writing direction to direction for all entries</p>
|
||||||
|
<p>See Also: [NSCell-setBaseWritingDirection:] -setTitleBaseWritingDirection:</p>
|
||||||
|
*/
|
||||||
|
- (void) setTextBaseWritingDirection: (NSWritingDirection)direction
|
||||||
|
{
|
||||||
|
int i, count = [self numberOfRows];
|
||||||
|
|
||||||
|
/* Set the writing direction attribute to the cell prototype */
|
||||||
|
[[self prototype] setBaseWritingDirection: direction];
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
[[self cellAtRow: i column: 0] setBaseWritingDirection: direction];
|
||||||
|
}
|
||||||
|
|
||||||
/**<p>Returns the index of the entry specified by aTag or -1 if aTag is not
|
/**<p>Returns the index of the entry specified by aTag or -1 if aTag is not
|
||||||
found in entries.</p><p>See Also: [NSMatrix-cellAtRow:column:]</p>
|
found in entries.</p><p>See Also: [NSMatrix-cellAtRow:column:]</p>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include "AppKit/NSAttributedString.h"
|
||||||
#include "AppKit/NSColor.h"
|
#include "AppKit/NSColor.h"
|
||||||
#include "AppKit/NSFormCell.h"
|
#include "AppKit/NSFormCell.h"
|
||||||
#include "AppKit/NSFont.h"
|
#include "AppKit/NSFont.h"
|
||||||
|
@ -36,19 +37,6 @@
|
||||||
#include "AppKit/NSTextFieldCell.h"
|
#include "AppKit/NSTextFieldCell.h"
|
||||||
#include "GNUstepGUI/GSTheme.h"
|
#include "GNUstepGUI/GSTheme.h"
|
||||||
|
|
||||||
static NSColor *shadowCol;
|
|
||||||
|
|
||||||
@interface NSFormCell (PrivateColor)
|
|
||||||
+ (void) _systemColorsChanged: (NSNotification*)n;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSFormCell (PrivateColor)
|
|
||||||
+ (void) _systemColorsChanged: (NSNotification*)n
|
|
||||||
{
|
|
||||||
ASSIGN(shadowCol, [NSColor controlDarkShadowColor]);
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
/** <p>TODO Description </p>
|
/** <p>TODO Description </p>
|
||||||
*/
|
*/
|
||||||
@implementation NSFormCell
|
@implementation NSFormCell
|
||||||
|
@ -57,12 +45,6 @@ static NSColor *shadowCol;
|
||||||
if (self == [NSFormCell class])
|
if (self == [NSFormCell class])
|
||||||
{
|
{
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
addObserver: self
|
|
||||||
selector: @selector(_systemColorsChanged:)
|
|
||||||
name: NSSystemColorsDidChangeNotification
|
|
||||||
object: nil];
|
|
||||||
[self _systemColorsChanged: nil];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +77,7 @@ static NSColor *shadowCol;
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
RELEASE(_titleCell);
|
RELEASE(_titleCell);
|
||||||
|
TEST_RELEASE(_placeholder);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +216,22 @@ static NSColor *shadowCol;
|
||||||
return [_titleCell font];
|
return [_titleCell font];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** <p>Returns the writing direction of the NSFormCell's title</p>
|
||||||
|
<p>See Also: -setTitleBaseWritingDirection: [NSCell-baseWritingDirection]</p>
|
||||||
|
*/
|
||||||
|
- (NSWritingDirection)titleBaseWritingDirection
|
||||||
|
{
|
||||||
|
return [_titleCell baseWritingDirection];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** <p>Sets the writing direction of the NSFormCell's title</p>
|
||||||
|
<p>See Also: -titleBaseWritingDirection: [NSCell-setBaseWritingDirection]</p>
|
||||||
|
*/
|
||||||
|
- (void)setTitleBaseWritingDirection: (NSWritingDirection)writingDirection
|
||||||
|
{
|
||||||
|
[_titleCell setBaseWritingDirection: writingDirection];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Warning: this method returns the width of the title; the width the
|
// Warning: this method returns the width of the title; the width the
|
||||||
// title would have if the cell was the only cell in the form. This
|
// title would have if the cell was the only cell in the form. This
|
||||||
|
@ -268,6 +267,42 @@ static NSColor *shadowCol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSAttributedString*)placeholderAttributedString
|
||||||
|
{
|
||||||
|
if (_formcell_placeholder_is_attributed_string == YES)
|
||||||
|
{
|
||||||
|
return (NSAttributedString*)_placeholder;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)placeholderString
|
||||||
|
{
|
||||||
|
if (_formcell_placeholder_is_attributed_string == YES)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (NSString*)_placeholder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPlaceholderAttributedString: (NSAttributedString*)string
|
||||||
|
{
|
||||||
|
ASSIGN(_placeholder, string);
|
||||||
|
_formcell_placeholder_is_attributed_string = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPlaceholderString: (NSString*)string
|
||||||
|
{
|
||||||
|
ASSIGN(_placeholder, string);
|
||||||
|
_formcell_placeholder_is_attributed_string = NO;
|
||||||
|
}
|
||||||
|
|
||||||
// Updates the title width. The width of aRect is the new title width
|
// Updates the title width. The width of aRect is the new title width
|
||||||
// to display. Invoked by NSForm to align the editable parts of the
|
// to display. Invoked by NSForm to align the editable parts of the
|
||||||
// cells.
|
// cells.
|
||||||
|
@ -318,61 +353,80 @@ static NSColor *shadowCol;
|
||||||
return [super drawingRectForBounds: theRect];
|
return [super drawingRectForBounds: theRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
{
|
{
|
||||||
NSRect titleFrame = cellFrame;
|
|
||||||
NSRect borderedFrame = cellFrame;
|
NSRect borderedFrame = cellFrame;
|
||||||
|
|
||||||
// Save last view drawn to
|
|
||||||
if (_control_view != controlView)
|
|
||||||
_control_view = controlView;
|
|
||||||
|
|
||||||
// do nothing if cell's frame rect is zero
|
|
||||||
if (NSIsEmptyRect(cellFrame))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Safety check
|
|
||||||
if (_displayedTitleWidth == -1)
|
|
||||||
_displayedTitleWidth = [self titleWidth];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw title
|
|
||||||
//
|
|
||||||
titleFrame.size.width = _displayedTitleWidth;
|
|
||||||
[_titleCell drawWithFrame: titleFrame inView: controlView];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Leave unfilled the space between titlecell and editable text.
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw border
|
// Draw border
|
||||||
//
|
//
|
||||||
borderedFrame.origin.x += _displayedTitleWidth + 3;
|
borderedFrame.origin.x += _displayedTitleWidth + 3;
|
||||||
borderedFrame.size.width -= _displayedTitleWidth + 3;
|
borderedFrame.size.width -= _displayedTitleWidth + 3;
|
||||||
|
|
||||||
if (NSIsEmptyRect(borderedFrame))
|
[super _drawBorderAndBackgroundWithFrame: borderedFrame inView: controlView];
|
||||||
return;
|
// Draw text background
|
||||||
|
|
||||||
if (_cell.is_bordered)
|
|
||||||
{
|
|
||||||
[shadowCol set];
|
|
||||||
NSFrameRect(borderedFrame);
|
|
||||||
}
|
|
||||||
else if (_cell.is_bezeled)
|
|
||||||
{
|
|
||||||
NSRect frame;
|
|
||||||
|
|
||||||
frame = [[GSTheme theme] drawWhiteBezel: borderedFrame
|
|
||||||
withClip: NSZeroRect];
|
|
||||||
[[NSColor textBackgroundColor] set];
|
[[NSColor textBackgroundColor] set];
|
||||||
NSRectFill (frame);
|
NSRectFill([self drawingRectForBounds: cellFrame]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
// Draw interior
|
{
|
||||||
//
|
NSRect titleFrame = cellFrame;
|
||||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
|
||||||
|
// Safety check
|
||||||
|
if (_displayedTitleWidth == -1)
|
||||||
|
_displayedTitleWidth = [self titleWidth];
|
||||||
|
|
||||||
|
// Draw title
|
||||||
|
titleFrame.size.width = _displayedTitleWidth;
|
||||||
|
[_titleCell drawWithFrame: titleFrame inView: controlView];
|
||||||
|
|
||||||
|
// Draw text
|
||||||
|
[super drawWithFrame: cellFrame inView: controlView];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Attributed string that will be displayed.
|
||||||
|
*/
|
||||||
|
- (NSAttributedString*)_drawAttributedString
|
||||||
|
{
|
||||||
|
NSAttributedString *attrStr;
|
||||||
|
|
||||||
|
attrStr = [super _drawAttributedString];
|
||||||
|
if (attrStr == nil)
|
||||||
|
{
|
||||||
|
attrStr = [self placeholderAttributedString];
|
||||||
|
if (attrStr == nil)
|
||||||
|
{
|
||||||
|
NSString *string;
|
||||||
|
NSDictionary *attributes;
|
||||||
|
NSMutableDictionary *newAttribs;
|
||||||
|
|
||||||
|
string = [self placeholderString];
|
||||||
|
if (string == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes = [self _nonAutoreleasedTypingAttributes];
|
||||||
|
newAttribs = [NSMutableDictionary
|
||||||
|
dictionaryWithDictionary: attributes];
|
||||||
|
[newAttribs setObject: [NSColor disabledControlTextColor]
|
||||||
|
forKey: NSForegroundColorAttributeName];
|
||||||
|
|
||||||
|
return AUTORELEASE([[NSAttributedString alloc]
|
||||||
|
initWithString: string
|
||||||
|
attributes: newAttribs]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return attrStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return attrStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -387,6 +441,7 @@ static NSColor *shadowCol;
|
||||||
title cell of the copied cell, the string value of the title cell
|
title cell of the copied cell, the string value of the title cell
|
||||||
of the original cell would be changed too ! */
|
of the original cell would be changed too ! */
|
||||||
c->_titleCell = [_titleCell copyWithZone: zone];
|
c->_titleCell = [_titleCell copyWithZone: zone];
|
||||||
|
c->_placeholder = [_placeholder copyWithZone: zone];
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,40 +140,13 @@
|
||||||
attributes: attributes]);
|
attributes: attributes]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
- (NSAttributedString*) _drawAttributedString
|
||||||
inView: (NSView *)controlView
|
|
||||||
{
|
{
|
||||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
|
||||||
|
|
||||||
/* Draw background, then ... */
|
|
||||||
if (_textfieldcell_draws_background)
|
|
||||||
{
|
|
||||||
if ([self isEnabled])
|
|
||||||
{
|
|
||||||
[_background_color set];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[[NSColor controlBackgroundColor] set];
|
|
||||||
}
|
|
||||||
NSRectFill(cellFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_echosBullets)
|
if (_echosBullets)
|
||||||
{
|
{
|
||||||
// Add spacing between border and inside
|
|
||||||
if (_cell.is_bordered || _cell.is_bezeled)
|
|
||||||
{
|
|
||||||
cellFrame.origin.x += 3;
|
|
||||||
cellFrame.size.width -= 6;
|
|
||||||
cellFrame.origin.y += 1;
|
|
||||||
cellFrame.size.height -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cell.is_disabled)
|
if (!_cell.is_disabled)
|
||||||
{
|
{
|
||||||
[self _drawAttributedText: [self _replacementAttributedString]
|
return [self _replacementAttributedString];
|
||||||
inFrame: cellFrame];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -188,17 +161,15 @@
|
||||||
[newAttribs setObject: [NSColor disabledControlTextColor]
|
[newAttribs setObject: [NSColor disabledControlTextColor]
|
||||||
forKey: NSForegroundColorAttributeName];
|
forKey: NSForegroundColorAttributeName];
|
||||||
|
|
||||||
attrStr = [[NSAttributedString alloc]
|
return AUTORELEASE([[NSAttributedString alloc]
|
||||||
initWithString: [attrStr string]
|
initWithString: [attrStr string]
|
||||||
attributes: newAttribs];
|
attributes: newAttribs]);
|
||||||
[self _drawAttributedText: attrStr
|
|
||||||
inFrame: cellFrame];
|
|
||||||
RELEASE(attrStr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* .. do nothing. */
|
/* .. do nothing. */
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue