/*********************************************************************** * UPDOWN_Draw * * Draw the arrows. The background need not be erased. */ static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc) { BOOL uPressed, uHot, dPressed, dHot; RECT rect; HTHEME theme = GetWindowTheme (infoPtr->Self); int uPart = 0, uState = 0, dPart = 0, dState = 0; BOOL needBuddyBg = FALSE; uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR); uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN); dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR); dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN); if (theme) { uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP; uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL)); dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN; dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL)); needBuddyBg = IsWindow (infoPtr->Buddy) && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState) || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState)); } /* Draw the common border between ourselves and our buddy */ if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) { if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) { GetClientRect(infoPtr->Self, &rect); DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_BOTTOM | BF_TOP | (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT)); } } /* Draw the incr button */ UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR); if (theme) { DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL); } else { DrawFrameControl(hdc, &rect, DFC_SCROLL, (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) | ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) | (uPressed ? DFCS_PUSHED : 0) | (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); } /* Draw the decr button */ UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR); if (theme) { DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL); } else { DrawFrameControl(hdc, &rect, DFC_SCROLL, (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) | ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) | (dPressed ? DFCS_PUSHED : 0) | (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); } return 0; }
/* paint the combobox */ static LRESULT paint (HTHEME theme, HWND hwnd, HDC hParamDC, ULONG state) { PAINTSTRUCT ps; HDC hDC; COMBOBOXINFO cbi; DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); hDC = (hParamDC) ? hParamDC : BeginPaint( hwnd, &ps); TRACE("hdc=%p\n", hDC); if( hDC && !(state & STATE_NOREDRAW) ) { RECT frameRect; int buttonState; cbi.cbSize = sizeof (cbi); SendMessageW (hwnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbi); /* paint border */ if ((dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE) GetClientRect (hwnd, &frameRect); else { CopyRect (&frameRect, &cbi.rcItem); InflateRect(&frameRect, EDIT_CONTROL_PADDING + COMBO_XBORDERSIZE, EDIT_CONTROL_PADDING + COMBO_YBORDERSIZE); } DrawThemeBackground (theme, hDC, 0, IsWindowEnabled (hwnd) ? CBXS_NORMAL : CBXS_DISABLED, &frameRect, NULL); /* paint button */ if (cbi.stateButton != STATE_SYSTEM_INVISIBLE) { if (!IsWindowEnabled (hwnd)) buttonState = CBXS_DISABLED; else if (cbi.stateButton == STATE_SYSTEM_PRESSED) buttonState = CBXS_PRESSED; else if (state & STATE_HOT) buttonState = CBXS_HOT; else buttonState = CBXS_NORMAL; DrawThemeBackground (theme, hDC, CP_DROPDOWNBUTTON, buttonState, &cbi.rcButton, NULL); } /* paint text, if we need to */ if ((dwStyle & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST) paint_text (hwnd, hDC, dwStyle, &cbi); } if( !hParamDC ) EndPaint(hwnd, &ps); return 0; }
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); } }
static void STATUSBAR_RefreshPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID) { HBRUSH hbrBk; HTHEME theme; TRACE("item %d\n", itemID); if (part->bound.right < part->bound.left) return; if (!RectVisible(hdc, &part->bound)) return; if ((theme = GetWindowTheme (infoPtr->Self))) { RECT cr; GetClientRect (infoPtr->Self, &cr); DrawThemeBackground(theme, hdc, 0, 0, &cr, &part->bound); } else { if (infoPtr->clrBk != CLR_DEFAULT) hbrBk = CreateSolidBrush (infoPtr->clrBk); else hbrBk = GetSysColorBrush (COLOR_3DFACE); FillRect(hdc, &part->bound, hbrBk); if (infoPtr->clrBk != CLR_DEFAULT) DeleteObject (hbrBk); } STATUSBAR_DrawPart (infoPtr, hdc, part, itemID); }
static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused) { static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL }; RECT bgRect, textRect, contentRect; int state = states[ drawState ]; WCHAR *text = get_button_text(hwnd); LOGFONTW lf; HFONT font, hPrevFont = NULL; BOOL created_font = FALSE; HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf); if (SUCCEEDED(hr)) { font = CreateFontIndirectW(&lf); if (!font) TRACE("Failed to create font\n"); else { hPrevFont = SelectObject(hDC, font); created_font = TRUE; } } else { font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); hPrevFont = SelectObject(hDC, font); } GetClientRect(hwnd, &bgRect); textRect = bgRect; if (text) { SIZE textExtent; GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent); bgRect.top += (textExtent.cy / 2); textRect.left += 10; textRect.bottom = textRect.top + textExtent.cy; textRect.right = textRect.left + textExtent.cx + 4; ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom); } GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect); ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom); if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state)) DrawThemeParentBackground(hwnd, hDC, NULL); DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL); SelectClipRgn(hDC, NULL); if (text) { InflateRect(&textRect, -2, 0); DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect); HeapFree(GetProcessHeap(), 0, text); } if (created_font) DeleteObject(font); if (hPrevFont) SelectObject(hDC, hPrevFont); }
LRESULT CPanel::OnPaint(UINT, WPARAM,LPARAM,BOOL&) { CPaintDC dc(m_hWnd); CRect r; GetClientRect(&r); CRgn rgn; HRGN oldRgn=NULL; if(roundCorners) { rgn.CreateRoundRectRgn(r.left,r.top,r.right,r.bottom,cornerParam.x,cornerParam.y); dc.SelectClipRgn(rgn); } if(m_hTheme == NULL || theme == FALSE) { if(enableGradient==FALSE) dc.FillSolidRect(&r,bkColor); else gradientRender.DrawGradient(dc,r,startColor,endColor,gradientType,transformationType); } else DrawThemeBackground(dc,TABP_BODY,0,&r,NULL); //DrawThemeBackground(dc,BP_PUSHBUTTON,0,&r,NULL); if(!caption.IsEmpty()) { CFont oldFont=dc.SelectFont(font); COLORREF tc=dc.SetTextColor(textColor); int bkm=dc.SetBkMode(TRANSPARENT); dc.DrawText(caption,caption.GetLength(),r,vertAlign|horizAlign|singleLine); dc.SetTextColor(tc); dc.SetBkMode(bkm); dc.SelectFont(oldFont); } if(m_hTheme == NULL || theme == FALSE) { if(roundCorners==FALSE) { dc.DrawEdge(&r,inner|outer,edge); } else { dc.SelectClipRgn(NULL); CPen pen; HBRUSH oldBrush = dc.SelectStockBrush(NULL_BRUSH); pen.CreatePen(PS_INSIDEFRAME,1,borderColor); HPEN oldpen=dc.SelectPen(pen); dc.RoundRect(r,cornerParam); dc.SelectPen(oldpen); dc.SelectBrush(oldBrush); } } else DrawThemeEdge(dc,TABP_BODY,0,&r,inner|outer,edge); //DrawThemeEdge(dc,BP_PUSHBUTTON,0,&r,inner|outer,edge); return 0; }
static void themeImage(HDC dc, RECT *r, int cbState, HTHEME theme) { HRESULT res; res = DrawThemeBackground(theme, dc, BP_CHECKBOX, themestates[cbState], r, NULL); if (res != S_OK) xpanichresult("error drawing checkbox image", res); }
HRESULT xpt_DrawThemeBackground(XPTHANDLE xptHandle, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect) { mir_cslock lck(xptCS); if (xpt_IsThemed(xptHandle)) return DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect); return S_FALSE; }
static void STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect) { HPEN hPenFace, hPenShadow, hPenHighlight, hOldPen; POINT pt; INT i; TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); if (theme) { RECT gripperRect; SIZE gripperSize; gripperRect = *lpRect; if (SUCCEEDED (GetThemePartSize (theme, hdc, SP_GRIPPER, 0, lpRect, TS_DRAW, &gripperSize))) { gripperRect.left = gripperRect.right - gripperSize.cx; gripperRect.top = gripperRect.bottom - gripperSize.cy; if (SUCCEEDED (DrawThemeBackground(theme, hdc, SP_GRIPPER, 0, &gripperRect, NULL))) return; } } pt.x = lpRect->right - 1; pt.y = lpRect->bottom - 1; hPenFace = CreatePen( PS_SOLID, 1, comctl32_color.clr3dFace); hOldPen = SelectObject( hdc, hPenFace ); MoveToEx (hdc, pt.x - 12, pt.y, NULL); LineTo (hdc, pt.x, pt.y); LineTo (hdc, pt.x, pt.y - 13); pt.x--; pt.y--; hPenShadow = CreatePen( PS_SOLID, 1, comctl32_color.clr3dShadow); SelectObject( hdc, hPenShadow ); for (i = 1; i < 11; i += 4) { MoveToEx (hdc, pt.x - i, pt.y, NULL); LineTo (hdc, pt.x + 1, pt.y - i - 1); MoveToEx (hdc, pt.x - i - 1, pt.y, NULL); LineTo (hdc, pt.x + 1, pt.y - i - 2); } hPenHighlight = CreatePen( PS_SOLID, 1, comctl32_color.clr3dHilight); SelectObject( hdc, hPenHighlight ); for (i = 3; i < 13; i += 4) { MoveToEx (hdc, pt.x - i, pt.y, NULL); LineTo (hdc, pt.x + 1, pt.y - i - 1); } SelectObject (hdc, hOldPen); DeleteObject( hPenFace ); DeleteObject( hPenShadow ); DeleteObject( hPenHighlight ); }
HRESULT xpt_DrawThemeBackground(XPTHANDLE xptHandle, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect) { HRESULT res = S_FALSE; xptlock(); if (xpt_IsThemed(xptHandle)) res = DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect); xptunlock(); return res; }
static void SCROLL_ThemeDrawPart(PDRAW_CONTEXT pcontext, int iPartId,int iStateId, SCROLLBARINFO* psbi, int htCurrent, int htDown, int htHot, RECT* r) { if(psbi->rgstate[htCurrent] & STATE_SYSTEM_UNAVAILABLE) iStateId += BUTTON_DISABLED - BUTTON_NORMAL; else if (htHot == htCurrent) iStateId += BUTTON_HOT - BUTTON_NORMAL; else if (htDown == htCurrent) iStateId += BUTTON_PRESSED - BUTTON_NORMAL; DrawThemeBackground(pcontext->scrolltheme, pcontext->hDC, iPartId, iStateId, r, NULL); }
void LTIndefProgressBar::VerifyBuffers( CDC* pDC ) { CRect rClientEx; GetClientRect(rClientEx); if (!p_BarBack) { p_BarBack = LTBitmapBuffer::Create(pDC, rClientEx.Width(),rClientEx.Height()); DrawThemeBackground(h_ThemeBar, p_BarBack->GetDC()->m_hDC, PP_BAR, 0, rClientEx, rClientEx); } if (!p_BarSlot) { CRect rSlot = rClientEx; rSlot.right = rSlot.left + SLOT_WIDTH; p_BarSlot = LTBitmapBuffer::Create(pDC, rSlot.Width(), rClientEx.Height()); DrawThemeBackground(h_ThemeBar, p_BarSlot->GetDC()->m_hDC, PP_FILL, PBFS_PARTIAL, rSlot, rSlot); } }
/*********************************************************************** * UPDOWN_DrawBuddyBackground * * Draw buddy background for visual integration. */ static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc) { RECT br; HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy); if (!buddyTheme) return FALSE; GetClientRect (infoPtr->Buddy, &br); MapWindowPoints (infoPtr->Buddy, infoPtr->Self, (POINT*)&br, 2); /* FIXME: take disabled etc. into account */ DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL); return TRUE; }
static void STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID) { RECT r = part->bound; UINT border = BDR_SUNKENOUTER; HTHEME theme = GetWindowTheme (infoPtr->Self); int themePart = SP_PANE; int x = 0; TRACE("part bound %s\n", wine_dbgstr_rect(&r)); if (part->style & SBT_POPOUT) border = BDR_RAISEDOUTER; else if (part->style & SBT_NOBORDERS) border = 0; if (theme) { if ((GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) && (infoPtr->simple || (itemID == (infoPtr->numParts-1)))) themePart = SP_GRIPPERPANE; DrawThemeBackground(theme, hdc, themePart, 0, &r, NULL); } else DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST); if (part->hIcon) { INT cy = r.bottom - r.top; DrawIconEx (hdc, r.left + 2, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); x = 2 + cy; } if (part->style & SBT_OWNERDRAW) { DRAWITEMSTRUCT dis; dis.CtlID = GetWindowLongPtrW (infoPtr->Self, GWLP_ID); dis.itemID = itemID; dis.hwndItem = infoPtr->Self; dis.hDC = hdc; dis.rcItem = r; dis.itemData = (ULONG_PTR)part->text; SendMessageW (infoPtr->Notify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis); } else { r.left += x; #ifdef __REACTOS__ if (!theme) DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS); else DrawThemeText(theme, hdc, SP_PANE, 0, part->text, -1, DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX, 0, &r); #else DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS); #endif } }
HRESULT xpt_DrawTheme(XPTHANDLE xptHandle, HWND hwnd, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect) { mir_cslock lck(xptCS); if (xpt_IsThemed(xptHandle)) { if (IsThemeBackgroundPartiallyTransparent(((XPTObject*)xptHandle)->hThemeHandle, type, state)) { DrawThemeParentBackground(hwnd, hdc, sizeRect); return DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect); } } return S_FALSE; }
void track_bar_impl::draw_channel (HDC dc, const RECT * rc) const { if (get_theme_handle()) { DrawThemeBackground(get_theme_handle(), dc, get_orientation() ? TKP_TRACKVERT : TKP_TRACK, TUTS_NORMAL, rc, 0); } else { RECT rc_temp = *rc; DrawEdge (dc, &rc_temp, EDGE_SUNKEN, BF_RECT); } }
/******************************************** DrawBackground Purpose Provides a more straightforward way to draw a background by wrapping all the calls required into the dll, as well as using our theme data mappings to find the core info required. Params hwnd - the HWND of the control we draw to, or NUL hdc - the device context for the dll to draw to type - the cell type we want to draw state - the state of the cell we want to draw pRect - represents the area we want to draw to pClipRect - is exposed, but is almost always NULL Return A bool to indicate success or failure, which is used to control drawing in the old style throughout the library *********************************************/ bool UGXPThemes::DrawBackground(HWND hwnd, HDC hdc, UGXPCellType type, UGXPThemeState state, const RECT *pRect, const RECT *pClipRect) { bool success = false; if (useThemes) { UGThemeData * td = LookupThemeData(type, state); if (!td) { return false; } HANDLE hTheme = OpenThemeData(hwnd, td->GetThemeName()); if(hTheme) { // If the background is transparent, we draw using the Data cell type first, // which fills the background. DrawThemeParentBackground just plain does not work // for us, perhaps because the parent is an owner drawn control ? // Of course, if the Data cell type has transparency, all we can do is return E_FAILED if (IsThemeBackgroundPartiallyTransparent(hTheme, td->GetPartID(), td->GetStateID())) { if (type == XPCellTypeData) return FALSE; UGThemeData * tdCell = LookupThemeData(XPCellTypeData, (state == ThemeStatePressed || state == ThemeStateTriState) ? ThemeStateNormal : state); HANDLE hThemeCell = OpenThemeData(hwnd, tdCell->GetThemeName()); DrawThemeBackground(hThemeCell, hdc, tdCell->GetPartID(), tdCell->GetStateID(), pRect, pClipRect); } success = SUCCEEDED(DrawThemeBackground(hTheme, hdc, td->GetPartID(), td->GetStateID(), pRect, pClipRect)); // CloseThemeData(hTheme); } } return success; }
static void CB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags) { static const int cb_states[3][5] = { { CBS_UNCHECKEDNORMAL, CBS_UNCHECKEDDISABLED, CBS_UNCHECKEDHOT, CBS_UNCHECKEDPRESSED, CBS_UNCHECKEDNORMAL }, { CBS_CHECKEDNORMAL, CBS_CHECKEDDISABLED, CBS_CHECKEDHOT, CBS_CHECKEDPRESSED, CBS_CHECKEDNORMAL }, { CBS_MIXEDNORMAL, CBS_MIXEDDISABLED, CBS_MIXEDHOT, CBS_MIXEDPRESSED, CBS_MIXEDNORMAL } }; static const int rb_states[2][5] = { { RBS_UNCHECKEDNORMAL, RBS_UNCHECKEDDISABLED, RBS_UNCHECKEDHOT, RBS_UNCHECKEDPRESSED, RBS_UNCHECKEDNORMAL }, { RBS_CHECKEDNORMAL, RBS_CHECKEDDISABLED, RBS_CHECKEDHOT, RBS_CHECKEDPRESSED, RBS_CHECKEDNORMAL } }; static const int cb_size = 13; RECT bgRect, textRect; HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL; LRESULT checkState = SendMessageW(hwnd, BM_GETCHECK, 0, 0); DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE); int part = ((dwStyle & BUTTON_TYPE) == BS_RADIOBUTTON) || ((dwStyle & BUTTON_TYPE) == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX; int state = (part == BP_CHECKBOX) ? cb_states[ checkState ][ drawState ] : rb_states[ checkState ][ drawState ]; WCHAR *text = get_button_text(hwnd); GetClientRect(hwnd, &bgRect); GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect); if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */ bgRect.top = bgRect.top + (textRect.bottom - textRect.top - cb_size) / 2; /* adjust for the check/radio marker */ bgRect.bottom = bgRect.top + cb_size; bgRect.right = bgRect.left + cb_size; textRect.left = bgRect.right + 6; if (IsThemeBackgroundPartiallyTransparent(theme, part, state)) DrawThemeParentBackground(hwnd, hDC, NULL); DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL); if (text) { DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect); HeapFree(GetProcessHeap(), 0, text); } if (hPrevFont) SelectObject(hDC, hPrevFont); }
static LRESULT STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) { RECT rect; HBRUSH hbrBk; HFONT hOldFont; HTHEME theme; TRACE("\n"); if (!IsWindowVisible(infoPtr->Self)) return 0; STATUSBAR_SetPartBounds(infoPtr); GetClientRect (infoPtr->Self, &rect); if ((theme = GetWindowTheme (infoPtr->Self))) { DrawThemeBackground(theme, hdc, 0, 0, &rect, NULL); } else { if (infoPtr->clrBk != CLR_DEFAULT) hbrBk = CreateSolidBrush (infoPtr->clrBk); else hbrBk = GetSysColorBrush (COLOR_3DFACE); FillRect(hdc, &rect, hbrBk); if (infoPtr->clrBk != CLR_DEFAULT) DeleteObject (hbrBk); } hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont); if (infoPtr->simple) { STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0); } else { unsigned int i; for (i = 0; i < infoPtr->numParts; i++) { STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i); } } SelectObject (hdc, hOldFont); if ((GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) && !(GetWindowLongW (infoPtr->Notify, GWL_STYLE) & WS_MAXIMIZE)) STATUSBAR_DrawSizeGrip (theme, hdc, &rect); return 0; }
/******************************************** DrawBackground Purpose Provides a more straightforward way to draw a background by wrapping all the calls required into the dll, as well as using our theme data mappings to find the core info required. This version still takes a theme name instead of using our lookup table, it's used in cases where we hard code the theme part ( such a progress bars ) Params hwnd - the HWND of the control we draw to, or NUL hdc - the device context for the dll to draw to theme - the name of the theme to use iPartId - the theme part to draw iStateId - the state of the part to draw pRect - represents the area we want to draw to pClipRect - is exposed, but is almost always NULL Return A bool to indicate success or failure, which is used to control drawing in the old style throughout the library *********************************************/ bool UGXPThemes::DrawBackground(HWND hwnd, HDC hdc, LPCWSTR theme, int partID, int stateID, const RECT *pRect, const RECT *pClipRect, bool useCache) { bool success = false; if (useThemes) { HANDLE themeHandle = OpenThemeData(hwnd, theme, useCache); if (themeHandle) { // If the background is transparent, we draw using the Data cell type first, // which fills the background. DrawThemeParentBackground just plain does not work // for us, perhaps because the parent is an owner drawn control ? // Of course, if the Data cell type has transparency, this will fail. if (IsThemeBackgroundPartiallyTransparent(themeHandle, partID, stateID)) { //RECT temp = *pRect; UGThemeData * tdCell = LookupThemeData(XPCellTypeData, ThemeStateNormal); HANDLE hThemeCell = OpenThemeData(hwnd, tdCell->GetThemeName()); DrawThemeBackground(hThemeCell, hdc, partID, stateID, pRect, pClipRect); } HRESULT hr = DrawThemeBackground(themeHandle, hdc, partID, stateID, pRect, pClipRect); success = SUCCEEDED(hr); if (!useCache) { CloseThemeData(themeHandle); } } } return success; }
void drawBackground( int pId = 0, int sId = 0 ) { if ( pId ) partId = pId; if ( sId ) stateId = sId; if ( name && name == "TAB" && ( partId == TABP_TABITEMLEFTEDGE || partId == TABP_TABITEMRIGHTEDGE || partId == TABP_TABITEM ) ) { QRect oldrec = rec; rec = QRect( 0, 0, rec.width(), rec.height() ); QPixmap pm( rec.size() ); QPainter p( &pm ); p.eraseRect( 0, 0, rec.width(), rec.height() ); DrawThemeBackground( handle(), p.handle(), partId, stateId, &rect(), 0 ); rec = oldrec; painter->drawPixmap( rec.x(), rec.y(), pm ); } else { ulong res = DrawThemeBackground( handle(), painter->handle(), partId, stateId, &rect(), 0 ); } }
/*********************************************************************** * UPDOWN_DrawBuddyBackground * * Draw buddy background for visual integration. */ static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc) { RECT br, r; HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy); if (!buddyTheme) return FALSE; GetWindowRect (infoPtr->Buddy, &br); MapWindowPoints (NULL, infoPtr->Self, (POINT*)&br, 2); GetClientRect (infoPtr->Self, &r); if (infoPtr->dwStyle & UDS_ALIGNLEFT) br.left = r.left; else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) br.right = r.right; /* FIXME: take disabled etc. into account */ DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL); return TRUE; }
static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags) { static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL }; RECT bgRect, textRect, contentRect; HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL; int state = states[ drawState ]; WCHAR *text = get_button_text(hwnd); GetClientRect(hwnd, &bgRect); textRect = bgRect; if (text) { SIZE textExtent; GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent); bgRect.top += (textExtent.cy / 2); textRect.left += 10; textRect.bottom = textRect.top + textExtent.cy; textRect.right = textRect.left + textExtent.cx + 4; ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom); } GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect); ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom); if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state)) DrawThemeParentBackground(hwnd, hDC, NULL); DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL); SelectClipRgn(hDC, NULL); if (text) { textRect.left += 2; textRect.right -= 2; DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect); HeapFree(GetProcessHeap(), 0, text); } if (hPrevFont) SelectObject(hDC, hPrevFont); }
BOOL CPropPageFrameDefault::OnEraseBkgnd(CDC* pDC) { if (IsAppThemed()) { HTHEME hTheme = OpenThemeData(m_hWnd, L"TREEVIEW"); if (hTheme) { CRect rect; GetClientRect(rect); DrawThemeBackground(hTheme, pDC->m_hDC, 0, 0, rect, nullptr); CloseThemeData(hTheme); } return TRUE; } else { return CWnd::OnEraseBkgnd(pDC); } }
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HDC hdc = (HDC) wParam; if (!TrayTheme) { bHandled = FALSE; return 0; } RECT rect; GetClientRect(&rect); if (IsThemeBackgroundPartiallyTransparent(TrayTheme, TNP_BACKGROUND, 0)) DrawThemeParentBackground(m_hWnd, hdc, &rect); DrawThemeBackground(TrayTheme, hdc, TNP_BACKGROUND, 0, &rect, 0); return TRUE; }
void CEditWithButton_Base::DrawButton(CRect rectButton) { CWindowDC dc(this); HTHEME hButtonTheme = OpenThemeData(m_hWnd, _T("Button")); if (hButtonTheme) { int ButtonState = GetButtonThemeState(); // If necessary, first fill with the edit control's background color. if (IsThemeBackgroundPartiallyTransparent(hButtonTheme, BP_PUSHBUTTON, ButtonState)) { HTHEME hEditTheme = OpenThemeDataEx(m_hWnd, _T("Edit"), OTD_NONCLIENT); COLORREF BgColor = RGB(0, 0, 0); BgColor = GetThemeSysColor(hEditTheme, (GetStyle() & (ES_READONLY | WS_DISABLED)) ? COLOR_3DFACE : COLOR_WINDOW); dc.FillSolidRect(rectButton, BgColor); CloseThemeData(hEditTheme); } DrawThemeBackground(hButtonTheme, dc, BP_PUSHBUTTON, ButtonState, rectButton, NULL); DrawButtonContent(dc, rectButton, hButtonTheme); CloseThemeData(hButtonTheme); } else { UINT uState = DFCS_BUTTONPUSH; if (GetStyle() & (ES_READONLY | WS_DISABLED)) uState |= DFCS_INACTIVE; else if (m_IsButtonPressed) uState |= DFCS_PUSHED; dc.DrawFrameControl(rectButton, DFC_BUTTON, uState); // If the button is in a pressed state, then contents should move slightly as part of the "push" effect. if (m_IsButtonPressed) rectButton.OffsetRect(1, 1); DrawButtonContent(dc, rectButton, NULL); } }
/* Draw themed border */ static void nc_paint (HTHEME theme, HWND hwnd, HRGN region) { HRGN cliprgn = region; DWORD exStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); if (exStyle & WS_EX_CLIENTEDGE) { HDC dc; RECT r; int cxEdge = GetSystemMetrics (SM_CXEDGE), cyEdge = GetSystemMetrics (SM_CYEDGE); int part = EP_EDITTEXT; int state = ETS_NORMAL; DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); if (!IsWindowEnabled (hwnd)) state = ETS_DISABLED; else if (dwStyle & ES_READONLY) state = ETS_READONLY; else if (GetFocus() == hwnd) state = ETS_FOCUSED; GetWindowRect(hwnd, &r); /* New clipping region passed to default proc to exclude border */ cliprgn = CreateRectRgn (r.left + cxEdge, r.top + cyEdge, r.right - cxEdge, r.bottom - cyEdge); if (region != (HRGN)1) CombineRgn (cliprgn, cliprgn, region, RGN_AND); OffsetRect(&r, -r.left, -r.top); dc = GetDCEx(hwnd, region, DCX_WINDOW|DCX_INTERSECTRGN); OffsetRect(&r, -r.left, -r.top); if (IsThemeBackgroundPartiallyTransparent (theme, part, state)) DrawThemeParentBackground(hwnd, dc, &r); DrawThemeBackground (theme, dc, part, state, &r, 0); ReleaseDC(hwnd, dc); } /* Call default proc to get the scrollbars etc. also painted */ DefWindowProcW (hwnd, WM_NCPAINT, (WPARAM)cliprgn, 0); }
static void PB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused) { static const int states[] = { PBS_NORMAL, PBS_DISABLED, PBS_HOT, PBS_PRESSED, PBS_DEFAULTED }; RECT bgRect, textRect; HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL; int state = states[ drawState ]; WCHAR *text = get_button_text(hwnd); GetClientRect(hwnd, &bgRect); GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect); if (IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, state)) DrawThemeParentBackground(hwnd, hDC, NULL); DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL); if (text) { DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect); HeapFree(GetProcessHeap(), 0, text); } if (focused) { MARGINS margins; RECT focusRect = bgRect; GetThemeMargins(theme, hDC, BP_PUSHBUTTON, state, TMT_CONTENTMARGINS, NULL, &margins); focusRect.left += margins.cxLeftWidth; focusRect.top += margins.cyTopHeight; focusRect.right -= margins.cxRightWidth; focusRect.bottom -= margins.cyBottomHeight; DrawFocusRect( hDC, &focusRect ); } if (hPrevFont) SelectObject(hDC, hPrevFont); }
static void STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect) { RECT rc = *lpRect; TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); if (theme) { SIZE gripperSize; if (SUCCEEDED (GetThemePartSize (theme, hdc, SP_GRIPPER, 0, lpRect, TS_DRAW, &gripperSize))) { rc.left = rc.right - gripperSize.cx; rc.top = rc.bottom - gripperSize.cy; if (SUCCEEDED (DrawThemeBackground(theme, hdc, SP_GRIPPER, 0, &rc, NULL))) return; } } rc.left = max( rc.left, rc.right - GetSystemMetrics(SM_CXVSCROLL) - 1 ); rc.top = max( rc.top, rc.bottom - GetSystemMetrics(SM_CYHSCROLL) - 1 ); DrawFrameControl( hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP ); }
//************************************************************************************************** void LTThemeButton::OnPaintButtonState( CDC* pDC ) { if (!p_Owner->PaintBack(this, pDC, r_Area)) { if (pi_BackColor) pDC->FillSolidRect(r_Area, *pi_BackColor); } DrawThemeBackground(*ph_Theme, pDC->m_hDC, i_Part, i_State + i_StateOffset, r_Area, *pr_Clip); //LTVirtualButton::OnPaintButtonState(pDC); }