forked from cocoabits/MASPreferences
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMASPreferencesWindowController.h
More file actions
120 lines (101 loc) · 3.58 KB
/
Copy pathMASPreferencesWindowController.h
File metadata and controls
120 lines (101 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//
// You create an application Preferences window using code like this:
// _preferencesWindowController = [[MASPreferencesWindowController alloc] initWithViewControllers:controllers title:title]
//
// To open the Preferences window:
// [_preferencesWindowController showWindow:sender]
//
#import <AppKit/AppKit.h>
@protocol MASPreferencesViewController;
NS_ASSUME_NONNULL_BEGIN
/*!
* Notification posted when you switch selected panel in Preferences.
*/
extern NSString * const kMASPreferencesWindowControllerDidChangeViewNotification;
/*!
* Window controller for managing Preference view controllers.
*/
__attribute__((__visibility__("default")))
@interface MASPreferencesWindowController : NSWindowController <NSToolbarDelegate, NSWindowDelegate>
{
@private
NSMutableArray *_viewControllers;
NSMutableDictionary *_minimumViewRects;
NSString *_title;
NSViewController <MASPreferencesViewController> *_selectedViewController;
NSToolbar * __unsafe_unretained _toolbar;
}
/*!
* Child view controllers in the Preferences window.
*/
@property (nonatomic, readonly) NSMutableArray *viewControllers;
/*!
* Index of selected panel in the Preferences window.
*/
@property (nonatomic, readonly) NSUInteger indexOfSelectedController;
/*!
* View controller representing selected panel in the Preferences window.
*/
@property (nonatomic, readonly) NSViewController <MASPreferencesViewController> *selectedViewController;
/*!
* Optional window title provided in the initializer.
*/
@property (nonatomic, copy, readonly, nullable) NSString *title;
/*!
* The toolbar managed by the Preferences window.
*/
@property (nonatomic, unsafe_unretained) IBOutlet NSToolbar *toolbar;
/*!
* Creates new a window controller for Preferences with custom title.
*
* @param viewControllers Non-empty list of view controllers representing Preference panels.
* @param title Optional title for the Preferneces window. Pass `nil` to show the title provided by selected view controller.
*
* @return A new controller with the given title.
*/
- (instancetype)initWithViewControllers:(NSArray *)viewControllers title:(NSString * _Nullable)title;
- (instancetype)init __attribute((unavailable("Please use initWithViewControllers:title:")));
/*!
* Creates new a window controller for Preferences with a flexible title.
*
* @param viewControllers Non-empty list of view controllers representing Preference panels.
*
* @return A new controller with title depending on selected view controller.
*/
- (instancetype)initWithViewControllers:(NSArray *)viewControllers;
/*!
* Appends new panel to the Preferences window.
*
* @param viewController View controller representing new panel.
*/
- (void)addViewController:(NSViewController <MASPreferencesViewController> *)viewController;
/*!
* Changes selection in the Preferences toolbar.
*
* @param controllerIndex Position of the new panel to select in the toolbar.
*/
- (void)selectControllerAtIndex:(NSUInteger)controllerIndex;
/*!
* Changes selection in the Preferences toolbar using panel identifier.
*
* @param identifier String identifier of the view controller to select.
*/
- (void)selectControllerWithIdentifier:(NSString *)identifier;
/*!
* Useful action for switching to the next panel.
*
* For example, you may connect it to the main menu.
*
* @param sender Menu or toolbar item.
*/
- (IBAction)goNextTab:(id _Nullable)sender;
/*!
* Useful action for switching to the previous panel.
*
* For example, you may connect it to the main menu.
*
* @param sender Menu or toolbar item.
*/
- (IBAction)goPreviousTab:(id _Nullable)sender;
@end
NS_ASSUME_NONNULL_END