home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / genedit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  122 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 "genedit.h"
  22.  
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char BASED_CODE THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. IMPLEMENT_DYNAMIC( CGenericEdit, CEdit )
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CGenericEdit
  32.  
  33. CGenericEdit::CGenericEdit()
  34. {
  35. }
  36.  
  37. CGenericEdit::~CGenericEdit()
  38. {
  39. }
  40.  
  41.  
  42. BEGIN_MESSAGE_MAP(CGenericEdit, CEdit)
  43.     //{{AFX_MSG_MAP(CGenericEdit)
  44.     ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  45.     ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  46.     ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  47.     ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  48.     ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  49.     ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  50.     ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
  51.     ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  52.     //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54.  
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CGenericEdit message handlers
  58.  
  59. void CGenericEdit::OnEditCopy() 
  60. {
  61.     Copy();    
  62. }
  63.  
  64. void CGenericEdit::OnUpdateEditCopy(CCmdUI* pCmdUI) 
  65. {
  66.     int iStartSel, iEndSel;
  67.     GetSel(iStartSel, iEndSel);
  68.  
  69.     if(iStartSel != iEndSel)    {
  70.         pCmdUI->Enable(TRUE);
  71.     }
  72.     else    {
  73.         pCmdUI->Enable(FALSE);
  74.     }
  75. }
  76.  
  77. void CGenericEdit::OnEditCut() 
  78. {
  79.     Cut();
  80. }
  81.  
  82. void CGenericEdit::OnUpdateEditCut(CCmdUI* pCmdUI) 
  83. {
  84.     int iStartSel, iEndSel;
  85.     GetSel(iStartSel, iEndSel);
  86.  
  87.     if(iStartSel != iEndSel)    {
  88.         pCmdUI->Enable(TRUE);
  89.     }
  90.     else    {
  91.         pCmdUI->Enable(FALSE);
  92.     }
  93. }
  94.  
  95. void CGenericEdit::OnEditPaste() 
  96. {
  97.     Paste();
  98. }
  99.  
  100. void CGenericEdit::OnUpdateEditPaste(CCmdUI* pCmdUI) 
  101. {
  102.     pCmdUI->Enable(
  103.         ::IsClipboardFormatAvailable(CF_TEXT)
  104. #ifdef XP_WIN32
  105.             ||    ::IsClipboardFormatAvailable(CF_TEXT)
  106. #endif
  107.     );
  108.     
  109.  
  110. }
  111.  
  112. void CGenericEdit::OnEditUndo() 
  113. {
  114.     Undo();
  115. }
  116.  
  117. void CGenericEdit::OnUpdateEditUndo(CCmdUI* pCmdUI) 
  118. {
  119.     pCmdUI->SetText(szLoadString(IDS_UNDO));
  120.     pCmdUI->Enable(CanUndo());
  121. }
  122.