void UIElementVectorial::DrawStaticBox(wxDC& dc,const wxString& label, const wxPoint& pos, const wxSize& size)
{
	wxColour c_pen = dc.GetPen().GetColour();
	dc.SetPen(wxPen(dc.GetTextForeground()));
	dc.DrawRoundedRectangle(pos.x, pos.y, size.x, size.y,3.1f);
	dc.SetPen(wxPen(c_pen));
	dc.DrawRotatedText(label,pos.x+10,pos.y,0);
}
void PenStyleComboBox::OnDrawItem( wxDC& dc,
                                    const wxRect& rect,
                                    int item,
                                    int flags ) const
{
    if ( item == wxNOT_FOUND )
        return;

    wxRect r(rect);
    r.Deflate(3);
    r.height -= 2;

    int penStyle = wxSOLID;
//    if ( item == 1 )
//        penStyle = wxTRANSPARENT;
//    else if ( item == 2 )
//        penStyle = wxDOT;
//    else if ( item == 3 )
//        penStyle = wxLONG_DASH;
//    else if ( item == 4 )
//        penStyle = wxSHORT_DASH;
    if ( item == 0 )
        penStyle = wxDOT_DASH;
    else if ( item == 1 )
        penStyle = wxBDIAGONAL_HATCH;
    else if ( item == 2 )
        penStyle = wxCROSSDIAG_HATCH;
//    else if ( item == 8 )
//        penStyle = wxFDIAGONAL_HATCH;
//    else if ( item == 9 )
//        penStyle = wxCROSS_HATCH;
//    else if ( item == 10 )
//        penStyle = wxHORIZONTAL_HATCH;
//    else if ( item == 11 )
//        penStyle = wxVERTICAL_HATCH;

    wxPen pen( dc.GetTextForeground(), 3, penStyle );

    // Get text colour as pen colour
    dc.SetPen( pen );

    if ( !(flags & wxODCB_PAINTING_CONTROL) )
    {
        dc.DrawText(GetString( item ),
                    r.x + 3,
                    (r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
                   );

        dc.DrawLine( r.x+5, r.y+((r.height/4)*3), r.x+r.width - 5, r.y+((r.height/4)*3) );
    }
    else
    {
        dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 );
    }
}
Example #3
0
    virtual void OnDrawItem( wxDC& dc,
                             const wxRect& rect,
                             int item,
                             int flags ) const
    {
        if ( item == wxNOT_FOUND )
            return;

        wxRect r(rect);
        r.Deflate(3);
        r.height -= 2;

        wxPenStyle penStyle = wxPENSTYLE_SOLID;
        if ( item == 1 )
            penStyle = wxPENSTYLE_TRANSPARENT;
        else if ( item == 2 )
            penStyle = wxPENSTYLE_DOT;
        else if ( item == 3 )
            penStyle = wxPENSTYLE_LONG_DASH;
        else if ( item == 4 )
            penStyle = wxPENSTYLE_SHORT_DASH;
        else if ( item == 5 )
            penStyle = wxPENSTYLE_DOT_DASH;
        else if ( item == 6 )
            penStyle = wxPENSTYLE_BDIAGONAL_HATCH;
        else if ( item == 7 )
            penStyle = wxPENSTYLE_CROSSDIAG_HATCH;
        else if ( item == 8 )
            penStyle = wxPENSTYLE_FDIAGONAL_HATCH;
        else if ( item == 9 )
            penStyle = wxPENSTYLE_CROSS_HATCH;
        else if ( item == 10 )
            penStyle = wxPENSTYLE_HORIZONTAL_HATCH;
        else if ( item == 11 )
            penStyle = wxPENSTYLE_VERTICAL_HATCH;

        wxPen pen( dc.GetTextForeground(), 3, penStyle );

        // Get text colour as pen colour
        dc.SetPen( pen );

        if ( !(flags & wxODCB_PAINTING_CONTROL) )
        {
            dc.DrawText(GetString( item ),
                        r.x + 3,
                        (r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
                       );

            dc.DrawLine( r.x+5, r.y+((r.height/4)*3), r.x+r.width - 5, r.y+((r.height/4)*3) );
        }
        else
        {
            dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 );
        }
    }
