NSRect drawTitleWithFrameInView (long /*int*/ id, long /*int*/ sel, long /*int*/ title, NSRect titleRect, long /*int*/ view) { boolean wrap = (style & SWT.WRAP) != 0 && text.length() != 0; if (wrap) { NSSize wrapSize = new NSSize(); wrapSize.width = titleRect.width; wrapSize.height = MAX_SIZE; NSAttributedString attribStr = createString(text, null, foreground, style, true, true, true); NSRect rect = attribStr.boundingRectWithSize(wrapSize, OS.NSStringDrawingUsesLineFragmentOrigin); switch (style & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) { case SWT.LEFT: rect.x = titleRect.x; break; case SWT.CENTER: rect.x = titleRect.x + (titleRect.width - rect.width) / 2f; break; case SWT.RIGHT: rect.x = titleRect.x + titleRect.width - rect.width; break; } rect.y = titleRect.y + (titleRect.height - rect.height) / 2; attribStr.drawInRect(rect); attribStr.release (); return rect; } return super.drawTitleWithFrameInView(id, sel, title, titleRect, view); }
destRect.width = Math.min (stringSize.width, cellRect.x + cellRect.width - MARGIN - drawX); destRect.height = Math.min (stringSize.height, cellRect.height); attrString.drawInRect (destRect);
destRect.width = Math.min (stringSize.width, cellRect.x + cellRect.width - MARGIN - drawX); destRect.height = Math.min (stringSize.height, cellRect.height); attrString.drawInRect (destRect);
void drawLabelInRect(long /*int*/ id, long /*int*/ sel, boolean shouldTruncateLabel, NSRect rect) { if (image != null && !image.isDisposed()) { NSSize imageSize = image.handle.size(); NSRect destRect = new NSRect(); destRect.x = rect.x; destRect.y = rect.y; destRect.width = imageSize.width; destRect.height = imageSize.height; NSGraphicsContext.static_saveGraphicsState(); NSAffineTransform transform = NSAffineTransform.transform(); transform.scaleXBy(1, -1); transform.translateXBy(0, -(destRect.height + 2 * destRect.y)); transform.concat(); image.handle.drawInRect(destRect, new NSRect(), OS.NSCompositeSourceOver, 1); NSGraphicsContext.static_restoreGraphicsState(); rect.x += imageSize.width + IMAGE_GAP; rect.width -= imageSize.width + IMAGE_GAP; } if (attriStr != null) { attriStr.drawInRect(rect); } super.drawLabelInRect(id, sel, shouldTruncateLabel, rect); }