void CStatusCtrl::OnOutputcontextCopytoclipboard() { long nStart, nEnd; GetSel(nStart, nEnd); if (nStart == nEnd) { HideSelection(TRUE, FALSE); SetSel(0, -1); Copy(); SetSel(nStart, nEnd); HideSelection(FALSE, FALSE); } else Copy(); }
void ZoomText::UpdateLexer(IEditor* editor) { if(!editor) { editor = clGetManager()->GetActiveEditor(); } if(!editor) { DoClear(); return; } znConfigItem data; clConfig conf("zoom-navigator.conf"); conf.ReadItem(&data); m_filename = editor->GetFileName().GetFullPath(); LexerConf::Ptr_t lexer = EditorConfigST::Get()->GetLexerForFile(m_filename); if(!lexer) { lexer = EditorConfigST::Get()->GetLexer("Text"); } lexer->Apply(this, true); if(lexer->IsDark()) { MarkerSetAlpha(1, 10); } else { MarkerSetAlpha(1, 20); } SetZoom(m_zoomFactor); SetEditable(false); SetUseHorizontalScrollBar(false); SetUseVerticalScrollBar(data.IsUseScrollbar()); HideSelection(true); MarkerSetBackground(1, m_colour); }
void CEditCtrl::SetText(const CString& text, COLORREF color) { CHARFORMAT cf; ::memset(&cf, 0, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; cf.crTextColor = color; int iTotalLength = GetWindowTextLength(); HideSelection(TRUE, TRUE); SetSel(iTotalLength, iTotalLength); SetSelectionCharFormat(cf); ReplaceSel((LPCTSTR)text); HideSelection(FALSE, TRUE); }
//----------------------------------------------------------------------------- // Purpose: handles keyboard input //----------------------------------------------------------------------------- int CBaseHudWeaponSelection::KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding ) { if (IsInSelectionMode() && pszCurrentBinding && !stricmp(pszCurrentBinding, "cancelselect")) { HideSelection(); // returning 0 indicates, we've handled it, no more action needs to be taken return 0; } // let someone else handle it return 1; }
ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { Hide(); if(!wxStyledTextCtrl::Create(parent, id, pos, size, style | wxNO_BORDER, name)) { return; } wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); for(int i = 0; i < wxSTC_STYLE_MAX; ++i) { StyleSetBackground(i, bgColour); } znConfigItem data; clConfig conf("zoom-navigator.conf"); conf.ReadItem(&data); SetEditable(false); SetUseHorizontalScrollBar(false); SetUseVerticalScrollBar(data.IsUseScrollbar()); HideSelection(true); SetMarginWidth(1, 0); SetMarginWidth(2, 0); SetMarginWidth(3, 0); m_zoomFactor = data.GetZoomFactor(); m_colour = data.GetHighlightColour(); MarkerSetBackground(1, m_colour); SetZoom(m_zoomFactor); EventNotifier::Get()->Connect(wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL, this); EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this); MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour); #ifndef __WXMSW__ SetTwoPhaseDraw(false); SetBufferedDraw(false); SetLayoutCache(wxSTC_CACHE_DOCUMENT); #endif MarkerSetAlpha(1, 10); m_timer = new wxTimer(this); Bind(wxEVT_TIMER, &ZoomText::OnTimer, this, m_timer->GetId()); Show(); }
ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, style | wxNO_BORDER, name) { znConfigItem data; clConfig conf("zoom-navigator.conf"); conf.ReadItem(&data); SetEditable(false); SetUseHorizontalScrollBar(false); SetUseVerticalScrollBar(data.IsUseScrollbar()); HideSelection(true); SetMarginWidth(1, 0); SetMarginWidth(2, 0); SetMarginWidth(3, 0); m_zoomFactor = data.GetZoomFactor(); m_colour = data.GetHighlightColour(); MarkerSetBackground(1, m_colour); SetZoom(m_zoomFactor); EventNotifier::Get()->Connect( wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL, this); EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this); MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour); #ifndef __WXMSW__ SetTwoPhaseDraw(false); SetBufferedDraw(false); SetLayoutCache(wxSTC_CACHE_DOCUMENT); #endif MarkerSetAlpha(1, 10); wxTheApp->Bind(wxEVT_IDLE, &ZoomText::OnIdle, this); }
//----------------------------------------------------------------------------- // Purpose: Abort selecting a weapon //----------------------------------------------------------------------------- void CBaseHudWeaponSelection::CancelWeaponSelection( void ) { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( !player ) return; // Fastswitches happen in a single frame, so the Weapon Selection HUD Element isn't visible // yet, but it's going to be next frame. We need to ask it if it thinks it's going to draw, // instead of checking it's IsActive flag. if ( ShouldDraw() ) { HideSelection(); m_hSelectedWeapon = NULL; // Play the "close weapon selection" sound player->EmitSound( "Player.WeaponSelectionClose" ); } else { engine->ClientCmd("escape"); } }
//----------------------------------------------------------------------------- // Purpose: handles keyboard input //----------------------------------------------------------------------------- int CBaseHudWeaponSelection::KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding ) { if (IsInSelectionMode() && pszCurrentBinding && !stricmp(pszCurrentBinding, "cancelselect")) { HideSelection(); // returning 0 indicates, we've handled it, no more action needs to be taken return 0; } //Tony; check 0 as well, otherwise you have to have 0 bound to slot10 no matter what. if ( down >= 1 && keynum >= KEY_0 && keynum <= KEY_9 ) { //Tony; 0 is actually '10' (slot10) if (keynum == KEY_0) keynum = KEY_A; //Dealing with button codes, so just use KEY_A, which is equal to 11 anyway. if ( HandleHudMenuInput( keynum - 1 ) ) return 0; } // let someone else handle it return 1; }
void CStatusCtrl::ShowStatus(CString status, int nType) { USES_CONVERSION; CString rtfstr = m_RTFHeader; status.Replace(_T("\\"), _T("\\\\")); status.Replace(_T("{"), _T("\\{")); status.Replace(_T("}"), _T("\\}")); status.Replace(_T("\r"), _T("")); status.Replace(_T("\n"), _T("\\status")); CString str; switch (nType) { case 0: str = "\\cf2"; break; case 1: str = "\\cf5"; break; case 2: str = "\\cf3"; break; case 3: str = "\\cf4"; break; } status = str + status; if (!m_bEmpty) rtfstr += "\\par " + status; else { m_bEmpty = FALSE; rtfstr += status; } rtfstr += "} "; char *buffer = new char[rtfstr.GetLength() + 5]; //Make it large enough to hold unicode data strcpy(buffer + 4, T2CA(rtfstr)); *(int *)buffer = 0; EDITSTREAM es; es.dwCookie = (DWORD)buffer; // Pass a pointer to the CString to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. CWnd *pFocusWnd = GetFocus(); if (pFocusWnd && pFocusWnd == this) AfxGetMainWnd()->SetFocus(); long nStart, nEnd; GetSel(nStart, nEnd); BOOL nScrollToEnd = FALSE; int num = 0; //this is the number of visible lines CRect rect; GetRect(rect); int height = rect.Height(); for (int i = GetFirstVisibleLine(); i < GetLineCount() && GetCharPos(LineIndex(i)).y < height; i++) num++; if (GetFirstVisibleLine() + num+m_nMoveToBottom >= GetLineCount()) nScrollToEnd = TRUE; HideSelection(TRUE, FALSE); SetSel(-1, -1); StreamIn(SF_RTF | SFF_SELECTION, es); // Perform the streaming if (GetLineCount() > 1000) { nStart -= LineLength(0) + 2; nEnd -= LineLength(0) + 2; if (nStart < 0) nEnd = 0; if (nEnd < 0) nEnd = 0; SetSel(0, LineLength(0) + 2); ReplaceSel(_T("")); } SetSel(nStart, nEnd); if (pFocusWnd && pFocusWnd == this) SetFocus(); HideSelection(FALSE, FALSE); if (nScrollToEnd) { if (nStart != nEnd && (LineFromChar(nStart) >= GetFirstVisibleLine() && LineFromChar(nStart) <= GetFirstVisibleLine() + num || LineFromChar(nEnd) >= GetFirstVisibleLine() && LineFromChar(nEnd) <= GetFirstVisibleLine() + num)) LineScroll(1); else { m_nMoveToBottom++; if (!m_nTimerID) m_nTimerID = SetTimer(654, 25, NULL); } } delete [] buffer; }
void CStatusCtrl::ShowStatus(CString status, int nType) { USES_CONVERSION; CString rtfstr = m_RTFHeader; status.Replace(_T("\\"), _T("\\\\")); status.Replace(_T("{"), _T("\\{")); status.Replace(_T("}"), _T("\\}")); status.Replace(_T("\r"), _T("")); status.Replace(_T("\n"), _T("\\status")); CString str; switch (nType) { case FZ_LOG_STATUS: //str.LoadString(IDS_STATUSMSG_PREFIX); str += "\\cf2"; break; case FZ_LOG_ERROR: //str.LoadString(IDS_ERRORMSG_PREFIX); str="\\cf5"; break; case FZ_LOG_COMMAND: //str.LoadString(IDS_COMMANDMSG_PREFIX); str="\\cf3"; break; case FZ_LOG_REPLY: //str.LoadString(IDS_RESPONSEMSG_PREFIX); str="\\cf4"; break; case FZ_LOG_LIST: //str.LoadString(IDS_TRACEMSG_TRACE); str="\\cf11"; break; case FZ_LOG_APIERROR: case FZ_LOG_WARNING: case FZ_LOG_INFO: case FZ_LOG_DEBUG: //str.LoadString(IDS_TRACEMSG_TRACE); str="\\cf7"; break; } CString tmp; tmp += str; tmp += "\\tab "; tmp += status; status = tmp; if (!m_bEmpty){ rtfstr += "\\par "; rtfstr += status; }else { m_bEmpty = FALSE; rtfstr += status; } rtfstr += "} "; EDITSTREAM es; string s = Util::ws2s(wstring(rtfstr)); es.dwCookie = (DWORD)&s; // Pass a pointer to the string to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. CWnd *pFocusWnd = GetFocus(); if (pFocusWnd && pFocusWnd == this) AfxGetMainWnd()->SetFocus(); long nStart, nEnd; GetSel(nStart, nEnd); BOOL nScrollToEnd = FALSE; int num = 0; //this is the number of visible lines CRect rect; GetRect(rect); int height = rect.Height(); for (int i = GetFirstVisibleLine(); i < GetLineCount() && GetCharPos(LineIndex(i)).y < height; i++) num++; if (GetFirstVisibleLine() + num+m_nMoveToBottom >= GetLineCount()) nScrollToEnd = TRUE; HideSelection(TRUE, FALSE); SetSel(-1, -1); StreamIn(SF_RTF | SFF_SELECTION, es); // Perform the streaming if (GetLineCount() > 1000) { nStart -= LineLength(0) + 2; nEnd -= LineLength(0) + 2; if (nStart < 0) nEnd = 0; if (nEnd < 0) nEnd = 0; SetSel(0, LineLength(0) + 2); ReplaceSel(_T("")); } SetSel(nStart, nEnd); if (pFocusWnd && pFocusWnd == this) SetFocus(); HideSelection(FALSE, FALSE); if (nScrollToEnd) { if (nStart != nEnd && (LineFromChar(nStart) >= GetFirstVisibleLine() && LineFromChar(nStart) <= GetFirstVisibleLine() + num || LineFromChar(nEnd) >= GetFirstVisibleLine() && LineFromChar(nEnd) <= GetFirstVisibleLine() + num)) LineScroll(1); else { m_nMoveToBottom++; if (!m_nTimerID) m_nTimerID = SetTimer(654, 25, NULL); } } }
void CTWScriptEdit::FormatTextRange(int nStart, int nEnd) { if (nStart >= nEnd) return; m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); LockWindowUpdate(); HideSelection(TRUE, FALSE); WCHAR *pBuffer = NULL; try { SetSel(nStart, nEnd); //pBuffer = new WCHAR[nEnd - nStart + 1]; CHAR* pBuffer2 = new CHAR[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer2); pBuffer = GetUnicode(pBuffer2); ASSERT(nLen <= nEnd - nStart); pBuffer[nLen] = 0; WCHAR *pStart, *pPtr; pStart = pPtr = pBuffer; WCHAR* pSymbolStart = NULL; SymbolColor ic; while (*pPtr != 0) { WCHAR ch = *pPtr; if (ch == m_chComment && (m_chComment2 == 0 || pPtr[1] == m_chComment2)) { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (ch != 0 && ch != '\r'); ic = m_icComment; } else if (IsStringQuote(ch)) { // Process strings pSymbolStart = pPtr; WCHAR ch1 = ch; do { ch = *(++pPtr); } while (ch != 0 && ch != ch1 && ch != '\r'); if (ch == ch1) pPtr++; ic = m_icString; } else if (_istdigit(ch)) { // Process numbers pSymbolStart = pPtr; wcstod(pSymbolStart, &pPtr); ic = m_icNumber; } else if (_istalpha(ch) || ch == '_') { // Process keywords pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; int nPos = IsKeyword(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strKeywords.Mid(nPos+1, pPtr - pSymbolStart)); if (wcsicmp(m_strComment, pSymbolStart) == 0) { *pPtr = ch; *pSymbolStart = m_chComment; if (pSymbolStart[1] != 0 && m_chComment2 != 0) pSymbolStart[1] = m_chComment2; pPtr = pSymbolStart; pSymbolStart = NULL; continue; } ic = m_icKeyword; } else { nPos = IsConstant(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strConstants.Mid(nPos+1, pPtr - pSymbolStart)); ic = m_icConstant; } else { pSymbolStart = NULL; } } *pPtr = ch; } else { pPtr++; } if (pSymbolStart != NULL) { ASSERT(pSymbolStart < pPtr); SetFormatRange(nStart + pStart - pBuffer, nStart + pSymbolStart - pBuffer, FALSE, RGB(0,0,0)); SetFormatRange(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, ic.bBold, ic.clrColor); pStart = pPtr; pSymbolStart = 0; } else if (*pPtr == 0) SetFormatRange(nStart + pStart - pBuffer, nStart + pPtr - pBuffer, FALSE, RGB(0,0,0)); } } catch(...){} //delete [] pBuffer; SetSel(crOldSel); HideSelection(FALSE, FALSE); UnlockWindowUpdate(); m_bInForcedChange = FALSE; }
void CEmoticonRichEditCtrl::FormatTextRange(int nStart, int nEnd) { BOOL bEmoticon = FALSE; if (nStart >= nEnd) { TRACE("\nreturn!!\n"); return; } m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); TRACE("crOldSel MIN [%d] MAX [%d] \n", crOldSel.cpMin, crOldSel.cpMax ); HideSelection(TRUE, FALSE); TCHAR *pBuffer = NULL; //char *pBuffer = NULL; try { TRACE("FormatTextRange : nStart [%d] nEnd [%d] \n", nStart, nEnd); SetSel(nStart, nEnd); pBuffer = new TCHAR[nEnd - nStart + 1]; //pBuffer = new char[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer); pBuffer[nLen] = 0; TRACE("new [%d] pBuffer [%S]\n", nEnd - nStart + 1, pBuffer); //ASSERT(nLen <= nEnd - nStart); TCHAR *pStart, *pPtr, *pSymbolStart ; //char* pStart = NULL, *pPtr = NULL; //char* pSymbolStart = NULL; pStart = pPtr = pBuffer; while (*pPtr != 0) { TCHAR ch = *pPtr; //char ch = *pPtr; if ( _istalpha(ch) || ch == '_') { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; //TRACE("pSymbolStart [%s]\n", pSymbolStart ); int nPos = IsEmoticon(pSymbolStart); if (nPos >= 0) { bEmoticon = TRUE; SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG); //TRACE("이모티콘!!! [%s]\n", pSymbolStart ); SetSel(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); ReplaceSel(" "); TRACE("이모티콘영역 [%d] [%d]\n", nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); CString strTmp(pSymbolStart); int nIndex = atoi( (LPCSTR)strTmp.Mid(2,2) ) ; HBITMAP hBitmap = GetImage( m_imgListFaces , nIndex ); if (hBitmap) { CString strOutID; strOutID.Empty(); CImageDataObject::InsertBitmap(m_pRichEditOle, hBitmap, strOutID ); // strTmp => ec01 , strOutID = 12232132321 if(m_nRole == ROLE_SEND_INPUT ) { char* pszID = new char[10+1]; char* pszVal = new char[10+1]; strncpy(pszID, (LPCSTR)strOutID, 10); strcpy(pszVal, pSymbolStart); TRACE("WM_EMOTICON_MAP : pszID [%s] pszVal [%s]\n", pszID, pszVal ); GetParent()->SendMessage( WM_EMOTICON_MAP, (WPARAM) pszID , (LPARAM) pszVal) ; } } ReplaceSel(" "); pStart = pPtr; pSymbolStart = 0; } else { pSymbolStart = NULL; } *pPtr = ch; } else { pPtr++; } } } catch(...) { //delete [] pBuffer; //pBuffer = NULL ; } delete [] pBuffer; if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } SetSel(crOldSel); if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } HideSelection(FALSE, FALSE); //UnlockWindowUpdate(); SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG ); m_bInForcedChange = FALSE; }