Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
7.8 KiB

  1. #ifndef __ZOOMWND_H_
  2. #define __ZOOMWND_H_
  3. #define ZW_DRAWCOMPLETE (WM_USER+99) // PRIVATE
  4. #define ZW_BACKDRAWCOMPLETE (WM_USER+100) // PRIVATE
  5. // messages for the Preview Window
  6. #define IV_SETIMAGEDATA (WM_USER+101)
  7. #define IV_SCROLL (WM_USER+102)
  8. #define IV_SETOPTIONS (WM_USER+104)
  9. #define IV_ONCHANGENOTIFY (WM_USER+106)
  10. #define IV_ISAVAILABLE (WM_USER+107)
  11. typedef struct
  12. {
  13. LONG x;
  14. LONG y;
  15. LONG cx;
  16. LONG cy;
  17. } PTSZ;
  18. class CPreviewWnd;
  19. class CZoomWnd : public CWindowImpl<CZoomWnd>
  20. {
  21. public:
  22. enum MODE { MODE_PAN, MODE_ZOOMIN, MODE_ZOOMOUT, MODE_NOACTION };
  23. // public accessor functions
  24. void ZoomIn(); // Does a zoom in, handles contraints
  25. void ZoomOut(); // does a zoom out, handles boundry conditions and constraints
  26. void ActualSize(); // show image at full size (crop if needed)
  27. void BestFit(); // show full image in window (scale down if needed)
  28. BOOL IsBestFit() { return m_fBestFit; }
  29. void SetImageData(CDecodeTask * pImageData, BOOL bUpdate=TRUE); // used to set an image for display
  30. HRESULT PrepareImageData(CDecodeTask * pImageData); // Draw an image in the back buffer
  31. void SetPalette( HPALETTE hpal ); // If in palette mode, set this to the palette to use
  32. void StatusUpdate( int iStatus ); // used to set m_iStrID to display correct status message
  33. void Zoom( WPARAM wParam, LPARAM lParam );
  34. BOOL SetMode( MODE modeNew );
  35. BOOL ScrollBarsPresent();
  36. BOOL SetScheduler(IShellTaskScheduler * pTaskScheduler);
  37. int QueryStatus() { return m_iStrID; }
  38. // Annotation Functions
  39. void GetVisibleImageWindowRect(LPRECT prectImage);
  40. void GetImageFromWindow(LPPOINT ppoint, int cSize);
  41. void GetWindowFromImage(LPPOINT ppoint, int cSize);
  42. CAnnotationSet* GetAnnotations() { return &m_Annotations; }
  43. void CommitAnnotations();
  44. DWORD GetBackgroundColor();
  45. CZoomWnd(CPreviewWnd *pPreview);
  46. ~CZoomWnd();
  47. DECLARE_WND_CLASS( TEXT("ShImgVw:CZoomWnd") );
  48. protected:
  49. BEGIN_MSG_MAP(CZoomWnd)
  50. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  51. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseDown)
  52. MESSAGE_HANDLER(WM_MBUTTONDOWN, OnMouseDown)
  53. MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnMouseDown)
  54. MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
  55. MESSAGE_HANDLER(WM_LBUTTONUP, OnMouseUp)
  56. MESSAGE_HANDLER(WM_MBUTTONUP, OnMouseUp)
  57. MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
  58. MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
  59. MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
  60. MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
  61. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  62. MESSAGE_HANDLER(WM_SIZE, OnSize)
  63. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  64. MESSAGE_HANDLER(WM_HSCROLL, OnScroll)
  65. MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
  66. MESSAGE_HANDLER(WM_MOUSEWHEEL, OnWheelTurn)
  67. MESSAGE_HANDLER(ZW_DRAWCOMPLETE, OnDrawComplete)
  68. MESSAGE_HANDLER(ZW_BACKDRAWCOMPLETE, OnBackDrawComplete)
  69. MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
  70. END_MSG_MAP()
  71. // message handlers
  72. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  73. LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  74. LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  75. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  76. LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  77. LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  78. LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  79. LRESULT OnMouseDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  80. LRESULT OnMouseUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  81. LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  82. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  83. LRESULT OnWheelTurn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  84. LRESULT OnDrawComplete(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  85. LRESULT OnBackDrawComplete(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  86. LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  87. public:
  88. // This is lazy. These are used by CPreview so I made them public when they probably shouldn't be.
  89. LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  90. int m_cxImage; // width of bitmap referenced by m_pImageData
  91. int m_cyImage; // height of bitmap referenced by m_pImageData
  92. float m_cxImgPhys; // actual width of the image in inches
  93. float m_cyImgPhys; // actual height of the image in inches
  94. int m_cxImgPix; // width of the image in screen pixels
  95. int m_cyImgPix; // height of the image in screen pixels
  96. float m_imgDPIx;
  97. float m_imgDPIy;
  98. float m_winDPIx;
  99. float m_winDPIy;
  100. protected:
  101. BOOL m_fBestFit; // True if we are in Bets Fit mode
  102. CDecodeTask * m_pImageData;// Handle to a IShellImageData object with render info
  103. int m_cxCenter; // point to center on relative to image
  104. int m_cyCenter; // point to center on relative to image
  105. int m_cxVScroll; // width of a scroll bar
  106. int m_cyHScroll; // height of a scroll bar
  107. int m_cxWindow; // width of our client area + scroll width if scroll bar is visible
  108. int m_cyWindow; // height of our client area + scroll height if scroll bar is visible
  109. float m_cxWinPhys; // actual width of the client area in inches
  110. float m_cyWinPhys; // actual height of the client in inches
  111. int m_xPosMouse; // used to track mouse movement when dragging the LMB
  112. int m_yPosMouse; // used to track mouse movement when dragging the LMB
  113. MODE m_modeDefault; // The zoom or pan mode when the shift key isn't pressed
  114. PTSZ m_ptszDest; // the point and size of the destination rectangle (window coordinates)
  115. RECT m_rcCut; // the rectangle of the part of the image that will be visible (image coordinates)
  116. RECT m_rcBleed; // the rectangle adjusted for pixelation effects (window coordinates)
  117. BOOL m_fPanning; // true when we are panning (implies left mouse button is down)
  118. BOOL m_fCtrlDown; // a mode modifier ( zoom <=> pan ), true if Ctrl Key is down
  119. BOOL m_fShiftDown; // a mode modifier ( zoom in <=> zoom out), true if Shift Key is down
  120. BOOL m_fTimerReady; // reset each time SetImageData is called, unset when timer is reset after OnDrawComplete
  121. int m_iStrID; // string to display when no bitmap available
  122. BOOL m_fFoundBackgroundColor;
  123. DWORD m_dwBackgroundColor;
  124. HPALETTE m_hpal;
  125. CPreviewWnd *m_pPreview; // do not delete this
  126. CAnnotationSet m_Annotations;
  127. Buffer * m_pFront;
  128. Buffer * m_pBack;
  129. UINT m_iIndex; // Index corresponding to the back buffer.
  130. IShellTaskScheduler * m_pTaskScheduler;
  131. // protected methods
  132. void AdjustRectPlacement(); // applies constraints for centering, ensureinging maximum visibility, etc
  133. void CalcCut(); // calculates the cut region that will be visible after a zoom
  134. void CalcCut(PTSZ ptszDest, int cxImage, int cyImage, RECT &rcCut, RECT &rcBleed);
  135. void GetPTSZForBestFit(int cxImgPix, int cyImgPix, float cxImgPhys, float cyImgPhys, PTSZ &ptszDest);
  136. void SetScrollBars(); // ensures scroll bar state is correct. Used after window resize or zoom.
  137. HRESULT PrepareDraw(); // draw the image in the background thread
  138. void FlushDrawMessages(); // remove any pending draw tasks and messages
  139. BOOL SwitchBuffers(UINT iIndex);
  140. void _UpdatePhysicalSize();
  141. };
  142. #include "prevwnd.h"
  143. #endif