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); } } }
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); }
/* 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); }
/* * 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 ); } }
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); }
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() ); }
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); }
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); }
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); }
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)); } }
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); } }
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 ); }
/* 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); } }
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); }
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); } }
// -------------------------------------------------------------------------------- // void guAlListBox::DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const { m_Attr.m_Font->SetPointSize( 10 ); guAlbumItem * Item = &( * ( guAlbumItems * ) m_Items )[ row ]; dc.SetFont( * m_Attr.m_Font ); dc.SetBackgroundMode( wxTRANSPARENT ); dc.SetTextForeground( IsSelected( row ) ? m_Attr.m_SelFgColor : m_Attr.m_TextFgColor ); dc.DrawText( Item->m_Name, rect.x + 45, rect.y + 4 ); if( Item->m_Year ) { int Pos; dc.GetTextExtent( Item->m_Name, &Pos, NULL ); Pos += rect.x + 45; m_Attr.m_Font->SetPointSize( 7 ); dc.SetFont( * m_Attr.m_Font ); dc.DrawText( wxString::Format( wxT( " (%4u)" ), Item->m_Year ), Pos, rect.y + 7 ); } if( !Item->m_ArtistName.IsEmpty() ) { m_Attr.m_Font->SetPointSize( 8 ); dc.SetFont( * m_Attr.m_Font ); dc.DrawText( _( "by " ) + Item->m_ArtistName, rect.x + 45, rect.y + 22 ); } if( Item->m_Thumb ) { dc.DrawBitmap( * Item->m_Thumb, rect.x + 1, rect.y + 1, false ); } // else if( Item->m_Thumb ) // { // guLogError( wxT( "Thumb image corrupt or not correctly loaded" ) ); // } }
void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid, const wxGridCellAttr& attr, wxDC& dc, bool isSelected) { dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT ); // TODO some special colours for attr.IsReadOnly() case? // different coloured text when the grid is disabled if ( grid.IsThisEnabled() ) { if ( isSelected ) { wxColour clr; if ( grid.HasFocus() ) clr = grid.GetSelectionBackground(); else clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); dc.SetTextBackground( clr ); dc.SetTextForeground( grid.GetSelectionForeground() ); } else { dc.SetTextBackground( attr.GetBackgroundColour() ); dc.SetTextForeground( attr.GetTextColour() ); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont( attr.GetFont() ); }
void SeqAA::show_direct ( wxDC& dc ) { myass ( itemsperline , "AA:show_direct_ipl" ) ; if ( !itemsperline ) return ; mylog ( "SeqAA::show_direct" , "0" ) ; can->SetFont(*can->font); dc.SetFont(*can->font); int a , b , w , h , n , bo = can->border ; int csgc = can->NumberOfLines() , cbs = can->blocksize ; int cih = can->isHorizontal() ; int xa , xb , ya , yb ; for ( n = 0 ; n < csgc && can->seq[n] != this ; n++ ) ; if ( n == csgc ) return ; mylog ( "SeqAA::show_direct" , "1" ) ; // Setting basic values int cw = can->charwidth , ch = can->charheight ; int ox = bo + cw + cw * endnumberlength ; int oy = n*ch+bo ; can->MyGetClientSize ( &w , &h ) ; xb = w ; yb = h ; wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; wxColour tf ; if ( primaryMode ) tf = *wxBLACK ; else tf = myapp()->frame->aa_color ;; // wxColour ( 130 , 130 , 130 ) ;//*wxLIGHT_GREY ; dc.SetTextForeground ( tf ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.GetDeviceOrigin ( &xa , &ya ) ; xa = -xa ; xb += xa ; ya = -ya ; yb += ya ; mylog ( "SeqAA::show_direct" , "2" ) ; b = ( ya - ch - oy ) / ( ch * csgc ) * itemsperline ; mylog ( "SeqAA::show_direct" , "3" ) ; for ( a = 0 ; a < b && a < s.length() ; a += itemsperline ) ; for ( ; a < s.length() ; a++ ) { int px = a % itemsperline , py = a / itemsperline ; bool showNumber = ( px == 0 ) ; px = px * cw + ( px / cbs ) * ( cw - 1 ) + ox ; py = py * ch * csgc + oy ; if ( !can->getDrawAll() ) { if ( py + ch < ya ) continue ; if ( py > yb ) break ; if ( cih ) { if ( px + cw < xa ) continue ; if ( px > xb ) continue ; } } int pm = getMark ( a ) ; if ( pm == 1 ) // Marked (light gray background) { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ; } else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxBLACK ) ; } if ( pm == 2 && can->doOverwrite() ) dc.SetTextForeground ( *wxWHITE ) ; else dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ; if ( can->isPrinting() && pm == 1 ) { dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ; dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle ( px , py , cw , ch ) ; } if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( *wxBLACK ) ; } // Show the char wxChar ch2 = s.GetChar(a) ; if ( ch2 == '|' ) ch2 = myapp()->frame->stopcodon ; dc.DrawText ( wxString ( ch2 ) , px , py ) ; int pz = py + ch ; if ( pm == 2 && !can->doOverwrite() ) // Insert cursor { dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( px-1 , py , px-1 , pz ) ; dc.DrawLine ( px-3 , py , px+2 , py ) ; dc.DrawLine ( px-3 , pz , px+2 , pz ) ; } if ( pm > 0 ) // Reverting cursor settings { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ; } // Protease cuts for ( int q = 0 ; q < pc.GetCount() ; q++ ) { if ( a == pc[q]->cut - pc[q]->left ) { int qx = px ; int qy = py ; if ( !pc[q]->left ) qx += cw + 4 ; dc.SetTextForeground ( *wxBLACK ) ; dc.SetPen(*wxGREY_PEN); dc.DrawLine ( qx , qy + 1 , qx , qy + can->charheight - 2 ) ; dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( qx+1 , qy + 1 , qx+1 , qy + can->charheight - 2 ) ; wxString pn = pc[q]->protease->name ; for ( int w = 0 ; w+1 < pn.length() ; w++ ) if ( pn.GetChar(w) == ' ' && pn.GetChar(w+1) == '(' ) pn = pn.substr ( 0 , w ) ; dc.SetFont(*can->smallFont); int u1 , u2 ; dc.GetTextExtent ( pn , &u1 , &u2 ) ; dc.DrawText ( pn , qx - u1/2 , qy - u2/2 ) ; dc.SetFont(*can->font); if ( primaryMode ) dc.SetTextForeground ( getHighlightColor ( a , *wxBLACK ) ) ; else dc.SetTextForeground ( myapp()->frame->aa_color /* *wxLIGHT_GREY */ ) ; } } if ( showNumber && primaryMode ) { wxString t = wxString::Format ( _T("%d") , a + 1 ) ; while ( endnumberlength > t.length() ) t = _T("0") + t ; // t.Pad ( endnumberlength - t.length() , '0' , false ) ; dc.DrawText ( t , bo , py ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
void SeqDNA::show_direct ( wxDC& dc ) { myass ( itemsperline , "DNA:show_direct_ipl" ) ; if ( !itemsperline ) return ; myass ( can , "SeqDNA::show_direct1" ) ; can->SetFont(*can->font); dc.SetFont(*can->font); int a , b , w , h , n , bo = can->border ; int csgc = can->NumberOfLines() , cbs = can->blocksize ; int cih = can->isHorizontal() ; int xa , xb , ya , yb ; for ( n = 0 ; n < can->seq.GetCount() && can->seq[n] != this ; n++ ) ; if ( n == can->seq.GetCount() ) return ; // Setting basic values int cw = can->charwidth , ch = can->charheight ; int ox = bo + cw + cw * endnumberlength ; int oy = n*ch+bo ; bool isPrimer = false ; if ( whatsthis().StartsWith ( _T("PRIMER") ) ) isPrimer = true ; can->MyGetClientSize ( &w , &h ) ; xb = w ; yb = h ; wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; dc.SetTextForeground ( fontColor ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.GetDeviceOrigin ( &xa , &ya ) ; xa = -xa ; xb += xa ; ya = -ya ; yb += ya ; myass ( ch , "SeqDNA::show_direct2a" ) ; myass ( csgc , "SeqDNA::show_direct2b" ) ; b = ( ya - ch - oy ) / ( ch * csgc ) * itemsperline ; for ( a = 0 ; a < b && a < s.length() ; a += itemsperline ) ; myass ( itemsperline , "SeqDNA::show_direct3" ) ; myass ( cbs , "SeqDNA::show_direct4" ) ; for ( a = 0 ; a < s.length() ; a++ ) { int px = a % itemsperline , py = a / itemsperline ; bool showNumber = ( px == 0 ) ; px = px * cw + ( px / cbs ) * ( cw - 1 ) + ox ; py = py * ch * csgc + oy ; if ( !can->getDrawAll() ) { if ( py + ch < ya ) continue ; if ( py > yb ) break ; if ( cih ) { if ( px + cw < xa ) continue ; if ( px > xb ) continue ; } } int pm = getMark ( a ) ; char ac = s.GetChar(a) ; if ( pm == 0 && !showNumber && ac == ' ' ) continue ; if ( pm == 1 ) // Marked (light gray background) { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; dc.SetTextForeground ( *wxBLACK ) ; } else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxBLACK ) ; dc.SetTextForeground ( *wxWHITE ) ; } else dc.SetTextForeground ( getHighlightColor ( a , getBaseColor ( ac ) ) ) ; if ( isPrimer ) { if ( s.GetChar(a) == vec->getSequenceChar(a) ) dc.SetTextForeground ( *wxBLUE ) ; else dc.SetTextForeground ( *wxRED ) ; } if ( can->isPrinting() && pm == 1 ) { dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ; dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle ( px , py , cw , ch ) ; } if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( *wxBLACK ) ; } dc.DrawText ( wxString ( (wxChar) ac ) , px , py ) ; int pz = py + ch ; if ( pm == 2 && !can->doOverwrite() ) // Insert cursor { dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( px-1 , py , px-1 , pz ) ; dc.DrawLine ( px-3 , py , px+2 , py ) ; dc.DrawLine ( px-3 , pz , px+2 , pz ) ; } if ( pm > 0 ) // Reverting cursor settings { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( fontColor ) ; } // Methylation if ( !invers && alternateName.IsEmpty() && wxNOT_FOUND != vec->getMethylationSiteIndex ( a ) ) { dc.SetPen(*wxRED_PEN); dc.DrawLine ( px , py + ch - 2 , px + cw , py + ch - 2 ) ; dc.SetPen(*wxTRANSPARENT_PEN); } if ( showNumber ) { dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; mylog ( "SeqDNA::show_direct" , "A" ) ; wxString t ; if ( showNumbers ) { mylog ( "SeqDNA::show_direct" , "B" ) ; t = wxString::Format ( _T("%d") , a + 1 ) ; int padd = endnumberlength - t.length() ; mylog ( "SeqDNA::show_direct" , wxString::Format ( "C: %d, %d" , endnumberlength , padd ) ) ; if ( padd > 0 && padd < 20 ) t.Pad ( padd , '0' , false ) ; mylog ( "SeqDNA::show_direct" , "D" ) ; } else { mylog ( "SeqDNA::show_direct" , "B2" ) ; if ( isPrimer ) dc.SetTextForeground ( *wxBLUE ) ; else dc.SetTextForeground ( *wxBLACK ) ; mylog ( "SeqDNA::show_direct" , "C2" ) ; t = alternateName ; mylog ( "SeqDNA::show_direct" , "D2" ) ; } dc.DrawText ( t , bo , py ) ; mylog ( "SeqDNA::show_direct" , "E" ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
void TimeRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); wxGridTableBase *table = grid.GetTable(); TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col); wxString tstr; if (te) { double value; table->GetValue(row, col).ToDouble(&value); NumericTextCtrl tt(NumericConverter::TIME, &grid, wxID_ANY, te->GetFormat(), value, te->GetRate(), wxPoint(10000, 10000), // create offscreen wxDefaultSize, true); tstr = tt.GetString(); te->DecRef(); } dc.SetBackgroundMode(wxTRANSPARENT); if (grid.IsEnabled()) { if (isSelected) { dc.SetTextBackground(grid.GetSelectionBackground()); dc.SetTextForeground(grid.GetSelectionForeground()); } else { dc.SetTextBackground(attr.GetBackgroundColour()); dc.SetTextForeground(attr.GetTextColour()); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont(attr.GetFont()); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign); }
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 ); sTmp = sFullString[(size_t)(nIndex + 1)]; rDC.GetTextExtent( sTmp ,(wxCoord *)&nCharWidth ,(wxCoord *)&nHeight ); sFullString.Replace(sTgt.c_str(), wxEmptyString, true); } // // Draw the main item text sans the accel text // POINTL vPntStart = {nX, rRect.y + 4}; ::GpiCharStringAt( impl->GetHPS() ,&vPntStart ,sFullString.length() ,sFullString.char_str() ); if (bFoundMnemonic) { // // Underline the mnemonic -- still won't work, but at least it "looks" right // wxPen vPen; POINTL vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide vPntStart.x = nX + nWidth - 1; vPntStart.y = rRect.y + 2; // Make it look pretty! vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black rDC.SetPen(vPen); ::GpiMove(hPS, &vPntStart); ::GpiLine(hPS, &vPntEnd); } // // Now draw the accel text // if (bFoundAccel) { size_t nWidth; size_t nHeight; rDC.GetTextExtent( sAccel ,(wxCoord *)&nWidth ,(wxCoord *)&nHeight ); // // Back off the starting position from the right edge // vPntStart.x = rRect.width - (nWidth + 7); vPntStart.y = rRect.y + 4; ::GpiCharStringAt( impl->GetHPS() ,&vPntStart ,sAccel.length() ,sAccel.char_str() ); } // // Draw the bitmap // --------------- // if (IsCheckable() && !m_bmpChecked.IsOk()) { if (eStatus & wxODChecked) { RECTL vRect; HBITMAP hBmpCheck = ::WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK); vRect.xLeft = rRect.x; vRect.xRight = rRect.x + GetMarginWidth(); vRect.yBottom = rRect.y; vRect.yTop = rRect.y + m_nHeight - 3; ::WinDrawBitmap( hPS // PS for this menuitem ,hBmpCheck // system checkmark ,NULL // draw the whole bitmap ,(PPOINTL)&vRect // destination -- bottom left corner of the menuitem area ,0L // ignored ,0L // draw a bitmap ,DBM_NORMAL // draw normal size ); } } else { // // For uncheckable item we use only the 'checked' bitmap // wxBitmap vBmp(GetBitmap(IsCheckable() ? ((eStatus & wxODChecked) != 0) : TRUE)); if (vBmp.IsOk()) { wxMemoryDC vDCMem(&rDC); wxMemoryDC* pOldDC = (wxMemoryDC*)vBmp.GetSelectedInto(); if(pOldDC != NULL) { vBmp.SetSelectedInto(NULL); } vDCMem.SelectObject(vBmp); // // Center bitmap // int nBmpWidth = vBmp.GetWidth(); int nBmpHeight = vBmp.GetHeight(); // // There should be enough space! // wxASSERT((nBmpWidth <= rRect.width) && (nBmpHeight <= rRect.height)); int nHeightDiff = m_nHeight - nBmpHeight; rDC.Blit( rRect.x + (GetMarginWidth() - nBmpWidth) / 2 ,rRect.y + nHeightDiff / 2 ,nBmpWidth ,nBmpHeight ,&vDCMem ,0 ,0 ,wxCOPY ,true ); if (eStatus & wxODSelected) { POINTL vPnt1 = {rRect.x + 1, rRect.y + 3}; // Leave a little background border POINTL vPnt2 = {rRect.x + GetMarginWidth(), rRect.y + m_nHeight - 3}; LINEBUNDLE vLine; vLine.lColor = vColBack.GetPixel(); ::GpiSetAttrs( hPS ,PRIM_LINE ,LBB_COLOR ,0 ,&vLine ); ::GpiMove(hPS, &vPnt1); ::GpiBox( hPS ,DRO_OUTLINE ,&vPnt2 ,0L ,0L ); } vBmp.SetSelectedInto(NULL); } } return true; } // end of wxOwnerDrawn::OnDrawItem
// draw the item bool wxOwnerDrawn::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 // wxString sFullString = GetItemLabel(); // need to save the original text int nIndex; size_t nWidth; size_t nCharWidth; size_t nHeight; bool bFoundMnemonic = false; // // Deal with the mnemonic character // nIndex = sFullString.Find(wxT("~")); if (nIndex != -1) { wxString sTmp = sFullString; bFoundMnemonic = true; sTmp.Remove(nIndex); rDC.GetTextExtent( sTmp ,(wxCoord *)&nWidth ,(wxCoord *)&nHeight ); sTmp = sFullString[(size_t)(nIndex + 1)]; rDC.GetTextExtent( sTmp ,(wxCoord *)&nCharWidth ,(wxCoord *)&nHeight ); sFullString.Replace(sTgt.c_str(), wxEmptyString, true); } // // Draw the main item text sans the accel text // POINTL vPntStart = {nX, rRect.y + 4}; ::GpiCharStringAt( impl->GetHPS() ,&vPntStart ,sFullString.length() ,sFullString.char_str() ); if (bFoundMnemonic) { // // Underline the mnemonic -- still won't work, but at least it "looks" right // wxPen vPen; POINTL vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide vPntStart.x = nX + nWidth - 1; vPntStart.y = rRect.y + 2; // Make it look pretty! vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black rDC.SetPen(vPen); ::GpiMove(hPS, &vPntStart); ::GpiLine(hPS, &vPntEnd); } return true; } // end of wxOwnerDrawn::OnDrawItem
void SeqAA::show ( wxDC& dc ) { if ( useDirectRoutines() ) { show_direct ( dc ) ; return ; } wxMessageBox ( _T("One has to wonder...2") ) ; int cw2 , ch2 ; dc.SetFont(*can->smallFont); dc.GetTextExtent ( _T("A") , &cw2 , &ch2 ) ; dc.SetFont(*can->font); wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; int a = 0 , b , cnt = offset+1 ; wxString t ; wxColour bbg ( 150 , 150 , 255 ) ; dc.SetTextBackground ( *wxWHITE ) ; if ( primaryMode ) dc.SetTextForeground ( getHighlightColor ( a , *wxBLACK ) ) ; else dc.SetTextForeground ( myapp()->frame->aa_color ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; int xa , ya , yb ; dc.GetDeviceOrigin ( &xa , &ya ) ; ya = -ya ; can->MyGetClientSize ( &xa , &yb ) ; yb += ya ; for ( a = 0 ; a < pos.p.GetCount() ; a++ ) { if ( can->hardstop > -1 && a > can->hardstop ) break ; b = pos.p[a] ; int ty = pos.r[a].y ; int tz = ty + can->charheight ; bool insight = true ; if ( tz < ya ) insight = false ; if ( ty > yb ) insight = false ; if ( can->getDrawAll() ) insight = true ; if ( !insight && ty > yb ) a = pos.p.GetCount() ; if ( b > 0 && !insight ) cnt++ ; if ( b > 0 && insight ) // Character { if ( getMark ( a ) == 1 ) { if ( primaryMode ) { dc.SetTextForeground ( *wxBLACK ) ; dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; } else { dc.SetTextForeground ( bbg ) ; dc.SetTextBackground ( *wxWHITE ) ; } } else if ( getMark ( a ) == 2 && can->doOverwrite() ) { dc.SetTextForeground ( *wxWHITE ) ; dc.SetTextBackground ( *wxBLACK ) ; dc.SetBackgroundMode ( wxSOLID ) ; } wxChar ch2 = s.GetChar(b-1) ; if ( ch2 == '|' ) ch2 = myapp()->frame->stopcodon ; t = ch2 ; if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetTextForeground ( *wxBLACK ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; } dc.DrawText ( t, pos.r[a].x, pos.r[a].y ) ; if ( getMark ( a ) == 2 && !can->doOverwrite() ) { int tx = pos.r[a].x , ty = pos.r[a].y ; int tz = ty + can->charheight ; dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( tx-1 , ty , tx-1 , tz ) ; dc.DrawLine ( tx-3 , ty , tx+2 , ty ) ; dc.DrawLine ( tx-3 , tz , tx+2 , tz ) ; } if ( getMark ( a ) > 0 ) { dc.SetTextBackground ( *wxWHITE ) ; if ( primaryMode ) dc.SetTextForeground ( getHighlightColor ( a , *wxBLACK ) ) ; else dc.SetTextForeground ( myapp()->frame->aa_color ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; } // Protease cuts for ( int q = 0 ; q < pc.GetCount() ; q++ ) { if ( b == pc[q]->cut ) { int qx = pos.r[a].x - 2 ; int qy = pos.r[a].y ; if ( !pc[q]->left ) qx += can->charwidth + 4 ; dc.SetTextForeground ( *wxBLACK ) ; dc.SetPen(*wxGREY_PEN); dc.DrawLine ( qx , qy + 1 , qx , qy + can->charheight - 2 ) ; dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( qx+1 , qy + 1 , qx+1 , qy + can->charheight - 2 ) ; wxString pn = pc[q]->protease->name ; for ( int w = 0 ; w+1 < pn.length() ; w++ ) if ( pn.GetChar(w) == ' ' && pn.GetChar(w+1) == '(' ) pn = pn.substr ( 0 , w ) ; dc.SetFont(*can->smallFont); int u1 , u2 ; dc.GetTextExtent ( pn , &u1 , &u2 ) ; dc.DrawText ( pn , qx - u1/2 , qy - u2/2 ) ; dc.SetFont(*can->font); if ( primaryMode ) dc.SetTextForeground ( getHighlightColor ( a , *wxBLACK ) ) ; else dc.SetTextForeground ( myapp()->frame->aa_color ) ; } } cnt++ ; } else if ( insight ) // Front number { // if ( primaryMode ) sprintf ( u , "%d" , cnt ) ; // else sprintf ( u , "%d" , cnt/3 ) ; // t = u ; if ( primaryMode ) t = wxString::Format ( _T("%d") , cnt ) ; else t = wxString::Format ( _T("%d") , cnt/3 ) ; while ( t.length() < endnumberlength ) t = _T("0") + t ; dc.DrawText ( t , pos.r[a].x, pos.r[a].y ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab) { if(tab.rect.height <= 1) return; dc.SetFont(m_tab_label_font); dc.SetPen(*wxTRANSPARENT_PEN); if(tab.active || tab.hovered || tab.highlight) { if(tab.active) { dc.SetFont(m_tab_active_label_font); dc.SetBrush(m_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1, tab.rect.width - 1, 1); } wxRect grad_rect(tab.rect); grad_rect.height -= 4; grad_rect.width -= 1; grad_rect.height /= 2; grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1; dc.SetBrush(m_tab_active_top_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1, grad_rect.y - tab.rect.y - 3); if(tab.highlight) { dc.GradientFillLinear(grad_rect, m_tab_highlight_top_colour, m_tab_highlight_top_gradient_colour, wxSOUTH); } else { dc.GradientFillLinear(grad_rect, m_tab_active_background_colour, m_tab_active_background_gradient_colour, wxSOUTH); } } else { wxRect btm_rect(tab.rect); btm_rect.height -= 4; btm_rect.width -= 1; btm_rect.height /= 2; btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1; dc.SetBrush(m_tab_hover_background_brush); dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width, btm_rect.height); wxRect grad_rect(tab.rect); grad_rect.width -= 1; grad_rect.y += 3; grad_rect.height = btm_rect.y - grad_rect.y; dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour, m_tab_hover_background_top_gradient_colour, wxSOUTH); } wxPoint border_points[5]; border_points[0] = wxPoint(0, 3); border_points[1] = wxPoint(1, 2); border_points[2] = wxPoint(tab.rect.width - 3, 2); border_points[3] = wxPoint(tab.rect.width - 1, 4); border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1); dc.SetPen(m_tab_border_pen); dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); wxRect old_clip; dc.GetClippingBox(old_clip); bool is_first_tab = false; wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar); if(bar && bar->GetPage(0) == tab.page) is_first_tab = true; wxBitmap icon; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { icon = tab.page->GetIcon(); if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) { if(icon.IsOk()) { int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); } } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) { wxString label = tab.page->GetLabel(); if(!label.IsEmpty()) { dc.SetTextForeground(m_tab_label_colour); dc.SetBackgroundMode(wxTRANSPARENT); int offset = 0; if(icon.IsOk()) offset += icon.GetWidth() + 2; int text_height; int text_width; dc.GetTextExtent(label, &text_width, &text_height); int x = (tab.rect.width - 2 - text_width - offset) / 2; if(x > 8) x = 8; else if(x < 1) x = 1; int width = tab.rect.width - x - 2; x += tab.rect.x + offset; int y = tab.rect.y + (tab.rect.height - text_height) / 2; if(icon.IsOk()) { dc.DrawBitmap(icon, x - offset, tab.rect.y + (tab.rect.height - icon.GetHeight()) / 2, true); } dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); dc.DrawText(label, x, y); } } // Draw the left hand edge of the tab only for the first tab (subsequent // tabs use the right edge of the prior tab as their left edge). As this is // outside the rectangle for the tab, only draw it if the leftmost part of // the tab is within the clip rectangle (the clip region has to be cleared // to draw outside the tab). if(is_first_tab && old_clip.x <= tab.rect.x && tab.rect.x < old_clip.x + old_clip.width) { dc.DestroyClippingRegion(); dc.DrawLine(tab.rect.x - 1, tab.rect.y + 4, tab.rect.x - 1, tab.rect.y + tab.rect.height - 1); } }
void wxSwitcherItems::PaintItems(wxDC& dc, wxWindow* win) { wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); wxColour standardTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxColour selectionOutlineColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); wxFont standardFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont groupFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); groupFont.SetWeight(wxFONTWEIGHT_BOLD); if (GetBackgroundColour().Ok()) backgroundColour = GetBackgroundColour(); if (GetTextColour().Ok()) standardTextColour = GetTextColour(); if (GetSelectionColour().Ok()) selectionColour = GetSelectionColour(); if (GetSelectionOutlineColour().Ok()) selectionOutlineColour = GetSelectionOutlineColour(); if (GetSelectionTextColour().Ok()) selectionTextColour = GetSelectionTextColour(); if (GetItemFont().Ok()) { standardFont = GetItemFont(); groupFont = wxFont(standardFont.GetPointSize(), standardFont.GetFamily(), standardFont.GetStyle(), wxFONTWEIGHT_BOLD, standardFont.GetUnderlined(), standardFont.GetFaceName()); } int textMarginX = wxSWITCHER_TEXT_MARGIN_X; dc.SetLogicalFunction(wxCOPY); dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(win->GetClientRect()); dc.SetBackgroundMode(wxTRANSPARENT); size_t i; for (i = 0; i < m_items.GetCount(); i++) { wxSwitcherItem& item = m_items[i]; bool selected = ((int) i == m_selection); if (selected) { dc.SetPen(wxPen(selectionOutlineColour)); dc.SetBrush(wxBrush(selectionColour)); dc.DrawRectangle(item.GetRect()); } wxRect clippingRect(item.GetRect()); clippingRect.Deflate(1, 1); dc.SetClippingRegion(clippingRect); if (selected) dc.SetTextForeground(selectionTextColour); else if (item.GetTextColour().Ok()) dc.SetTextForeground(item.GetTextColour()); else dc.SetTextForeground(standardTextColour); if (item.GetFont().Ok()) dc.SetFont(item.GetFont()); else { if (item.GetIsGroup()) dc.SetFont(groupFont); else dc.SetFont(standardFont); } int w, h; dc.GetTextExtent(item.GetTitle(), & w, & h); int x = item.GetRect().x; x += textMarginX; if (!item.GetIsGroup()) { if (item.GetBitmap().Ok() && item.GetBitmap().GetWidth() <= 16 && item.GetBitmap().GetHeight() <= 16) { dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + (item.GetRect().height - item.GetBitmap().GetHeight()) / 2, true); } x += 16; x += textMarginX; } int y = item.GetRect().y + (item.GetRect().height - h)/2; dc.DrawText(item.GetTitle(), x, y); dc.DestroyClippingRegion(); } }
void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) { // Old, but in some ways better (drawing opaque tabs) #ifndef wxUSE_NEW_METHOD if (!m_view) return; // Top-left of tab view area int viewX = m_view->GetViewRect().x; int viewY = m_view->GetViewRect().y; // Top-left of tab control int tabX = GetX() + viewX; int tabY = GetY() + viewY; int tabHeightInc = 0; if (m_isSelected) { tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); tabY -= tabHeightInc; } dc.SetPen(*wxTRANSPARENT_PEN); // Draw grey background if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { if(m_view->GetBackgroundBrush()) dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. #ifdef __WXMOTIF__ dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); #else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); #endif } // Draw highlight and shadow dc.SetPen(*m_view->GetHighlightPen()); // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition()); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); // Vertical highlight: if first tab, draw to bottom of view if (tabX == m_view->GetViewRect().x && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y + m_view->GetViewRect().height)); else if (tabX == m_view->GetViewRect().x) // Not box drawing, just to top of view. dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y)); else dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis)); dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY); dc.SetPen(*m_view->GetShadowPen()); // Test if we're outside the right-hand edge of the view area if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) { int bottomY = m_view->GetViewRect().y + m_view->GetViewRect().height + GetY() + m_view->GetTabHeight() + m_view->GetTopMargin(); // Add a tab height since we wish to draw to the bottom of the view. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), bottomY); // Calculate the far-right of the view, since we don't wish to // draw inside that int rightOfView = m_view->GetViewRect().x + m_view->GetViewRect().width + 1; // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY-1), (tabX + GetWidth()), (bottomY-1)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), bottomY); // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY), (tabX + GetWidth() + 1), (bottomY)); } else { if (lastInRow) { // 25/5/97 UNLESS it's less than the max number of positions in this row int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); int maxPositions = ((wxTabLayer *)m_view->GetLayers().Item(0)->GetData())->GetCount(); // Only down to the bottom of the tab, not to the top of the view if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; #ifdef __WXMOTIF__ topY -= 1; #endif // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), topY); } else { // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below (and next col along) happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition() + 1); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); #ifdef __WXMOTIF__ subtractThis += 1; #endif // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), (tabY + GetHeight() + tabHeightInc - subtractThis)); } } // Draw centered text int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) dc.SetFont(* m_view->GetSelectedTabFont()); else dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); wxCoord textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); int textX = (int)(tabX + (GetWidth() - textWidth)/2.0); if (textX < (tabX + 2)) textX = (tabX + 2); dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight()); dc.DrawText(GetLabel(), textX, textY); dc.DestroyClippingRegion(); if (m_isSelected) { dc.SetPen(*m_view->GetHighlightPen()); // Draw white highlight from the tab's left side to the left hand edge of the view dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc), tabX, (tabY + GetHeight() + tabHeightInc)); // Draw white highlight from the tab's right side to the right hand edge of the view dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc), m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc)); } #else // New HEL version with rounder tabs if (!m_view) return; int tabInc = 0; if (m_isSelected) { tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); } int tabLeft = GetX() + m_view->GetViewRect().x; int tabTop = GetY() + m_view->GetViewRect().y - tabInc; int tabRight = tabLeft + m_view->GetTabWidth(); int left = m_view->GetViewRect().x; int top = tabTop + m_view->GetTabHeight() + tabInc; int right = left + m_view->GetViewRect().width; int bottom = top + m_view->GetViewRect().height; if (m_isSelected) { // TAB is selected - draw TAB and the View's full outline dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = left; pnts[n++].y = bottom; pnts[n].x = left; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); if (!lastInRow) { dc.DrawLine( (tabRight + 2), top, right, top ); } dc.SetPen(*(m_view->GetShadowPen())); dc.DrawLine( tabRight, tabTop + 2, tabRight, top ); dc.DrawLine( right, top, right, bottom ); dc.DrawLine( right, bottom, left, bottom ); dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (lastInRow) { dc.DrawLine( tabRight + 1, bottom, tabRight + 1, tabTop + 1 ); } else { dc.DrawLine( tabRight + 1, tabTop + 2, tabRight + 1, top ); dc.DrawLine( right + 1, top, right + 1, bottom + 1 ); } dc.DrawLine( right + 1, bottom + 1, left + 1, bottom + 1 ); } else { // TAB is not selected - just draw TAB outline and RH edge // if the TAB is the last in the row int maxPositions = ((wxTabLayer*)m_view->GetLayers().Item(0)->GetData())->GetCount(); wxTabControl* tabBelow = 0; wxTabControl* tabBelowRight = 0; if (GetColPosition() > 0) { tabBelow = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() ); } if (!lastInRow && GetColPosition() > 0) { tabBelowRight = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() + 1 ); } float raisedTop = top - m_view->GetTabSelectionHeight() + m_view->GetTabHeight(); dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = tabLeft; if (tabBelow && tabBelow->IsSelected()) { pnts[n++].y = (long)raisedTop; } else { pnts[n++].y = top; } pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); dc.SetPen(*(m_view->GetShadowPen())); if (GetRowPosition() >= maxPositions - 1) { dc.DrawLine( tabRight, (tabTop + 2), tabRight, bottom ); dc.DrawLine( tabRight, bottom, (tabRight - m_view->GetHorizontalTabOffset()), bottom ); } else { if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight, (long)raisedTop, tabRight, tabTop + 1 ); } else { dc.DrawLine( tabRight, top - 1, tabRight, tabTop + 1 ); } } dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (GetRowPosition() >= maxPositions - 1) { // draw right hand edge to bottom of view dc.DrawLine( tabRight + 1, bottom + 1, tabRight + 1, tabTop + 2 ); dc.DrawLine( tabRight + 1, bottom + 1, (tabRight - m_view->GetHorizontalTabOffset()), bottom + 1 ); } else { // draw right hand edge of TAB if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight + 1, (long)(raisedTop - 1), tabRight + 1, tabTop + 2 ); } else { dc.DrawLine( tabRight + 1, top - 1, tabRight + 1, tabTop + 2 ); } } } // Draw centered text dc.SetPen(*wxBLACK_PEN); if (m_isSelected) { dc.SetFont(*(m_view->GetSelectedTabFont())); } else { dc.SetFont(*(GetFont())); } wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); float textX = (tabLeft + tabRight - textWidth) / 2; float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); dc.DrawText(GetLabel(), (long)textX, (long)textY); #endif }
void wxSpeedButton::Paint( wxDC &dc ) { int n; int w,h; wxColour cf; // foreground color wxColour cb; // background color wxColour cg; // gray text wxColour cy; // yellow wxBrush bb; // background brush wxPen pp; // line-drawing pen wxBitmap bmp; wxString s; wxRect rr; // get size and layout if (! mCalcBusy) CalcLayout(false); w = mCurrentSize.GetWidth(); h = mCurrentSize.GetHeight(); // get colors cf = GetForegroundColour(); cb = GetBackgroundColour(); cg = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT ); cy = wxTheColourDatabase->Find(_("YELLOW")); // use wxWidgets to draw the basic button rr.SetX(0); rr.SetY(0); rr.SetWidth(w); rr.SetHeight(h); n = 0; if (mMouseDown || mButtonDown) n = n | wxCONTROL_PRESSED; if (mButtonFocused) n = n | wxCONTROL_ISDEFAULT; wxRendererNative::Get().DrawPushButton(this, dc, rr, n); // track mouse movements with mMouseOver using a dotted yellow line pp = *wxBLACK_PEN; pp.SetColour(cy); // pp.SetStyle(wxDOT); dc.SetPen(pp); if (mMouseOver) { n = 2; dc.DrawLine( n, n, w-n, n); dc.DrawLine(w-n, n, w-n, h-n); dc.DrawLine(w-n, h-n, n, h-n); dc.DrawLine( n, h-n, n, n); }; // select the bitmap to draw if (! IsEnabled()) bmp = mGlyphDisabled; else if (mMouseDown || mButtonDown) bmp = mGlyphDown; else bmp = mGlyphUp; if (bmp.IsOk()) dc.DrawBitmap(bmp, mGlyphPos.x, mGlyphPos.y, true ); // the text label s = GetLabelText(); if (! s.IsEmpty()) { dc.SetFont(GetFont()); dc.SetBackgroundMode(wxTRANSPARENT); if (! IsEnabled()) dc.SetTextForeground(cg); else dc.SetTextForeground(cf); dc.DrawText(s, mLabelPos.x, mLabelPos.y); }; }
//+-------------------------------------------------------------+ //| 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, valueheight, &memoryDC, valuewidth * (m_pipValue - 1), valuepos+valueheight, wxCOPY); // Draw the pips dc.Blit((wxCoord)(x + m_scale*3 + valuewidth+2), (wxCoord)(y + m_scale*3), pipsize, pipsize, &memoryDC, pipsize * m_suit, pippos, wxCOPY); dc.Blit((wxCoord)(x + m_width - m_scale*3-valuewidth-pipsize-2), (wxCoord)(y + m_height - pipsize - m_scale*3), pipsize, pipsize, &memoryDC, pipsize * m_suit, pipsize+pippos, wxCOPY); switch (m_pipValue) { case 1: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - m_scale*5 + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); break; case 3: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 2: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 5: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 4: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 8: dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10), (wxCoord)(y - symdist + 5 * m_height / 8), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); case 7: dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10), (wxCoord)(y - symdist + 3 * m_height / 8), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); case 6: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + m_height / 2), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; case 10: dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + 2 * m_height / 3), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); case 9: dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist2 + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist2 + 5 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 7 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist2 + m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist2 + 5 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 7 * m_height / 12), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4), (wxCoord)(y - symdist + 3 * m_height / 4), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); dc.Blit((wxCoord)(x - symdist + m_width / 2), (wxCoord)(y - symdist + m_height / 3), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); break; case 11: case 12: case 13: memoryDC.SelectObject(*m_pictureBmap); int picwidth = 40,picheight = 45; dc.Blit((wxCoord)(x + (m_width-picwidth)/2), (wxCoord)(y - picheight/2 + m_height/2), picwidth, picheight, &memoryDC, picwidth * (m_pipValue - 11), 0, wxCOPY); memoryDC.SelectObject(*m_symbolBmap); dc.Blit((wxCoord)(x + m_width-(m_width-picwidth)/2-symsize-3), (wxCoord)(y - picheight/2+m_height/2+1), symsize, symsize, &memoryDC, symsize * m_suit, sympos, wxCOPY); dc.Blit((wxCoord)(x + (m_width-picwidth)/2+2), (wxCoord)(y + picheight/2 + m_height/2-symsize), symsize, symsize, &memoryDC, symsize * m_suit, sympos2, wxCOPY); break; } } dc.SetBackground( backgroundBrush ); } // Card:Draw()
void SeqDNA::show ( wxDC& dc ) { if ( useDirectRoutines() ) { show_direct ( dc ) ; return ; } dc.SetFont(*can->font); wxColour tbg = dc.GetTextBackground () ; wxColour tfg = dc.GetTextForeground () ; int bm = dc.GetBackgroundMode () ; int a , b , cnt = offset+1 ; wxString t ; char u[100] , valid[256] ; for ( a = 0 ; a < 256 ; a++ ) valid[a] = 0 ; valid['A'] = valid['C'] = valid['T'] = valid['G'] = valid[' '] = 1 ; // dc.SetTextBackground ( *wxWHITE ) ; dc.SetTextForeground ( fontColor ) ; // dc.SetBackgroundMode ( wxSOLID ) ; dc.SetBackgroundMode ( wxTRANSPARENT ) ; int xa , ya , yb ; dc.GetDeviceOrigin ( &xa , &ya ) ; ya = -ya ; can->MyGetClientSize ( &xa , &yb ) ; yb += ya ; for ( a = 0 ; a < pos.p.GetCount() ; a++ ) { if ( can->hardstop > -1 && a > can->hardstop ) break ; b = pos.p[a] ; int tx = pos.r[a].x , ty = pos.r[a].y ; int tz = ty + can->charheight ; bool insight = true ; // Meaning "is this part visible" if ( tz < ya ) insight = false ; if ( ty > yb ) insight = false ; if ( can->getDrawAll() ) insight = true ; if ( !insight && ty > yb ) a = pos.p.GetCount() ; if ( b > 0 && !insight ) cnt++ ; if ( b > 0 && insight ) // Character { t = s.GetChar(b-1) ; int pm = getMark ( a ) ; if ( pm == 1 ) // Marked (light gray background) { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxLIGHT_GREY ) ; dc.SetTextForeground ( *wxBLACK ) ; } else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor { dc.SetBackgroundMode ( wxSOLID ) ; dc.SetTextBackground ( *wxBLACK ) ; } if ( pm == 2 && can->doOverwrite() ) dc.SetTextForeground ( *wxWHITE ) ; else dc.SetTextForeground ( getBaseColor ( t.GetChar(0) ) ) ; if ( can->isPrinting() && pm == 1 ) { dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ; dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle ( tx , ty , can->charwidth , can->charheight ) ; } if ( can->isPrinting() && !can->getPrintToColor() ) { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( *wxBLACK ) ; } dc.DrawText ( t , tx , ty ) ; if ( pm == 2 && !can->doOverwrite() ) // Insert cursor { dc.SetPen(*wxBLACK_PEN); dc.DrawLine ( tx-1 , ty , tx-1 , tz ) ; dc.DrawLine ( tx-3 , ty , tx+2 , ty ) ; dc.DrawLine ( tx-3 , tz , tx+2 , tz ) ; } if ( pm > 0 ) // Reverting cursor settings { dc.SetBackgroundMode ( wxTRANSPARENT ) ; dc.SetTextForeground ( fontColor ) ; } cnt++ ; } else if ( insight ) // Front number { if ( showNumbers ) { //sprintf ( u , "%d" , cnt ) ; //t = u ; t = wxString::Format ( _T("%d") , cnt ) ; while ( t.length() < endnumberlength ) t = _T("0") + t ; } else t = alternateName ; dc.SetTextForeground ( *wxBLACK ) ; dc.DrawText ( t , pos.r[a].x, pos.r[a].y ) ; } } dc.SetBackgroundMode ( bm ) ; dc.SetTextBackground ( tbg ) ; dc.SetTextForeground ( tfg ) ; }
void wxRibbonMetroArtProvider::DrawTab( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab) { if(tab.rect.height <= 2) return; if(tab.active || tab.hovered) { if(tab.active) { wxRect background(tab.rect); background.x += 2; background.y += 1; background.width -= 3; background.height -= 1; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_tab_active_background_colour); dc.DrawRectangle(background); // TODO: active and hovered } else if(tab.hovered) { wxRect background(tab.rect); background.x += 2; background.y += 1; background.width -= 3; background.height -= 2; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_tab_hover_background_colour); dc.DrawRectangle(background); } wxPoint border_points[4]; border_points[0] = wxPoint(1, tab.rect.height - 2); border_points[1] = wxPoint(1, 0); border_points[2] = wxPoint(tab.rect.width - 1, 0); border_points[3] = wxPoint(tab.rect.width - 1, tab.rect.height - 1); if (tab.active) dc.SetPen(m_tab_border_pen); else dc.SetPen(m_tab_border_pen); // TODO: introduce hover border pen colour dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { wxBitmap icon = tab.page->GetIcon(); if(icon.IsOk()) { int x = tab.rect.x + 4; if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) { wxString label = tab.page->GetLabel(); if(!label.IsEmpty()) { dc.SetFont(m_tab_label_font); dc.SetTextForeground(m_tab_label_colour); dc.SetBackgroundMode(wxTRANSPARENT); int text_height; int text_width; dc.GetTextExtent(label, &text_width, &text_height); int width = tab.rect.width - 5; int x = tab.rect.x + 3; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { x += 3 + tab.page->GetIcon().GetWidth(); width -= 3 + tab.page->GetIcon().GetWidth(); } int y = tab.rect.y + (tab.rect.height - text_height) / 2; if(width <= text_width) { dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); dc.DrawText(label, x, y); } else { dc.DrawText(label, x + (width - text_width) / 2 + 1, y); } } } }