コード例 #1
1
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
                               wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif

    int xlocal = x + m_PosX;
    int ylocal = y + m_PosY;

    if (m_UseBkColour)
    {
        wxBrush myb = wxBrush(m_BkColour, wxBRUSHSTYLE_SOLID);

        int real_y1 = mMax(ylocal, view_y1);
        int real_y2 = mMin(ylocal + m_Height - 1, view_y2);

        dc.SetBrush(myb);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
    }

    if (m_Border == 1)
    {
        // draw thin border using lines
        wxPen mypen1(m_BorderColour1, 1, wxPENSTYLE_SOLID);
        wxPen mypen2(m_BorderColour2, 1, wxPENSTYLE_SOLID);

        dc.SetPen(mypen1);
        dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal);
        dc.SetPen(mypen2);
        dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal +  m_Width - 1, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
    }
    else if (m_Border> 0)
    {
        wxBrush mybrush1(m_BorderColour1, wxBRUSHSTYLE_SOLID);
        wxBrush mybrush2(m_BorderColour2, wxBRUSHSTYLE_SOLID);

        // draw upper left corner
        // 0---------------5
        // |              /
        // | 3-----------4
        // | |
        // | 2
        // |/
        // 1

        wxPoint poly[6];
        poly[0].x =m_PosX;
        poly[0].y = m_PosY ;
        poly[1].x =m_PosX;
        poly[1].y = m_PosY + m_Height;
        poly[2].x =m_PosX + m_Border;
        poly[2].y = poly[1].y - m_Border;
        poly[3].x =poly[2].x ;
        poly[3].y = m_PosY + m_Border;
        poly[4].x =m_PosX + m_Width - m_Border;
        poly[4].y = poly[3].y;
        poly[5].x =m_PosX + m_Width;
        poly[5].y = m_PosY;

        dc.SetBrush(mybrush1);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawPolygon(6, poly, x, y);

        // draw lower right corner reusing point 1,2,4 and 5
        //                 5
        //                /|
        //               4 |
        //               | |
        //   2-----------3 |
        //  /              |
        // 1---------------0
        dc.SetBrush(mybrush2);
        poly[0].x = poly[5].x;
        poly[0].y = poly[1].y;
        poly[3].x = poly[4].x;
        poly[3].y = poly[2].y;
        dc.DrawPolygon(6, poly, x, y);

        // smooth color transition like firefox
        wxColour borderMediumColour(
            (m_BorderColour1.Red() + m_BorderColour2.Red()) /2 ,
            (m_BorderColour1.Green() + m_BorderColour2.Green()) /2 ,
            (m_BorderColour1.Blue() + m_BorderColour2.Blue()) /2
        );
        wxPen mypen3(borderMediumColour, 1, wxPENSTYLE_SOLID);
        dc.SetPen(mypen3);
        dc.DrawLines(2, &poly[1], x, y - 1); // between 1 and 2
        dc.DrawLines(2, &poly[4], x, y - 1); // between 4 and 5
    }
    if (m_Cells)
    {
        // draw container's contents:
        for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
        {

            // optimize drawing: don't render off-screen content:
            if ((ylocal + cell->GetPosY() <= view_y2) &&
                    (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))
            {
                // the cell is visible, draw it:
                UpdateRenderingStatePre(info, cell);
                cell->Draw(dc,
                           xlocal, ylocal, view_y1, view_y2,
                           info);
                UpdateRenderingStatePost(info, cell);
            }
            else
            {
                // the cell is off-screen, proceed with font+color+etc.
                // changes only:
                cell->DrawInvisible(dc, xlocal, ylocal, info);
            }
        }
    }
}
コード例 #2
0
ファイル: shapes.cpp プロジェクト: d0k/malprogramm
void Rectangle::draw(wxDC& dc) const {
	dc.SetPen(*wxBLACK_PEN);
	dc.SetBrush(wxBrush(color));
	dc.DrawRectangle(left, top, width, height);
}
コード例 #3
0
ファイル: plot.cpp プロジェクト: ccamatthews/fityk
void FPlot::draw_data (wxDC& dc,
                       double (*compute_y)(vector<Point>::const_iterator,
                                           Model const*),
                       fityk::Data const* data,
                       Model const* model,
                       wxColour const& color, wxColour const& inactive_color,
                       int Y_offset,
                       bool cumulative)
{
    if (data->is_empty())
        return;
    vector<Point>::const_iterator first = data->get_point_at(ftk->view.left()),
                                  last = data->get_point_at(ftk->view.right());
    if (first > data->points().begin())
        --first;
    if (last < data->points().end())
        ++last;
    // prepare coordinates
    int len = last - first;
    if (len <= 0)
        return;
    wxPoint2DDouble *pp = new wxPoint2DDouble[len];
    vector<bool> aa(len);
    vector<double> yy(len);
    Y_offset *= (get_pixel_height(dc) / 100);
    for (int i = 0; i != len; ++i) {
        const Point& p = *(first + i);
        pp[i].m_x = xs.px_d(p.x);
        yy[i] = (*compute_y)((first+i), model);
        if (cumulative && i > 0)
            yy[i] += yy[i-1];
        pp[i].m_y = ys.px_d(yy[i]) - Y_offset;
        aa[i] = p.is_active;
    }

    // draw inactive
    wxColour icol = inactive_color.Ok() ? inactive_color : inactiveDataCol;
    dc.SetPen(wxPen(icol, pen_width));
    dc.SetBrush(wxBrush(icol, wxBRUSHSTYLE_SOLID));
    draw_data_by_activity(dc, pp, aa, false);
    if (draw_sigma)
        for (int i = 0; i != len; ++i)
            if (!aa[i]) {
                double sigma = (first + i)->sigma;
                dc.DrawLine(iround(pp[i].m_x), ys.px(yy[i] - sigma) - Y_offset,
                            iround(pp[i].m_x), ys.px(yy[i] + sigma) - Y_offset);
            }

    // draw active
    wxColour acol = color.Ok() ? color : activeDataCol;
    dc.SetPen(wxPen(acol, pen_width));
    dc.SetBrush(wxBrush(acol, wxBRUSHSTYLE_SOLID));
    draw_data_by_activity(dc, pp, aa, true);
    if (draw_sigma)
        for (int i = 0; i != len; ++i)
            if (aa[i]) {
                double sigma = (first + i)->sigma;
                dc.DrawLine(iround(pp[i].m_x), ys.px(yy[i] - sigma) - Y_offset,
                            iround(pp[i].m_x), ys.px(yy[i] + sigma) - Y_offset);
            }

    delete [] pp;
}
コード例 #4
0
ファイル: tabart.cpp プロジェクト: avdbg/wxTest
void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
                                wxWindow* wnd,
                                const wxAuiNotebookPage& page,
                                const wxRect& in_rect,
                                int close_button_state,
                                wxRect* out_tab_rect,
                                wxRect* out_button_rect,
                                int* x_extent)
{
    wxCoord normal_textx, normal_texty;
    wxCoord selected_textx, selected_texty;
    wxCoord textx, texty;

    // if the caption is empty, measure some temporary text
    wxString caption = page.caption;
    if (caption.empty())
        caption = wxT("Xj");

    dc.SetFont(m_selectedFont);
    dc.GetTextExtent(caption, &selected_textx, &selected_texty);

    dc.SetFont(m_normalFont);
    dc.GetTextExtent(caption, &normal_textx, &normal_texty);

    // figure out the size of the tab
    wxSize tab_size = GetTabSize(dc,
                                 wnd,
                                 page.caption,
                                 page.bitmap,
                                 page.active,
                                 close_button_state,
                                 x_extent);

    wxCoord tab_height = tab_size.y;
    wxCoord tab_width = tab_size.x;
    wxCoord tab_x = in_rect.x;
    wxCoord tab_y = in_rect.y + in_rect.height - tab_height;

    caption = page.caption;

    // select pen, brush and font for the tab to be drawn

    if (page.active)
    {
        dc.SetPen(m_selectedBkPen);
        dc.SetBrush(m_selectedBkBrush);
        dc.SetFont(m_selectedFont);
        textx = selected_textx;
        texty = selected_texty;
    }
    else
    {
        dc.SetPen(m_normalBkPen);
        dc.SetBrush(m_normalBkBrush);
        dc.SetFont(m_normalFont);
        textx = normal_textx;
        texty = normal_texty;
    }


    // -- draw line --

    wxPoint points[7];
    points[0].x = tab_x;
    points[0].y = tab_y + tab_height - 1;
    points[1].x = tab_x + tab_height - 3;
    points[1].y = tab_y + 2;
    points[2].x = tab_x + tab_height + 3;
    points[2].y = tab_y;
    points[3].x = tab_x + tab_width - 2;
    points[3].y = tab_y;
    points[4].x = tab_x + tab_width;
    points[4].y = tab_y + 2;
    points[5].x = tab_x + tab_width;
    points[5].y = tab_y + tab_height - 1;
    points[6] = points[0];

    dc.SetClippingRegion(in_rect);

    dc.DrawPolygon(WXSIZEOF(points) - 1, points);

    dc.SetPen(*wxGREY_PEN);

    //dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points);
    dc.DrawLines(WXSIZEOF(points), points);


    int text_offset;

    int close_button_width = 0;
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        close_button_width = m_activeCloseBmp.GetWidth();
        text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
    }
    else
    {
        text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2);
    }

    // set minimum text offset
    if (text_offset < tab_x + tab_height)
        text_offset = tab_x + tab_height;

    // chop text if necessary
    wxString draw_text = wxAuiChopText(dc,
                          caption,
                          tab_width - (text_offset-tab_x) - close_button_width);

    // draw tab text
    dc.DrawText(draw_text,
                 text_offset,
                 (tab_y + tab_height)/2 - (texty/2) + 1);


    // draw focus rectangle
    if (page.active && (wnd->FindFocus() == wnd))
    {
        wxRect focusRect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1),
            selected_textx, selected_texty);

        focusRect.Inflate(2, 2);

        wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
    }

    // draw close button if necessary
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        wxBitmap bmp;
        if (page.active)
            bmp = m_activeCloseBmp;
        else
            bmp = m_disabledCloseBmp;

        wxRect rect(tab_x + tab_width - close_button_width - 1,
                    tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1,
                    close_button_width,
                    tab_height - 1);
        DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state);

        *out_button_rect = rect;
    }


    *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height);

    dc.DestroyClippingRegion();
}
コード例 #5
0
void SeqAA::show_direct ( wxDC& dc )
    {
    myass ( itemsperline , "AA:show_direct_ipl" ) ;
    if ( !itemsperline ) return ;
    mylog ( "SeqAA::show_direct" , "0" ) ;
    can->SetFont(*can->font);
    dc.SetFont(*can->font);
    int a , b , w , h , n , bo = can->border ;
    int csgc = can->NumberOfLines() , cbs = can->blocksize ;
    int cih = can->isHorizontal() ;
    int xa , xb , ya , yb ;
    for ( n = 0 ; n < csgc && can->seq[n] != this ; n++ ) ;
    if ( n == csgc ) return ;
    mylog ( "SeqAA::show_direct" , "1" ) ;
    
    // Setting basic values
    int cw = can->charwidth , ch = can->charheight ;
    int ox = bo + cw + cw * endnumberlength ;
    int oy = n*ch+bo ;
    
    can->MyGetClientSize ( &w , &h ) ;
    xb = w ;
    yb = h ;

    wxColour tbg = dc.GetTextBackground () ;
    wxColour tfg = dc.GetTextForeground () ;
    int bm = dc.GetBackgroundMode () ;
    wxColour tf ;
    if ( primaryMode ) tf = *wxBLACK ;
    else tf = myapp()->frame->aa_color ;; // wxColour ( 130 , 130 , 130 ) ;//*wxLIGHT_GREY ;
    dc.SetTextForeground ( tf ) ;
    dc.SetBackgroundMode ( wxTRANSPARENT ) ;

    dc.GetDeviceOrigin ( &xa , &ya ) ;
    xa = -xa ;
    xb += xa ;
    ya = -ya ;
    yb += ya ;
    
    mylog ( "SeqAA::show_direct" , "2" ) ;
    b = ( ya - ch - oy ) / ( ch * csgc ) * itemsperline ;
    mylog ( "SeqAA::show_direct" , "3" ) ;
    for ( a = 0 ; a < b && a < s.length() ; a += itemsperline ) ;
        
    for ( ; a < s.length() ; a++ )
        {
        int px = a % itemsperline , py = a / itemsperline ;
        
        bool showNumber = ( px == 0 ) ;
        
        px = px * cw + ( px / cbs ) * ( cw - 1 ) + ox ;
        py = py * ch * csgc + oy ;
        
        if ( !can->getDrawAll() )
           {
           if ( py + ch < ya ) continue ;
           if ( py > yb ) break ;
           if ( cih )
              {
              if ( px + cw < xa ) continue ;
              if ( px > xb ) continue ;
              }    
           }    

       int pm = getMark ( a ) ;
       if ( pm == 1 ) // Marked (light gray background)
          {
          dc.SetBackgroundMode ( wxSOLID ) ;
          dc.SetTextBackground ( *wxLIGHT_GREY ) ;
          dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ;
          }
       else if ( pm == 2 && can->doOverwrite() ) // Overwrite cursor
          {
          dc.SetBackgroundMode ( wxSOLID ) ;
          dc.SetTextBackground ( *wxBLACK ) ;
          }
       if ( pm == 2 && can->doOverwrite() ) dc.SetTextForeground ( *wxWHITE ) ;
       else dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ;
       if ( can->isPrinting() && pm == 1 )
          {
          dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ;
          dc.SetPen(*wxTRANSPARENT_PEN);
          dc.DrawRectangle ( px , py , cw , ch ) ;
          }
       if ( can->isPrinting() && !can->getPrintToColor() )
          {
          dc.SetBackgroundMode ( wxTRANSPARENT ) ;
          dc.SetTextForeground ( *wxBLACK ) ;
          }

		 // Show the char
		 wxChar ch2 = s.GetChar(a) ;
		 if ( ch2 == '|' ) ch2 = myapp()->frame->stopcodon ;
       dc.DrawText ( wxString ( ch2 ) , px , py ) ;
       
       int pz = py + ch ;

       if ( pm == 2 && !can->doOverwrite() ) // Insert cursor
          {
             dc.SetPen(*wxBLACK_PEN);
             dc.DrawLine ( px-1 , py , px-1 , pz ) ;
             dc.DrawLine ( px-3 , py , px+2 , py ) ;
             dc.DrawLine ( px-3 , pz , px+2 , pz ) ;
          }
       if ( pm > 0 ) // Reverting cursor settings
          {
          dc.SetBackgroundMode ( wxTRANSPARENT ) ;
          dc.SetTextForeground ( getHighlightColor ( a , tf ) ) ;
          }

       // Protease cuts
       for ( int q = 0 ; q < pc.GetCount() ; q++ )
          {
          if ( a == pc[q]->cut - pc[q]->left )
             {
             int qx = px ;
             int qy = py ;
             if ( !pc[q]->left ) qx += cw + 4 ;
             dc.SetTextForeground ( *wxBLACK ) ;
             dc.SetPen(*wxGREY_PEN);
             dc.DrawLine ( qx   , qy + 1 , qx   , qy + can->charheight - 2 ) ;
             dc.SetPen(*wxBLACK_PEN);
             dc.DrawLine ( qx+1 , qy + 1 , qx+1 , qy + can->charheight - 2 ) ;

             wxString pn = pc[q]->protease->name ;
             for ( int w = 0 ; w+1 < pn.length() ; w++ )
                if ( pn.GetChar(w) == ' ' && pn.GetChar(w+1) == '(' )
                   pn = pn.substr ( 0 , w ) ;
             dc.SetFont(*can->smallFont);
             int u1 , u2 ;
             dc.GetTextExtent ( pn , &u1 , &u2 ) ;
             dc.DrawText ( pn , qx - u1/2 , qy - u2/2 ) ;
             dc.SetFont(*can->font);
             
             if ( primaryMode ) dc.SetTextForeground ( getHighlightColor ( a , *wxBLACK ) ) ;
             else dc.SetTextForeground ( myapp()->frame->aa_color /* *wxLIGHT_GREY */ ) ;
             }
          }

        if ( showNumber && primaryMode )
           {
           wxString t = wxString::Format ( _T("%d") , a + 1 ) ;
           while ( endnumberlength > t.length() ) t = _T("0") + t ;
//           t.Pad ( endnumberlength - t.length() , '0' , false ) ;
           dc.DrawText ( t , bo , py ) ;
           }    
        }    


    dc.SetBackgroundMode ( bm ) ;
    dc.SetTextBackground ( tbg ) ;
    dc.SetTextForeground ( tfg ) ;
    }
