BOOL duStyleGroup::RemoveStyle(int nIndex) { int nStyleCount = GetStyleCount(); if (nIndex < 0 || nIndex >= nStyleCount) return FALSE; int i = 0; vector<duStyleBase *>::iterator iterStyle = m_vtStylelist.begin(); for (; iterStyle != m_vtStylelist.end(); iterStyle++) { if (i != nIndex) { i++; continue; } duStyleBase *pStyleBase = *iterStyle; if (pStyleBase) { m_vtStylelist.erase(iterStyle); delete pStyleBase; pStyleBase = NULL; return TRUE; } i++; } return FALSE; }
duStyleBase *duStyleGroup::GetStyle(int nIndex) { int nStyleCount = GetStyleCount(); if (nIndex < 0 || nIndex >= nStyleCount) return NULL; return m_vtStylelist[nIndex]; }
IMenuStyle *MenuManager::GetStyle(unsigned int index) { if (index >= GetStyleCount()) { return NULL; } return m_Styles[index]; }
void duStyleGroup::Draw(HDC hDC, LPRECT lpDstRect, UINT uState, LPCTSTR lpszText, int nAlpha) { int nStyleCount = GetStyleCount(); int i; for (i = 0; i < nStyleCount; i++) { duStyleBase *pStyle = m_vtStylelist[i]; if (pStyle && (pStyle->GetState() & uState)) pStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); } }
BOOL duStyleGroup::MoveDown(int nIndex) { int nStyleCount = GetStyleCount(); if (nIndex >= nStyleCount || nIndex < 0) return FALSE; duStyleBase *pStyleBase = m_vtStylelist[nIndex + 1]; m_vtStylelist[nIndex + 1] = m_vtStylelist[nIndex]; m_vtStylelist[nIndex] = pStyleBase; return TRUE; }
IMenuStyle *MenuManager::FindStyleByName(const char *name) { unsigned int count = GetStyleCount(); for (unsigned int i=0; i<count; i++) { IMenuStyle *ptr = GetStyle(i); if (strcasecmp(ptr->GetStyleName(), name) == 0) { return ptr; } } return NULL; }
void duStyleGroup::CalcTextRect(UINT uState, LPCTSTR lpszText, LPSIZE lpOutSize) { if (lpOutSize == NULL || lpszText == NULL) return; lpOutSize->cx = lpOutSize->cy = 0; int nStyleCount = GetStyleCount(); int i = 0; for (i = 0; i < nStyleCount; i++) { duStyleBase *pStyleBase = GetStyle(i); if (pStyleBase && (pStyleBase->GetType() == STYLE_TEXT) && (pStyleBase->GetState() & uState)) { duTextStyle *pTextStyle = (duTextStyle *)pStyleBase; pTextStyle->CalcTextRect(lpszText, lpOutSize); break; } } }
//-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- void LanguageSettings::Apply(ScintillaEdit &scintilla) const { scintilla.SetLexer(lexerId); scintilla.SetStyleBits(styleBits); scintilla.SetTabWidth(tabWidth); scintilla.SetUseTabs(!tabsToSpaces); int i; int count = GetKeywordSetCount(); for (i = 0; i < count; ++i) { const KeywordSet *set = GetKeywordSet(i); if (set->keywords) scintilla.SetKeywords(set->setId, set->keywords); } // scintilla.SetWhiteSpaceBGColour(true, defaultBackground); // scintilla.SetWhiteSpaceFGColour(true, defaultForeground); ApplyStyle(scintilla, defaultStyle); /// Copy default style to all. scintilla.StyleClearAll(); scintilla.SetCaretColour(defaultStyle.foreground); scintilla.SetSelectionBGColour(true, defaultStyle.foreground); scintilla.SetSelectionFGColour(true, defaultStyle.background); count = GetStyleCount(); for (i = 0; i < count; ++i) { const StyleSettings *style = GetStyle(i); ASSERT(style); ApplyStyle(scintilla, *style); } scintilla.Colourise(0, -1); }
void duStyleGroup::GrayDrawByStyle(HDC hDC, LPRECT lpDstRect, UINT uState, LPCTSTR lpszText, int nAlpha) { BYTE r,g,b,gray; int styleCount = GetStyleCount(); UINT nStyleType = 0; COLORREF orgColor, grayColor; int i = 0; for (i = 0;i < styleCount; i++) { duStyleBase *pStyle = m_vtStylelist[i]; if ( (pStyle == NULL) || (!(pStyle->GetState() & uState)) ) continue; nStyleType = pStyle->GetType(); if (nStyleType == STYLE_TEXT) { duTextStyle *pTextStyle = (duTextStyle *)pStyle; orgColor = pTextStyle->GetTextColor(); r = GetRValue(orgColor); g = GetGValue(orgColor); b = GetBValue(orgColor); gray = RGB2GRAY(r,g,b); grayColor = RGB(gray, gray, gray); pTextStyle->SetTextColor(grayColor); pTextStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); pTextStyle->SetTextColor(orgColor); } else if (nStyleType == STYLE_RECT) { duRectStyle *pRectStyle = (duRectStyle *)pStyle; COLORREF fillColor, fillGrayColor, borderColor, borderGrayColor; if ( pRectStyle->IsFillRect() ) { fillColor = pRectStyle->GetFillColor(); r = GetRValue(fillColor); g = GetGValue(fillColor); b = GetBValue(fillColor); gray = RGB2GRAY(r, g, b); fillGrayColor = RGB(gray, gray, gray); pRectStyle->SetFillColor(fillGrayColor); if ( pRectStyle->IsDrawBorder() ) { borderColor = pRectStyle->GetBorderColor(); r = GetRValue(borderColor); g = GetGValue(borderColor); b = GetBValue(borderColor); gray = RGB2GRAY(r, g, b); borderGrayColor = RGB(gray, gray, gray); pRectStyle->SetBorderColor(borderGrayColor); } pRectStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); pRectStyle->SetFillColor(fillColor); if ( pRectStyle->IsDrawBorder() ) { pRectStyle->SetBorderColor(borderColor); } } else { if ( pRectStyle->IsDrawBorder() ) { borderColor = pRectStyle->GetBorderColor(); r = GetRValue(borderColor); g = GetGValue(borderColor); b = GetBValue(borderColor); gray = RGB2GRAY(r, g, b); borderGrayColor = RGB(gray, gray, gray); pRectStyle->SetBorderColor(borderGrayColor); pRectStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); pRectStyle->SetBorderColor(borderColor); } } } else if (nStyleType == STYLE_IMAGE) { duImageStyle *pImageStyle = (duImageStyle *)pStyle; duResManager *pResManager = GetResManager(); if (pResManager) { dustring picfile = pImageStyle->GetPicFile(); duImage *pImage = (duImage *)pResManager->GetResObj(picfile.c_str(), DU_RES_IMAGE); if (pImage) { duImage *pGrayImage = pImage->CreateGrayImage(); if (pGrayImage) { pResManager->AddResObj(pGrayImage); LPCTSTR pNewPicFile = pGrayImage->GetName(); pImageStyle->SetPicFile(pNewPicFile); pImageStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); pImageStyle->SetPicFile(picfile.c_str()); pResManager->DeleteResObj(pNewPicFile, DU_RES_IMAGE); } } } } else if (nStyleType == STYLE_LINE) { duLineStyle *pLineStyle = (duLineStyle *)pStyle; COLORREF clrLineColor, clrGrayColor; clrLineColor = pLineStyle->GetLineColor(); BYTE r, g, b, gray; r = GetRValue(clrLineColor); g = GetGValue(clrLineColor); b = GetBValue(clrLineColor); gray = RGB2GRAY(r, g, b); clrGrayColor = RGB(gray, gray, gray); pLineStyle->SetLineColor(clrGrayColor); pLineStyle->Draw(hDC, lpDstRect, lpszText, nAlpha); pLineStyle->SetLineColor(clrLineColor); } } }