home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / cxpane.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.3 KB  |  258 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. #ifndef __HTML_PANE_CONTEXT_H
  19. #define __HTML_PANE_CONTEXT_H
  20.  
  21. //  What is CPaneCX?
  22. //      A pane is part of a complete window.
  23. //
  24. //      There is no relation from a pane to the chrome of a full window.
  25. //      There is no frame, no document, no view, no toolbar, etc.
  26. //      No assumptions should be made, or the pane becomes non-reusable in a
  27. //          window that is yet to be invented.
  28. //
  29. //      A pane can be put many places:
  30. //          In a dialog.
  31. //          In a navigation tool.
  32. //          In a browser.
  33. //      It is up to the place to provide the chrome.  It is up to the pane to
  34. //          provide the HTML.
  35.  
  36. #include "cxdc.h"
  37. #include "drawable.h"
  38.  
  39. #define VSCROLL_LINE    32
  40. #define HSCROLL_LINE    32
  41. #define SCROLL_UNITS    10000
  42. #define RIGHT_MARGIN    (-1 * Pix2TwipsX(8))
  43. #define LEFT_MARGIN     (Pix2TwipsX(8))
  44. #define TOP_MARGIN      (Pix2TwipsY(8))
  45. #define BOTTOM_MARGIN   (-1 * Pix2TwipsY(8))
  46.  
  47. struct PaneMessage {
  48.     PaneMessage(WPARAM wSet, LPARAM lSet)
  49.     {
  50.         wParam = wSet;
  51.         lParam = lSet;
  52.         bSetRetval = FALSE;
  53.         lRetval = NULL;
  54.     }
  55.     WPARAM wParam;
  56.     LPARAM lParam;
  57.     BOOL bSetRetval;
  58.     LPARAM lRetval;
  59. };
  60.  
  61. class CPaneCX : public CDCCX    {
  62. public:
  63.     CPaneCX(HWND hPane, BOOL bDestroyOnWMDestroy);
  64.     ~CPaneCX();
  65.     virtual void DestroyContext();
  66.     virtual void Initialize(BOOL bOwnDC, RECT *pRect = NULL, BOOL bInitialPalette = TRUE, BOOL bNewMemDC = TRUE);
  67.  
  68. private:
  69.     HWND m_hPane;
  70.     BOOL m_bDestroyOnWMDestroy;
  71. private:
  72.     BOOL SubClass(HWND hWnd, BOOL bSubClass);
  73.     void CacheDCInfo(BOOL bCache);
  74. public:
  75.     HWND GetPane() const;
  76.     HWND SetPane(HWND hPane);
  77.  
  78. public:
  79.     BOOL IsNavCenterHTMLPane() const;
  80.  
  81. private:
  82.     WNDPROC m_pPrevProc;
  83. private:
  84.     WNDPROC GetSubclassedProc();
  85.     friend LRESULT CALLBACK
  86. #ifndef _WIN32
  87.         _export
  88. #endif
  89.         PaneProc(HWND hPane, UINT uMsg, WPARAM wParam, LPARAM lParam);
  90.  
  91. protected:
  92.     void PreWMPaint(PaneMessage *pMsg);
  93. #ifdef EDITOR
  94.     virtual
  95. #endif
  96.     void PreWMErasebkgnd(PaneMessage *pMsg);
  97.     void PreWMVScroll(PaneMessage *pMsg);
  98.     void PreWMHScroll(PaneMessage *pMsg);
  99.     void PreNavCenterQueryPosition(PaneMessage *pMsg);
  100.     void PreIdleUpdateCmdUI(PaneMessage *pMsg);
  101. #if defined(XP_WIN32) && _MSC_VER >= 1100
  102.     void PreWMMouseWheel(PaneMessage *pMsg);
  103.     void PreWMHackedMouseWheel(PaneMessage *pMsg);
  104. #endif
  105. protected:
  106.     virtual void AftWMSize(PaneMessage *pMsg);
  107.     void AftWMDestroy(PaneMessage *pMsg);
  108.     void AftWMMouseActivate(PaneMessage *pMsg);
  109.  
  110. private:
  111.     HDC m_hClassDC;
  112.     HDC m_hOwnDC;
  113.     HDC m_hSubstDC;
  114. public:
  115.     void RefreshArea(int32 lLeft, int32 lTop, uint32 lWidth, uint32 lHeight);
  116.     virtual HDC GetContextDC();
  117.     virtual void ReleaseContextDC(HDC hDC);
  118.     virtual BOOL IsOwnDC() const;
  119.     virtual BOOL IsClassDC() const;
  120.     HDC SubstituteDC(HDC hDC);
  121.     
  122. private:
  123.     CDrawable *m_pDrawable;
  124.     COffscreenDrawable *m_pOffscreenDrawable;
  125.     COnscreenDrawable *m_pOnscreenDrawable;
  126. public:
  127.     CDrawable *GetDrawable();
  128.     virtual void SetDrawable(MWContext *pContext, CL_Drawable *pDrawable);
  129.     virtual void GetDrawingOrigin(int32 *plOrgX, int32 *plOrgY);
  130.     virtual FE_Region GetDrawingClip();
  131.  
  132. public:
  133.     void *m_pResizeReloadTimeout;
  134. protected:
  135.     void NiceResizeReload(void);
  136.     
  137. private:
  138.     int32 m_nPageY;
  139.     int32 m_nPageX;
  140.     BOOL m_bVScrollBarOn;
  141.     BOOL m_bHScrollBarOn;
  142.     BOOL m_bDynamicScrollBars;
  143.     BOOL m_bAlwaysShowScrollBars;
  144. #ifdef XP_WIN32
  145.     int m_iWheelDelta;
  146. #endif
  147. public:
  148.     void ShowScrollBars(int iBars, BOOL bShow);
  149.     BOOL IsVScrollBarOn();
  150.     BOOL IsHScrollBarOn();
  151.     BOOL DynamicScrollBars();
  152.     BOOL AlwaysShowScrollBars();
  153.     int32 GetPageY();
  154.     int32 GetPageX();
  155.     void SetAlwaysShowScrollBars(BOOL bSet);
  156.     void SetDynamicScrollBars(BOOL bSet);
  157.     void RealizeScrollBars(int32 *pX = NULL, int32 *pY = NULL);
  158. #ifdef EDITOR
  159.     virtual
  160. #endif
  161.     void Scroll(int iBars, UINT uSBCode, UINT uPos, HWND hCtrl, UINT uTimes = 1);
  162.     void MakeElementVisible(int32 lX, int32 lY);
  163.     
  164. #ifdef XP_WIN16
  165.     // 16-bit forms need their own segment.
  166. private:
  167.     HGLOBAL m_hTextElementSegment;
  168.     LPVOID  m_lpTextElementHeap;
  169. public:
  170.     HINSTANCE GetSegment();
  171. #endif
  172.     
  173. //  Marginal implementation.
  174. protected:
  175.     int32 m_lLeftMargin;
  176.     int32 m_lRightMargin;
  177.     int32 m_lTopMargin;
  178.     int32 m_lBottomMargin;
  179.     
  180. //  Coordinate resolution.
  181. public:
  182.     void ResolvePoint(XY& xy, POINT& point);
  183.     virtual void GetWindowOffset(int32 *pX, int32 *pY);
  184.     LO_Element *GetLayoutElement(XY& Point, CL_Layer *layer) const;
  185.  
  186. public:
  187.     virtual int GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bReallyLoad = TRUE, BOOL bForceNew = FALSE);
  188. public:
  189.     virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight);
  190.     virtual void FinishedLayout(MWContext *pContext);
  191.     virtual void SetDocDimension(MWContext *pContext, int iLocation, int32 lWidth, int32 lLength);
  192. };
  193.  
  194. inline HWND CPaneCX::GetPane() const
  195. {
  196.     return(m_hPane);
  197. }
  198. inline WNDPROC CPaneCX::GetSubclassedProc()
  199. {
  200.     return(m_pPrevProc);
  201. }
  202. inline CDrawable *CPaneCX::GetDrawable()
  203. {
  204.     return(m_pDrawable);
  205. }
  206. inline BOOL CPaneCX::IsVScrollBarOn()
  207. {
  208.     return(m_bVScrollBarOn);
  209. }
  210. inline BOOL CPaneCX::IsHScrollBarOn()
  211. {
  212.     return(m_bHScrollBarOn);
  213. }
  214. inline BOOL CPaneCX::DynamicScrollBars()
  215. {
  216.     return(m_bDynamicScrollBars);
  217. }
  218. inline BOOL CPaneCX::AlwaysShowScrollBars()
  219. {
  220.     return(m_bAlwaysShowScrollBars);
  221. }
  222. inline int32 CPaneCX::GetPageY()
  223. {
  224.     return(m_nPageY);
  225. }
  226. inline int32 CPaneCX::GetPageX()
  227. {
  228.     return(m_nPageX);
  229. }
  230. inline void CPaneCX::SetAlwaysShowScrollBars(BOOL bSet)
  231. {
  232.     m_bAlwaysShowScrollBars = bSet;
  233. }
  234. inline void CPaneCX::SetDynamicScrollBars(BOOL bSet)
  235. {
  236.     m_bDynamicScrollBars = bSet;
  237. }
  238. inline void CPaneCX::ResolvePoint(XY& xy, POINT& point)
  239. {
  240.     xy.x = Pix2TwipsX(point.x) + GetOriginX();
  241.     xy.y = Pix2TwipsY(point.y) + GetOriginY();
  242. }
  243. inline LO_Element *CPaneCX::GetLayoutElement(XY& Point, CL_Layer *layer) const
  244. {
  245.     return(LO_XYToElement(GetContext(), Point.x, Point.y, layer));
  246. }
  247. inline BOOL CPaneCX::IsNavCenterHTMLPane() const
  248. {
  249.     BOOL bRetval = FALSE;
  250.     MWContext *pContext = GetContext();
  251.     if(pContext && MWContextPane == pContext->type && Pane == GetContextType()) {
  252.         bRetval = TRUE;
  253.     }
  254.     return(bRetval);
  255. }
  256.  
  257. #endif // __HTML_PANE_CONTEXT_H
  258.