コード例 #6
0
ファイル: toggle.cpp プロジェクト: AsherBond/MondocosmOS
void wxCustomButton::Paint( wxDC &dc )
{
    dc.BeginDrawing();

    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);
    dc.EndDrawing();
}
コード例 #7
0
ファイル: htmlcell.cpp プロジェクト: gitrider/wxsj2
void wxHtmlWordCell::Draw(wxDC& dc, int x, int y,
                          int WXUNUSED(view_y1), int WXUNUSED(view_y2),
                          wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxBLACK_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width /* VZ: +1? */ ,m_Height);
#endif

    bool drawSelectionAfterCell = false;

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

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

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

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

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

        SwitchSelState(dc, info, true);

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

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

    // NB: If the text is justified then there is usually some free space
    //     between adjacent cells and drawing the selection only onto cells
    //     would result in ugly unselected spaces. The code below detects
    //     this special case and renders the selection *outside* the sell,
    //     too.
    if ( m_Parent->GetAlignHor() == wxHTML_ALIGN_JUSTIFY &&
            drawSelectionAfterCell )
    {
        wxHtmlCell *nextCell = m_Next;
        while ( nextCell && nextCell->IsFormattingCell() )
            nextCell = nextCell->GetNext();
        if ( nextCell )
        {
            int nextX = nextCell->GetPosX();
            if ( m_PosX + m_Width < nextX )
            {
                dc.SetBrush(dc.GetBackground());
                dc.SetPen(*wxTRANSPARENT_PEN);
                dc.DrawRectangle(x + m_PosX + m_Width, y + m_PosY,
                                 nextX - m_PosX - m_Width, m_Height);
            }
        }
    }
}
コード例 #8
0
ファイル: CtrlRegisterList.cpp プロジェクト: mziab/pcsx2
void CtrlRegisterList::render(wxDC& dc)
{
	wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console");
	dc.SetFont(font);
	
	// clear background
	wxColor white = wxColor(0xFFFFFFFF);

	dc.SetBrush(wxBrush(white));
	dc.SetPen(wxPen(white));

	wxSize size = GetSize();
	dc.DrawRectangle(0,0,size.x,size.y);

	refreshChangedRegs();

	wxColor colorChanged = wxColor(0xFF0000FF);
	wxColor colorUnchanged = wxColor(0xFF004000);
	wxColor colorNormal = wxColor(0xFF600000);

	// draw categories
	int piece = size.x/cpu->getRegisterCategoryCount();
	for (int i = 0; i < cpu->getRegisterCategoryCount(); i++)
	{
		const char* name = cpu->getRegisterCategoryName(i);

		int x = i*piece;

		if (i == category)
		{
			dc.SetBrush(wxBrush(wxColor(0xFF70FF70)));
			dc.SetPen(wxPen(wxColor(0xFF000000)));
		} else {
			dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8)));
			dc.SetPen(wxPen(wxColor(0xFF000000)));
		}
		
		dc.DrawRectangle(x-1,-1,piece+1,rowHeight+1);

		// center text
		x += (piece-strlen(name)*charWidth)/2;
		dc.DrawText(wxString(name,wxConvUTF8),x,1);
	}

	int nameStart = 17;
	int valueStart = startPositions[category];

	ChangedReg* changedRegs = changedCategories[category];
	int registerBits = cpu->getRegisterSize(category);
	DebugInterface::RegisterType type = cpu->getRegisterType(category);

	for (int i = 0; i < cpu->getRegisterCount(category); i++)
	{
		int x = valueStart;
		int y = rowHeight*(i+1);

		if (currentRows[category] == i)
		{
			dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8)));
			dc.SetPen(wxPen(wxColor(0xFFFFEFE8)));
			dc.DrawRectangle(0,y,size.x,rowHeight);
		}

		const char* name = cpu->getRegisterName(category,i);
		dc.SetTextForeground(colorNormal);
		dc.DrawText(wxString(name,wxConvUTF8),nameStart,y+2);

		u128 value = cpu->getRegister(category,i);
		ChangedReg& changed = changedRegs[i];

		switch (type)
		{
		case DebugInterface::NORMAL:	// display them in 32 bit parts
			switch (registerBits)
			{
			case 128:
				{
					int startIndex = std::min<int>(3,maxBits/32-1);
					int actualX = size.x-4-(startIndex+1)*(8*charWidth+2);
					x = std::max<int>(actualX,x);

					if (startIndex != 3)
					{
						bool c = false;
						for (int i = 3; i > startIndex; i--)
							c = c || changed.changed[i];

						if (c)
						{
							dc.SetTextForeground(colorChanged);
							dc.DrawText(L"+",x-charWidth,y+2);
						}
					}

					for (int i = startIndex; i >= 0; i--)
					{
						if (changed.changed[i])
							dc.SetTextForeground(colorChanged);
						else
							dc.SetTextForeground(colorUnchanged);

						drawU32Text(dc,value._u32[i],x,y+2);
						x += charWidth*8+2;
					}
					break;
				}
			case 64:
				{
					if (maxBits < 64 && changed.changed[1])
					{
						dc.SetTextForeground(colorChanged);
						dc.DrawText(L"+",x-charWidth,y+2);
					}

					for (int i = 1; i >= 0; i--)
					{
						if (changed.changed[i])
							dc.SetTextForeground(colorChanged);
						else
							dc.SetTextForeground(colorUnchanged);

						drawU32Text(dc,value._u32[i],x,y+2);
						x += charWidth*8+2;
					}
					break;
				}
			case 32:
				{
					if (changed.changed[0])
						dc.SetTextForeground(colorChanged);
					else
						dc.SetTextForeground(colorUnchanged);

					drawU32Text(dc,value._u32[0],x,y+2);
					break;
				}
			}
			break;
		case DebugInterface::SPECIAL:		// let debug interface format them and just display them
			{
				if (changed.changed[0] || changed.changed[1] || changed.changed[2] || changed.changed[3])
					dc.SetTextForeground(colorChanged);
				else
					dc.SetTextForeground(colorUnchanged);

				dc.DrawText(cpu->getRegisterString(category,i),x,y+2);
				break;
			}
		}
	}
}
コード例 #9
0
ファイル: areadraw.cpp プロジェクト: IGNF/wxfreechart
void FillAreaDraw::Draw(wxDC &dc, wxRect rc)
{
	dc.SetPen(m_borderPen);
	dc.SetBrush(m_fillBrush);
	dc.DrawRectangle(rc);
}
コード例 #10
0
void wxSheetCellBoolRendererRefData::Draw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc, const wxRect& rect,
        const wxSheetCoords& coords,
        bool isSelected)
{
    wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect, coords, isSelected);

    // draw a check mark in the centre (ignoring alignment - TODO)
    wxSize size = GetBestSize(sheet, attr, dc, coords);

    // don't draw outside the cell
    wxCoord minSize = wxMin(rect.width, rect.height) - 1;
    if ((size.x >= minSize) || (size.y >= minSize))
        size.x = size.y = minSize - 2; // leave (at least) 1 pixel margin

    // draw a border around checkmark
    int align = attr.GetAlignment();

    wxRect rectBorder(rect.GetPosition(), size);

    if ((align & wxALIGN_RIGHT) != 0)
        rectBorder.x += rect.width - size.x - 2;
    else if ((align & wxALIGN_CENTRE_HORIZONTAL) != 0)
        rectBorder.x += rect.width/2 - size.x/2;
    else // wxALIGN_LEFT
        rectBorder.x += 2;

    if ((align & wxALIGN_BOTTOM) != 0)
        rectBorder.y += rect.height - size.y - 2;
    else if ((align & wxALIGN_CENTRE_VERTICAL) != 0)
        rectBorder.y += rect.height/2 - size.y/2;
    else // wxALIGN_TOP
        rectBorder.y += 2;

    bool value = false;
    if ( sheet.GetTable() && sheet.GetTable()->CanGetValueAs(coords, wxSHEET_VALUE_BOOL) )
        value = sheet.GetTable()->GetValueAsBool(coords);
    else
    {
        wxString strValue( sheet.GetCellValue(coords) );
        value = !( strValue.IsEmpty() || (strValue == wxT("0")) ||
                   (strValue.Lower() == wxT("f")) || (strValue.Lower() == wxT("false")));
    }

    if ( value )
    {
        wxRect rectMark = rectBorder;
#ifdef __WXMSW__
        // MSW DrawCheckMark() is weird (and should probably be changed...)
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN/2);
        rectMark.x++;
        rectMark.y++;
