本文整理汇总了C++中wxDC::GetBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetBackground方法的具体用法?C++ wxDC::GetBackground怎么用?C++ wxDC::GetBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetBackground方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: Draw
//+-------------------------------------------------------------+
//| Card::Draw() |
//+-------------------------------------------------------------+
//| Description: |
//| Draw the card at (x, y). |
//| If the card is facedown draw the back of the card. |
//| If the card is faceup draw the front of the card. |
//| Cards are not held in bitmaps, instead they are drawn |
//| from their constituent parts when required. |
//| hbmap_symbols contains large and small suit symbols and |
//| pip values. These are copied to the appropriate part of |
//| the card. Picture cards use the pictures defined in |
//| hbmap_pictures. Note that only one picture is defined |
//| for the Jack, Queen and King, unlike a real pack where |
//| each suit is different. |
//| |
//| WARNING: |
//| The locations of these symbols is 'hard-wired' into the |
//| code. Editing the bitmaps or the numbers below will |
//| result in the wrong symbols being displayed. |
//+-------------------------------------------------------------+
void Card::Draw(wxDC& dc, int x, int y)
{
wxBrush backgroundBrush( dc.GetBackground() );
dc.SetBrush(* wxWHITE_BRUSH);
dc.SetPen(* wxBLACK_PEN);
dc.DrawRoundedRectangle(x, y, m_width, m_height, 4);
if (m_wayUp == facedown)
{
dc.SetBackground(* wxRED_BRUSH);
dc.SetBackgroundMode(wxSOLID);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
*wxBLACK, wxCROSSDIAG_HATCH
);
dc.SetBrush(* brush);
dc.DrawRoundedRectangle(
x + 4, y + 4,
m_width - 8, m_height - 8,
2
);
}
else
{
wxMemoryDC memoryDC;
memoryDC.SelectObject(*m_symbolBmap);
// dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextBackground(*wxWHITE);
switch (m_suit)
{
case spades:
case clubs:
dc.SetTextForeground(*wxBLACK);
break;
case diamonds:
case hearts:
dc.SetTextForeground(*wxRED);
break;
}
int symsize = 11;
int sympos = 14;
int sympos2 = 25;
int symdist = 5;
int symdist2 = 6;
int pipsize,pippos,valueheight,valuewidth;
int valuepos;
if (m_scale > 1.2)
{
pipsize = symsize;
pippos = sympos;
valueheight = 10;
valuewidth = 9;
valuepos = 50;
}
else
{
pipsize = 7;
pippos = 0;
valueheight = 7;
valuewidth = 6;
valuepos = 36;
}
// Draw the value
dc.Blit((wxCoord)(x + m_scale*3),
(wxCoord)(y + m_scale*3),
valuewidth,
valueheight,
&memoryDC,
valuewidth * (m_pipValue - 1),
valuepos,
wxCOPY);
dc.Blit((wxCoord)(x + m_width - m_scale*3 - valuewidth),
(wxCoord)(y + m_height - valueheight - m_scale*3),
valuewidth,
//.........这里部分代码省略.........
示例3: Draw
void wxHtmlWordCell::Draw(wxDC& dc, int x, int y,
int WXUNUSED(view_y1), int WXUNUSED(view_y2),
wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
dc.SetPen(*wxBLACK_PEN);
dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width /* VZ: +1? */ ,m_Height);
#endif
bool drawSelectionAfterCell = false;
if ( info.GetState().GetSelectionState() == wxHTML_SEL_CHANGING )
{
// Selection changing, we must draw the word piecewise:
wxHtmlSelection *s = info.GetSelection();
wxString txt;
int w, h;
int ofs = 0;
wxPoint priv = (this == s->GetFromCell()) ?
s->GetFromPrivPos() : s->GetToPrivPos();
// NB: this is quite a hack: in order to compute selection boundaries
// (in word's characters) we must know current font, which is only
// possible inside rendering code. Therefore we update the
// information here and store it in wxHtmlSelection so that
// ConvertToText can use it later:
if ( priv == wxDefaultPosition )
{
SetSelectionPrivPos(dc, s);
priv = (this == s->GetFromCell()) ?
s->GetFromPrivPos() : s->GetToPrivPos();
}
int part1 = priv.x;
int part2 = priv.y;
if ( part1 > 0 )
{
txt = m_Word.Mid(0, part1);
dc.DrawText(txt, x + m_PosX, y + m_PosY);
dc.GetTextExtent(txt, &w, &h);
ofs += w;
}
SwitchSelState(dc, info, true);
txt = m_Word.Mid(part1, part2-part1);
dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);
if ( (size_t)part2 < m_Word.length() )
{
dc.GetTextExtent(txt, &w, &h);
ofs += w;
SwitchSelState(dc, info, false);
txt = m_Word.Mid(part2);
dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);
}
else
drawSelectionAfterCell = true;
}
else
{
wxHtmlSelectionState selstate = info.GetState().GetSelectionState();
// Not changing selection state, draw the word in single mode:
if ( selstate != wxHTML_SEL_OUT &&
dc.GetBackgroundMode() != wxSOLID )
{
SwitchSelState(dc, info, true);
}
else if ( selstate == wxHTML_SEL_OUT &&
dc.GetBackgroundMode() == wxSOLID )
{
SwitchSelState(dc, info, false);
}
dc.DrawText(m_Word, x + m_PosX, y + m_PosY);
drawSelectionAfterCell = (selstate != wxHTML_SEL_OUT);
}
// NB: If the text is justified then there is usually some free space
// between adjacent cells and drawing the selection only onto cells
// would result in ugly unselected spaces. The code below detects
// this special case and renders the selection *outside* the sell,
// too.
if ( m_Parent->GetAlignHor() == wxHTML_ALIGN_JUSTIFY &&
drawSelectionAfterCell )
{
wxHtmlCell *nextCell = m_Next;
while ( nextCell && nextCell->IsFormattingCell() )
nextCell = nextCell->GetNext();
if ( nextCell )
{
int nextX = nextCell->GetPosX();
if ( m_PosX + m_Width < nextX )
{
dc.SetBrush(dc.GetBackground());
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(x + m_PosX + m_Width, y + m_PosY,
nextX - m_PosX - m_Width, m_Height);
}
//.........这里部分代码省略.........