Example #4
0
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);
        }
    }
}
// draws a line of symbols
void wxSymbolListCtrl::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
    wxColour oldTextColour = dc.GetTextForeground();
    int startSymbol = n*m_symbolsPerLine;

    int i;
    for (i = 0; i < m_symbolsPerLine; i++)
    {
        bool resetColour = false;
        int symbol = startSymbol+i;
        if (symbol == m_current)
        {
            dc.SetBrush(wxBrush(m_colBgSel));

            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
            resetColour = true;

            wxPen oldPen = dc.GetPen();
            dc.SetPen(*wxTRANSPARENT_PEN);

            dc.DrawRectangle(rect.x + i*m_cellSize.x, rect.y, m_cellSize.x, rect.y+rect.height);
            dc.SetPen(oldPen);
        }

        // Don't draw first line
        if (i != 0)
            dc.DrawLine(rect.x + i*m_cellSize.x, rect.y, i*m_cellSize.x, rect.y+rect.height);

        if (symbol >= m_minSymbolValue && symbol <= m_maxSymbolValue)
        {
            wxString text;
            text << (wxChar) symbol;

            wxCoord w, h;
            dc.GetTextExtent(text, & w, & h);

            int x = rect.x + i*m_cellSize.x + (m_cellSize.x - w)/2;
            int y = rect.y + (m_cellSize.y - h)/2;
            dc.DrawText(text, x, y);
        }

        if (resetColour)
            dc.SetTextForeground(oldTextColour);
    }

    // Draw horizontal separator line
    dc.DrawLine(rect.x, rect.y+rect.height-1, rect.x+rect.width, rect.y+rect.height-1);
}
Example #6
0
void MyDrawText(wxDC &dc, const wxString &s, wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
    #ifdef __WXMSW__   // this special purpose implementation is because the MSW implementation calls TextExtent, which costs 25% of all cpu time
        //wxMSWDCImpl *impl = (wxMSWDCImpl *)dc.GetImpl();
        //impl->DrawAnyText(s, x, y);   // protected, sigh
        dc.CalcBoundingBox(x, y);
        dc.CalcBoundingBox(x + w, y + h);

        HDC hdc = (HDC)dc.GetHDC();
        ::SetTextColor(hdc, dc.GetTextForeground().GetPixel());
        ::SetBkColor(hdc, dc.GetTextBackground().GetPixel());
        ::ExtTextOut(hdc, x, y, 0, NULL, s.c_str(), s.length(), NULL);
    #else
        dc.DrawText(s, x, y);
    #endif
}
Example #7
0
void FindCmdDlg::ActionList::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const {
	const bool isCurrent = IsCurrent(n);
	dc.SetTextForeground(isCurrent ? m_hlTextColor : m_textColor);

	const unsigned int ypos = rect.y + m_topMargen;
	unsigned int rightBorder = rect.GetRight();

	const tmAction& action = *m_items[n].action;
	const vector<unsigned int>& hl = m_items[n].hlChars;

	wxString name = action.name;
	if (action.bundle) {
		name += wxT(" - ");
		name += action.bundle->name;
	}

	if ( !action.trigger.empty() )
	{
		const wxString trig =  action.trigger + wxT("\x21E5");

		dc.SetFont(m_unifont);
		int trig_width, trig_height;
		dc.GetTextExtent(trig, &trig_width, &trig_height);

		// Draw a grey rounded rect as background for trigger
		const unsigned int bg_height = trig_height + 1;
		const unsigned int bg_width = trig_width + 10;
		const unsigned int bg_xpos = rect.GetWidth()-2-bg_width;
		const unsigned int bg_ypos = rect.y+ (int)((rect.GetHeight()-bg_height)/2.0);
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		dc.DrawRoundedRectangle(bg_xpos, bg_ypos, bg_width, bg_height, 2);

		// Draw the trigger text
		const wxColour prevColour = dc.GetTextForeground();
		dc.SetTextForeground(*wxBLACK);
		dc.DrawText(trig, bg_xpos + 5, bg_ypos);
		dc.SetTextForeground(prevColour);

		rightBorder = bg_xpos;
	}
	else if (!action.key.shortcut.empty()) {
		const wxString& shortcut = action.key.shortcut;

		dc.SetFont(m_font);
		int accel_width, accel_height;
        dc.GetTextExtent(shortcut, &accel_width, &accel_height);

		const unsigned int xpos = rect.GetWidth()-2-accel_width;
		dc.DrawText(shortcut, xpos, ypos);

		rightBorder = xpos;
	}

	// Calc extension width
	static const wxString ext = wxT("..  ");
	dc.SetFont(m_font);
	int w, h;
	dc.GetTextExtent(ext, &w, &h);
	const unsigned int extwidth = w;

	// See if we have to resize the action name to fit
	// note that this is not 100% correct as bold chars take up a bit more space.
	unsigned int len = name.length();
	dc.GetTextExtent(name, &w, &h);
	if (w > (int)rightBorder) {
		do {
			name.resize(--len);
			dc.GetTextExtent(name, &w, &h);
		} while (len > 0 && w + extwidth > rightBorder);
		name += ext;
	}

	// Draw action name
	DrawItemText(dc, rect, name, hl, isCurrent);
}
Example #8
0
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
    // vars to use ...
