Esempio n. 1
0
void wxWebView::OnPaint(wxPaintEvent& event)
{
    
    if (m_beingDestroyed || !m_mainFrame)
        return;
    
    WebCore::Frame* frame = m_mainFrame->GetFrame();
    if (!frame || !frame->view())
        return;
    
    wxAutoBufferedPaintDC dc(this);

    if (IsShown() && frame->document()) {
#if USE(WXGC)
        wxGCDC gcdc(dc);
#endif

        if (dc.IsOk()) {
            wxRect paintRect = GetUpdateRegion().GetBox();

            WebCore::IntSize offset = frame->view()->scrollOffset();
#if USE(WXGC)
            gcdc.SetDeviceOrigin(-offset.width(), -offset.height());
#endif
            dc.SetDeviceOrigin(-offset.width(), -offset.height());
            paintRect.Offset(offset.width(), offset.height());

#if USE(WXGC)
            WebCore::GraphicsContext* gc = new WebCore::GraphicsContext(&gcdc);
#else
            WebCore::GraphicsContext* gc = new WebCore::GraphicsContext((wxWindowDC*)&dc);
#endif
            if (gc && frame->contentRenderer()) {
                if (frame->view()->needsLayout())
                    frame->view()->layout();

                frame->view()->paintContents(gc, paintRect);
            }
            delete gc;
        }
    }
}
Esempio n. 2
0
void MorphanView::OnDraw(wxDC& dc)
{
    wxGraphicsContext* gc = wxGraphicsContext::Create(panel);
    if (!gc) return;

    wxGCDC gcdc(gc);

    wxPoint origin = dc.GetDeviceOrigin();
    gcdc.SetUserScale(zoom, zoom);
    gcdc.SetDeviceOrigin(origin.x, origin.y);

    if (show_grid)
        DrawGrid(gcdc);

    Morphan* morphan = GetDocument();
    if (!morphan) return;

    const MorphanKeyFrame& keyFrame = morphan->Get(current_frame);

    wxPen cpbox(*wxBLACK, 2);
    wxBrush cpfill(*wxWHITE);

    MorphanDrawContext context(gcdc, keyFrame.GetOpacity());
    for (const Primitive* p : keyFrame.GetPrimitives())
    {
        p->Draw(context);

        if (show_points)
        {
            gcdc.SetPen(cpbox);
            gcdc.SetBrush(cpfill);
            const std::vector<wxRealPoint> points = p->GetControlPoints();
            for (const auto& point : points)
                gcdc.DrawRectangle(point.x - 3, point.y - 3, 6, 6);
        }
    }

    if (in_window && (tool && tool->CanPreview()))
    {
        gcdc.SetPen(wxPen(wxColour(255, 0, 0, 255), outlineWidth));
        gcdc.SetBrush(*wxTRANSPARENT_BRUSH);
        tool->Preview(gcdc, mouse, wxGetKeyState(WXK_SHIFT));
    }

    if (in_window && (modifyTool && modifyTool->HasSelection()))
    {
        std::set<PrimitiveSelection> selection = modifyTool->PreviewModify(mouse);
        cpbox.SetColour(*wxRED);
        MorphanDrawContext context(gcdc, 1.0f);
        for (PrimitiveSelection ps : selection)
        {
            ps.primitive->SetOutline(*wxRED);
            ps.primitive->Draw(context);
            if (show_points)
            {
                gcdc.SetPen(cpbox);
                gcdc.SetBrush(cpfill);
                const std::vector<wxRealPoint> points = ps.primitive->GetControlPoints();
                for (const auto& point : points)
                    gcdc.DrawRectangle(point.x - 3, point.y - 3, 6, 6);
            }
            delete ps.primitive;
        }
    }
}