コード例 #1
0
ファイル: EditCtrl.cpp プロジェクト: kepazon/my_sumatrapdf
static LRESULT CALLBACK
EditProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
    EditCtrl *w = (EditCtrl *)dwRefData;
    CrashIf(w->hwnd != (HWND)lp);

    if (w->preFilter) {
        bool discard = false;
        auto res = w->preFilter(hwnd, msg, wp, lp, discard);
        if (discard) {
            return res;
        }
    }

    if (WM_NCDESTROY == msg) {
        RemoveWindowSubclass(GetParent(w->hwnd), EditParentProc, 0);
        RemoveWindowSubclass(w->hwnd, EditProc, 0);
        return DefSubclassProc(hwnd, msg, wp, lp);
    }

    // Node: this is sent during creation, which is too early for us (we didn't
    // subclass the window yet)
    // currently, we force it with SetWindowPos(... SMP_FRAMECHANGED)
    if (WM_NCCALCSIZE == msg) {
        NCCALCSIZE_PARAMS *p = (NCCALCSIZE_PARAMS *)lp;
        RECT orig = p->rgrc[0];
        LRESULT res = DefSubclassProc(hwnd, msg, wp, lp);
        RECT curr = p->rgrc[0];
        w->ncDx = RectDx(orig) - RectDx(curr);
        w->ncDy = RectDy(orig) - RectDy(curr);
        return res;
    }

    return DefSubclassProc(hwnd, msg, wp, lp);
}
コード例 #2
0
ファイル: LoadPict.cpp プロジェクト: kjk/kjkpub
void RootWindow::DrawPict(HDC hdc)
{
    RECT    clientRc;
    long    picDx, picDy;
    int     winDx, winDy;
    HDC     dcTmp = NULL;
    HBITMAP bmpTmp = NULL;
    HBITMAP bmpOld = NULL;

    if (NULL == g_pic)
        return;

    GetClientRect(m_hwnd, &clientRc);
    winDx = RectDx(&clientRc);
    winDy = RectDy(&clientRc);

    g_pic->get_Width(&picDx);
    g_pic->get_Height(&picDy);

    dcTmp = CreateCompatibleDC(hdc);
    if (NULL == dcTmp)
        return;

    bmpTmp = CreateCompatibleBitmap(hdc, winDx, winDy);
    if (NULL == bmpTmp)
        goto Exit;
    bmpOld = (HBITMAP)SelectObject(dcTmp, bmpTmp);

    HDC dcToDraw = dcTmp;

    FillRectangle(dcToDraw, 0, 0, RectDx(&clientRc), RectDy(&clientRc), COL_WHITE);

    if (m_fPictHasBorder)
    {
        RECT tmpRc = { 0 };
        tmpRc.left = m_pictPosX - BORDER_PIXEL_SIZE;
        tmpRc.top  = m_pictPosY - BORDER_PIXEL_SIZE;
        tmpRc.right = tmpRc.left + m_pictPixelDx + 2*BORDER_PIXEL_SIZE;
        tmpRc.bottom = tmpRc.top + m_pictPixelDy + 2*BORDER_PIXEL_SIZE;
        FillRectangle(dcToDraw, &tmpRc, COL_RED);
    }

    g_pic->Render(dcToDraw, 
                  m_pictPosX, m_pictPosY, 
                  m_pictPixelDx, m_pictPixelDy,
                  0, picDy, 
                  picDx, -picDy, NULL);

    BitBlt(hdc, 0, 0, winDx, winDy, dcToDraw, 0, 0, SRCCOPY);

    SelectObject(dcTmp, bmpOld);

Exit:
    if (NULL != bmpTmp)
        DeleteObject(bmpTmp);
    if (NULL != dcTmp)
        DeleteDC(dcTmp);
}
コード例 #3
0
ファイル: LoadPict.cpp プロジェクト: kjk/kjkpub
void RootWindow::DrawPictCentered(HDC hdc)
{
    RECT    clientRc;
    int     winDx, winDy;

    if (NULL == g_pic)
        return;

    GetClientRect(m_hwnd, &clientRc);
    winDx = RectDx(&clientRc);
    winDy = RectDy(&clientRc);

    m_pictPosX = 0;
    if (winDx > m_pictPixelDx)
        m_pictPosX = (winDx - m_pictPixelDx) / 2;

    m_pictPosY = 0;
    if (winDy > m_pictPixelDy)
        m_pictPosY = (winDy - m_pictPixelDy) / 2;

    m_count = 0;
    m_direction = AnimDirRight;

    DrawPict(hdc);
}
コード例 #4
0
ファイル: UIPanel.cpp プロジェクト: NeomMob/directui
SIZE TextPanelUI::EstimateSize(SIZE szAvailable)
{
    RECT rcText = { 0, 0, MAX(szAvailable.cx, m_cxWidth), 9999 };
    m_nLinks = 0;
    BlueRenderEngineUI::DoPaintPrettyText(m_mgr->GetPaintDC(), m_mgr, rcText, m_txt, UICOLOR_EDIT_TEXT_NORMAL, UICOLOR__INVALID, NULL, m_nLinks, DT_CALCRECT | m_uTextStyle);
    return CSize(RectDx(rcText), RectDy(rcText));
}
コード例 #5
0
ファイル: UIPanel.cpp プロジェクト: NeomMob/directui
void TaskPanelUI::DoPaint(HDC hDC, const RECT& rcPaint)
{
    // Handling gracefull fading of panel
    if (m_hFadeBitmap != NULL)  {
        DWORD dwTimeDiff = ::timeGetTime() - m_dwFadeTick;
        TPostPaintUI job;
        job.rc = m_rcFade;
        job.hBitmap = m_hFadeBitmap;
        job.iAlpha = (BYTE) CLAMP(255 - (long)(dwTimeDiff / (FADE_DELAY / 255.0)), 0, 255);
        m_mgr->AddPostPaintBlit(job);
    }
    // A tiny panel (see explaination in EstimateSize()) is invisible
    if (RectDx(m_rcItem) < 2) return;
    // Paint caption
    int cyFont = m_mgr->GetThemeFontInfo(UIFONT_NORMAL).tmHeight;
    RECT rcArc = { m_rcItem.left, m_rcItem.top, m_rcItem.right, m_rcItem.top + cyFont + 6 };
    BlueRenderEngineUI::DoPaintArcCaption(hDC, m_mgr, rcArc, m_txt, UIARC_GRIPPER);
    // Paint background
    RECT rcClient = { m_rcItem.left, rcArc.bottom, m_rcItem.right, m_rcItem.bottom };
    COLORREF clrFirst, clrSecond;
    m_mgr->GetThemeColorPair(UICOLOR_TASK_BACKGROUND, clrFirst, clrSecond);
    BlueRenderEngineUI::DoPaintGradient(hDC, m_mgr, rcClient, clrFirst, clrSecond, false, 128);
    BlueRenderEngineUI::DoPaintFrame(hDC, m_mgr, rcClient, UICOLOR_TASK_CAPTION, UICOLOR_TASK_CAPTION, UICOLOR__INVALID, 0);
    // Paint elements
    VerticalLayoutUI::DoPaint(hDC, rcPaint);
}
コード例 #6
0
ファイル: WinUtil.cpp プロジェクト: RazvanB/sumatrapdf
void ResizeHwndToClientArea(HWND hwnd, int dx, int dy, bool hasMenu)
{
    WINDOWINFO wi = { 0 };
    wi.cbSize = sizeof(wi);
    GetWindowInfo(hwnd, &wi);

    RECT r = { 0 };
    r.right = dx; r.bottom = dy;
    DWORD style = wi.dwStyle;
    DWORD exStyle = wi.dwExStyle;
    AdjustWindowRectEx(&r, style, hasMenu, exStyle);
    if ((dx == RectDx(wi.rcClient)) && (dy == RectDy(wi.rcClient)))
        return;

    dx = RectDx(r); dy = RectDy(r);
    int x = wi.rcWindow.left;
    int y = wi.rcWindow.top;
    MoveWindow(hwnd, x, y, dx, dy, TRUE);
}
コード例 #7
0
ファイル: UITab.cpp プロジェクト: NeomMob/directui
void TabFolderUI::DoPaint(HDC hDC, const RECT& rcPaint)
{
    {
        RenderClip clip;
        BlueRenderEngineUI::GenerateClip(hDC, rcPaint, clip);

        // Fill client area background
        RECT rcFill = { 0 };
        ::IntersectRect(&rcFill, &rcPaint, &m_rcClient);
        BlueRenderEngineUI::DoFillRect(hDC, m_mgr, rcFill, UICOLOR_TAB_BACKGROUND_NORMAL);

        // Frame around client area
        BlueRenderEngineUI::DoPaintRectangle(hDC, m_mgr, m_rcClient, UICOLOR_TAB_BORDER, UICOLOR__INVALID);

        // Paint tab strip
        RECT rcTabs = m_rcItem;
        rcTabs.left += m_rcInset.left;
        rcTabs.top += m_rcInset.top;
        rcTabs.right -= m_rcInset.right;
        rcTabs.bottom = m_rcClient.top;
        RECT rcTemp = { 0 };
        if (::IntersectRect(&rcTemp, &rcPaint, &rcTabs))  
        {
            int posX = 1;
            m_tabAreas.Empty();
            for (int i = 0; i < GetCount(); i++)  
            {
                const ControlUI* page = GetItem(i);
                const char *txt = page->GetText();
                RECT rcTab = { rcTabs.left + posX, rcTabs.top, rcTabs.right, m_rcClient.top };
                UINT uState = 0;
                if (IsFocused())  uState |= UISTATE_FOCUSED;
                if (!IsEnabled())  uState |= UISTATE_DISABLED;
                if (m_curSel == i)  uState = UISTATE_PUSHED;
                BlueRenderEngineUI::DoPaintTabFolder(hDC, m_mgr, rcTab, txt, uState);
                posX += RectDx(rcTab) + 2;
                m_tabAreas.Add(&rcTab);
            }
        }
    }

    if (m_curPage != NULL)  m_curPage->DoPaint(hDC, rcPaint);
}
コード例 #8
0
ファイル: EditCtrl.cpp プロジェクト: kepazon/my_sumatrapdf
bool CreateEditCtrl(EditCtrl *w) {
    // Note: has to remember this here because when I GetWindowStyle() later on,
    // WS_BORDER is not set, which is a mystery, because it is being drawn.
    // also, WS_BORDER seems to be painted in client areay
    w->hasBorder = bit::IsMaskSet<DWORD>(w->dwStyle, WS_BORDER);

    RECT rc = w->initialPos;
    w->hwnd = CreateWindowExW(w->dwExStyle, WC_EDIT, L"", w->dwStyle, rc.left, rc.top, RectDx(rc),
                              RectDy(rc), w->parent, nullptr, GetModuleHandleW(nullptr), nullptr);

    if (!w->hwnd) {
        return false;
    }
    SetFont(w, GetDefaultGuiFont());
    SetWindowSubclass(w->hwnd, EditProc, 0, (DWORD_PTR)w);
    SetWindowSubclass(GetParent(w->hwnd), EditParentProc, 0, (DWORD_PTR)w);
    return true;
}
コード例 #9
0
ファイル: TreeCtrl.cpp プロジェクト: jingyu9575/sumatrapdf
bool TreeCtrl::Create(const WCHAR* title) {
    if (!title) {
        title = L"";
    }

    RECT rc = this->initialPos;
    HMODULE hmod = GetModuleHandleW(nullptr);
    this->hwnd = CreateWindowExW(this->dwExStyle, WC_TREEVIEWW, title, this->dwStyle, rc.left, rc.top, RectDx(rc),
                                 RectDy(rc), this->parent, this->menu, hmod, nullptr);
    if (!this->hwnd) {
        return false;
    }
    TreeView_SetUnicodeFormat(this->hwnd, true);
    this->SetFont(GetDefaultGuiFont());
    Subclass(this);

    return true;
}