本文整理汇总了C++中wxDC::GetImpl方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetImpl方法的具体用法?C++ wxDC::GetImpl怎么用?C++ wxDC::GetImpl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetImpl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WXUNUSED
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);
}
示例2: hTheme
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
);
}
示例3: if
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
);
}
示例4: DrawSimpleArrow
wxRect DrawSimpleArrow(wxDC& dc,
GtkWidget *widget,
int button_state,
wxRect const &in_rect,
int orientation,
GtkArrowType arrow_type)
{
int scroll_arrow_hlength, scroll_arrow_vlength;
gtk_widget_style_get(widget,
"scroll-arrow-hlength", &scroll_arrow_hlength,
"scroll-arrow-vlength", &scroll_arrow_vlength,
NULL);
GtkStateType state;
GtkShadowType shadow;
ButtonStateAndShadow(button_state, state, shadow);
wxRect out_rect;
if (orientation == wxLEFT)
out_rect.x = in_rect.x;
else
out_rect.x = in_rect.x + in_rect.width - scroll_arrow_hlength;
out_rect.y = (in_rect.y + in_rect.height - 3 * gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget())->ythickness - scroll_arrow_vlength) / 2;
out_rect.width = scroll_arrow_hlength;
out_rect.height = scroll_arrow_vlength;
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
GdkWindow* window = impldc->GetGDKWindow();
gtk_paint_arrow (gtk_widget_get_style(wxGTKPrivate::GetButtonWidget()), window, state, shadow, NULL, widget, "notebook",
arrow_type, TRUE, out_rect.x, out_rect.y, out_rect.width, out_rect.height);
return out_rect;
}
示例5: PaintBackground
// helper for OnPaint(): really erase the background, i.e. do it even if we
// don't have any non default brush for doing it (DoEraseBackground() doesn't
// do anything in such case)
void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
{
// note that we do not use the box background colour here, it shouldn't
// apply to its interior for several reasons:
// 1. wxGTK doesn't do it
// 2. controls inside the box don't get correct bg colour because they
// are not our children so we'd have some really ugly colour mix if
// we did it
// 3. this is backwards compatible behaviour and some people rely on it,
// see http://groups.google.com/groups?selm=4252E932.3080801%40able.es
wxWindow *parent = GetParent();
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(impl->GetHDC(), this);
// if there is no special brush for painting this control, just use the
// solid background colour
wxBrush brush;
if ( !hbr )
{
brush = wxBrush(parent->GetBackgroundColour());
hbr = GetHbrushOf(brush);
}
::FillRect(GetHdcOf(*impl), &rc, hbr);
}
示例6: wxHasCGContext
// check if we're having a CGContext we can draw into
inline bool wxHasCGContext(wxWindow* WXUNUSED(win), wxDC& dc)
{
wxGCDCImpl* gcdc = wxDynamicCast( dc.GetImpl() , wxGCDCImpl);
if ( gcdc )
{
if ( gcdc->GetGraphicsContext()->GetNativeContext() )
return true;
}
return false;
}
示例7: DrawCloseButton
wxRect DrawCloseButton(wxDC& dc,
GtkWidget *widget,
int button_state,
wxRect const &in_rect,
int orientation,
GdkRectangle* clipRect)
{
GtkStyle *style_button = gtk_widget_get_style(wxGTKPrivate::GetButtonWidget());
int xthickness = style_button->xthickness;
int ythickness = style_button->ythickness;
wxBitmap bmp(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
{
wxImage img = bmp.ConvertToImage();
img.Rescale(s_CloseIconSize, s_CloseIconSize);
bmp = img;
}
int button_size = s_CloseIconSize + 2 * xthickness;
wxRect out_rect;
if (orientation == wxLEFT)
out_rect.x = in_rect.x - ythickness;
else
out_rect.x = in_rect.x + in_rect.width - button_size - ythickness;
out_rect.y = in_rect.y + (in_rect.height - button_size) / 2;
out_rect.width = button_size;
out_rect.height = button_size;
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
GdkWindow* window = impldc->GetGDKWindow();
if (button_state == wxAUI_BUTTON_STATE_HOVER)
{
gtk_paint_box(style_button, window,
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, clipRect, widget, "button",
out_rect.x, out_rect.y, out_rect.width, out_rect.height);
}
else if (button_state == wxAUI_BUTTON_STATE_PRESSED)
{
gtk_paint_box(style_button, window,
GTK_STATE_ACTIVE, GTK_SHADOW_IN, clipRect, widget, "button",
out_rect.x, out_rect.y, out_rect.width, out_rect.height);
}
dc.DrawBitmap(bmp, out_rect.x + xthickness, out_rect.y + ythickness, true);
return out_rect;
}
示例8: DrawBackground
void wxAuiGtkTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect)
{
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
GdkWindow* window = impldc->GetGDKWindow();
gtk_style_apply_default_background(gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget()),
window,
true,
GTK_STATE_NORMAL,
NULL,
rect.x, rect.y, rect.width, rect.height);
}
示例9: wxRenderer_DrawScrollbar
void wxRenderer_DrawScrollbar(wxWindow* WXUNUSED(window), wxDC& dc,
const wxRect& rect, wxOrientation orient, int current,
wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int max, int step, int flags)
{
const wxCoord x = rect.x;
const wxCoord y = rect.y;
const wxCoord w = rect.width;
const wxCoord h = rect.height;
dc.SetBrush( *wxWHITE_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(rect);
dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect hiRect = CGRectMake( x, y, w, h );
CGContextRef cgContext = NULL;
wxGraphicsContext* gc = NULL;
#if wxCHECK_VERSION(2,9,0)
wxGCDCImpl *impl = dynamic_cast<wxGCDCImpl*> (dc.GetImpl());
if (impl)
gc = impl->GetGraphicsContext();
#else
gc = dc.GetGraphicsContext();
#endif
if (gc)
cgContext = (CGContextRef) gc->GetNativeContext();
if (cgContext)
{
HIThemeTrackDrawInfo trackInfo;
trackInfo.version = 0;
trackInfo.kind = kThemeMediumScrollBar;
trackInfo.bounds = hiRect;
trackInfo.min = 0;
trackInfo.max = max;
trackInfo.value = current;
trackInfo.trackInfo.scrollbar.viewsize = step;
trackInfo.attributes = 0;
if (orient == wxHORIZONTAL)
trackInfo.attributes |= kThemeTrackHorizontal;
trackInfo.enableState = (flags & wxCONTROL_FOCUSED) ? kThemeTrackActive : kThemeTrackInactive;
trackInfo.trackInfo.scrollbar.pressState = wxScrollbarPartToHIPressedState(focusPart);
trackInfo.attributes |= kThemeTrackShowThumb;
if (flags & wxCONTROL_DISABLED)
trackInfo.enableState = kThemeTrackDisabled;
HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
}
}
示例10: OnDrawItem
bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
wxODAction act, wxODStatus stat)
{
// first draw the label
if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) )
return false;
// now draw the check mark part
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
HDC hdc = GetHdcOf(*impl);
wxSize size = wxRendererNative::Get().GetCheckBoxSize(GetParent());
// first create bitmap in a memory DC
MemoryHDC hdcMem(hdc);
CompatibleBitmap hBmpCheck(hdc, size.GetWidth(), size.GetHeight());
// then draw a check mark into it
{
SelectInHDC selBmp(hdcMem, hBmpCheck);
int flags = wxCONTROL_FLAT;
if ( IsChecked() )
flags |= wxCONTROL_CHECKED;
wxDCTemp dcMem(hdcMem);
wxRendererNative::Get().DrawCheckBox(GetParent(), dcMem, wxRect(size), flags);
} // select hBmpCheck out of hdcMem
// finally draw bitmap to screen
// position of check mark bitmap
int x = rc.GetX() + CHECKMARK_EXTRA_SPACE;
int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2;
UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL;
// checkmarks should not be mirrored in RTL layout
DWORD oldLayout = impl->GetLayoutDirection() == wxLayout_RightToLeft ? LAYOUT_RTL : 0;
if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout | LAYOUT_BITMAPORIENTATIONPRESERVED);
wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState);
if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout);
return true;
}
示例11: Draw
// Draws the given image on a dc at the specified position.
// If 'solidBackground' is true, Draw sets the image list background
// colour to the background colour of the wxDC, to speed up
// drawing by eliminating masked drawing where possible.
bool wxImageList::Draw(int index,
wxDC& dc,
int x, int y,
int flags,
bool solidBackground)
{
wxDCImpl *impl = dc.GetImpl();
wxMSWDCImpl *msw_impl = wxDynamicCast( impl, wxMSWDCImpl );
if (!msw_impl)
return false;
HDC hDC = GetHdcOf(*msw_impl);
wxCHECK_MSG( hDC, false, wxT("invalid wxDC in wxImageList::Draw") );
COLORREF clr = CLR_NONE; // transparent by default
if ( solidBackground )
{
const wxBrush& brush = dc.GetBackground();
if ( brush.IsOk() )
{
clr = wxColourToRGB(brush.GetColour());
}
}
ImageList_SetBkColor(GetHImageList(), clr);
UINT style = 0;
if ( flags & wxIMAGELIST_DRAW_NORMAL )
style |= ILD_NORMAL;
if ( flags & wxIMAGELIST_DRAW_TRANSPARENT )
style |= ILD_TRANSPARENT;
if ( flags & wxIMAGELIST_DRAW_SELECTED )
style |= ILD_SELECTED;
if ( flags & wxIMAGELIST_DRAW_FOCUSED )
style |= ILD_FOCUS;
bool ok = ImageList_Draw(GetHImageList(), index, hDC, x, y, style) != 0;
if ( !ok )
{
wxLogLastError(wxT("ImageList_Draw()"));
}
return ok;
}
示例12: hTheme
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);
}
示例13: DrawSash
void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
{
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
wxUnusedVar(window);
wxUnusedVar(orientation);
HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
CGContextRef cgContext ;
wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;
HIThemeSplitterDrawInfo drawInfo ;
drawInfo.version = 0 ;
drawInfo.state = kThemeStateActive ;
drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;
#elif defined(__WXGTK__)
// clear out the rectangle first
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_sash_brush);
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#if 0
GdkRectangle gdk_rect;
if (orientation == wxVERTICAL )
{
gdk_rect.x = rect.x;
gdk_rect.y = rect.y;
gdk_rect.width = m_sash_size;
gdk_rect.height = rect.height;
}
else
{
gdk_rect.x = rect.x;
gdk_rect.y = rect.y;
gdk_rect.width = rect.width;
gdk_rect.height = m_sash_size;
}
#endif
if (!window) return;
if (!window->m_wxwindow) return;
if (!gtk_widget_is_drawable(window->m_wxwindow)) return;
gtk_paint_handle
(
gtk_widget_get_style(window->m_wxwindow),
window->GTKGetDrawingWindow(),
// flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_STATE_NORMAL,
GTK_SHADOW_NONE,
NULL /* no clipping */,
window->m_wxwindow,
"paned",
rect.x,
rect.y,
rect.width,
rect.height,
(orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
);
#else
wxUnusedVar(window);
wxUnusedVar(orientation);
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_sash_brush);
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}
示例14: OnDrawItem
bool wxMenuItem::OnDrawItem( wxDC& rDC,
const wxRect& rRect,
wxODAction eAction,
wxODStatus eStatus )
{
//
// Select the font and draw the text
// ---------------------------------
//
CHARBUNDLE vCbnd;
wxPMDCImpl *impl = (wxPMDCImpl*) rDC.GetImpl();
HPS hPS= impl->GetHPS();
wxFont vFont;
wxColour vColBack;
wxColour vColText;
COLORREF vRef;
RECTL vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};
memset(&vCbnd, 0, sizeof(CHARBUNDLE));
GetFontToUse(vFont);
GetColourToUse(eStatus, vColText, vColBack);
rDC.SetFont(vFont);
rDC.SetTextBackground(vColBack);
rDC.SetTextForeground(vColText);
rDC.SetBackgroundMode(wxTRANSPARENT);
vCbnd.lColor = vColText.GetPixel();
vCbnd.lBackColor = vColBack.GetPixel();
::GpiSetAttrs( hPS
,PRIM_CHAR
,CBB_BACK_COLOR | CBB_COLOR
,0
,&vCbnd
);
::GpiSetBackMix( hPS
,BM_LEAVEALONE
);
//
// Paint the background
//
::WinFillRect(hPS, &vRect, vColBack.GetPixel());
//
// Determine where to draw and leave space for a check-mark.
//
int nX = rRect.x + GetMarginWidth();
//
// Unfortunately, unlike Win32, PM has no owner drawn specific text
// drawing methods like ::DrawState that can cleanly handle accel
// mnemonics and deal, automatically, with various states, so we have
// to handle them ourselves. Notice Win32 can't handle \t in ownerdrawn
// strings either. We cannot handle mnemonics either. We display
// them, though, in the hope we can figure them out some day.
//
//
// Display main text and accel text separately to align better
//
wxString sTgt = wxT("\t");
wxString sFullString = GetItemLabel(); // need to save the original text
wxString sAccel;
int nIndex;
size_t nWidth;
size_t nCharWidth;
size_t nHeight;
bool bFoundMnemonic = false;
bool bFoundAccel = false;
//
// Deal with the tab, extracting the Accel text
//
nIndex = sFullString.Find(sTgt);
if (nIndex != -1)
{
bFoundAccel = true;
sAccel = sFullString.Mid(nIndex + 1);
sFullString.Remove(nIndex);
}
//
// Deal with the mnemonic character
//
sTgt = wxT("~");
nIndex = sFullString.Find(sTgt);
if (nIndex != -1)
{
wxString sTmp = sFullString;
bFoundMnemonic = true;
sTmp.Remove(nIndex);
rDC.GetTextExtent( sTmp
,(wxCoord *)&nWidth
,(wxCoord *)&nHeight
);
//.........这里部分代码省略.........
示例15: OnDrawItem
// 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;
}