本文整理汇总了C++中wxDC::SetBackgroundMode方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::SetBackgroundMode方法的具体用法?C++ wxDC::SetBackgroundMode怎么用?C++ wxDC::SetBackgroundMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::SetBackgroundMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTextLine
void wxStdRenderer::DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
int selStart,
int selEnd,
int flags)
{
if ( (selStart == -1) || !(flags & wxCONTROL_FOCUSED) )
{
// just draw it as is
dc.DrawText(text, rect.x, rect.y);
}
else // we have selection
{
wxCoord width,
x = rect.x;
// draw the part before selection
wxString s(text, (size_t)selStart);
if ( !s.empty() )
{
dc.DrawText(s, x, rect.y);
dc.GetTextExtent(s, &width, NULL);
x += width;
}
// draw the selection itself
s = wxString(text.c_str() + selStart, text.c_str() + selEnd);
if ( !s.empty() )
{
wxColour colFg = dc.GetTextForeground(),
colBg = dc.GetTextBackground();
dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
dc.SetTextBackground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT));
dc.SetBackgroundMode(wxSOLID);
dc.DrawText(s, x, rect.y);
dc.GetTextExtent(s, &width, NULL);
x += width;
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextBackground(colBg);
dc.SetTextForeground(colFg);
}
// draw the final part
s = text.c_str() + selEnd;
if ( !s.empty() )
{
dc.DrawText(s, x, rect.y);
}
}
}
示例2: DrawTextTransparent
void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font, int ybase,
const char *s, int len,
ColourAllocated fore) {
SetFont(font);
hdc->SetTextForeground(wxColourFromCA(fore));
hdc->SetBackgroundMode(wxTRANSPARENT);
// ybase is where the baseline should be, but wxWin uses the upper left
// corner, so I need to calculate the real position for the text...
hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
hdc->SetBackgroundMode(wxSOLID);
}
示例3: DrawBackground
/* draws alternating background colours */
void CBOINCGridCellRenderer::DrawBackground(wxGrid& grid,
wxDC& dc,
const wxRect& rect,
int row,
bool isSelected)
{
dc.SetBackgroundMode( wxSOLID );
// grey out fields if the grid is disabled
if( grid.IsEnabled() )
{
if ( isSelected )
{
dc.SetBrush( wxBrush(grid.GetSelectionBackground(), wxSOLID) );
}
else
{
//alternate background colours
if(row % 2 == 0) {
dc.SetBrush(wxBrush(wxColour(240,240,240)));
}
else {
dc.SetBrush(*wxWHITE_BRUSH);
}
}
}
else
{
dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
}
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(rect);
}
示例4: Render
/*
* Here we do the actual rendering. I put it in a separate
* method so that it can work no matter what type of DC
* (e.g. wxPaintDC or wxClientDC) is used.
*/
void BasicDrawPane::Render(wxDC& dc)
{
int width, height;
this->GetSize(&width, &height);
if ( m_bgColor.IsOk() )
{
dc.SetBrush(wxBrush(m_bgColor));
dc.DrawRectangle(0, 0, width, height);
}
if ( m_textForeGround.IsOk() )
{
dc.SetTextForeground( m_textForeGround );
}
if ( !m_text.IsEmpty() )
{
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetFont( m_font );
/*
* ちょうど中央表示できるよう調整
*/
const int cHeight = dc.GetCharHeight();
const int cWidth = dc.GetCharWidth();
const int textLen = m_text.Len();
const int textHalfSize = textLen * cWidth / 2;
dc.DrawText( m_text, width / 2 - textHalfSize, height / 2 - cHeight / 2 );
}
}
示例5: Draw
void wxGridCellRenderer::Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int WXUNUSED(row), int WXUNUSED(col),
bool isSelected)
{
dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID );
wxColour clr;
if ( grid.IsThisEnabled() )
{
if ( isSelected )
{
if ( grid.HasFocus() )
clr = grid.GetSelectionBackground();
else
clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
}
else
{
clr = attr.GetBackgroundColour();
}
}
else // grey out fields if the grid is disabled
{
clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
}
dc.SetBrush(clr);
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(rect);
}
示例6: SetTextColoursAndFont
void wxSheetCellStringRendererRefData::SetTextColoursAndFont(wxSheet& sheet,
const wxSheetCellAttr& attr,
wxDC& dc,
bool isSelected)
{
dc.SetBackgroundMode( wxTRANSPARENT );
// TODO some special colours for attr.IsReadOnly() case?
// different coloured text when the sheet is disabled
if ( sheet.IsEnabled() )
{
if ( isSelected )
{
dc.SetTextBackground( sheet.GetSelectionBackground() );
dc.SetTextForeground( sheet.GetSelectionForeground() );
}
else
{
dc.SetTextBackground( attr.GetBackgroundColour() );
dc.SetTextForeground( attr.GetForegroundColour() );
}
}
else
{
dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
}
dc.SetFont( attr.GetFont() );
}
示例7: OnDraw
void wxDivisionShape::OnDraw(wxDC &dc)
{
dc.SetBrush(* wxTRANSPARENT_BRUSH);
dc.SetBackgroundMode(wxTRANSPARENT);
double x1 = (double)(GetX() - (GetWidth() / 2.0));
double y1 = (double)(GetY() - (GetHeight() / 2.0));
double x2 = (double)(GetX() + (GetWidth() / 2.0));
double y2 = (double)(GetY() + (GetHeight() / 2.0));
// Should subtract 1 pixel if drawing under Windows
#ifdef __WXMSW__
y2 -= (double)1.0;
#endif
if (m_leftSide)
{
dc.SetPen(* m_leftSidePen);
dc.DrawLine(WXROUND(x1), WXROUND(y2), WXROUND(x1), WXROUND(y1));
}
if (m_topSide)
{
dc.SetPen(* m_topSidePen);
dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y1));
}
// For testing purposes, draw a rectangle so we know
// how big the division is.
// SetBrush(* wxCYAN_BRUSH);
// wxRectangleShape::OnDraw(dc);
}
示例8: PaintTrackCursor
void AudioDisplay::PaintTrackCursor(wxDC &dc) {
wxDCPenChanger penchanger(dc, wxPen(*wxWHITE));
dc.DrawLine(track_cursor_pos-scroll_left, audio_top, track_cursor_pos-scroll_left, audio_top+audio_height);
if (track_cursor_label.empty()) return;
wxDCFontChanger fc(dc);
wxFont font = dc.GetFont();
font.SetWeight(wxFONTWEIGHT_BOLD);
dc.SetFont(font);
wxSize label_size(dc.GetTextExtent(track_cursor_label));
wxPoint label_pos(track_cursor_pos - scroll_left - label_size.x/2, audio_top + 2);
label_pos.x = mid(2, label_pos.x, GetClientSize().GetWidth() - label_size.x - 2);
int old_bg_mode = dc.GetBackgroundMode();
dc.SetBackgroundMode(wxTRANSPARENT);
// Draw border
dc.SetTextForeground(wxColour(64, 64, 64));
dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y+1);
dc.DrawText(track_cursor_label, label_pos.x+1, label_pos.y-1);
dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y+1);
dc.DrawText(track_cursor_label, label_pos.x-1, label_pos.y-1);
// Draw fill
dc.SetTextForeground(*wxWHITE);
dc.DrawText(track_cursor_label, label_pos.x, label_pos.y);
dc.SetBackgroundMode(old_bg_mode);
label_pos.x -= 2;
label_pos.y -= 2;
label_size.IncBy(4, 4);
// If the rendered text changes size we have to draw it an extra time to make sure the entire thing was drawn
bool need_extra_redraw = track_cursor_label_rect.GetSize() != label_size;
track_cursor_label_rect.SetPosition(label_pos);
track_cursor_label_rect.SetSize(label_size);
if (need_extra_redraw)
RefreshRect(track_cursor_label_rect, false);
}
示例9: Redraw
void Pack::Redraw(wxDC& dc)
{
Pile::Redraw(dc);
wxString str;
str.Printf(wxT("%d "), m_topCard + 1);
dc.SetBackgroundMode( wxSOLID );
dc.SetTextBackground(FortyApp::BackgroundColour());
dc.SetTextForeground(FortyApp::TextColour());
dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2);
}
示例10: SwitchSelState
static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info,
bool toSelection)
{
wxColour fg = info.GetState().GetFgColour();
wxColour bg = info.GetState().GetBgColour();
if ( toSelection )
{
dc.SetBackgroundMode(wxSOLID);
dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg));
dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg));
dc.SetBackground(wxBrush(info.GetStyle().GetSelectedTextBgColour(bg),
wxSOLID));
}
else
{
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(fg);
dc.SetTextBackground(bg);
dc.SetBackground(wxBrush(bg, wxSOLID));
}
}
示例11: DrawItem
void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{
if (m_treeCtrl)
{
wxString text = m_treeCtrl->GetItemText(id);
dc.SetTextForeground(* wxBLACK);
dc.SetBackgroundMode(wxTRANSPARENT);
int textW, textH;
dc.GetTextExtent(text, & textW, & textH);
int x = 5;
int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
dc.DrawText(text, x, y);
}
}
示例12: DoPrepareDC
void EDA_DRAW_PANEL::DoPrepareDC( wxDC& dc )
{
wxScrolledWindow::DoPrepareDC( dc );
if( GetScreen() != NULL )
{
double scale = GetScreen()->GetScalingFactor();
dc.SetUserScale( scale, scale );
wxPoint pt = GetScreen()->m_DrawOrg;
dc.SetLogicalOrigin( pt.x, pt.y );
}
SetClipBox( dc ); // Reset the clip box to the entire screen.
GRResetPenAndBrush( &dc );
dc.SetBackgroundMode( wxTRANSPARENT );
}
示例13: DrawColLabel
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */
void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col )
{
if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 )
return;
int colLeft = GetColLeft(col);
wxRect rect;
int colRight = GetColRight(col) - 1;
dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
dc.DrawLine( colRight, 0,
colRight, m_colLabelHeight-1 );
dc.DrawLine( colLeft, 0, colRight, 0 );
dc.DrawLine( colLeft, m_colLabelHeight-1,
colRight+1, m_colLabelHeight-1 );
dc.SetPen( *wxWHITE_PEN );
dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 );
dc.DrawLine( colLeft, 1, colRight, 1 );
dc.SetBackgroundMode( wxTRANSPARENT );
dc.SetTextForeground( GetLabelTextColour() );
dc.SetFont( GetLabelFont() );
int hAlign, vAlign, orient;
GetColLabelAlignment( &hAlign, &vAlign );
orient = GetColLabelTextOrientation();
rect.SetX( colLeft + 2 );
rect.SetY( 2 );
rect.SetWidth( GetColWidth(col) - 4 );
rect.SetHeight( m_colLabelHeight - 4 );
DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
//paint sorting indicators, if needed
if(col == sortColumn) {
int x = rect.GetRight() - ascBitmap.GetWidth() - 2;
int y = rect.GetY();
dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true);
}
}
示例14: Draw
void wxSheetCellRendererRefData::Draw( wxSheet& sheet,
const wxSheetCellAttr& attr,
wxDC& dc,
const wxRect& rect,
const wxSheetCoords& UNUSE(coords),
bool isSelected )
{
dc.SetBackgroundMode( wxSOLID );
// grey out fields if the sheet is disabled
if ( sheet.IsEnabled() )
{
if ( isSelected )
dc.SetBrush( wxBrush(sheet.GetSelectionBackground(), wxSOLID) );
else
dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxSOLID) );
}
else
dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(rect);
#ifdef TEST_SELECTION_BLOCKS // colouring for identifying different blocks
if (isSelected)
{
int i = sheet.GetSelection()->Index(coords);
wxColour c(GetRainbow(i*10));
dc.SetBrush( wxBrush(c, wxSOLID) );
dc.DrawRectangle(rect);
wxFont font = dc.GetFont();
dc.SetFont(*wxSMALL_FONT);
dc.DrawText(wxString::Format(wxT("%d"), i), rect.x, rect.y);
}
#endif // TEST_SELECTION_BLOCKS
//FIXME - border drawing code, maybe it goes here?
//dc.SetPen( wxPen(sheet.GetGridLineColour(), 1, wxSOLID) );
//dc.DrawRectangle(rect.x-1, rect.y-1, rect.width+2, rect.height+2);
}
示例15: DrawItem
virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{
if (m_treeCtrl)
{
PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id);
wxString text;
if (data != NULL) text = data->EditCtrl->GetValueAsText(id);
dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
dc.DrawRectangle(rect);
dc.SetTextForeground(* wxBLACK);
dc.SetBackgroundMode(wxTRANSPARENT);
int textW, textH;
dc.GetTextExtent(text, & textW, & textH);
int x = 5;
int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
dc.DrawText(text, x, y);
}
}