home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / winctrl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-16  |  9.7 KB  |  221 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11.  
  12. // Video control interface base classes, December 1995
  13.  
  14. #ifndef __WINCTRL__
  15. #define __WINCTRL__
  16.  
  17. #define ABSOL(x) (x < 0 ? -x : x)
  18. #define NEGAT(x) (x > 0 ? -x : x)
  19.  
  20. class CBaseControlWindow : public CBaseVideoWindow, public CBaseWindow
  21. {
  22. protected:
  23.  
  24.     CBaseFilter *m_pFilter;            // Pointer to owning media filter
  25.     CBasePin *m_pPin;                  // Controls media types for connection
  26.     CCritSec *m_pInterfaceLock;        // Externally defined critical section
  27.     COLORREF m_BorderColour;           // Current window border colour
  28.     BOOL m_bAutoShow;                  // What happens when the state changes
  29.     HWND m_hwndOwner;                  // Owner window that we optionally have
  30.     HWND m_hwndDrain;                  // HWND to post any messages received
  31.     BOOL m_bCursorHidden;               // Should we hide the window cursor
  32.  
  33. public:
  34.  
  35.     // Internal methods for other objects to get information out
  36.  
  37.     HRESULT DoSetWindowStyle(long Style,long WindowLong);
  38.     HRESULT DoGetWindowStyle(long *pStyle,long WindowLong);
  39.     BOOL IsAutoShowEnabled() { return m_bAutoShow; };
  40.     COLORREF GetBorderColour() { return m_BorderColour; };
  41.     HWND GetOwnerWindow() { return m_hwndOwner; };
  42.     BOOL IsCursorHidden() { return m_bCursorHidden; };
  43.  
  44.     // Override message loop to route owner messages
  45.  
  46.     HRESULT MessageLoop();
  47.     BOOL RerouteIfOwned(PMSG pMessage);
  48.  
  49.     // Derived classes must call this to set the pin the filter is using
  50.     // We don't have the pin passed in to the constructor (as we do with
  51.     // the CBaseFilter object) because filters typically create the
  52.     // pins dynamically when requested in CBaseFilter::GetPin. This can
  53.     // not be called from our constructor because is is a virtual method
  54.  
  55.     void SetControlWindowPin(CBasePin *pPin) {
  56.         m_pPin = pPin;
  57.     }
  58.  
  59. public:
  60.  
  61.     CBaseControlWindow(CBaseFilter *pFilter,   // Owning media filter
  62.                        CCritSec *pInterfaceLock,    // Locking object
  63.                        TCHAR *pName,                // Object description
  64.                        LPUNKNOWN pUnk,              // Normal COM ownership
  65.                        HRESULT *phr);               // OLE return code
  66.  
  67.     // These are the properties we support
  68.  
  69.     STDMETHODIMP put_Caption(BSTR strCaption);
  70.     STDMETHODIMP get_Caption(BSTR *pstrCaption);
  71.     STDMETHODIMP put_AutoShow(long AutoShow);
  72.     STDMETHODIMP get_AutoShow(long *AutoShow);
  73.     STDMETHODIMP put_WindowStyle(long WindowStyle);
  74.     STDMETHODIMP get_WindowStyle(long *pWindowStyle);
  75.     STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
  76.     STDMETHODIMP get_WindowStyleEx(long *pWindowStyleEx);
  77.     STDMETHODIMP put_WindowState(long WindowState);
  78.     STDMETHODIMP get_WindowState(long *pWindowState);
  79.     STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
  80.     STDMETHODIMP get_BackgroundPalette(long *pBackgroundPalette);
  81.     STDMETHODIMP put_Visible(long Visible);
  82.     STDMETHODIMP get_Visible(long *pVisible);
  83.     STDMETHODIMP put_Left(long Left);
  84.     STDMETHODIMP get_Left(long *pLeft);
  85.     STDMETHODIMP put_Width(long Width);
  86.     STDMETHODIMP get_Width(long *pWidth);
  87.     STDMETHODIMP put_Top(long Top);
  88.     STDMETHODIMP get_Top(long *pTop);
  89.     STDMETHODIMP put_Height(long Height);
  90.     STDMETHODIMP get_Height(long *pHeight);
  91.     STDMETHODIMP put_Owner(OAHWND Owner);
  92.     STDMETHODIMP get_Owner(OAHWND *Owner);
  93.     STDMETHODIMP put_MessageDrain(OAHWND Drain);
  94.     STDMETHODIMP get_MessageDrain(OAHWND *Drain);
  95.     STDMETHODIMP get_BorderColor(long *Color);
  96.     STDMETHODIMP put_BorderColor(long Color);
  97.     STDMETHODIMP get_FullScreenMode(long *FullScreenMode);
  98.     STDMETHODIMP put_FullScreenMode(long FullScreenMode);
  99.  
  100.     // And these are the methods
  101.  
  102.     STDMETHODIMP SetWindowForeground(long Focus);
  103.     STDMETHODIMP NotifyOwnerMessage(long hwnd,long uMsg,long wParam,long lParam);
  104.     STDMETHODIMP GetMinIdealImageSize(long *pWidth,long *pHeight);
  105.     STDMETHODIMP GetMaxIdealImageSize(long *pWidth,long *pHeight);
  106.     STDMETHODIMP SetWindowPosition(long Left,long Top,long Width,long Height);
  107.     STDMETHODIMP GetWindowPosition(long *pLeft,long *pTop,long *pWidth,long *pHeight);
  108.     STDMETHODIMP GetRestorePosition(long *pLeft,long *pTop,long *pWidth,long *pHeight);
  109.     STDMETHODIMP HideCursor(long HideCursor);
  110.     STDMETHODIMP IsCursorHidden(long *CursorHidden);
  111. };
  112.  
  113. // This class implements the IBasicVideo interface
  114.  
  115. class CBaseControlVideo : public CBaseBasicVideo
  116. {
  117. protected:
  118.  
  119.     CBaseFilter *m_pFilter;   // Pointer to owning media filter
  120.     CBasePin *m_pPin;                   // Controls media types for connection
  121.     CCritSec *m_pInterfaceLock;         // Externally defined critical section
  122.  
  123. public:
  124.  
  125.     // Derived classes must provide these for the implementation
  126.  
  127.     virtual HRESULT IsDefaultTargetRect() PURE;
  128.     virtual HRESULT SetDefaultTargetRect() PURE;
  129.     virtual HRESULT SetTargetRect(RECT *pTargetRect) PURE;
  130.     virtual HRESULT GetTargetRect(RECT *pTargetRect) PURE;
  131.     virtual HRESULT IsDefaultSourceRect() PURE;
  132.     virtual HRESULT SetDefaultSourceRect() PURE;
  133.     virtual HRESULT SetSourceRect(RECT *pSourceRect) PURE;
  134.     virtual HRESULT GetSourceRect(RECT *pSourceRect) PURE;
  135.     virtual HRESULT GetStaticImage(long *pBufferSize,long *pDIBImage) PURE;
  136.  
  137.     // Derived classes must override this to return a VIDEOINFO representing
  138.     // the video format. We cannot call IPin ConnectionMediaType to get this
  139.     // format because various filters dynamically change the type when using
  140.     // DirectDraw such that the format shows the position of the logical
  141.     // bitmap in a frame buffer surface, so the size might be returned as
  142.     // 1024x768 pixels instead of 320x240 which is the real video dimensions
  143.  
  144.     virtual void GetVideoFormat(VIDEOINFO *pVideoInfo) PURE;
  145.  
  146.     // Helper function for creating memory renderings of a DIB image
  147.  
  148.     HRESULT CopyImage(IMediaSample *pMediaSample,
  149.                       VIDEOINFO *pVideoInfo,
  150.                       LONG *pBufferSize,
  151.                       BYTE *pDIBImage,
  152.                       RECT *pSourceRect);
  153.  
  154.     // Override this if you want notifying when the rectangles change
  155.     virtual HRESULT OnUpdateRectangles() { return NOERROR; };
  156.     virtual HRESULT OnVideoSizeChange();
  157.  
  158.     // Derived classes must call this to set the pin the filter is using
  159.     // We don't have the pin passed in to the constructor (as we do with
  160.     // the CBaseFilter object) because filters typically create the
  161.     // pins dynamically when requested in CBaseFilter::GetPin. This can
  162.     // not be called from our constructor because is is a virtual method
  163.  
  164.     void SetControlVideoPin(CBasePin *pPin) {
  165.         m_pPin = pPin;
  166.     }
  167.  
  168.     // Helper methods for checking rectangles
  169.     virtual HRESULT CheckSourceRect(RECT *pSourceRect);
  170.     virtual HRESULT CheckTargetRect(RECT *pTargetRect);
  171.  
  172. public:
  173.  
  174.     CBaseControlVideo(CBaseFilter *pFilter,    // Owning media filter
  175.                       CCritSec *pInterfaceLock,     // Serialise interface
  176.                       TCHAR *pName,                 // Object description
  177.                       LPUNKNOWN pUnk,               // Normal COM ownership
  178.                       HRESULT *phr);                // OLE return code
  179.  
  180.     // These are the properties we support
  181.  
  182.     STDMETHODIMP get_AvgTimePerFrame(REFTIME *pAvgTimePerFrame);
  183.     STDMETHODIMP get_BitRate(long *pBitRate);
  184.     STDMETHODIMP get_BitErrorRate(long *pBitErrorRate);
  185.     STDMETHODIMP get_VideoWidth(long *pVideoWidth);
  186.     STDMETHODIMP get_VideoHeight(long *pVideoHeight);
  187.     STDMETHODIMP put_SourceLeft(long SourceLeft);
  188.     STDMETHODIMP get_SourceLeft(long *pSourceLeft);
  189.     STDMETHODIMP put_SourceWidth(long SourceWidth);
  190.     STDMETHODIMP get_SourceWidth(long *pSourceWidth);
  191.     STDMETHODIMP put_SourceTop(long SourceTop);
  192.     STDMETHODIMP get_SourceTop(long *pSourceTop);
  193.     STDMETHODIMP put_SourceHeight(long SourceHeight);
  194.     STDMETHODIMP get_SourceHeight(long *pSourceHeight);
  195.     STDMETHODIMP put_DestinationLeft(long DestinationLeft);
  196.     STDMETHODIMP get_DestinationLeft(long *pDestinationLeft);
  197.     STDMETHODIMP put_DestinationWidth(long DestinationWidth);
  198.     STDMETHODIMP get_DestinationWidth(long *pDestinationWidth);
  199.     STDMETHODIMP put_DestinationTop(long DestinationTop);
  200.     STDMETHODIMP get_DestinationTop(long *pDestinationTop);
  201.     STDMETHODIMP put_DestinationHeight(long DestinationHeight);
  202.     STDMETHODIMP get_DestinationHeight(long *pDestinationHeight);
  203.  
  204.     // And these are the methods
  205.  
  206.     STDMETHODIMP GetVideoSize(long *pWidth,long *pHeight);
  207.     STDMETHODIMP SetSourcePosition(long Left,long Top,long Width,long Height);
  208.     STDMETHODIMP GetSourcePosition(long *pLeft,long *pTop,long *pWidth,long *pHeight);
  209.     STDMETHODIMP GetVideoPaletteEntries(long StartIndex,long Entries,long *pRetrieved,long *pPalette);
  210.     STDMETHODIMP SetDefaultSourcePosition();
  211.     STDMETHODIMP IsUsingDefaultSource();
  212.     STDMETHODIMP SetDestinationPosition(long Left,long Top,long Width,long Height);
  213.     STDMETHODIMP GetDestinationPosition(long *pLeft,long *pTop,long *pWidth,long *pHeight);
  214.     STDMETHODIMP SetDefaultDestinationPosition();
  215.     STDMETHODIMP IsUsingDefaultDestination();
  216.     STDMETHODIMP GetCurrentImage(long *pBufferSize,long *pDIBImage);
  217. };
  218.  
  219. #endif // __WINCTRL__
  220.  
  221.