//************************************************************************************** // Filename: NibModalDialog.h // Part of Contextual Menu Workshop by Abracode Inc. // http://free.abracode.com/cmworkshop/ // Copyright © 2002-2003 Abracode, Inc. All rights reserved. // // Description: A dialog created from nib resources // //************************************************************************************** // Revision History: // Saturday, June 7, 2003 - Original //************************************************************************************** #pragma once #if defined(__MACH__) #import #else #include #endif //defined(__MACH__) const HICommand kNullHICommand = { 0, 0, {NULL, 0 } }; class NibModalDialog { public: NibModalDialog(CFStringRef inNibName, CFStringRef inDlogWindowName); NibModalDialog(CFBundleRef inBundleRef, CFStringRef inNibName, CFStringRef inDlogWindowName); virtual ~NibModalDialog(); virtual void Run(); virtual void Initialize(); virtual void InstallEventHandler(); virtual OSStatus HandleEvent(EventHandlerCallRef inCallRef, EventRef inEvent); virtual OSStatus ProcessCommand(); virtual Boolean CommandShouldQuitDialog(); void DisposeDialog(); static pascal OSStatus DialogEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ); WindowRef GetWindow() { return mWindow; } void GetLastCommand( HICommand &outCommand ) const { outCommand = mCommand; } UInt32 GetLastCommandID() const { return mCommand.commandID; } Boolean WasDialogOkeyed() const { return (mCommand.commandID == kHICommandOK); } Boolean WasDialogCanceled() const { return (mCommand.commandID == kHICommandCancel); } ControlRef GetControlByID(const ControlID &inControlID); protected: WindowRef mWindow; EventHandlerUPP mDlgEventHandlerUPP; HICommand mCommand; Boolean mIsRunning; private: NibModalDialog(const NibModalDialog&); NibModalDialog& operator=(const NibModalDialog&); };