#if wxUSE_STATUSBAR
    wxString s;
#endif // wxUSE_STATUSBAR
    wxPen wP;
    wxBrush wB;
    wxPoint points[6];
    wxColour wC;
    wxFont wF;

    dc.SetFont(*wxSWISS_FONT);
    dc.SetPen(*wxGREEN_PEN);

    switch (m_index)
    {
        default:
        case 0:
            // draw lines to make a cross
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            // draw point colored line and spline
            wP = *wxCYAN_PEN;
            wP.SetWidth(3);
            dc.SetPen(wP);

            dc.DrawPoint (25,15);
            dc.DrawLine(50, 30, 200, 30);
            dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
            s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
            break;

        case 1:
            // draw standard shapes
            dc.SetBrush(*wxCYAN_BRUSH);
            dc.SetPen(*wxRED_PEN);
            dc.DrawRectangle(10, 10, 100, 70);
            wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
            dc.SetBrush (wB);
            dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
            dc.SetBrush (wxBrush(wxT("GOLDENROD")) );
            dc.DrawEllipse(100, 100, 100, 50);

            points[0].x = 100; points[0].y = 200;
            points[1].x = 70; points[1].y = 260;
            points[2].x = 160; points[2].y = 230;
            points[3].x = 40; points[3].y = 230;
            points[4].x = 130; points[4].y = 260;
            points[5].x = 100; points[5].y = 200;

            dc.DrawPolygon(5, points);
            dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
            s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
            break;

        case 2:
            // draw text in Arial or similar font
            dc.DrawLine(50,25,50,35);
            dc.DrawLine(45,30,55,30);
            dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
            wC = dc.GetTextForeground();
            dc.SetTextForeground (wxT("FIREBRICK"));

            // no effect in msw ??
            dc.SetTextBackground (wxT("WHEAT"));
            dc.DrawText(wxT("This is a Red string"), 50, 200);
            dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
            dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.SetTextForeground (wC);
            dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
            break;

        case 3 :
            // four arcs start and end points, center
            dc.SetBrush(*wxGREEN_BRUSH);
            dc.DrawArc ( 200,300, 370,230, 300,300 );
            dc.SetBrush(*wxBLUE_BRUSH);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(-10,-10);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(0,0);

            wP.SetColour (wxT("CADET BLUE"));
            dc.SetPen(wP);
            dc.DrawArc ( 75,125, 110, 40, 75, 75 );

            wP.SetColour (wxT("SALMON"));
            dc.SetPen(wP);
            dc.SetBrush(*wxRED_BRUSH);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0);

            wP = *wxCYAN_PEN;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (wxT("SALMON")));
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0);
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0);
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0);

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC); //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break;

        case 6:
            dc.DrawIcon( wxICON(sample), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break;

        case 7:
            dc.SetTextForeground(wxT("RED"));
            dc.DrawText(wxT("Red = Clipping Off"), 30, 5);
            dc.SetTextForeground(wxT("GREEN"));
            dc.DrawText(wxT("Green = Clipping On"), 30, 25);

            dc.SetTextForeground(wxT("BLACK"));

            dc.SetPen(*wxRED_PEN);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);

            dc.SetPen(*wxGREEN_PEN);

            // Clipped checkmarks
            dc.DrawRectangle(180,50,75,75);
            dc.SetClippingRegion(180,50,75,75);                   // x,y,width,height version
            dc.DrawCheckMark ( 180,50,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(80,150,75,75));
            dc.SetClippingRegion(wxPoint(80,150),wxSize(75,75));  // pt,size version
            dc.DrawCheckMark ( 80,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(180,150,75,75));
            dc.SetClippingRegion(wxRect(180,150,75,75));          // rect version
            dc.DrawCheckMark ( 180,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect( 80,250,50,65));
            dc.DrawRectangle(wxRect(105,260,50,65));
            dc.SetClippingRegion(wxRect( 80,250,50,65));  // second call to SetClippingRegion
            dc.SetClippingRegion(wxRect(105,260,50,65));  // forms intersection with previous
            dc.DrawCheckMark(80,250,75,75);
            dc.DestroyClippingRegion();                   // only one call to destroy (there's no stack)

            /*
            ** Clipping by wxRegion not implemented for SVG.   Should be
            ** possible, but need to access points that define the wxRegion
            ** from inside DoSetDeviceClippingRegion() and wxRegion does not
            ** implement anything like getPoints().
            points[0].x = 180; points[0].y = 250;
            points[1].x = 255; points[1].y = 250;
            points[2].x = 180; points[2].y = 325;
            points[3].x = 255; points[3].y = 325;
            points[4].x = 180; points[4].y = 250;

            dc.DrawLines (5, points);
            wxRegion reg = wxRegion(5,points);

            dc.SetClippingRegion(reg);
            dc.DrawCheckMark ( 180,250,75,75);
            dc.DestroyClippingRegion();
            */

