void addTraits(NSMutableDictionary dict, Font font) { if ((font.extraTraits & OS.NSBoldFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_BOLD), OS.NSStrokeWidthAttributeName); } if ((font.extraTraits & OS.NSItalicFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_ITALIC), OS.NSObliquenessAttributeName); } }
void addTraits(NSMutableDictionary dict) { if ((extraTraits & OS.NSBoldFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_BOLD), OS.NSStrokeWidthAttributeName); } if ((extraTraits & OS.NSItalicFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_ITALIC), OS.NSObliquenessAttributeName); } }
void addPool (NSAutoreleasePool pool) { if (pools == null) pools = new NSAutoreleasePool [4]; if (poolCount == pools.length) { NSAutoreleasePool[] temp = new NSAutoreleasePool [poolCount + 4]; System.arraycopy (pools, 0, temp, 0, poolCount); pools = temp; } if (poolCount == 0) { NSMutableDictionary dictionary = NSThread.currentThread().threadDictionary(); dictionary.setObject(NSNumber.numberWithInteger(pool.id), NSString.stringWith("SWT_NSAutoreleasePool")); } pools [poolCount++] = pool; }
NSAttributedString createString(String string, int flags, boolean draw) { NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(5); Font font = data.font; dict.setObject(font.handle, OS.NSFontAttributeName); font.addTraits(dict); if (draw) { Pattern pattern = data.foregroundPattern; if (pattern != null) { if (pattern.color != null) dict.setObject(pattern.color, OS.NSForegroundColorAttributeName); } else { NSColor fg = data.fg; fg.retain(); dict.setObject(fg, OS.NSForegroundColorAttributeName); dict.setObject(device.paragraphStyle, OS.NSParagraphStyleAttributeName);
NSAttributedString createString (String string, Font font, double /*float*/ [] foreground, int alignment, boolean wrap, boolean enabled, boolean mnemonics) { NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(5); if (font == null) font = this.font != null ? this.font : defaultFont(); dict.setObject (font.handle, OS.NSFontAttributeName); addTraits(dict, font); if (enabled) { if (foreground != null) { NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], foreground[3]); dict.setObject (color, OS.NSForegroundColorAttributeName); dict.setObject (NSColor.disabledControlTextColor (), OS.NSForegroundColorAttributeName); paragraphStyle.setBaseWritingDirection(OS.NSWritingDirectionLeftToRight); dict.setObject (paragraphStyle, OS.NSParagraphStyleAttributeName); paragraphStyle.release (); int length = string.length ();
paragraphStyle.setBaseWritingDirection(direction); paragraphStyle.setLineBreakMode(OS.NSLineBreakByTruncatingMiddle); dict.setObject (paragraphStyle, OS.NSParagraphStyleAttributeName); paragraphStyle.release (); dict.setObject (NSFont.menuBarFontOfSize(0), OS.NSFontAttributeName); NSAttributedString attribStr = ((NSAttributedString) new NSAttributedString ().alloc ()).initWithString (label, dict); dict.release();
if (obj == null) { NSNumber nsnumber = NSNumber.numberWithInteger(pool.id); dictionary.setObject(nsnumber, key); } else { pool.release();
String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; //$NON-NLS-1$ NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(3); dict.setObject(data.font.handle, OS.NSFontAttributeName); data.font.addTraits(dict); NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString(NSString.stringWith(s), dict);
if (font.extraTraits != 0) { NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(5); dict.setObject (color, OS.NSForegroundColorAttributeName); dict.setObject (font.handle, OS.NSFontAttributeName); addTraits(dict, font); NSMutableParagraphStyle paragraphStyle = (NSMutableParagraphStyle)new NSMutableParagraphStyle ().alloc ().init (); paragraphStyle.setAlignment (alignment); paragraphStyle.setBaseWritingDirection(direction); dict.setObject (paragraphStyle, OS.NSParagraphStyleAttributeName); paragraphStyle.release (); NSAttributedString attribStr = ((NSAttributedString) new NSAttributedString ().alloc ()).initWithString (textCell.title(), dict);
if (font.extraTraits != 0) { NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(5); dict.setObject (color, OS.NSForegroundColorAttributeName); dict.setObject (font.handle, OS.NSFontAttributeName); addTraits(dict, font); NSMutableParagraphStyle paragraphStyle = (NSMutableParagraphStyle)new NSMutableParagraphStyle ().alloc ().init (); paragraphStyle.setAlignment (alignment); paragraphStyle.setBaseWritingDirection(direction); dict.setObject (paragraphStyle, OS.NSParagraphStyleAttributeName); paragraphStyle.release (); NSAttributedString attribStr = ((NSAttributedString) new NSAttributedString ().alloc ()).initWithString (textCell.title(), dict);
label = label.initWithString(accelText); NSMutableDictionary dict = ((NSMutableDictionary)new NSMutableDictionary().alloc()).initWithCapacity(1); dict.setObject (NSFont.menuBarFontOfSize(0), OS.NSFontAttributeName); NSAttributedString attribStr = ((NSAttributedString) new NSAttributedString ().alloc ()).initWithString (label, dict); dict.release();
dict.setDictionary(widget.selectedTextAttributes()); dict.removeObjectForKey(OS.NSBackgroundColorAttributeName); dict.setObject(NSCursor.arrowCursor(), OS.NSCursorAttributeName); widget.setSelectedTextAttributes(dict);