Example #1
0
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 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 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 ) ;
    }
Example #4
0
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 ) ;
    }
Example #5
0
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 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 ;
           dc.GetTextExtent ( t , &tw , &th ) ;
           int ty = pos.r[a].y ;
           ty += lines * can->charheight ;
			mylog ( "SeqPlot::show" , "2d4" ) ;
#ifdef __WXGTK__
	   ty += th / 2 ;
	   dc.DrawText ( t , pos.r[a].x , ty ) ;
#else
           ty -= ( lines * can->charheight - tw ) / 2 ;
           dc.DrawRotatedText ( t , pos.r[a].x, ty , 90 ) ;
#endif
           dc.SetFont(*can->font);
           }
			mylog ( "SeqPlot::show" , "2e" ) ;
        }
    mylog ( "SeqPlot::show" , "3" ) ;
    dc.SetBackgroundMode ( bm ) ;
    dc.SetTextBackground ( tbg ) ;
    dc.SetTextForeground ( tfg ) ;
    }
Example #7
0
void wxHtmlWordCell::Draw(wxDC& dc, int x, int y,
                          int WXUNUSED(view_y1), int WXUNUSED(view_y2),
                          wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxBLACK_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width /* VZ: +1? */ ,m_Height);
#endif

    bool drawSelectionAfterCell = false;

    if ( info.GetState().GetSelectionState() == wxHTML_SEL_CHANGING )
    {
        // Selection changing, we must draw the word piecewise:
        wxHtmlSelection *s = info.GetSelection();
        wxString txt;
        int w, h;
        int ofs = 0;

        wxPoint priv = (this == s->GetFromCell()) ?
                       s->GetFromPrivPos() : s->GetToPrivPos();

        // NB: this is quite a hack: in order to compute selection boundaries
        //     (in word's characters) we must know current font, which is only
        //     possible inside rendering code. Therefore we update the
        //     information here and store it in wxHtmlSelection so that
        //     ConvertToText can use it later:
        if ( priv == wxDefaultPosition )
        {
            SetSelectionPrivPos(dc, s);
            priv = (this == s->GetFromCell()) ?
                   s->GetFromPrivPos() : s->GetToPrivPos();
        }

        int part1 = priv.x;
        int part2 = priv.y;

        if ( part1 > 0 )
        {
            txt = m_Word.Mid(0, part1);
            dc.DrawText(txt, x + m_PosX, y + m_PosY);
            dc.GetTextExtent(txt, &w, &h);
            ofs += w;
        }

        SwitchSelState(dc, info, true);

        txt = m_Word.Mid(part1, part2-part1);
        dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);

        if ( (size_t)part2 < m_Word.length() )
        {
            dc.GetTextExtent(txt, &w, &h);
            ofs += w;
            SwitchSelState(dc, info, false);
            txt = m_Word.Mid(part2);
            dc.DrawText(txt, ofs + x + m_PosX, y + m_PosY);
        }
        else
            drawSelectionAfterCell = true;
    }
    else
    {
        wxHtmlSelectionState selstate = info.GetState().GetSelectionState();
        // Not changing selection state, draw the word in single mode:
        if ( selstate != wxHTML_SEL_OUT &&
                dc.GetBackgroundMode() != wxSOLID )
        {
            SwitchSelState(dc, info, true);
        }
        else if ( selstate == wxHTML_SEL_OUT &&
                  dc.GetBackgroundMode() == wxSOLID )
        {
            SwitchSelState(dc, info, false);
        }
        dc.DrawText(m_Word, x + m_PosX, y + m_PosY);
        drawSelectionAfterCell = (selstate != wxHTML_SEL_OUT);
    }

    // NB: If the text is justified then there is usually some free space
    //     between adjacent cells and drawing the selection only onto cells
    //     would result in ugly unselected spaces. The code below detects
    //     this special case and renders the selection *outside* the sell,
    //     too.
    if ( m_Parent->GetAlignHor() == wxHTML_ALIGN_JUSTIFY &&
            drawSelectionAfterCell )
    {
        wxHtmlCell *nextCell = m_Next;
        while ( nextCell && nextCell->IsFormattingCell() )
            nextCell = nextCell->GetNext();
        if ( nextCell )
        {
            int nextX = nextCell->GetPosX();
            if ( m_PosX + m_Width < nextX )
            {
                dc.SetBrush(dc.GetBackground());
                dc.SetPen(*wxTRANSPARENT_PEN);
                dc.DrawRectangle(x + m_PosX + m_Width, y + m_PosY,
                                 nextX - m_PosX - m_Width, m_Height);
            }
        }
    }
}