PTToolGroupManager


@interface PTToolGroupManager : NSObject <NSCoding, PTOverridable>

The PTToolGroupManager class maintains a list of tool groups, represented by instances of the PTToolGroup class, each of which contain a set of available tools for that mode.

This class is designed to work in conjuction with the PTToolGroupToolbar class to display the tool groups and provide interactive control over the current tool.

  • Initializes a newly created PTToolGroupManager instance.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()

    Return Value

    an initialized PTToolGroupManager instance

  • Returns an object initialized from data in a given unarchiver.

    Declaration

    Objective-C

    - (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder;

    Swift

    init?(coder: NSCoder)

    Parameters

    coder

    An unarchiver object

    Return Value

    self, initialized using the data in decoder, or nil if the object could not be initialized

  • Initializes a newly created PTToolGroupManager instance with the provided tool manager.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithToolManager:
        (nonnull PTToolManager *)toolManager;

    Swift

    convenience init(toolManager: PTToolManager)

    Parameters

    toolManager

    The tool manager to be used by the receiver

    Return Value

    an initialized PTToolGroupManager instance

  • The receiver uses this tool manager instance to manage the current tool and observes notifications posted by the tool manager.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) PTToolManager *toolManager;

    Swift

    var toolManager: PTToolManager? { get set }
  • The tool group manager’s delegate object.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<PTToolGroupManagerDelegate> delegate;

    Swift

    weak var delegate: (any PTToolGroupManagerDelegate)? { get set }
  • Whether this tool group manager is currently enabled. The receiver will not observe notifications posted by its toolManager when this property’s value is NO.

    The default value of this property is NO.

    Declaration

    Objective-C

    @property (nonatomic, getter=isEnabled) BOOL enabled;

    Swift

    var isEnabled: Bool { get set }
  • The list of tool groups managed by this tool group manager. Each tool group represents an “tool group”, each with their own set of available tools to be displayed.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSArray<PTToolGroup *> *_Nonnull groups;

    Swift

    var groups: [PTToolGroup] { get set }
  • Adds the specified PTToolGroup instances to the end of the list of tool groups in groups. If the tool group is already in groups then this method does nothing.

    Declaration

    Objective-C

    - (void)addToolGroup:(nonnull PTToolGroup *)toolGroup;

    Swift

    func add(_ toolGroup: PTToolGroup)

    Parameters

    toolGroup

    the tool group to add

  • Inserts the given PTToolGroup instance at the specified index in the list of tool groups in groups. If the tool group is already in groups then this method does nothing.

    Declaration

    Objective-C

    - (void)insertToolGroup:(nonnull PTToolGroup *)toolGroup
                    atIndex:(NSUInteger)index;

    Swift

    func insert(_ toolGroup: PTToolGroup, at index: UInt)

    Parameters

    toolGroup

    the tool group to insert

    index

    the index at which to insert the tool group in groups

  • Removes the specified PTToolGroup instances from the list of tool groups in groups. If the tool group is not in groups then this method does nothing.

    Declaration

    Objective-C

    - (void)removeToolGroup:(nonnull PTToolGroup *)toolGroup;

    Swift

    func remove(_ toolGroup: PTToolGroup)

    Parameters

    toolGroup

    the tool group to remove

  • Removes the tool group in groups at the specified index.

    Declaration

    Objective-C

    - (void)removeToolGroupAtIndex:(NSUInteger)index;

    Swift

    func removeToolGroup(at index: UInt)

    Parameters

    index

    the index in groups of the tool group to remove

  • The currently selected tool group in groups.

    When the groups list is empty, the value of this property is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) PTToolGroup *selectedGroup;

    Swift

    var selectedGroup: PTToolGroup? { get set }
  • The index of the currently selected tool group in groups.

    When the groups list is empty, the value of this property is NSNotFound.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger selectedGroupIndex;

    Swift

    var selectedGroupIndex: UInt { get set }
  • The feature ID of the currently selected tool group in groups.

    When the groups list is empty, the value of this property is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *selectedGroupFeatureID;

    Swift

    var selectedGroupFeatureID: String? { get set }
  • The “View” tool group.

    This group does not contain any tools.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull viewItemGroup;

    Swift

    var viewItemGroup: PTToolGroup { get }
  • The “Annotate” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull annotateItemGroup;

    Swift

    var annotateItemGroup: PTToolGroup { get }
  • The “Draw” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull drawItemGroup;

    Swift

    var drawItemGroup: PTToolGroup { get }
  • The “Fill And Sign” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull fillAndSignItemGroup;

    Swift

    var fillAndSignItemGroup: PTToolGroup { get }
  • The “Prepare Form” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull prepareFormItemGroup;

    Swift

    var prepareFormItemGroup: PTToolGroup { get }
  • The “Insert” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull insertItemGroup;

    Swift

    var insertItemGroup: PTToolGroup { get }
  • The “Measure” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull measureItemGroup;

    Swift

    var measureItemGroup: PTToolGroup { get }
  • The “Pens” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull pensItemGroup;

    Swift

    var pensItemGroup: PTToolGroup { get }
  • The “Redact” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull redactItemGroup;

    Swift

    var redactItemGroup: PTToolGroup { get }
  • The “Favorites” tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTToolGroup *_Nonnull favoritesItemGroup;

    Swift

    var favoritesItemGroup: PTToolGroup { get }
  • Creates a new item for the specified PTTool subclass. The item is not part of any group and must be added to an existing or new group in order to be used.

    Declaration

    Objective-C

    - (nonnull UIBarButtonItem *)createItemForToolClass:(nonnull Class)toolClass;

    Swift

    func createItem(forToolClass toolClass: AnyClass) -> UIBarButtonItem

    Parameters

    toolClass

    the PTTool subclass to be associated with the created item

    Return Value

    a new item for the specified PTTool subclass

  • The undo manager currently being tracked by the tool group manager.

    When the toolManager‘s tool is a PTCreateToolBase subclass and returns YES from PTCreateToolBase.undoManagerEnabled then this property will be equal to toolManager.tool.undoManager. Otherwise, toolManager.undoManager will be returned.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly, nullable) NSUndoManager *undoManager;

    Swift

    weak var undoManager: UndoManager? { get }
  • The undo button item. When activated, this item calls -undo:.

    This bar button item’s UIBarButtonItem.enabled property is automatically updated to reflect the current value of undoManager.canUndo.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIBarButtonItem *_Nonnull undoButtonItem;

    Swift

    var undoButtonItem: UIBarButtonItem { get }
  • This method calls [undoManager undo] on the tool group manager’s undoManager property.

    Declaration

    Objective-C

    - (void)undo:(nullable id)sender;

    Swift

    func undo(_ sender: Any?)
  • The redo button item. When activated, this item calls -redo:.

    This bar button item’s UIBarButtonItem.enabled property is automatically updated to reflect the current value of undoManager.canRedo.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIBarButtonItem *_Nonnull redoButtonItem;

    Swift

    var redoButtonItem: UIBarButtonItem { get }
  • This method calls [undoManager redo] on the tool group manager’s undoManager property.

    Declaration

    Objective-C

    - (void)redo:(nullable id)sender;

    Swift

    func redo(_ sender: Any?)
  • Updates the state of the undoButtonItem and redoButtonItem bar button items.

    Declaration

    Objective-C

    - (void)updateUndoRedoItems;

    Swift

    func updateUndoRedoItems()
  • Whether editing of groups from the user interface is enabled. When enabled, the editGroupButtonItem item is displayed at the end of all tool groups, except for the favoritesItemGroup, in the user interface.

    If this property is set to NO and editing is disabled, then the editGroupButtonItem item will not be displayed in the user interface.

    The default value of this property is YES.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isEditingEnabled) BOOL editingEnabled;

    Swift

    var isEditingEnabled: Bool { get set }
  • The “Edit Items” button item. This item is to be shown at the end of all tool item groups, except for the favoritesItemGroup, when the editingEnabled property is set to YES.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIBarButtonItem *_Nonnull editGroupButtonItem;

    Swift

    var editGroupButtonItem: UIBarButtonItem { get }
  • This method asks the tool group manager’s delegate to edit the currently selected tool group in the selectedGroup property via the -[PTToolGroupManagerDelegate toolGroupManager:editItemsForGroup:] delegate method.

    If the selectedGroup property is nil then this method does nothing.

    Declaration

    Objective-C

    - (void)editSelectedGroup:(nonnull id)sender;

    Swift

    func editSelectedGroup(_ sender: Any)
  • The “Apply redact” button item. This item is to be shown at the first of redact tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIBarButtonItem *_Nonnull applyRedactButtonItem;

    Swift

    var applyRedactButtonItem: UIBarButtonItem { get }
  • The “Add pages” button item. This item is to be shown at the last of insert tool group.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIBarButtonItem *_Nonnull addPagesButtonItem;

    Swift

    var addPagesButtonItem: UIBarButtonItem { get }
  • Save the current set of tool groups in groups and the selected group to disk at the location specified by the PTToolGroupManager.savedGroupsURL class property.

    Declaration

    Objective-C

    - (void)saveGroups;

    Swift

    func saveGroups()
  • Save the current set of tool groups in groups and the selected group to disk at the specified location.

    Declaration

    Objective-C

    - (void)saveGroupsToURL:(nonnull NSURL *)savedGroupsURL;

    Swift

    func saveGroups(to savedGroupsURL: URL)

    Parameters

    savedGroupsURL

    The URL of the location at which to save the groups

  • Restore the set of tool groups and selected group from disk at the location specified by the PTToolGroupManager.savedGroupsURL class property.

    Declaration

    Objective-C

    - (void)restoreGroups;

    Swift

    func restoreGroups()
  • Restore the set of tool groups and selected group from disk at the specified location.

    Declaration

    Objective-C

    - (void)restoreGroupsFromURL:(nonnull NSURL *)savedGroupsURL;

    Swift

    func restoreGroups(from savedGroupsURL: URL)

    Parameters

    savedGroupsURL

    The URL of the location from which to restore the groups

  • The URL of the location at which to save and restore the set of tool groups and selected group.

    The default value of this property is the URL of a .plist file inside the directory returned by PTToolsUtil.toolsResourcesDirectoryURL.

    Declaration

    Objective-C

    @property (class, nonatomic, strong, readonly) NSURL *_Nonnull savedGroupsURL;

    Swift

    class var savedGroupsURL: URL { get }