#else // !MSW
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN);
#endif // MSW/!MSW

        dc.SetTextForeground(attr.GetForegroundColour());
        dc.DrawCheckMark(rectMark);
    }

    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.SetPen(wxPen(attr.GetForegroundColour(), 1, wxSOLID));
    dc.DrawRectangle(rectBorder);
}
コード例 #11
0
ファイル: skinbrush.cpp プロジェクト: niterain/digsby
void SkinColor::Draw(wxDC& dc, const wxRect& rect, int n) {
    dc.SetBrush(brush);
    dc.SetPen(pen);
    dc.DrawRectangle(rect);
}
コード例 #12
0
ファイル: PlatWX.cpp プロジェクト: cubemoon/game-editor
void SurfaceImpl::BrushColour(ColourAllocated back) {
    hdc->SetBrush(wxBrush(wxColourFromCA(back), wxSOLID));
}
コード例 #13
0
ファイル: dockart.cpp プロジェクト: 252525fb/rpcs3
void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
{
#if defined(__WXMAC__)
    HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
    CGContextRef cgContext ;
#if wxMAC_USE_CORE_GRAPHICS
    cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext() ;
#else
    Rect bounds ;
    GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ;
    QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
    CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
    CGContextScaleCTM( cgContext , 1 , -1 ) ;

    if ( window )
    {
        wxPoint origin = window->GetClientAreaOrigin();
        int x, y;
        x = origin.x;
        y = origin.y;
        window->MacWindowToRootWindow( &x , &y );
        CGContextTranslateCTM( cgContext, x, y);
    }
#endif

    HIThemeSplitterDrawInfo drawInfo ;
    drawInfo.version = 0 ;
    drawInfo.state = kThemeStateActive ;
    drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
    HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;

#if wxMAC_USE_CORE_GRAPHICS
#else
    QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ;
#endif

#elif defined(__WXGTK__)
    // clear out the rectangle first
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

    GdkRectangle gdk_rect;
    if (orientation == wxVERTICAL )
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = m_sash_size;
        gdk_rect.height = rect.height;
    }
    else
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = rect.width;
        gdk_rect.height = m_sash_size;
    }

    if (!window) return;
    if (!window->m_wxwindow) return;
    if (!GTK_PIZZA(window->m_wxwindow)->bin_window) return;

    gtk_paint_handle
    (
        window->m_wxwindow->style,
        GTK_PIZZA(window->m_wxwindow)->bin_window,
        // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
        GTK_STATE_NORMAL,
        GTK_SHADOW_NONE,
        NULL /* no clipping */,
        window->m_wxwindow,
        "paned",
        rect.x,
        rect.y,
        rect.width,
        rect.height,
        (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
    );

#else
    wxUnusedVar(window);
    wxUnusedVar(orientation);
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}
コード例 #14
0
ファイル: shapes.cpp プロジェクト: d0k/malprogramm
void Circle::draw(wxDC& dc) const {
	dc.SetPen(*wxBLACK_PEN);
	dc.SetBrush(wxBrush(color));
	dc.DrawEllipse(left, top, width, height);
}
コード例 #15
0
ファイル: SAuiTabArt.cpp プロジェクト: SanyaWaffles/SLADE
void SAuiDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
	int button,
	int button_state,
	const wxRect& _rect,
	wxAuiPaneInfo& pane)
{
	wxBitmap bmp;
	if (!(&pane))
		return;
	switch (button)
	{
	default:
	case wxAUI_BUTTON_CLOSE:
		if (pane.state & wxAuiPaneInfo::optionActive)
			bmp = m_activeCloseBitmap;
		else
			bmp = m_inactiveCloseBitmap;
		break;
	case wxAUI_BUTTON_PIN:
		if (pane.state & wxAuiPaneInfo::optionActive)
			bmp = m_activePinBitmap;
		else
			bmp = m_inactivePinBitmap;
		break;
	case wxAUI_BUTTON_MAXIMIZE_RESTORE:
		if (pane.IsMaximized())
		{
			if (pane.state & wxAuiPaneInfo::optionActive)
				bmp = m_activeRestoreBitmap;
			else
				bmp = m_inactiveRestoreBitmap;
		}
		else
		{
			if (pane.state & wxAuiPaneInfo::optionActive)
				bmp = m_activeMaximizeBitmap;
			else
				bmp = m_inactiveMaximizeBitmap;
		}
		break;
	}


	wxRect rect = _rect;

	int old_y = rect.y;
	rect.y = rect.y + (rect.height / 2) - (bmp.GetHeight() / 2) + 1;
	rect.height = old_y + rect.height - rect.y - 1;
	//rect.y--;


	if (button_state == wxAUI_BUTTON_STATE_PRESSED)
	{
		rect.x++;
		rect.y++;
	}

	if (button_state == wxAUI_BUTTON_STATE_HOVER ||
		button_state == wxAUI_BUTTON_STATE_PRESSED)
	{
		/*if (pane.state & wxAuiPaneInfo::optionActive)
		{
			dc.SetBrush(wxBrush(m_activeCaptionColour.ChangeLightness(120)));
			dc.SetPen(wxPen(m_activeCaptionColour.ChangeLightness(70)));
		}
		else
		{
			dc.SetBrush(wxBrush(m_inactiveCaptionColour.ChangeLightness(120)));
			dc.SetPen(wxPen(m_inactiveCaptionColour.ChangeLightness(70)));
		}*/

		//dc.SetBrush(wxBrush(captionAccentColour));
		//dc.SetPen(wxPen(m_inactiveCaptionColour.ChangeLightness(70)));

		// draw the background behind the button
		//dc.DrawRectangle(rect.x, rect.y, 15, 15);

		dc.SetPen(wxPen(Drawing::darkColour(Drawing::getPanelBGColour(), 2.0f)));
		dc.SetBrush(wxBrush(Drawing::lightColour(Drawing::getPanelBGColour(), 1.0f)));
		dc.DrawRectangle(rect.x, rect.y, rect.width + 1, rect.width + 1);

		bmp = m_activeCloseBitmap;
		//dc.DrawBitmap(bmp, rect.x + 1, rect.y, true);
		//dc.DrawBitmap(bmp, rect.x - 1, rect.y, true);
		//dc.DrawBitmap(bmp, rect.x, rect.y, true);
	}


	// draw the button itself
	dc.DrawBitmap(bmp, rect.x, rect.y, true);
}
コード例 #16
0
ファイル: dockart.cpp プロジェクト: jonntd/dynamica
void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
{
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
    wxUnusedVar(window);
    wxUnusedVar(orientation);

    HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
    CGContextRef cgContext ;
    wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
    cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;

    HIThemeSplitterDrawInfo drawInfo ;
    drawInfo.version = 0 ;
    drawInfo.state = kThemeStateActive ;
    drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
    HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;

#elif defined(__WXGTK__)
    // clear out the rectangle first
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

#if 0
    GdkRectangle gdk_rect;
    if (orientation == wxVERTICAL )
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = m_sash_size;
        gdk_rect.height = rect.height;
    }
    else
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = rect.width;
        gdk_rect.height = m_sash_size;
    }
