Exemplo n.º 1
0
void CCompileEditView::Initialize() 
{
	PARAFORMAT2 pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab + 1) * 1440/5 ;

	SetParaFormat( pf );

	CHARFORMAT2A cfDefault;
	GetRichEditCtrl().GetDefaultCharFormat( cfDefault );
	
	//cfDefault.cbSize = sizeof(cfDefault);
	cfDefault.dwEffects = CFE_BOLD | CFE_PROTECTED; 
	cfDefault.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT |
		CFM_PROTECTED | CFM_SIZE | CFM_FACE | CFM_CHARSET;
		
		//CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_PROTECTED ;
	//cfDefault.yHeight = 200;
	cfDefault.bCharSet = GB2312_CHARSET;//GB2312_CHARSET|ANSI_CHARSET|CHINESEBIG5_CHARSET|SYMBOL_CHARSET|DEFAULT_CHARSET|SYMBOL_CHARSET|OEM_CHARSET;//0xEE; 
	strcpy(cfDefault.szFaceName, _T("宋体"));  // Courier New // 宋体

	this->SetCharFormat(cfDefault);

	GetRichEditCtrl().SetDefaultCharFormat(cfDefault);
	GetRichEditCtrl().SetWordCharFormat(cfDefault);	

	GetRichEditCtrl().SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);
}
Exemplo n.º 2
0
long
mfc_term_view::eob(int beg)
{
  long i = GetRichEditCtrl().LineIndex(GetRichEditCtrl().GetLineCount() - 1);
  if (!beg) i += GetRichEditCtrl().LineLength(i);
  return i;
}
Exemplo n.º 3
0
void CvSqlQueryRichEditView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	CRichEditView::OnRButtonDown(nFlags, point);
	CPoint p = point;
	ClientToScreen(&p);
	CRichEditCtrl& ctrl = GetRichEditCtrl();

	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_RICHTEXT_POPUP));
	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);
	CWnd* pWndPopupOwner = this;

	long nStartChar= -1, nEndChar = -1;
	GetRichEditCtrl().GetSel(nStartChar, nEndChar);
	UINT nFlagCutCopy = (nStartChar != nEndChar)? MF_ENABLED: MF_DISABLED|MF_GRAYED;
	UINT nFlagPaste   = ::IsClipboardFormatAvailable(CF_TEXT)? MF_ENABLED: MF_DISABLED|MF_GRAYED; 
	UINT nFlagUndo   = ctrl.CanUndo()? MF_ENABLED: MF_DISABLED|MF_GRAYED; 

	pPopup->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND|nFlagCutCopy);
	pPopup->EnableMenuItem(ID_EDIT_CUT,  MF_BYCOMMAND|nFlagCutCopy);
	pPopup->EnableMenuItem(ID_EDIT_PASTE,  MF_BYCOMMAND|nFlagPaste);
	pPopup->EnableMenuItem(ID_EDIT_UNDO,  MF_BYCOMMAND|nFlagUndo);
	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, pWndPopupOwner);
}
Exemplo n.º 4
0
void CBCGPMSOffice2007DemoView::OnInitialUpdate ()
{
	CRichEditView::OnInitialUpdate();

	SendMessage (EM_SHOWSCROLLBAR, SB_HORZ, FALSE);
	SendMessage (EM_SHOWSCROLLBAR, SB_VERT, FALSE);

	GetRichEditCtrl ().SetEventMask (GetRichEditCtrl ().GetEventMask() | (ENM_REQUESTRESIZE | ENM_SCROLL));

	CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar ();
	if (pScrollBar->GetSafeHwnd () != NULL && GetRichEditCtrl().GetTextLength () == 0)
	{
		ASSERT_VALID (pScrollBar);
		pScrollBar->EnableScrollBar (ESB_DISABLE_BOTH);
	}

	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));

	CCharFormat cf;
	GetDefaultFont (cf);

	SetCharFormat (cf);
	SyncFont ();
}
Exemplo n.º 5
0
void
mfc_term_view::set_command(const char *txt)  // at end of term_view
{
  GetRichEditCtrl().SetSel(mark, eob(0));
  GetRichEditCtrl().ReplaceSel(txt);
  long mn, mx;
  GetRichEditCtrl().GetSel(mn, mx);
  GetRichEditCtrl().SetSel(mx, mx);
}
Exemplo n.º 6
0
void CCompileEditView::OnEdit(int nBegin,int nEnd,CString strText,BOOL bEdit /*= FALSE*/)
{
	CPoint point = GetRichEditCtrl().GetCaretPos();
	
	CClientDC dc((CWnd*)&GetRichEditCtrl());
	CSize size = dc.GetTextExtent("A");
	point.y += size.cy;

	ShowOnlineList(point,SW_SHOW,strText,bEdit,nBegin,nEnd);	
}
Exemplo n.º 7
0
//----------------------------------------------------------------------------
void CColorRichEditView::RedrawLines( bool bModified )
{
	if( m_redrawInProcess ) return;
	m_redrawInProcess = true;
	{
		CRichEditRedrawer rd(*this);
		m_Colorizer.Colorize(&GetRichEditCtrl(),GetRichEditCtrl().GetLineCount(),bModified);
	}
	m_redrawInProcess = false;
}
Exemplo n.º 8
0
void
mfc_term_view::send_or_copy()  // bound to Enter in term_view
{
  long i, m;
  GetRichEditCtrl().GetSel(i, m);
  m = GetRichEditCtrl().LineIndex(GetRichEditCtrl().LineFromChar(mark));
  if (i >= m) {  // send new input as command line
    m = eob();
    //if (GetRichEditCtrl().LineLength(m)) {
      GetRichEditCtrl().SetSel(m, m);
      GetRichEditCtrl().ReplaceSel("\r\n");
      GetRichEditCtrl().GetSel(i, m);
    //}
    GetRichEditCtrl().SetSel(mark, m);
    CString txt = GetRichEditCtrl().GetSelText();
    if (mfc_deliver(txt, txt.GetLength())) {
      hist_view->save_line(txt);
      mark = m;
    }
    GetRichEditCtrl().SetSel(m, m);

  } else {       // copy current line as pending new command line
    CString txt = grab_line();
    set_command(w_deprompt((char *)(const char *)txt));
  }
}
Exemplo n.º 9
0
void
mfc_term_view::save_line(const char *txt)    // to end of hist_view
{
  long mn0, mx0;
  GetRichEditCtrl().GetSel(mn0, mx0);
  long i = eob(1);
  if (mx0 > i) mn0 = mx0 = i;
  GetRichEditCtrl().SetSel(i, eob(0));
  GetRichEditCtrl().ReplaceSel(txt);
  GetRichEditCtrl().SetSel(mn0, mx0);
}
Exemplo n.º 10
0
void CCompileEditView::OnEditOnlineHelp()
{
	CPoint point = GetRichEditCtrl().GetCaretPos() ;

	CClientDC dc((CWnd*)&GetRichEditCtrl());
	CSize size = dc.GetTextExtent("A");
	point.y += size.cy;


	ShowOnlineList(point,SW_SHOW);
}
Exemplo n.º 11
0
void
mfc_term_view::home_mark()     // after VK_HOME in term_view
{
  long i, m;
  GetRichEditCtrl().GetSel(i, m);
  if (i < mark) {  // adjust to mark
    if (GetRichEditCtrl().LineFromChar(mark) ==
        GetRichEditCtrl().LineFromChar(i))
      GetRichEditCtrl().SetSel(mark, mark);
  }
}
Exemplo n.º 12
0
//----------------------------------------------------------------------------
void CColorRichEditView::RedrawLine( int index, bool bModified )
{
	if( m_redrawInProcess ) return;

	m_redrawInProcess = true;
	CHARRANGE cr;
	GetRichEditCtrl().GetSel(cr);
	m_Colorizer.Colorize(&GetRichEditCtrl(),index,bModified);
	GetRichEditCtrl().SetSel(cr);
	m_redrawInProcess = false;
}
Exemplo n.º 13
0
//----------------------------------------------------------------------------
CRichEditRedrawer::CRichEditRedrawer( CColorRichEditView& view )
: m_view(view)
{
	GetRichEditCtrl().GetSel(m_selBegin, m_selEnd);

	//turn off response to onchange events
	long mask = GetRichEditCtrl().GetEventMask();
	GetRichEditCtrl().SetEventMask(mask &= ~ENM_CHANGE );

	//set redraw to false to reduce flicker, and to speed things up
	GetRichEditCtrl().SetRedraw(FALSE);
}
Exemplo n.º 14
0
long
mfc_term_view::bol(int offset)
{
  long line = GetRichEditCtrl().LineFromChar(-1);
  if (offset) {
    line += offset;
    if (line < 0)
      line = 0;
    else if (line >= GetRichEditCtrl().GetLineCount())
      line = GetRichEditCtrl().GetLineCount() - 1;
  }
  return GetRichEditCtrl().LineIndex(line);
}
Exemplo n.º 15
0
CString
mfc_term_view::grab_line(int offset) const
{
  long line = GetRichEditCtrl().LineFromChar(-1);
  if (offset) {
    line += offset;
    if (line<0 || line>=GetRichEditCtrl().GetLineCount())
      return (const char *)0;
  }
  int len = GetRichEditCtrl().LineLength(GetRichEditCtrl().LineIndex(line));
  LPSTR s = (char*)_alloca((len + 2)*2);   // copied from MFC GetSelText
  GetRichEditCtrl().GetLine(line, s, len+2);
  s[len] = '\0';
  return s;
}
Exemplo n.º 16
0
void CActionsSampleView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();

	USES_CONVERSION;

	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));

	CHARFORMAT cf;
	ZeroMemory(&cf, sizeof(CHARFORMAT));
	
	CString strDefFont = _T("Tahoma");
	cf.cbSize = sizeof(CHARFORMAT);
	cf.dwMask = CFM_BOLD |CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_SIZE |
		CFM_COLOR | CFM_OFFSET | CFM_PROTECTED | CFM_FACE;
	cf.dwEffects = CFE_AUTOCOLOR;
	cf.yHeight = 200; //10pt
	cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;

