예제 #1
0
static void FadeCtrl_CalcRect(HDC hdc, LPRECT lprcTo, LPRECT lprcIn, LPCTSTR pszString)
{
    int nLines = String_CountSubChars(pszString, _T('\n')) + 1;
    TEXTMETRIC tm;

    GetTextMetrics(hdc, &tm);

    lprcTo->top     = (Rect_Height(&*lprcIn) / 2) - ((tm.tmHeight * nLines) / 2);
    lprcTo->bottom  = (Rect_Height(&*lprcIn) / 2) + ((tm.tmHeight * nLines) / 2);
    lprcTo->left    = lprcIn->left;
    lprcTo->right   = lprcIn->right;
}
예제 #2
0
void Rect_Copy(Rect *r, Rect const *other)
{
    DENG_ASSERT(r);
    if(!other) return;
    Point2_SetXY(r->origin, Rect_X(other), Rect_Y(other));
    Size2_SetWidthHeight(r->size, Rect_Width(other), Rect_Height(other));
}
예제 #3
0
파일: sub_pcp_hex.c 프로젝트: now/slackedit
void HexEdit_Create(HWND hwndOwner, LPTSTR pszFile)
{
    HWND hwndEdit;
    RECT rc;

    GetClientRect(hwndOwner, &rc);

    hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, WC_HEXEDIT, _T(""),
                WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPED,
                0, 0, Rect_Width(&rc), Rect_Height(&rc),
                hwndOwner, (HMENU)IDC_EDIT_MDICHILD, g_hInstance, pszFile);

    ASSERT(hwndEdit != NULL);

