public NSRect(Point2D origin, Dimension2D size) { this.origin = new NSPoint(origin); this.size = new NSSize(size); }
public NSRect(double w, double h) { this.origin = new NSPoint(0, 0); this.size = new NSSize(w, h); }
public NSRect(Rectangle2D rect) { this.origin = new NSPoint(rect.getX(), rect.getY()); this.size = new NSSize(rect.getWidth(), rect.getHeight()); }
public NSRect() { this(new NSPoint(0, 0), new NSSize()); }
/** * Overlay badge image. * * @param badge Overlay * @param icon Icon * @return Cached icon */ @Override protected NSImage badge(final NSImage badge, final NSImage icon) { NSImage f = NSImage.imageWithSize(icon.size()); f.lockFocus(); icon.drawInRect(new NSRect(new NSPoint(0, 0), icon.size()), NSZeroRect, NSGraphics.NSCompositeSourceOver, 1.0f); badge.drawInRect(new NSRect(new NSPoint(0, 0), badge.size()), NSZeroRect, NSGraphics.NSCompositeSourceOver, 1.0f); f.unlockFocus(); return f; }
if(event != null) { NSPoint dragPosition = view.convertPoint_fromView(event.locationInWindow(), null); NSRect imageRect = new NSRect(new NSPoint(dragPosition.x.doubleValue() - 16, dragPosition.y.doubleValue() - 16), new NSSize(32, 32)); view.dragPromisedFilesOfTypes(NSMutableArray.arrayWithObject(fileTypes.iterator().next()), imageRect, this.id(), true, event);
/** * Resize window frame to fit the content view of the currently selected tab. */ private void resize() { final NSRect windowFrame = NSWindow.contentRectForFrameRect_styleMask(window.frame(), window.styleMask()); final double height = this.getMinWindowHeight(); final NSRect frameRect = new NSRect( new NSPoint(windowFrame.origin.x.doubleValue(), windowFrame.origin.y.doubleValue() + windowFrame.size.height.doubleValue() - height), new NSSize(windowFrame.size.width.doubleValue(), height) ); window.setFrame_display_animate(NSWindow.frameRectForContentRect_styleMask(frameRect, window.styleMask()), true, window.isVisible()); }
public NSView getAccessoryView(final NSAlert alert) { if(this.hasLocation()) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regions.stream().sorted(Comparator.comparing(Location.Name::toString)).forEach(region -> { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } }); // Override accessory view with location menu added regionPopup.setFrameOrigin(new NSPoint(0, 0)); view.addSubview(regionPopup); inputField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(inputField); return view; } return super.getAccessoryView(alert); }
@Override public void windowWillClose(final NSNotification notification) { cascade = new NSPoint(this.window().frame().origin.x.doubleValue(), this.window().frame().origin.y.doubleValue() + this.window().frame().size.height.doubleValue()); super.windowWillClose(notification); }
@Override public void windowWillClose(final NSNotification notification) { // Convert from lower left to top left coordinates cascade = new NSPoint(this.window().frame().origin.x.doubleValue(), this.window().frame().origin.y.doubleValue() + this.window().frame().size.height.doubleValue()); super.windowWillClose(notification); }
@Override public void windowWillClose(final NSNotification notification) { cascade = new NSPoint(this.window().frame().origin.x.doubleValue(), this.window().frame().origin.y.doubleValue() + this.window().frame().size.height.doubleValue()); super.windowWillClose(notification); }
/** * @param rowIndexes is the list of row numbers that will be participating in the drag. * @return To refuse the drag, return false. To start a drag, return true and place * the drag data onto pboard (data, owner, and so on). * @see NSTableView.DataSource * Invoked by view after it has been determined that a drag should begin, but before the drag has been started. * The drag image and other drag-related information will be set up and provided by the table view once this call * returns with true. */ @Override public boolean tableView_writeRowsWithIndexes_toPasteboard(final NSTableView view, final NSIndexSet rowIndexes, final NSPasteboard pboard) { for(NSUInteger index = rowIndexes.firstIndex(); !index.equals(NSIndexSet.NSNotFound); index = rowIndexes.indexGreaterThanIndex(index)) { pasteboard.add(this.getSource().get(index.intValue())); } NSEvent event = NSApplication.sharedApplication().currentEvent(); if(event != null) { NSPoint dragPosition = view.convertPoint_fromView(event.locationInWindow(), null); NSRect imageRect = new NSRect(new NSPoint(dragPosition.x.doubleValue() - 16, dragPosition.y.doubleValue() - 16), new NSSize(32, 32)); // Writing a promised file of the host as a bookmark file to the clipboard view.dragPromisedFilesOfTypes(NSArray.arrayWithObject("duck"), imageRect, this.id(), true, event); return true; } return false; }
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regionPopup.setFrameOrigin(new NSPoint(0, 0)); for(Location.Name region : regions) { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } } // Override accessory view with location menu added view.addSubview(regionPopup); return view; }
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); confirmField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); confirmField.cell().setPlaceholderString(LocaleFactory.localizedString("Confirm Passphrase", "Cryptomator")); confirmField.setFrameOrigin(new NSPoint(0, 0)); view.addSubview(confirmField); strengthIndicator = NSLevelIndicator.levelIndicatorWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 18)); if(strengthIndicator.respondsToSelector(Foundation.selector("setLevelIndicatorStyle:"))) { strengthIndicator.setLevelIndicatorStyle(NSLevelIndicator.NSDiscreteCapacityLevelIndicatorStyle); } strengthIndicator.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(strengthIndicator); passwordField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); passwordField.cell().setPlaceholderString(LocaleFactory.localizedString("Passphrase", "Cryptomator")); notificationCenter.addObserver(this.id(), Foundation.selector("passwordFieldTextDidChange:"), NSControl.NSControlTextDidChangeNotification, passwordField.id()); passwordField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(passwordField); final NSView accessory = super.getAccessoryView(alert); accessory.setFrameSize(this.getFrame(alert, accessory).size); accessory.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(accessory); return view; }
@Override public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); if(options.keychain) { keychainCheckbox = NSButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 18)); keychainCheckbox.setTitle(LocaleFactory.localizedString("Save Password", "Keychain")); keychainCheckbox.setAction(Foundation.selector("keychainCheckboxClicked:")); keychainCheckbox.setTarget(this.id()); keychainCheckbox.setButtonType(NSButton.NSSwitchButton); keychainCheckbox.setState(options.save ? NSCell.NSOnState : NSCell.NSOffState); keychainCheckbox.sizeToFit(); // Override accessory view with location menu added keychainCheckbox.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue())); view.addSubview(keychainCheckbox); } inputField = NSSecureTextField.textfieldWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 22)); inputField.cell().setPlaceholderString(options.getPasswordPlaceholder()); inputField.setFrameOrigin(new NSPoint(0, this.getFrame(alert, view).size.height.doubleValue() + view.subviews().count().doubleValue() * SUBVIEWS_VERTICAL_SPACE)); view.addSubview(inputField); return view; }