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.

381 lines
12 KiB

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1993 Microsoft Corporation,
  3. // All rights reserved.
  4. // This source code is only intended as a supplement to the
  5. // Microsoft Foundation Classes Reference and Microsoft
  6. // QuickHelp and/or WinHelp documentation provided with the library.
  7. // See these sources for detailed information regarding the
  8. // Microsoft Foundation Classes product.
  9. #ifndef __AFXPRIV_H__
  10. #define __AFXPRIV_H__
  11. /////////////////////////////////////////////////////////////////////////////
  12. // AFXPRIV - MFC Private Classes
  13. // Implementation structures
  14. struct AFX_VBXEVENTPARAMS; // VBX implementation
  15. struct AFX_SIZEPARENTPARAMS; // Control bar implementation
  16. struct AFX_CMDHANDLERINFO; // Command routing implementation
  17. // Classes declared in this file
  18. //CObject
  19. //CFile
  20. //CMemFile
  21. class CSharedFile; // Shared memory file
  22. //CDC
  23. class CPreviewDC; // Virtual DC for print preview
  24. //CCmdTarget
  25. //CWnd
  26. //CView
  27. class CPreviewView; // Print preview view
  28. // AFXDLL support
  29. #undef AFXAPP_DATA
  30. #define AFXAPP_DATA AFXAPI_DATA
  31. /////////////////////////////////////////////////////////////////////////////
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Global ID ranges (see Technical note TN020 for more details)
  34. // 8000 -> FFFF command IDs (used for menu items, accelerators and controls)
  35. #define IS_COMMAND_ID(nID) ((nID) & 0x8000)
  36. // 8000 -> DFFF : user commands
  37. // E000 -> EFFF : AFX commands and other things
  38. // F000 -> FFFF : standard windows commands and other things etc
  39. // E000 -> E7FF standard commands
  40. // E800 -> E8FF control bars (first 32 are special)
  41. // E900 -> EEFF standard window controls/components
  42. // EF00 -> EFFF SC_ menu help
  43. // F000 -> FFFF standard strings
  44. #define ID_COMMAND_FROM_SC(sc) (((sc - 0xF000) >> 4) + AFX_IDS_SCFIRST)
  45. // 0000 -> 7FFF IDR range
  46. // 0000 -> 6FFF : user resources
  47. // 7000 -> 7FFF : AFX (and standard windows) resources
  48. // IDR ranges (NOTE: IDR_ values must be <32768)
  49. #define ASSERT_VALID_IDR(nIDR) \
  50. ASSERT((nIDR) != 0 && (nIDR) < 0x8000)
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Context sensitive help support (see Technical note TN028 for more details)
  53. // Help ID bases
  54. #define HID_BASE_COMMAND 0x00010000UL // ID and IDM
  55. #define HID_BASE_RESOURCE 0x00020000UL // IDR and IDD
  56. #define HID_BASE_PROMPT 0x00030000UL // IDP
  57. #define HID_BASE_NCAREAS 0x00040000UL
  58. #define HID_BASE_CONTROL 0x00050000UL // IDC
  59. #define HID_BASE_DISPATCH 0x00060000UL // IDispatch help codes
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Internal AFX Windows messages (see Technical note TN024 for more details)
  62. #define WM_VBXEVENT 0x0360 // lParam = AFX_VBXEVENTPARAMS
  63. #define WM_SIZEPARENT 0x0361 // lParam = AFX_SIZEPARENTPARAMS
  64. #define WM_SETMESSAGESTRING 0x0362 // wParam = nIDS (or 0),
  65. // lParam = lpszOther (or NULL)
  66. #define WM_IDLEUPDATECMDUI 0x0363 // wParam == bDisableIfNoHandler
  67. #define WM_INITIALUPDATE 0x0364 // (params unused) - sent to children
  68. #define WM_COMMANDHELP 0x0365 // lResult = TRUE/FALSE, lParam = dwContext
  69. #define WM_HELPHITTEST 0x0366 // lResult = dwContext, lParam = x,y
  70. #define WM_EXITHELPMODE 0x0367 // (params unused)
  71. #define WM_RECALCPARENT 0x0368 // force RecalcLayout on frame window
  72. // (only for inplace frame windows)
  73. #define WM_SIZECHILD 0x0369 // special notify from COleResizeBar
  74. // wParam = ID of child window
  75. // lParam = lpRectNew (new position/size)
  76. #define WM_KICKIDLE 0x036A // private to property page implementation
  77. // WM_SOCKET_NOTIFY and WM_SOCKET_DEAD are used internally by MFC's
  78. // Windows sockets implementation. For more information, see sockcore.cpp
  79. #define WM_SOCKET_NOTIFY 0x0373
  80. #define WM_SOCKET_DEAD 0x0374
  81. #define TCM_TABCHANGING 0x0375 // (params unused)
  82. #define TCM_TABCHANGED 0x0376 // (params unused) lResult = !bChange
  83. #define ON_MESSAGE_VOID(message, memberFxn) \
  84. { message, 0, AfxSig_vv, \
  85. (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(void))memberFxn },
  86. struct AFX_VBXEVENTPARAMS
  87. {
  88. UINT nNotifyCode;
  89. int nEventIndex;
  90. CWnd* pControl;
  91. LPVOID lpUserParams;
  92. };
  93. struct AFX_SIZEPARENTPARAMS
  94. {
  95. HDWP hDWP; // handle for DeferWindowPos
  96. RECT rect; // parent client rectangle (trim as appropriate)
  97. };
  98. void _AfxRepositionWindow(AFX_SIZEPARENTPARAMS FAR* lpLayout,
  99. HWND hWnd, LPCRECT lpRect);
  100. /////////////////////////////////////////////////////////////////////////////
  101. // Implementation of command routing
  102. struct AFX_CMDHANDLERINFO
  103. {
  104. CCmdTarget* pTarget;
  105. void (AFX_MSG_CALL CCmdTarget::*pmf)(void);
  106. };
  107. /////////////////////////////////////////////////////////////////////////////
  108. // Shared file support
  109. class CSharedFile : public CMemFile
  110. {
  111. DECLARE_DYNAMIC(CSharedFile)
  112. public:
  113. // Constructors
  114. CSharedFile(UINT nAllocFlags = GMEM_DDESHARE|GMEM_MOVEABLE,
  115. UINT nGrowBytes = 4096);
  116. // Attributes
  117. HGLOBAL Detach();
  118. void SetHandle(HGLOBAL hGlobalMemory, BOOL bAllowGrow = TRUE);
  119. // Implementation
  120. public:
  121. virtual ~CSharedFile();
  122. protected:
  123. virtual BYTE FAR* Alloc(DWORD nBytes);
  124. virtual BYTE FAR* Realloc(BYTE FAR* lpMem, DWORD nBytes);
  125. virtual void Free(BYTE FAR* lpMem);
  126. UINT m_nAllocFlags;
  127. HGLOBAL m_hGlobalMemory;
  128. BOOL m_bAllowGrow;
  129. };
  130. /////////////////////////////////////////////////////////////////////////////
  131. // Implementation of PrintPreview
  132. class CPreviewDC : public CDC
  133. {
  134. DECLARE_DYNAMIC(CPreviewDC)
  135. public:
  136. virtual void SetAttribDC(HDC hDC); // Set the Attribute DC
  137. virtual void SetOutputDC(HDC hDC);
  138. virtual void ReleaseOutputDC();
  139. // Constructors
  140. CPreviewDC();
  141. // Implementation
  142. public:
  143. virtual ~CPreviewDC();
  144. #ifdef _DEBUG
  145. virtual void AssertValid() const;
  146. virtual void Dump(CDumpContext& dc) const;
  147. #endif
  148. void SetScaleRatio(int nNumerator, int nDenominator);
  149. void SetTopLeftOffset(CSize TopLeft);
  150. void ClipToPage();
  151. // These conversion functions can be used without an output DC
  152. void PrinterDPtoScreenDP(LPPOINT lpPoint) const;
  153. // Device-Context Functions
  154. virtual int SaveDC();
  155. virtual BOOL RestoreDC(int nSavedDC);
  156. public:
  157. virtual CGdiObject* SelectStockObject(int nIndex);
  158. virtual CFont* SelectObject(CFont* pFont);
  159. // Drawing-Attribute Functions
  160. virtual COLORREF SetBkColor(COLORREF crColor);
  161. virtual COLORREF SetTextColor(COLORREF crColor);
  162. // Mapping Functions
  163. virtual int SetMapMode(int nMapMode);
  164. virtual CPoint SetViewportOrg(int x, int y);
  165. virtual CPoint OffsetViewportOrg(int nWidth, int nHeight);
  166. virtual CSize SetViewportExt(int x, int y);
  167. virtual CSize ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom);
  168. virtual CSize SetWindowExt(int x, int y);
  169. virtual CSize ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom);
  170. // Text Functions
  171. virtual BOOL TextOut(int x, int y, LPCSTR lpszString, int nCount);
  172. virtual BOOL ExtTextOut(int x, int y, UINT nOptions, LPRECT lpRect,
  173. LPCSTR lpszString, UINT nCount, LPINT lpDxWidths);
  174. virtual CSize TabbedTextOut(int x, int y, LPCSTR lpszString, int nCount,
  175. int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin);
  176. virtual int DrawText(LPCSTR lpszString, int nCount, LPRECT lpRect,
  177. UINT nFormat);
  178. virtual BOOL GrayString(CBrush* pBrush,
  179. BOOL (CALLBACK EXPORT* lpfnOutput)(HDC, LPARAM, int),
  180. LPARAM lpData, int nCount,
  181. int x, int y, int nWidth, int nHeight);
  182. // Printer Escape Functions
  183. virtual int Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData);
  184. // Implementation
  185. protected:
  186. void MirrorMappingMode(BOOL bCompute);
  187. void MirrorViewportOrg();
  188. void MirrorFont();
  189. void MirrorAttributes();
  190. CSize ComputeDeltas(int& x, LPCSTR lpszString, UINT& nCount, BOOL bTabbed,
  191. UINT nTabStops, LPINT lpnTabStops, int nTabOrigin,
  192. char* pszOutputString, int* pnDxWidths, int& nRightFixup);
  193. protected:
  194. int m_nScaleNum; // Scale ratio Numerator
  195. int m_nScaleDen; // Scale ratio Denominator
  196. int m_nSaveDCIndex; // DC Save index when Screen DC Attached
  197. int m_nSaveDCDelta; // delta between Attrib and output restore indices
  198. CSize m_sizeTopLeft;// Offset for top left corner of page
  199. HFONT m_hFont; // Font selected into the screen DC (NULL if none)
  200. HFONT m_hPrinterFont; // Font selected into the print DC
  201. CSize m_sizeWinExt; // cached window extents computed for screen
  202. CSize m_sizeVpExt; // cached viewport extents computed for screen
  203. };
  204. /////////////////////////////////////////////////////////////////////////////
  205. // CPreviewView
  206. class CDialogBar;
  207. class CPreviewView : public CScrollView
  208. {
  209. DECLARE_DYNCREATE(CPreviewView)
  210. // Constructors
  211. public:
  212. CPreviewView();
  213. BOOL SetPrintView(CView* pPrintView);
  214. // Attributes
  215. protected:
  216. CView* m_pOrigView;
  217. CView* m_pPrintView;
  218. CPreviewDC* m_pPreviewDC; // Output and attrib DCs Set, not created
  219. CDC m_dcPrint; // Actual printer DC
  220. // Operations
  221. void SetZoomState(UINT nNewState, UINT nPage, CPoint point);
  222. void SetCurrentPage(UINT nPage, BOOL bClearRatios);
  223. // Returns TRUE if in a page rect. Returns the page index
  224. // in nPage and the point converted to 1:1 screen device coordinates
  225. BOOL FindPageRect(CPoint& point, UINT& nPage);
  226. // Overridables
  227. virtual void OnActivateView(BOOL bActivate,
  228. CView* pActivateView, CView* pDeactiveView);
  229. // Returns .cx/.cy as the numerator/denominator pair for the ratio
  230. // using CSize for convenience
  231. virtual CSize CalcScaleRatio(CSize windowSize, CSize actualSize);
  232. virtual void PositionPage(UINT nPage);
  233. virtual void OnDisplayPageNumber(UINT nPage, UINT nPagesDisplayed);
  234. // Implementation
  235. public:
  236. virtual ~CPreviewView();
  237. virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
  238. #ifdef _DEBUG
  239. void AssertValid() const;
  240. void Dump(CDumpContext& dc) const;
  241. #endif
  242. protected:
  243. //{{AFX_MSG(CPreviewView)
  244. afx_msg void OnPreviewClose();
  245. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  246. afx_msg void OnSize(UINT nType, int cx, int cy);
  247. afx_msg void OnDraw(CDC* pDC);
  248. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  249. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  250. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  251. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  252. afx_msg void OnNumPageChange();
  253. afx_msg void OnNextPage();
  254. afx_msg void OnPrevPage();
  255. afx_msg void OnPreviewPrint();
  256. afx_msg void OnZoomIn();
  257. afx_msg void OnZoomOut();
  258. afx_msg void OnUpdateNumPageChange(CCmdUI* pCmdUI);
  259. afx_msg void OnUpdateNextPage(CCmdUI* pCmdUI);
  260. afx_msg void OnUpdatePrevPage(CCmdUI* pCmdUI);
  261. afx_msg void OnUpdateZoomIn(CCmdUI* pCmdUI);
  262. afx_msg void OnUpdateZoomOut(CCmdUI* pCmdUI);
  263. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  264. //}}AFX_MSG
  265. void DoZoom(UINT nPage, CPoint point);
  266. void SetScaledSize(UINT nPage);
  267. CSize CalcPageDisplaySize();
  268. CPrintPreviewState* m_pPreviewState; // State to restore
  269. CDialogBar* m_pToolBar; // Toolbar for preview
  270. struct PAGE_INFO
  271. {
  272. CRect rectScreen; // screen rect (screen device units)
  273. CSize sizeUnscaled; // unscaled screen rect (screen device units)
  274. CSize sizeScaleRatio; // scale ratio (cx/cy)
  275. CSize sizeZoomOutRatio; // scale ratio when zoomed out (cx/cy)
  276. };
  277. PAGE_INFO* m_pPageInfo; // Array of page info structures
  278. PAGE_INFO m_pageInfoArray[2]; // Embedded array for the default implementation
  279. BOOL m_bPageNumDisplayed;// Flags whether or not page number has yet
  280. // been displayed on status line
  281. UINT m_nZoomOutPages; // number of pages when zoomed out
  282. UINT m_nZoomState;
  283. UINT m_nMaxPages; // for sanity checks
  284. UINT m_nCurrentPage;
  285. UINT m_nPages;
  286. int m_nSecondPageOffset; // used to shift second page position
  287. HCURSOR m_hMagnifyCursor;
  288. CSize m_sizePrinterPPI; // printer pixels per inch
  289. CPoint m_ptCenterPoint;
  290. CPrintInfo* m_pPreviewInfo;
  291. DECLARE_MESSAGE_MAP()
  292. friend CView;
  293. friend BOOL CALLBACK _AfxPreviewCloseProc(CFrameWnd* pFrameWnd);
  294. };
  295. // Zoom States
  296. #define ZOOM_OUT 0
  297. #define ZOOM_MIDDLE 1
  298. #define ZOOM_IN 2
  299. /////////////////////////////////////////////////////////////////////////////
  300. void AFXAPI AfxResetMsgCache();
  301. #undef AFXAPP_DATA
  302. #define AFXAPP_DATA NEAR
  303. /////////////////////////////////////////////////////////////////////////////
  304. #endif // __AFXPRIV_H__