home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 11 / PC World Interactive 11.iso / share / multimed / effect / Common Files / WinFramework.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-17  |  7.4 KB  |  197 lines

  1. //////////
  2. //
  3. //    File:        WinFramework.h
  4. //
  5. //    Contains:    Support for playing QuickTime VR movies in a Windows application.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based (heavily!) on MDIPlayer sample code by Brian S. Friedkin (Aug 5, 1996).
  9. //
  10. //    Copyright:    ⌐ 1996-1997 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //    Change History (most recent first):
  13. //
  14. //       <1>         07/03/96    rtm        first file; revised to personal coding style;
  15. //                                    renamed numerous types and parameters to mirror VRShell on MacOS
  16. //       
  17. //////////
  18.  
  19. #pragma once
  20.  
  21. #ifndef __MOVIES__
  22. #include <Movies.h>
  23. #endif
  24.  
  25. #ifndef __QTML__
  26. #include <QTML.h>
  27. #endif
  28.  
  29. #ifndef __RESOURCES__
  30. #include <Resources.h>
  31. #endif
  32.  
  33. #ifndef __QUICKTIMEVR__
  34. #include <QuickTimeVR.h>
  35. #endif
  36.  
  37. #ifndef __QTUtilities__
  38. #include "QTUtilities.h"
  39. #endif
  40.  
  41. #ifndef __QTVRUtilities__
  42. #include "QTVRUtilities.h"
  43. #endif
  44.  
  45. #ifndef __Prefix_File__
  46. #include <WinPrefix.h>
  47. #endif
  48.  
  49. #include <windows.h>
  50.  
  51. #include <Sound.h>
  52. #include <Scrap.h>
  53. #include <TextUtils.h>
  54.  
  55. //////////
  56. // constants
  57. //////////
  58.  
  59. #define    WM_PUMPMOVIE                (WM_USER+0)
  60. #define    WM_OPENDROPPEDFILES            (WM_USER+1)
  61. #define USEEXPLORERSTYLE            (LOBYTE(LOWORD(GetVersion()))>=4)
  62. #define kOpenDialogCustomData        11                        // an arbitrary value that allows our dialog proc to detect the Open File dialog box
  63. #define kAlertMessageMaxLength        256                        // maximum length of a message in the DoCautionAlert message box
  64.  
  65. // items in Save Changes dialog box
  66. #define kSaveChanges                IDYES                    // save the changes before closing window
  67. #define kCancelClose                IDCANCEL                // no, don't close the window or save changes
  68. #define kDontSaveChanges            IDNO                    // discard any unsaved changes
  69.  
  70. // constants for standard modal dialog filter proc
  71. #define kMyButtonDelay                8
  72. #define kReturnKey                    (char)0x0D    
  73. #define kEnterKey                    (char)0x03    
  74. #define kEscapeKey                    (char)0x1B    
  75. #define kPeriod                        '.'
  76.  
  77. // constants for selecting InitApplication phase
  78. enum {
  79.     kInitAppPhase_BeforeCreateFrameWindow     = 1L << 0,        // MDI frame window windows not yet created
  80.     kInitAppPhase_AfterCreateFrameWindow    = 1L << 1,        // MDI frame window windows already created
  81.     kInitAppPhase_BothPhases                = kInitAppPhase_BeforeCreateFrameWindow | kInitAppPhase_AfterCreateFrameWindow
  82. };
  83.  
  84. // constants for selecting StopApplication phase
  85. enum {
  86.     kStopAppPhase_BeforeDestroyWindows         = 1 << 0,        // movie windows not yet torn down
  87.     kStopAppPhase_AfterDestroyWindows        = 1    << 1,        // movie windows already torn down
  88.     kStopAppPhase_BothPhases                = kStopAppPhase_BeforeDestroyWindows | kStopAppPhase_AfterDestroyWindows
  89. };
  90.  
  91. // parameters to the SetMenuItemState function
  92. #define kEnableMenuItem                MF_ENABLED
  93. #define kDisableMenuItem            MF_GRAYED
  94.  
  95. //////////
  96. // macros
  97. //////////
  98.  
  99. // macros for converting Mac menu ID/menu item pairs into a single "menu item identifier"
  100. #define MENU_IDENTIFIER(menuID,menuItem)    ((menuID<<8)+(menuItem))
  101. #define MENU_ID(menuIdentifier)                ((menuIdentifier&0xff00)>>8)
  102. #define MENU_ITEM(menuIdentifier)            ((menuIdentifier&0x00ff))
  103.  
  104.  
  105. //////////
  106. // data types
  107. //////////
  108.  
  109. typedef HMENU                MenuReference;
  110. typedef HWND                WindowReference;
  111.  
  112.  
  113. //////////
  114. // structures
  115. //////////
  116.  
  117. // WindowObjectRecord is a data structure attached to a movie window.
  118. // We use this structure to associate data with any window presented.
  119.  
  120. typedef struct {
  121.     WindowReference            fWindow;            // the window
  122.     Movie                    fMovie;                // the main movie (QT or QTVR)
  123.     MovieController         fController;        // the movie controller for this window
  124.     FSSpec                    fFileFSSpec;        // location of the movie file
  125.     short                    fFileResID;
  126.     short                    fFileRefNum;
  127.     Boolean                    fCanResizeWindow;    // can the window be resized?
  128.     Boolean                    fDirty;                // has the movie data changed since the last save?
  129.     QTVRInstance            fInstance;            // the QTVRInstance
  130.     Handle                    fAppData;            // a handle to application-specific window data
  131. } WindowObjectRecord, *WindowObjectPtr, **WindowObject;
  132.  
  133.  
  134. //////////
  135. // function prototypes
  136. //////////
  137.  
  138. LRESULT CALLBACK             FrameWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam);
  139. LRESULT CALLBACK             MovieWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam);
  140. BOOL                        GetFile (char *theFileName);
  141. int                            AdjustMenus (HWND theWnd, HMENU theMenu);
  142. void                        QuitFramework (void);
  143.  
  144. MovieController                SetupMovieWindowWithController (Movie theMovie, HWND theWindow);
  145. void                        DoOpenCommandLineMovies (LPSTR theCmdLine);
  146. BOOL                        DoCreateMovieWindow (Movie theMovie, FSSpec *theFSSpec);
  147. static void                    DoSaveMovie (HWND theWnd);
  148. static void                    DoCut (HWND theWnd);
  149. static void                    DoCopy (HWND theWnd);
  150. static void                    DoPaste (HWND theWnd);
  151. static void                    DoClear (HWND theWnd);
  152. static void                    DoUndo (HWND theWnd);
  153. static void                    GetDisplayName (char *thePathName, char *theFileName);
  154.  
  155. void                        SizeWindowToMovie (WindowObject theWindowObject);
  156. static void                    ShowAboutBox (void);
  157. int                            DoCautionAlert (HWND theWnd, UINT theID, UINT theIconStyle, UINT theButtonStyle, LPSTR theTitle, LPSTR theArgument);
  158. static UINT APIENTRY        DialogProc (HWND theDialog, UINT theMessage, WPARAM wParam, LPARAM lParam);
  159. static void                    CalcWindowMinMaxInfo (HWND theWnd, LPMINMAXINFO lpMinMax);
  160.  
  161. WindowReference                GetFrontMovieWindow (void);
  162. WindowReference                GetNextMovieWindow (WindowReference theWindow);
  163. WindowObject                GetWindowObjectFromFrontWindow (void);
  164. WindowObject                GetWindowObjectFromWindow (HWND theWnd);
  165. MovieController              GetMCFromFrontWindow (void);
  166. MovieController                GetMCFromWindow (WindowReference theWindow);
  167. QTVRInstance                GetQTVRInstanceFromFrontWindow (void);
  168. Handle                        GetAppDataFromFrontWindow (void);
  169. Handle                        GetAppDataFromWindow (HWND theWnd);
  170. Handle                        GetAppDataFromWindowObject (WindowObject theWindowObject);
  171. Boolean                     IsWindowObjectOurs (WindowObject theWindowObject);
  172. void                        DoBeep (void);
  173. void                        SetMenuState (MenuReference theMenu, UInt16 theMenuRank, short theState);
  174. void                        SetMenuItemState (MenuReference theMenu, UInt16 theMenuItem, short theState);
  175. void                        SetMenuItemLabel (MenuReference theMenu, UInt16 theMenuItem, char *theText);
  176. void                        SetMenuItemCheck (MenuReference theMenu, UInt16 theMenuItem, Boolean theState);
  177. GrafPtr                        GetPortFromWindowReference (WindowReference theWindow);
  178. WindowReference                GetWindowReferenceFromPort (GrafPtr thePort);
  179. short                        GetWindowWidth (WindowReference theWindow);
  180.  
  181.  
  182. // application-specific functions
  183. // These are defined in the ComApplication.c file;
  184. // you could override these to change the behavior of the function in a specific application.
  185. void                        InitApplication (UInt32 theStartPhase);
  186. void                        StopApplication (UInt32 theStopPhase);
  187. void                        DoIdle (WindowReference theWindow);
  188. void                        DoUpdateWindow (WindowReference theWindow, Rect *theRefrehArea);
  189. void                         HandleContentClick (WindowReference theWindow, EventRecord *theEvent);
  190. Boolean                        HandleApplicationKeyPress (char theCharCode);
  191. void                         HandleApplicationMenu (UInt16 theMenuItem);
  192. void                        AdjustApplicationMenus (WindowReference theWindow, MenuReference theMenu);
  193. Boolean                        DoApplicationEventLoopAction (EventRecord *theEvent);
  194. void                        AddControllerFunctionality (MovieController theMC);
  195. void                        InitApplicationWindowObject (WindowObject theWindowObject);
  196. void                        RemoveApplicationWindowObject (WindowObject theWindowObject);
  197. PASCAL_RTN Boolean             ApplicationMCActionFilterProc (MovieController theMC, short theAction, void *theParams, long theRefCon);