#endif

    if (!window) return;
    if (!window->m_wxwindow) return;
    if (!GTK_WIDGET_DRAWABLE(window->m_wxwindow)) return;

    gtk_paint_handle
    (
        window->m_wxwindow->style,
        window->GTKGetDrawingWindow(),
        // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
        GTK_STATE_NORMAL,
        GTK_SHADOW_NONE,
        NULL /* no clipping */,
        window->m_wxwindow,
        "paned",
        rect.x,
        rect.y,
        rect.width,
        rect.height,
        (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
    );

#else
    wxUnusedVar(window);
    wxUnusedVar(orientation);
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sash_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}
コード例 #17
0
ファイル: sashwin.cpp プロジェクト: gitrider/wxsj2
// Draw the sash
void wxSashWindow::DrawSash(wxSashEdgePosition edge, wxDC& dc)
{
    int w, h;
    GetClientSize(&w, &h);

    wxPen facePen(m_faceColour, 1, wxSOLID);
    wxBrush faceBrush(m_faceColour, wxSOLID);
    wxPen mediumShadowPen(m_mediumShadowColour, 1, wxSOLID);
    wxPen darkShadowPen(m_darkShadowColour, 1, wxSOLID);
    wxPen lightShadowPen(m_lightShadowColour, 1, wxSOLID);
    wxPen hilightPen(m_hilightColour, 1, wxSOLID);
    wxColour blackClr(0, 0, 0);
    wxColour whiteClr(255, 255, 255);
    wxPen blackPen(blackClr, 1, wxSOLID);
    wxPen whitePen(whiteClr, 1, wxSOLID);

    if ( edge == wxSASH_LEFT || edge == wxSASH_RIGHT )
    {
        int sashPosition = (edge == wxSASH_LEFT) ? 0 : ( w - GetEdgeMargin(edge) );

        dc.SetPen(facePen);
        dc.SetBrush(faceBrush);
        dc.DrawRectangle(sashPosition, 0, GetEdgeMargin(edge), h);

        if (GetWindowStyleFlag() & wxSW_3DSASH)
        {
            if (edge == wxSASH_LEFT)
            {
                // Draw a dark grey line on the left to indicate that the
                // sash is raised
                dc.SetPen(mediumShadowPen);
                dc.DrawLine(GetEdgeMargin(edge), 0, GetEdgeMargin(edge), h);
            }
            else
            {
                // Draw a highlight line on the right to indicate that the
                // sash is raised
                dc.SetPen(hilightPen);
                dc.DrawLine(w - GetEdgeMargin(edge), 0, w - GetEdgeMargin(edge), h);
            }
        }
    }
    else // top or bottom
    {
        int sashPosition = (edge == wxSASH_TOP) ? 0 : ( h - GetEdgeMargin(edge) );

        dc.SetPen(facePen);
        dc.SetBrush(faceBrush);
        dc.DrawRectangle(0, sashPosition, w, GetEdgeMargin(edge));

        if (GetWindowStyleFlag() & wxSW_3DSASH)
        {
            if (edge == wxSASH_BOTTOM)
            {
                // Draw a highlight line on the bottom to indicate that the
                // sash is raised
                dc.SetPen(hilightPen);
                dc.DrawLine(0, h - GetEdgeMargin(edge), w, h - GetEdgeMargin(edge));
            }
            else
            {
                // Draw a drak grey line on the top to indicate that the
                // sash is raised
                dc.SetPen(mediumShadowPen);
                dc.DrawLine(1, GetEdgeMargin(edge), w-1, GetEdgeMargin(edge));
            }
        }
    }

    dc.SetPen(wxNullPen);
    dc.SetBrush(wxNullBrush);
}
コード例 #18
0
ファイル: dockart.cpp プロジェクト: jonntd/dynamica
void wxAuiDefaultDockArt::DrawPaneButton(wxDC& dc, wxWindow *WXUNUSED(window),
                                      int button,
                                      int button_state,
                                      const wxRect& _rect,
                                      wxAuiPaneInfo& pane)
{
    wxBitmap bmp;
    if (!(&pane))
        return;
    switch (button)
    {
        default:
        case wxAUI_BUTTON_CLOSE:
            if (pane.state & wxAuiPaneInfo::optionActive)
                bmp = m_active_close_bitmap;
            else
                bmp = m_inactive_close_bitmap;
            break;
        case wxAUI_BUTTON_PIN:
            if (pane.state & wxAuiPaneInfo::optionActive)
                bmp = m_active_pin_bitmap;
            else
                bmp = m_inactive_pin_bitmap;
            break;
        case wxAUI_BUTTON_MAXIMIZE_RESTORE:
            if (pane.IsMaximized())
            {
                if (pane.state & wxAuiPaneInfo::optionActive)
                    bmp = m_active_restore_bitmap;
                else
                    bmp = m_inactive_restore_bitmap;
            }
            else
            {
                if (pane.state & wxAuiPaneInfo::optionActive)
                    bmp = m_active_maximize_bitmap;
                else
                    bmp = m_inactive_maximize_bitmap;
            }
            break;
    }


    wxRect rect = _rect;

    int old_y = rect.y;
    rect.y = rect.y + (rect.height/2) - (bmp.GetHeight()/2);
    rect.height = old_y + rect.height - rect.y - 1;


    if (button_state == wxAUI_BUTTON_STATE_PRESSED)
    {
        rect.x++;
        rect.y++;
    }

    if (button_state == wxAUI_BUTTON_STATE_HOVER ||
        button_state == wxAUI_BUTTON_STATE_PRESSED)
    {
        if (pane.state & wxAuiPaneInfo::optionActive)
        {
            dc.SetBrush(wxBrush(wxAuiStepColour(m_active_caption_colour, 120)));
            dc.SetPen(wxPen(wxAuiStepColour(m_active_caption_colour, 70)));
        }
        else
        {
            dc.SetBrush(wxBrush(wxAuiStepColour(m_inactive_caption_colour, 120)));
            dc.SetPen(wxPen(wxAuiStepColour(m_inactive_caption_colour, 70)));
        }

        // draw the background behind the button
        dc.DrawRectangle(rect.x, rect.y, 15, 15);
    }


    // draw the button itself
    dc.DrawBitmap(bmp, rect.x, rect.y, true);
}
コード例 #19
0
void uddCellItem::DrawNormal(wxDC& dc)
{
	// jestliže se vykreslují všechny okraje
	if( m_nBorderSides == bsAll )
	{
		dc.SetPen(m_Border);	// nastavit pero
		dc.SetBrush(m_Fill);	// nastavit štětec
		dc.DrawRectangle( 		// vykreslit obdélník
		   Conv2Point(GetAbsolutePosition()), Conv2Size(m_nRectSize) );
	}
	// jinak se nevykreslují všechny okraje (vykreslují se postupně)
	else
	{
		// vytvořit kopii pera okraje (kvůli zachování vlastností - šířky hlavně)
		wxPen rectanglePen( m_Border );
		// nastavit kopii barvu štětce
		// jestliže je transparentní
		if( m_Fill.IsTransparent() ) 
			// nastavit styl průhlednosti kopii pera
			rectanglePen.SetStyle( wxPENSTYLE_TRANSPARENT );
		// jinak
		else
			// nastavit kopii pera 
			rectanglePen.SetStyle( wxPENSTYLE_SOLID );
			rectanglePen.SetColour( m_Fill.GetColour() );
		// nastavit pero a štětec pro vykreslení obdélníku (podkladu)
		dc.SetPen( rectanglePen );	
		dc.SetBrush( m_Fill );
		
		// vykreslit obdélník
		dc.DrawRectangle(
		   Conv2Point(GetAbsolutePosition()), Conv2Size(m_nRectSize) );
		// nastavit původní pero pro okraj
		dc.SetPen( m_Border );
		
		// získat šířku okraje do pomocné proměnné
		int borderThickness = m_Border.GetWidth();
		
		// vykreslit zvolené okraje
		if( ContainsSide( bsLeft ) ) {
			wxPoint startPoint = Conv2Point(GetAbsolutePosition());
			startPoint.x -= borderThickness / 2;
			wxPoint endPoint( startPoint );
			endPoint.y += m_nRectSize.y;
			dc.DrawLine( startPoint, endPoint );
		}
		if( ContainsSide( bsTop ) ) {
			wxPoint startPoint = Conv2Point(GetAbsolutePosition());
			startPoint.y -= borderThickness / 2;
			wxPoint endPoint( startPoint );
			endPoint.x += m_nRectSize.x;
			dc.DrawLine( startPoint, endPoint );
		}
		if( ContainsSide( bsRight ) ) {
			wxPoint startPoint = Conv2Point(GetAbsolutePosition());
			startPoint.x += m_nRectSize.x - 1 - borderThickness / 2; // !!!
			wxPoint endPoint( startPoint );
			endPoint.y += m_nRectSize.y;
			dc.DrawLine( startPoint, endPoint );
		}
		if( ContainsSide( bsBottom ) ) {
			wxPoint startPoint = Conv2Point(GetAbsolutePosition());
			startPoint.y += m_nRectSize.y - 1 - borderThickness / 2; // !!!
			wxPoint endPoint( startPoint );
			endPoint.x += m_nRectSize.x;
			dc.DrawLine( startPoint, endPoint );
		}
	}
	// vyresetovat pero i štětec
	dc.SetBrush(wxNullBrush);
	dc.SetPen(wxNullPen);
	
	// vykreslit text
	DrawTextContent(dc);
}
コード例 #20
0
ファイル: instancectrl.cpp プロジェクト: Glought/MultiMC4
/// Draw the item
bool InstanceVisual::Draw(wxDC& dc, InstanceCtrl* ctrl, const wxRect& rect, int style)
{
	wxColour backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
	wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
	wxColour highlightTextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
	wxColour focus_color = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
	wxColour focussedSelection = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
	
	wxRect imageRect(rect.x + (rect.width - 32) / 2, rect.y, 32, 32);
	
	if (style & wxINST_SELECTED)
	{
		wxBrush brush(focus_color);
		wxPen pen(focus_color);
		dc.SetBrush(brush);
		dc.SetPen(pen);
	}
	else
	{
		wxBrush brush(backgroundColor);
		wxPen pen(backgroundColor);
		dc.SetBrush(brush);
		dc.SetPen(pen);
	}
	
	// Draw the label
	wxString name = m_inst->GetName();
	if (!name.IsEmpty())
	{
		int margin = ctrl->GetItemMargin();
		
		wxRect textRect;
		textRect.x = rect.x + margin;
		textRect.y = rect.y + imageRect.height + 2 * margin;
		textRect.width = rect.width - 2 * margin;
		
		dc.SetFont(ctrl->GetFont());
		if (style & wxINST_SELECTED)
			dc.SetTextForeground(highlightTextColor);
		else
			dc.SetTextForeground(textColor);
		dc.SetBackgroundMode(wxTRANSPARENT);
		
		int yoffset = 0;
		wxSize textsize = dc.GetMultiLineTextExtent(name_wrapped);
		textRect.height = textsize.GetHeight();
		if (style & wxINST_SELECTED)
		{
			wxRect hiRect;
			hiRect.x = rect.x + (rect.width - textsize.x) / 2 - margin;
			hiRect.y = textRect.y - margin;
			hiRect.SetSize(textsize + wxSize(2 * margin, 2 * margin));
			dc.DrawRectangle(hiRect);
		}
		dc.DrawLabel(name_wrapped, textRect, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL);
	}
	
	// Draw the icon
	auto list = InstIconList::Instance();
	wxImage icon;
	if (style & wxINST_SELECTED)
		icon = list->getHLImageForKey(m_inst->GetIconKey());
	else
		icon = list->getImageForKey(m_inst->GetIconKey());
	wxBitmap bmap = wxBitmap(icon);
	int x = imageRect.x + (imageRect.width - bmap.GetWidth()) / 2;
	int y = imageRect.y + (imageRect.height - bmap.GetHeight()) / 2;
	dc.DrawBitmap(bmap , x, y, true);
	
	return true;
}
コード例 #21
0
ファイル: htmlcell.cpp プロジェクト: gitrider/wxsj2
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
                               wxHtmlRenderingInfo& info)
{
#if 0 // useful for debugging
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(x+m_PosX,y+m_PosY,m_Width,m_Height);
#endif

    int xlocal = x + m_PosX;
    int ylocal = y + m_PosY;

    if (m_UseBkColour)
    {
        wxBrush myb = wxBrush(m_BkColour, wxSOLID);

        int real_y1 = mMax(ylocal, view_y1);
        int real_y2 = mMin(ylocal + m_Height - 1, view_y2);

        dc.SetBrush(myb);
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.DrawRectangle(xlocal, real_y1, m_Width, real_y2 - real_y1 + 1);
    }

    if (m_UseBorder)
    {
        wxPen mypen1(m_BorderColour1, 1, wxSOLID);
        wxPen mypen2(m_BorderColour2, 1, wxSOLID);

        dc.SetPen(mypen1);
        dc.DrawLine(xlocal, ylocal, xlocal, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal, xlocal + m_Width, ylocal);
        dc.SetPen(mypen2);
        dc.DrawLine(xlocal + m_Width - 1, ylocal, xlocal +  m_Width - 1, ylocal + m_Height - 1);
        dc.DrawLine(xlocal, ylocal + m_Height - 1, xlocal + m_Width, ylocal + m_Height - 1);
    }

    if (m_Cells)
    {
        // draw container's contents:
        for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext())
        {

            // optimize drawing: don't render off-screen content:
            if ((ylocal + cell->GetPosY() <= view_y2) &&
                    (ylocal + cell->GetPosY() + cell->GetHeight() > view_y1))
            {
                // the cell is visible, draw it:
                UpdateRenderingStatePre(info, cell);
                cell->Draw(dc,
                           xlocal, ylocal, view_y1, view_y2,
                           info);
                UpdateRenderingStatePost(info, cell);
            }
            else
            {
                // the cell is off-screen, proceed with font+color+etc.
                // changes only:
                cell->DrawInvisible(dc, xlocal, ylocal, info);
            }
        }
    }
}
コード例 #22
0
void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd,
                            const wxAuiNotebookPage& page,
                            const wxRect& in_rect, int close_button_state,
                            wxRect* out_tab_rect, wxRect* out_button_rect,
                            int* x_extent)
{
    // Visual studio 7.1 style
    // This code is based on the renderer included in wxFlatNotebook:
    // http://svn.berlios.de/wsvn/codeblocks/trunk/src/sdk/wxFlatNotebook/src/wxFlatNotebook/renderer.cpp?rev=5106

    // figure out the size of the tab

    wxSize tab_size = GetTabSize(dc,
                                 wnd,
                                 page.caption,
                                 page.bitmap,
                                 page.active,
                                 close_button_state,
                                 x_extent);

#if wxCHECK_VERSION(2, 9, 3)
    wxCoord tab_height = m_tabCtrlHeight - 3;
#else
    wxCoord tab_height = m_tab_ctrl_height - 3;
#endif
    wxCoord tab_width = tab_size.x;
    wxCoord tab_x = in_rect.x;
    wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
    int clip_width = tab_width;
    if (tab_x + clip_width > in_rect.x + in_rect.width - 4)
        clip_width = (in_rect.x + in_rect.width) - tab_x - 4;
    dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);
    if(m_flags & wxAUI_NB_BOTTOM)
        tab_y--;

    dc.SetPen((page.active) ? wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT)) : wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
    dc.SetBrush((page.active) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(*wxTRANSPARENT_BRUSH));

    if (page.active)
    {
//        int tabH = (m_flags & wxAUI_NB_BOTTOM) ? tab_height - 5 : tab_height - 2;
        int tabH = tab_height - 2;

        dc.DrawRectangle(tab_x, tab_y, tab_width, tabH);

        int rightLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding - 2 : c_vertical_border_padding - 1;
        int rightLineY2 = tabH + 3;
        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
        dc.DrawLine(tab_x + tab_width - 1, rightLineY1 + 1, tab_x + tab_width - 1, rightLineY2);
        if(m_flags & wxAUI_NB_BOTTOM)
            dc.DrawLine(tab_x + 1, rightLineY2 - 3 , tab_x + tab_width - 1, rightLineY2 - 3);
        dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)));
        dc.DrawLine(tab_x + tab_width , rightLineY1 , tab_x + tab_width, rightLineY2);
        if(m_flags & wxAUI_NB_BOTTOM)
            dc.DrawLine(tab_x , rightLineY2 - 2 , tab_x + tab_width, rightLineY2 - 2);

    }
    else
    {
        // We dont draw a rectangle for non selected tabs, but only
        // vertical line on the right
        int blackLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding + 2 : c_vertical_border_padding + 1;
        int blackLineY2 = tab_height - 5;
        dc.DrawLine(tab_x + tab_width, blackLineY1, tab_x + tab_width, blackLineY2);
    }

    wxPoint border_points[2];
    if (m_flags & wxAUI_NB_BOTTOM)
    {
        border_points[0] = wxPoint(tab_x, tab_y);
        border_points[1] = wxPoint(tab_x, tab_y + tab_height - 6);
    }
    else // if (m_flags & wxAUI_NB_TOP)
    {
        border_points[0] = wxPoint(tab_x, tab_y + tab_height - 4);
        border_points[1] = wxPoint(tab_x, tab_y + 2);
    }

    int drawn_tab_yoff = border_points[1].y;
    int drawn_tab_height = border_points[0].y - border_points[1].y;

    int text_offset = tab_x + 8;

    int bitmap_offset = 0;
    if (page.bitmap.IsOk())
    {
        bitmap_offset = tab_x + 8;

        // draw bitmap
        dc.DrawBitmap(page.bitmap,
                      bitmap_offset,
                      drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
                      true);

        text_offset = bitmap_offset + page.bitmap.GetWidth();
        text_offset += 3; // bitmap padding
    }
     else
    {
        text_offset = tab_x + 8;
    }


    // if the caption is empty, measure some temporary text
    wxString caption = page.caption;
    if (caption.empty())
        caption = wxT("Xj");

    wxCoord textx;
    wxCoord texty;
    if (page.active)
