コード例 #1
0
ファイル: htmlcell.cpp プロジェクト: gitrider/wxsj2
void wxHtmlColourCell::DrawInvisible(wxDC& dc,
                                     int WXUNUSED(x), int WXUNUSED(y),
                                     wxHtmlRenderingInfo& info)
{
    wxHtmlRenderingState& state = info.GetState();
    if (m_Flags & wxHTML_CLR_FOREGROUND)
    {
        state.SetFgColour(m_Colour);
        if (state.GetSelectionState() != wxHTML_SEL_IN)
            dc.SetTextForeground(m_Colour);
        else
            dc.SetTextForeground(
                info.GetStyle().GetSelectedTextColour(m_Colour));
    }
    if (m_Flags & wxHTML_CLR_BACKGROUND)
    {
        state.SetBgColour(m_Colour);
        if (state.GetSelectionState() != wxHTML_SEL_IN)
        {
            dc.SetTextBackground(m_Colour);
            dc.SetBackground(wxBrush(m_Colour, wxSOLID));
        }
        else
        {
            wxColour c = info.GetStyle().GetSelectedTextBgColour(m_Colour);
            dc.SetTextBackground(c);
            dc.SetBackground(wxBrush(c, wxSOLID));
        }
    }
}
コード例 #2
0
void wxSheetCellStringRendererRefData::SetTextColoursAndFont(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc,
        bool isSelected)
{
    dc.SetBackgroundMode( wxTRANSPARENT );

    // TODO some special colours for attr.IsReadOnly() case?

    // different coloured text when the sheet is disabled
    if ( sheet.IsEnabled() )
    {
        if ( isSelected )
        {
            dc.SetTextBackground( sheet.GetSelectionBackground() );
            dc.SetTextForeground( sheet.GetSelectionForeground() );
        }
        else
        {
            dc.SetTextBackground( attr.GetBackgroundColour() );
            dc.SetTextForeground( attr.GetForegroundColour() );
        }
    }
    else
    {
        dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    }

    dc.SetFont( attr.GetFont() );
}
コード例 #3
0
ファイル: stdrend.cpp プロジェクト: czxxjtu/wxPython-1
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);
        }
    }
}
コード例 #4
0
void HexEditLineBuffer::Draw( wxDC& dc, int x, int y, int fontX, int fontY, wxColour* foregrounds, wxColour* backgrounds )
{
    for ( char* ptr = m_Buffer; ptr < m_End; )
    {
        // Searching for continous block with same style
        wxString str;

        do
        {
            str += wxChar( ptr[ 0 ] );
            ptr += 2;
        }
        while ( ( ptr < m_End ) && ( ptr[1] == ptr[-1] ) );

        char style = ptr[-1];

        dc.SetBrush( backgrounds[ (int)style ] );
        dc.SetPen( backgrounds[ (int)style ] );

        dc.DrawRectangle( x, y, fontX * str.length(), fontY );

        dc.SetPen( foregrounds[ (int)style ] );
        dc.SetTextForeground( foregrounds[ (int)style ] );
        dc.SetTextBackground( backgrounds[ (int)style ] );

        dc.DrawText( str, x, y );
        x += fontX * str.length();
    }
}
コード例 #5
0
ファイル: LinkEvent.cpp プロジェクト: trinajstica/GD
/**
 * Render the event in the bitmap
 */
void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
    gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();

    dc.SetBrush( wxBrush( wxColour( 255, 255, 255 ) ) );
    dc.SetPen( wxPen( wxColour( 0, 0, 0 ), 1) );
    wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
    dc.DrawRectangle(rect);

    dc.DrawBitmap( gd::SkinHelper::GetIcon("events", 24), x+4, y + 1, true);

    dc.SetTextBackground( wxColour( 255, 255, 255 ) );
    if ( !IsDisabled() )
        dc.SetTextForeground( wxColour( 0, 0, 0 ) );
    else
        dc.SetTextForeground( wxColour( 160, 160, 160 ) );

    dc.SetFont(renderingHelper->GetNiceFont());
    dc.DrawText( _("Link to ")+GetTarget(), x+32, y + 3 );

    if ( GetIncludeConfig() == INCLUDE_BY_INDEX )
    {
        wxRect textRect = dc.GetTextExtent(_("Link to ")+GetTarget());
        dc.DrawText( _("Include only events ")+gd::String::From(GetIncludeStart()+1)+_(" to ")+gd::String::From(GetIncludeEnd()+1), x+textRect.GetWidth()+32+10, y + 5 );
    }
    else if ( GetIncludeConfig() == INCLUDE_EVENTS_GROUP )
    {
        wxRect textRect = dc.GetTextExtent(_("Link to ")+GetTarget());
        dc.DrawText( _("Include only the events group named \"")+gd::String::From(GetEventsGroupName())+_("\""), x+textRect.GetWidth()+32+10, y + 5 );
    }
#endif
}
コード例 #6
0
ファイル: LinkEvent.cpp プロジェクト: kumarjith/GD
/**
 * Render the event in the bitmap
 */
void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
    dc.SetBrush( wxBrush( wxColour( 255, 255, 255 ) ) );
    dc.SetPen( wxPen( wxColour( 0, 0, 0 ), 1) );
    wxRect rect(x+1, y, width, GetRenderedHeight(width, platform)-2);
    dc.DrawRectangle(rect);

    dc.DrawBitmap( gd::SkinHelper::GetIcon("events", 24), x+4, y + 1, true);

    dc.SetTextBackground( wxColour( 255, 255, 255 ) );
    if ( !IsDisabled() )
        dc.SetTextForeground( wxColour( 0, 0, 0 ) );
    else
        dc.SetTextForeground( wxColour( 160, 160, 160 ) );
    dc.SetFont( wxFont( 12, wxDEFAULT, wxNORMAL, wxNORMAL ) );
    dc.DrawText( _("Link to ")+GetTarget(), x+32, y + 3 );
    wxRect lien = dc.GetTextExtent(_("Link to ")+GetTarget());

    dc.SetFont( wxFont( 10, wxDEFAULT, wxNORMAL, wxNORMAL ) );
    if ( IncludeAllEvents() )
        dc.DrawText( _("Include all events"), x+lien.GetWidth()+32+10, y + 5 );
    else
        dc.DrawText( _("Include events ")+ToString(GetIncludeStart()+1)+_(" to ")+ToString(GetIncludeEnd()+1), x+lien.GetWidth()+32+10, y + 5 );
