// Copyright (c) Microsoft Corporation. All rights reserved #pragma once #include "ViewportEventHandler.h" #include #include namespace DManipSample { class CAppWindow { public: CAppWindow(); int ShowAndServiceWindow(); private: HRESULT _Initialize(); HRESULT _InitializeDevices(); HRESULT _InitializeManagerAndViewport(); HRESULT _InitializeDrawing(); HRESULT _SizeDependentChanges(); HRESULT _DrawOuterPrimaryContent(); HRESULT _DrawInnerPrimaryContent(); HRESULT _DrawViewportStatusText(); HRESULT _DrawButtonState(ComPtr buttonVisual, BOOL isUp, WCHAR* buttonText, size_t buttonTextLength); HRESULT _ChangeButtonState(ComPtr buttonVisual); BOOL _OuterViewportHasContact(UINT contactId); HRESULT _HitTestRect(UINT contactId, HWND hWnd, BOOL applyTransform, float left, float top, float right, float bottom, BOOL* rectHit); LRESULT _WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK s_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); HWND _hWnd; // The IDirectManipulationManager2 instance is one of the two objects that is explicitly CoCreated. It handles // creating other DirectManipulation COM objects and activating/deactivating DirectManipulation. ComPtr _manager; // The IDirectManipulationCompositor instance is the other object that is explicitly CoCreated. It handles // transforming associated DirectComposition visuals with DirectManipulation updates. ComPtr _compositor; // The pointers to the outer viewport (checked pattern) and the inner (nested) viewport (concentric circles) ComPtr _viewportOuter; ComPtr _viewportInner; // The IDirectManipulationContent instances for each viewport facilitate setting and retrieving properties of the content in the // viewport such as the content boundaries and current transformations. ComPtr _contentOuter; ComPtr _contentInner; // These callbacks are associated with our viewports. The IDirectManipulationViewportEventHandler interface is // user defined. In this case, it is implemented in the CViewportEventHandler class. ComPtr _handlerOuter; ComPtr _handlerInner; // These cookies are returned when an instance of IDirectManipulationViewportEventHandler is added to a // viewport via IDirectManipulationViewport2::AddEventHandler. It can be used to later disassociate the // handler from the viewport. DWORD _viewportOuterHandlerCookie; DWORD _viewportInnerHandlerCookie; RECT _viewportOuterRect; RECT _contentOuterRect; RECT _viewportInnerRect; RECT _contentInnerRect; ComPtr _d2dFactory; ComPtr _dcompDevice; ComPtr _dcompTarget; ComPtr _dcompVisualOuterParent; ComPtr _dcompVisualOuterChild; ComPtr _dcompVisualInnerParent; ComPtr _dcompVisualInnerChild; ComPtr _dcompVisualText; ComPtr _dcompVisualButtonUpDefault; ComPtr _dcompVisualButtonUpCapturedByViewport; ComPtr _dcompVisualButtonUpClicked; ComPtr _dcompVisualButtonDown; ComPtr _dcompVisualButtonCurrent; ComPtr _textSurface; ComPtr _statusTextFormat; ComPtr _viewportTextFormat; ComPtr _writeFactory; ComPtr _d3dDevice; ComPtr _dxgiDevice; ComPtr _bitmapConverter; // Tracks the contacts being handled by the viewport so we don't end up calling SetContact on the viewports // unnecessarily. std::list _activeContacts; }; }