#if wxCHECK_VERSION(2, 9, 3)
        dc.SetFont(m_selectedFont);
#else
        dc.SetFont(m_selected_font);
#endif
    else
コード例 #23
0
void SeqPlot::show ( wxDC& dc )
    {
    if ( s.IsEmpty() ) return ;
    mylog ( "SeqPlot::show" , "1" ) ;
    dc.SetFont(*can->font);
    wxColour tbg = dc.GetTextBackground () ;
    wxColour tfg = dc.GetTextForeground () ;
    int bm = dc.GetBackgroundMode () ;
    int a , b , cnt = offset+1 ;
    wxString t ;
    char u[100] , valid[256] ;
    for ( a = 0 ; a < 256 ; a++ ) valid[a] = 0 ;
    valid['A'] = valid['C'] = valid['T'] = valid['G'] = valid[' '] = 1 ;
//    dc.SetTextBackground ( *wxWHITE ) ;
    dc.SetTextForeground ( fontColor ) ;
//    dc.SetBackgroundMode ( wxSOLID ) ;
    dc.SetBackgroundMode ( wxTRANSPARENT ) ;
    int xa , xb , ya , yb ;
    dc.GetDeviceOrigin ( &xa , &ya ) ;
    ya = -ya ;
    xa = -xa ;
    can->MyGetClientSize ( &xb , &yb ) ;
    yb += ya ;
    xb += xa ;
    int lx = 0 ;
    startOfLine = true ;
    mylog ( "SeqPlot::show" , "2" ) ;
    for ( a = 0 ; a < pos.p.GetCount() ; a++ )
        {
			mylog ( "SeqPlot::show" , "2a" ) ;
        if ( can->hardstop > -1 && a > can->hardstop ) break ;
			mylog ( "SeqPlot::show" , "2b" ) ;
        b = pos.p[a] ;
        int tx = pos.r[a].x , ty = pos.r[a].y ;
        int tz = ty + can->charheight * lines ;
        bool insight = true ; // Meaning "is this part visible"
        if ( tz < ya ) insight = false ;
        if ( ty > yb ) insight = false ;
        if ( tx + can->charwidth < xa ) insight = false ;
        if ( tx > xb ) insight = false ;
        if ( can->getDrawAll() ) insight = true ;
        if ( !insight && ty > yb ) a = pos.p.GetCount() ;
        if ( b > 0 && !insight ) cnt++ ;
			mylog ( "SeqPlot::show" , "2c" ) ;
        if ( b > 0 && insight ) // Character
           {
           if ( lx == 0 ) lx = tx ;
           t = s.GetChar(b-1) ;
           if ( can->isPrinting() )
	       {
		   if (getMark ( a ) == 1 )
			   {
		       dc.SetBrush ( *MYBRUSH ( wxColour ( 230 , 230 , 230 ) ) ) ;
		       dc.SetPen(*wxTRANSPARENT_PEN);
		       dc.DrawRectangle ( tx , ty , can->charwidth , can->charheight ) ;
			   }
			mylog ( "SeqPlot::show" , "2c1" ) ;
		   if ( !can->getPrintToColor() )
			   {
		       dc.SetBackgroundMode ( wxTRANSPARENT ) ;
		       dc.SetTextForeground ( *wxBLACK ) ;
			   }
	       }

			mylog ( "SeqPlot::show" , wxString::Format ( _T("2c2 (type %d)") , type ) ) ;
           switch ( type )
              {
              case CHOU_FASMAN : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
              case COILED_COIL : showChouFasman ( dc , b-1 , tx , ty , lx ) ; break ;
              case M_W : showMW ( dc , b-1 , tx , ty , lx ) ; break ;
              case P_I : showPI ( dc , b-1 , tx , ty , lx ) ; break ;
              case H_P : showHP ( dc , b-1 , tx , ty , lx ) ; break ;
              }
           lx = tx + can->charwidth ;
           cnt++ ;
           startOfLine = false ;
			mylog ( "SeqPlot::show" , "2c3" ) ;
           }
        else if ( insight ) // Front
           {           
			mylog ( "SeqPlot::show" , "2d1" ) ;
           lx = 0 ;
           startOfLine = true ;
           if ( !can->isMiniDisplay() ) continue ;
			mylog ( "SeqPlot::show" , "2d2" ) ;
           dc.SetFont(*can->smallFont);
           if ( type == CHOU_FASMAN ) t = _T("Chou-Fasman") ;
           if ( type == COILED_COIL ) t = _T("Coiled-coil") ;
           else if ( type == M_W ) t = _T("MW") ;
           else if ( type == P_I ) t = _T("pI") ;
           else if ( type == H_P )
              {
              t = _T("t_method_") ;
              t += hp_method ;
              t = txt(t) ;
              t += wxString::Format( _T(" [%d]") , hp_window ) ;
              }
			mylog ( "SeqPlot::show" , "2d3" ) ;
           dc.SetTextForeground ( *wxBLACK ) ;
           int tw , th ;
           dc.GetTextExtent ( t , &tw , &th ) ;
           int ty = pos.r[a].y ;
           ty += lines * can->charheight ;
			mylog ( "SeqPlot::show" , "2d4" ) ;
#ifdef __WXGTK__
	   ty += th / 2 ;
	   dc.DrawText ( t , pos.r[a].x , ty ) ;
#else
           ty -= ( lines * can->charheight - tw ) / 2 ;
           dc.DrawRotatedText ( t , pos.r[a].x, ty , 90 ) ;
#endif
           dc.SetFont(*can->font);
           }
			mylog ( "SeqPlot::show" , "2e" ) ;
        }
    mylog ( "SeqPlot::show" , "3" ) ;
    dc.SetBackgroundMode ( bm ) ;
    dc.SetTextBackground ( tbg ) ;
    dc.SetTextForeground ( tfg ) ;
    }