#endif
}
コード例 #7
0
ファイル: TestScrollWinView.cpp プロジェクト: LreeLenn/geoda
void TestScrollWinCanvas::PaintShapes(wxDC& dc)
{
	TemplateCanvas::PaintShapes(dc);
	dc.SetPen(*wxBLACK_PEN);
	dc.SetBrush(*wxRED_BRUSH);
	dc.SetTextForeground(*wxBLACK);
	dc.SetTextBackground(wxTransparentColor); // new const in wxWidgets 2.9.1
	dc.SetFont(*wxSMALL_FONT);
	int y=10;
	int dy=20;
	int i=0;
	dc.DrawLine(30,30, 250,15);
	dc.DrawText("*wxSMALL_FONT", 10, y+(dy*i++));
	dc.SetFont(*wxNORMAL_FONT);
	dc.DrawText("*wxNORMAL_FONT", 10, y+(dy*i++));
	dc.SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT));
	dc.DrawText("GetFont(wxSYS_ANSI_VAR_FONT)", 10, y+(dy*i++));
	dc.SetFont(wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT));
	dc.DrawText("GetFont(wxSYS_SYSTEM_FONT)", 10, y+(dy*i++));
	wxFont f1(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f1);
	dc.DrawText("8, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	wxFont f1_1(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f1_1);
	dc.DrawText("9, wxFONTFAMILY_SWISS", 10, y+(dy*i++));	
	wxFont f2(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f2);
	dc.DrawText("10, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	wxFont f3(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f3);
	dc.DrawText("11, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	wxFont f4(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f4);
	dc.DrawText("12, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	wxFont f5(14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	dc.SetFont(f5);
	dc.DrawText("14, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	f5.SetPointSize(16);
	dc.SetFont(f5);
	dc.DrawText("16, wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	f5.SetPixelSize(wxSize(0,15));
	dc.SetFont(f5);
	dc.DrawText("SetPixelSize(0,15), wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	f5.SetPixelSize(wxSize(0,10));
	dc.SetFont(f5);
	dc.DrawText("SetPixelSize(0,10), wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	f5.SetPixelSize(wxSize(0,20));
	dc.SetFont(f5);
	dc.DrawText("SetPixelSize(0,20), wxFONTFAMILY_SWISS", 10, y+(dy*i++));
	dc.SetFont(*GdaConst::small_font);
	dc.DrawText("*GdaConst::small_font", 10, y+(dy*i++));
	dc.SetFont(*GdaConst::medium_font);
	dc.DrawText("*GdaConst::medium_font", 10, y+(dy*i++));
	dc.SetTextForeground(GdaConst::selectable_fill_color);
	dc.SetFont(*GdaConst::large_font);
	dc.DrawText("*GdaConst::large_font", 10, y+(dy*i++));
}
コード例 #8
0
//---------------------------------------------------------------------------
void wxPagedWindow::DrawPaperBar( twTabInfo& tab, int x, int y,
                                  wxBrush& brush, wxPen& pen, wxDC& dc )
{
    wxPoint poly[4];

    // draw organizer-style paper outlet

    poly[0].x = x - mTabTrianGap;
    poly[0].y = y;

    poly[1].x = x + mTabTrianGap;
    poly[1].y = y + tab.mDims.y-1;

    poly[2].x = x + tab.mDims.x - mTabTrianGap;
    poly[2].y = y + tab.mDims.y-1;

    poly[3].x = x + tab.mDims.x + mTabTrianGap;
    poly[3].y = y;

    dc.SetPen( pen );
    dc.SetBrush( brush );

    dc.DrawPolygon( 4, poly );

    long w,h;

    // set select default font of the window into it's device context
    //dc.SetFont( GetLabelingFont() );

    dc.SetTextBackground( brush.GetColour() );

    dc.GetTextExtent(tab.mText, &w, &h );

    if ( tab.HasImg() )
    {
        wxMemoryDC tmpDc;
        tmpDc.SelectObject( tab.GetImg() );

        dc.Blit( x + mTitleHorizGap,
            y + ( tab.mDims.y - tab.ImgHeight() ) / 2,
            tab.ImgWidth(),
            tab.ImgHeight(),
            &tmpDc, 0, 0, wxCOPY
            );
    }

    if ( tab.HasText() )
    {
        int tx = x + mTitleHorizGap +
            tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);

        dc.DrawText( tab.GetText(), tx, y + ( tab.mDims.y - h ) / 2 );
    }
}  // wxPagedWindow::DrawPaperBar()
コード例 #9
0
ファイル: game.cpp プロジェクト: crankycoder/wxPython-2.9.2.4
void Game::DisplayScore(wxDC& dc)
{
    wxColour bgColour = FortyApp::BackgroundColour();
    wxPen* pen = wxThePenList->FindOrCreatePen(bgColour, 1, wxSOLID);
    dc.SetTextBackground(bgColour);
    dc.SetTextForeground(FortyApp::TextColour());
    dc.SetBrush(FortyApp::BackgroundBrush());
    dc.SetPen(* pen);

    // count the number of cards in foundations
    m_currentScore = 0;
    for (int i = 0; i < 8; i++)
    {
        m_currentScore += m_foundations[i]->GetNumCards();
    }

    int x, y;
    m_pack->GetTopCardPos(x, y);
    x += 12 * CardWidth - 105;

    wxCoord w, h;
    {
        wxCoord width, height;
        dc.GetTextExtent(wxT("Average score:m_x"), &width, &height);
        w = width;
        h = height;
    }
    dc.DrawRectangle(x + w, y, 20, 4 * h);

    wxString str;
    str.Printf(wxT("%d"), m_currentScore);
    dc.DrawText(wxT("Score:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(wxT("%d"), m_numGames);
    dc.DrawText(wxT("Games played:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(wxT("%d"), m_numWins);
    dc.DrawText(wxT("Games won:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    int average = 0;
    if (m_numGames > 0)
    {
        average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
    }
    str.Printf(wxT("%d"), average);
    dc.DrawText(wxT("Average score:"), x, y);
    dc.DrawText(str, x + w, y);
}
コード例 #10
0
void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
                                 const char *s, int len,
                                 ColourAllocated fore, ColourAllocated back) {
    SetFont(font);
    hdc->SetTextForeground(wxColourFromCA(fore));
    hdc->SetTextBackground(wxColourFromCA(back));
    FillRectangle(rc, back);

    // ybase is where the baseline should be, but wxWin uses the upper left
    // corner, so I need to calculate the real position for the text...
    hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
}
コード例 #11
0
ファイル: IsoLine.cpp プロジェクト: fzschornack/OpenCPN
void IsoLine::drawIsoLineLabels(GRIBOverlayFactory *pof, wxDC &dc, wxColour text_color, wxColour back_color,
                                PlugIn_ViewPort *vp, int density, int first, double coef)
{
///
//#if 0
    std::list<Segment *>::iterator it;
    int nb = first;
    wxString label;

    label.Printf(_T("%d"), (int)(value*coef+0.5));

    wxPen penText(text_color);

    int w, h;
    dc.GetTextExtent(label, &w, &h);

    dc.SetPen(penText);
    dc.SetBrush(wxBrush(back_color));
    dc.SetTextForeground(text_color);
    dc.SetTextBackground(back_color);

    //---------------------------------------------------------
    // Ecrit les labels
    //---------------------------------------------------------
    for (it=trace.begin(); it!=trace.end(); it++,nb++)
    {
        if (nb % density == 0)
		{
            Segment *seg = *it;

//            if(vp->vpBBox.PointInBox((seg->px1 + seg->px2)/2., (seg->py1 + seg->py2)/2., 0.))
            {
 //                 wxPoint ab = vp->GetMercatorPixFromLL(seg->py1, seg->px1);
 //                 wxPoint cd = vp->GetMercatorPixFromLL(seg->py2, seg->px2);
			wxPoint ab;
			GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
			wxPoint cd;
			GetCanvasPixLL(vp, &cd, seg->py1, seg->px1);
                  
			int label_offset = 6;
                  int xd = (ab.x + cd.x-(w+label_offset * 2))/2;
                  int yd = (ab.y + cd.y - h)/2;

                 
                  dc.DrawRoundedRectangle(xd, yd, w+(label_offset * 2), h, -.25);
                  dc.DrawText(label, label_offset/2 + xd, yd-1);
            }

        }
    }
//#endif
///
}
コード例 #12
0
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
                                  const char *s, int len,
                                  ColourAllocated fore, ColourAllocated back) {
    SetFont(font);
    hdc->SetTextForeground(wxColourFromCA(fore));
    hdc->SetTextBackground(wxColourFromCA(back));
    FillRectangle(rc, back);
    hdc->SetClippingRegion(wxRectFromPRectangle(rc));

    // see comments above
    hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
    hdc->DestroyClippingRegion();
}
コード例 #13
0
ファイル: game.cpp プロジェクト: crankycoder/wxPython-2.9.2.4
void Pack::Redraw(wxDC& dc)
{
    Pile::Redraw(dc);

    wxString str;
    str.Printf(wxT("%d  "), m_topCard + 1);

    dc.SetBackgroundMode( wxSOLID );
    dc.SetTextBackground(FortyApp::BackgroundColour());
    dc.SetTextForeground(FortyApp::TextColour());
    dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2);

}
コード例 #14
0
ファイル: htmlcell.cpp プロジェクト: gitrider/wxsj2
static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info,
                           bool toSelection)
{
    wxColour fg = info.GetState().GetFgColour();
    wxColour bg = info.GetState().GetBgColour();

    if ( toSelection )
    {
        dc.SetBackgroundMode(wxSOLID);
        dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg));
        dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg));
        dc.SetBackground(wxBrush(info.GetStyle().GetSelectedTextBgColour(bg),
                                 wxSOLID));
    }
    else
    {
        dc.SetBackgroundMode(wxTRANSPARENT);
        dc.SetTextForeground(fg);
        dc.SetTextBackground(bg);
        dc.SetBackground(wxBrush(bg, wxSOLID));
    }
}
コード例 #15
0
ファイル: gridctrl.cpp プロジェクト: 3v1n0/wxWidgets
void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid,
                                                     const wxGridCellAttr& attr,
                                                     wxDC& dc,
                                                     bool isSelected)
{
    dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );

    // TODO some special colours for attr.IsReadOnly() case?

    // different coloured text when the grid is disabled
    if ( grid.IsThisEnabled() )
    {
        if ( isSelected )
        {
            wxColour clr;
            if ( grid.HasFocus() )
                clr = grid.GetSelectionBackground();
            else
                clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
            dc.SetTextBackground( clr );
            dc.SetTextForeground( grid.GetSelectionForeground() );
        }
        else
        {
            dc.SetTextBackground( attr.GetBackgroundColour() );
            dc.SetTextForeground( attr.GetTextColour() );
        }
    }
    else
    {
        dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    }

    dc.SetFont( attr.GetFont() );
}
コード例 #16
0
ファイル: GroupEvent.cpp プロジェクト: alcemirfernandes/GD
/**
 * Render the event in the bitmap
 */
void GroupEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
    wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name);
    wxColour backgroundColor = wxColour(colorR, colorG, colorB);
    wxColour textColor = colorR + colorG + colorB > 200*3 ? *wxBLACK : *wxWHITE;
    if (IsDisabled())
    {
        backgroundColor.MakeDisabled();
        textColor = wxColour(160, 160, 160);
    }

    dc.SetBrush(wxBrush(backgroundColor));
    dc.SetPen(wxPen(backgroundColor.ChangeLightness(70)));
    wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
    dc.DrawRectangle(rect);

    dc.SetTextBackground(backgroundColor);
    dc.SetTextForeground(textColor);
    dc.SetFont( wxFont( 12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ) );
    dc.DrawText( groupTitle, x+5, y + 5 );
#endif
}
コード例 #17
0
bool wxMenuItem::OnDrawItem( wxDC& rDC,
                               const wxRect& rRect,
                               wxODAction eAction,
                               wxODStatus eStatus )
{

    //
    // Select the font and draw the text
    // ---------------------------------
    //

    CHARBUNDLE                      vCbnd;
    wxPMDCImpl                      *impl = (wxPMDCImpl*) rDC.GetImpl();
    HPS                             hPS= impl->GetHPS();
    wxFont                          vFont;
    wxColour                        vColBack;
    wxColour                        vColText;
    COLORREF                        vRef;
    RECTL                           vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};

    memset(&vCbnd, 0, sizeof(CHARBUNDLE));

    GetFontToUse(vFont);
    GetColourToUse(eStatus, vColText, vColBack);

    rDC.SetFont(vFont);
    rDC.SetTextBackground(vColBack);
    rDC.SetTextForeground(vColText);
    rDC.SetBackgroundMode(wxTRANSPARENT);

    vCbnd.lColor     = vColText.GetPixel();
    vCbnd.lBackColor = vColBack.GetPixel();
    ::GpiSetAttrs( hPS
                  ,PRIM_CHAR
                  ,CBB_BACK_COLOR | CBB_COLOR
                  ,0
                  ,&vCbnd
                 );
    ::GpiSetBackMix( hPS
                    ,BM_LEAVEALONE
                   );

    //
    // Paint the background
    //
    ::WinFillRect(hPS, &vRect, vColBack.GetPixel());

    //
    // Determine where to draw and leave space for a check-mark.
    //
    int nX = rRect.x + GetMarginWidth();

    //
    // Unfortunately, unlike Win32, PM has no owner drawn specific text
    // drawing methods like ::DrawState that can cleanly handle accel
    // mnemonics and deal, automatically, with various states, so we have
    // to handle them ourselves. Notice Win32 can't handle \t in ownerdrawn
    // strings either.  We cannot handle mnemonics either.  We display
    // them, though, in the hope we can figure them out some day.
    //

    //
    // Display main text and accel text separately to align better
    //
    wxString sTgt = wxT("\t");
    wxString sFullString = GetItemLabel(); // need to save the original text
    wxString sAccel;
    int      nIndex;
    size_t   nWidth;
    size_t   nCharWidth;
    size_t   nHeight;
    bool     bFoundMnemonic = false;
    bool     bFoundAccel = false;

    //
    // Deal with the tab, extracting the Accel text
    //
    nIndex = sFullString.Find(sTgt);
    if (nIndex != -1)
    {
        bFoundAccel = true;
        sAccel = sFullString.Mid(nIndex + 1);
        sFullString.Remove(nIndex);
    }

    //
    // Deal with the mnemonic character
    //
    sTgt = wxT("~");
    nIndex = sFullString.Find(sTgt);
    if (nIndex != -1)
    {
        wxString sTmp = sFullString;

        bFoundMnemonic = true;
        sTmp.Remove(nIndex);
        rDC.GetTextExtent( sTmp
                          ,(wxCoord *)&nWidth
                          ,(wxCoord *)&nHeight
                         );
        sTmp = sFullString[(size_t)(nIndex + 1)];
        rDC.GetTextExtent( sTmp
                          ,(wxCoord *)&nCharWidth
                          ,(wxCoord *)&nHeight
                         );
        sFullString.Replace(sTgt.c_str(), wxEmptyString, true);
    }

    //
    // Draw the main item text sans the accel text
    //
    POINTL                      vPntStart = {nX, rRect.y + 4};
    ::GpiCharStringAt( impl->GetHPS()
                      ,&vPntStart
                      ,sFullString.length()
                      ,sFullString.char_str()
                     );
    if (bFoundMnemonic)
    {
        //
        // Underline the mnemonic -- still won't work, but at least it "looks" right
        //
        wxPen                       vPen;
        POINTL                      vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide

        vPntStart.x = nX + nWidth - 1;
        vPntStart.y = rRect.y + 2; // Make it look pretty!
        vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black
        rDC.SetPen(vPen);
        ::GpiMove(hPS, &vPntStart);
        ::GpiLine(hPS, &vPntEnd);
    }

    //
    // Now draw the accel text
    //
    if (bFoundAccel)
    {
        size_t                      nWidth;
        size_t                      nHeight;

        rDC.GetTextExtent( sAccel
                          ,(wxCoord *)&nWidth
                          ,(wxCoord *)&nHeight
                         );
        //
        // Back off the starting position from the right edge
        //
        vPntStart.x = rRect.width - (nWidth + 7);
        vPntStart.y = rRect.y + 4;
        ::GpiCharStringAt( impl->GetHPS()
                          ,&vPntStart
                          ,sAccel.length()
                          ,sAccel.char_str()
                         );
    }

    //
    // Draw the bitmap
    // ---------------
    //
    if (IsCheckable() && !m_bmpChecked.IsOk())
    {
        if (eStatus & wxODChecked)
        {
            RECTL                   vRect;
            HBITMAP                 hBmpCheck = ::WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK);

            vRect.xLeft   = rRect.x;
            vRect.xRight  = rRect.x + GetMarginWidth();
            vRect.yBottom = rRect.y;
            vRect.yTop    = rRect.y + m_nHeight - 3;

            ::WinDrawBitmap( hPS             // PS for this menuitem
                            ,hBmpCheck       // system checkmark
                            ,NULL            // draw the whole bitmap
                            ,(PPOINTL)&vRect // destination -- bottom left corner of the menuitem area
                            ,0L              // ignored
                            ,0L              // draw a bitmap
                            ,DBM_NORMAL      // draw normal size
                           );
        }
    }
    else
    {
        //
        // For uncheckable item we use only the 'checked' bitmap
        //
        wxBitmap vBmp(GetBitmap(IsCheckable() ? ((eStatus & wxODChecked) != 0) : TRUE));

        if (vBmp.IsOk())
        {

            wxMemoryDC              vDCMem(&rDC);
            wxMemoryDC*             pOldDC = (wxMemoryDC*)vBmp.GetSelectedInto();

            if(pOldDC != NULL)
            {
                vBmp.SetSelectedInto(NULL);
            }
            vDCMem.SelectObject(vBmp);

            //
            // Center bitmap
            //
            int                     nBmpWidth = vBmp.GetWidth();
            int                     nBmpHeight = vBmp.GetHeight();

            //
            // There should be enough space!
            //
            wxASSERT((nBmpWidth <= rRect.width) && (nBmpHeight <= rRect.height));

            int                     nHeightDiff = m_nHeight - nBmpHeight;

            rDC.Blit( rRect.x + (GetMarginWidth() - nBmpWidth) / 2
                     ,rRect.y + nHeightDiff / 2
                     ,nBmpWidth
                     ,nBmpHeight
                     ,&vDCMem
                     ,0
                     ,0
                     ,wxCOPY
                     ,true
                    );

            if (eStatus & wxODSelected)
            {
                POINTL              vPnt1 = {rRect.x + 1, rRect.y + 3}; // Leave a little background border
                POINTL              vPnt2 = {rRect.x + GetMarginWidth(), rRect.y + m_nHeight - 3};

                LINEBUNDLE          vLine;

                vLine.lColor = vColBack.GetPixel();
                ::GpiSetAttrs( hPS
                              ,PRIM_LINE
                              ,LBB_COLOR
                              ,0
                              ,&vLine
                             );
                ::GpiMove(hPS, &vPnt1);
                ::GpiBox( hPS
                         ,DRO_OUTLINE
                         ,&vPnt2
                         ,0L
                         ,0L
                        );
            }
            vBmp.SetSelectedInto(NULL);
        }
    }
    return true;
} // end of wxOwnerDrawn::OnDrawItem
コード例 #18
0
ファイル: Grid.cpp プロジェクト: ducknoir/audacity
void TimeRenderer::Draw(wxGrid &grid,
                        wxGridCellAttr &attr,
                        wxDC &dc,
                        const wxRect &rect,
                        int row,
                        int col,
                        bool isSelected)
{
    wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);

    wxGridTableBase *table = grid.GetTable();
    TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col);
    wxString tstr;

    if (te) {
        double value;

        table->GetValue(row, col).ToDouble(&value);

        NumericTextCtrl tt(NumericConverter::TIME, &grid,
                           wxID_ANY,
                           te->GetFormat(),
                           value,
                           te->GetRate(),
                           wxPoint(10000, 10000),  // create offscreen
                           wxDefaultSize,
                           true);
        tstr = tt.GetString();

        te->DecRef();
    }

    dc.SetBackgroundMode(wxTRANSPARENT);

    if (grid.IsEnabled())
    {
        if (isSelected)
        {
            dc.SetTextBackground(grid.GetSelectionBackground());
            dc.SetTextForeground(grid.GetSelectionForeground());
        }
        else
        {
            dc.SetTextBackground(attr.GetBackgroundColour());
            dc.SetTextForeground(attr.GetTextColour());
        }
    }
    else
    {
        dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    }

    dc.SetFont(attr.GetFont());

    int hAlign, vAlign;

    attr.GetAlignment(&hAlign, &vAlign);

    grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign);
}
コード例 #19
0
ファイル: toggle.cpp プロジェクト: SamanthaClark/UI-Builder
void wxCustomButton::Paint( wxDC &dc )
{
    int w, h;
    GetSize(&w,&h);

    wxColour foreColour = GetForegroundColour();
    wxColour backColour = GetBackgroundColour();

    if (m_focused)
    {
        backColour.Set( wxMin(backColour.Red()   + 20, 255),
                        wxMin(backColour.Green() + 20, 255),
                        wxMin(backColour.Blue()  + 20, 255) );
    }

    wxBitmap bitmap;

    if (IsEnabled())
    {
        if (GetValue() && m_bmpSelected.Ok())
            bitmap = m_bmpSelected;
        else if (m_focused && m_bmpFocus.Ok())
            bitmap = m_bmpFocus;
        else if (m_bmpLabel.Ok())
            bitmap = m_bmpLabel;
    }
    else
    {
        // try to create disabled if it doesn't exist
        if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok())
            m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel);

        if (m_bmpDisabled.Ok())
            bitmap = m_bmpDisabled;
        else if (m_bmpLabel.Ok())
            bitmap = m_bmpLabel;

        foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
    }