#if wxUSE_STATUSBAR
            s = wxT("Clipping region");
#endif // wxUSE_STATUSBAR
            break;

        case 8:
            wxString txtStr;
            wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL;
            wxCoord txtPad = 0;

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
            //dc.SetTextBackground(*wxBLUE);

            // Horizontal text
            txtStr = wxT("Horizontal string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 300;
            dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad);
            dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad);

            // Vertical text
            txtStr = wxT("Vertical string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 250;
            dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad);
            dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90);

            // 45 degree text
            txtStr = wxT("45 deg string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0);
            double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0);
            double padding = (double)txtPad / sqrt(2.0);
            txtX = 150;
            txtY = 200;
            dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top
            dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW));
            dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
            dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
            dc.DrawRotatedText(txtStr, txtX, txtY, 45);
#if wxUSE_STATUSBAR
            s = wxT("Text position test page");
#endif // wxUSE_STATUSBAR
            break;
    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}
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 ) ;
    }    
Example #10
0
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 #11
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 #12
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 #14
0
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
    // vars to use ...
#if wxUSE_STATUSBAR
    wxString s ;
#endif // wxUSE_STATUSBAR
    wxPen wP ;
    wxBrush wB ;
    wxPoint points[6];
    wxColour wC;
    wxFont wF ;

    dc.SetFont(*wxSWISS_FONT);
    dc.SetPen(*wxGREEN_PEN);


    switch (m_index)
    {
        default:
        case 0:
            // draw lines to make a cross
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            // draw point colored line and spline
            wP = *wxCYAN_PEN ;
            wP.SetWidth(3);
            dc.SetPen(wP);

            dc.DrawPoint (25,15) ;
            dc.DrawLine(50, 30, 200, 30);
            dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
            s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
            break ;

        case 1:
            // draw standard shapes
            dc.SetBrush(*wxCYAN_BRUSH);
            dc.SetPen(*wxRED_PEN);
            dc.DrawRectangle(10, 10, 100, 70);
            wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT);
            dc.SetBrush (wB);
            dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
            dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) );
            dc.DrawEllipse(100, 100, 100, 50);

            points[0].x = 100; points[0].y = 200;
            points[1].x = 70; points[1].y = 260;
            points[2].x = 160; points[2].y = 230;
            points[3].x = 40; points[3].y = 230;
            points[4].x = 130; points[4].y = 260;
            points[5].x = 100; points[5].y = 200;

            dc.DrawPolygon(5, points);
            dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
            s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
            break ;

        case 2:
            // draw text in Arial or similar font
            dc.DrawLine(50,25,50,35);
            dc.DrawLine(45,30,55,30);
            dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
            wC = dc.GetTextForeground() ;
            dc.SetTextForeground (_T("FIREBRICK"));

            // no effect in msw ??
            dc.SetTextBackground (_T("WHEAT"));
            dc.DrawText(wxT("This is a Red string"), 50, 200);
            dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
            dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.SetTextForeground (wC) ;
            dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
            break ;

        case 3 :
            // four arcs start and end points, center
            dc.SetBrush(*wxGREEN_BRUSH);
            dc.DrawArc ( 200,300, 370,230, 300,300 );
            dc.SetBrush(*wxBLUE_BRUSH);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(-10,-10);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(0,0);

            wP.SetColour (_T("CADET BLUE"));
            dc.SetPen(wP);
            dc.DrawArc ( 75,125, 110, 40, 75, 75 );

            wP.SetColour (_T("SALMON"));
            dc.SetPen(wP);
            dc.SetBrush(*wxRED_BRUSH);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0) ;

            wP = *wxCYAN_PEN ;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (_T("SALMON"),wxSOLID)) ;
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0) ;
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0) ;
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0) ;

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (_T("SALMON"),wxTRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break ;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC) ; //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 6:
            dc.DrawIcon( wxIcon(mondrian_xpm), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break ;

    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}