#if (_RICHEDIT_VER >= 0x0200)
	lstrcpyn(cf.szFaceName, strDefFont, LF_FACESIZE);
#else
	lstrcpynA(cf.szFaceName, T2A((LPTSTR) (LPCTSTR) strDefFont), LF_FACESIZE);
#endif

	GetRichEditCtrl().SetDefaultCharFormat(cf);

}
Exemplo n.º 17
0
void
mfc_term_view::add_output(const char *txt)   // at end of term_view
{
  if (::IsWindow(m_hWnd)) {
    long mn0, mx0, i, m = mark;
    GetRichEditCtrl().GetSel(mn0, mx0);
    GetRichEditCtrl().SetSel(mark, mark);
    GetRichEditCtrl().ReplaceSel(txt);
    GetRichEditCtrl().GetSel(i, mark);
    if (mx0>m || (mx0==m && mn0==mx0)) {
      if (mn0 < m) mn0 = mx0;
      mn0 += mark-m, mx0 += mark-m;
    }
    GetRichEditCtrl().SetSel(mn0, mx0);
  }
}
Exemplo n.º 18
0
void CMSOffice2007DemoView::OnLButtonUp(UINT nFlags, CPoint point)
{
	CRichEditView::OnLButtonUp(nFlags, point);
	
	if (m_ptMouseDown == CPoint (-1, -1))
	{
		return;
	}

	m_ptMouseDown = CPoint (-1, -1);

	if (GetSelectedItem() != NULL || CMFCPopupMenu::GetActiveMenu() != NULL || GetRichEditCtrl().GetSelText().IsEmpty())
	{
		return;
	}

	if (!theApp.m_bShowFloaty)
	{
		return;
	}

	CMFCRibbonMiniToolBar* pFloaty = new CMFCRibbonMiniToolBar;

	InitFloaty(pFloaty);

	ClientToScreen(&point);
	pFloaty->Show(point.x, point.y);
}
Exemplo n.º 19
0
void CFunctionView::OnInitialUpdate()
{
    CRichEditView::OnInitialUpdate();

    //Set Word Wrap OFF
    m_nWordWrap = WrapNone;

    //To turn on the horizontal scroll bar
    WrapChanged();

    //Try to create a Font
    BOOL bSuccess = m_omFont.CreateFont(10, 0, 0, 0, 400, FALSE, FALSE, 0,
                                        ANSI_CHARSET, OUT_DEFAULT_PRECIS,
                                        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                                        DEFAULT_PITCH | FF_MODERN, DEFAULT_FONT);

    //If succeeded, Set the Font
    if ( bSuccess )
    {
        SetFont(&m_omFont);
    }

    //Set the Richedit control to be Read-only
    GetRichEditCtrl().SetReadOnly();

    RevokeDragDrop(m_hWnd);
}
Exemplo n.º 20
0
void CvSqlQueryRichEditView::OnChange() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CRichEditView::OnInitDialog()
	// function to send the EM_SETEVENTMASK message to the control
	// with the ENM_CHANGE flag ORed into the lParam mask.
	
	// TODO: Add your control notification handler code here
	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	if (!pDoc)
		return;

	if (pDoc->m_bHighlight)
	{
		CRichEditCtrl& ctrl = GetRichEditCtrl();
		ctrl.GetSel (pDoc->m_nStart, pDoc->m_nEnd);
		ctrl.SetSel (0, -1);
		OnColorPick (pDoc->m_crColorText);
		ctrl.SetSel (pDoc->m_nStart, pDoc->m_nEnd);
		pDoc->m_bHighlight = FALSE;
	}
	if (!m_pLowerView)
	{
		CSplitterWnd* pP1 = (CSplitterWnd*)GetParent(); // CSplitterWnd;
		ASSERT_VALID (pP1);
		m_pLowerView = (CvSqlQueryLowerView*)pP1->GetPane (1, 0);
	}
	if (m_pLowerView)
		m_pLowerView->GetDlgSqlQueryResult()->SendMessage (WM_SQL_STATEMENT_CHANGE, 0, 0);
}
Exemplo n.º 21
0
void CvSqlQueryRichEditView::SetColor  (LONG nStart, LONG nEnd, COLORREF crColor)
{
	CRichEditCtrl& ctrl = GetRichEditCtrl();
	CdSqlQueryRichEditDoc* pDoc = (CdSqlQueryRichEditDoc*)GetDocument();
	ASSERT (pDoc);
	if (!pDoc)
		return;
	pDoc->m_nStart = nStart;
	pDoc->m_nEnd   = nEnd;

	LONG oldEventMask = ctrl.SetEventMask(ENM_NONE);
	if (nStart == -1)
	{
		ctrl.SetSel (0, -1);
		OnColorPick (crColor);
		SetHighlight (FALSE);
		ctrl.SetSel (-1, 0);
	}
	else
	{
		ctrl.SetSel (-1, 0);
		ctrl.SetSel (nStart, nEnd);
		OnColorPick (crColor);
		SetHighlight (TRUE);
		ctrl.SetSel (-1, 0);
	}
	ctrl.SetEventMask(oldEventMask);
}
Exemplo n.º 22
0
void CColorRichEditView::SetAccentByIndex(int ind)
{
	CRichEditCtrl& re = GetRichEditCtrl();
	if( ind>=re.GetTextLength()-1 || ind<0 ) 
		return;
	CString Paradigm = GetText();
	int lineInd = re.LineIndex();
	int line_no = re.LineFromChar(lineInd);
	ind += line_no; // delete '\r'
	if(!is_lower_vowel(Paradigm[ind], m_morphWizard.m_Language) )
		return;
	int wordStart = ind;
	{
		while (wordStart > 0 && !isspace((BYTE) Paradigm[wordStart]))
			wordStart--;
	};
	DWORD wordEnd = ind;

	while (wordEnd < Paradigm.GetLength() && !isspace((BYTE)Paradigm.GetAt(wordEnd) ))
		wordEnd++;
	int accOld = Paradigm.Find("'",wordStart);
	if( accOld>=0  && accOld < wordEnd) 
	{
		if( accOld<ind ) --ind;
		Paradigm.Delete(accOld);
	}
	Paradigm.Insert(ind+1,"'");
	SetText(Paradigm);
	
}
Exemplo n.º 23
0
int
mfc_term_view::at_eob()
{
  long mn, mx;
  GetRichEditCtrl().GetSel(mn, mx);
  return (mn==mx && mx==eob());
}
Exemplo n.º 24
0
// converting diacritic marks
void  CColorRichEditView::SetText(const CString& S)
{
	CStringAndPosition SP;
	SP.m_BufferLength = MultiByteToWideChar(GetCodePage(), 0,(const char*)S, S.GetLength(), NULL, NULL);
	SP.m_pBuffer = new char[SP.m_BufferLength*2+1];
	memset(SP.m_pBuffer,0, SP.m_BufferLength*2+1);
	int debug = S.GetLength();
	assert (debug  == SP.m_BufferLength);
	if (S.GetLength()>0)
	{
		if (!MultiByteToWideChar(GetCodePage(), 0, (const char*)S, S.GetLength(), (WCHAR*)SP.m_pBuffer, SP.m_BufferLength))
		{
			ErrorMessage ("MultiByteToWideChar failed");
		};
	}
	
				

	SP.m_Position = 0;
	EDITSTREAM es;
	es.dwCookie = (DWORD) &SP;
	es.pfnCallback = MyStreamInCallback; 
	SP.m_BufferLength *= 2;
	GetRichEditCtrl().StreamIn(SF_TEXT|SF_UNICODE, es);
};
Exemplo n.º 25
0
// converting diacritic marks
CString CColorRichEditView::GetText() const
{
	CRichEditCtrl& re = GetRichEditCtrl();
	int TextLen = re.GetTextLength();
	CStringAndPosition SP;
	SP.m_pBuffer = new char[TextLen*2];
	EDITSTREAM es;
	es.dwCookie = (DWORD) &SP;
	es.pfnCallback = MyStreamOutCallback; 
	GetRichEditCtrl().StreamOut(SF_TEXT|SF_UNICODE, es);
	char* buf = new char[TextLen+1];
	if (!WideCharToMultiByte(GetCodePage(), 0, (WCHAR*)SP.m_pBuffer, TextLen, buf, TextLen, NULL, NULL))
	{
		ErrorMessage ("WideCharToMultiByte failed");
	};
	buf[TextLen] =0;
	CString S = buf;
	delete buf;
	return S;
};
Exemplo n.º 26
0
void
mfc_edit_view::on_choose_file()
{
  CFileDialog dlg(1);
  CString name;
  dlg.m_ofn.lpstrTitle = "Insert Filename";
  dlg.m_ofn.lpstrFile = name.GetBuffer(1025);
  if (dlg.DoModal() == IDOK)
    GetRichEditCtrl().ReplaceSel(name);
  name.ReleaseBuffer();
}
void CMyRichEditView::OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, 
   BOOL bCase, BOOL bWord)
{
   CWaitCursor wait;
   // no selection or different than what we are looking for
   if (!FindText(lpszFind, bCase, bWord))
   {
      OnTextNotFound(lpszFind);
      return;
   }

   GetRichEditCtrl().HideSelection(TRUE, FALSE);
   m_nNumReplaced = 0;
   do
   {
      GetRichEditCtrl().ReplaceSel(lpszReplace);
      m_nNumReplaced++;  // Record the number of replacements

   } while (FindTextSimple(lpszFind));
   GetRichEditCtrl().HideSelection(FALSE, FALSE);
}
Exemplo n.º 28
0
// 设置段落属性
void CitbookView::onParaFormatSetEx(PARAFORMAT2& pf)
{
	CRichEditCtrl& rCtrl = GetRichEditCtrl();		
	pf.cbSize = sizeof PARAFORMAT2;

	CHARRANGE cr;
	rCtrl.GetSel(cr);
	if (cr.cpMax != cr.cpMin)
		SendMessage(EM_SETPARAFORMAT, SCF_SELECTION, (LPARAM)&pf);	
	else
		SendMessage(EM_SETPARAFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&pf);
}
Exemplo n.º 29
0
int
mfc_edit_view::OnCreate(LPCREATESTRUCT lpcs)
{
  if (CCtrlView::OnCreate(lpcs) != 0)
    return -1;
  GetRichEditCtrl().LimitText(lMaxSize);
  GetRichEditCtrl().SetEventMask(ENM_SELCHANGE | ENM_CHANGE | ENM_SCROLL);
  VERIFY(GetRichEditCtrl().SetOLECallback(&m_xRichEditOleCallback));
  m_lpRichEditOle = GetRichEditCtrl().GetIRichEditOle();
  DragAcceptFiles(0);
  GetRichEditCtrl().SetOptions(ECOOP_OR, ECO_AUTOWORDSELECTION);

  if (!font_init) {
    HFONT f = (HFONT)GetStockObject(ANSI_FIXED_FONT);
        LOGFONT lf;
        if (::GetObject((HGDIOBJ)f, sizeof(LOGFONT), &lf)) {
      fixed_font.CreateFontIndirect(&lf);
    } else {
      return 1;
    }
    font_init = 1;
  }
  GetRichEditCtrl().SetFont(&fixed_font,0);

  WrapChanged();
  ASSERT(m_lpRichEditOle != NULL);
  return 0;
}
Exemplo n.º 30
0
void
mfc_edit_view::on_open_line()
{
  int len, i, n, oline=0;
  char s[1076];
  long line = GetRichEditCtrl().LineFromChar(-1);
  for (n=0 ; n<10 ; n++,line--) {
    len = GetRichEditCtrl().LineLength(GetRichEditCtrl().LineIndex(line));
    if (len>1075) len = 1075;
    GetRichEditCtrl().GetLine(line, s, len);
    s[len] = '\0';
    for (i=4 ; i<len-8 ; i++) {
      if (s[i]==':' &&
          s[i-1]=='E' && s[i-2]=='N' && s[i-3]=='I' && s[i-4]=='L') {
        for (i++ ; i<len-7 ; i++) if (s[i]!=' ' && s[i]!='\t') break;
        while (s[i]>='0' && s[i]<='9') oline = 10*oline + (s[i++]-'0');
        for (i+=4 ; i<len-1 ; i++) {
          if (s[i]==':' &&
              s[i-1]=='E' && s[i-2]=='L' && s[i-3]=='I' && s[i-4]=='F') {
            for (i++ ; i<len ; i++) if (s[i]!=' ' && s[i]!='\t') break;
            if (i < len) {
              /* document name s line number oline */
              mfc_edit_doc *doc=
                (mfc_edit_doc *)the_boss.OpenDocumentFile(&s[i]);
              if (doc) {
                mfc_edit_view *view = (mfc_edit_view *)doc->GetView();
                long ll = view->GetRichEditCtrl().LineIndex(oline-1);
                view->GetRichEditCtrl().SetSel(ll, ll);
              } else {
                MessageBeep(MB_OK);
              }
              return;
            }
          }
        }
      }
    }
  }
  MessageBeep(MB_OK);
}