#if wxCHECK_VERSION(2, 8, 0)

    // wxCONTROL_DISABLED
    //flags may have the wxCONTROL_PRESSED, wxCONTROL_CURRENT or wxCONTROL_ISDEFAULT

    int ren_flags = 0;
    if (GetValue())
        ren_flags |= wxCONTROL_PRESSED;
    if (m_focused)
        ren_flags |= wxCONTROL_CURRENT;
    if (!IsEnabled())
        ren_flags |= wxCONTROL_DISABLED;

    wxRendererNative::Get().DrawPushButton(this, dc, wxRect(0, 0, w, h), ren_flags);

#else

    wxBrush brush(backColour, wxSOLID);
    dc.SetBackground(brush);
    dc.SetBrush(brush);
    dc.SetPen(*wxTRANSPARENT_PEN);

    dc.DrawRectangle(0, 0, w, h);

#endif // !wxCHECK_VERSION(2, 8, 0)

    if (bitmap.Ok())
        dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, true );

    if (!GetLabel().IsEmpty())
    {
        dc.SetFont(GetFont());
        dc.SetTextBackground(backColour);
        dc.SetTextForeground(foreColour);
        dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y);
    }

#if !wxCHECK_VERSION(2, 8, 0)
    if (GetValue())                                        // draw sunken border
    {
        dc.SetPen(*wxGREY_PEN);
        dc.DrawLine(0,h-1,0,0);     dc.DrawLine(0,0,w,0);
        dc.SetPen(*wxWHITE_PEN);
        dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1);
        dc.SetPen(*wxBLACK_PEN);
        dc.DrawLine(1,h-2,1,1);     dc.DrawLine(1,1,w-1,1);
    }
    else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border
    {
        dc.SetPen(*wxWHITE_PEN);
        dc.DrawLine(0,h-2,0,0);     dc.DrawLine(0,0,w-1,0);
        dc.SetPen(*wxBLACK_PEN);
        dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1);
        dc.SetPen(*wxGREY_PEN);
        dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1);
    }
