home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / MFC / INCLUDE / AFXPRIV.H_ / AFXPRIV.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  11.6 KB  |  365 lines

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