コード例 #24
0
void wxSwitcherItems::PaintItems(wxDC& dc, wxWindow* win)
{
    wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
    wxColour standardTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    wxColour selectionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
    wxColour selectionOutlineColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    wxColour selectionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
    wxFont standardFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxFont groupFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    groupFont.SetWeight(wxBOLD);

    if (GetBackgroundColour().Ok())
        backgroundColour = GetBackgroundColour();

    if (GetTextColour().Ok())
        standardTextColour = GetTextColour();

    if (GetSelectionColour().Ok())
        selectionColour = GetSelectionColour();

    if (GetSelectionOutlineColour().Ok())
        selectionOutlineColour = GetSelectionOutlineColour();

    if (GetSelectionTextColour().Ok())
        selectionTextColour = GetSelectionTextColour();

    if (GetItemFont().Ok())
    {
        standardFont = GetItemFont();
        groupFont = wxFont(standardFont.GetPointSize(), standardFont.GetFamily(), standardFont.GetStyle(),
            wxBOLD, standardFont.GetUnderlined(), standardFont.GetFaceName());
    }

    int textMarginX = wxSWITCHER_TEXT_MARGIN_X;

    dc.SetLogicalFunction(wxCOPY);
    dc.SetBrush(wxBrush(backgroundColour));
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.DrawRectangle(win->GetClientRect());
    dc.SetBackgroundMode(wxTRANSPARENT);

    size_t i;
    for (i = 0; i < m_items.GetCount(); i++)
    {
        wxSwitcherItem& item = m_items[i];
        bool selected = ((int) i == m_selection);

        if (selected)
        {
            dc.SetPen(wxPen(selectionOutlineColour));
            dc.SetBrush(wxBrush(selectionColour));
            dc.DrawRectangle(item.GetRect());
        }

        wxRect clippingRect(item.GetRect());
        clippingRect.Deflate(1, 1);

        dc.SetClippingRegion(clippingRect);

        if (selected)
            dc.SetTextForeground(selectionTextColour);
        else if (item.GetTextColour().Ok())
            dc.SetTextForeground(item.GetTextColour());
        else
            dc.SetTextForeground(standardTextColour);

        if (item.GetFont().Ok())
            dc.SetFont(item.GetFont());
        else
        {
            if (item.GetIsGroup())
                dc.SetFont(groupFont);
            else
                dc.SetFont(standardFont);
        }

        int w, h;
        dc.GetTextExtent(item.GetTitle(), & w, & h);

        int x = item.GetRect().x;

        x += textMarginX;

        if (!item.GetIsGroup())
        {
            if (item.GetBitmap().Ok() && item.GetBitmap().GetWidth() <= 16 && item.GetBitmap().GetHeight() <= 16)
            {
                dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + (item.GetRect().height - item.GetBitmap().GetHeight()) / 2, true);
            }

            x += 16;

            x += textMarginX;
        }

        int y = item.GetRect().y + (item.GetRect().height - h)/2;
        dc.DrawText(item.GetTitle(), x, y);

        dc.DestroyClippingRegion();
    }
}
コード例 #25
0
ファイル: tabart.cpp プロジェクト: avdbg/wxTest
void wxAuiGenericTabArt::DrawTab(wxDC& dc,
                                 wxWindow* wnd,
                                 const wxAuiNotebookPage& page,
                                 const wxRect& in_rect,
                                 int close_button_state,
                                 wxRect* out_tab_rect,
                                 wxRect* out_button_rect,
                                 int* x_extent)
{
    wxCoord normal_textx, normal_texty;
    wxCoord selected_textx, selected_texty;
    wxCoord texty;

    // if the caption is empty, measure some temporary text
    wxString caption = page.caption;
    if (caption.empty())
        caption = wxT("Xj");

    dc.SetFont(m_selectedFont);
    dc.GetTextExtent(caption, &selected_textx, &selected_texty);

    dc.SetFont(m_normalFont);
    dc.GetTextExtent(caption, &normal_textx, &normal_texty);

    // figure out the size of the tab
    wxSize tab_size = GetTabSize(dc,
                                 wnd,
                                 page.caption,
                                 page.bitmap,
                                 page.active,
                                 close_button_state,
                                 x_extent);

    wxCoord tab_height = m_tabCtrlHeight - 3;
    wxCoord tab_width = tab_size.x;
    wxCoord tab_x = in_rect.x;
    wxCoord tab_y = in_rect.y + in_rect.height - tab_height;


    caption = page.caption;


    // select pen, brush and font for the tab to be drawn

    if (page.active)
    {
        dc.SetFont(m_selectedFont);
        texty = selected_texty;
    }
    else
    {
        dc.SetFont(m_normalFont);
        texty = normal_texty;
    }


    // create points that will make the tab outline

    int clip_width = tab_width;
    if (tab_x + clip_width > in_rect.x + in_rect.width)
        clip_width = (in_rect.x + in_rect.width) - tab_x;

/*
    wxPoint clip_points[6];
    clip_points[0] = wxPoint(tab_x,              tab_y+tab_height-3);
    clip_points[1] = wxPoint(tab_x,              tab_y+2);
    clip_points[2] = wxPoint(tab_x+2,            tab_y);
    clip_points[3] = wxPoint(tab_x+clip_width-1, tab_y);
    clip_points[4] = wxPoint(tab_x+clip_width+1, tab_y+2);
    clip_points[5] = wxPoint(tab_x+clip_width+1, tab_y+tab_height-3);

    // FIXME: these ports don't provide wxRegion ctor from array of points
#if !defined(__WXDFB__) && !defined(__WXCOCOA__)
    // set the clipping region for the tab --
    wxRegion clipping_region(WXSIZEOF(clip_points), clip_points);
    dc.SetClippingRegion(clipping_region);
#endif // !wxDFB && !wxCocoa
*/
    // since the above code above doesn't play well with WXDFB or WXCOCOA,
    // we'll just use a rectangle for the clipping region for now --
    dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3);


    wxPoint border_points[6];
    if (m_flags &wxAUI_NB_BOTTOM)
    {
        border_points[0] = wxPoint(tab_x,             tab_y);
        border_points[1] = wxPoint(tab_x,             tab_y+tab_height-6);
        border_points[2] = wxPoint(tab_x+2,           tab_y+tab_height-4);
        border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4);
        border_points[4] = wxPoint(tab_x+tab_width,   tab_y+tab_height-6);
        border_points[5] = wxPoint(tab_x+tab_width,   tab_y);
    }
    else //if (m_flags & wxAUI_NB_TOP) {}
    {
        border_points[0] = wxPoint(tab_x,             tab_y+tab_height-4);
        border_points[1] = wxPoint(tab_x,             tab_y+2);
        border_points[2] = wxPoint(tab_x+2,           tab_y);
        border_points[3] = wxPoint(tab_x+tab_width-2, tab_y);
        border_points[4] = wxPoint(tab_x+tab_width,   tab_y+2);
        border_points[5] = wxPoint(tab_x+tab_width,   tab_y+tab_height-4);
    }
    // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
    // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}

    int drawn_tab_yoff = border_points[1].y;
    int drawn_tab_height = border_points[0].y - border_points[1].y;


    if (page.active)
    {
        // draw active tab

        // draw base background color
        wxRect r(tab_x, tab_y, tab_width, tab_height);
        dc.SetPen(wxPen(m_activeColour));
        dc.SetBrush(wxBrush(m_activeColour));
        dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4);

        // this white helps fill out the gradient at the top of the tab
        dc.SetPen(*wxWHITE_PEN);
        dc.SetBrush(*wxWHITE_BRUSH);
        dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4);

        // these two points help the rounded corners appear more antialiased
        dc.SetPen(wxPen(m_activeColour));
        dc.DrawPoint(r.x+2, r.y+1);
        dc.DrawPoint(r.x+r.width-2, r.y+1);

        // set rectangle down a bit for gradient drawing
        r.SetHeight(r.GetHeight()/2);
        r.x += 2;
        r.width -= 3;
        r.y += r.height;
        r.y -= 2;

        // draw gradient background
        wxColor top_color = *wxWHITE;
        wxColor bottom_color = m_activeColour;
        dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
    }
    else
    {
        // draw inactive tab

        wxRect r(tab_x, tab_y+1, tab_width, tab_height-3);

        // start the gradent up a bit and leave the inside border inset
        // by a pixel for a 3D look.  Only the top half of the inactive
        // tab will have a slight gradient
        r.x += 3;
        r.y++;
        r.width -= 4;
        r.height /= 2;
        r.height--;

        // -- draw top gradient fill for glossy look
        wxColor top_color = m_baseColour;
        wxColor bottom_color = top_color.ChangeLightness(160);
        dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);

        r.y += r.height;
        r.y--;

        // -- draw bottom fill for glossy look
        top_color = m_baseColour;
        bottom_color = m_baseColour;
        dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
    }

    // draw tab outline
    dc.SetPen(m_borderPen);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.DrawPolygon(WXSIZEOF(border_points), border_points);

    // there are two horizontal grey lines at the bottom of the tab control,
    // this gets rid of the top one of those lines in the tab control
    if (page.active)
    {
        if (m_flags &wxAUI_NB_BOTTOM)
            dc.SetPen(wxPen(m_baseColour.ChangeLightness(170)));
        // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
        // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
        else //for wxAUI_NB_TOP
            dc.SetPen(m_baseColourPen);
        dc.DrawLine(border_points[0].x+1,
                    border_points[0].y,
                    border_points[5].x,
                    border_points[5].y);
    }


    int text_offset = tab_x + 8;
    int close_button_width = 0;
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        close_button_width = m_activeCloseBmp.GetWidth();
    }

    int bitmap_offset = 0;
    if (page.bitmap.IsOk())
    {
        bitmap_offset = tab_x + 8;

        // draw bitmap
        dc.DrawBitmap(page.bitmap,
                      bitmap_offset,
                      drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
                      true);

        text_offset = bitmap_offset + page.bitmap.GetWidth();
        text_offset += 3; // bitmap padding

    }
    else
    {
        text_offset = tab_x + 8;
    }


    wxString draw_text = wxAuiChopText(dc,
                          caption,
                          tab_width - (text_offset-tab_x) - close_button_width);

    // draw tab text
    dc.DrawText(draw_text,
                text_offset,
                drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1);

    // draw focus rectangle
    if (page.active && (wnd->FindFocus() == wnd))
    {
        wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1),
            selected_textx, selected_texty);

        wxRect focusRect;
        wxRect focusRectBitmap;

        if (page.bitmap.IsOk())
            focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2),
                                            page.bitmap.GetWidth(), page.bitmap.GetHeight());

        if (page.bitmap.IsOk() && draw_text.IsEmpty())
            focusRect = focusRectBitmap;
        else if (!page.bitmap.IsOk() && !draw_text.IsEmpty())
            focusRect = focusRectText;
        else if (page.bitmap.IsOk() && !draw_text.IsEmpty())
            focusRect = focusRectText.Union(focusRectBitmap);

        focusRect.Inflate(2, 2);

        wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
    }

    // draw close button if necessary
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        wxBitmap bmp = m_disabledCloseBmp;

        if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
            close_button_state == wxAUI_BUTTON_STATE_PRESSED)
        {
            bmp = m_activeCloseBmp;
        }

        int offsetY = tab_y-1;
        if (m_flags & wxAUI_NB_BOTTOM)
            offsetY = 1;

        wxRect rect(tab_x + tab_width - close_button_width - 1,
                    offsetY + (tab_height/2) - (bmp.GetHeight()/2),
                    close_button_width,
                    tab_height);

        IndentPressedBitmap(&rect, close_button_state);
        dc.DrawBitmap(bmp, rect.x, rect.y, true);

        *out_button_rect = rect;
    }

    *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height);

    dc.DestroyClippingRegion();
}
コード例 #26
0
ファイル: SAuiTabArt.cpp プロジェクト: SanyaWaffles/SLADE
void SAuiTabArt::DrawTab(wxDC& dc,
	wxWindow* wnd,
	const wxAuiNotebookPage& page,
	const wxRect& in_rect,
	int close_button_state,
	wxRect* out_tab_rect,
	wxRect* out_button_rect,
	int* x_extent)
{
	wxCoord normal_textx, normal_texty;
	wxCoord selected_textx, selected_texty;
	wxCoord texty;

	// if the caption is empty, measure some temporary text
	wxString caption = page.caption;
	if (caption.empty())
		caption = wxT("Xj");

	dc.SetFont(m_selectedFont);
	dc.GetTextExtent(caption, &selected_textx, &selected_texty);

	dc.SetFont(m_normalFont);
	dc.GetTextExtent(caption, &normal_textx, &normal_texty);

	bool bluetab = false;
	if (page.window->GetName() == "startpage")
		bluetab = true;

	// figure out the size of the tab
	wxSize tab_size = GetTabSize(dc,
		wnd,
		page.caption,
		page.bitmap,
		page.active,
		close_button_state,
		x_extent);

	wxCoord tab_height = m_tabCtrlHeight + 2;// -1;// -3;
	wxCoord tab_width = tab_size.x;
	wxCoord tab_x = in_rect.x;
	wxCoord tab_y = in_rect.y + in_rect.height - tab_height + 3;


	if (!page.active)
	{
		tab_height -= 2;
		tab_y += 2;
	}

	caption = page.caption;


	// select pen, brush and font for the tab to be drawn
	if (page.active)
	{
		dc.SetFont(m_selectedFont);
		texty = selected_texty;
	}
	else
	{
		dc.SetFont(m_normalFont);
		texty = normal_texty;
	}


	// create points that will make the tab outline
	int clip_width = tab_width;
	if (tab_x + clip_width > in_rect.x + in_rect.width)
		clip_width = (in_rect.x + in_rect.width) - tab_x;
	dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3);

	wxPoint border_points[6];
	if (m_flags &wxAUI_NB_BOTTOM)
	{
		border_points[0] = wxPoint(tab_x, tab_y);
		border_points[1] = wxPoint(tab_x, tab_y + tab_height - 4);
		border_points[2] = wxPoint(tab_x, tab_y + tab_height - 4);
		border_points[3] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4);
		border_points[4] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4);
		border_points[5] = wxPoint(tab_x + tab_width, tab_y);
	}
	else
	{
		border_points[0] = wxPoint(tab_x, tab_y + tab_height - 4);
		border_points[1] = wxPoint(tab_x, tab_y);
		border_points[2] = wxPoint(tab_x + 2, tab_y);
		border_points[3] = wxPoint(tab_x + tab_width - 2, tab_y);
		border_points[4] = wxPoint(tab_x + tab_width, tab_y);
		border_points[5] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4);
	}

	int drawn_tab_yoff = border_points[1].y + 1;
	int drawn_tab_height = border_points[0].y - border_points[1].y;


	wxColour bgcol;
	if (page.active)
	{
		// draw active tab
		bgcol = m_activeColour;

		// draw base background color
		wxRect r(tab_x, tab_y, tab_width, tab_height);
		dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.SetBrush(wxBrush(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 5);

		// highlight top of tab
		wxColour col_hilight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
		dc.SetPen(*wxTRANSPARENT_PEN);// *wxWHITE_PEN);
		dc.SetBrush(wxBrush(col_hilight));// *wxWHITE_BRUSH);
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, 1);
	}
	else
	{
		bgcol = m_inactiveTabColour;

		wxRect r(tab_x, tab_y, tab_width, tab_height);
		wxPoint mouse = wnd->ScreenToClient(wxGetMousePosition());
		/*if (r.Contains(mouse))
		{
			dc.SetPen(wxPen(m_activeColour));
			dc.SetBrush(wxBrush(m_activeColour));
		}
		else
		{*/
			dc.SetPen(wxPen(m_inactiveTabColour));
			dc.SetBrush(wxBrush(m_inactiveTabColour));
		//}
		dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 4);
	}

	// draw tab outline
	dc.SetPen(m_borderPen);
	dc.SetBrush(*wxTRANSPARENT_BRUSH);
	dc.DrawPolygon(WXSIZEOF(border_points), border_points);

	// there are two horizontal grey lines at the bottom of the tab control,
	// this gets rid of the top one of those lines in the tab control
	if (page.active)
	{
		if (m_flags &wxAUI_NB_BOTTOM)
			dc.SetPen(wxPen(m_baseColour.ChangeLightness(170)));
		else
			dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour));
		dc.DrawLine(border_points[0].x + 1,
			border_points[0].y,
			border_points[5].x,
			border_points[5].y);
	}


	int text_offset = tab_x + 8;
	int close_button_width = 0;
	if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
	{
		close_button_width = m_activeCloseBmp.GetWidth();
	}

	int bitmap_offset = 0;
	if (page.bitmap.IsOk())
	{
		bitmap_offset = tab_x + 8;

		// draw bitmap
		dc.DrawBitmap(page.bitmap,
			bitmap_offset,
			drawn_tab_yoff + (drawn_tab_height / 2) - (page.bitmap.GetHeight() / 2),
			true);

		text_offset = bitmap_offset + page.bitmap.GetWidth();
		text_offset += 4; // bitmap padding

	}
	else
	{
		text_offset = tab_x + 8;
	}

	dc.SetTextForeground((page.active && bluetab) ? wxColor(0,0,0) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
	wxString draw_text = wxAuiChopText(dc,
		caption,
		tab_width - (text_offset - tab_x) - close_button_width);

	// draw tab text
	dc.DrawText(draw_text,
		text_offset,
		drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 0);

	// draw focus rectangle
	if (page.active && (wnd->FindFocus() == wnd))
	{
		wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 1),
			selected_textx, selected_texty);

		wxRect focusRect;
		wxRect focusRectBitmap;

		if (page.bitmap.IsOk())
			focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height / 2) - (page.bitmap.GetHeight() / 2),
				page.bitmap.GetWidth(), page.bitmap.GetHeight());

		if (page.bitmap.IsOk() && draw_text.IsEmpty())
			focusRect = focusRectBitmap;
		else if (!page.bitmap.IsOk() && !draw_text.IsEmpty())
			focusRect = focusRectText;
		else if (page.bitmap.IsOk() && !draw_text.IsEmpty())
			focusRect = focusRectText.Union(focusRectBitmap);

		focusRect.Inflate(2, 2);

		wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
	}

	// draw close button if necessary
	if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
	{
		wxBitmap bmp = m_disabledCloseBmp;

		int offsetY = tab_y;
		if (m_flags & wxAUI_NB_BOTTOM)
			offsetY = 1;

		wxRect rect(tab_x + tab_width - close_button_width - 3,
			offsetY + (tab_height / 2) - (bmp.GetHeight() / 2),
			close_button_width,
			tab_height);

		IndentPressedBitmap(&rect, close_button_state);

		if (close_button_state == wxAUI_BUTTON_STATE_HOVER ||
			close_button_state == wxAUI_BUTTON_STATE_PRESSED)
		{
			/*wxColour bcol = m_borderPen.GetColour();
			float r = ((float)bcol.Red() * 0.2f) + ((float)m_activeColour.Red() * 0.8f);
			float g = ((float)bcol.Green() * 0.2f) + ((float)m_activeColour.Green() * 0.8f);
			float b = ((float)bcol.Blue() * 0.2f) + ((float)m_activeColour.Blue() * 0.8f);*/
			//captionAccentColour = wxColor(r, g, b);

			//dc.SetPen(*wxTRANSPARENT_PEN);
			dc.SetPen(wxPen(Drawing::darkColour(bgcol, 2.0f)));
			dc.SetBrush(wxBrush(Drawing::lightColour(bgcol, 1.0f)));
			dc.DrawRectangle(rect.x, rect.y + 1, rect.width - 1, rect.width - 2);

			bmp = m_activeCloseBmp;
			//dc.DrawBitmap(bmp, rect.x + 1, rect.y, true);
			//dc.DrawBitmap(bmp, rect.x - 1, rect.y, true);
			dc.DrawBitmap(bmp, rect.x, rect.y, true);
		}
		else
		{
			bmp = m_disabledCloseBmp;
			dc.DrawBitmap(bmp, rect.x, rect.y, true);
		}

		*out_button_rect = rect;
	}

	*out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height);

	dc.DestroyClippingRegion();
}
コード例 #27
0
ファイル: combo.cpp プロジェクト: 0ryuO/dolphin-avsync
// draw focus background on area in a way typical on platform
void
wxComboCtrl::PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const
{
#if wxUSE_UXTHEME
    wxUxThemeHandle hTheme(this, L"COMBOBOX");
#endif

    wxSize sz = GetClientSize();
    bool isEnabled;
    bool doDrawFocusRect; // also selected

    // For smaller size control (and for disabled background) use less spacing
    int focusSpacingX;
    int focusSpacingY;

    if ( !(flags & wxCONTROL_ISSUBMENU) )
    {
        // Drawing control
        isEnabled = IsThisEnabled();
        doDrawFocusRect = ShouldDrawFocus();

#if wxUSE_UXTHEME
        // Windows-style: for smaller size control (and for disabled background) use less spacing
        if ( hTheme )
        {
            // WinXP  Theme
            focusSpacingX = isEnabled ? 2 : 1;
            focusSpacingY = sz.y > (GetCharHeight()+2) && isEnabled ? 2 : 1;
        }
        else
#endif
        {
            // Classic Theme
            if ( isEnabled )
            {
                focusSpacingX = 1;
                focusSpacingY = 1;
            }
            else
            {
                focusSpacingX = 0;
                focusSpacingY = 0;
            }
        }
    }
    else
    {
        // Drawing a list item
        isEnabled = true; // they are never disabled
        doDrawFocusRect = flags & wxCONTROL_SELECTED ? true : false;

        focusSpacingX = 0;
        focusSpacingY = 0;
    }

    // Set the background sub-rectangle for selection, disabled etc
    wxRect selRect(rect);
    selRect.y += focusSpacingY;
    selRect.height -= (focusSpacingY*2);

    int wcp = 0;

    if ( !(flags & wxCONTROL_ISSUBMENU) )
        wcp += m_widthCustomPaint;

    selRect.x += wcp + focusSpacingX;
    selRect.width -= wcp + (focusSpacingX*2);

    //wxUxThemeEngine* theme = NULL;
    //if ( hTheme )
    //    theme = wxUxThemeEngine::GetIfActive();

    wxColour fgCol;
    wxColour bgCol;
    bool doDrawDottedEdge = false;
    bool doDrawSelRect = true;

    // TODO: doDrawDottedEdge = true when focus has arrived to control via tab.
    //       (and other cases which are not that apparent).

    if ( isEnabled )
    {
        // If popup is hidden and this control is focused,
        // then draw the focus-indicator (selbgcolor background etc.).
        if ( doDrawFocusRect )
        {
            // NB: We can't really use XP visual styles to get TMT_TEXTCOLOR since
            //     it is not properly defined for combo boxes. Instead, they expect
            //     you to use DrawThemeText.
            //
            //    Here is, however, sample code how to get theme colours:
            //
            //    COLORREF cref;
            //    theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_NORMAL,TMT_TEXTCOLOR,&cref);
            //    dc.SetTextForeground( wxRGBToColour(cref) );
            if ( (m_iFlags & wxCC_FULL_BUTTON) && !(flags & wxCONTROL_ISSUBMENU) )
            {
                // Vista style read-only combo
                fgCol = GetForegroundColour();
                bgCol = GetBackgroundColour();
                doDrawSelRect = false;
                doDrawDottedEdge = true;
            }
            else
            {
                fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
                bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
            }
        }
        else
        {
            fgCol = GetForegroundColour();
            bgCol = GetBackgroundColour();
            doDrawSelRect = false;
        }
    }
    else
    {
        fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
        bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
    }

    dc.SetTextForeground(fgCol);
    dc.SetBrush(bgCol);
    if ( doDrawSelRect )
    {
        dc.SetPen(bgCol);
        dc.DrawRectangle(selRect);
    }

    if ( doDrawDottedEdge )
        wxMSWDrawFocusRect(dc, selRect);

    // Don't clip exactly to the selection rectangle so we can draw
    // to the non-selected area in front of it.
    wxRect clipRect(rect.x,rect.y,
                    (selRect.x+selRect.width)-rect.x-1,rect.height);
    dc.SetClippingRegion(clipRect);
}
コード例 #28
0
ファイル: SAuiTabArt.cpp プロジェクト: SanyaWaffles/SLADE
void SAuiDockArt::DrawCaption(wxDC& dc,
	wxWindow *window,
	const wxString& text,
	const wxRect& rect,
	wxAuiPaneInfo& pane)
{
	dc.SetPen(*wxTRANSPARENT_PEN);
	dc.SetFont(m_captionFont);

	dc.SetBrush(wxBrush(captionBackColour));
	dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

	//dc.SetPen(m_borderPen);
	//dc.SetBrush(wxBrush(Drawing::darkColour(captionBackColour, 2.0f)));
	//dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

	wxColor sepCol;
	int l = rgba_t(captionBackColour.Red(), captionBackColour.Green(), captionBackColour.Blue()).greyscale().r;
	if (l < 100)
		sepCol = Drawing::lightColour(captionBackColour, 2.0f);
	else
		sepCol = Drawing::darkColour(captionBackColour, 2.0f);

	//dc.SetPen(wxPen(sepCol));
	//dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1);

	dc.SetBrush(wxBrush(sepCol));
	dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height + 1);

	int caption_offset = 0;
	if (pane.icon.IsOk())
	{
		DrawIcon(dc, rect, pane);
		caption_offset += pane.icon.GetWidth() + 3;
	}

	dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));

	wxRect clip_rect = rect;
	clip_rect.width -= 3; // text offset
	clip_rect.width -= 2; // button padding
	if (pane.HasCloseButton())
		clip_rect.width -= m_buttonSize;
	if (pane.HasPinButton())
		clip_rect.width -= m_buttonSize;
	if (pane.HasMaximizeButton())
		clip_rect.width -= m_buttonSize;

	wxString draw_text = wxAuiChopText(dc, text, clip_rect.width);
	wxCoord w, h;
	dc.GetTextExtent(draw_text, &w, &h);

	dc.SetClippingRegion(clip_rect);