#endif // !wxCHECK_VERSION(2, 8, 0)

    dc.SetBackground(wxNullBrush);
    dc.SetBrush(wxNullBrush);
    dc.SetPen(wxNullPen);
}
コード例 #20
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 ) ;
    }
コード例 #21
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 ) ;
    }
コード例 #22
0
ファイル: audio_display.cpp プロジェクト: Gpower2/Aegisub
	void Paint(wxDC &dc)
	{
		int bottom = bounds.y + bounds.height;

		// Background
		dc.SetPen(wxPen(colours.Dark()));
		dc.SetBrush(wxBrush(colours.Dark()));
		dc.DrawRectangle(bounds);

		// Top line
		dc.SetPen(wxPen(colours.Light()));
		dc.DrawLine(bounds.x, bottom-1, bounds.x+bounds.width, bottom-1);

		// Prepare for writing text
		dc.SetTextBackground(colours.Dark());
		dc.SetTextForeground(colours.Light());

		// Figure out the first scale mark to show
		int ms_left = int(pixel_left * ms_per_pixel);
		int next_scale_mark = int(ms_left / scale_minor_divisor);
		if (next_scale_mark * scale_minor_divisor < ms_left)
			next_scale_mark += 1;
		assert(next_scale_mark * scale_minor_divisor >= ms_left);

		// Draw scale marks
		int next_scale_mark_pos;
		int last_text_right = -1;
		int last_hour = -1, last_minute = -1;
		if (duration < 3600) last_hour = 0; // Trick to only show hours if audio is longer than 1 hour
		do {
			next_scale_mark_pos = int(next_scale_mark * scale_minor_divisor / ms_per_pixel) - pixel_left;
			bool mark_is_major = next_scale_mark % scale_major_modulo == 0;

			if (mark_is_major)
				dc.DrawLine(next_scale_mark_pos, bottom-6, next_scale_mark_pos, bottom-1);
			else
				dc.DrawLine(next_scale_mark_pos, bottom-4, next_scale_mark_pos, bottom-1);

			// Print time labels on major scale marks
			if (mark_is_major && next_scale_mark_pos > last_text_right)
			{
				double mark_time = next_scale_mark * scale_minor_divisor / 1000.0;
				int mark_hour = (int)(mark_time / 3600);
				int mark_minute = (int)(mark_time / 60) % 60;
				double mark_second = mark_time - mark_hour*3600.0 - mark_minute*60.0;

				wxString time_string;
				bool changed_hour = mark_hour != last_hour;
				bool changed_minute = mark_minute != last_minute;

				if (changed_hour)
				{
					time_string = wxString::Format("%d:%02d:", mark_hour, mark_minute);
					last_hour = mark_hour;
					last_minute = mark_minute;
				}
				else if (changed_minute)
				{
					time_string = wxString::Format("%d:", mark_minute);
					last_minute = mark_minute;
				}
				if (scale_minor >= Sc_Decisecond)
					time_string += wxString::Format("%02d", (int)mark_second);
				else if (scale_minor == Sc_Centisecond)
					time_string += wxString::Format("%02.1f", mark_second);
				else
					time_string += wxString::Format("%02.2f", mark_second);

				int tw, th;
				dc.GetTextExtent(time_string, &tw, &th);
				last_text_right = next_scale_mark_pos + tw;

				dc.DrawText(time_string, next_scale_mark_pos, 0);
			}

			next_scale_mark += 1;

		} while (next_scale_mark_pos < bounds.width);
	}
