void EmoticonsSelectionLayout::DrawEmoticon(HDC hdc, int index, RECT fullRc) { Emoticon *e = ssd->module->emoticons[index]; int width, height; GetEmoticonSize(e, width, height); RECT rc = fullRc; rc.left += (rc.right - rc.left - width) / 2; rc.top += (rc.bottom - rc.top - height) / 2; rc.right = rc.left + width; rc.bottom = rc.top + height; if (e->img == NULL || e->img->img == NULL) { if (e->texts.getCount() > 0) { DrawEmoticonText(hdc, e->texts[0], rc); } else { DrawEmoticonText(hdc, e->description, rc); } } else { HDC hdc_img = CreateCompatibleDC(hdc); HBITMAP old_bmp = (HBITMAP) SelectObject(hdc_img, e->img->img); if (e->img->transparent) { BLENDFUNCTION bf = {0}; bf.SourceConstantAlpha = 255; bf.AlphaFormat = AC_SRC_ALPHA; AlphaBlend(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc_img, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf); } else { BitBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc_img, 0, 0, SRCCOPY); } SelectObject(hdc_img, old_bmp); DeleteDC(hdc_img); } if (selection == index) { rc = fullRc; rc.left -= 2; rc.right += 2; rc.top -= 2; rc.bottom += 2; FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH)); } }
void UpdateAdditionsWin(void) { Rect r; Cell c; int i; GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad + 1); HLock(gControls->cfg->selAddMsg); DrawString( CToPascal(*gControls->cfg->selAddMsg)); HUnlock(gControls->cfg->selAddMsg); #if 0 RGBColor backColorOld; Rect adjustedRect, *clRect = &gControls->aw->compListBox; SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1); GetBackColor(&backColorOld); BackColor(whiteColor); EraseRect(&adjustedRect); RGBBackColor(&backColorOld); #endif LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList); SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top, gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom); FrameRect(&r); SetPt(&c, 0, 0); if (LGetSelect(true, &c, gControls->aw->compList)) { HLock((Handle)gControls->aw->compDescTxt); SetRect(&r, (*gControls->aw->compDescTxt)->viewRect.left, (*gControls->aw->compDescTxt)->viewRect.top, (*gControls->aw->compDescTxt)->viewRect.right, (*gControls->aw->compDescTxt)->viewRect.bottom); HUnlock((Handle)gControls->aw->compDescTxt); TEUpdate(&r, gControls->aw->compDescTxt); } DrawDiskSpaceMsgs( gControls->opt->vRefNum ); for (i = 0; i < numRows; i++) { if (gControls->cfg->comp[rowToComp[i]].highlighted) { AddInitRowHighlight(i); break; } } SetPort(oldPort); }
static void draw_device_area( GDSpecPtr device_spec, GDHandle selected_device, Rect *frame) { Point offset; GDHandle device; get_device_area_offset(frame, &offset); EraseRect(frame); FrameRect(frame); for (device= GetDeviceList(); device; device= GetNextDevice(device)) { if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) { GDSpec spec; Rect bounds; BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); get_device_area_frame(device, &bounds, offset); RGBForeColor(HasDepthGDSpec(&spec) ? &rgb_dark_gray : &rgb_white); PaintRect(&bounds); RGBForeColor(&rgb_black); if (device==selected_device) PenSize(2, 2); FrameRect(&bounds); PenSize(1, 1); if (device==GetMainDevice()) { bounds.bottom= bounds.top + DEVICE_AREA_MENU_BAR_HEIGHT; EraseRect(&bounds); FrameRect(&bounds); } } } return; }
static void DrawPreview(HWND hwnd, HDC hdc) { BITMAPINFO bi; bi.bmiHeader.biSize = sizeof(bi.bmiHeader); bi.bmiHeader.biWidth = 8; bi.bmiHeader.biHeight = -8; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; HBITMAP hBmpBrush = CreateDIBSection(0, &bi, DIB_RGB_COLORS, 0, 0, 0); HDC dcBmp = CreateCompatibleDC(0); HBITMAP hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmpBrush); HBRUSH hbr = CreateSolidBrush(RGB(0xcc, 0xcc, 0xcc)); RECT rc; SetRect(&rc, 0, 0, 8, 8); FillRect(dcBmp, &rc, hbr); DeleteObject(hbr); hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff)); SetRect(&rc, 4, 0, 8, 4); FillRect(dcBmp, &rc, hbr); SetRect(&rc, 0, 4, 4, 8); FillRect(dcBmp, &rc, hbr); DeleteObject(hbr); SelectObject(dcBmp, hBmpSave); DeleteDC(dcBmp); GetClientRect(hwnd, &rc); hbr = CreatePatternBrush(hBmpBrush); SetBrushOrgEx(hdc, 1, 1, 0); FillRect(hdc, &rc, hbr); DeleteObject(hbr); DeleteObject(hBmpBrush); if (gPreviewOk) { int width = min(rc.right, wndPreview->getContent()->getWidth()); int height = min(rc.bottom, wndPreview->getContent()->getHeight()); int left = (rc.right - width) / 2; int top = (rc.bottom - height) / 2; BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = 255; bf.AlphaFormat = AC_SRC_ALPHA; AlphaBlend(hdc, left, top, width, height, wndPreview->getContent()->getDC(), 0, 0, width, height, bf); } FrameRect(hdc, &rc, GetStockBrush(LTGRAY_BRUSH)); }
HBRUSH CFocusCheckbox::CtlColor(CDC* pDC, UINT nCtlColor) { CRect r; GetClientRect(r); r.InflateRect(3, 1, 1, 1); FrameRect(pDC->m_hDC, r, GetSysColorBrush(COLOR_3DFACE)); if (GetFocus() == this) pDC->DrawFocusRect(r); // TODO: Return a non-NULL brush if the parent's handler should not be called return NULL; }
void CLCDMyProgressBar::OnDraw(CLCDGfxBase& rGfx) { // draw the border RECT r = { 0, 0, GetWidth(), GetHeight() }; FrameRect(rGfx.GetHDC(), &r, m_hBrush); // draw the progress switch (m_eMyStyle) { case STYLE_CURSOR: { int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, (float)1, (float)(GetWidth() - m_nCursorWidth - 1), m_fPos); r.left = nCursorPos; r.right = r.left + m_nCursorWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; case STYLE_FILLED_H: case STYLE_FILLED_V: { int nBar = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, 0.0f, (m_eMyStyle == STYLE_FILLED_H ? (float)GetWidth() : (float)GetHeight()) - 4, m_fPos); r.left = r.left + 2; r.bottom = r.bottom - 2; if (m_eMyStyle == STYLE_FILLED_H) { r.right = nBar + 2; r.top = r.top + 2; } else { r.right = r.right - 2; r.top = r.bottom - nBar; } FillRect(rGfx.GetHDC(), &r, m_hBrush); } break; case STYLE_DASHED_CURSOR: { int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax, (float)1, (float)(GetWidth() - m_nCursorWidth - 1), m_fPos); r.left = nCursorPos; r.right = r.left + m_nCursorWidth; FillRect(rGfx.GetHDC(), &r, m_hBrush); HPEN hOldPen = (HPEN)::SelectObject(rGfx.GetHDC(), m_hPen); ::MoveToEx(rGfx.GetHDC(), 0, (r.bottom - r.top) / 2, NULL); ::LineTo(rGfx.GetHDC(), nCursorPos, (r.bottom - r.top) / 2); ::SelectObject(rGfx.GetHDC(), hOldPen); } break; default: break; } }
LOCAL void PalPicker_Draw( HWND hWindow, HDC hDC ) /***********************************************************************/ { RECT ClientRect, rPatch; LPCOLORMAP lpColorMap; LPTR lpData; FRMTYPEINFO TypeInfo; int iWidth, iHeight, c, r, n; BYTE value; lpColorMap = PalPicker_GetColorMap(hWindow); if (lpColorMap) n = lpColorMap->NumEntries; else n = 256; // fill background with white GetClientRect(hWindow, &ClientRect); FillRect( hDC, &ClientRect, (HBRUSH)GetStockObject(WHITE_BRUSH) ); // frame the picker FrameRect(hDC, &ClientRect, (HBRUSH)GetStockObject(BLACK_BRUSH) ); InflateRect(&ClientRect, -3, -3); WindowsToAstralRect(&ClientRect); iWidth = RectWidth(&ClientRect); iHeight = RectHeight(&ClientRect); lpData = Alloc((long)iWidth); if (!lpData) return; if (lpColorMap) FrameSetTypeInfo(&TypeInfo, FDT_PALETTECOLOR, lpColorMap); else FrameSetTypeInfo(&TypeInfo, FDT_GRAYSCALE, NULL); value = 0; for (r = 0; r < 16; ++r) { for (c = 0; c < 16; ++c) { PalPicker_GetRect(hWindow, r, c, &rPatch); PalPicker_DrawPatch(hDC, &rPatch, value, TypeInfo, lpData); ++value; if (value >= n) break; } if (value >= n) break; } FreeUp(lpData); }
void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { if (nIDCtl != IDC_PLAYLIST) { return; } int nItem = lpDrawItemStruct->itemID; CRect rcItem = lpDrawItemStruct->rcItem; POSITION pos = FindPos(nItem); bool fSelected = pos == m_pl.GetPos(); CPlaylistItem& pli = m_pl.GetAt(pos); CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) { FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc)); FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31)); } else { FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW))); } COLORREF textcolor = fSelected ? 0xff : 0; if (pli.m_fInvalid) { textcolor |= 0xA0A0A0; } CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid"); CSize timesize(0, 0); CPoint timept(rcItem.right, 0); if (time.GetLength() > 0) { timesize = pDC->GetTextExtent(time); if ((3 + timesize.cx + 3) < rcItem.Width() / 2) { timept = CPoint(rcItem.right - (3 + timesize.cx + 3), (rcItem.top + rcItem.bottom - timesize.cy) / 2); pDC->SetTextColor(textcolor); pDC->TextOut(timept.x, timept.y, time); } } CString fmt, file; fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1 + m_pl.GetCount()) + 1); file.Format(fmt, nItem + 1, m_list.GetItemText(nItem, COL_NAME)); CSize filesize = pDC->GetTextExtent(file); while (3 + filesize.cx + 6 > timept.x && file.GetLength() > 3) { file = file.Left(file.GetLength() - 4) + _T("..."); filesize = pDC->GetTextExtent(file); } if (file.GetLength() > 3) { pDC->SetTextColor(textcolor); pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - filesize.cy) / 2, file); } }
INT_PTR CWipeProp::OnReceiveMsg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static COLORREF acrCustomClr[16]; switch (msg) { case WM_DRAWITEM: // Paint the color swatch if (wParam == IDC_SMPTE_COLOR) { HBRUSH solidBrush = CreateSolidBrush(m_dwBorderColor); DRAWITEMSTRUCT *pDraw = (DRAWITEMSTRUCT*)lParam; FillRect(pDraw->hDC, &pDraw->rcItem, solidBrush); FrameRect(pDraw->hDC, &pDraw->rcItem, (HBRUSH)GetStockObject(BLACK_BRUSH)); DeleteObject(solidBrush); return TRUE; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SMPTE_PICK_COLOR: { // Show the Choose Color dialog to pick a new color swatch CHOOSECOLOR cc; ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = m_hDlg; cc.lpCustColors = (LPDWORD)acrCustomClr; cc.Flags = CC_RGBINIT; cc.rgbResult = m_dwBorderColor; if (ChooseColor(&cc)) { m_dwBorderColor = cc.rgbResult; InvalidateRect(GetDlgItem(hDlg, IDC_SMPTE_COLOR), 0, FALSE); } } return TRUE; } // inner switch break; } // default return FALSE; }
int TLDisplay::DrawTitle(int x, int y, const char *title, RECT *rc, int pass, COLORREF *bgnd, COLORREF *txtcolor) { RECT r = {0,0,1,1}; RECT r2; int oy = yoffs + bmpH/2; SelectObject(bmpDC, hfont); // // if rc exists : only compute the rectangle & display the link // if((pass == 0) || (!rc)) { DrawText(bmpDC,title, strlen(title),&r,DT_CALCRECT); y = FindFreeYLevel(x, r.right + 2, y)*(LevelHeigth+Margin); y += oy; if(oy > y) { y -= TlineHalfH + TlineDecoH + Margin; } else { y += TlineHalfH + TlineDecoH + Margin; } r.left += x; r.top += y; r.right += x; r.bottom += y; if(rc) *rc = r; if(oy > r.bottom) DrawVArrow(r.left, r.bottom+1, oy); else DrawVArrow(r.left, r.top-1, oy); } if((pass > 0) || (!rc)) // display the stuff { if(rc) r = *rc; r2.left = r.left-1; r2.top = r.top-1; r2.right = r.right+1; r2.bottom = r.bottom+1; FrameRect(bmpDC, &r2, hbrush_frametxt); SetTextColor(bmpDC, txtcolor ? *txtcolor : TextColor); SetBkMode(bmpDC, OPAQUE); SetBkColor(bmpDC, bgnd ? *bgnd : TextBgndColor); DrawText(bmpDC,title, strlen(title),&r,DT_LEFT);//DT_CALCRECT); } return 0; }
// 画验证码 void CLoginDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { if (nIDCtl == m_verifyCodePicture.GetDlgCtrlID()) { FillRect(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, (HBRUSH)GetStockObject(WHITE_BRUSH)); if (!m_verifyImage.IsNull()) m_verifyImage.Draw(lpDrawItemStruct->hDC, lpDrawItemStruct->rcItem); FrameRect(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, (HBRUSH)GetStockObject(BLACK_BRUSH)); return; } CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); }
// // Draw a colour rectangle with border // void PaintFrameRect(HDC hdc, RECT *rect, COLORREF border, COLORREF fill) { HBRUSH hbrFill = CreateSolidBrush(fill); HBRUSH hbrBorder = CreateSolidBrush(border); FrameRect(hdc, rect, hbrBorder); InflateRect(rect, -1, -1); FillRect(hdc, rect, hbrFill); InflateRect(rect, 1, 1); DeleteObject(hbrFill); DeleteObject(hbrBorder); }
void draw_main_screen() { RECT draw_rect,big_rect = {-1,-1,582,414}; HBRUSH new_brush; COLORREF y = RGB(128,128,128);//y = RGB(119,119,119); // draw left buttons (always active) draw_lb(); // draw right buttons (only when not editing terrain) if (overall_mode >= 60) { draw_rect.left = RIGHT_AREA_UL_X; draw_rect.top = RIGHT_AREA_UL_Y; draw_rect.right = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH - 16; draw_rect.bottom = RIGHT_AREA_UL_Y + RIGHT_AREA_HEIGHT; //c = GetNearestPaletteIndex(hpal,y); new_brush = CreateSolidBrush(y); OffsetRect(&draw_rect,ulx,uly); FrameRect(main_dc,&draw_rect,new_brush); OffsetRect(&big_rect,ulx,uly); if (ulx > 40) FrameRect(main_dc,&big_rect,new_brush); DeleteObject(new_brush); InsetRect(&draw_rect,1,1); OffsetRect(&draw_rect,-1 * ulx,-1 * uly); paint_pattern(NULL,1,draw_rect,3); draw_rb(); } // draw terrain palette if ((overall_mode < 60) || (overall_mode == 62)) { place_location(); } }
void CBaseEventPropertiesDialog::DrawSpline( HDC hdc, HWND placeholder, CChoreoEvent *e ) { RECT rcOut; GetSplineRect( placeholder, rcOut ); HBRUSH bg = CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) ); FillRect( hdc, &rcOut, bg ); DeleteObject( bg ); if ( !e ) return; // Draw spline float range = ( float )( rcOut.right - rcOut.left ); if ( range <= 1.0f ) return; float height = ( float )( rcOut.bottom - rcOut.top ); HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNTEXT ) ); HPEN oldPen = (HPEN)SelectObject( hdc, pen ); float duration = e->GetDuration(); float starttime = e->GetStartTime(); for ( int i = 0; i < (int)range; i++ ) { float frac = ( float )i / ( range - 1 ); float scale = 1.0f - e->GetIntensity( starttime + frac * duration ); int h = ( int ) ( scale * ( height - 1 ) ); if ( i == 0 ) { MoveToEx( hdc, rcOut.left + i, rcOut.top + h, NULL ); } else { LineTo( hdc, rcOut.left + i, rcOut.top + h ); } } SelectObject( hdc, oldPen ); HBRUSH frame = CreateSolidBrush( GetSysColor( COLOR_BTNSHADOW ) ); InflateRect( &rcOut, 1, 1 ); FrameRect( hdc, &rcOut, frame ); DeleteObject( frame ); }
void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { if (nIDCtl != IDC_EDITLIST) { return; } int nItem = lpDrawItemStruct->itemID; CRect rcItem = lpDrawItemStruct->rcItem; POSITION pos = m_editList.FindIndex(nItem); if (pos) { bool fSelected = (pos == m_curPos); UNREFERENCED_PARAMETER(fSelected); CClip& curClip = m_editList.GetAt(pos); CString strTemp; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) { FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc)); FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31)); } else { FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW))); } COLORREF textcolor = RGB(0, 0, 0); if (!curClip.HaveIn() || !curClip.HaveOut()) { textcolor = RGB(255, 0, 0); } for (int i = 0; i < COL_MAX; i++) { m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem); pDC->SetTextColor(textcolor); switch (i) { case COL_INDEX: strTemp.Format(_T("%d"), nItem + 1); pDC->DrawText(strTemp, rcItem, DT_CENTER | DT_VCENTER); break; case COL_IN: pDC->DrawText(curClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER); break; case COL_OUT: pDC->DrawText(curClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER); break; case COL_NAME: pDC->DrawText(curClip.GetName(), rcItem, DT_LEFT | DT_VCENTER); break; } } } }
void slide_stamps(void) { int i; bitmap *b = thePort->portBMap; if (stamp_err) { stamp_err = 0; return; } HideCursor(); for (i = 2; i > 0; i--) { CopyBits(b, b, &stampingR[i - 1], &stampingR[i], &stampingR[i], zREPz); PenColor(WHITE); FrameRect(&stampingR[i]); } CopyBits(b, b, &stampR, &stampingR[0], &stampingR[0], zREPz); FrameRect(&stampingR[0]); ShowCursor(); }
int DrawMinButton(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, COLORREF clrBtn) { HBRUSH hBackBrush = CreateSolidBrush (clrBack); HBRUSH hBorderBrush = CreateSolidBrush (clrBorder); HBRUSH hBtBrush = CreateSolidBrush (clrBtn); int width = pRect->right - pRect->left; int height = pRect->bottom - pRect->top; RECT rc; rc.top = pRect->top + height * 1 /3 + height/5; rc.bottom = pRect->top + height * 2 /3 + height/4; rc.left = pRect->left + width*2/7 + 1; rc.right = pRect->right - width*2/7 - 1; FillRect(hdc, pRect, hBackBrush); FrameRect(hdc, pRect, hBorderBrush); FillRect(hdc, &rc, hBtBrush); FrameRect(hdc, &rc, hBorderBrush); DeleteObject(hBackBrush); DeleteObject(hBorderBrush); DeleteObject(hBtBrush); return 0; }
LOCAL void PalPicker_DrawFocus( HWND hWindow, HDC hDC ) /***********************************************************************/ { RECT ClientRect; BOOL fSetFocus; if ( !(GetWindowLong( hWindow, GWL_STYLE ) & WS_TABSTOP) ) return; fSetFocus = GetFocus() == hWindow; GetClientRect( hWindow, &ClientRect ); InflateRect( &ClientRect, -1, -1); FrameRect( hDC, &ClientRect, (HBRUSH)GetStockObject( fSetFocus ? BLACK_BRUSH : WHITE_BRUSH ) ); }
BOOL PaintBufferedRect(HDC hdc, LPRECT lprc, CUxThemeAeroImpl *pUx) { HDC hdcPaint = NULL; HPAINTBUFFER hBufferedPaint = pUx->BeginBufferedPaint(hdc, lprc, BPBF_TOPDOWNDIB, NULL, &hdcPaint); if (hdcPaint) { VERIFY(FrameRect(hdcPaint, lprc, (HBRUSH)GetStockObject(BLACK_BRUSH))); // Make every pixel opaque VERIFY(S_OK==pUx->BufferedPaintMakeOpaque_(hBufferedPaint, lprc)); VERIFY(S_OK==pUx->EndBufferedPaint(hBufferedPaint, TRUE)); } return TRUE; }
static void CreatePreview(TSelectorData *sd, TCHAR *fn, LPDRAWITEMSTRUCT lps) { HDC hdc = CreateCompatibleDC(lps->hDC); sd->hbmpPreview = CreateCompatibleBitmap(lps->hDC, lps->rcItem.right - lps->rcItem.left, lps->rcItem.bottom - lps->rcItem.top); SelectObject(hdc, sd->hbmpPreview); RECT rc; HBRUSH hbr; BITMAPINFO bi = {0}; bi.bmiHeader.biSize = sizeof(bi.bmiHeader); bi.bmiHeader.biWidth = 8; bi.bmiHeader.biHeight = -8; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; HBITMAP hBmpBrush = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, 0, 0, 0); HDC dcBmp = CreateCompatibleDC(0); HBITMAP hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmpBrush); hbr = CreateSolidBrush(RGB(0xcc, 0xcc, 0xcc)); SetRect(&rc, 0, 0, 8, 8); FillRect(dcBmp, &rc, hbr); DeleteObject(hbr); hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff)); SetRect(&rc, 4, 0, 8, 4); FillRect(dcBmp, &rc, hbr); SetRect(&rc, 0, 4, 4, 8); FillRect(dcBmp, &rc, hbr); DeleteObject(hbr); SelectObject(dcBmp, hBmpSave); DeleteDC(dcBmp); rc = lps->rcItem; OffsetRect(&rc, -rc.left, -rc.top); hbr = CreatePatternBrush(hBmpBrush); SetBrushOrgEx(hdc, 1, 1, 0); FillRect(hdc, &rc, hbr); DeleteObject(hbr); DeleteObject(hBmpBrush); HDC hdcSave = lps->hDC; lps->hDC = hdc; sttPreviewSkin(sd->obj, fn, lps); lps->hDC = hdcSave; FrameRect(hdc, &rc, GetStockBrush(LTGRAY_BRUSH)); DeleteDC(hdc); }
/*------------------------------------------------ WM_DRAWITEM message --------------------------------------------------*/ void OnDrawItem(LPARAM lParam) { LPDRAWITEMSTRUCT pDis; HBRUSH hbr; COLORREF col; RECT rc; int cxicon, cyicon; pDis = (LPDRAWITEMSTRUCT)lParam; switch(pDis->itemAction) { case ODA_DRAWENTIRE: case ODA_SELECT: { if(pDis->itemState & ODS_SELECTED) col = GetSysColor(COLOR_HIGHLIGHT); else col = GetSysColor(COLOR_WINDOW); hbr = CreateSolidBrush(col); FillRect(pDis->hDC, &pDis->rcItem, hbr); DeleteObject(hbr); if(!(pDis->itemState & ODS_FOCUS)) break; } case ODA_FOCUS: { if(pDis->itemState & ODS_FOCUS) col = GetSysColor(COLOR_WINDOWTEXT); else col = GetSysColor(COLOR_WINDOW); hbr = CreateSolidBrush(col); FrameRect(pDis->hDC, &pDis->rcItem, hbr); DeleteObject(hbr); break; } } if(pDis->itemData == 0) return; cxicon = GetSystemMetrics(SM_CXSMICON); cyicon = GetSystemMetrics(SM_CYSMICON); CopyRect(&rc, &(pDis->rcItem)); DrawIconEx(pDis->hDC, rc.left + (rc.right - rc.left - cxicon)/2, rc.top + (rc.bottom - rc.top - cyicon)/2, (HICON)pDis->itemData, cxicon, cyicon, 0, NULL, DI_NORMAL); }
void LCD_doframeRect(Lcd *x, Symbol *s, short argc, Atom *argv) { PaletteHandle pH; RGBColor fColor; GrafPort *gp; RgnHandle cur; Rect b,r; long left, top, right, bottom, color; EnterCallback(); left = argv->a_w.w_long; top = (argv+1)->a_w.w_long; right = (argv+2)->a_w.w_long; bottom = (argv+3)->a_w.w_long; color = (argv+4)->a_w.w_long; #ifdef debug post("frameRect"); #endif gp = patcher_setport(x->lcd_box.b_patcher); if (gp) { if (!box_nodraw((void *)x)) { if (color) // sde 11/1 x->lcd_pIndex = (short)color & (numPaletteColors-1); cur = NewRgn(); GetClip(cur); SetClip(x->lcd_region); setUpPalette(x,&fColor,&pH); r = x->lcd_box.b_rect; b.left = r.left + (short)left; b.top = r.top + (short)top; b.right = r.left + (short)right; b.bottom = r.top + (short)bottom; FrameRect(&b); restorePalette(x,&fColor,&pH); SetClip(cur); DisposeRgn(cur); } SetPort(gp); } ExitCallback(); }
void box_d_item(DialogPtr dp, short item) { Rect r; Handle h; short itemType; GetDItem (dp, item, &itemType, &h, &r); PenNormal (); PenSize (2, 2); InsetRect (&r, -2, -2); FrameRect (&r); PenNormal (); }
/* ================ ColorButton_DrawItem Draws the actual color button as as reponse to a WM_DRAWITEM message ================ */ void ColorButton_DrawItem( HWND hWnd, LPDRAWITEMSTRUCT dis ) { assert( dis ); HDC hDC = dis->hDC; UINT state = dis->itemState; RECT rDraw = dis->rcItem; RECT rArrow; // Draw outter edge UINT uFrameState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT; if( state & ODS_SELECTED ) { uFrameState |= DFCS_PUSHED; } if( state & ODS_DISABLED ) { uFrameState |= DFCS_INACTIVE; } DrawFrameControl( hDC, &rDraw, DFC_BUTTON, uFrameState ); // Draw Focus if( state & ODS_SELECTED ) { OffsetRect( &rDraw, 1, 1 ); } if( state & ODS_FOCUS ) { RECT rFocus = {rDraw.left, rDraw.top, rDraw.right - 1, rDraw.bottom }; DrawFocusRect( hDC, &rFocus ); } InflateRect( &rDraw, -GetSystemMetrics( SM_CXEDGE ), -GetSystemMetrics( SM_CYEDGE ) ); // Draw the arrow rArrow.left = rDraw.right - ARROW_SIZE_CX - GetSystemMetrics( SM_CXEDGE ) / 2; rArrow.right = rArrow.left + ARROW_SIZE_CX; rArrow.top = ( rDraw.bottom + rDraw.top ) / 2 - ARROW_SIZE_CY / 2; rArrow.bottom = ( rDraw.bottom + rDraw.top ) / 2 + ARROW_SIZE_CY / 2; ColorButton_DrawArrow( hDC, &rArrow, ( state & ODS_DISABLED ) ? ::GetSysColor( COLOR_GRAYTEXT ) : RGB( 0, 0, 0 ) ); rDraw.right = rArrow.left - GetSystemMetrics( SM_CXEDGE ) / 2; // Draw separator DrawEdge( hDC, &rDraw, EDGE_ETCHED, BF_RIGHT ); rDraw.right -= ( GetSystemMetrics( SM_CXEDGE ) * 2 ) + 1 ; // Draw Color if( ( state & ODS_DISABLED ) == 0 ) { HBRUSH color = CreateSolidBrush( ( COLORREF )GetWindowLong( hWnd, GWL_USERDATA ) ); FillRect( hDC, &rDraw, color ); FrameRect( hDC, &rDraw, ( HBRUSH )::GetStockObject( BLACK_BRUSH ) ); DeleteObject( color ); } }
BOOL pascal DownloadProgress(DCProgressStatus Status, short PercentComplete, DCProgressType Type, long RefCon) { HDC hDC; char report[80]; RECT outline; HBRUSH DrawBrush; hDC=GetDC(MainWnd); SetBkMode(hDC,OPAQUE); SetBkColor(hDC,RGB(255,255,255)); if (PercentComplete == 0) { DrawBrush=CreateSolidBrush(RGB(255,255,255)); outline.left=0; outline.right=385; outline.top=0; outline.bottom=25; FillRect(hDC,&outline,DrawBrush); DeleteObject(DrawBrush); } outline.top=26; outline.bottom=154; if (DownloadSide == 0) { outline.left=16; outline.right=184; } else { outline.left=206; outline.right=374; } if (PercentComplete%5 == 0) { if ((Type == DCImageProcess && PercentComplete%20 == 0) || (Type == DCTransferImage && PercentComplete%10 == 0)) DrawBrush=CreateSolidBrush(RGB(0,0,0)); else DrawBrush=CreateSolidBrush(RGB(255,255,255)); FrameRect(hDC,&outline,DrawBrush); DeleteObject(DrawBrush); } if (Type == DCTransferImage) sprintf(report,"Downloading %3d%%",PercentComplete); else /* Type == DCImageProcess */ sprintf(report,"Decompressing %3d%%",PercentComplete); TextOut(hDC,0,0,report,strlen(report)); ReleaseDC(MainWnd,hDC); return(TRUE); }
int disk_error_handler(int errval, int ax, int bp, int si) { rect R, R2; char tbuf[128]; int err; int centerx = sR.Xmax / 2; int centery = sR.Ymax / 2; int height = 2 * FontHeight + 10; int width = sR.Xmax / 2; R.Xmin = sR.Xmax / 4; R.Xmax = R.Xmin + width; R.Ymin = centery - height / 2; R.Ymax = R.Ymin + height; PushRect(&R, &err); if (ax < 0) sprintf(tbuf, "Device error %x: %x %p", errval, ax, MK_FP(bp, si)); else sprintf(tbuf, "Disk error on drive %c", 'A' + (ax & 0xff)); PenColor(MENUBACK); PaintRect(&R); PenColor(MENUTEXT); BackColor(MENUBACK); R2 = R; InsetRect(&R2, 2, 2); FrameRect(&R2); TextAlign(alignCenter, alignTop); MoveTo(centerx, R.Ymin + 4); DrawString(tbuf); MoveTo(centerx, R.Ymin + FontHeight + 4); DrawString("Hit any key to continue"); getch(); PopRect(&err); hardretn(-1); #pragma warn -rvl }
static void MyUserPaneDrawProc(ControlRef control, SInt16 part) { // we now use a User Pane Control instead of a dialog user item // the draw, hit test, and track are more separated Rect bounds; GetControlBounds(control, &bounds); PenSize(3, 3); if (!IsControlActive(control)) { RGBColor gray = {32767, 32767, 32767}; RGBForeColor(&gray); } FrameRect(&bounds); Rect userRect = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; PaintRect(&userRect); }
int DrawMaxButton(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, COLORREF clrBtn, int isZoomed) { HBRUSH hBackBrush = CreateSolidBrush (clrBack); HBRUSH hBorderBrush = CreateSolidBrush (clrBorder); HBRUSH hBtBrush = CreateSolidBrush (clrBtn); int width = pRect->right - pRect->left; int height = pRect->bottom - pRect->top; RECT rc1, rc2; rc1.top = pRect->top + height/5; rc1.bottom = pRect->top + height * 2 /3 + height/4; rc1.left = pRect->left + width*2/7; rc1.right = pRect->right - width*2/7; rc2 = rc1; rc2.top += 3; rc2.bottom -= 3; rc2.left += 3; rc2.right -= 3; FillRect(hdc, pRect, hBackBrush); FrameRect(hdc, pRect, hBorderBrush); if (isZoomed){ OffsetRect(&rc1, 3, -1); OffsetRect(&rc2, 3, -1); FillRect(hdc, &rc1, hBtBrush); FrameRect(hdc, &rc1, hBorderBrush); FillRect(hdc, &rc2, hBackBrush); FrameRect(hdc, &rc2, hBorderBrush); OffsetRect(&rc1, -4, 3); OffsetRect(&rc2, -4, 3); FillRect(hdc, &rc1, hBtBrush); FrameRect(hdc, &rc1, hBorderBrush); FillRect(hdc, &rc2, hBackBrush); FrameRect(hdc, &rc2, hBorderBrush); }else{ FillRect(hdc, &rc1, hBtBrush); FrameRect(hdc, &rc1, hBorderBrush); FillRect(hdc, &rc2, hBackBrush); FrameRect(hdc, &rc2, hBorderBrush); } DeleteObject(hBackBrush); DeleteObject(hBorderBrush); DeleteObject(hBtBrush); return 0; }
BOOL dpi_Rectangle(HDC hdc, double left, double top, double right, double bottom) { int l, t, r, b; RECT rect; l = (int)floor(left * dpi); t = (int)floor(top * dpi); r = (int)floor(right * dpi); b = (int)floor(bottom * dpi); if (r - l == 0) r = l + 1; if (b - t == 0) b = t + 1; rect.left = l; rect.top = t; rect.bottom = b; rect.right = r; return FrameRect(hdc, &rect, 0); }
TS_DefaultOnPaint(TS* ts) { HWND hwnd = HWND_FROM_TS(ts); PAINTSTRUCT ps; HDC hdc; RECT rect; int i; int height; COLORREF normal_text = GetSysColor(COLOR_WINDOWTEXT); COLORREF hilite_text = GetSysColor(COLOR_HIGHLIGHTTEXT); hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); FillRect(hdc, &rect, GetSysColorBrush(COLOR_WINDOW)); FrameRect(hdc, &rect, GetSysColorBrush(COLOR_WINDOWFRAME)); height = (rect.bottom - 2 - 2) / g_TaskList->count - 1 - 1; rect.left += 2; rect.top += 2; rect.right -= 2; rect.bottom -= 2; SetTextColor(hdc, normal_text); SetBkMode(hdc, TRANSPARENT); for (i = 0; i < g_TaskList->count; i++) { rect.top += 1; if (i == g_TaskList->selected_task_index) { RECT r = rect; SetTextColor(hdc, hilite_text); r.bottom = rect.top + height; FillRect(hdc, &r, GetSysColorBrush(COLOR_HIGHLIGHT)); } DrawText( hdc, g_TaskList->list[i]->title, -1, &rect, DT_NOPREFIX | DT_SINGLELINE ); if (i == g_TaskList->selected_task_index) SetTextColor(hdc, normal_text); rect.top += height + 1; } EndPaint(hwnd, &ps); return 0; }