void CToolBarTreeView::Draw() { const int& cx = m_mdc.cx; const int& cy = m_mdc.cy; if (IsAppThemed()) { HTHEME hTheme = OpenThemeData(m_hWnd, L"TREEVIEW"); ASSERT(hTheme); RECT rc = {0, 0, cx, cy}; DrawThemeBackground(hTheme, m_mdc, LBCP_BORDER_NOSCROLL, LBPSN_NORMAL, &rc, NULL); CloseThemeData(hTheme); // TODO: detect size of border (check for high DPI) DrawRect(m_mdc, 1, 1, cx - 2, SCY(24), GetSysColor(COLOR_BTNFACE), 96); DrawRect(m_mdc, 1, 1 + SCY(24) - 1, cx - 2, 1, GetSysColor(COLOR_BTNFACE), 192); } else { RECT rc = {0, 0, cx, cy}; FillSolidRect(m_mdc, &rc, GetSysColor(COLOR_WINDOW)); FillSolidRect(m_mdc, 1, 1, cx - 2, SCY(24), GetSysColor(COLOR_BTNFACE)); DrawEdge(m_mdc, &rc, EDGE_SUNKEN, BF_RECT); } }
void Draw3dRect(TDC& dc, int x, int y, int cx, int cy, TColor clrTopLeft, TColor clrBottomRight) { FillSolidRect(dc, x, y, cx - 1, 1, clrTopLeft); FillSolidRect(dc, x, y, 1, cy - 1, clrTopLeft); FillSolidRect(dc, x + cx, y, -1, cy, clrBottomRight); FillSolidRect(dc, x, y + cy, cx, -1, clrBottomRight); }
void CDC::Draw3dRect(int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight) { FillSolidRect(x, y, cx - 1, 1, clrTopLeft); FillSolidRect(x, y, 1, cy - 1, clrTopLeft); FillSolidRect(x + cx, y, -1, cy, clrBottomRight); FillSolidRect(x, y + cy, cx, -1, clrBottomRight); }
LRESULT CBrandBand::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) { PAINTSTRUCT paintInfo; HDC dc; POINT destinationPoint; HDC sourceDC; HBITMAP oldBitmap; RECT clientRect; RECT tempRect; dc = BeginPaint(&paintInfo); GetClientRect(&clientRect); destinationPoint.x = (clientRect.right - clientRect.left - fBitmapSize) / 2; destinationPoint.y = (clientRect.bottom - clientRect.top - fBitmapSize) / 2; ::SetBkColor(dc, RGB(255, 255, 255)); tempRect.left = 0; tempRect.top = 0; tempRect.right = clientRect.right; tempRect.bottom = destinationPoint.y; FillSolidRect(dc, &tempRect, RGB(255, 255, 255)); tempRect.left = 0; tempRect.top = destinationPoint.y + fBitmapSize; tempRect.right = clientRect.right; tempRect.bottom = clientRect.bottom; FillSolidRect(dc, &paintInfo.rcPaint, RGB(255, 255, 255)); tempRect.left = 0; tempRect.top = destinationPoint.y; tempRect.right = destinationPoint.x; tempRect.bottom = destinationPoint.y + fBitmapSize; FillSolidRect(dc, &paintInfo.rcPaint, RGB(255, 255, 255)); tempRect.left = destinationPoint.x + fBitmapSize; tempRect.top = destinationPoint.y; tempRect.right = clientRect.right; tempRect.bottom = destinationPoint.y + fBitmapSize; FillSolidRect(dc, &paintInfo.rcPaint, RGB(255, 255, 255)); sourceDC = CreateCompatibleDC(dc); oldBitmap = reinterpret_cast<HBITMAP>(SelectObject(sourceDC, fImageBitmap)); BitBlt(dc, destinationPoint.x, destinationPoint.y, fBitmapSize, fBitmapSize, sourceDC, 0, fCurrentFrame * fBitmapSize, SRCCOPY); SelectObject(sourceDC, oldBitmap); DeleteDC(sourceDC); EndPaint(&paintInfo); return 0; }
//KMemDC KMemDC::KMemDC(HDC hDC, const RECT* pRect):KDC(){ assert(hDC!=NULL); // Some initialization m_hDCPaint=hDC; // Get the rectangle to draw if(!pRect) ::GetClipBox(hDC,&m_rect); else m_rect=*pRect; // Create a Memory DC CreateCompatibleDC(hDC); ::LPtoDP(hDC,(POINT*)(&m_rect),2); m_bitmap=::CreateCompatibleBitmap(hDC, m_rect.right-m_rect.left,m_rect.bottom-m_rect.top); m_oldBitmap=(HBITMAP)SelectObject(m_bitmap); SetMapMode(::GetMapMode(hDC)); SIZE size; ::GetWindowExtEx(hDC,&size); SetWindowExt(size); ::GetViewportExtEx(hDC,&size); SetViewportExt(size); ::DPtoLP(hDC,(POINT*)(&m_rect),2); SetWindowOrg(m_rect.left, m_rect.top); // Fill background FillSolidRect(&m_rect, ::GetBkColor(hDC)); }
/******************************************************************************* Function Name : COffScreenDC Description : Standard default constructor Member of : COffScreenDC Functionality : Initialises data members and creates offscreen (buffer) Bitmap Author(s) : Raja N Date Created : 23.06.2004 Modifications : Raja N on 06.08.2004 Added code to check the failure condition *******************************************************************************/ COffScreenDC::COffScreenDC(CDC* pDC, const CRect& rcBounds) : CDC() { CreateCompatibleDC(pDC); // Store the screen DC m_pDC = pDC; // Store Screen Area Rectangle m_rcBounds = rcBounds; // Create a new bitmap for offscreen m_bCreateSuccess = m_omBitmap.CreateCompatibleBitmap( pDC, rcBounds.Width(), rcBounds.Height()); // If the creation is success if( m_bCreateSuccess == TRUE ) { // Select the Bit map and // Save the old bitmap m_pOldBitmap = SelectObject( &m_omBitmap ); // Fill the background with white color } // Create failed use the CDC directly else { // Delete the created DC DeleteDC(); // Use the Screen DC directly m_hDC = pDC->m_hDC; // Copy m_hAttribDC // This data member contains the attribute device context for this // CDC object m_hAttribDC = pDC->m_hAttribDC; } // To change the background replace it with approp. background color FillSolidRect( &rcBounds, WHITE_COLOR ); }
LRESULT CWENavigatorDlg::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HDC hDC = (HDC)wParam; CRect client; GetClientRect(&client); int state = SaveDC(hDC); if (m_layoutView) { CRect rect; rect.left = 3 + (client.Width()-6-m_size.cx)/2; rect.top = 3 + (client.Height()-6-16-m_size.cy)/2; rect.right = rect.left + m_size.cx; rect.bottom = rect.top + m_size.cy; rect.InflateRect(2, 2); ExcludeClipRect(hDC, rect.left, rect.top, rect.right, rect.bottom); } FillSolidRect(hDC, &client, GetSysColor(COLOR_BTNFACE)); RestoreDC(hDC, state); return TRUE; }
void CompositionObject::Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, short& nX, short& nY) { bool bQuit = false; while (!bQuit && !gb.IsEOF()) { short nCount = 0; BYTE nPaletteIndex = 0; BYTE bTemp = (BYTE)gb.BitRead(4); if (bTemp != 0) { nPaletteIndex = bTemp; nCount = 1; } else { if (gb.BitRead(1) == 0) { // switch_1 nCount = (short)gb.BitRead(3); // run_length_3-9 if (nCount != 0) { nCount += 2; } else { bQuit = true; } } else { if (gb.BitRead(1) == 0) { // switch_2 nCount = 4 + (short)gb.BitRead(2); // run_length_4-7 nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code } else { switch (gb.BitRead(2)) { // switch_3 case 0: nCount = 1; break; case 1: nCount = 2; break; case 2: // if (switch_3 == '10') nCount = 9 + (short)gb.BitRead(4); // run_length_9-24 nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code break; case 3: nCount = 25 + gb.ReadByte(); // run_length_25-280 nPaletteIndex = (BYTE)gb.BitRead(4); // 4-bit_pixel-code break; } } } } #if 0 if (nX + nCount > m_width) { ASSERT(FALSE); break; } #endif if (nCount > 0) { FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]); nX += nCount; } } gb.BitByteAlign(); }
void KDC::FillSolidRect(int x,int y,int cx,int cy,COLORREF clrColor){ RECT rect; rect.left =x; rect.top =y; rect.right =x+cx; rect.bottom =y+cy; FillSolidRect(&rect,clrColor); }
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd) { RECT rcClient; //ULONGLONG CommitChargeLimit; int i; static int offset = 0; if (offset++ >= 10) offset = 0; /* * Get the client area rectangle */ GetClientRect(hWnd, &rcClient); /* * Fill it with blackness */ FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); /* * Get the memory usage */ //CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); /* * Draw the graph background * * Draw the horizontal bars */ for (i=0; i<rcClient.bottom; i++) { if ((i % 11) == 0) { /* FillSolidRect2(hDC, 0, i, rcClient.right, 1, DARK_GREEN); */ } } /* * Draw the vertical bars */ for (i=11; i<rcClient.right + offset; i++) { if ((i % 11) == 0) { /* FillSolidRect2(hDC, i - offset, 0, 1, rcClient.bottom, DARK_GREEN); */ } } /* * Draw the memory usage */ for (i=rcClient.right; i>=0; i--) { } }
void CompositionObject::Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, short& nX, short& nY) { BYTE bTemp; BYTE nPaletteIndex = 0; short nCount; bool bQuit = false; while (!bQuit && !gb.IsEOF()) { nCount = 0; nPaletteIndex = 0; bTemp = (BYTE)gb.BitRead(2); if (bTemp != 0) { nPaletteIndex = bTemp; nCount = 1; } else { if (gb.BitRead(1) == 1) { // switch_1 nCount = 3 + (short)gb.BitRead(3); // run_length_3-9 nPaletteIndex = (BYTE)gb.BitRead(2); } else { if (gb.BitRead(1) == 0) { // switch_2 switch (gb.BitRead(2)) { // switch_3 case 0: bQuit = true; break; case 1: nCount = 2; break; case 2: // if (switch_3 == '10') nCount = 12 + (short)gb.BitRead(4); // run_length_12-27 nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code break; case 3: nCount = 29 + gb.ReadByte(); // run_length_29-284 nPaletteIndex = (BYTE)gb.BitRead(2); // 4-bit_pixel-code break; } } else { nCount = 1; } } } if (nX + nCount > m_width) { ASSERT(FALSE); break; } if (nCount > 0) { FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]); nX += nCount; } } gb.BitByteAlign(); }
void CompositionObject::RenderHdmv(SubPicDesc& spd) { if (!m_pRLEData || !HavePalette()) { return; } CGolombBuffer GBuffer(m_pRLEData, m_nRLEDataSize); BYTE bTemp; BYTE bSwitch; BYTE nPaletteIndex = 0; short nCount; short nX = m_horizontal_position; short nY = m_vertical_position; while ((nY < (m_vertical_position + m_height)) && !GBuffer.IsEOF()) { bTemp = GBuffer.ReadByte(); if (bTemp != 0) { nPaletteIndex = bTemp; nCount = 1; } else { bSwitch = GBuffer.ReadByte(); if (!(bSwitch & 0x80)) { if (!(bSwitch & 0x40)) { nCount = bSwitch & 0x3F; if (nCount > 0) { nPaletteIndex = 0; } } else { nCount = (bSwitch & 0x3F) << 8 | (short)GBuffer.ReadByte(); nPaletteIndex = 0; } } else { if (!(bSwitch & 0x40)) { nCount = bSwitch & 0x3F; nPaletteIndex = GBuffer.ReadByte(); } else { nCount = (bSwitch & 0x3F) << 8 | (short)GBuffer.ReadByte(); nPaletteIndex = GBuffer.ReadByte(); } } } if (nCount > 0) { if (nPaletteIndex != 0xFF) { // Fully transparent (§9.14.4.2.2.1.1) FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]); } nX += nCount; } else { nY++; nX = m_horizontal_position; } } }
long CHelpView::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { PAINTSTRUCT ps; BeginPaint(&ps); HDC hDC = ps.hdc; RECT client; GetClientRect(&client); FillSolidRect(hDC, m_splitx-3, 0, 6, client.bottom, GetSysColor(COLOR_BTNFACE)); Draw3DRect(hDC, m_splitx-3, 0, 6, client.bottom, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW)); EndPaint(&ps); return 0; }
void DrawVertGradient(HDC hDC, RECT* rect, COLORREF light, COLORREF dark) { int height = rect->bottom - rect->top; int width = rect->right - rect->left; for (int y = 0; y < height; y++) { COLORREF clr = RGB( GetRValue(light) + (GetRValue(dark)-GetRValue(light)) * y / height, GetGValue(light) + (GetGValue(dark)-GetGValue(light)) * y / height, GetBValue(light) + (GetBValue(dark)-GetBValue(light)) * y / height, ); FillSolidRect(hDC, rect->left, rect->top + y, width, 1, clr); } }
void DrawHorzGradient(HDC hDC, RECT* rect, COLORREF light, COLORREF dark) { int width = rect->right - rect->left; int height = rect->bottom - rect->top; for (int x = 0; x < width; x++) { COLORREF clr = RGB( GetRValue(light) + (GetRValue(dark)-GetRValue(light)) * x / width, GetGValue(light) + (GetGValue(dark)-GetGValue(light)) * x / width, GetBValue(light) + (GetBValue(dark)-GetBValue(light)) * x / width, ); FillSolidRect(hDC, rect->left+x, rect->top, 1, height, clr); } }
void CompositionObject::Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb, SHORT& nX, SHORT& nY) { BYTE bTemp; BYTE nPaletteIndex = 0; SHORT nCount; bool bQuit = false; while(!bQuit && !gb.IsEOF()) { nCount = 0; nPaletteIndex = 0; bTemp = gb.ReadByte(); if(bTemp != 0) { nPaletteIndex = bTemp; nCount = 1; } else { if(gb.BitRead(1) == 0) // switch_1 { nCount = (SHORT)gb.BitRead(7); // run_length_1-127 if(nCount == 0) bQuit = true; } else { nCount = (SHORT)gb.BitRead(7); // run_length_3-127 nPaletteIndex = gb.ReadByte(); } } if(nX + nCount > m_width) { ASSERT(FALSE); break; } if(nCount > 0) { FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]); nX += nCount; } } gb.BitByteAlign(); }
/////////////////////////////////////////////////////////////////////////////// // The fillRect(x, y, w, h) method must paint the specified rectangular area // using the fillStyle. If either height or width are zero, this method // has no effect. void GdiContext2D::fillRect(double x, double y, double w, double h) { Check(); //TODO waiting for transformations.. RECT rect = {(LONG)x, (LONG)y, (LONG)(x + w), (LONG)(y + h)}; if (shadowOffsetX != 0 && shadowOffsetY != 0) { DrawShadow(m_hDC, rect, (int)shadowOffsetX); } if (fillStyle.fillStyleEnum == FillStyleEnumSolid) { COLORREF color = ColorToColorRef(fillStyle.m_Color); FillSolidRect(m_hDC, &rect, color); } else if (fillStyle.fillStyleEnum == FillStyleEnumGradient) { UINT mode = fillStyle.canvasGradient.pCanvasGradientImp->isVertical() ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H; COLORREF color1 = fillStyle.canvasGradient.pCanvasGradientImp->color1; COLORREF color2 = fillStyle.canvasGradient.pCanvasGradientImp->color2; if (mode == GRADIENT_FILL_RECT_V && fillStyle.canvasGradient.pCanvasGradientImp->y0 > fillStyle.canvasGradient.pCanvasGradientImp->y1) { std::swap(color1, color2); } if (mode == GRADIENT_FILL_RECT_H && fillStyle.canvasGradient.pCanvasGradientImp->x0 > fillStyle.canvasGradient.pCanvasGradientImp->x1) { std::swap(color1, color2); } FillGradientRect(m_hDC, rect, color1, color2, mode); } }
CMemDC::CMemDC(CDC* pDC, const CRect* pRect) : CDC() { ASSERT(pDC != NULL); // Some initialization m_pDC = pDC; m_oldBitmap = NULL; m_bMemDC = !pDC->IsPrinting(); // Get the rectangle to draw if (pRect == NULL) { pDC->GetClipBox(&m_rect); } else { m_rect = *pRect; } if (m_bMemDC) { // Create a Memory DC CreateCompatibleDC(pDC); pDC->LPtoDP(&m_rect); m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); m_oldBitmap = SelectObject(&m_bitmap); SetMapMode(pDC->GetMapMode()); SetWindowExt(pDC->GetWindowExt()); SetViewportExt(pDC->GetViewportExt()); pDC->DPtoLP(&m_rect); SetWindowOrg(m_rect.left, m_rect.top); } else { // Make a copy of the relevent parts of the current DC for printing m_bPrinting = pDC->m_bPrinting; m_hDC = pDC->m_hDC; m_hAttribDC = pDC->m_hAttribDC; } // Fill background FillSolidRect(m_rect, pDC->GetBkColor()); }
void CompositionObject::RenderHdmv(SubPicDesc& spd) { if(m_pRLEData) { CGolombBuffer GBuffer(m_pRLEData, m_nRLEDataSize); BYTE bTemp; BYTE bSwitch; bool bEndOfLine = false; BYTE nPaletteIndex; SHORT nCount; SHORT nX = 0; SHORT nY = 0; while((nY < m_height) && !GBuffer.IsEOF()) { bTemp = GBuffer.ReadByte(); if(bTemp != 0) { nPaletteIndex = bTemp; nCount = 1; } else { bSwitch = GBuffer.ReadByte(); if(!(bSwitch & 0x80)) { if(!(bSwitch & 0x40)) { nCount = bSwitch & 0x3F; if(nCount > 0) nPaletteIndex = 0; } else { nCount = (bSwitch & 0x3F) << 8 | (SHORT)GBuffer.ReadByte(); nPaletteIndex = 0; } } else { if(!(bSwitch & 0x40)) { nCount = bSwitch & 0x3F; nPaletteIndex = GBuffer.ReadByte(); } else { nCount = (bSwitch & 0x3F) << 8 | (SHORT)GBuffer.ReadByte(); nPaletteIndex = GBuffer.ReadByte(); } } } if(nCount > 0) { if(nPaletteIndex != 0xFF) // Fully transparent (§9.14.4.2.2.1.1) FillSolidRect(spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]); nX += nCount; } else { nY++; nX = 0; } } } }
/// <param name="rect">bounding rectangle</param> /// <param name="fill">polygon fill color</param> void Canvas::FillRectangle(const rect_t &rect, color_t fill) { FillSolidRect(rect.x, rect.y, rect.wide, rect.high, fill); }
HRESULT CColorSpectrum::OnDraw(ATL_DRAWINFO& di) { CRect& rc = *(CRect*)di.prcBounds; HDC hDC = di.hdcDraw; if (m_bEnabled) { #define ROWBYTES(width,bitcount) ((((width)*(bitcount)+31) >> 3) & 0xfffc) int width = rc.Width()-20; int height = rc.Height(); FillSolidRect(hDC, rc.left+width, rc.top, 20, height/2, RGB(255, 255, 255)); FillSolidRect(hDC, rc.left+width, rc.top+height/2, 20, rc.Height()-height/2, RGB(0, 0, 0)); int bytesPerRow = ROWBYTES(width, 24); BITMAPINFOHEADER bmi; ZeroMemory(&bmi, sizeof(bmi)); bmi.biSize = sizeof(BITMAPINFOHEADER); bmi.biWidth = width; bmi.biHeight = height; bmi.biPlanes = 1; bmi.biBitCount = 24; bmi.biCompression = BI_RGB; bmi.biSizeImage = bytesPerRow*height; LPBYTE bits = (LPBYTE)GlobalAlloc(0, bmi.biSizeImage); if (bits) { for (int y = 0; y < height; y++) { RGBTRIPLE* dest = (RGBTRIPLE*)(bits + (height-y-1)*bytesPerRow); for (int x = 0; x < width; x++) { int h = (x * 255)/width; int l = ((height-y-1) * 255)/height; int s = ((height-y-1) * 255)/height; //int s = 127;//(x * width)/255; COLORREF clr = HLStoRGB(HLS(h, l, s)); dest->rgbtRed = GetRValue(clr); dest->rgbtGreen = GetGValue(clr); dest->rgbtBlue = GetBValue(clr); dest++; } } SetDIBitsToDevice(hDC, rc.left, rc.top, width, height, 0, 0, 0, height, bits, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS); GlobalFree(bits); } } return S_OK; }
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd) { RECT rcClient; RECT rcBarLeft; RECT rcBarRight; RECT rcText; COLORREF crPrevForeground; WCHAR Text[260]; HFONT hOldFont; ULONG CpuUsage; ULONG CpuKernelUsage; int nBars; int nBarsUsed; /* Bottom bars that are "used", i.e. are bright green, representing used cpu time */ int nBarsUsedKernel; /* Bottom bars that are "used", i.e. are bright green, representing used cpu kernel time */ int nBarsFree; /* Top bars that are "unused", i.e. are dark green, representing free cpu time */ int i; /* * Get the client area rectangle */ GetClientRect(hWnd, &rcClient); /* * Fill it with blackness */ FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); /* * Get the CPU usage */ CpuUsage = PerfDataGetProcessorUsage(); if (CpuUsage <= 0) CpuUsage = 0; if (CpuUsage > 100) CpuUsage = 100; wsprintfW(Text, L"%d%%", (int)CpuUsage); /* * Draw the font text onto the graph */ rcText = rcClient; InflateRect(&rcText, -2, -2); crPrevForeground = SetTextColor(hDC, RGB(0, 255, 0)); hOldFont = SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT)); DrawTextW(hDC, Text, -1, &rcText, DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_SINGLELINE); SelectObject(hDC, hOldFont); SetTextColor(hDC, crPrevForeground); /* * Now we have to draw the graph * So first find out how many bars we can fit */ nBars = ((rcClient.bottom - rcClient.top) - 25) / 3; nBarsUsed = (nBars * CpuUsage) / 100; if ((CpuUsage) && (nBarsUsed == 0)) { nBarsUsed = 1; } nBarsFree = nBars - (nlastBarsUsed>nBarsUsed ? nlastBarsUsed : nBarsUsed); if (TaskManagerSettings.ShowKernelTimes) { CpuKernelUsage = PerfDataGetProcessorSystemUsage(); if (CpuKernelUsage <= 0) CpuKernelUsage = 0; if (CpuKernelUsage >= 100) CpuKernelUsage = 100; nBarsUsedKernel = (nBars * CpuKernelUsage) / 100; } else { nBarsUsedKernel = 0; } /* * Now draw the bar graph */ rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2; rcBarLeft.right = rcBarLeft.left + 16; rcBarRight.left = rcBarLeft.left + 17; rcBarRight.right = rcBarLeft.right + 17; rcBarLeft.top = rcBarRight.top = 5; rcBarLeft.bottom = rcBarRight.bottom = 7; if (nBarsUsed < 0) nBarsUsed = 0; if (nBarsUsed > nBars) nBarsUsed = nBars; if (nBarsFree < 0) nBarsFree = 0; if (nBarsFree > nBars) nBarsFree = nBars; if (nBarsUsedKernel < 0) nBarsUsedKernel = 0; if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars; /* * Draw the "free" bars */ for (i=0; i<nBarsFree; i++) { FillSolidRect(hDC, &rcBarLeft, DARK_GREEN); FillSolidRect(hDC, &rcBarRight, DARK_GREEN); rcBarLeft.top += 3; rcBarLeft.bottom += 3; rcBarRight.top += 3; rcBarRight.bottom += 3; } /* * Draw the last "used" bars */ if ((nlastBarsUsed - nBarsUsed) > 0) { for (i=0; i< (nlastBarsUsed - nBarsUsed); i++) { if (nlastBarsUsed > 5000) nlastBarsUsed = 5000; FillSolidRect(hDC, &rcBarLeft, MEDIUM_GREEN); FillSolidRect(hDC, &rcBarRight, MEDIUM_GREEN); rcBarLeft.top += 3; rcBarLeft.bottom += 3; rcBarRight.top += 3; rcBarRight.bottom += 3; } } nlastBarsUsed = nBarsUsed; /* * Draw the "used" bars */ for (i=0; i<nBarsUsed; i++) { if (nBarsUsed > 5000) nBarsUsed = 5000; FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN); rcBarLeft.top += 3; rcBarLeft.bottom += 3; rcBarRight.top += 3; rcBarRight.bottom += 3; } /* * Draw the "used" kernel bars */ rcBarLeft.top -=3; rcBarLeft.bottom -=3; rcBarRight.top -=3; rcBarRight.bottom -=3; for (i=0; i<nBarsUsedKernel; i++) { FillSolidRect(hDC, &rcBarLeft, RED); FillSolidRect(hDC, &rcBarRight, RED); rcBarLeft.top -=3; rcBarLeft.bottom -=3; rcBarRight.top -=3; rcBarRight.bottom -=3; } SelectObject(hDC, hOldFont); }
void CIppsSignalDC::DrawBackground() { FillSolidRect(0, 0, GetWidth(), GetHeight(), GetColorAxisBack()); }
LRESULT CToolbarsDlg::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { UINT idCtl = (UINT) wParam; // control identifier LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam; // item-drawing information if (lpdis->itemID >= 0) { TCHAR text[256]; ::SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM)text); IUIDlgSite* dlgbar = (IUIDlgSite*)::SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, 0); CRect& rcItem = *(CRect*)&lpdis->rcItem; int oldBk = SetBkMode(lpdis->hDC, TRANSPARENT); FillSolidRect(lpdis->hDC, &rcItem, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_WINDOW)); CRect selectedRect = rcItem; BOOL bVisible = FALSE; dlgbar->IsVisible(&bVisible); CRect cbrect = rcItem; cbrect.right = cbrect.left+18; cbrect.InflateRect(-1, -1); DrawFrameControl(lpdis->hDC, &cbrect, DFC_BUTTON, DFCS_BUTTONCHECK | (bVisible? DFCS_CHECKED: 0)); /* if (imageIndex >= 0) { selectedRect.left += 20; CRect iconrect = rcItem; iconrect.right = iconrect.left+20; int cx, cy; ImageList_GetIconSize(hImageList, &cx, &cy); ImageList_Draw(hImageList, imageIndex, lpdis->hDC, iconrect.left+(iconrect.Width()-cx)/2, iconrect.top+(iconrect.Height()-cy)/2, ILD_TRANSPARENT); if (lpdis->itemState & ODS_SELECTED) { Draw3DRect(lpdis->hDC, &iconrect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); } } */ // FillSolidRect(lpdis->hDC, &selectedRect, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_BTNFACE)); CRect trect = rcItem; trect.left += 22; SetTextColor(lpdis->hDC, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHTTEXT): GetSysColor(COLOR_WINDOWTEXT)); DrawText(lpdis->hDC, text, lstrlen(text), &trect, DT_SINGLELINE | DT_VCENTER); /* if (cmdType == 1) { CRect textbnd(0,0,0,0); DrawText(lpdis->hDC, text, lstrlen(text), &textbnd, DT_SINGLELINE | DT_CALCRECT); int height = 18; int top = rcItem.top + (rcItem.Height()-height)/2; Rectangle(lpdis->hDC, trect.left + textbnd.Width()+2, top, rcItem.right-2, top+height); CRect arrowrect(rcItem.right-2-18+1, top+1, rcItem.right-2-1, top+height-1); DrawFrameControl(lpdis->hDC, &arrowrect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | DFCS_FLAT); } */ SetBkMode(lpdis->hDC, oldBk); } return 0; }
void ClientConnection::ReadCoRRERect(rfbFramebufferUpdateRectHeader *pfburh) { // An RRE rect is always followed by a background color // For speed's sake we read them together into a buffer. char tmpbuf[sz_rfbRREHeader+4]; // biggest pixel is 4 bytes long rfbRREHeader *prreh = (rfbRREHeader *) tmpbuf; CARD8 *pcolor = (CARD8 *) tmpbuf + sz_rfbRREHeader; ReadExact(tmpbuf, sz_rfbRREHeader + m_minPixelBytes); prreh->nSubrects = Swap32IfLE(prreh->nSubrects); SETUP_COLOR_SHORTCUTS; COLORREF color; switch (m_myFormat.bitsPerPixel) { case 8: color = COLOR_FROM_PIXEL8_ADDRESS(pcolor); break; case 16: color = COLOR_FROM_PIXEL16_ADDRESS(pcolor); break; case 24: case 32: color = COLOR_FROM_PIXEL32_ADDRESS(pcolor); break; } // Draw the background of the rectangle FillSolidRect(pfburh->r.x, pfburh->r.y, pfburh->r.w, pfburh->r.h, color); if (prreh->nSubrects == 0) return; // Draw the sub-rectangles rfbCoRRERectangle *pRect; rfbRectangle rect; // The size of an CoRRE subrect including color info int subRectSize = m_minPixelBytes + sz_rfbCoRRERectangle; // Read subrects into the buffer CheckBufferSize(subRectSize * prreh->nSubrects); ReadExact(m_netbuf, subRectSize * prreh->nSubrects); BYTE *p = (BYTE *) m_netbuf; { boost::recursive_mutex::scoped_lock l(m_bitmapdcMutex); \ ObjectSelector b(m_hBitmapDC, m_hBitmap); \ PaletteSelector ps(m_hBitmapDC, m_hPalette); \ for (CARD32 i = 0; i < prreh->nSubrects; i++) { pRect = (rfbCoRRERectangle *) (p + m_minPixelBytes); switch (m_myFormat.bitsPerPixel) { case 8: color = COLOR_FROM_PIXEL8_ADDRESS(p); break; case 16: color = COLOR_FROM_PIXEL16_ADDRESS(p); break; case 32: color = COLOR_FROM_PIXEL32_ADDRESS(p); break; }; // color = COLOR_FROM_PIXEL8_ADDRESS(netbuf); rect.x = pRect->x + pfburh->r.x; rect.y = pRect->y + pfburh->r.y; rect.w = pRect->w; rect.h = pRect->h; FillSolidRect(rect.x, rect.y, rect.w, rect.h, color); p+=subRectSize; } } }
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) { RECT rcClient; RECT rcBarLeft; RECT rcBarRight; RECT rcText; COLORREF crPrevForeground; WCHAR Text[260]; HFONT hOldFont; ULONGLONG CommitChargeTotal; ULONGLONG CommitChargeLimit; int nBars; int nBarsUsed = 0; /* Bottom bars that are "used", i.e. are bright green, representing used memory */ int nBarsFree; /* Top bars that are "unused", i.e. are dark green, representing free memory */ int i; /* * Get the client area rectangle */ GetClientRect(hWnd, &rcClient); /* * Fill it with blackness */ FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); /* * Get the memory usage */ CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK(); CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); if (CommitChargeTotal > 1024) wsprintfW(Text, L"%d MB", (int)(CommitChargeTotal / 1024)); else wsprintfW(Text, L"%d K", (int)CommitChargeTotal); /* * Draw the font text onto the graph */ rcText = rcClient; InflateRect(&rcText, -2, -2); crPrevForeground = SetTextColor(hDC, RGB(0, 255, 0)); hOldFont = SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT)); DrawTextW(hDC, Text, -1, &rcText, DT_BOTTOM | DT_CENTER | DT_NOPREFIX | DT_SINGLELINE); SelectObject(hDC, hOldFont); SetTextColor(hDC, crPrevForeground); /* * Now we have to draw the graph * So first find out how many bars we can fit */ nBars = ((rcClient.bottom - rcClient.top) - 25) / 3; if (CommitChargeLimit) nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100; nBarsFree = nBars - nBarsUsed; if (nBarsUsed < 0) nBarsUsed = 0; if (nBarsUsed > nBars) nBarsUsed = nBars; if (nBarsFree < 0) nBarsFree = 0; if (nBarsFree > nBars) nBarsFree = nBars; /* * Now draw the bar graph */ rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2; rcBarLeft.right = rcBarLeft.left + 16; rcBarRight.left = rcBarLeft.left + 17; rcBarRight.right = rcBarLeft.right + 17; rcBarLeft.top = rcBarRight.top = 5; rcBarLeft.bottom = rcBarRight.bottom = 7; /* * Draw the "free" bars */ for (i=0; i<nBarsFree; i++) { FillSolidRect(hDC, &rcBarLeft, DARK_GREEN); FillSolidRect(hDC, &rcBarRight, DARK_GREEN); rcBarLeft.top += 3; rcBarLeft.bottom += 3; rcBarRight.top += 3; rcBarRight.bottom += 3; } /* * Draw the "used" bars */ for (i=0; i<nBarsUsed; i++) { FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN); rcBarLeft.top += 3; rcBarLeft.bottom += 3; rcBarRight.top += 3; rcBarRight.bottom += 3; } SelectObject(hDC, hOldFont); }
BOOL CGraphTRDialog::OnTimer(HWND hWnd, int nIDEvent) { // 一応チェック if (m_hdcMem == NULL) return TRUE; // データの取得 int nBarTransmitted, nBarReceived, nLine; BOOL bDraw = GetData(nBarTransmitted, nBarReceived, m_bPlotLineGraph, nLine); if (bDraw) { // データが取れたらウィンドウを表示する if (m_bHidPrev) { // 前回 hide だったら ShowWindow(SW_SHOW); m_bHidPrev = FALSE; } // 左にスクロール if (m_nBitBltWidth) BitBlt(m_hdcMem, 0, 0, m_nBitBltWidth, m_nWindowHeight, m_hdcMem, m_nBarWidth, 0, SRCCOPY); // 上から描画 RECT rect; rect.left = m_nBitBltWidth; rect.right = m_nBitBltWidth + m_nBarWidth; rect.top = 0; int nYTransmitted = m_nWindowHeight - (m_nWindowHeight * nBarTransmitted) / 100; int nYReceived = m_nWindowHeight - (m_nWindowHeight * nBarReceived) / 100; if (nYTransmitted >= nYReceived) { // Y 座標が大きい方から rect.bottom = nYReceived; FillSolidRect(m_hdcMem, m_clrBG, &rect); rect.top = rect.bottom; rect.bottom = nYTransmitted; FillSolidRect(m_hdcMem, m_clrBar50, &rect); rect.top = rect.bottom; rect.bottom = m_nWindowHeight; // 下端は描画されないみたい FillSolidRect(m_hdcMem, m_clrBar0, &rect); } else { rect.bottom = nYTransmitted; FillSolidRect(m_hdcMem, m_clrBG, &rect); rect.top = rect.bottom; rect.bottom = nYReceived; FillSolidRect(m_hdcMem, m_clrBar0, &rect); rect.top = rect.bottom; rect.bottom = m_nWindowHeight; // 下端は描画されないみたい FillSolidRect(m_hdcMem, m_clrBar50, &rect); } // 線グラフ if (m_bPlotLineGraph) { DrawLineGraph(nLine, rect.left, rect.right); } InvalidateRect(hWnd, NULL, TRUE); } else { ShowWindow(SW_HIDE); m_bHidPrev = TRUE; } return TRUE; }
void FillSolidRect(HDC hDC, RECT* rect, COLORREF clr) { FillSolidRect(hDC, rect->left, rect->top, rect->right-rect->left, rect->bottom-rect->top, clr); }
void CodePreview::Update(int y, int line) { // Clear the back buffer and draw a border. RECT r = { 0, 0, m_wndWidth, m_wndHeight }; StrokeRect(m_paintDC, MetalBar::s_codePreviewFg, r); r.left = 1; r.right -= 1; r.top = 1; r.bottom -= 1; FillSolidRect(m_paintDC, MetalBar::s_codePreviewBg, r); // Draw the text with buffering, because calling ExtTextOut() at each character is way too slow. SetBkMode(m_paintDC, OPAQUE); int charsPerLine = (m_wndWidth - HORIZ_MARGIN*2) / s_charWidth; int numVisLines = (m_wndHeight-VERT_MARGIN*2) / s_lineHeight; numVisLines = std::min(numVisLines, m_imgNumLines); int startLine = (line - numVisLines / 2); startLine = clamp(startLine, 0, m_imgNumLines - numVisLines); std::vector<wchar_t> txtBuf; txtBuf.reserve(charsPerLine); int textY = VERT_MARGIN / 2; for(int line = startLine; line < startLine + numVisLines; ++line, textY += s_lineHeight) { int textX = HORIZ_MARGIN / 2; unsigned char currentFormat = FormatType_Plain; int bufX = textX; for(int col = 0; col < charsPerLine; ++col, textX += s_charWidth) { const CharInfo& info = m_text[line*charsPerLine + col]; if(info.format == FormatType_EOL) break; // Spaces can be merged with whatever format is currently active, except for highlight. if( (info.chr == L' ') && (currentFormat != FormatType_Highlight) ) { txtBuf.push_back(L' '); continue; } if(info.format != currentFormat) { FlushTextBuf(txtBuf, currentFormat, bufX, textY); currentFormat = info.format; bufX = textX; } txtBuf.push_back(info.chr); } FlushTextBuf(txtBuf, currentFormat, bufX, textY); } // Update the window position. y -= m_wndHeight / 2; y = clamp(y, m_parentYMin, m_parentYMax - m_wndHeight); int x = m_rightEdge - m_wndWidth - 10; SetWindowPos(m_hwnd, 0, x, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER); // Refresh. InvalidateRect(m_hwnd, 0, TRUE); UpdateWindow(m_hwnd); }
void CLogWnd::OnPaint(HDC hDC) { RECT rc; GetClientRect(m_hWnd, &rc); FillSolidRect(hDC, 0, 0, rc.right, SCY(1), m_clrBackgrLine); }