コード例 #23
0
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 ) ;
    }    
コード例 #24
0
//---------------------------------------------------------------------------
void wxTabbedWindow::DrawDecorations( wxDC& dc )
{
    // Protability NOTE::: DrawLine(..) draws a line from the first position,
    //                     but not including the point specified by last position.
    //                     This way Windows draws lines, not sure how Motif and Gtk
    //                     prots behave...

    int width, height;
    GetClientSize( &width, &height );

    // check if there's at least a bit of space to draw things

    if ( width  < mHorizGap*2 + BORDER_SZ*2+1 ||
        height < mVertGap*2  + BORDER_SZ*2+1 + mTitleHeight
        )
        return;

    // step #1 - draw border around the tab content area

    // setup position for kind of "pencil"
    int curX = mHorizGap;
    int curY = mVertGap;

    int xSize = width  - mHorizGap*2;
    int ySize = height - mVertGap *2  - mTitleHeight;

    // layer 1 (upper white)
    DrawShadedRect( curX+0, curY+0, xSize-0, ySize-0,
        mWhitePen, mBlackPen, dc  );

    // layer 2 (upper gray)
    DrawShadedRect( curX+1, curY+1, xSize-2-1, ySize-2-1,
        mGrayPen, mGrayPen, dc  );

    // layer 3 (upper darkGray)
    DrawShadedRect( curX+2, curY+2, xSize-3-2, ySize-3-2,
        mDarkPen, mWhitePen, dc  );

    // layer 4 (upper black)
    DrawShadedRect( curX+3, curY+3, xSize-4-3, ySize-4-3,
        mBlackPen, mGrayPen, dc  );

    // add non-siemtric layer from the lower-right side (confroming to MFC-look)

    dc.SetPen( mDarkPen );
    dc.DrawLine( curX+1, curY + ySize - 2, curX + xSize - 1, curY + ySize - 2 );   // horiz
    dc.DrawLine( curX + xSize - 2, curY + 1, curX + xSize - 2, curY + ySize - 2 ); // vert

    // step #2 - draw tab title bars

    curX = mFirstTitleGap;
    curY = height - mVertGap - mTitleHeight;

    size_t tabNo = 0;
    wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();

    while( pNode )
    {
        // "hard-coded metafile" for decorations

        twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));

        xSize = tab.mDims.x;
        ySize = mTitleHeight;

        if ( tabNo == mActiveTab )
        {
            dc.SetPen( mGrayPen );
            dc.DrawLine( curX+1, curY-2, curX+xSize-2, curY-2 );
            dc.DrawLine( curX+1, curY-1, curX+xSize-2, curY-1 );
        }

        dc.SetPen( mWhitePen );

        if ( tabNo == mActiveTab )
            dc.DrawLine( curX, curY-2, curX, curY+ySize-2 );
        else
            dc.DrawLine( curX, curY, curX, curY+ySize-2 );

        dc.SetPen( mDarkPen );
        dc.DrawLine( curX+1, curY+ySize-3, curX+1, curY+ySize-1 ); // to pix down
        dc.DrawLine( curX+2, curY+ySize-2, curX+xSize-2, curY+ySize-2 );
        dc.DrawLine( curX+xSize-3, curY+ySize-3, curX+xSize-2, curY+ySize-3 );
        if ( tabNo == mActiveTab )
            dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-3 );
        else
            dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-1 );

        dc.SetPen( mBlackPen );
        dc.DrawLine( curX+xSize-1, curY, curX+xSize-1, curY+ySize-2 );
        dc.DrawLine( curX+xSize-2, curY+ySize-2, curX+xSize-3, curY+ySize-2 );
        dc.DrawLine( curX+xSize-3, curY+ySize-1, curX+1, curY+ySize-1 );

        pNode = pNode->GetNext();
        ++tabNo;

        // darw image and (or without) text centered within the
        // title bar rectangle

        if ( mLayoutType != wxTITLE_BORDER_ONLY && tab.HasImg() )
        {
            wxMemoryDC tmpDc;
            tmpDc.SelectObject( tab.GetImg() );

            dc.Blit( curX + mTitleHorizGap,
                curY + ( ySize - tab.ImgHeight() ) / 2,
                tab.ImgWidth(),
                tab.ImgHeight(),
                &tmpDc, 0, 0, wxCOPY
                );
        }

        if ( mLayoutType == wxTITLE_IMG_AND_TEXT && tab.HasText() )
        {
            long x,w,h;

            // set select default font of the window into it's device context
            //dc.SetFont( GetLabelingFont() );

            dc.SetTextBackground( GetBackgroundColour() );

            dc.GetTextExtent(tab.mText, &w, &h );

            x = curX + mTitleHorizGap +
                tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);

            dc.DrawText( tab.GetText(), x, curY + ( ySize - h ) / 2 );
        }
        curX += xSize;

    } // end of `while (pNode)'
}  // wxTabbedWindow::DrawDecorations()
コード例 #25
0
ファイル: card.cpp プロジェクト: dariusliep/LogViewer
//+-------------------------------------------------------------+
//| Card::Draw()                                                |
//+-------------------------------------------------------------+
//| Description:                                                |
//| Draw the card at (x, y).                                    |
//| If the card is facedown draw the back of the card.          |
//| If the card is faceup draw the front of the card.           |
//| Cards are not held in bitmaps, instead they are drawn       |
//| from their constituent parts when required.                 |
//| hbmap_symbols contains large and small suit symbols and     |
//| pip values. These are copied to the appropriate part of     |
//| the card. Picture cards use the pictures defined in         |
//| hbmap_pictures. Note that only one picture is defined       |
//| for the Jack, Queen and King, unlike a real pack where      |
//| each suit is different.                                     |
//|                                                             |
//| WARNING:                                                    |
//| The locations of these symbols is 'hard-wired' into the     |
//| code. Editing the bitmaps or the numbers below will         |
//| result in the wrong symbols being displayed.                |
//+-------------------------------------------------------------+
void Card::Draw(wxDC& dc, int x, int y)
{
    wxBrush backgroundBrush( dc.GetBackground() );
    dc.SetBrush(* wxWHITE_BRUSH);
    dc.SetPen(* wxBLACK_PEN);
        dc.DrawRoundedRectangle(x, y, m_width, m_height, 4);
    if (m_wayUp == facedown)
    {
        dc.SetBackground(* wxRED_BRUSH);
        dc.SetBackgroundMode(wxSOLID);
        wxBrush* brush = wxTheBrushList->FindOrCreateBrush(
                            *wxBLACK, wxCROSSDIAG_HATCH
                            );
        dc.SetBrush(* brush);

        dc.DrawRoundedRectangle(
                x + 4, y + 4,
                m_width - 8, m_height - 8,
                2
                );
    }
    else
    {
        wxMemoryDC memoryDC;

        memoryDC.SelectObject(*m_symbolBmap);

//        dc.SetBackgroundMode(wxTRANSPARENT);

        dc.SetTextBackground(*wxWHITE);
        switch (m_suit)
        {
            case spades:
            case clubs:
                dc.SetTextForeground(*wxBLACK);
                break;
            case diamonds:
            case hearts:
                dc.SetTextForeground(*wxRED);
                break;
        }

        int symsize = 11;
        int sympos = 14;
        int sympos2 = 25;
        int symdist = 5;
        int symdist2 = 6;

        int pipsize,pippos,valueheight,valuewidth;
        int valuepos;
        if (m_scale > 1.2)
        {
            pipsize = symsize;
            pippos = sympos;
            valueheight = 10;
            valuewidth = 9;
            valuepos = 50;
        }
        else
        {
            pipsize = 7;
            pippos = 0;
            valueheight = 7;
            valuewidth = 6;
            valuepos = 36;
        }

        // Draw the value
        dc.Blit((wxCoord)(x + m_scale*3),
                (wxCoord)(y + m_scale*3),
                valuewidth,
                valueheight,
                &memoryDC,
                valuewidth * (m_pipValue - 1),
                valuepos,
                wxCOPY);
        dc.Blit((wxCoord)(x + m_width - m_scale*3 - valuewidth),
                (wxCoord)(y + m_height - valueheight - m_scale*3),
                valuewidth,
                valueheight,
                &memoryDC,
                valuewidth * (m_pipValue - 1),
                valuepos+valueheight,
                wxCOPY);

        // Draw the pips
        dc.Blit((wxCoord)(x + m_scale*3 + valuewidth+2),
                (wxCoord)(y + m_scale*3),
                pipsize,
                pipsize,
                &memoryDC,
                pipsize * m_suit,
                pippos,
                wxCOPY);
        dc.Blit((wxCoord)(x + m_width - m_scale*3-valuewidth-pipsize-2),
                (wxCoord)(y + m_height - pipsize - m_scale*3),
                pipsize,
                pipsize,
                &memoryDC,
                pipsize * m_suit,
                pipsize+pippos,
                wxCOPY);

        switch (m_pipValue)
        {
        case 1:
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - m_scale*5 + m_height / 2),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            break;

        case 3:
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + m_height / 2),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
        case 2:
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            break;

        case 5:
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + m_height / 2),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
        case 4:
            dc.Blit((wxCoord)(x - symdist +  m_width / 4),
                    (wxCoord)(y - symdist + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            break;

        case 8:
            dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10),
                    (wxCoord)(y - symdist + 5 * m_height / 8),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
        case 7:
            dc.Blit((wxCoord)(x - symdist + 5 * m_width / 10),
                    (wxCoord)(y - symdist + 3 * m_height / 8),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
        case 6:
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC, symsize * m_suit, sympos, wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + m_height / 2),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + m_height / 2),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            break;

        case 10:
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + 2 * m_height / 3),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
        case 9:
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist2 + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist2 + 5 * m_height / 12),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + 7 * m_height / 12),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);

            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist2 + m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist2 + 5 * m_height / 12),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + 7 * m_height / 12),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + 3 * m_width / 4),
                    (wxCoord)(y - symdist + 3 * m_height / 4),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            dc.Blit((wxCoord)(x - symdist + m_width / 2),
                    (wxCoord)(y - symdist + m_height / 3),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            break;
        case 11:
        case 12:
        case 13:
            memoryDC.SelectObject(*m_pictureBmap);
            int picwidth = 40,picheight = 45;
            dc.Blit((wxCoord)(x + (m_width-picwidth)/2),
                    (wxCoord)(y - picheight/2 + m_height/2),
                    picwidth,
                    picheight,
                    &memoryDC,
                    picwidth * (m_pipValue - 11),
                    0,
                    wxCOPY);

            memoryDC.SelectObject(*m_symbolBmap);
            dc.Blit((wxCoord)(x + m_width-(m_width-picwidth)/2-symsize-3),
                    (wxCoord)(y - picheight/2+m_height/2+1),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos,
                    wxCOPY);
            dc.Blit((wxCoord)(x + (m_width-picwidth)/2+2),
                    (wxCoord)(y + picheight/2 + m_height/2-symsize),
                    symsize,
                    symsize,
                    &memoryDC,
                    symsize * m_suit,
                    sympos2,
                    wxCOPY);
            break;
        }

    }
    dc.SetBackground( backgroundBrush );
} // Card:Draw()
コード例 #26
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
}
コード例 #27
0
ファイル: ownerdrw.cpp プロジェクト: beanhome/dev
// draw the item
bool wxOwnerDrawn::OnDrawItem( wxDC& rDC,
                               const wxRect& rRect,
                               wxODAction eAction,
                               wxODStatus eStatus )
{

    //
    // Select the font and draw the text
    // ---------------------------------
    //

    CHARBUNDLE                      vCbnd;
    wxPMDCImpl                      *impl = (wxPMDCImpl*) rDC.GetImpl();
    HPS                             hPS= impl->GetHPS();
    wxFont                          vFont;
    wxColour                        vColBack;
    wxColour                        vColText;
    COLORREF                        vRef;
    RECTL                           vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};

    memset(&vCbnd, 0, sizeof(CHARBUNDLE));

    GetFontToUse(vFont);
    GetColourToUse(eStatus, vColText, vColBack);

    rDC.SetFont(vFont);
    rDC.SetTextBackground(vColBack);
    rDC.SetTextForeground(vColText);
    rDC.SetBackgroundMode(wxTRANSPARENT);

    vCbnd.lColor     = vColText.GetPixel();
    vCbnd.lBackColor = vColBack.GetPixel();
    ::GpiSetAttrs( hPS
                  ,PRIM_CHAR
                  ,CBB_BACK_COLOR | CBB_COLOR
                  ,0
                  ,&vCbnd
                 );
    ::GpiSetBackMix( hPS
                    ,BM_LEAVEALONE
                   );

    //
    // Paint the background
    //
    ::WinFillRect(hPS, &vRect, vColBack.GetPixel());

    //
    // Determine where to draw and leave space for a check-mark.
    //
    int nX = rRect.x + GetMarginWidth();

    //
    // Unfortunately, unlike Win32, PM has no owner drawn specific text
    // drawing methods like ::DrawState that can cleanly handle accel
    // mnemonics and deal, automatically, with various states, so we have
    // to handle them ourselves. Notice Win32 can't handle \t in ownerdrawn
    // strings either.  We cannot handle mnemonics either.  We display
    // them, though, in the hope we can figure them out some day.
    //

    //
    // Display main text
    //
    wxString sFullString = GetItemLabel(); // need to save the original text
    int      nIndex;
    size_t   nWidth;
    size_t   nCharWidth;
    size_t   nHeight;
    bool     bFoundMnemonic = false;

    //
    // Deal with the mnemonic character
    //
    nIndex = sFullString.Find(wxT("~"));
    if (nIndex != -1)
    {
        wxString sTmp = sFullString;

        bFoundMnemonic = true;
        sTmp.Remove(nIndex);
        rDC.GetTextExtent( sTmp
                          ,(wxCoord *)&nWidth
                          ,(wxCoord *)&nHeight
                         );
        sTmp = sFullString[(size_t)(nIndex + 1)];
        rDC.GetTextExtent( sTmp
                          ,(wxCoord *)&nCharWidth
                          ,(wxCoord *)&nHeight
                         );
        sFullString.Replace(sTgt.c_str(), wxEmptyString, true);
    }

    //
    // Draw the main item text sans the accel text
    //
    POINTL                      vPntStart = {nX, rRect.y + 4};
    ::GpiCharStringAt( impl->GetHPS()
                      ,&vPntStart
                      ,sFullString.length()
                      ,sFullString.char_str()
                     );
    if (bFoundMnemonic)
    {
        //
        // Underline the mnemonic -- still won't work, but at least it "looks" right
        //
        wxPen                       vPen;
        POINTL                      vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide

        vPntStart.x = nX + nWidth - 1;
        vPntStart.y = rRect.y + 2; // Make it look pretty!
        vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black
        rDC.SetPen(vPen);
        ::GpiMove(hPS, &vPntStart);
        ::GpiLine(hPS, &vPntEnd);
    }

    return true;
} // end of wxOwnerDrawn::OnDrawItem
コード例 #28
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
void wxCustomButton::Paint( wxDC &dc )
{
#if (wxMINOR_VERSION<8)
    dc.BeginDrawing();
#endif

    int w, h;
    GetSize(&w,&h);

    wxColour foreColour = GetForegroundColour();
    wxColour backColour = GetBackgroundColour();

    if (m_focused)
    {
        backColour.Set( wxMin(backColour.Red()   + 20, 255),
                        wxMin(backColour.Green() + 20, 255),
                        wxMin(backColour.Blue()  + 20, 255) );
    }

    wxBitmap bitmap;

    if (IsEnabled())
    {
        if (GetValue() && m_bmpSelected.Ok())
            bitmap = m_bmpSelected;
        else if (m_focused && m_bmpFocus.Ok())
            bitmap = m_bmpFocus;
        else if (m_bmpLabel.Ok())
            bitmap = m_bmpLabel;
    }
    else
    {
        // try to create disabled if it doesn't exist
        if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok())
            m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel);

        if (m_bmpDisabled.Ok())
            bitmap = m_bmpDisabled;
        else if (m_bmpLabel.Ok())
            bitmap = m_bmpLabel;

        foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
    }

    wxBrush brush(backColour, wxSOLID);
    dc.SetBackground(brush);
    dc.SetBrush(brush);
    dc.SetPen(*wxTRANSPARENT_PEN);

    dc.DrawRectangle(0, 0, w, h);

    if (bitmap.Ok())
        dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, TRUE );

    if (!GetLabel().IsEmpty())
    {
        dc.SetFont(GetFont());
        dc.SetTextBackground(backColour);
        dc.SetTextForeground(foreColour);
        dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y);
    }

    if (GetValue())                                        // draw sunken border
    {
        dc.SetPen(*wxGREY_PEN);
        dc.DrawLine(0,h-1,0,0);     dc.DrawLine(0,0,w,0);
        dc.SetPen(*wxWHITE_PEN);
        dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1);
        dc.SetPen(*wxBLACK_PEN);
        dc.DrawLine(1,h-2,1,1);     dc.DrawLine(1,1,w-1,1);
    }
    else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border
    {
        dc.SetPen(*wxWHITE_PEN);
        dc.DrawLine(0,h-2,0,0);     dc.DrawLine(0,0,w-1,0);
        dc.SetPen(*wxBLACK_PEN);
        dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1);
        dc.SetPen(*wxGREY_PEN);
        dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1);
    }

    dc.SetBackground(wxNullBrush);
    dc.SetBrush(wxNullBrush);
    dc.SetPen(wxNullPen);
