1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/compapis/RCS/appapi.h $
4 // $Date: 1997/08/05 13:12:03 $
7 // Specification of generic "Application" interface. App could implement
8 // this. Libraries provide a generic implementation. Generic things common to
9 // all applications, game or not.
15 #if defined(__SC__) || defined(__RCC__)
19 ///////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////////
29 F_DECLARE_INTERFACE(IApplication
);
30 F_DECLARE_INTERFACE(IAppAdviseSink
);
32 ///////////////////////////////////////////////////////////////////////////////
34 // Create a generic application and add it to the global app-object
37 #define GenericApplicationCreate(argc, argv, name, defaultPath) \
39 IUnknown * pAppUnknown = AppGetObj(IUnknown); \
40 _GenericApplicationCreate(IID_TO_REFIID(IID_IApplication), NULL, pAppUnknown, argc, argv, name, defaultPath);\
41 COMRelease(pAppUnknown); \
45 // Creates a generic application, aggregating it with specfied pOuter,
46 // use IAggregate protocol if ppApplication is NULL, else self-init
49 EXTERN tResult LGAPI
_GenericApplicationCreate(REFIID
, IApplication
** ppApplication
, IUnknown
* pOuter
, int argc
, const char *argv
[], const char * pszName
, const char * pszDefaultPath
);
51 ///////////////////////////////////////////////////////////////////////////////
53 // INTERFACE: IApplication
58 #define INTERFACE IApplication
60 DECLARE_INTERFACE_(IApplication
, IUnknown
)
65 DECLARE_UNKNOWN_PURE();
68 // Quit the application (conditional, non-error), return non-zero to not quit
70 STDMETHOD (QueryQuit
)(THIS
) PURE
;
73 // Quit the application (unconditional, non-error)
75 STDMETHOD_(void, Quit
)(THIS
) PURE
;
78 // Quit the application (unconditional, error)
80 STDMETHOD_(void, Abort
)(THIS_
const char * pszReason
) PURE
;
83 // Get/Set application name, as displayed in title bar
85 STDMETHOD_(void, SetCaption
)(THIS_
const char *) PURE
;
86 STDMETHOD_(const char *, GetCaption
)(THIS
) PURE
;
89 // Get/Set default path for file access
91 STDMETHOD_(void, SetDefaultFilePath
)(THIS_
const char *) PURE
;
92 STDMETHOD_(const char *, GetDefaultFilePath
)(THIS
) PURE
;
95 // Get the full path of the application .EXE
96 // i.e., c:\foo\bar.exe
98 STDMETHOD_(const char *, GetFullName
)(THIS
) PURE
;
101 // Get the full path of the application .EXE
104 STDMETHOD_(const char *, GetPath
)(THIS
) PURE
;
107 // Display a message box
109 STDMETHOD_(int, MessageBox
)(THIS_
const char * pszMessage
, const char * pszCaption
, int fFlags
) PURE
;
112 // Advise/Unadvise for sink/holder protocol
114 STDMETHOD (Advise
)(THIS_ IAppAdviseSink
* pSink
, DWORD
* pCookie
) PURE
;
115 STDMETHOD (Unadvise
)(THIS_ DWORD cookie
) PURE
;
120 STDMETHOD_(void, AppCommand
)(THIS_
unsigned nCmdId
) PURE
;
124 ///////////////////////////////////////
126 #define IApplication_QueryInterface(p, a, b) COMQueryInterface(p, a, b)
127 #define IApplication_AddRef(p) COMAddRef(p)
128 #define IApplication_Release(p) COMRelease(p)
129 #define IApplication_QueryQuit(p) COMCall0(p, QueryQuit)
130 #define IApplication_Quit(p) COMCall0(p, Quit)
131 #define IApplication_Abort(p, a) COMCall1(p, Abort, a)
132 #define IApplication_SetCaption(p, a) COMCall1(p, SetCaption, a)
133 #define IApplication_GetCaption(p) COMCall0(p, GetCaption)
134 #define IApplication_SetDefaultFilePath(p, a) COMCall1(p, SetDefaultFilePath, a)
135 #define IApplication_GetDefaultFilePath(p) COMCall0(p, GetDefaultFilePath)
136 #define IApplication_GetFullName(p) COMCall0(p, GetFullName)
137 #define IApplication_GetPath(p) COMCall0(p, GetPath)
138 #define IApplication_MessageBox(p, a, b, c) COMCall3(p, MessageBox, a, b, c)
139 #define IApplication_Advise(p, a, b) COMAdvise(p, a, b)
140 #define IApplication_Unadvise(p, a) COMUnadvise(p, a)
142 ///////////////////////////////////////////////////////////////////////////////
144 // INTERFACE: IAppAdviseSink
148 #define kVerAppAdvise 2
150 // Original interface
151 #define kVerAppAdvise_Original 1
154 #define kVerAppAdvise_CommandSupport 2
156 ///////////////////////////////////////
159 #define INTERFACE IAppAdviseSink
161 DECLARE_INTERFACE_(IAppAdviseSink
, IUnknown
)
166 DECLARE_UNKNOWN_PURE();
169 // This is called to determine the revision of the sink interface
171 STDMETHOD_(short, GetVersion
)(THIS
) PURE
;
174 // This is called when the application exits (return non-zero to block)
176 STDMETHOD (OnQueryQuit
)(THIS
) PURE
;
179 // This is called when the application exits
181 STDMETHOD_(void, OnQuit
)(THIS
) PURE
;
184 // This is called when making an emergency exit
186 STDMETHOD_(void, OnCriticalError
)(THIS_
int errorCode
) PURE
;
189 // This is called when a command is issued (menus, for example)
191 STDMETHOD_(void, OnCommand
)(THIS_
unsigned nCmdId
) PURE
;
194 ///////////////////////////////////////
196 #define IAppAdviseSink_QueryInterface(p, a, b) COMQueryInterface(p, a, b)
197 #define IAppAdviseSink_AddRef(p) COMAddRef(p)
198 #define IAppAdviseSink_Release(p) COMRelease(p)
199 #define IAppAdviseSink_GetVersion(p) COMCall0(p, GetVersion)
200 #define IAppAdviseSink_OnQueryQuit(p) COMCall0(p, OnQueryQuit)
201 #define IAppAdviseSink_OnQuit(p) COMCall0(p, OnQuit)
202 #define IAppAdviseSink_OnCriticalError(p, a) COMCall1(p, OnCriticalError, a)
204 ///////////////////////////////////////////////////////////////////////////////
206 #endif /* __APPAPI_H */