#ifdef __WXMSW__
	dc.DrawText(draw_text, rect.x + 5 + caption_offset, rect.y + (rect.height / 2) - (h / 2));
#else
	dc.DrawText(draw_text, rect.x + 5 + caption_offset, rect.y + (rect.height / 2) - (h / 2) + 1);
#endif

	//dc.SetPen(wxPen(captionAccentColour));
	//dc.DrawLine(rect.x + w + 8, rect.y + (rect.height / 2) - 1, rect.x + rect.width - 16, rect.y + (rect.height / 2) - 1);
	//dc.DrawLine(rect.x + w + 8, rect.y + (rect.height / 2) + 1, rect.x + rect.width - 16, rect.y + (rect.height / 2) + 1);

	dc.DestroyClippingRegion();
}
コード例 #29
0
ファイル: autoaxis.cpp プロジェクト: betrixed/AGW
void DataLayer::renderDC(wxDC& dc, PixelWorld& px)
{
    Series& xdata = *(xdata_);
    Series& ydata = *(ydata_);
    auto savepen = dc.GetPen();


    wxPen colpen(symbolBorder_);

    dc.SetPen(colpen);


    auto savefill = dc.GetBrush();
    wxBrush fill(symbolFill_);
    dc.SetBrush(fill);
    const double& xscale = px.xScale_.scale_;
    const double& yscale = px.yScale_.scale_;
    const double& xoffset = px.xScale_.offset_;
    const double& yoffset = px.yScale_.offset_;

    const int radius = (this->symbolSize_)*2 + 1;

    // draw lines first
    wxPenStyle linepen = indexToPenStyle(lineStyle_);

    wxRect clip(px.left_,px.top_, px.xspan_, px.yspan_);

    {


        if ((lineWidth_ > 0) && (linepen != wxPENSTYLE_TRANSPARENT))
        {
            wxPen linePen(lineColor_, lineWidth_, linepen);

            auto savePen = dc.GetPen();
            dc.SetPen(linePen);
            dc.SetClippingRegion(clip);

            int xprev = 0;
            int yprev = 0;
            for(size_t i = 0; i < xdata.size(); i++)
            {
                auto x = xdata[i];
                auto y = ydata[i];
                if (std::isnan(x) || std::isnan(y))
                    continue;
                auto xpt = (int)( (x-xoffset)* xscale ) + px.left_;
                auto ypt = (int)( (y-yoffset)* yscale ) + px.top_;

                if (i > 0)
                {
                    dc.DrawLine(xprev,yprev,xpt,ypt);
                }
                xprev = xpt;
                yprev = ypt;
            }

            dc.SetPen(savePen);
        }

        auto sdraw = SymbolDraw::MakeSymbolDraw((PlotShape)symbolShape_, radius, dc);
        wxPen sympen(this->symbolBorder_, 1, wxPENSTYLE_SOLID);

        dc.SetPen(sympen);
        dc.SetClippingRegion(clip);
        auto errors = errorbar_;
        for(size_t i = 0; i < xdata.size(); i++)
        {
            auto x = xdata[i];
            auto y = ydata[i];
            if (std::isnan(x) || std::isnan(y))
                continue;
            auto xpt = (int)( (x-xoffset)* xscale ) + px.left_;
            auto ypt = (int)( (y-yoffset)* yscale ) + px.top_;

            sdraw->draw(xpt,ypt);

            if (errors != nullptr)
            {
                auto errorSize = (*errors)[i];
                auto ept = (int)( errorSize*yscale);
                dc.DrawLine(xpt,ypt-ept,xpt,ypt+ept);
                dc.DrawLine(xpt-radius,ypt-ept,xpt+radius, ypt-ept);
                dc.DrawLine(xpt-radius,ypt+ept,xpt+radius, ypt+ept);
            }
        }
    }
    dc.SetBrush(savefill);
    dc.SetPen(savepen);
    dc.DestroyClippingRegion();
}
コード例 #30
0
void MyFrame::Draw(wxDC& dc)
{
    // This routine just draws a bunch of random stuff on the screen so that we
    // can check that different types of object are being drawn consistently
    // between the screen image, the print preview image (at various zoom
    // levels), and the printed page.
    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();
    dc.SetFont(wxGetApp().m_testFont);

    dc.SetBackgroundMode(wxTRANSPARENT);

    dc.SetPen(*wxBLACK_PEN);
    dc.SetBrush(*wxLIGHT_GREY_BRUSH);
//    dc.SetBackground(*wxWHITE_BRUSH);
    dc.DrawRectangle(0, 0, 230, 350);
    dc.DrawLine(0, 0, 229, 349);
    dc.DrawLine(229, 0, 0, 349);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);

    dc.SetBrush(*wxCYAN_BRUSH);
    dc.SetPen(*wxRED_PEN);

    dc.DrawRoundedRectangle(0, 20, 200, 80, 20);

    dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);

    dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) );
    dc.DrawEllipse(50, 140, 100, 50);
    dc.SetPen(*wxRED_PEN);

    dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
    