#if (wxMINOR_VERSION<8)
    dc.EndDrawing();
#endif
}
コード例 #29
0
ファイル: browser_cover.cpp プロジェクト: boh1996/silverjuke
void SjCoverBrowser::DoPaint(wxDC& dc)
{
	long    x, y, w, h;
	#define SPACE_BRUSH g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgBrush

	// reset required and waiting images
	g_mainFrame->m_imgThread->RequireStart(m_window);

	// draw stuff very left (does not scroll)
	dc.SetPen(*wxTRANSPARENT_PEN);
	dc.SetBrush(SPACE_BRUSH);
	dc.DrawRectangle(0, 0, SPACE_LEFT, m_window->m_clientH);

	dc.SetClippingRegion(wxRect(0, 0, SPACE_LEFT-SEL_BORDER_W, m_window->m_clientH));
	w = m_fontHeight - 4;
	h = m_fontHeight - 4;
	x = (SPACE_LEFT-w) / 2;
	y = SPACE_TOP + 2;
	dc.SetPen(g_mainFrame->m_workspaceColours[SJ_COLOUR_TITLE1].fgPen);
	SjTools::DrawIcon(dc, wxRect(x, y, w, h),
	                  (m_flags&SJ_BROWSER_VIEW_COVER)? SJ_DRAWICON_TRIANGLE_DOWN : SJ_DRAWICON_TRIANGLE_RIGHT);

	if( g_mainFrame->m_libraryModule )
		m_window->DrawUpText(dc, g_mainFrame->m_libraryModule->GetUpText(), 0, SPACE_TOP+m_fontHeight, SPACE_LEFT, m_window->m_clientH-(SPACE_TOP+m_fontHeight));
	dc.DestroyClippingRegion();

	// draw space atop of all covers
	long currY = -m_scrollY;
	dc.SetBrush(SPACE_BRUSH);
	dc.SetPen(*wxTRANSPARENT_PEN);
	dc.DrawRectangle(SPACE_LEFT, currY, m_window->m_clientW, g_mainFrame->m_currColumnYSpace);

	// go through all cover rows
	int coverIndex = 0;
	currY += g_mainFrame->m_currColumnYSpace;
	for( int yIndex = 0; yIndex < m_coversYCount+ADD_ROWS/*try two rows more*/; yIndex++ )
	{
		// go through all cover columns
		long currX = SPACE_LEFT;
		for( int xIndex = 0; xIndex < m_coversXCount; xIndex++ )
		{
			bool selectCover = false, coverDrawn = false, borderBottom = true;

			if( coverIndex < m_allocatedCoverCount )
			{
				SjCol* cover = m_allocatedCover[coverIndex++];
				if( cover && cover->m_rowCount>0 && cover->m_rows[0]->m_roughType==SJ_RRTYPE_COVER )
				{
					SjImgThreadObj* cachedImg = m_window->RequireImage(cover->m_rows[0]->m_textm); // cachedImg may be NULL, but this is okay for PaintCover() and for ReleaseImage()
					m_window->PaintCover(dc, cachedImg, currX, currY);
					g_mainFrame->m_imgThread->ReleaseImage(m_window, cachedImg);
					coverDrawn = true;
					selectCover = cover->FindFirstSelectedRow()!=NULL;

					// draw text below cover
					if( m_flags&SJ_BROWSER_VIEW_COVER )
					{
						// get text
						wxString texts[2];
						int trackCount = 0;
						for( int r = 0; r < cover->m_rowCount; r++ )
						{
							SjRow* row = cover->m_rows[r];
							if( row )
							{
								if( row->m_roughType == SJ_RRTYPE_TITLE1 || row->m_roughType == SJ_RRTYPE_TITLE2 )
								{
									if( texts[0].IsEmpty() ) texts[0] = row->m_textm; else texts[1] = row->m_textm;
								}
								else if( row->m_roughType == SJ_RRTYPE_NORMAL )
								{
									trackCount ++;
								}
							}
						}

						if( texts[0].IsEmpty() ) {
							texts[0].Printf(_("%s tracks"), SjTools::FormatNumber(trackCount).c_str());
						}

						// draw text
						for( int i=0; i<m_linesBelowCover; i++ )
						{
							wxRect drawRect(currX, currY+g_mainFrame->m_currCoverHeight+m_fontHeight*i, g_mainFrame->m_currCoverWidth, m_fontHeight);

							SjSkinColour* bgcolour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : SJ_COLOUR_NORMAL];
							SjSkinColour* fgcolour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : (i==0?SJ_COLOUR_TITLE1:SJ_COLOUR_TITLE2)];

							wxFont* stdFont   = i==0? &g_mainFrame->m_currBoldFont : &g_mainFrame->m_currStdFont;
							wxFont* smallFont = i==0? &g_mainFrame->m_currSmallBoldFont : &g_mainFrame->m_currSmallFont;

							dc.SetPen(*wxTRANSPARENT_PEN);
							dc.SetBrush(bgcolour->bgBrush);
							dc.DrawRectangle(drawRect);

							dc.SetTextBackground(fgcolour->bgColour);
							dc.SetTextForeground(fgcolour->fgColour);
							g_tools->DrawSingleLineText(dc, texts[i], drawRect,
							                            *stdFont, *smallFont, NULL, fgcolour->hiColour);

							if( selectCover )
								borderBottom = false;
						}
					}
				}
			}

			if( !coverDrawn )
			{
				// draw space instead of cover (normally this happens if this are the last covers)
				dc.SetPen(*wxTRANSPARENT_PEN);
				dc.SetBrush(g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgBrush);
				dc.DrawRectangle(currX-SEL_BORDER_W, currY-SEL_BORDER_W, g_mainFrame->m_currCoverWidth+SEL_BORDER_W*2, m_coverNTitleHeight+SEL_BORDER_W*2);
			}
			else
			{
				// draw the (selection) border
				SjSkinColour* colour = &g_mainFrame->m_workspaceColours[selectCover? SJ_COLOUR_SELECTIONODD : SJ_COLOUR_NORMAL];

				dc.SetPen(colour->bgPen);
				dc.SetBrush(*wxTRANSPARENT_BRUSH);
				for( int i = 1; i <= SEL_BORDER_W; i++ )
				{
					dc.DrawRectangle(currX-i, currY-i, g_mainFrame->m_currCoverWidth+i*2, m_coverNTitleHeight+i*(borderBottom?2:1));
					if( !borderBottom )
					{
						dc.SetPen(g_mainFrame->m_workspaceColours[SJ_COLOUR_NORMAL].bgPen);
						y = currY+m_coverNTitleHeight+i-1;
						dc.DrawLine(currX-SEL_BORDER_W, y, currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W, y);
						dc.SetPen(colour->bgPen);
					}
				}
			}

			// draw space aright of the cover
			x = currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W;
			y = currY-SEL_BORDER_W;
			h = m_coverNTitleHeight+SEL_BORDER_W*2;
			w = m_coverXSpace-SEL_BORDER_W*2;
			if( xIndex == m_coversXCount-1 )
				w = m_window->m_clientW-(currX+g_mainFrame->m_currCoverWidth+SEL_BORDER_W);
			if( w > 0 )
			{
				dc.SetPen(*wxTRANSPARENT_PEN);
				dc.SetBrush(SPACE_BRUSH);
				dc.DrawRectangle(x, y, w, h);
			}

			// next cover in row
			currX += g_mainFrame->m_currCoverWidth+m_coverXSpace;
		}

		// draw space below this cover row
		x = SPACE_LEFT-SEL_BORDER_W;
		y = currY+m_coverNTitleHeight+SEL_BORDER_W;
		w = m_window->m_clientW-x;
		h = g_mainFrame->m_currColumnYSpace-SEL_BORDER_W*2;
		if( yIndex == (m_coversYCount-1)+ADD_ROWS /*we've added 2 in the for() loop, so no -1 here*/ )
			h = m_window->m_clientH-(currY+m_coverNTitleHeight+SEL_BORDER_W);
		if( h > 0 )
		{
			dc.SetPen(*wxTRANSPARENT_PEN);
			dc.SetBrush(SPACE_BRUSH);
			dc.DrawRectangle(x, y, w, h);
		}

		// next row
		currY += m_coverNTitleHeight+g_mainFrame->m_currColumnYSpace;
	}

	// free all images that are no longer required but still waiting
	g_mainFrame->m_imgThread->RequireEnd(m_window);
}
コード例 #30
0
ファイル: CRawlogTreeView.cpp プロジェクト: 3660628/mrpt
/* ------------------------------------------------------------
						reloadFromRawlog
   ------------------------------------------------------------ */