//  lpfnOldWndProc = SubclassWindow(hwndEdit, HexEdit_WndProc);
}
예제 #4
0
파일: dlg_find.c 프로젝트: now/slackedit
void Find_ChangeMode(HWND hwnd, BOOL bReplace)
{
    if (bReplace)
    {
        RECT rCancel, rHelp, rReplace, rReplaceAll;
        HWND hwndCancel, hwndHelp, hwndReplace, hwndReplaceAll;
        POINT p;

        hwndCancel      = GetDlgItem(hwnd, IDCANCEL);
        hwndHelp        = GetDlgItem(hwnd, IDC_BUTTON_HELP);
        hwndReplace     = GetDlgItem(hwnd, IDC_BUTTON_REPLACE);
        hwndReplaceAll  = GetDlgItem(hwnd, IDC_BUTTON_REPLACEALL);

        GetWindowRect(hwndCancel, &rCancel);
        GetWindowRect(hwndHelp, &rHelp);
        GetWindowRect(hwndReplace, &rReplace);
        GetWindowRect(hwndReplaceAll, &rReplaceAll);

        p.x = rCancel.left;
        p.y = rCancel.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndReplace, 0, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        p.x = rHelp.left;
        p.y = rHelp.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndReplaceAll, 0, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        p.x = rReplace.left;
        p.y = rReplace.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndCancel, 0, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        p.x = rReplaceAll.left;
        p.y = rReplaceAll.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndHelp, 0, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        if (g_WindowSettings.bReplaceCentered)
        {
            Window_CenterWindow(hwnd);
        }
        else
        {
            SetWindowPos(hwnd, 0, g_WindowSettings.nReplaceXPos, g_WindowSettings.nReplaceYPos,
                    0, 0, SWP_NOZORDER | SWP_NOSIZE);
        }

        Window_EnableDlgItem(hwnd, IDC_COMBO_REPLACE, TRUE);

        SetDlgItemText(hwnd, IDC_DIRECTION, _T("Context"));
        SetDlgItemText(hwnd, IDC_RADIO_DIRECTION_UP, _T("&Selection"));
        SetDlgItemText(hwnd, IDC_RADIO_DIRECTION_DOWN, _T("Wh&ole File"));
    }
    else
    {
        HWND hwndReplace, hwndReplaceAll, hwndReplaceTxt, hwndReplaceLbl;
        HWND hwndWholeWord, hwndCase, hwndRegExp, hwndDirection, hwndUp,
            hwndDown;
        HWND hwndWrapSearch;
        RECT r;
        POINT p;

        hwndReplace         = GetDlgItem(hwnd, IDC_BUTTON_REPLACE);
        hwndReplaceAll      = GetDlgItem(hwnd, IDC_BUTTON_REPLACEALL);
        hwndReplaceTxt      = GetDlgItem(hwnd, IDC_COMBO_REPLACE);
        hwndReplaceLbl      = GetDlgItem(hwnd, IDC_LABEL_REPLACE);

        hwndWholeWord       = GetDlgItem(hwnd, IDC_CHECK_WHOLEWORD);
        hwndCase            = GetDlgItem(hwnd, IDC_CHECK_MATCHCASE);
        hwndRegExp          = GetDlgItem(hwnd, IDC_CHECK_REGEXP);
        hwndWrapSearch      = GetDlgItem(hwnd, IDC_CHECK_WRAPSEARCH);
        hwndDirection       = GetDlgItem(hwnd, IDC_DIRECTION);
        hwndUp              = GetDlgItem(hwnd, IDC_RADIO_DIRECTION_UP);
        hwndDown            = GetDlgItem(hwnd, IDC_RADIO_DIRECTION_DOWN);

        ShowWindow(hwndReplace,    SW_HIDE);
        ShowWindow(hwndReplaceAll, SW_HIDE);
        ShowWindow(hwndReplaceTxt, SW_HIDE);
        ShowWindow(hwndReplaceLbl, SW_HIDE);

        GetWindowRect(hwndReplaceLbl, &r);
        p.x = r.left;
        p.y = r.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndWholeWord, 0, p.x, p.y + 10, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndWholeWord, &r);
        p.x = r.left;
        p.y = r.bottom;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndCase, 0, p.x, p.y + 3, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndCase, &r);
        p.x = r.left;
        p.y = r.bottom;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndRegExp, 0, p.x, p.y + 3, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndRegExp, &r);
        p.x = r.left;
        p.y = r.bottom;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndWrapSearch, 0, p.x, p.y + 3, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndWholeWord, &r);
        p.x = r.right;
        p.y = r.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndDirection, 0, p.x + 30, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndDirection, &r);
        p.x = r.left;
        p.y = r.top;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndUp, 0, p.x + 9, p.y + 16, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndUp, &r);
        p.x = r.left;
        p.y = r.bottom;
        ScreenToClient(hwnd, &p);
        SetWindowPos(hwndDown, 0, p.x, p.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

        GetWindowRect(hwndReplaceTxt, &r);
        p.y = Rect_Height(&r);
        GetWindowRect(hwnd, &r);

        SetWindowPos(hwnd, 0, g_WindowSettings.nFindXPos, g_WindowSettings.nFindYPos,
            Rect_Width(&r), Rect_Height(&r) - (p.y + 4), SWP_NOZORDER);
        
        if (g_WindowSettings.bFindCentered)
            Window_CenterWindow(hwnd);
    }
}
예제 #5
0
static DWORD WINAPI FadeCtrl_ThreadProc(LPVOID lpParameter)
{
    MSG msg;
    LPFADECTRL lpfc = (LPFADECTRL)lpParameter;

    if (List_GetNodeCount(lpfc->pPageList) == 0)
        return (0);

    while (TRUE)
    {
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
            {
                break;
            }
            else
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
        else if ((GetTickCount() - lpfc->dwCounter) > 75)
        {
            HDC hdcWin;
            HDC hdcMem;
            HBITMAP hBitmap;
            HBITMAP hOldBitmap;
            LOGFONT lf;
            HFONT hFont, hOldFont;
            LOGBRUSH lb;
            HBRUSH hBrush;

            hdcWin = GetDC(lpfc->hwnd);
            hdcMem = CreateCompatibleDC(hdcWin);

            hBitmap = CreateCompatibleBitmap(hdcWin, Rect_Width(&lpfc->rc), Rect_Height(&lpfc->rc));

            INITSTRUCT(lf, FALSE);
            lf.lfHeight         = -11;
            lf.lfCharSet        = OEM_CHARSET;
            lf.lfPitchAndFamily = FIXED_PITCH;
            _tcscpy(lf.lfFaceName, _T("Verdana Console"));

            hFont       = CreateFontIndirect(&lf);
            hOldFont    = SelectObject(hdcMem, hFont);

            if (lpfc->pfcCurrentPage == NULL)
            {
                lpfc->pfcCurrentPage    = ((PFADECTRLPAGE)List_GetNode(lpfc->pPageList, 0)->pData);

                if (lpfc->pfcCurrentPage == NULL)
                    break; // Not good...some fuck0 has passed us a shit text resource

                FadeCtrl_CalcRect(hdcMem, &lpfc->pfcCurrentPage->rcText, &lpfc->rc, lpfc->pfcCurrentPage->pszPageText);
            }

            if (lpfc->pfcCurrentPage->nCurrentWaitTime == 0)
            {
                if (lpfc->bFadingIn)
                    lpfc->pfcCurrentPage->crCurrent = FadeCtrl_GetColor(lpfc->pfcCurrentPage->crFadeTo, lpfc->pfcCurrentPage->crBackground, lpfc->pfcCurrentPage->nCurrentPercentage);
                else
                    lpfc->pfcCurrentPage->crCurrent = FadeCtrl_GetColor(lpfc->pfcCurrentPage->crBackground, lpfc->pfcCurrentPage->crFadeTo, lpfc->pfcCurrentPage->nCurrentPercentage);

                if (lpfc->bFadingIn && lpfc->pfcCurrentPage->nCurrentPercentage == lpfc->pfcCurrentPage->nFadePercent)
                {
                    lpfc->bFadingIn = FALSE;
                    lpfc->pfcCurrentPage->nCurrentPercentage = 0;
                    lpfc->pfcCurrentPage->nCurrentWaitTime = lpfc->pfcCurrentPage->nFadeOutWaitTime;
                }
                else if (!lpfc->bFadingIn && lpfc->pfcCurrentPage->nCurrentPercentage == lpfc->pfcCurrentPage->nFadePercent)
                {
                    PFADECTRLPAGE pfcPage;

                    lpfc->bFadingIn = TRUE;

                    pfcPage = ((PFADECTRLPAGE)List_NextNode(List_FindNode(lpfc->pPageList, lpfc->pfcCurrentPage, 0), 1)->pData);

                    if (pfcPage == lpfc->pfcCurrentPage)
                        lpfc->pfcCurrentPage = ((PFADECTRLPAGE)List_GetNode(lpfc->pPageList, 0)->pData);
                    else
                        lpfc->pfcCurrentPage = pfcPage;

                    if (lpfc->pfcCurrentPage == NULL)
                        break;

                    lpfc->pfcCurrentPage->nCurrentPercentage = 0;
                    lpfc->pfcCurrentPage->nCurrentWaitTime = lpfc->pfcCurrentPage->nFadeInWaitTime;

                    FadeCtrl_CalcRect(hdcMem, &lpfc->pfcCurrentPage->rcText, &lpfc->rc, lpfc->pfcCurrentPage->pszPageText);
                }
                else
                {
                    lpfc->pfcCurrentPage->nCurrentPercentage += lpfc->pfcCurrentPage->nPercentageDelta;
                }
            }
            else
            {
                // Setable decrement ? why ? 
                lpfc->pfcCurrentPage->nCurrentWaitTime -= 50;
            }

            SetBkColor(hdcMem, lpfc->pfcCurrentPage->crBackground);
            SetTextColor(hdcMem, lpfc->pfcCurrentPage->crCurrent);

            hOldBitmap = SelectObject(hdcMem, hBitmap);

            lb.lbColor  = lpfc->pfcCurrentPage->crBackground;
            lb.lbStyle  = BS_SOLID;

            FillRect(hdcMem, &lpfc->rc, (hBrush = CreateBrushIndirect(&lb)));
            DrawText(hdcMem, lpfc->pfcCurrentPage->pszPageText, -1, &lpfc->pfcCurrentPage->rcText, DT_CENTER);

            BitBlt(hdcWin, 0, 0, Rect_Width(&lpfc->rc), Rect_Height(&lpfc->rc), hdcMem, 0, 0, SRCCOPY);

            DeleteObject(SelectObject(hdcMem, hOldFont));
            DeleteObject(SelectObject(hdcMem, hOldBitmap));
            DeleteObject(hBrush);
            DeleteDC(hdcMem);
            ReleaseDC(lpfc->hwnd, hdcWin);

            lpfc->dwCounter = GetTickCount();
        }

        if (lpfc->bActive == FALSE)
            break;
    }

    return (0);
}
예제 #6
0
static void TipOfDay_DoPaint(HWND hwnd, HDC hdc, BOOL bUpdateTextOnly)
{
    RECT rcTip, rcSeperator, rcDidYou, rcBulb, rc = s_rcDraw;
    HBRUSH hBrush;
    HWND hwndStatic;
    HFONT hDidYouFont, hTipFont, hOldFont;
    TCHAR szDidYou[32];
    HANDLE hOldHandle;
    COLORREF crOldBackground;

    hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);

    hwndStatic = GetDlgItem(hwnd, IDC_TXT_TIPSTRING);
    GetWindowRect(hwndStatic, &rcTip);
    Window_ScreenToClientRect(hwnd, &rcTip);

    hwndStatic = GetDlgItem(hwnd, IDC_BMP_BULB);
    GetWindowRect(hwndStatic, &rcBulb);

    crOldBackground = SetBkColor(hdc, GetSysColor(COLOR_WINDOW));

    if (!bUpdateTextOnly)
    {
        HBRUSH hBrushShadow = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
        HBRUSH hOldBrush;
        HDC hdcMem;
        HBITMAP hOldBitmap;
        BITMAP bm;

        Paint_Draw3DRect(hdc, &rc, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNSHADOW), 1);
        InflateRect(&rc, -1, -1);
        Paint_FillRect(hdc, &rc, GetSysColor(COLOR_WINDOW));
        
        rcSeperator = rc;

        rc.right = rcTip.left - 10;
        Paint_FillRect(hdc, &rc, GetSysColor(COLOR_BTNSHADOW));

        GetObject(s_hBulbBitmap, sizeof(BITMAP), &bm);

        Window_ScreenToClientRect(hwnd, &rcBulb);
        hdcMem = CreateCompatibleDC(hdc);
        hOldBitmap      = SelectObject(hdcMem, s_hBulbBitmap);
        rcBulb.bottom   = rcBulb.top + bm.bmHeight;
        rcBulb.right    = rcBulb.left + bm.bmWidth;
        hOldBrush       = SelectObject(hdcMem, hBrushShadow);
        ExtFloodFill(hdcMem, 0, 0, RGB(255, 255, 255), FLOODFILLSURFACE);
        BitBlt(hdc, rcBulb.left, rcBulb.top, Rect_Width(&rcBulb), Rect_Height(&rcBulb),
                hdcMem, 0, 0, SRCCOPY);

        SelectObject(hdcMem, hOldBitmap);
        DeleteObject(SelectObject(hdcMem, hOldBrush));
        DeleteDC(hdcMem);

        rcSeperator.top     = rcBulb.bottom + 6;
        rcSeperator.bottom  = rcSeperator.top + 1;

        Paint_FillRect(hdc, &rcSeperator, GetSysColor(COLOR_BTNSHADOW));
    }

    hDidYouFont = CreateFont(22, 0, 0, 0, FW_BOLD, 0, 0, 0,
                            DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_SWISS, _T("Times"));

    hTipFont    = CreateFont(16, 0, 0, 0, FW_NORMAL, 0, 0, 0,
                            DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                            DEFAULT_PITCH | FF_SWISS, _T("Arial"));

    hOldFont = SelectObject(hdc, hDidYouFont);
    hOldHandle = String_SetResourceHandle(PCPControls_GetHandle());
    _tcsncpy(szDidYou, String_LoadString(IDS_TIP_DIDYOU), sizeof(szDidYou));
    String_SetResourceHandle(hOldHandle);
    rcDidYou        = rcTip;
    rcDidYou.top    = rcBulb.top;
    DrawText(hdc, szDidYou, -1, &rcDidYou, DT_SINGLELINE);

    SelectObject(hdc, hTipFont);
    Paint_FillRect(hdc, &rcTip, GetSysColor(COLOR_WINDOW));
    DrawText(hdc, s_szCurrentTip, -1, &rcTip, DT_WORDBREAK);
    SelectObject(hdc, hOldFont);
    SetBkColor(hdc, crOldBackground);
    DeleteObject(hDidYouFont);
    DeleteObject(hTipFont);
}