public void tile() { /* Let the superclass do most of the work. */ super.tile(); if (!hasHorizontalScroller()) { if (null != _scalePopUpButton) { _scalePopUpButton.removeFromSuperview(); _scalePopUpButton = null; } } else { if (_scalePopUpButton == null) makeScalePopUpButton(); NSScroller horizScroller = horizontalScroller(); NSMutableRect horizScrollerFrame = new NSMutableRect(horizScroller.frame()); NSRect incrementLineFrame = horizScroller.rectForPart(NSScroller.IncrementLine); NSMutableRect buttonFrame = new NSMutableRect(_scalePopUpButton.frame()); /* Adjust the horizontal scroller size and set the button size and location. */ buttonFrame.setX(horizScrollerFrame.x()); buttonFrame.setHeight(incrementLineFrame.height()); buttonFrame.setY(horizScrollerFrame.y() + incrementLineFrame.y()); horizScrollerFrame.setWidth(horizScrollerFrame.width() - (buttonFrame.width() + 1.0f)); horizScrollerFrame.setX(horizScrollerFrame.x() + (buttonFrame.width() + 1.0f)); horizScroller.setFrame(horizScrollerFrame); _scalePopUpButton.setFrame(buttonFrame); } }
public void drawRect(NSRect rect) { NSMutableRect verticalLineRect; super.drawRect(rect); if ((_scalePopUpButton != null) && (_scalePopUpButton.superview() != null)) { verticalLineRect = new NSMutableRect(_scalePopUpButton.frame()); verticalLineRect.setX(verticalLineRect.maxX()); verticalLineRect.setWidth(1.0f); if (verticalLineRect.intersectsRect(rect)) { NSColor.blackColor().set(); NSBezierPath.bezierPathWithRect(verticalLineRect).fill(); } } }
protected void makeScalePopUpButton() { if (_scalePopUpButton == null) { /* Create the pop up button. */ _scalePopUpButton = new NSPopUpButton(new NSRect(0f, 0f, 1f, 1f), false); _scalePopUpButton.setBezelStyle(NSButtonCell.RegularSquareBezelStyle); /* Fill it with the scales. */ int numberOfDefaultItems = MenuLabels.length; for (int i = 0; i < numberOfDefaultItems; i++) { String label = NSBundle.localizedString(MenuLabels[i]); _scalePopUpButton.addItem(label); NSMenuItem item = (NSMenuItem) _scalePopUpButton.itemAtIndex(i); if (ScaleFactors[i] != 0f) { Number factor = new Float(ScaleFactors[i]); item.setRepresentedObject(factor); } } _scalePopUpButton.selectItemAtIndex(DefaultSelectedItem); /* Hook it up. */ _scalePopUpButton.setTarget(this); _scalePopUpButton.setAction(new NSSelector("scalePopUpAction", new Class[] {getClass()})); /* Pick a suitable font. */ _scalePopUpButton.setFont(NSFont.toolTipsFontOfSize(10f)); /* Make sure the pop up is big enough to fit the cells. */ _scalePopUpButton.sizeToFit(); /* Don't ever let it become the first responder. */ _scalePopUpButton.setRefusesFirstResponder(true); /* Put it in the scroll view. */ addSubview(_scalePopUpButton); } }