void CRawlogTreeView::OnDraw(wxDC& dc)
{
	// The origin of the window:
	int xc0,y0;
	GetViewStart(&xc0,&y0);		// Not pixels, but **lines**

	int w,h;
	GetSize(&w,&h);

	wxRect  visibleArea(xc0*ROW_HEIGHT,y0*ROW_HEIGHT,w*ROW_HEIGHT,h*ROW_HEIGHT);

	//wxBufferedDC	dc(&real_dc, visibleArea.GetSize() ); //wxSize(w,h) );

	dc.SetPen( *wxTRANSPARENT_PEN );
	dc.SetBrush( *wxWHITE_BRUSH );
	dc.DrawRectangle(xc0*ROW_HEIGHT,y0*ROW_HEIGHT,w,h);

	// The first time only, create fonts:
	static wxFont	font_normal(11,wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
	static wxFont	font_bold  (11,wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD  );
	static wxColour wxColorGray(40,40,40);
	static wxColour brush_SELECTED_COLOR( 0,200, 200);
	static wxPen gray_thick( brush_SELECTED_COLOR, 3 );
	static wxPen gray_thin( brush_SELECTED_COLOR, 1 );

	size_t first_item = y0;

	size_t n_visible_items = (h/ROW_HEIGHT)+1;
	if (n_visible_items<1) n_visible_items=1;

	size_t last_item = first_item+n_visible_items-1;

	last_item = min(last_item, m_tree_nodes.size() );

	// Draw icons?
	// ----------------------------
	int   x0 = 30;
	int   Ax0_img  = 0; // Increment in x for the icons, if any.

	if (m_imageList && m_imageList->GetImageCount()>0)
	{
		int		imgw,imgh;
		m_imageList->GetSize(0,imgw,imgh);
		Ax0_img = imgw + 4;
	}

	// Draw only those elements that are visible:
	// -----------------------------------------------
	const int		first_tim_y = ROW_HEIGHT + 1;
	const int		last_tim_y  = (m_tree_nodes.size()-1)*ROW_HEIGHT - 1;


	for (size_t i=first_item;i<last_item;i++)
	{
		int y = i*ROW_HEIGHT;	// y= bottom of that row
		TNodeData  &d = m_tree_nodes[i];

		switch (d.level)
		{
		case 0:
			dc.SetFont( font_bold );
			dc.SetTextForeground( *wxBLACK );
			break;

		case 1:
			dc.SetFont( font_normal );
			dc.SetTextForeground( *wxBLACK );
			break;

		default:
		case 2:
			dc.SetFont( font_normal );
			dc.SetTextForeground( wxColorGray );
			break;
		};

		// Select icon & text according to type of object
		// ------------------------------------------------
		int			icon = -1;
		wxString	s;

		if (i==0)
		{
			// The root node:
			s = _U( format("Rawlog: %s",m_rawlog_name.c_str()).c_str() );
			icon = 3;
		}
		else
		{
			// According to class ID:
			m_rawlog->getAsGeneric( d.index );  // Just to assure it's on memory

			if (d.data.present())
			{
				// Icon:
				icon = iconIndexFromClass( d.data->GetRuntimeClass() );

				// Text:
				if (d.level==1)
				{
					s << _U( format("[%i] ",(int)d.index ).c_str() );
				}

				s << _U( d.data->GetRuntimeClass()->className );

				// Sensor label:
				if ( d.data->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ) )
				{
					CObservationPtr obs = CObservationPtr(d.data);

					/*if (first_tim==INVALID_TIMESTAMP)
					{
						first_tim = obs->timestamp;
						first_tim_y = y+1;
					}

					last_tim = obs->timestamp;
					last_tim_y = y+1;*/

					if ( !obs->sensorLabel.empty())
						s << wxT(" : ") << _U( obs->sensorLabel.c_str() );
				}
			}
		}

		// Draw text and icon:
		// ------------------------------------
		if (m_selectedItem==int(i))
		{
			dc.SetBrush( brush_SELECTED_COLOR );
			dc.DrawRectangle(x0+TREE_HORZ_STEPS * d.level,y,w-x0,ROW_HEIGHT);
			dc.SetTextBackground( brush_SELECTED_COLOR );

			dc.SetPen( gray_thick );
			dc.DrawLine(x0,y+1,x0+TREE_HORZ_STEPS * d.level,y+1);
		}
		else
		{
			dc.SetTextBackground( GetBackgroundColour() );

			dc.SetPen( gray_thin );
			dc.DrawLine(x0,y+1,x0+TREE_HORZ_STEPS * d.level,y+1);
		}

		dc.DrawText( s, Ax0_img + x0 + TREE_HORZ_STEPS * d.level, y );
		if (m_imageList && icon>=0)
			m_imageList->Draw(icon, dc,x0 + TREE_HORZ_STEPS * d.level +1,y );
	}

	// Draw time-line:
	// -----------------------------------------------
	dc.SetPen( *wxLIGHT_GREY_PEN );
	dc.DrawLine(15, visibleArea.GetTop() ,15, visibleArea.GetBottom() );

	dc.SetTextForeground( wxColorGray );
	dc.SetFont( font_normal );
	dc.DrawRotatedText(_("Time"),17,10,-90);

	// timestamps in time-line:
	// -----------------------------------------------
	if (m_rawlog_start!=INVALID_TIMESTAMP && m_rawlog_last!=INVALID_TIMESTAMP && last_tim_y>first_tim_y)
	{
		dc.SetFont( font_normal );

		const double len_tim = mrpt::system::timeDifference(m_rawlog_start,m_rawlog_last);

		for (size_t i=first_item;i<last_item;i++)
		{
			int y = i*ROW_HEIGHT;	// y= bottom of that row
			TNodeData  &d = m_tree_nodes[i];

			if (d.data.present())
			{
				TTimeStamp	t_this = INVALID_TIMESTAMP;
				if ( d.data->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ) )
				{
					CObservationPtr obs = CObservationPtr(d.data);
					t_this = obs->timestamp;
				}

				if (t_this!=INVALID_TIMESTAMP)
				{
					// Draw line:
					if (m_selectedItem==int(i))
							dc.SetPen( gray_thick );
					else	dc.SetPen( gray_thin );

					// Calc. the "y" coordinate for this time:
					double At = mrpt::system::timeDifference(m_rawlog_start,t_this);
					double rat = At / len_tim;
					int  ty =  first_tim_y + (last_tim_y-first_tim_y)*rat;

					dc.DrawLine(15,ty,x0,y+1);

					// Draw some text labels with times:
					if ((i%5)==0)
					{
						dc.DrawLine(10,ty,15,ty);

						// Seconds from start of rawlog:
						if (m_rawlog_start!=INVALID_TIMESTAMP)
						{
							double sec = mrpt::system::timeDifference(m_rawlog_start,t_this);
							wxString s = _U( format("%.03fs", sec ).c_str() );
							dc.DrawRotatedText(s,17,ty+3,-90);
						}
					}
				}
			}
		} // end for i
	}
}