本文整理汇总了C++中wxDC::GetDeviceOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetDeviceOrigin方法的具体用法?C++ wxDC::GetDeviceOrigin怎么用?C++ wxDC::GetDeviceOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetDeviceOrigin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void GlyphCellRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected)
{
wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, false);
wxString value = grid.GetTable()->GetValue(row, col);
wxString label;
auto it = glyphs.find(value);
if (it == glyphs.end()) return;
const SvgGlyph &glyph = it->second;
if (!glyph.IsOk())
return;
if (showGlyphNames) label = glyph.glyphName;
else label.Printf("%04x", glyph.unicode[0]);
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(static_cast<wxPaintDC&>(dc)));
wxRect newRect = rect;
// replace with gc->GetRenderer()->GetName() == L"cairo" after wx 3.1
bool isCairo = false;
#if wxUSE_CAIRO
isCairo = true;
#endif
// Oh, crap
if (isCairo)
{
newRect.x += dc.GetDeviceOrigin().x;
newRect.y += dc.GetDeviceOrigin().y;
}
std::map<wxString, wxBitmap>::iterator findIt = glyphCache.find(glyph.unicode);
if (findIt == glyphCache.end())
{
bool result;
std::tie(findIt, result) = glyphCache.emplace(glyph.unicode, GetBitmapForGlyph(glyph, fontSize, glyphColor, attr.GetBackgroundColour(), false));
if (!result) return;
}
if (hlCellCoords.GetCol() == col && hlCellCoords.GetRow() == row)
{
gc->SetPen(wxPen(hlColor, 1));
gc->DrawRoundedRectangle(newRect.x + 1, newRect.y + 1, newRect.width - 2, newRect.height - 2, 5);
}
newRect.height -= labelFont.GetPixelSize().GetHeight() + 2 * padding;
const wxBitmap &glyphBitmap = findIt->second;
if (glyphBitmap.IsOk())
{
gc->DrawBitmap(glyphBitmap,
newRect.x + (newRect.width - glyphBitmap.GetWidth()) / 2,
newRect.y + (newRect.height - glyphBitmap.GetHeight()) / 2,
glyphBitmap.GetWidth(), glyphBitmap.GetHeight());
}
double maxTextWidth = std::max(0, newRect.width - 2);
double width, height, descent, externalLeading;
gc->SetFont(labelFont, labelColor);
gc->GetTextExtent(label, &width, &height, &descent, &externalLeading);
wxString origLabel = label;
size_t cutCntr = 1;
while (width > maxTextWidth && !label.IsEmpty())
{
label = origLabel.Left(origLabel.Length() - cutCntr++) + L"\u2026";
gc->GetTextExtent(label, &width, &height, &descent, &externalLeading);
}
gc->DrawText(label, newRect.x + (newRect.width - width) / 2, newRect.y + newRect.height + padding);
}
示例2: Render
void clRowEntry::Render(wxWindow* win, wxDC& dc, const clColours& c, int row_index, clSearchText* searcher)
{
wxUnusedVar(searcher);
wxRect rowRect = GetItemRect();
bool zebraColouring = (m_tree->HasStyle(wxTR_ROW_LINES) || m_tree->HasStyle(wxDV_ROW_LINES));
bool even_row = ((row_index % 2) == 0);
// Define the clipping region
bool hasHeader = (m_tree->GetHeader() && !m_tree->GetHeader()->empty());
// Not cell related
clColours colours = c;
if(zebraColouring) {
// Set Zebra colouring, only if no user colour was provided for the given line
colours.SetItemBgColour(even_row ? c.GetAlternateColour() : c.GetBgColour());
}
// Override default item bg colour with the user's one
if(GetBgColour().IsOk()) { colours.SetItemBgColour(GetBgColour()); }
wxRect selectionRect = rowRect;
wxPoint deviceOrigin = dc.GetDeviceOrigin();
selectionRect.SetX(-deviceOrigin.x);
if(IsSelected()) {
DrawSimpleSelection(win, dc, selectionRect, colours);
} else if(IsHovered()) {
dc.SetPen(colours.GetHoverBgColour());
dc.SetBrush(colours.GetHoverBgColour());
dc.DrawRectangle(selectionRect);
} else if(colours.GetItemBgColour().IsOk()) {
dc.SetBrush(colours.GetItemBgColour());
dc.SetPen(colours.GetItemBgColour());
dc.DrawRectangle(selectionRect);
}
// Per cell drawings
for(size_t i = 0; i < m_cells.size(); ++i) {
bool last_cell = (i == (m_cells.size() - 1));
colours = c; // reset the colours
wxFont f = clScrolledPanel::GetDefaultFont();
clCellValue& cell = GetColumn(i);
if(cell.GetFont().IsOk()) { f = cell.GetFont(); }
if(cell.GetTextColour().IsOk()) { colours.SetItemTextColour(cell.GetTextColour()); }
if(cell.GetBgColour().IsOk()) { colours.SetItemBgColour(cell.GetBgColour()); }
dc.SetFont(f);
wxColour buttonColour = IsSelected() ? colours.GetSelbuttonColour() : colours.GetButtonColour();
wxRect cellRect = GetCellRect(i);
// We use a helper class to clip the drawings this ensures that if we exit the scope
// the clipping region is restored properly
clClipperHelper clipper(dc);
if(hasHeader) { clipper.Clip(cellRect); }
int textXOffset = cellRect.GetX();
if((i == 0) && !IsListItem()) {
// The expand button is only make sense for the first cell
if(HasChildren()) {
wxRect buttonRect = GetButtonRect();
buttonRect.Deflate(1);
textXOffset += buttonRect.GetWidth();
if(m_tree->IsNativeTheme() && !IS_OSX) {
int flags = wxCONTROL_CURRENT;
if(IsExpanded()) { flags |= wxCONTROL_EXPANDED; }
int button_width = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
wxRect modButtonRect = buttonRect;
modButtonRect.SetWidth(button_width);
modButtonRect.SetHeight(button_width);
modButtonRect = modButtonRect.CenterIn(buttonRect);
wxRendererNative::Get().DrawTreeItemButton(win, dc, modButtonRect, flags);
} else {
wxRect buttonRect = GetButtonRect();
if(textXOffset >= cellRect.GetWidth()) {
// if we cant draw the button (off screen etc)
SetRects(GetItemRect(), wxRect());
continue;
}
buttonRect.Deflate((buttonRect.GetWidth() / 3), (buttonRect.GetHeight() / 3));
wxRect tribtn = buttonRect;
dc.SetPen(wxPen(buttonColour, 2));
if(IsExpanded()) {
tribtn.SetHeight(tribtn.GetHeight() - tribtn.GetHeight() / 2);
tribtn = tribtn.CenterIn(buttonRect);
wxPoint middleLeft = wxPoint((tribtn.GetLeft() + tribtn.GetWidth() / 2), tribtn.GetBottom());
dc.DrawLine(tribtn.GetTopLeft(), middleLeft);
dc.DrawLine(tribtn.GetTopRight(), middleLeft);
} else {
tribtn.SetWidth(tribtn.GetWidth() - tribtn.GetWidth() / 2);
tribtn = tribtn.CenterIn(buttonRect);
wxPoint middleLeft = wxPoint(tribtn.GetRight(), (tribtn.GetY() + (tribtn.GetHeight() / 2)));
wxPoint p1 = tribtn.GetTopLeft();
wxPoint p2 = tribtn.GetBottomLeft();
dc.DrawLine(p1, middleLeft);
dc.DrawLine(middleLeft, p2);
}
}
} else {
wxRect buttonRect(rowRect);
buttonRect.SetWidth(rowRect.GetHeight());
buttonRect.Deflate(1);
//.........这里部分代码省略.........
示例3: show
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 ) ;
}
示例4: show_direct
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 ) ;
//.........这里部分代码省略.........
示例5: show
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 ) ;
//.........这里部分代码省略.........
示例6: show_direct
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);
//.........这里部分代码省略.........
示例7: show
void SeqPlot::show ( wxDC& dc )
{
if ( s.IsEmpty() ) return ;
mylog ( "SeqPlot::show" , "1" ) ;
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 , xb , ya , yb ;
dc.GetDeviceOrigin ( &xa , &ya ) ;
ya = -ya ;
xa = -xa ;
can->MyGetClientSize ( &xb , &yb ) ;
yb += ya ;
xb += xa ;
int lx = 0 ;
startOfLine = true ;
mylog ( "SeqPlot::show" , "2" ) ;
for ( a = 0 ; a < pos.p.GetCount() ; a++ )
{
mylog ( "SeqPlot::show" , "2a" ) ;
if ( can->hardstop > -1 && a > can->hardstop ) break ;
mylog ( "SeqPlot::show" , "2b" ) ;
b = pos.p[a] ;
int tx = pos.r[a].x , ty = pos.r[a].y ;
int tz = ty + can->charheight * lines ;
bool insight = true ; // Meaning "is this part visible"
if ( tz < ya ) insight = false ;
if ( ty > yb ) insight = false ;
if ( tx + can->charwidth < xa ) insight = false ;
if ( tx > xb ) insight = false ;
if ( can->getDrawAll() ) insight = true ;
if ( !insight && ty > yb ) a = pos.p.GetCount() ;
if ( b > 0 && !insight ) cnt++ ;
mylog ( "SeqPlot::show" , "2c" ) ;
if ( b > 0 && insight ) // Character
{
if ( lx == 0 ) lx = tx ;
t = s.GetChar(b-1) ;
if ( can->isPrinting() )
{
if (getMark ( a ) == 1 )
{
dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle ( tx , ty , can->charwidth , can->charheight ) ;
}
mylog ( "SeqPlot::show" , "2c1" ) ;
if ( !can->getPrintToColor() )
{
dc.SetBackgroundMode ( wxTRANSPARENT ) ;
dc.SetTextForeground ( *wxBLACK ) ;
}
}
mylog ( "SeqPlot::show" , wxString::Format ( _T("2c2 (type %d)") , type ) ) ;
switch ( type )
{
case CHOU_FASMAN : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
case COILED_COIL : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
case M_W : showMW ( dc , b-1 , tx , ty , lx ) ; break ;
case P_I : showPI ( dc , b-1 , tx , ty , lx ) ; break ;
case H_P : showHP ( dc , b-1 , tx , ty , lx ) ; break ;
}
lx = tx + can->charwidth ;
cnt++ ;
startOfLine = false ;
mylog ( "SeqPlot::show" , "2c3" ) ;
}
else if ( insight ) // Front
{
mylog ( "SeqPlot::show" , "2d1" ) ;
lx = 0 ;
startOfLine = true ;
if ( !can->isMiniDisplay() ) continue ;
mylog ( "SeqPlot::show" , "2d2" ) ;
dc.SetFont(*can->smallFont);
if ( type == CHOU_FASMAN ) t = _T("Chou-Fasman") ;
if ( type == COILED_COIL ) t = _T("Coiled-coil") ;
else if ( type == M_W ) t = _T("MW") ;
else if ( type == P_I ) t = _T("pI") ;
else if ( type == H_P )
{
t = _T("t_method_") ;
t += hp_method ;
t = txt(t) ;
t += wxString::Format( _T(" [%d]") , hp_window ) ;
}
mylog ( "SeqPlot::show" , "2d3" ) ;
dc.SetTextForeground ( *wxBLACK ) ;
int tw , th ;
//.........这里部分代码省略.........
示例8: VdkDcDeviceOriginAdder
void VdkDcDeviceOriginAdder(wxDC &dc, int dX, int dY) {
int x, y;
dc.GetDeviceOrigin(&x, &y);
dc.SetDeviceOrigin(x + dX, y + dY);
}
示例9: OnDraw
void MorphanView::OnDraw(wxDC& dc)
{
wxGraphicsContext* gc = wxGraphicsContext::Create(panel);
if (!gc) return;
wxGCDC gcdc(gc);
wxPoint origin = dc.GetDeviceOrigin();
gcdc.SetUserScale(zoom, zoom);
gcdc.SetDeviceOrigin(origin.x, origin.y);
if (show_grid)
DrawGrid(gcdc);
Morphan* morphan = GetDocument();
if (!morphan) return;
const MorphanKeyFrame& keyFrame = morphan->Get(current_frame);
wxPen cpbox(*wxBLACK, 2);
wxBrush cpfill(*wxWHITE);
MorphanDrawContext context(gcdc, keyFrame.GetOpacity());
for (const Primitive* p : keyFrame.GetPrimitives())
{
p->Draw(context);
if (show_points)
{
gcdc.SetPen(cpbox);
gcdc.SetBrush(cpfill);
const std::vector<wxRealPoint> points = p->GetControlPoints();
for (const auto& point : points)
gcdc.DrawRectangle(point.x - 3, point.y - 3, 6, 6);
}
}
if (in_window && (tool && tool->CanPreview()))
{
gcdc.SetPen(wxPen(wxColour(255, 0, 0, 255), outlineWidth));
gcdc.SetBrush(*wxTRANSPARENT_BRUSH);
tool->Preview(gcdc, mouse, wxGetKeyState(WXK_SHIFT));
}
if (in_window && (modifyTool && modifyTool->HasSelection()))
{
std::set<PrimitiveSelection> selection = modifyTool->PreviewModify(mouse);
cpbox.SetColour(*wxRED);
MorphanDrawContext context(gcdc, 1.0f);
for (PrimitiveSelection ps : selection)
{
ps.primitive->SetOutline(*wxRED);
ps.primitive->Draw(context);
if (show_points)
{
gcdc.SetPen(cpbox);
gcdc.SetBrush(cpfill);
const std::vector<wxRealPoint> points = ps.primitive->GetControlPoints();
for (const auto& point : points)
gcdc.DrawRectangle(point.x - 3, point.y - 3, 6, 6);
}
delete ps.primitive;
}
}
}