mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
* Source/NSSecureTextField.m: Patch to make bullets output when
setEchosBullets is set to yes in NSSecureTextField. Corrects bug #19761. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27020 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a91c8ec537
commit
bd03e7d444
2 changed files with 50 additions and 11 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-11-09 10:24-EST Saso Kiselkov
|
||||||
|
Committed by: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/NSSecureTextField.m: Patch to make bullets output when
|
||||||
|
setEchosBullets is set to yes in NSSecureTextField. Corrects
|
||||||
|
bug #19761.
|
||||||
|
|
||||||
2008-11-08 10:09-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
2008-11-08 10:09-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSDocument.m: Correction for bug#24758, add name and
|
* Source/NSDocument.m: Correction for bug#24758, add name and
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
#include "AppKit/NSTextView.h"
|
#include "AppKit/NSTextView.h"
|
||||||
#include "AppKit/NSWindow.h"
|
#include "AppKit/NSWindow.h"
|
||||||
|
|
||||||
|
// the Unicode code point for a bullet
|
||||||
|
#define BULLET 0x2022
|
||||||
|
|
||||||
/* 'Secure' subclasses */
|
/* 'Secure' subclasses */
|
||||||
@interface NSSecureTextView : NSTextView
|
@interface NSSecureTextView : NSTextView
|
||||||
{
|
{
|
||||||
|
@ -121,20 +124,35 @@
|
||||||
_echosBullets = flag;
|
_echosBullets = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Substitute a fixed-pitch font for correct bullet drawing */
|
||||||
|
- (void) setFont: (NSFont *) f
|
||||||
|
{
|
||||||
|
if (![f isFixedPitch])
|
||||||
|
{
|
||||||
|
f = [NSFont userFixedPitchFontOfSize: [f pointSize]];
|
||||||
|
}
|
||||||
|
|
||||||
|
[super setFont: f];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSAttributedString *)_replacementAttributedString
|
- (NSAttributedString *)_replacementAttributedString
|
||||||
{
|
{
|
||||||
NSDictionary *attributes;
|
NSDictionary *attributes;
|
||||||
NSMutableString *string;
|
NSMutableString *string;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
unichar *buf;
|
||||||
|
|
||||||
length = [[self stringValue] length];
|
length = [[self stringValue] length];
|
||||||
string = [[NSMutableString alloc] initWithCapacity: length];
|
buf = NSZoneMalloc (NSDefaultMallocZone (), length * sizeof (unichar));
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
[string appendString: @"*"];
|
buf[i] = BULLET;
|
||||||
}
|
}
|
||||||
AUTORELEASE(string);
|
|
||||||
|
string = [[NSMutableString alloc]
|
||||||
|
initWithCharactersNoCopy: buf length: length freeWhenDone: YES];
|
||||||
|
AUTORELEASE (string);
|
||||||
|
|
||||||
attributes = [self _nonAutoreleasedTypingAttributes];
|
attributes = [self _nonAutoreleasedTypingAttributes];
|
||||||
return AUTORELEASE([[NSAttributedString alloc] initWithString: string
|
return AUTORELEASE([[NSAttributedString alloc] initWithString: string
|
||||||
|
@ -225,14 +243,28 @@
|
||||||
{
|
{
|
||||||
if ([self echosBullets])
|
if ([self echosBullets])
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
FIXME: Functionality not implemented.
|
* FIXME: Rather stupid way of drawing bullets, but better than nothing
|
||||||
This also doesn't eblong into this method, rather
|
* at all. Works well enough for secure text fields.
|
||||||
we should do the replacement during the glyph generation.
|
* This also doesn't belong into this method, rather we should do
|
||||||
This gets currently done in [GSLayoutManager _generateGlyphsForRun:at:],
|
* the replacement during glyph generation. This gets currently done
|
||||||
but should be done in an NSTypesetter subclass. Only with this in place
|
* in [GSLayoutManager _generateGlyphsForRun:at:], but should be done
|
||||||
it seems possible to implement bullet echoing.
|
* in an NSTypesetter subclass. Only with this in place it seems
|
||||||
*/
|
* possible to implement bullet echoing.
|
||||||
|
*/
|
||||||
|
unichar buf[] = {BULLET};
|
||||||
|
NSString *string = [NSString stringWithCharacters: buf length: 1];
|
||||||
|
NSFont *font = [_typingAttributes objectForKey: NSFontAttributeName];
|
||||||
|
double width = [font widthOfString: string];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = glyphRange.location; i <= NSMaxRange (glyphRange); i++)
|
||||||
|
{
|
||||||
|
NSPoint p = NSMakePoint (containerOrigin.x + (i - 1) * width,
|
||||||
|
containerOrigin.y);
|
||||||
|
|
||||||
|
[string drawAtPoint: p withAttributes: _typingAttributes];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue