home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / cxwin1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  125 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.  
  19. #include "stdafx.h"
  20.  
  21. #include "cxwin.h"
  22. #include "cntritem.h"
  23. #include "medit.h"
  24. #include "button.h"
  25. #include "fmbutton.h"
  26. #include "gridedge.h"
  27. #include "cxsave.h"
  28. #include "netsvw.h"
  29. #include "feembed.h"
  30. #include "libevent.h"
  31. #include "np.h"
  32. #include "winclose.h"
  33. #ifdef EDITOR
  34. #include "edview.h"
  35. #endif /* EDITOR */
  36.  
  37. void CWinCX::DisplayText(MWContext *pContext, int iLocation, LO_TextStruct *pText, XP_Bool iClear)  
  38. {
  39. #ifdef EDITOR
  40.     CNetscapeEditView * pView;
  41. #endif // EDITOR
  42.     BOOL bHideCaret = FALSE;
  43.  
  44.     //  If we're erasing a selection, do so now.
  45.     if(iClear)  {
  46.         LTRB Rect;
  47.         if(ResolveElement(Rect, pText->x, pText->y, pText->x_offset, pText->y_offset,
  48.                             pText->width, pText->height))  {
  49.             SafeSixteen(Rect);
  50.  
  51.             RECT crRect;
  52.             ::SetRect(&crRect,CASTINT(Rect.left), CASTINT(Rect.top), CASTINT(Rect.right), CASTINT(Rect.bottom));
  53.             HDC pDC = GetContextDC();
  54.             EraseTextBkgnd(pDC, crRect, pText);
  55.             ReleaseContextDC(pDC);
  56.         }
  57.     } else {
  58.         // Hide the editor's caret during drawing -- needed to avoid
  59.         //   erasing character pixels by the caret
  60. #ifdef EDITOR
  61.         pView = (CNetscapeEditView *)GetView();
  62.         if( pView && pView->IsEditor() && pView->m_caret.bEnabled && pView->m_caret.cShown ) {
  63.             pView->HideCaret();
  64.             pView->m_caret.cShown = 0;
  65.             bHideCaret = TRUE;
  66.         }
  67. #endif // EDITOR
  68.     }
  69.  
  70.     //  Call the base.
  71. //#ifndef NO_TAB_NAVIGATION 
  72.     uint32 flag = 0;
  73.     setTextTabFocusDrawFlag( pText, &flag );
  74.     CDCCX::DisplayText(pContext, iLocation, pText, iClear, flag);
  75. //#endif /* NO_TAB_NAVIGATION */
  76.  
  77. #ifdef EDITOR
  78.     if( bHideCaret ) {
  79.         pView->ShowCaret();
  80.         pView->m_caret.cShown = 1;
  81.     }
  82. #endif // EDITOR
  83. }
  84.  
  85. void CWinCX::DisplaySubtext(MWContext *pContext, int iLocation, LO_TextStruct *pText, int32 lStartPos, int32 lEndPos, XP_Bool iClear)   {
  86. #ifdef EDITOR
  87.     CNetscapeEditView * pView;
  88. #endif // EDITOR
  89.     BOOL bHideCaret = FALSE;
  90.  
  91.     //  If we're erasing a selection, do so now.
  92.     if(iClear)  {
  93.         LTRB Rect;
  94.         if(ResolveElement(Rect, pText, iLocation, lStartPos, lEndPos, iClear))  {
  95.             SafeSixteen(Rect);
  96.  
  97.             RECT crRect;
  98.             ::SetRect(&crRect, CASTINT(Rect.left), CASTINT(Rect.top), CASTINT(Rect.right), CASTINT(Rect.bottom));
  99.             HDC pDC = GetContextDC();
  100.             EraseTextBkgnd(pDC, crRect, pText);
  101.             ReleaseContextDC(pDC);
  102.         }
  103.     } else {
  104.         // Hide the editor's caret during drawing
  105. #ifdef EDITOR
  106.         pView = (CNetscapeEditView *)GetView();
  107.         if( pView && pView->IsEditor() && pView->m_caret.bEnabled && pView->m_caret.cShown ) {
  108.             pView->HideCaret();
  109.             pView->m_caret.cShown = 0;
  110.             bHideCaret = TRUE;
  111.         }
  112. #endif // EDITOR
  113.     }
  114.  
  115.     //  Call the base.
  116.     CDCCX::DisplaySubtext(pContext, iLocation, pText, lStartPos, lEndPos, iClear);
  117. #ifdef EDITOR
  118.     if( bHideCaret ) {
  119.         pView->ShowCaret();
  120.         pView->m_caret.cShown = 1;
  121.     }
  122. #endif // EDITOR
  123. }
  124.  
  125.