| 1 |
/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ |
| 2 |
|
| 3 |
/* AbiSource Application Framework |
| 4 |
* Copyright (C) 2003 Hubert Figuiere |
| 5 |
* Copyright (C) 2004 Francis James Franklin |
| 6 |
* Copyright (C) 2009 Hubert Figuiere |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU General Public License |
| 10 |
* as published by the Free Software Foundation; either version 2 |
| 11 |
* of the License, or (at your option) any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program; if not, write to the Free Software |
| 20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 |
* 02110-1301 USA. |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifndef XAP_COCOAAPPCONTROLLER_H |
| 25 |
#define XAP_COCOAAPPCONTROLLER_H |
| 26 |
|
| 27 |
#import <Cocoa/Cocoa.h> |
| 28 |
|
| 29 |
#include "xap_CocoaPlugin.h" |
| 30 |
|
| 31 |
class AV_View; |
| 32 |
class XAP_Frame; |
| 33 |
|
| 34 |
@class EV_CocoaMenuDelegate; |
| 35 |
|
| 36 |
@class AP_CocoaPlugin_MenuIDRef; |
| 37 |
|
| 38 |
@interface XAP_CocoaApplication : NSApplication |
| 39 |
{ |
| 40 |
// |
| 41 |
} |
| 42 |
- (void)terminate:(id)sender; |
| 43 |
- (void)orderFrontStandardAboutPanel:(id)sender; |
| 44 |
- (void)orderFrontPreferencesPanel:(id)sender; |
| 45 |
- (void)openContextHelp:(id)sender; |
| 46 |
- (void)sendEvent:(NSEvent *)anEvent; |
| 47 |
@end |
| 48 |
|
| 49 |
enum XAP_CocoaAppMenu_Id |
| 50 |
{ |
| 51 |
XAP_CocoaAppMenu_AbiWord = 0, |
| 52 |
XAP_CocoaAppMenu_File, |
| 53 |
XAP_CocoaAppMenu_Edit, |
| 54 |
XAP_CocoaAppMenu_View, |
| 55 |
XAP_CocoaAppMenu_Insert, |
| 56 |
XAP_CocoaAppMenu_Format, |
| 57 |
XAP_CocoaAppMenu_Tools, |
| 58 |
XAP_CocoaAppMenu_Table, |
| 59 |
XAP_CocoaAppMenu_Window, |
| 60 |
XAP_CocoaAppMenu_Help, |
| 61 |
XAP_CocoaAppMenu_count__ |
| 62 |
}; |
| 63 |
|
| 64 |
@interface XAP_CocoaAppController : NSObject |
| 65 |
{ |
| 66 |
IBOutlet NSMenu * oMenu_AbiWord; |
| 67 |
|
| 68 |
IBOutlet NSMenuItem * oMenuItem_AboutAbiWord; |
| 69 |
IBOutlet NSMenuItem * oMenuItem_Preferences; |
| 70 |
|
| 71 |
IBOutlet NSMenu * oMenu_File; |
| 72 |
IBOutlet NSMenu * oMenu_Edit; |
| 73 |
IBOutlet NSMenu * oMenu_View; |
| 74 |
IBOutlet NSMenu * oMenu_Insert; |
| 75 |
IBOutlet NSMenu * oMenu_Format; |
| 76 |
IBOutlet NSMenu * oMenu_Tools; |
| 77 |
IBOutlet NSMenu * oMenu_Table; |
| 78 |
IBOutlet NSMenu * oMenu_Window; |
| 79 |
IBOutlet NSMenu * oMenu_Help; |
| 80 |
|
| 81 |
IBOutlet NSMenuItem * oMenuItem_File; |
| 82 |
IBOutlet NSMenuItem * oMenuItem_Edit; |
| 83 |
IBOutlet NSMenuItem * oMenuItem_View; |
| 84 |
IBOutlet NSMenuItem * oMenuItem_Insert; |
| 85 |
IBOutlet NSMenuItem * oMenuItem_Format; |
| 86 |
IBOutlet NSMenuItem * oMenuItem_Tools; |
| 87 |
IBOutlet NSMenuItem * oMenuItem_Table; |
| 88 |
IBOutlet NSMenuItem * oMenuItem_Window; |
| 89 |
IBOutlet NSMenuItem * oMenuItem_Help; |
| 90 |
|
| 91 |
IBOutlet NSMenuItem * oMenuItem_AbiWordHelp; |
| 92 |
|
| 93 |
NSMenu * m_PanelMenu; |
| 94 |
NSMenu * m_ContextMenu; |
| 95 |
|
| 96 |
NSMenu * m_AppMenu[XAP_CocoaAppMenu_count__]; |
| 97 |
NSMenuItem * m_AppItem[XAP_CocoaAppMenu_count__]; |
| 98 |
|
| 99 |
NSMutableDictionary * m_MenuIDRefDictionary; |
| 100 |
|
| 101 |
NSMutableArray * m_Plugins; |
| 102 |
NSMutableArray * m_PluginsTools; |
| 103 |
|
| 104 |
NSMenuItem * m_PluginsToolsSeparator; |
| 105 |
|
| 106 |
NSMutableArray * m_FilesRequestedDuringLaunch; |
| 107 |
|
| 108 |
NSMutableArray * m_ToolProviders; |
| 109 |
|
| 110 |
BOOL m_bApplicationLaunching; |
| 111 |
BOOL m_bAutoLoadPluginsAfterLaunch; |
| 112 |
|
| 113 |
AV_View * m_pViewCurrent; |
| 114 |
XAP_Frame * m_pFrameCurrent; |
| 115 |
|
| 116 |
AV_View * m_pViewPrevious; |
| 117 |
XAP_Frame * m_pFramePrevious; |
| 118 |
} |
| 119 |
+ (XAP_CocoaAppController*)sharedAppController; |
| 120 |
|
| 121 |
- (id)init; |
| 122 |
- (void)dealloc; |
| 123 |
|
| 124 |
- (void)setAutoLoadPluginsAfterLaunch:(BOOL)autoLoadPluginsAfterLaunch; |
| 125 |
|
| 126 |
- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key; |
| 127 |
|
| 128 |
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification; |
| 129 |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification; |
| 130 |
|
| 131 |
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; |
| 132 |
- (void)applicationWillTerminate:(NSNotification *)aNotification; |
| 133 |
|
| 134 |
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; |
| 135 |
- (BOOL)application:(NSApplication *)theApplication openTempFile:(NSString *)filename; |
| 136 |
- (BOOL)application:(NSApplication *)theApplication printFile:(NSString *)filename; |
| 137 |
- (BOOL)applicationOpenUntitledFile:(NSApplication *)theApplication; |
| 138 |
- (BOOL)applicationOpenFile:(NSApplication *)theApplication; |
| 139 |
|
| 140 |
- (id)dockFileNew:(id)sender; |
| 141 |
- (id)dockFileOpen:(id)sender; |
| 142 |
|
| 143 |
/* - (NSMenu *)applicationDockMenu:(NSApplication *)sender; */ |
| 144 |
|
| 145 |
/* For building the Application Menu |
| 146 |
*/ |
| 147 |
- (void)setAboutTitle:(NSString *)title; |
| 148 |
- (void)setPrefsTitle:(NSString *)title; |
| 149 |
- (void)setCHelpTitle:(NSString *)title; // context-help |
| 150 |
|
| 151 |
- (void)setTitle:(NSString *)title forMenu:(XAP_CocoaAppMenu_Id)appMenu; |
| 152 |
|
| 153 |
- (const char *)keyEquivalentForMenuID:(int /* XAP_Menu_Id */)menuid modifierMask:(unsigned int *)mask; |
| 154 |
|
| 155 |
- (NSMenu *)panelMenu; |
| 156 |
- (NSMenu *)contextMenu; |
| 157 |
|
| 158 |
- (void)appendPanelItem:(NSMenuItem *)item; |
| 159 |
- (void)appendContextItem:(NSMenuItem *)item; |
| 160 |
- (void)appendItem:(NSMenuItem *)item toMenu:(XAP_CocoaAppMenu_Id)appMenu; |
| 161 |
|
| 162 |
- (void)clearContextMenu; |
| 163 |
- (void)clearMenu:(XAP_CocoaAppMenu_Id)appMenu; // except AbiWord & Windows |
| 164 |
- (void)clearAllMenus; // except AbiWord & Windows |
| 165 |
|
| 166 |
|
| 167 |
- (void)reappendPluginMenuItems; // for use after rebuilding menus - see XAP_CocoaApp::rebuildMenus() |
| 168 |
- (void)appendPluginMenuItem:(NSMenuItem *)menuItem; |
| 169 |
- (void)removePluginMenuItem:(NSMenuItem *)menuItem; |
| 170 |
|
| 171 |
/* Do we need this? getLastFocussedFrame() should be tracking this now... [TODO!!] |
| 172 |
*/ |
| 173 |
- (void)setCurrentView:(AV_View *)view inFrame:(XAP_Frame *)frame; |
| 174 |
- (void)resetCurrentView:(AV_View *)view inFrame:(XAP_Frame *)frame; |
| 175 |
- (void)unsetCurrentView:(AV_View *)view inFrame:(XAP_Frame *)frame; |
| 176 |
|
| 177 |
- (AV_View *)currentView; |
| 178 |
- (XAP_Frame *)currentFrame; |
| 179 |
|
| 180 |
- (AV_View *)previousView; |
| 181 |
- (XAP_Frame *)previousFrame; |
| 182 |
|
| 183 |
- (void)notifyFrameViewChange; // [re/un]setCurrentView call this |
| 184 |
|
| 185 |
/** |
| 186 |
* Load .Abi bundle plugin at path. |
| 187 |
* |
| 188 |
* \return Returns nil on failure. |
| 189 |
*/ |
| 190 |
- (XAP_CocoaPlugin *)loadPlugin:(NSString *)path; |
| 191 |
|
| 192 |
/** |
| 193 |
* \return Returns list of currently loaded plugins. |
| 194 |
*/ |
| 195 |
- (NSArray *)plugins; |
| 196 |
|
| 197 |
/** |
| 198 |
* Checks to see whether the plugins can deactivate, and, if they can, deactivates them. |
| 199 |
* |
| 200 |
* \return Returns false if any of the plugins object. |
| 201 |
*/ |
| 202 |
- (BOOL)deactivateAllPlugins; |
| 203 |
|
| 204 |
/** |
| 205 |
* Checks to see whether the plugins can deactivate, and, if they can, deactivates them. |
| 206 |
* |
| 207 |
* \return Returns false if the plugin objects, unless override is YES. |
| 208 |
*/ |
| 209 |
- (BOOL)deactivatePlugin:(XAP_CocoaPlugin *)plugin overridePlugin:(BOOL)override; |
| 210 |
|
| 211 |
/** |
| 212 |
* This provides a mechanism for associating XAP_CocoaPlugin_MenuItem objects |
| 213 |
* with a given menu ID. |
| 214 |
*/ |
| 215 |
- (void)addRef:(AP_CocoaPlugin_MenuIDRef *)ref forMenuID:(NSNumber *)menuid; |
| 216 |
|
| 217 |
/** |
| 218 |
* This provides a mechanism for finding XAP_CocoaPlugin_MenuItem objects associated |
| 219 |
* with a given menu ID. |
| 220 |
*/ |
| 221 |
- (AP_CocoaPlugin_MenuIDRef *)refForMenuID:(NSNumber *)menuid; |
| 222 |
|
| 223 |
/** |
| 224 |
* This provides a mechanism for removing XAP_CocoaPlugin_MenuItem objects associated |
| 225 |
* with a given menu ID. |
| 226 |
*/ |
| 227 |
- (void)removeRefForMenuID:(NSNumber *)menuid; |
| 228 |
|
| 229 |
/** |
| 230 |
* Get a list of all the tool providers. |
| 231 |
* Each tool provider is of type id <NSObject, XAP_CocoaPlugin_ToolProvider>. |
| 232 |
* |
| 233 |
* \return The tool providers. |
| 234 |
*/ |
| 235 |
- (NSArray *)toolProviders; |
| 236 |
|
| 237 |
/** |
| 238 |
* Find a tool provider by name. |
| 239 |
* (TODO: If plug-ins are registering tool providers, we need to implement a notification |
| 240 |
* system to update toolbar systems.) |
| 241 |
* |
| 242 |
* \param name The name of the tool provider to find. |
| 243 |
* |
| 244 |
* \return The tool provider, or nil if none is registered with the given name. |
| 245 |
*/ |
| 246 |
- (id <NSObject, XAP_CocoaPlugin_ToolProvider>)toolProvider:(NSString *)name; |
| 247 |
|
| 248 |
@end |
| 249 |
|
| 250 |
#endif /* ! XAP_COCOAAPPCONTROLLER_H */ |