mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 10:01:56 +00:00
Some support for bullet echoing.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25297 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9883fec367
commit
15e9772c24
2 changed files with 138 additions and 28 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2007-06-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSSecureTextFieldCell (-drawInteriorWithFrame:): Add
|
||||||
|
some support for bullet echoing and a comment on the missing bits.
|
||||||
|
|
||||||
2007-06-28 Fred Kiefer <FredKiefer@gmx.de>
|
2007-06-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSView.m (-_lockFocusInContext:inRect:): Ignore the frame
|
* Source/NSView.m (-_lockFocusInContext:inRect:): Ignore the frame
|
||||||
|
|
|
@ -30,22 +30,31 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include "AppKit/NSSecureTextField.h"
|
|
||||||
#include "AppKit/NSImage.h"
|
#include "AppKit/NSAttributedString.h"
|
||||||
#include "AppKit/NSFont.h"
|
|
||||||
#include "AppKit/NSTextView.h"
|
|
||||||
#include "AppKit/NSLayoutManager.h"
|
|
||||||
#include "AppKit/NSTextContainer.h"
|
|
||||||
#include "AppKit/NSWindow.h"
|
|
||||||
#include "AppKit/NSEvent.h"
|
#include "AppKit/NSEvent.h"
|
||||||
|
#include "AppKit/NSFont.h"
|
||||||
|
#include "AppKit/NSImage.h"
|
||||||
|
#include "AppKit/NSLayoutManager.h"
|
||||||
|
#include "AppKit/NSSecureTextField.h"
|
||||||
|
#include "AppKit/NSTextContainer.h"
|
||||||
|
#include "AppKit/NSTextView.h"
|
||||||
|
#include "AppKit/NSWindow.h"
|
||||||
|
|
||||||
/* 'Secure' subclasses */
|
/* 'Secure' subclasses */
|
||||||
@interface NSSecureTextView : NSTextView
|
@interface NSSecureTextView : NSTextView
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
- (void) setEchosBullets:(BOOL)flag;
|
||||||
|
- (BOOL) echosBullets;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GSSimpleSecureLayoutManager : NSLayoutManager
|
@interface GSSimpleSecureLayoutManager : NSLayoutManager
|
||||||
{}
|
{
|
||||||
|
BOOL _echosBullets;
|
||||||
|
}
|
||||||
|
- (void) setEchosBullets:(BOOL)flag;
|
||||||
|
- (BOOL) echosBullets;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSSecureTextField
|
@implementation NSSecureTextField
|
||||||
|
@ -111,32 +120,97 @@
|
||||||
_echosBullets = flag;
|
_echosBullets = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSAttributedString *)_replacementAttributedString
|
||||||
|
{
|
||||||
|
NSDictionary *attributes;
|
||||||
|
NSMutableString *string;
|
||||||
|
unsigned int length;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
length = [[self stringValue] length];
|
||||||
|
string = [[NSMutableString alloc] initWithCapacity: length];
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
[string appendString: @"*"];
|
||||||
|
}
|
||||||
|
AUTORELEASE(string);
|
||||||
|
|
||||||
|
attributes = [self _nonAutoreleasedTypingAttributes];
|
||||||
|
return AUTORELEASE([[NSAttributedString alloc] initWithString: string
|
||||||
|
attributes: attributes]);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
||||||
inView: (NSView *)controlView
|
inView: (NSView *)controlView
|
||||||
{
|
{
|
||||||
|
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||||
|
|
||||||
/* Draw background, then ... */
|
/* Draw background, then ... */
|
||||||
if (_textfieldcell_draws_background)
|
if (_textfieldcell_draws_background)
|
||||||
{
|
{
|
||||||
if ([self isEnabled])
|
if ([self isEnabled])
|
||||||
{
|
{
|
||||||
[_background_color set];
|
[_background_color set];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[NSColor controlBackgroundColor] set];
|
[[NSColor controlBackgroundColor] set];
|
||||||
}
|
}
|
||||||
NSRectFill ([self drawingRectForBounds: cellFrame]);
|
NSRectFill(cellFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
[self _drawAttributedText: [self _replacementAttributedString]
|
||||||
|
inFrame: cellFrame];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSAttributedString *attrStr = [self _replacementAttributedString];
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* .. do nothing. */
|
||||||
}
|
}
|
||||||
/* .. do nothing. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSText *) setUpFieldEditorAttributes: (NSText *)textObject
|
- (NSText *) setUpFieldEditorAttributes: (NSText *)textObject
|
||||||
{
|
{
|
||||||
/* Replace the text object with a secure instance. It's not shared. */
|
NSSecureTextView *secureView;
|
||||||
textObject = [NSSecureTextView new];
|
|
||||||
AUTORELEASE (textObject);
|
|
||||||
|
|
||||||
return [super setUpFieldEditorAttributes: textObject];
|
/* Replace the text object with a secure instance. It's not shared. */
|
||||||
|
secureView = AUTORELEASE([[NSSecureTextView alloc] init]);
|
||||||
|
|
||||||
|
[secureView setEchosBullets: [self echosBullets]];
|
||||||
|
return [super setUpFieldEditorAttributes: secureView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)decoder
|
- (id) initWithCoder: (NSCoder *)decoder
|
||||||
|
@ -163,11 +237,37 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GSSimpleSecureLayoutManager
|
@implementation GSSimpleSecureLayoutManager
|
||||||
- (void) drawGlyphsForGlyphRange: (NSRange)glyphRange
|
|
||||||
atPoint: (NSPoint)containerOrigin
|
- (BOOL) echosBullets
|
||||||
{
|
{
|
||||||
/* Do nothing. */
|
return _echosBullets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setEchosBullets: (BOOL)flag
|
||||||
|
{
|
||||||
|
_echosBullets = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) drawGlyphsForGlyphRange: (NSRange)glyphRange
|
||||||
|
atPoint: (NSPoint)containerOrigin
|
||||||
|
{
|
||||||
|
if ([self echosBullets])
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
FIXME: Functionality not implemented.
|
||||||
|
This also doesn't eblong into this method, rather
|
||||||
|
we should do the replacement during the glyph generation.
|
||||||
|
This gets currently done in [GSLayoutManager _generateGlyphsForRun:at:],
|
||||||
|
but should be done in an NSTypesetter subclass. Only with this in place
|
||||||
|
it seems possible to implement bullet echoing.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Do nothing. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSSecureTextView
|
@implementation NSSecureTextView
|
||||||
|
@ -183,17 +283,22 @@
|
||||||
/* Then, replace the layout manager with a
|
/* Then, replace the layout manager with a
|
||||||
* GSSimpleSecureLayoutManager. */
|
* GSSimpleSecureLayoutManager. */
|
||||||
m = [[GSSimpleSecureLayoutManager alloc] init];
|
m = [[GSSimpleSecureLayoutManager alloc] init];
|
||||||
AUTORELEASE (m);
|
|
||||||
[[self textContainer] replaceLayoutManager: m];
|
[[self textContainer] replaceLayoutManager: m];
|
||||||
|
RELEASE(m);
|
||||||
|
|
||||||
[self setFieldEditor: YES];
|
[self setFieldEditor: YES];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) copy: (id)sender
|
- (BOOL) echosBullets
|
||||||
{
|
{
|
||||||
/* Do nothing since copying from a NSSecureTextView is not permitted. */
|
return [(GSSimpleSecureLayoutManager*)[self layoutManager] echosBullets];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setEchosBullets: (BOOL)flag
|
||||||
|
{
|
||||||
|
[(GSSimpleSecureLayoutManager*)[self layoutManager] setEchosBullets: flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
||||||
|
@ -205,7 +310,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) validRequestorForSendType: (NSString*) sendType
|
- (id) validRequestorForSendType: (NSString*) sendType
|
||||||
returnType: (NSString*) returnType
|
returnType: (NSString*) returnType
|
||||||
{
|
{
|
||||||
/* Return nil to indicate that no type can be sent to the pasteboard
|
/* Return nil to indicate that no type can be sent to the pasteboard
|
||||||
* for an object of this class. */
|
* for an object of this class. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue