bool CBackgroundInfo::LoadBackgroundFile(bool abShowErrors) { // Пустой путь - значит БЕЗ обоев if (!*ms_BgImage) { return true; } //_ASSERTE(gpConEmu->isMainThread()); _ASSERTE(gpConEmu->isMainThread()); bool lRes = false; BY_HANDLE_FILE_INFORMATION inf = {0}; BITMAPFILEHEADER* pBkImgData = NULL; if (wcspbrk(ms_BgImage, L"%\\.") == NULL) { // May be "Solid color" COLORREF clr = (COLORREF)-1; if (GetColorRef(ms_BgImage, &clr)) { pBkImgData = CreateSolidImage(clr, 128, 128); } } if (!pBkImgData) { wchar_t* exPath = ExpandEnvStr(ms_BgImage); if (!exPath || !*exPath) { if (abShowErrors) { wchar_t szError[MAX_PATH*2]; DWORD dwErr = GetLastError(); _wsprintf(szError, SKIPLEN(countof(szError)) L"Can't expand environment strings:\r\n%s\r\nError code=0x%08X\r\nImage loading failed", ms_BgImage, dwErr); MBoxA(szError); } return false; } pBkImgData = LoadImageEx(exPath, inf); } if (pBkImgData) { ftBgModified = inf.ftLastWriteTime; nBgModifiedTick = GetTickCount(); //NeedBackgroundUpdate(); //MSectionLock SBG; SBG.Lock(&mcs_BgImgData); SafeFree(mp_BgImgData); mb_IsBackgroundImageValid = true; mp_BgImgData = pBkImgData; lRes = true; } return lRes; }
OP_STATUS SVGColor::GetCSSDecl(CSS_decl** out_cd, HTML_Element* element, short property, BOOL is_current_style) const { switch(m_color_type) { case SVGColor::SVGCOLOR_RGBCOLOR: case SVGColor::SVGCOLOR_RGBCOLOR_ICCCOLOR: *out_cd = LayoutProperties::GetComputedColorDecl(property, GetColorRef() #ifdef CURRENT_STYLE_SUPPORT , is_current_style #endif // CURRENT_STYLE_SUPPORT ); break; case SVGColor::SVGCOLOR_NONE: *out_cd = OP_NEW(CSS_type_decl, (property, CSS_VALUE_none)); break; default: OP_ASSERT(!"The cascade contains a non-computed value, which is an error."); } if(!*out_cd) return OpStatus::ERR_NO_MEMORY; return OpStatus::OK; }
HRESULT CColorValue::FormatBuffer(TCHAR* szBuffer, UINT uMaxLen, BOOL fReturnAsHex6/*=FALSE*/) const { HRESULT hr = S_OK; const struct COLORVALUE_PAIR* pColorPair; LONG lValue; DWORD type = GetType(); INT idx; DWORD dwSysColor; TCHAR achFmt[5] = _T("<0C>"); switch(type) { default: case TYPE_UNDEF: *szBuffer = 0; break; case TYPE_NAME: // requests from the OM set fReturnAsHex to true, so instead // of returning "red; we want to return "#ff0000" if(!fReturnAsHex6) { pColorPair = FindColorByValue(GetRawValue()); Assert(pColorPair); _tcsncpy(szBuffer, pColorPair->szName, uMaxLen); break; } // else fall through !!! case TYPE_RGB: // requests from the OM set fReturnAsHex to true, so instead // of returning "rgb(255,0,0)" we want to return "#ff0000" if(!fReturnAsHex6) { hr = Format(_afxGlobalData._hInstResource, 0, szBuffer, uMaxLen, _T("rgb(<0d>,<1d>,<2d>)"), (_dwValue&0x0000FF), (_dwValue&0x00FF00)>>8, (_dwValue&0xFF0000)>>16); break; } // else fall through !!! case TYPE_SYSINDEX: case TYPE_POUND6: case TYPE_POUND5: case TYPE_POUND4: achFmt[2] = _T('c'); case TYPE_POUND3: case TYPE_POUND2: case TYPE_POUND1: lValue = (LONG)GetColorRef(); if(fReturnAsHex6) { achFmt[2] = _T('c'); } hr = Format(_afxGlobalData._hInstResource, 0, szBuffer, uMaxLen, achFmt, lValue); if(!fReturnAsHex6 && (type!=TYPE_POUND6)) { szBuffer[((TYPE_POUND1-type)>>24)+2] = _T('\0'); }
//*************************************************************** void CColorListCtrl::OnPaint() { // First let the control do its default drawing. const MSG *msg = GetCurrentMessage(); DefWindowProc( msg->message, msg->wParam, msg->lParam ); if (!m_fullColumnLines) return; // Draw the lines only for LVS_REPORT mode if( (GetStyle() & LVS_TYPEMASK) == LVS_REPORT ) { // Get the number of columns CClientDC dc(this ); CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); // The bottom of the header corresponds to the top of the line RECT rect; pHeader->GetClientRect( &rect ); int top = rect.bottom; // Now get the client rect so we know the line length and // when to stop GetClientRect( &rect ); // The border of the column is offset by the horz scroll int borderx = 0 - GetScrollPos( SB_HORZ ); CPen *pOldPen; CPen pen; CGdiObject *pOldBrush; pen.CreatePen( PS_DOT, 0, GetColorRef(DEF_DESELTEXT) ); pOldPen =dc.SelectObject(&pen); pOldBrush=dc.SelectStockObject(NULL_BRUSH); for( int i = 0; i < nColumnCount; i++ ) { // Get the next border borderx += GetColumnWidth( i ); // if next border is outside client area, break out if( borderx >= rect.right ) break; // Draw the line. dc.MoveTo( borderx-1, top); dc.LineTo( borderx-1, rect.bottom ); } dc.SelectObject(pOldPen); dc.SelectObject(pOldBrush); } // Do not call CListCtrl::OnPaint() for painting messages }
//*************************************************************** void CColorListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!lpDrawItemStruct) return; IsCreated=TRUE; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CMyLParam* pMyLParam = GetMyLParam(lpDrawItemStruct->itemID); CRect rcItem; if (!pMyLParam) return; int x=0; typedef enum {R_NOTHINGS=0, R_FOCUS, R_SELECT, R_NORMAL, R_SEL_NOFOCUS} redrawmode; redrawmode redraw=R_NORMAL; // Get item image and state info LV_ITEM lvi; lvi.mask = LVIF_IMAGE | LVIF_STATE; lvi.iItem = lpDrawItemStruct->itemID; lvi.iSubItem = 0; lvi.stateMask = 0xFFFF; // get all state flags GetItem(&lvi); BOOL bHighlight = ( (lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) && ( ( GetFocus() == this ) || ( GetStyle() & LVS_SHOWSELALWAYS ) ) ) ); BOOL bLostFocus=(GetFocus()!=this); if ( (lpDrawItemStruct->itemAction&ODA_FOCUS)==ODA_FOCUS) { //the control gains or loses input focus if (bLostFocus) redraw=R_SEL_NOFOCUS; else if ((lvi.state&LVIS_FOCUSED)==LVIS_FOCUSED) redraw=R_FOCUS; else { if (bHighlight) redraw=R_SELECT; else redraw=R_NORMAL; } } else if ((lpDrawItemStruct->itemAction&ODA_SELECT)==ODA_SELECT) { //the selection status has changed if (bHighlight) { if (bLostFocus) redraw=R_SEL_NOFOCUS; else redraw=R_SELECT; } else redraw=R_NORMAL; } else { //redraw the item if (bLostFocus) { if (bHighlight) redraw=R_SEL_NOFOCUS; else redraw=R_NORMAL; } else { if ((lvi.state&LVIS_FOCUSED)==LVIS_FOCUSED) redraw=R_FOCUS; else { if (bHighlight) redraw=R_SELECT; else redraw=R_NORMAL; } } } CPen *pOldPen; CPen pen; CGdiObject *pOldBrush; switch(redraw) { case R_FOCUS: rcItem=GetFullCellRect(lpDrawItemStruct->itemID, TRUE); pDC->FillSolidRect(rcItem, GetColorRef(DEF_SELBACKGROUND)); pDC->SetTextColor(GetColorRef(DEF_SELTEXT)); if (m_BigFocusRect) { pen.CreatePen( PS_DOT, 0, GetColorRef(DEF_SELTEXT) ); pOldPen =pDC->SelectObject(&pen); pOldBrush=pDC->SelectStockObject(NULL_BRUSH); pDC->Rectangle(rcItem); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); } else pDC->DrawFocusRect(rcItem); for (x=0; x<m_columnSize; x++) { rcItem = GetCellRect(lpDrawItemStruct->itemID, x, FALSE); pDC->DrawText(CListCtrl::GetItemText(lpDrawItemStruct->itemID,x), rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER ); } break; case R_SELECT: rcItem=GetFullCellRect(lpDrawItemStruct->itemID, TRUE); pDC->FillSolidRect(rcItem, GetColorRef(DEF_SELBACKGROUND)); pDC->SetTextColor(GetColorRef(DEF_SELTEXT)); for (x=0; x<m_columnSize; x++) { rcItem = GetCellRect(lpDrawItemStruct->itemID, x, FALSE); pDC->DrawText(CListCtrl::GetItemText(lpDrawItemStruct->itemID,x), rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER); } break; case R_SEL_NOFOCUS: rcItem=GetFullCellRect(lpDrawItemStruct->itemID, TRUE); pDC->FillSolidRect(rcItem, GetColorRef(DEF_DESELBACKGROUND)); pDC->SetTextColor(pMyLParam->GetTextColor(DEF_DESELTEXT)); pen.CreatePen( PS_DOT, 0, GetColorRef(DEF_DESELBACKGROUND) ); pOldPen =pDC->SelectObject(&pen); pOldBrush=pDC->SelectStockObject(NULL_BRUSH); if (!m_withSingleRect) pDC->Rectangle(rcItem); for (x=0; x<m_columnSize; x++) { rcItem = GetCellRect(lpDrawItemStruct->itemID, x, FALSE); pDC->DrawText(CListCtrl::GetItemText(lpDrawItemStruct->itemID,x), rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER); } pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); break; case R_NORMAL: for (x=0; x<m_columnSize; x++) { rcItem = GetCellRect(lpDrawItemStruct->itemID, x, TRUE); pDC->FillSolidRect(rcItem, pMyLParam->GetBackColor(x)); pDC->SetTextColor(pMyLParam->GetTextColor(x)); if (m_withSingleRect) { pOldBrush=pDC->SelectStockObject(NULL_BRUSH); pDC->Rectangle(rcItem); pDC->SelectObject(pOldBrush); } rcItem = GetCellRect(lpDrawItemStruct->itemID, x, FALSE); pDC->DrawText(CListCtrl::GetItemText(lpDrawItemStruct->itemID,x), rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER); } break; } return; }
inline cr::color GetCrColor() const { return cr::color(GetColorRef()); }
inline D3DCOLOR GetD3DColor() const { COLORREF cref = GetColorRef(); return cr::color(cref).getD3DCOLOR(); }