Skip to content

Commit

Permalink
Add mapping for NSPopover.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 22, 2024
1 parent 5685d53 commit 49aae12
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 0 deletions.
120 changes: 120 additions & 0 deletions binding/src/main/java/ch/cyberduck/binding/application/NSPopover.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package ch.cyberduck.binding.application;

/*
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved.
* https://cyberduck.io/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

import org.rococoa.ID;
import org.rococoa.ObjCClass;
import org.rococoa.cocoa.foundation.NSRect;

/**
* A means to display additional content related to existing content on the screen.
*/
public abstract class NSPopover extends NSResponder {
private static final NSPopover._Class CLASS = org.rococoa.Rococoa.createClass("NSPopover", NSPopover._Class.class);

public interface _Class extends ObjCClass {
NSPopover alloc();
}

public abstract NSPopover init();

public static NSPopover create() {
return CLASS.alloc().init();
}

/**
* Your application assumes responsibility for closing the popover. AppKit will still close the popover in a
* limited number of circumstances. For instance, AppKit will attempt to close the popover when the window of
* its positioningView is closed. The exact interactions in which AppKit will close the popover are not guaranteed.
* You may consider implementing -cancel: to close the popover when the escape key is pressed.
*/
public static final int NSPopoverBehaviorApplicationDefined = 0;

/**
* AppKit will close the popover when the user interacts with a user interface element outside the popover.
* Note that interacting with menus or panels that become key only when needed will not cause a transient
* popover to close. The exact interactions that will cause transient popovers to close are not specified.
*/
public static final int NSPopoverBehaviorTransient = 1;

/**
* AppKit will close the popover when the user interacts with user interface elements in the window containing
* the popover's positioning view. Semi-transient popovers cannot be shown relative to views in other popovers,
* nor can they be shown relative to views in child windows. The exact interactions that cause semi-transient
* popovers to close are not specified.
*/
public static final int NSPopoverBehaviorSemitransient = 2;

/**
* Specifies the behavior of the popover.
*
* @param behavior The default value is NSPopoverBehaviorApplicationDefined. See NSPopoverBehavior for possible value.
*/
public abstract void setBehavior(int behavior);

/**
* You must set the content view controller of the popover before the popover is shown. Changes to the
* popover's content view controller while the popover is shown will cause the popover to animate if the animates property is YES.
*
* @param controller The view controller that manages the content of the popover.
*/
public abstract void setContentViewController(NSViewController controller);

/**
* Shows the popover anchored to the specified view.
* <p>
* This method raises NSInternalInconsistencyException if contentViewController or the view controller’s view is nil.
* If the popover is already being shown, this method updates the anchored view, rectangle, and preferred edge. If the
* positioning view is not visible, this method does nothing.
*
* @param positioningRect The rectangle within positioningView relative to which the popover should be positioned. Normally
* set to the bounds of positioningView. May be an empty rectangle, which will default to the bounds of positioningView.
* @param positioningView The view relative to which the popover should be positioned. Causes the method to raise NSInvalidArgumentException if nil.
* @param preferredEdge The edge of positioningView the popover should prefer to be anchored to.
*/
public abstract void showRelativeToRect_ofView_preferredEdge(NSRect positioningRect, NSView positioningView, int preferredEdge);

/**
* Shows the popover anchored to the specified toolbar item.
* <p>
* Use this method to display a popover relative to a toolbar item. When the item is in the overflow menu,
* the popover presents itself from another appropriate affordance in the window. ¨
* See showRelativeToRect:ofView:preferredEdge: for popover behavior.
* <p>
* This method raises an NSInvalidArgumentException if it can’t locate the toolbar item. This could
* occur if the item isn’t in a toolbar, or because the toolbar isn’t in the window.
* <p>
* C
*
* @param toolbarItem The toolbar item anchoring the popover.
*/
public abstract void showRelativeToToolbarItem(NSToolbarItem toolbarItem);

/**
* Attempts to close the popover.
* <p>
* The popover will not be closed if it has a delegate and the delegate implements the returns popoverShouldClose: method
* returning NO, or if a subclass of the NSPopover class implements popoverShouldClose: and returns NO).
* <p>
* The operation will fail if the popover is displaying a nested popover or if it has a child window. A window will
* attempt to close its popovers when it receives a performClose: message.
* <p>
* The popover animates out when closed unless the animates property is set to NO.
*
* @param sender The sender of the action message.
*/
public abstract void performClose(ID sender);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package ch.cyberduck.binding.application;

/*
* Copyright (c) 2002-2024 iterate GmbH. All rights reserved.
* https://cyberduck.io/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

import ch.cyberduck.binding.foundation.NSBundle;

import org.rococoa.ObjCClass;

public abstract class NSViewController extends NSResponder {
private static final NSViewController._Class CLASS = org.rococoa.Rococoa.createClass("NSViewController", NSViewController._Class.class);

public interface _Class extends ObjCClass {
NSViewController alloc();
}

public static NSViewController create() {
return CLASS.alloc();
}

public static NSViewController create(String nib, NSBundle bundle) {
return CLASS.alloc().initWithNibName_bundle(nib, bundle);
}

/**
* The NSViewController object looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory.
* <p>
* The specified nib file should typically have the class of the file's owner set to NSViewController, or a custom subclass, with the view outlet connected to a view.
* <p>
* If you pass in nil for nibNameOrNil, nibName returns nil and loadView throws an exception; in this case you must set view before view is invoked, or override loadView.
*
* @param nib The name of the nib file, without any leading path information.
* @param bundle The bundle in which to search for the nib file. If you specify nil, this method looks for the nib file in the main bundle.
* @return Returns a view controller object initialized to the nib file in the specified bundle.
*/
public abstract NSViewController initWithNibName_bundle(String nib, NSBundle bundle);

/**
* If this property’s value is not already set when you access it, the view controller invokes the loadView method. That method, in turn, sets the view from the nib file identified by the view controller’s nibName and nibBundle properties.
* <p>
* If you want to set a view controller’s view directly, set this property’s value immediately after creating the view controller.
*
* @param view The view controller’s primary view.
*/
public abstract void setView(NSView view);
}

0 comments on commit 49aae12

Please sign in to comment.