#if wxUSE_UNICODE
    //char *test = "Hebrew    שלום -- Japanese (日本語)";
    //wxString tmp = wxConvUTF8.cMB2WC( test );
    //dc.DrawText( tmp, 10, 200 );
#endif

    wxPoint points[5];
    points[0].x = 0;
    points[0].y = 0;
    points[1].x = 20;
    points[1].y = 0;
    points[2].x = 20;
    points[2].y = 20;
    points[3].x = 10;
    points[3].y = 20;
    points[4].x = 10;
    points[4].y = -20;
    dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE );
    dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE );

    dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );

    points[0].x = 150;
    points[0].y = 250;
    points[1].x = 180;
    points[1].y = 250;
    points[2].x = 180;
    points[2].y = 220;
    points[3].x = 200;
    points[3].y = 220;
    dc.DrawSpline( 4, points );

    dc.DrawArc( 20,10, 10,10, 25,40 );
        
    wxString str;
    int i = 0;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    i = m_angle;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    wxIcon my_icon = wxICON(mondrian) ;

    dc.DrawIcon( my_icon, 100, 100);

    if (m_bitmap.Ok())
    {
      dc.DrawBitmap(m_bitmap, 10, 25);
    }
    if (m_imgUp.Ok())
    {
      dc.DrawBitmap(m_imgUp, 300, 200);
      dc.DrawBitmap(m_imgUp, 300, 250, true);
    }
}