Example #1
0
bool OOPDesktopLyric::Present(wxDC &drawings) {
    HDC hdcScreen = ::GetDC(NULL);

    RECT rct;
    GetWindowRect(m_hWnd, &rct);

    POINT ptWinPos = { rct.left, rct.top };
    SIZE sizeWindow = { rct.right - rct.left, rct.bottom - rct.top };
    POINT ptSrc = { 0, 0 };

    BLENDFUNCTION blendFunc;
    // Initialize blend function
    blendFunc.BlendOp = 0; // the only BlendOp defined in Windows2000
    blendFunc.BlendFlags = 0; // nothing else is special...
    blendFunc.AlphaFormat = 1; // ...
    blendFunc.SourceConstantAlpha = m_style.alpha;

    BOOL bRet;
    bRet = UpdateLayeredWindow(m_hWnd, hdcScreen,
                              &ptWinPos, &sizeWindow,
                               drawings.GetHDC(),
                              &ptSrc,
                               0, &blendFunc, 2);

    ::ReleaseDC(NULL, hdcScreen);
    hdcScreen = NULL;

    return (bRet == TRUE);
}
Example #2
0
// For some reason, drawing a rectangle on a memory DC has problems.
// Use this substitute if we can.
static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
    wxBrush brush(dc.GetBrush());
    wxPen pen(dc.GetPen());
    if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT)
    {
        HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ;
        if (hBrush)
        {
            RECT rect;
            rect.left = x;
            rect.top = y;
            rect.right = x + width - 1;
            rect.bottom = y + height - 1;
            ::FillRect((HDC) dc.GetHDC(), &rect, hBrush);
        }
    }
    width --;
    height --;
    if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT)
    {
        dc.DrawLine(x, y, x + width, y);
        dc.DrawLine(x, y, x, y + height);
        dc.DrawLine(x, y+height, x+width, y + height);
        dc.DrawLine(x+width, y+height, x+width, y);
    }
}
Example #3
0
ClipRect::ClipRect(wxDC & canvas, const wxRect & rect)
    : dc_(canvas.GetHDC())
{
    const RECT temp = { rect.x, rect.y, rect.x + rect.width, rect.y + rect.height };
    rgn_ = CreateRectRgnIndirect(&temp);
    SelectClipRgn(static_cast<HDC>(dc_), static_cast<HRGN>(rgn_));
}
Example #4
0
void thBarViewCtrl::Mark(wxDC &dc, int bar)
{
    if (bar < 0)
        return;
    m_mark = bar;

    int bar_width, bar_left = GetBarArea(bar, bar_width);
    int bar_mid = bar_left + bar_width / 2;
    int bottom = m_rcBorder.y + m_rcBorder.height;

    dc.SetPen(GetBarPen(bar));
    dc.SetBrush(GetBarBrush(bar));

    wxPoint pts[3];
    pts[0] = wxPoint(-3, 3);
    pts[1] = wxPoint(0, 0);
    pts[2] = wxPoint(3, 3);
    dc.DrawPolygon(3, pts, bar_mid, bottom + 1);

    pts[0] = wxPoint(-3, -3);
    pts[2] = wxPoint(3, -3);
    dc.DrawPolygon(3, pts, bar_mid, m_rcBorder.y - 2);

    dc.SetPen(*wxTRANSPARENT_PEN);

    //! This looks bad with cross cursor.  But it's still useful.
    RECT rcInvert = {bar_left, m_rcBorder.y, bar_left + bar_width, bottom};
    InvertRect((HDC)dc.GetHDC(), &rcInvert);
}
Example #5
0
void MyDrawText(wxDC &dc, const wxString &s, wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
    #ifdef __WXMSW__   // this special purpose implementation is because the MSW implementation calls TextExtent, which costs 25% of all cpu time
        //wxMSWDCImpl *impl = (wxMSWDCImpl *)dc.GetImpl();
        //impl->DrawAnyText(s, x, y);   // protected, sigh
        dc.CalcBoundingBox(x, y);
        dc.CalcBoundingBox(x + w, y + h);

        HDC hdc = (HDC)dc.GetHDC();
        ::SetTextColor(hdc, dc.GetTextForeground().GetPixel());
        ::SetBkColor(hdc, dc.GetTextBackground().GetPixel());
        ::ExtTextOut(hdc, x, y, 0, NULL, s.c_str(), s.length(), NULL);
    #else
        dc.DrawText(s, x, y);
    #endif
}
Example #6
0
void wxPDFViewPage::DrawPrint(wxDC& dc, const wxRect& rect, bool forceBitmap)
{
	FPDF_PAGE page = GetPage();

	int renderFlags = FPDF_ANNOT | FPDF_PRINTING;
#ifdef wxPDFVIEW_USE_RENDER_TO_DC
	if (!forceBitmap)
	{
		FPDF_RenderPage(dc.GetHDC(), page, rect.x, rect.y, rect.width, rect.height, 0, renderFlags);
	} else
#endif
	{
		wxBitmap bmp = CreateBitmap(page, m_pages->form(), rect.GetSize(), renderFlags);
		dc.DrawBitmap(bmp, wxPoint(0, 0));
	}
}
Example #7
0
void tile(wxDC & canvas, long x, long y, long xs, long ys, void * src, long ix, long iy, long sx, long sy)
{
    if(sx <= 0 || sy <= 0)
        return;
    long bottom = y + ys;
    long right = x + xs;
    while(y < bottom)
    {
        long cy = std::min(bottom - y, sy);
        long px = x;
        while(px < right)
        {
            long cx = std::min(right - px, sx);
            BitBlt(static_cast<HDC>(canvas.GetHDC()), px, y, cx, cy, static_cast<HDC>(src), ix, iy, SRCCOPY);
            px += cx;
        }
        y += cy;
    }
}
Example #8
0
// helper for OnPaint(): really erase the background, i.e. do it even if we
// don't have any non default brush for doing it (DoEraseBackground() doesn't
// do anything in such case)
void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
{
    // note that we do not use the box background colour here, it shouldn't
    // apply to its interior for several reasons:
    //  1. wxGTK doesn't do it
    //  2. controls inside the box don't get correct bg colour because they
    //     are not our children so we'd have some really ugly colour mix if
    //     we did it
    //  3. this is backwards compatible behaviour and some people rely on it,
    //     see http://groups.google.com/groups?selm=4252E932.3080801%40able.es
    wxWindow *parent = GetParent();
    HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(dc.GetHDC(), GetHWND());

    // if there is no special brush for painting this control, just use the
    // solid background colour
    wxBrush brush;
    if ( !hbr )
    {
        brush = wxBrush(parent->GetBackgroundColour());
        hbr = GetHbrushOf(brush);
    }

    ::FillRect(GetHdcOf(dc), &rc, hbr);
}
Example #9
0
void wxRendererXP::DrawItemText(wxWindow* win,
                                wxDC& dc,
                                const wxString& text,
                                const wxRect& rect,
                                int align,
                                int flags,
                                wxEllipsizeMode ellipsizeMode)
{
    wxUxThemeHandle hTheme(win, L"LISTVIEW");

    const int itemState = GetListItemState(flags);

    wxUxThemeEngine* te = wxUxThemeEngine::Get();
    if ( te->DrawThemeTextEx && // Might be not available if we're under XP
            te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) )
    {
        RECT rc;
        wxCopyRectToRECT(rect, rc);

        DTTOPTS textOpts;
        textOpts.dwSize = sizeof(textOpts);
        textOpts.dwFlags = DTT_STATEID;
        textOpts.iStateId = itemState;
        if (flags & wxCONTROL_DISABLED)
        {
            textOpts.dwFlags |= DTT_TEXTCOLOR;
            textOpts.crText = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).GetPixel();
        }

        DWORD textFlags = DT_NOPREFIX;
        if ( align & wxALIGN_CENTER_HORIZONTAL )
            textFlags |= DT_CENTER;
        else if ( align & wxALIGN_RIGHT )
        {
            textFlags |= DT_RIGHT;
            rc.right--; // Alignment is inconsistent with DrawLabel otherwise
        }
        else
            textFlags |= DT_LEFT;

        if ( align & wxALIGN_BOTTOM )
            textFlags |= DT_BOTTOM;
        else if ( align & wxALIGN_CENTER_VERTICAL )
            textFlags |= DT_VCENTER;
        else
            textFlags |= DT_TOP;

        const wxString* drawText = &text;
        wxString ellipsizedText;
        switch ( ellipsizeMode )
        {
            case wxELLIPSIZE_NONE:
                // no flag required
                break;

            case wxELLIPSIZE_START:
            case wxELLIPSIZE_MIDDLE:
                // no native support for this ellipsize modes, use wxWidgets
                // implementation (may not be 100% accurate because per
                // definition the theme defines the font but should be close
                // enough with current windows themes)
                drawText = &ellipsizedText;
                ellipsizedText = wxControl::Ellipsize(text, dc, ellipsizeMode,
                                                      rect.width,
                                                      wxELLIPSIZE_FLAGS_NONE);
                break;

            case wxELLIPSIZE_END:
                textFlags |= DT_END_ELLIPSIS;
                break;
        }

        te->DrawThemeTextEx(hTheme, dc.GetHDC(), LVP_LISTITEM, itemState,
                            drawText->wchar_str(), -1, textFlags, &rc, &textOpts);
    }
    else
    {
        m_rendererNative.DrawItemText(win, dc, text, rect, align, flags, ellipsizeMode);
    }
}