Color getWidgetColor (int id) { if (0 <= id && id < colors.length && colors [id] != null) { return Color.cocoa_new (this, colors [id]); } return null; }
/** * Returns the receiver's foreground color. * * @return the color used for drawing foreground things * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Color getForeground() { if (handle == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED); return Color.cocoa_new(data.device, data.foreground); }
/** * Returns the background color. * * @return the receiver's background color * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Color getBackground() { if (handle == null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); return Color.cocoa_new (data.device, data.background); }
Color getBackgroundColor () { return background != null ? Color.cocoa_new (display, background) : defaultBackground (); }
Color getForegroundColor () { return foreground != null ? Color.cocoa_new (display, foreground) : defaultForeground (); }
/** * Returns the color to which to map the transparent pixel, or null if * the receiver has no transparent pixel. * <p> * There are certain uses of Images that do not support transparency * (for example, setting an image into a button or label). In these cases, * it may be desired to simulate transparency by using the background * color of the widget to paint the transparent pixels of the image. * Use this method to check which color will be used in these cases * in place of transparency. This value may be set with setBackground(). * <p> * * @return the background color of the image, or null if there is no transparency in the image * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Color getBackground() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (transparentPixel == -1) return null; int red = (transparentPixel >> 16) & 0xFF; int green = (transparentPixel >> 8) & 0xFF; int blue = (transparentPixel >> 0) & 0xFF; return Color.cocoa_new(device, new double /*float*/ []{red / 255f, green / 255f, blue / 255f, 1}); }
if (key.isEqualTo (OS.NSBackgroundColorAttributeName)) { NSColor color = new NSColor (attribs.objectForKey (key)); style.background = Color.cocoa_new (display, display.getNSColorRGB(color)); } else if (key.isEqualTo (OS.NSForegroundColorAttributeName)) { NSColor color = new NSColor (attribs.objectForKey (key)); style.foreground = Color.cocoa_new (display, display.getNSColorRGB(color)); } else if (key.isEqualTo (OS.NSUnderlineColorAttributeName)) { NSColor color = new NSColor (attribs.objectForKey (key)); style.underlineColor = Color.cocoa_new (display, display.getNSColorRGB(color)); } else if (key.isEqualTo (OS.NSUnderlineStyleAttributeName)) { NSNumber value = new NSNumber (attribs.objectForKey (key)); } else if (key.isEqualTo (OS.NSStrikethroughColorAttributeName)) { NSColor color = new NSColor (attribs.objectForKey (key)); style.strikeoutColor = Color.cocoa_new (display, display.getNSColorRGB(color)); } else if (key.isEqualTo (OS.NSStrikethroughStyleAttributeName)) { NSNumber value = new NSNumber (attribs.objectForKey (key));
selectionForeground = Color.cocoa_new(display, hasFocus ? display.alternateSelectedControlTextColor : display.selectedControlTextColor); selectionBackground = Color.cocoa_new(display, hasFocus ? display.alternateSelectedControlColor : display.secondarySelectedControlColor); userForeground = Color.cocoa_new(display, gc.getForeground().handle);
selectionForeground = Color.cocoa_new(display, hasFocus ? display.alternateSelectedControlTextColor : display.selectedControlTextColor); selectionBackground = Color.cocoa_new(display, hasFocus ? display.alternateSelectedControlColor : display.secondarySelectedControlColor); userForeground = Color.cocoa_new(display, gc.getForeground().handle);