void wxAuiMSWTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawBorder(dc, wnd, rect); return; } wxRect drawRect(rect); drawRect.y += m_maxTabHeight + wnd->FromDIP(1); drawRect.height -= m_maxTabHeight; // Mask border not covered by native theme wxRect topDrawRect(rect); topDrawRect.height = drawRect.height; dc.SetPen(wxPen(wnd->GetBackgroundColour(), GetBorderWidth(wnd))); dc.DrawRectangle(topDrawRect); RECT r; wxCopyRectToRECT(drawRect, r); wxUxThemeHandle hTheme(wnd, L"TAB"); ::DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TABP_PANE, 0, &r, NULL); }
void wxRendererMSW::DoDrawFrameControl(UINT type, UINT kind, wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) { wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); int style = kind; if ( flags & wxCONTROL_CHECKED ) style |= DFCS_CHECKED; if ( flags & wxCONTROL_DISABLED ) style |= DFCS_INACTIVE; if ( flags & wxCONTROL_FLAT ) style |= DFCS_MONO; if ( flags & wxCONTROL_PRESSED ) style |= DFCS_PUSHED; if ( flags & wxCONTROL_CURRENT ) style |= DFCS_HOT; if ( flags & wxCONTROL_UNDETERMINED ) // Using DFCS_BUTTON3STATE here doesn't work (as might be expected), // use the following two styles to get the same look of a check box // in the undetermined state. style |= DFCS_INACTIVE | DFCS_CHECKED; ::DrawFrameControl(GetHdcOf(dc.GetTempHDC()), &r, type, style); }
bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child) { // solid background colour overrides themed background drawing if ( !UseBgCol() && DoDrawBackground(hDC, child) ) return true; // If we're using a solid colour (for example if we've switched off // theming for this notebook), paint it if (UseBgCol()) { wxRect r = GetPageSize(); if ( r.IsEmpty() ) return false; RECT rc; wxCopyRectToRECT(r, rc); // map rect to the coords of the window we're drawing in if ( child ) ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); wxBrush brush(GetBackgroundColour()); HBRUSH hbr = GetHbrushOf(brush); ::FillRect((HDC) hDC, &rc, hbr); return true; } return wxNotebookBase::MSWPrintChild(hDC, child); }
void wxRendererXP::DrawTreeItemButton(wxWindow *win, wxDC& dc, const wxRect& rect, int flags) { wxUxThemeHandle hTheme(win, L"TREEVIEW"); if ( !hTheme ) { m_rendererNative.DrawTreeItemButton(win, dc, rect, flags); return; } wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); int state = flags & wxCONTROL_EXPANDED ? GLPS_OPENED : GLPS_CLOSED; wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, GetHdcOf(dc.GetTempHDC()), TVP_GLYPH, state, &r, NULL ); }
void wxRendererMSW::DoDrawFrameControl(UINT type, UINT kind, wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) { RECT r; wxCopyRectToRECT(rect, r); int style = kind; if ( flags & wxCONTROL_CHECKED ) style |= DFCS_CHECKED; if ( flags & wxCONTROL_DISABLED ) style |= DFCS_INACTIVE; if ( flags & wxCONTROL_FLAT ) style |= DFCS_MONO; if ( flags & wxCONTROL_PRESSED ) style |= DFCS_PUSHED; if ( flags & wxCONTROL_CURRENT ) style |= DFCS_HOT; ::DrawFrameControl(GetHdcOf(dc.GetTempHDC()), &r, type, style); }
void wxRendererXP::DrawTreeItemButton(wxWindow *win, wxDC& dc, const wxRect& rect, int flags) { wxUxThemeHandle hTheme(win, L"TREEVIEW"); if ( !hTheme ) { m_rendererNative.DrawTreeItemButton(win, dc, rect, flags); return; } RECT r; wxCopyRectToRECT(rect, r); int state = flags & wxCONTROL_EXPANDED ? GLPS_OPENED : GLPS_CLOSED; wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, GetHdcOf(dc.GetTempHDC()), TVP_GLYPH, state, &r, NULL ); }
void wxRendererXP::DrawItemSelectionRect(wxWindow *win, wxDC& dc, const wxRect& rect, int flags) { wxUxThemeHandle hTheme(win, L"LISTVIEW"); const int itemState = GetListItemState(flags); wxUxThemeEngine* const te = wxUxThemeEngine::Get(); if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) ) { RECT rc; wxCopyRectToRECT(rect, rc); if ( te->IsThemeBackgroundPartiallyTransparent(hTheme, LVP_LISTITEM, itemState) ) te->DrawThemeParentBackground(GetHwndOf(win), GetHdcOf(dc.GetTempHDC()), &rc); te->DrawThemeBackground(hTheme, GetHdcOf(dc.GetTempHDC()), LVP_LISTITEM, itemState, &rc, 0); } else { m_rendererNative.DrawItemSelectionRect(win, dc, rect, flags); } }
void wxAuiMSWToolBarArt::DrawOverflowButton( wxDC& dc, wxWindow* wnd, const wxRect& rect, int state) { if ( m_themed ) { RECT r; wxCopyRectToRECT(rect, r); wxUxThemeHandle hTheme(wnd, L"Rebar"); int chevState; if ( state & wxAUI_BUTTON_STATE_PRESSED ) chevState = CHEVS_PRESSED; else if ( state & wxAUI_BUTTON_STATE_HOVER ) chevState = CHEVS_HOT; else chevState = CHEVS_NORMAL; wxUxThemeEngine::Get()->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), (m_flags & wxAUI_TB_VERTICAL) ? RP_CHEVRONVERT : RP_CHEVRON, chevState, &r, NULL); } else wxAuiGenericToolBarArt::DrawOverflowButton(dc, wnd, rect, state); }
void wxTaskBarButtonImpl::SetThumbnailClip(const wxRect& rect) { m_thumbnailClipRect = rect; RECT rc; wxCopyRectToRECT(rect, rc); m_taskbarList->SetThumbnailClip(m_parent->GetHWND(), rect.IsEmpty() ? NULL : &rc); }
WXHBRUSH wxNotebook::QueryBgBitmap() { wxRect r = GetPageSize(); if ( r.IsEmpty() ) return 0; wxUxThemeHandle theme(this, L"TAB"); if ( !theme ) return 0; RECT rc; wxCopyRectToRECT(r, rc); WindowHDC hDC(GetHwnd()); wxUxThemeEngine::Get()->GetThemeBackgroundExtent ( theme, (HDC) hDC, 9 /* TABP_PANE */, 0, &rc, &rc ); MemoryHDC hDCMem(hDC); CompatibleBitmap hBmp(hDC, rc.right, rc.bottom); SelectInHDC selectBmp(hDCMem, hBmp); if ( !DoDrawBackground((WXHDC)(HDC)hDCMem) ) return 0; return (WXHBRUSH)::CreatePatternBrush(hBmp); }
void wxRendererXP::DoDrawButtonLike(HTHEME htheme, int part, wxDC& dc, const wxRect& rect, int flags) { wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); // the base state is always 1, whether it is PBS_NORMAL, // {CBS,RBS}_UNCHECKEDNORMAL or CBS_NORMAL int state = 1; // XBS_XXX is followed by XBX_XXXHOT, then XBS_XXXPRESSED and DISABLED enum { NORMAL_OFFSET, HOT_OFFSET, PRESSED_OFFSET, DISABLED_OFFSET, STATES_COUNT }; // in both RBS_ and CBS_ enums CHECKED elements are offset by 4 from base // (UNCHECKED) ones and MIXED are offset by 4 again as there are all states // from the above enum in between them if ( flags & wxCONTROL_CHECKED ) state += STATES_COUNT; else if ( flags & wxCONTROL_UNDETERMINED ) state += 2*STATES_COUNT; if ( flags & wxCONTROL_DISABLED ) state += DISABLED_OFFSET; else if ( flags & wxCONTROL_PRESSED ) state += PRESSED_OFFSET; else if ( flags & wxCONTROL_CURRENT ) state += HOT_OFFSET; // wxCONTROL_ISDEFAULT flag is only valid for push buttons else if ( part == BP_PUSHBUTTON && (flags & wxCONTROL_ISDEFAULT) ) state = PBS_DEFAULTED; wxUxThemeEngine::Get()->DrawThemeBackground ( htheme, GetHdcOf(dc.GetTempHDC()), part, state, &r, NULL ); }
void wxRendererMSWBase::DrawFocusRect(wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { RECT rc; wxCopyRectToRECT(rect, rc); ::DrawFocusRect(GetHdcOf(dc.GetTempHDC()), &rc); }
bool wxListBox::RefreshItem(size_t n) { wxRect rect; if ( !GetItemRect(n, rect) ) return false; RECT rc; wxCopyRectToRECT(rect, rc); return ::InvalidateRect((HWND)GetHWND(), &rc, FALSE) == TRUE; }
void ModernDockArt::DrawPaneButton(wxDC& dc, wxWindow* window, int button, int button_state, const wxRect& _rect, wxAuiPaneInfo& pane) { bool usingTheme = false; #ifdef __WXMSW__ #if wxUSE_UXTHEME if (wxUxThemeEngine::Get()) { wxUxThemeHandle hTheme(m_win, L"WINDOW"); if (hTheme) { usingTheme = true; // Get the real button position (compensating for borders) //const wxRect rect(_rect.x, _rect.y+m_button_border_size, m_button_size, m_button_size); const unsigned int ypos = _rect.y + (_rect.height/2) - (m_button_size/2); // center vertically const wxRect rect(_rect.x, ypos, m_real_button_size, m_real_button_size); // Draw the themed close button RECT rc; wxCopyRectToRECT(rect, rc); int state = 0; switch (button_state) { case wxAUI_BUTTON_STATE_NORMAL: state = 1; // CBS_NORMAL break; case wxAUI_BUTTON_STATE_HOVER: state = 2; // CBS_HOT break; case wxAUI_BUTTON_STATE_PRESSED: state = 3; // CBS_PUSHED break; default: wxASSERT_MSG(false, wxT("Unknown state")); } wxUxThemeEngine::Get()->DrawThemeBackground(hTheme, GetHdcOf(dc), 19 /*WP_SMALLCLOSEBUTTON*/, state, &rc, NULL); } } #endif // wxUSE_UXTHEME #endif // __WXMSW__ // Fallback to default closebutton if themes are not enabled if (!usingTheme) wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, _rect, pane); }
void wxRendererXP::DrawGauge(wxWindow* win, wxDC& dc, const wxRect& rect, int value, int max, int flags) { wxUxThemeHandle hTheme(win, L"PROGRESS"); if ( !hTheme ) { m_rendererNative.DrawGauge(win, dc, rect, value, max, flags); return; } RECT r; wxCopyRectToRECT(rect, r); wxUxThemeEngine::Get()->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), PP_BAR, 0, &r, NULL); RECT contentRect; wxUxThemeEngine::Get()->GetThemeBackgroundContentRect( hTheme, GetHdcOf(dc.GetTempHDC()), PP_BAR, 0, &r, &contentRect); contentRect.right = contentRect.left + wxMulDivInt32(contentRect.right - contentRect.left, value, max); wxUxThemeEngine::Get()->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), PP_CHUNK, 0, &contentRect, NULL); }
void wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) { RECT r; wxCopyRectToRECT(rect, r); int style = DFCS_SCROLLCOMBOBOX; if ( flags & wxCONTROL_DISABLED ) style |= DFCS_INACTIVE; if ( flags & wxCONTROL_PRESSED ) style |= DFCS_PUSHED | DFCS_FLAT; ::DrawFrameControl(GetHdcOf(dc.GetTempHDC()), &r, DFC_SCROLL, style); }
int wxRendererXP::DrawHeaderButton(wxWindow *win, wxDC& dc, const wxRect& rect, int flags, wxHeaderSortIconType sortArrow, wxHeaderButtonParams* params) { wxUxThemeHandle hTheme(win, L"HEADER"); if ( !hTheme ) { return m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params); } wxCHECK_MSG( dc.GetImpl(), -1, wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); int state; if ( flags & wxCONTROL_PRESSED ) state = HIS_PRESSED; else if ( flags & wxCONTROL_CURRENT ) state = HIS_HOT; else state = HIS_NORMAL; wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, GetHdcOf(dc.GetTempHDC()), HP_HEADERITEM, state, &r, NULL ); // NOTE: Using the theme to draw HP_HEADERSORTARROW doesn't do anything. // Why? If this can be fixed then draw the sort arrows using the theme // and then clear those flags before calling DrawHeaderButtonContents. // Add any extras that are specified in flags and params return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params); }
void wxRendererXP::DrawCollapseButton(wxWindow *win, wxDC& dc, const wxRect& rect, int flags) { wxUxThemeHandle hTheme(win, L"TASKDIALOG"); wxUxThemeEngine* const te = wxUxThemeEngine::Get(); int state; if (flags & wxCONTROL_PRESSED) state = TDLGEBS_PRESSED; else if (flags & wxCONTROL_CURRENT) state = TDLGEBS_HOVER; else state = TDLGEBS_NORMAL; if ( flags & wxCONTROL_EXPANDED ) state += 3; if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, state) ) { if (flags & wxCONTROL_EXPANDED) flags |= wxCONTROL_CHECKED; wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); te->DrawThemeBackground ( hTheme, GetHdcOf(dc.GetTempHDC()), TDLG_EXPANDOBUTTON, state, &r, NULL ); } else m_rendererNative.DrawCollapseButton(win, dc, rect, flags); }
bool wxNotebook::DoDrawBackground(WXHDC hDC, wxWindow *child) { wxUxThemeHandle theme(child ? child : this, L"TAB"); if ( !theme ) return false; // get the notebook client rect (we're not interested in drawing tabs // themselves) wxRect r = GetPageSize(); if ( r.IsEmpty() ) return false; RECT rc; wxCopyRectToRECT(r, rc); // map rect to the coords of the window we're drawing in if ( child ) ::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2); // we have the content area (page size), but we need to draw all of the // background for it to be aligned correctly wxUxThemeEngine::Get()->GetThemeBackgroundExtent ( theme, (HDC) hDC, 9 /* TABP_PANE */, 0, &rc, &rc ); wxUxThemeEngine::Get()->DrawThemeBackground ( theme, (HDC) hDC, 9 /* TABP_PANE */, 0, &rc, NULL ); return true; }
// NOTE: There is no guarantee that the button drawn fills the entire rect (XP // default theme, for example), so the caller should have cleared button's // background before this call. This is quite likely a wxMSW-specific thing. void wxRendererXP::DrawComboBoxDropButton(wxWindow * win, wxDC& dc, const wxRect& rect, int flags) { wxUxThemeHandle hTheme(win, L"COMBOBOX"); if ( !hTheme ) { m_rendererNative.DrawComboBoxDropButton(win, dc, rect, flags); return; } wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); int state; if ( flags & wxCONTROL_PRESSED ) state = CBXS_PRESSED; else if ( flags & wxCONTROL_CURRENT ) state = CBXS_HOT; else if ( flags & wxCONTROL_DISABLED ) state = CBXS_DISABLED; else state = CBXS_NORMAL; wxUxThemeEngine::Get()->DrawThemeBackground ( hTheme, GetHdcOf(dc.GetTempHDC()), CP_DROPDOWNBUTTON, state, &r, NULL ); }
void wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win), wxDC& dc, const wxRect& rect, int flags) { wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") ); wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect); RECT r; wxCopyRectToRECT(adjustedRect, r); int style = DFCS_SCROLLCOMBOBOX; if ( flags & wxCONTROL_DISABLED ) style |= DFCS_INACTIVE; if ( flags & wxCONTROL_PRESSED ) style |= DFCS_PUSHED | DFCS_FLAT; ::DrawFrameControl(GetHdcOf(dc.GetTempHDC()), &r, DFC_SCROLL, style); }
void wxAuiMSWTabArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawBackground(dc, wnd, rect); return; } int borderHeight = 2; wxRect drawRect = rect; drawRect.height -= borderHeight; // Draw background dc.SetBrush(wxBrush(wnd->GetBackgroundColour())); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(drawRect); // Draw top border drawRect.y = drawRect.height; drawRect.height = borderHeight + 2; drawRect.Inflate(1, 0); RECT r; wxCopyRectToRECT(drawRect, r); wxUxThemeHandle hTheme(wnd, L"TAB"); ::DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TABP_PANE, 0, &r, NULL); }
void wxAuiMSWToolBarArt::DrawGripper( wxDC& dc, wxWindow* wnd, const wxRect& rect) { if ( m_themed ) { RECT r; wxCopyRectToRECT(rect, r); wxUxThemeHandle hTheme(wnd, L"Rebar"); wxUxThemeEngine::Get()->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), (m_flags & wxAUI_TB_VERTICAL) ? RP_GRIPPERVERT : RP_GRIPPER, 0, &r, NULL); } else wxAuiGenericToolBarArt::DrawGripper(dc, wnd, rect); }
void wxAuiMSWToolBarArt::DrawBackground( wxDC& dc, wxWindow* wnd, const wxRect& rect) { if ( m_themed ) { RECT r; wxCopyRectToRECT(rect, r); wxUxThemeHandle hTheme(wnd, L"Rebar"); wxUxThemeEngine::Get()->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), RP_BACKGROUND, 0, &r, NULL); } else wxAuiGenericToolBarArt::DrawBackground(dc, wnd, rect); }
bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction WXUNUSED(act), wxODStatus stat) { const MenuDrawData* data = MenuDrawData::Get(); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hdc = GetHdcOf(*impl); RECT rect; wxCopyRectToRECT(rc, rect); int imgWidth = wxMax(GetMarginWidth(), data->CheckSize.cx); if ( IsOwnerDrawn() ) { // font and colors to use wxFont font; GetFontToUse(font); wxColour colText, colBack; GetColourToUse(stat, colText, colBack); // calculate metrics of item parts RECT rcSelection = rect; data->ItemMargin.ApplyTo(rcSelection); RECT rcSeparator = rcSelection; data->SeparatorMargin.ApplyTo(rcSeparator); RECT rcGutter = rcSelection; rcGutter.right = data->ItemMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth + imgWidth + data->CheckMargin.cxRightWidth + data->CheckBgMargin.cxRightWidth; RECT rcText = rcSelection; rcText.left = rcGutter.right + data->TextBorder; // we draw the text label vertically centered, but this results in it // being 1px too low compared to native menus for some reason, fix it if ( data->MenuLayout() != MenuDrawData::FullTheme ) rcText.top--; #if wxUSE_UXTHEME // If a custom background colour is explicitly specified, we should use // it instead of the default theme background. wxUxThemeEngine* const theme = GetBackgroundColour().IsOk() ? NULL : MenuDrawData::GetUxThemeEngine(); if ( theme ) { POPUPITEMSTATES state; if ( stat & wxODDisabled ) { state = (stat & wxODSelected) ? MPI_DISABLEDHOT : MPI_DISABLED; } else if ( stat & wxODSelected ) { state = MPI_HOT; } else { state = MPI_NORMAL; } wxUxThemeHandle hTheme(GetMenu()->GetWindow(), L"MENU"); if ( theme->IsThemeBackgroundPartiallyTransparent(hTheme, MENU_POPUPITEM, state) ) { theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPBACKGROUND, 0, &rect, NULL); } theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPGUTTER, 0, &rcGutter, NULL); if ( IsSeparator() ) { rcSeparator.left = rcGutter.right; theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPSEPARATOR, 0, &rcSeparator, NULL); return true; } theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPITEM, state, &rcSelection, NULL); } else #endif // wxUSE_UXTHEME { if ( IsSeparator() ) { DrawEdge(hdc, &rcSeparator, EDGE_ETCHED, BF_TOP); return true; } AutoHBRUSH hbr(colBack.GetPixel()); SelectInHDC selBrush(hdc, hbr); ::FillRect(hdc, &rcSelection, hbr); } // draw text label // using native API because it recognizes '&' HDCTextColChanger changeTextCol(hdc, colText.GetPixel()); HDCBgColChanger changeBgCol(hdc, colBack.GetPixel()); HDCBgModeChanger changeBgMode(hdc, TRANSPARENT); SelectInHDC selFont(hdc, GetHfontOf(font)); // item text name without mnemonic for calculating size wxString text = GetName(); SIZE textSize; ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &textSize); // item text name with mnemonic text = GetItemLabel().BeforeFirst('\t'); int flags = DST_PREFIXTEXT; // themes menu is using specified color for disabled labels if ( data->MenuLayout() == MenuDrawData::Classic && (stat & wxODDisabled) && !(stat & wxODSelected) ) flags |= DSS_DISABLED; if ( (stat & wxODHidePrefix) && !data->AlwaysShowCues ) flags |= DSS_HIDEPREFIX; int x = rcText.left; int y = rcText.top + (rcText.bottom - rcText.top - textSize.cy) / 2; ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text), text.length(), x, y, 0, 0, flags); // ::SetTextAlign(hdc, TA_RIGHT) doesn't work with DSS_DISABLED or DSS_MONO // as the last parameter in DrawState() (at least with Windows98). So we have // to take care of right alignment ourselves. wxString accel = GetItemLabel().AfterFirst(wxT('\t')); if ( !accel.empty() ) { SIZE accelSize; ::GetTextExtentPoint32(hdc, accel.c_str(), accel.length(), &accelSize); flags = DST_TEXT; // themes menu is using specified color for disabled labels if ( data->MenuLayout() == MenuDrawData::Classic && (stat & wxODDisabled) && !(stat & wxODSelected) ) flags |= DSS_DISABLED; x = rcText.right - data->ArrowMargin.GetTotalX() - data->ArrowSize.cx - data->ArrowBorder; // right align accel on FullTheme menu, left otherwise if ( data->MenuLayout() == MenuDrawData::FullTheme) x -= accelSize.cx; else x -= m_parentMenu->GetMaxAccelWidth(); y = rcText.top + (rcText.bottom - rcText.top - accelSize.cy) / 2; ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(accel), accel.length(), x, y, 0, 0, flags); } } // draw the bitmap RECT rcImg; SetRect(&rcImg, rect.left + data->ItemMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth, rect.top + data->ItemMargin.cyTopHeight + data->CheckBgMargin.cyTopHeight + data->CheckMargin.cyTopHeight, rect.left + data->ItemMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth + imgWidth, rect.bottom - data->ItemMargin.cyBottomHeight - data->CheckBgMargin.cyBottomHeight - data->CheckMargin.cyBottomHeight); if ( IsCheckable() && !m_bmpChecked.IsOk() ) { if ( stat & wxODChecked ) { DrawStdCheckMark((WXHDC)hdc, &rcImg, stat); } } else { wxBitmap bmp; if ( stat & wxODDisabled ) { bmp = GetDisabledBitmap(); } if ( !bmp.IsOk() ) { // for not checkable bitmaps we should always use unchecked one // because their checked bitmap is not set bmp = GetBitmap(!IsCheckable() || (stat & wxODChecked)); #if wxUSE_IMAGE if ( bmp.IsOk() && stat & wxODDisabled ) { // we need to grey out the bitmap as we don't have any specific // disabled bitmap wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale(); if ( imgGrey.IsOk() ) bmp = wxBitmap(imgGrey); } #endif // wxUSE_IMAGE } if ( bmp.IsOk() ) { wxMemoryDC dcMem(&dc); dcMem.SelectObjectAsSource(bmp); // center bitmap int nBmpWidth = bmp.GetWidth(), nBmpHeight = bmp.GetHeight(); int x = rcImg.left + (imgWidth - nBmpWidth) / 2; int y = rcImg.top + (rcImg.bottom - rcImg.top - nBmpHeight) / 2; dc.Blit(x, y, nBmpWidth, nBmpHeight, &dcMem, 0, 0, wxCOPY, true); } } return true; }
// draw the item bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction, wxODStatus stat) { // we do nothing if item isn't ownerdrawn if ( !IsOwnerDrawn() ) return true; wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hdc = GetHdcOf(*impl); RECT rect; wxCopyRectToRECT(rc, rect); { // set the font and colors wxFont font; GetFontToUse(font); wxColour colText, colBack; GetColourToUse(stat, colText, colBack); SelectInHDC selFont(hdc, GetHfontOf(font)); wxMSWImpl::wxTextColoursChanger textCol(hdc, colText, colBack); wxMSWImpl::wxBkModeChanger bkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); AutoHBRUSH hbr(wxColourToPalRGB(colBack)); SelectInHDC selBrush(hdc, hbr); ::FillRect(hdc, &rect, hbr); // using native API because it recognizes '&' wxString text = GetName(); SIZE sizeRect; ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect); int flags = DST_PREFIXTEXT; if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) flags |= DSS_DISABLED; if ( (stat & wxODHidePrefix) ) flags |= DSS_HIDEPREFIX; int x = rc.x + GetMarginWidth(); int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2; int cx = rc.GetWidth() - GetMarginWidth(); int cy = sizeRect.cy; ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text), text.length(), x, y, cx, cy, flags); } // reset to default the font, colors and brush if (stat & wxODHasFocus) ::DrawFocusRect(hdc, &rect); return true; }
void wxAuiMSWTabArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, int bitmap_id, int button_state, int orientation, wxRect* out_rect) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawButton(dc, wnd, in_rect, bitmap_id, button_state, orientation, out_rect); return; } const wchar_t* themeId = NULL; int part = 0; switch (bitmap_id) { case wxAUI_BUTTON_CLOSE: themeId = L"Window"; part = WP_CLOSEBUTTON; break; case wxAUI_BUTTON_LEFT: themeId = L"Spin"; part = SPNP_DOWNHORZ; break; case wxAUI_BUTTON_RIGHT: themeId = L"Spin"; part = SPNP_UPHORZ; break; case wxAUI_BUTTON_WINDOWLIST: themeId = L"Combobox"; part = CP_DROPDOWNBUTTON; break; } wxRect rect = in_rect; if ( orientation == wxLEFT ) { rect.SetX(in_rect.x); rect.SetY(((in_rect.y + in_rect.height) / 2) - (m_closeBtnSize.GetHeight() / 2)); rect.SetWidth(m_closeBtnSize.GetWidth()); rect.SetHeight(m_closeBtnSize.GetHeight()); } else { rect = wxRect(in_rect.x + in_rect.width - m_closeBtnSize.GetWidth(), ((in_rect.y + in_rect.height) / 2) - (m_closeBtnSize.GetHeight() / 2), m_closeBtnSize.GetWidth(), m_closeBtnSize.GetHeight()); } if ( bitmap_id == wxAUI_BUTTON_LEFT || bitmap_id == wxAUI_BUTTON_RIGHT ) { rect.y = in_rect.y; rect.height = in_rect.height - wnd->FromDIP(7); } dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(m_baseColour)); dc.DrawRectangle(rect); int btnState; if ( button_state == wxAUI_BUTTON_STATE_DISABLED ) btnState = TTCS_PRESSED + 1; else if ( button_state == wxAUI_BUTTON_STATE_HOVER ) btnState = TTCS_HOT; else if ( button_state == wxAUI_BUTTON_STATE_PRESSED ) btnState = TTCS_PRESSED; else btnState = TTCS_NORMAL; wxUxThemeHandle hTheme(wnd, themeId); wxRect btnRect(rect); btnRect.width -= wnd->FromDIP(1); RECT btnR; wxCopyRectToRECT(btnRect, btnR); ::DrawThemeBackground(hTheme, GetHdcOf(dc.GetTempHDC()), part, btnState, &btnR, NULL); if ( out_rect ) *out_rect = rect; }
void wxAuiMSWToolBarArt::DrawDropDownButton( wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) { if ( m_themed ) { wxUxThemeHandle hTheme(wnd, L"Toolbar"); wxUxThemeEngine* const te = wxUxThemeEngine::Get(); int dropDownWidth = 14; int textWidth = 0, textHeight = 0, textX = 0, textY = 0; int bmpX = 0, bmpY = 0; wxRect buttonRect = wxRect(rect.x, rect.y, rect.width - dropDownWidth, rect.height); wxRect dropDownRect = wxRect(rect.x + rect.width - dropDownWidth - 1, rect.y, dropDownWidth + 1, rect.height); if ( m_flags & wxAUI_TB_TEXT ) { dc.SetFont(m_font); int tx, ty; if ( m_flags & wxAUI_TB_TEXT ) { dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight); textWidth = 0; } dc.GetTextExtent(item.GetLabel(), &textWidth, &ty); } RECT btnR; wxCopyRectToRECT(buttonRect, btnR); RECT dropDownR; wxCopyRectToRECT(dropDownRect, dropDownR); int btnState; if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) btnState = TS_DISABLED; else if ( item.GetState() & wxAUI_BUTTON_STATE_PRESSED ) btnState = TS_PRESSED; else if ( item.GetState() & wxAUI_BUTTON_STATE_HOVER ) btnState = TS_HOT; else btnState = TS_NORMAL; te->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TP_SPLITBUTTON, btnState, &btnR, NULL); te->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TP_SPLITBUTTONDROPDOWN, btnState, &dropDownR, NULL); if ( m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM ) { bmpX = buttonRect.x + (buttonRect.width / 2) - (item.GetBitmap().GetWidth() / 2); bmpY = buttonRect.y + ((buttonRect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2); textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1; textY = rect.y + rect.height - textHeight - 1; } else if ( m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT ) { bmpX = rect.x + 3; bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2); textX = bmpX + 3 + item.GetBitmap().GetWidth(); textY = rect.y + (rect.height / 2) - (textHeight / 2); } wxBitmap bmp; if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) { bmp = item.GetDisabledBitmap(); } else { bmp = item.GetBitmap(); } if ( !bmp.IsOk() ) return; dc.DrawBitmap(bmp, bmpX, bmpY, true); // set the item's text color based on if it is disabled dc.SetTextForeground(*wxBLACK); if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) dc.SetTextForeground(DISABLED_TEXT_COLOR); if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() ) { dc.DrawText(item.GetLabel(), textX, textY); } } else wxAuiGenericToolBarArt::DrawDropDownButton(dc, wnd, item, rect); }
//--------------------------------------------------------------------------- // wxActiveXContainer::CreateActiveX // // Actually creates the ActiveX container through the FrameSite // and sets up ActiveX events // // TODO: Document this more //--------------------------------------------------------------------------- void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk) { HRESULT hret; hret = m_ActiveX.QueryInterface(iid, pUnk); CHECK_HR(hret); // FrameSite m_frameSite = new FrameSite(m_realparent, this); // oleClientSite hret = m_clientSite.QueryInterface( IID_IOleClientSite, (IDispatch *) m_frameSite); CHECK_HR(hret); // adviseSink wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite); wxASSERT(adviseSink.Ok()); // Get Dispatch interface hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX); CHECK_HR(hret); // // SETUP TYPEINFO AND ACTIVEX EVENTS // // get type info via class info wxAutoIProvideClassInfo classInfo(IID_IProvideClassInfo, m_ActiveX); wxASSERT(classInfo.Ok()); // type info wxAutoITypeInfo typeInfo; hret = classInfo->GetClassInfo(typeInfo.GetRef()); CHECK_HR(hret); wxASSERT(typeInfo.Ok()); // TYPEATTR TYPEATTR *ta = NULL; hret = typeInfo->GetTypeAttr(&ta); CHECK_HR(hret); // this should be a TKIND_COCLASS wxASSERT(ta->typekind == TKIND_COCLASS); // iterate contained interfaces for (int i = 0; i < ta->cImplTypes; i++) { HREFTYPE rt = 0; // get dispatch type info handle hret = typeInfo->GetRefTypeOfImplType(i, &rt); if (! SUCCEEDED(hret)) continue; // get dispatch type info interface wxAutoITypeInfo ti; hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef()); if (! ti.Ok()) continue; CHECK_HR(hret); // check if default event sink bool defEventSink = false; int impTypeFlags = 0; typeInfo->GetImplTypeFlags(i, &impTypeFlags); if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT) { if (impTypeFlags & IMPLTYPEFLAG_FSOURCE) { // WXOLE_TRACEOUT("Default Event Sink"); defEventSink = true; if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE) { // WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable"); defEventSink = false; wxFAIL_MSG(wxT("Default event sink is in vtable!")); } } } // wxAutoOleInterface<> assumes a ref has already been added // TYPEATTR TYPEATTR *ta = NULL; hret = ti->GetTypeAttr(&ta); CHECK_HR(hret); if (ta->typekind == TKIND_DISPATCH) { // WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str()); if (defEventSink) { wxAutoIConnectionPoint cp; DWORD adviseCookie = 0; wxAutoIConnectionPointContainer cpContainer(IID_IConnectionPointContainer, m_ActiveX); wxASSERT( cpContainer.Ok()); HRESULT hret = cpContainer->FindConnectionPoint(ta->guid, cp.GetRef()); CHECK_HR(hret); IDispatch* disp; m_frameSite->QueryInterface(IID_IDispatch, (void**)&disp); hret = cp->Advise(new wxActiveXEvents(this, ta->guid), &adviseCookie); CHECK_HR(hret); } } ti->ReleaseTypeAttr(ta); } // free typeInfo->ReleaseTypeAttr(ta); // // END // // Get IOleObject interface hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX); CHECK_HR(hret); // get IViewObject Interface hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX); CHECK_HR(hret); // document advise m_docAdviseCookie = 0; hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie); CHECK_HR(hret); // TODO:Needed? // hret = m_viewObject->SetAdvise(DVASPECT_CONTENT, 0, adviseSink); m_oleObject->SetHostNames(L"wxActiveXContainer", NULL); OleSetContainedObject(m_oleObject, TRUE); OleRun(m_oleObject); // Get IOleInPlaceObject interface hret = m_oleInPlaceObject.QueryInterface( IID_IOleInPlaceObject, m_ActiveX); CHECK_HR(hret); // status DWORD dwMiscStatus; m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus); CHECK_HR(hret); // set client site first ? if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) m_oleObject->SetClientSite(m_clientSite); // stream init wxAutoIPersistStreamInit pPersistStreamInit(IID_IPersistStreamInit, m_oleObject); if (pPersistStreamInit.Ok()) { hret = pPersistStreamInit->InitNew(); CHECK_HR(hret); } if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)) m_oleObject->SetClientSite(m_clientSite); m_oleObjectHWND = 0; if (m_oleInPlaceObject.Ok()) { hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND); if (SUCCEEDED(hret)) ::SetActiveWindow(m_oleObjectHWND); } if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME)) { RECT posRect; wxCopyRectToRECT(m_realparent->GetClientSize(), posRect); if (posRect.right > 0 && posRect.bottom > 0 && m_oleInPlaceObject.Ok()) { m_oleInPlaceObject->SetObjectRects(&posRect, &posRect); } hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)m_realparent->GetHWND(), &posRect); CHECK_HR(hret); hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)m_realparent->GetHWND(), &posRect); CHECK_HR(hret); } if (! m_oleObjectHWND && m_oleInPlaceObject.Ok()) { hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND); CHECK_HR(hret); } if (m_oleObjectHWND) { ::SetActiveWindow(m_oleObjectHWND); ::ShowWindow(m_oleObjectHWND, SW_SHOW); this->AssociateHandle(m_oleObjectHWND); this->Reparent(m_realparent); wxWindow* pWnd = m_realparent; int id = m_realparent->GetId(); pWnd->Connect(id, wxEVT_SIZE, wxSizeEventHandler(wxActiveXContainer::OnSize), 0, this); // this->Connect(GetId(), wxEVT_PAINT, // wxPaintEventHandler(wxActiveXContainer::OnPaint), 0, this); pWnd->Connect(id, wxEVT_SET_FOCUS, wxFocusEventHandler(wxActiveXContainer::OnSetFocus), 0, this); pWnd->Connect(id, wxEVT_KILL_FOCUS, wxFocusEventHandler(wxActiveXContainer::OnKillFocus), 0, this); } }
void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { // TODO: Convert drawing in this function to Windows API Code wxSize sz = GetClientSize(); wxDC* dcPtr = wxAutoBufferedPaintDCFactory(this); wxDC& dc = *dcPtr; const wxRect& rectButton = m_btnArea; wxRect rectTextField = m_tcArea; // FIXME: Either SetBackgroundColour or GetBackgroundColour // doesn't work under Vista, so here's a temporary // workaround. // In the theme-less rendering code below, this fixes incorrect // background on read-only comboboxes (they are gray, but should be // white). wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); #if wxUSE_UXTHEME const bool isEnabled = IsThisEnabled(); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hDc = GetHdcOf(*impl); HWND hWnd = GetHwndOf(this); wxUxThemeHandle hTheme(this, L"COMBOBOX"); #endif // wxUSE_UXTHEME wxRect borderRect(0,0,sz.x,sz.y); if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) { borderRect = m_tcArea; borderRect.Inflate(1); } int drawButFlags = 0; #if wxUSE_UXTHEME if ( hTheme ) { const bool useVistaComboBox = ::wxGetWinVersion() >= wxWinVersion_Vista; RECT rFull; wxCopyRectToRECT(borderRect, rFull); RECT rButton; wxCopyRectToRECT(rectButton, rButton); RECT rBorder; wxCopyRectToRECT(borderRect, rBorder); bool isNonStdButton = (m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE) || (m_iFlags & wxCC_IFLAG_HAS_NONSTANDARD_BUTTON); // // Get some states for themed drawing int butState; if ( !isEnabled ) { butState = CBXS_DISABLED; } // Vista will display the drop-button as depressed always // when the popup window is visilbe else if ( (m_btnState & wxCONTROL_PRESSED) || (useVistaComboBox && !IsPopupWindowState(Hidden)) ) { butState = CBXS_PRESSED; } else if ( m_btnState & wxCONTROL_CURRENT ) { butState = CBXS_HOT; } else { butState = CBXS_NORMAL; } int comboBoxPart = 0; // For XP, use the 'default' part RECT* rUseForBg = &rBorder; bool drawFullButton = false; int bgState = butState; const bool isFocused = (FindFocus() == GetMainWindowOfCompositeControl()) ? true : false; if ( useVistaComboBox ) { // Draw the entire control as a single button? if ( !isNonStdButton ) { if ( HasFlag(wxCB_READONLY) ) drawFullButton = true; } if ( drawFullButton ) { comboBoxPart = CP_READONLY; rUseForBg = &rFull; // It should be safe enough to update this flag here. m_iFlags |= wxCC_FULL_BUTTON; } else { comboBoxPart = CP_BORDER; m_iFlags &= ~wxCC_FULL_BUTTON; if ( isFocused ) bgState = CBB_FOCUSED; else bgState = CBB_NORMAL; } } // // Draw parent's background, if necessary RECT* rUseForTb = NULL; if ( ::IsThemeBackgroundPartiallyTransparent( hTheme, comboBoxPart, bgState ) ) rUseForTb = &rFull; else if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) rUseForTb = &rButton; if ( rUseForTb ) ::DrawThemeParentBackground( hWnd, hDc, rUseForTb ); // // Draw the control background (including the border) if ( m_widthCustomBorder > 0 ) { ::DrawThemeBackground( hTheme, hDc, comboBoxPart, bgState, rUseForBg, NULL ); } else { // No border. We can't use theme, since it cannot be relied on // to deliver borderless drawing, even with DrawThemeBackgroundEx. dc.SetBrush(bgCol); dc.SetPen(bgCol); dc.DrawRectangle(borderRect); } // // Draw the drop-button if ( !isNonStdButton ) { drawButFlags = Button_BitmapOnly; int butPart = CP_DROPDOWNBUTTON; if ( useVistaComboBox ) { if ( drawFullButton ) { // We need to alter the button style slightly before // drawing the actual button (but it was good above // when background etc was done). if ( butState == CBXS_HOT || butState == CBXS_PRESSED ) butState = CBXS_NORMAL; } if ( m_btnSide == wxRIGHT ) butPart = CP_DROPDOWNBUTTONRIGHT; else butPart = CP_DROPDOWNBUTTONLEFT; } ::DrawThemeBackground( hTheme, hDc, butPart, butState, &rButton, NULL ); } else if ( useVistaComboBox && (m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE) ) { // We'll do this, because DrawThemeParentBackground // doesn't seem to be reliable on Vista. drawButFlags |= Button_PaintBackground; } } else #endif { // Windows 2000 and earlier drawButFlags = Button_PaintBackground; dc.SetBrush(bgCol); dc.SetPen(bgCol); dc.DrawRectangle(borderRect); } // Button rendering (may only do the bitmap on button, depending on the flags) DrawButton( dc, rectButton, drawButFlags ); // Paint required portion of the custom image on the control if ( (!m_text || m_widthCustomPaint) ) { wxASSERT( m_widthCustomPaint >= 0 ); // this is intentionally here to allow drawed rectangle's // right edge to be hidden if ( m_text ) rectTextField.width = m_widthCustomPaint; dc.SetFont( GetFont() ); dc.SetClippingRegion(rectTextField); if ( m_popupInterface ) m_popupInterface->PaintComboControl(dc,rectTextField); else wxComboPopup::DefaultPaintComboControl(this,dc,rectTextField); } delete dcPtr; }