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.

206 lines
7.6 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: PREVWND.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 8/12/1999
  12. *
  13. * DESCRIPTION: Preview window class declaration
  14. *
  15. *******************************************************************************/
  16. #ifndef _PREVWND_H
  17. #define _PREVWND_H
  18. #include <windows.h>
  19. #include "regionde.h"
  20. #if defined(OLD_CRAPPY_HOME_SETUP)
  21. extern "C"
  22. {
  23. typedef struct _BLENDFUNCTION
  24. {
  25. BYTE BlendOp;
  26. BYTE BlendFlags;
  27. BYTE SourceConstantAlpha;
  28. BYTE AlphaFormat;
  29. }BLENDFUNCTION;
  30. #define AC_SRC_OVER 0x00
  31. typedef BOOL (WINAPI *AlphaBlendFn)( HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
  32. };
  33. #endif //OLD_CRAPPY_HOME_SETUP
  34. class CWiaPreviewWindow
  35. {
  36. private:
  37. HWND m_hWnd;
  38. BLENDFUNCTION m_bfBlendFunction;
  39. BOOL m_bDeleteBitmap;
  40. BOOL m_bSizing;
  41. BOOL m_bAllowNullSelection;
  42. BOOL m_SelectionDisabled;
  43. HBITMAP m_hBufferBitmap; // The double buffer bitmap
  44. HBITMAP m_hPaintBitmap; // The scaled image
  45. HBITMAP m_hAlphaBitmap; // The alpha blended bitmap
  46. HBITMAP m_hPreviewBitmap; // This is the actual full size image
  47. SIZE m_BitmapSize; // Actual size of the bitmap
  48. HCURSOR m_hCurrentCursor; // Used when windows sends us a WM_SETCURSOR message
  49. HCURSOR m_hCursorArrow;
  50. HCURSOR m_hCursorCrossHairs;
  51. HCURSOR m_hCursorMove;
  52. HCURSOR m_hCursorSizeNS;
  53. HCURSOR m_hCursorSizeNeSw;
  54. HCURSOR m_hCursorSizeNwSe;
  55. HCURSOR m_hCursorSizeWE;
  56. HPEN m_aHandlePens[3];
  57. HPEN m_aBorderPens[3];
  58. HBRUSH m_aHandleBrushes[3];
  59. HPEN m_hHandleHighlight;
  60. HPEN m_hHandleShadow;
  61. RECT m_rcCurrSel;
  62. RECT m_rectSavedDetected; // the user can double click to snap back to the selected region
  63. SIZE m_Delta;
  64. SIZE m_ImageSize;
  65. SIZE m_Resolution;
  66. int m_MovingSel;
  67. UINT m_nBorderSize;
  68. int m_nHandleType;
  69. UINT m_nHandleSize;
  70. HPALETTE m_hHalftonePalette;
  71. RECT m_rcSavedImageRect;
  72. int m_nCurrentRect;
  73. bool m_bSuccessfulRegionDetection; // have we succesfully detected regions for this scan?
  74. HBRUSH m_hBackgroundBrush;
  75. bool m_bPreviewMode;
  76. bool m_bUserChangedSelection;
  77. // We store all of the pens and brushes we use in arrays. These serve as mnemonic indices.
  78. enum
  79. {
  80. Selected = 0,
  81. Unselected = 1,
  82. Disabled = 2,
  83. };
  84. protected:
  85. void DestroyBitmaps(void);
  86. void DrawHandle( HDC hDC, const RECT &r, int nState );
  87. RECT GetSizingHandleRect( const RECT &rcSel, int iWhich );
  88. RECT GetSelectionRect( RECT &rcSel, int iWhich );
  89. POINT GetCornerPoint( int iWhich );
  90. void DrawSizingFrame( HDC hDC, RECT &rc, bool bFocus, bool bDisabled );
  91. int GetHitArea( POINT &pt );
  92. void NormalizeRect( RECT &r );
  93. void SendSelChangeNotification( bool bSetUserChangedSelection=true );
  94. void GenerateNewBitmap(void);
  95. RECT GetImageRect(void);
  96. void Repaint( PRECT pRect, bool bErase );
  97. bool IsAlphaBlendEnabled(void);
  98. HPALETTE SetHalftonePalette( HDC hDC );
  99. RECT ScaleSelectionRect( const RECT &rcOriginalImage, const RECT &rcCurrentImage, const RECT &rcOriginalSel );
  100. RECT GetDefaultSelection(void);
  101. BOOL IsDefaultSelectionRect( const RECT &rc );
  102. int GetSelectionRectCount(void);
  103. void PaintWindowTitle( HDC hDC );
  104. void SetCursor( HCURSOR hCursor );
  105. bool GetOriginAndExtentInImagePixels( WORD nItem, POINT &ptOrigin, SIZE &sizeExtent );
  106. void CreateNewBitmaps(void);
  107. void DrawBitmaps(void);
  108. void ResizeProgressBar();
  109. // Region detection helper functions:
  110. int XConvertToBitmapCoords(int x);
  111. int XConvertToScreenCoords(int x);
  112. int YConvertToBitmapCoords(int y);
  113. int YConvertToScreenCoords(int y);
  114. POINT ConvertToBitmapCoords(POINT p);
  115. POINT ConvertToScreenCoords(POINT p);
  116. RECT ConvertToBitmapCoords(RECT r);
  117. RECT ConvertToScreenCoords(RECT r);
  118. RECT GrowRegion(RECT r, int border);
  119. private:
  120. // No implementation
  121. CWiaPreviewWindow(void);
  122. CWiaPreviewWindow( const CWiaPreviewWindow & );
  123. CWiaPreviewWindow &operator=( const CWiaPreviewWindow & );
  124. public:
  125. explicit CWiaPreviewWindow( HWND hWnd );
  126. virtual ~CWiaPreviewWindow(void);
  127. static BOOL RegisterClass( HINSTANCE hInstance );
  128. static LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
  129. protected:
  130. // Standard windows messages
  131. LRESULT OnPaint( WPARAM, LPARAM );
  132. LRESULT OnSetCursor( WPARAM, LPARAM );
  133. LRESULT OnMouseMove( WPARAM, LPARAM );
  134. LRESULT OnLButtonDown( WPARAM, LPARAM );
  135. LRESULT OnLButtonUp( WPARAM, LPARAM );
  136. LRESULT OnLButtonDblClk( WPARAM, LPARAM );
  137. LRESULT OnCreate( WPARAM, LPARAM );
  138. LRESULT OnSize( WPARAM, LPARAM );
  139. LRESULT OnGetDlgCode( WPARAM, LPARAM );
  140. LRESULT OnKeyDown( WPARAM, LPARAM );
  141. LRESULT OnSetFocus( WPARAM, LPARAM );
  142. LRESULT OnKillFocus( WPARAM, LPARAM );
  143. LRESULT OnEnable( WPARAM, LPARAM );
  144. LRESULT OnEraseBkgnd( WPARAM, LPARAM );
  145. LRESULT OnEnterSizeMove( WPARAM, LPARAM );
  146. LRESULT OnExitSizeMove( WPARAM, LPARAM );
  147. LRESULT OnSetText( WPARAM, LPARAM );
  148. // Our messages
  149. LRESULT OnClearSelection( WPARAM, LPARAM );
  150. LRESULT OnSetResolution( WPARAM, LPARAM );
  151. LRESULT OnGetResolution( WPARAM, LPARAM );
  152. LRESULT OnSetBitmap( WPARAM, LPARAM );
  153. LRESULT OnGetBitmap( WPARAM, LPARAM );
  154. LRESULT OnGetBorderSize( WPARAM, LPARAM );
  155. LRESULT OnGetHandleSize( WPARAM, LPARAM );
  156. LRESULT OnGetBgAlpha( WPARAM, LPARAM );
  157. LRESULT OnGetHandleType( WPARAM, LPARAM );
  158. LRESULT OnSetBorderSize( WPARAM, LPARAM );
  159. LRESULT OnSetHandleSize( WPARAM, LPARAM );
  160. LRESULT OnSetBgAlpha( WPARAM, LPARAM );
  161. LRESULT OnSetHandleType( WPARAM, LPARAM );
  162. LRESULT OnGetSelOrigin( WPARAM, LPARAM );
  163. LRESULT OnGetSelExtent( WPARAM, LPARAM );
  164. LRESULT OnSetSelOrigin( WPARAM, LPARAM );
  165. LRESULT OnSetSelExtent( WPARAM, LPARAM );
  166. LRESULT OnGetSelCount( WPARAM, LPARAM );
  167. LRESULT OnGetAllowNullSelection( WPARAM, LPARAM );
  168. LRESULT OnSetAllowNullSelection( WPARAM, LPARAM );
  169. LRESULT OnGetDisableSelection( WPARAM, LPARAM );
  170. LRESULT OnSetDisableSelection( WPARAM, LPARAM );
  171. LRESULT OnDetectRegions( WPARAM, LPARAM );
  172. LRESULT OnGetBkColor( WPARAM, LPARAM );
  173. LRESULT OnSetBkColor( WPARAM, LPARAM );
  174. LRESULT OnSetPreviewMode( WPARAM, LPARAM );
  175. LRESULT OnGetPreviewMode( WPARAM, LPARAM );
  176. LRESULT OnGetImageSize( WPARAM, LPARAM );
  177. LRESULT OnSetBorderStyle( WPARAM, LPARAM );
  178. LRESULT OnSetBorderColor( WPARAM, LPARAM );
  179. LRESULT OnSetHandleColor( WPARAM, LPARAM );
  180. LRESULT OnRefreshBitmap( WPARAM, LPARAM );
  181. LRESULT OnSetProgress( WPARAM, LPARAM );
  182. LRESULT OnGetProgress( WPARAM, LPARAM );
  183. LRESULT OnCtlColorStatic( WPARAM, LPARAM );
  184. LRESULT OnGetUserChangedSelection( WPARAM, LPARAM );
  185. LRESULT OnSetUserChangedSelection( WPARAM, LPARAM );
  186. };
  187. #endif